diff --git a/feeds/ipq807x/qca-nss-drv/patches/200-napi_threaded.patch b/feeds/ipq807x/qca-nss-drv/200-napi_threaded.patch similarity index 100% rename from feeds/ipq807x/qca-nss-drv/patches/200-napi_threaded.patch rename to feeds/ipq807x/qca-nss-drv/200-napi_threaded.patch diff --git a/feeds/ipq807x/qca-nss-drv/Makefile b/feeds/ipq807x/qca-nss-drv/Makefile index 71d73b564..4c3f89f35 100644 --- a/feeds/ipq807x/qca-nss-drv/Makefile +++ b/feeds/ipq807x/qca-nss-drv/Makefile @@ -2,8 +2,17 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=qca-nss-drv +PKG_SOURCE_PROTO:=git PKG_BRANCH:=master PKG_RELEASE:=2 +PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/nss-drv +PKG_MIRROR_HASH:=350af8f6b1f06ea0871314783a5362483963bbe327ba774ba49a2a775847363e +PKG_VERSION:=7563fe37340ec4a28b7821a0ac17608ff30e2a85 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=$(PKG_VERSION) + NSS_CLIENTS_DIR:=$(TOPDIR)/qca/src/qca-nss-clients @@ -105,6 +114,7 @@ define Build/Compile ARCH="$(LINUX_KARCH)" \ M="$(PKG_BUILD_DIR)" \ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" SoC="$(subtarget)" \ + KBUILD_MODPOST_WARN=1 \ modules endef diff --git a/feeds/ipq807x/qca-nss-drv/src/Makefile b/feeds/ipq807x/qca-nss-drv/src/Makefile deleted file mode 100644 index f5c4b9040..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/Makefile +++ /dev/null @@ -1,537 +0,0 @@ -# ################################################### -# # Makefile for the NSS driver -# ################################################### - -obj-m += qca-nss-drv.o - -# -# List the files that belong to the driver in alphabetical order. -# -qca-nss-drv-objs := \ - nss_cmn.o \ - nss_core.o \ - nss_coredump.o \ - nss_drv_stats.o \ - nss_drv_strings.o \ - 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_if_log.o \ - nss_init.o \ - nss_ipv4.o \ - nss_ipv4_stats.o \ - nss_ipv4_strings.o \ - nss_ipv4_log.o \ - nss_log.o \ - nss_lso_rx.o \ - nss_lso_rx_stats.o \ - nss_lso_rx_strings.o \ - nss_meminfo.o \ - nss_n2h.o \ - nss_n2h_stats.o \ - nss_n2h_strings.o \ - nss_phys_if.o \ - nss_pm.o \ - nss_profiler.o \ - nss_project.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_unaligned.o \ - nss_unaligned_log.o \ - nss_unaligned_stats.o \ - nss_virt_if.o \ - nss_virt_if_stats.o \ - nss_vlan.o \ - nss_vlan_log.o \ - 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 - -# 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_BRIDGE_ENABLE)" "n" -ccflags-y += -DNSS_DRV_BRIDGE_ENABLE -qca-nss-drv-objs += \ - nss_bridge.o \ - nss_bridge_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_MESH_ENABLE)" "n" -ccflags-y += -DNSS_DRV_WIFI_MESH_ENABLE -qca-nss-drv-objs += \ - nss_wifi_mesh.o \ - nss_wifi_mesh_log.o \ - nss_wifi_mesh_stats.o \ - nss_wifi_mesh_strings.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 -qca-nss-drv-objs += \ - nss_l2tpv2.o \ - nss_l2tpv2_log.o \ - nss_l2tpv2_stats.o \ - nss_l2tpv2_strings.o -endif - -ifneq "$(NSS_DRV_LAG_ENABLE)" "n" -ccflags-y += -DNSS_DRV_LAG_ENABLE -qca-nss-drv-objs += \ - nss_lag.o \ - nss_lag_log.o -endif - -ifneq "$(NSS_DRV_PVXLAN_ENABLE)" "n" -ccflags-y += -DNSS_DRV_PVXLAN_ENABLE -qca-nss-drv-objs += \ - nss_pvxlan.o \ - nss_pvxlan_log.o \ - nss_pvxlan_stats.o -endif - -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_tstamp.o \ - nss_tstamp_stats.o -endif - -ifneq "$(NSS_DRV_GRE_ENABLE)" "n" -ccflags-y += -DNSS_DRV_GRE_ENABLE -qca-nss-drv-objs += \ - nss_gre.o \ - nss_gre_log.o \ - nss_gre_stats.o \ - nss_gre_strings.o -endif - -ifneq "$(NSS_DRV_GRE_REDIR_ENABLE)" "n" -ccflags-y += -DNSS_DRV_GRE_REDIR_ENABLE -qca-nss-drv-objs += \ - nss_gre_redir.o \ - nss_gre_redir_log.o \ - 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 -endif - -ifneq "$(NSS_DRV_GRE_TUNNEL_ENABLE)" "n" -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 -endif - -ifneq "$(NSS_DRV_CAPWAP_ENABLE)" "n" -ccflags-y += -DNSS_DRV_CAPWAP_ENABLE -qca-nss-drv-objs += \ - nss_capwap.o \ - nss_capwap_log.o \ - nss_capwap_stats.o \ - nss_capwap_strings.o -endif - -ifneq "$(NSS_DRV_MAPT_ENABLE)" "n" -ccflags-y += -DNSS_DRV_MAPT_ENABLE -qca-nss-drv-objs += \ - nss_map_t.o \ - nss_map_t_log.o \ - nss_map_t_stats.o \ - nss_map_t_strings.o -endif - -ifneq "$(NSS_DRV_PPTP_ENABLE)" "n" -ccflags-y += -DNSS_DRV_PPTP_ENABLE -qca-nss-drv-objs += \ - nss_pptp.o \ - nss_pptp_log.o \ - nss_pptp_stats.o \ - nss_pptp_strings.o -endif - -ifneq "$(NSS_DRV_SHAPER_ENABLE)" "n" -ccflags-y += -DNSS_DRV_SHAPER_ENABLE -qca-nss-drv-objs += \ - nss_shaper.o -endif - -ifneq "$(NSS_DRV_SJACK_ENABLE)" "n" -ccflags-y += -DNSS_DRV_SJACK_ENABLE -qca-nss-drv-objs += \ - nss_sjack.o \ - nss_sjack_log.o \ - nss_sjack_stats.o -endif - -ifneq "$(NSS_DRV_TUN6RD_ENABLE)" "n" -ccflags-y += -DNSS_DRV_TUN6RD_ENABLE -qca-nss-drv-objs += \ - nss_tun6rd.o \ - nss_tun6rd_log.o -endif - -ifneq "$(NSS_DRV_TRUSTSEC_ENABLE)" "n" -ccflags-y += -DNSS_DRV_TRUSTSEC_ENABLE -qca-nss-drv-objs += \ - nss_trustsec_tx.o \ - nss_trustsec_tx_log.o \ - nss_trustsec_tx_stats.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 -endif - -ifneq "$(NSS_DRV_QRFS_ENABLE)" "n" -ccflags-y += -DNSS_DRV_QRFS_ENABLE -qca-nss-drv-objs += \ - nss_qrfs.o \ - nss_qrfs_log.o \ - nss_qrfs_stats.o -endif - -ifneq "$(NSS_DRV_RMNET_ENABLE)" "n" -ccflags-y += -DNSS_DRV_RMNET_ENABLE -qca-nss-drv-objs += \ - nss_rmnet_rx.o \ - nss_rmnet_rx_stats.o -endif - -ifneq "$(NSS_DRV_PORTID_ENABLE)" "n" -ccflags-y += -DNSS_DRV_PORTID_ENABLE -qca-nss-drv-objs += \ - nss_portid.o \ - nss_portid_log.o \ - nss_portid_stats.o -endif - -ifneq "$(NSS_DRV_IGS_ENABLE)" "n" -ccflags-y += -DNSS_DRV_IGS_ENABLE -qca-nss-drv-objs += \ - nss_igs.o \ - nss_igs_stats.o -endif - -ifneq "$(NSS_DRV_OAM_ENABLE)" "n" -ccflags-y += -DNSS_DRV_OAM_ENABLE -qca-nss-drv-objs += \ - nss_oam.o \ - nss_oam_log.o -endif - -ifneq "$(NSS_DRV_CLMAP_ENABLE)" "n" -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 -endif - - -ifneq "$(NSS_DRV_VXLAN_ENABLE)" "n" -ccflags-y += -DNSS_DRV_VXLAN_ENABLE -qca-nss-drv-objs += \ - nss_vxlan.o \ - nss_vxlan_log.o \ - nss_vxlan_stats.o -endif - -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 \ - nss_match_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 \ - 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 - -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 += \ - nss_ipsec_log.o \ - nss_ipsec.o -endif - -ifneq "$(NSS_DRV_CRYPTO_ENABLE)" "n" -ccflags-y += -DNSS_DRV_CRYPTO_ENABLE -qca-nss-drv-objs += \ - nss_crypto.o \ - nss_crypto_log.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 -endif -ccflags-y += -I$(obj)/nss_hal/ipq806x -DNSS_HAL_IPQ806X_SUPPORT -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 - -ccflags-y += -DNSS_DRV_PPE_ENABLE -ccflags-y += -DNSS_DRV_EDMA_ENABLE - -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 -endif - -ifneq "$(NSS_DRV_CRYPTO_ENABLE)" "n" -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 \ - nss_dma_strings.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 -endif - -ifneq "$(NSS_DRV_QVPN_ENABLE)" "n" -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 -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),ipq807x ipq807x_64)) -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 \ - 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.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 -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 -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 -endif -ccflags-y += -I$(obj)/nss_hal/ipq50xx -DNSS_HAL_IPQ50XX_SUPPORT -DNSS_MULTI_H2N_DATA_RING_SUPPORT -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 += -DNSS_PM_DEBUG_LEVEL=0 -DNSS_SKB_REUSE_SUPPORT=1 -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 -else -NSS_CCFLAGS = -DNSS_DT_SUPPORT=1 -DNSS_FW_DBG_SUPPORT=0 -DNSS_PM_SUPPORT=0 - -ccflags-y += -I$(obj) -endif - -# Fabric scaling is supported in 3.14 and 4.4 only -ifneq ($(findstring 3.14, $(KERNELVERSION)),) -NSS_CCFLAGS += -DNSS_FABRIC_SCALING_SUPPORT=1 -else ifneq ($(findstring 4.4, $(KERNELVERSION)),) -NSS_CCFLAGS += -DNSS_FABRIC_SCALING_SUPPORT=1 -else -NSS_CCFLAGS += -DNSS_FABRIC_SCALING_SUPPORT=0 -endif - -# Disable Frequency scaling -ifeq "$(NSS_FREQ_SCALE_DISABLE)" "y" -ccflags-y += -DNSS_FREQ_SCALE_SUPPORT=0 -else -qca-nss-drv-objs += \ - nss_freq.o \ - nss_freq_log.o \ - nss_freq_stats.o -ccflags-y += -DNSS_FREQ_SCALE_SUPPORT=1 -endif - -ccflags-y += $(NSS_CCFLAGS) - -export NSS_CCFLAGS - -obj ?= . diff --git a/feeds/ipq807x/qca-nss-drv/src/Makefile.fsm b/feeds/ipq807x/qca-nss-drv/src/Makefile.fsm deleted file mode 100644 index 93ca00725..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/Makefile.fsm +++ /dev/null @@ -1,123 +0,0 @@ -# ################################################### -# # Makefile for the NSS driver -# ################################################### -obj-m += qca-nss-drv.o - -# -# List the files that belong to the driver in alphabetical order. -# -qca-nss-drv-objs := \ - nss_bridge.o \ - nss_bridge_log.o \ - nss_capwap.o \ - nss_capwap_log.o \ - nss_capwap_stats.o \ - nss_cmn.o \ - nss_core.o \ - nss_coredump.o \ - nss_crypto.o \ - nss_crypto_log.o \ - nss_dtls.o \ - nss_dtls_log.o \ - nss_dtls_stats.o \ - nss_dynamic_interface.o \ - nss_dynamic_interface_log.o \ - nss_edma.o \ - nss_edma_stats.o \ - nss_eth_rx.o \ - nss_eth_rx_stats.o \ - nss_gre.o \ - nss_gre_log.o \ - nss_gre_stats.o \ - nss_gre_redir.o \ - nss_gre_redir_log.o \ - nss_gre_redir_stats.o \ - nss_gre_tunnel.o \ - 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 \ - nss_ipv4.o \ - nss_ipv4_stats.o \ - nss_ipv4_log.o \ - nss_ipv4_reasm.o \ - nss_ipv4_reasm_stats.o \ - nss_ipv6.o \ - nss_ipv6_stats.o \ - nss_ipv6_log.o \ - nss_ipv6_reasm.o \ - nss_ipv6_reasm_stats.o \ - nss_l2tpv2.o \ - nss_l2tpv2_log.o \ - nss_l2tpv2_stats.o \ - nss_lag.o \ - nss_lag_log.o \ - nss_log.o \ - nss_lso_rx.o \ - nss_lso_rx_stats.o \ - nss_map_t.o \ - nss_map_t_log.o \ - nss_map_t_stats.o \ - nss_n2h.o \ - nss_n2h_stats.o \ - nss_oam.o \ - nss_oam_log.o \ - nss_phys_if.o \ - nss_pm.o \ - nss_profiler.o \ - nss_portid.o \ - nss_portid_log.o \ - nss_portid_stats.o \ - nss_ppe.o \ - nss_ppe_log.o \ - nss_ppe_stats.o \ - nss_pppoe.o \ - nss_pppoe_log.o \ - nss_pppoe_stats.o \ - nss_pptp.o \ - nss_pptp_log.o \ - nss_pptp_stats.o \ - nss_rps.o \ - nss_shaper.o \ - nss_sjack.o \ - nss_sjack_log.o \ - nss_sjack_stats.o \ - nss_stats.o \ - nss_tstamp.o \ - nss_tstamp_stats.o \ - nss_tun6rd.o \ - nss_tun6rd_log.o \ - nss_trustsec_tx.o \ - nss_trustsec_tx_log.o \ - nss_trustsec_tx_stats.o \ - nss_tunipip6.o \ - nss_tunipip6_log.o \ - nss_unaligned.o \ - nss_unaligned_log.o \ - nss_unaligned_stats.o \ - nss_virt_if.o \ - nss_virt_if_stats.o \ - nss_vlan.o \ - nss_vlan_log.o \ - nss_wifi.o \ - nss_wifi_log.o \ - nss_wifi_stats.o \ - nss_wifi_if.o \ - nss_wifi_if_stats.o \ - nss_wifi_vdev.o - -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_common.o -qca-nss-drv-objs += nss_data_plane/nss_data_plane_gmac.o - -ccflags-y += -I$(obj)/nss_hal/include -ccflags-y += -I$(obj)/nss_data_plane/include -ccflags-y += -I$(obj)/exports -ccflags-y += -I$(obj)/nss_hal/fsm9010 -DNSS_HAL_FSM9010_SUPPORT -ccflags-y += -DNSS_DEBUG_LEVEL=0 -DNSS_PKT_STATS_ENABLED=1 -ccflags-y += -DNSS_DT_SUPPORT=1 -DNSS_PM_SUPPORT=0 -DNSS_FW_DBG_SUPPORT=0 -DNSS_SKB_REUSE_SUPPORT=0 -ccflags-y += -DNSS_PPP_SUPPORT=0 -DNSS_FREQ_SCALE_SUPPORT=0 -DNSS_FABRIC_SCALING_SUPPORT=0 diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_fsm9010.h b/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_fsm9010.h deleted file mode 100644 index 7e472907c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_fsm9010.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_fsm9010.h - * Architecture dependent parameters. - */ -#ifndef __NSS_FSM9010_H -#define __NSS_FSM9010_H - -/** - * @addtogroup nss_arch_macros_fsm9010 - * @{ - */ - -#define NSS_MAX_NUM_PRI 1 /**< Maximum number of priority queues in NSS. */ -#define NSS_HOST_CORES 4 /**< Number of host cores. */ - -#define NSS_N2H_RING_COUNT 3 /**< Number of N2H rings. */ -#define NSS_H2N_RING_COUNT 4 /**< Number of H2N rings. */ -#define NSS_RING_SIZE 128 /**< Ring size. */ - -#define NSS_IMEM_START 0xE4000000 /**< NSS IMEM start address. */ -#define NSS_IMEM_SIZE 0x10000 /**< NSS IMEM size. */ - -/** - * @} - */ - -#endif /** __NSS_FSM9010_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq40xx.h b/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq40xx.h deleted file mode 100644 index d6d335132..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq40xx.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipq40xx.h - * Architecture dependent parameters. - */ -#ifndef __NSS_IPQ40XX_H -#define __NSS_IPQ40XX_H - -/** - * @addtogroup nss_arch_macros_ipq40xx - * @{ - */ - -#define NSS_MAX_NUM_PRI 1 /**< Maximum number of priority queues in NSS. */ -#define NSS_HOST_CORES 4 /**< Number of host cores. */ - -#define NSS_N2H_RING_COUNT 0 /**< Number of N2H rings. */ -#define NSS_H2N_RING_COUNT 0 /**< Number of H2N rings. */ -#define NSS_RING_SIZE 128 /**< Ring size. */ - -#define NSS_IMEM_START 0x39000000 /**< NSS IMEM start address. */ -#define NSS_IMEM_SIZE 0x10000 /**< NSS IMEM size per core. */ - -/** - * @} - */ - -#endif /** __NSS_IPQ40XX_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq50xx.h b/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq50xx.h deleted file mode 100644 index e83649f81..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq50xx.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipq50xx.h - * Architecture dependent parameters. - */ -#ifndef __NSS_IPQ50XX_H -#define __NSS_IPQ50XX_H - -/** - * @addtogroup nss_arch_macros_ipq50xx - * @{ - */ - -#define NSS_MAX_NUM_PRI 4 /**< Maximum number of priority queues in NSS. */ -#define NSS_HOST_CORES 2 /**< Number of host cores. */ - -#define NSS_N2H_RING_COUNT 3 /**< Number of N2H rings. */ -#define NSS_H2N_RING_COUNT 7 /**< Number of H2N rings. */ -#define NSS_RING_SIZE 128 /**< Ring size. */ - -/** - * @} - */ - -#endif /** __NSS_IPQ50XX_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq50xx_64.h b/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq50xx_64.h deleted file mode 100644 index b756c5af7..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq50xx_64.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipq50xx_64.h - * Architecture dependent parameters. - */ -#ifndef __NSS_IPQ50XX_64_H -#define __NSS_IPQ50XX_64_H - -/** - * @addtogroup nss_arch_macros_ipq50xx_64 - * @{ - */ - -#define NSS_MAX_NUM_PRI 4 /**< Maximum number of priority queues in NSS. */ -#define NSS_HOST_CORES 2 /**< Number of host cores. */ - -#define NSS_N2H_RING_COUNT 3 /**< Number of N2H rings. */ -#define NSS_H2N_RING_COUNT 7 /**< Number of H2N rings. */ -#define NSS_RING_SIZE 128 /**< Ring size. */ - -/** - * @} - */ - -#endif /** __NSS_IPQ50XX_64_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq60xx.h b/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq60xx.h deleted file mode 100644 index bc0396a46..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq60xx.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipq60xx.h - * Architecture dependent parameters. - */ -#ifndef __NSS_IPQ60XX_H -#define __NSS_IPQ60XX_H - -/** - * @addtogroup nss_arch_macros_ipq60xx - * @{ - */ - -#define NSS_MAX_NUM_PRI 4 /**< Maximum number of priority queues in NSS. */ -#define NSS_HOST_CORES 4 /**< Number of host cores. */ -#define NSS_PPE_SUPPORTED /**< PPE supported flag. */ - -#define NSS_N2H_RING_COUNT 5 /**< Number of N2H rings. */ -#define NSS_H2N_RING_COUNT 11 /**< Number of H2N rings. */ -#define NSS_RING_SIZE 128 /**< Ring size. */ - -/** - * @} - */ - -#endif /** __NSS_IPQ60XX_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq60xx_64.h b/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq60xx_64.h deleted file mode 100644 index a0e5e9ea8..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq60xx_64.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipq60xx_64.h - * Architecture dependent parameters. - */ -#ifndef __NSS_IPQ60XX_64_H -#define __NSS_IPQ60XX_64_H - -/** - * @addtogroup nss_arch_macros_ipq60xx_64 - * @{ - */ - -#define NSS_MAX_NUM_PRI 4 /**< Maximum number of priority queues in NSS. */ -#define NSS_HOST_CORES 4 /**< Number of host cores. */ -#define NSS_PPE_SUPPORTED /**< PPE supported flag. */ - -#define NSS_N2H_RING_COUNT 5 /**< Number of N2H rings. */ -#define NSS_H2N_RING_COUNT 11 /**< Number of H2N rings. */ -#define NSS_RING_SIZE 128 /**< Ring size. */ - -/** - * @} - */ - -#endif /** __NSS_IPQ60XX_64_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq806x.h b/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq806x.h deleted file mode 100644 index 216f950ef..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq806x.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipq806x.h - * Architecture dependent parameters. - */ -#ifndef __NSS_IPQ806X_H -#define __NSS_IPQ806X_H - -/** - * @addtogroup nss_arch_macros_ipq806x - * @{ - */ - -#define NSS_MAX_NUM_PRI 4 /**< Maximum number of priority queues in NSS. */ -#define NSS_HOST_CORES 2 /**< Number of host cores. */ - -#define NSS_N2H_RING_COUNT 3 /**< Number of N2H rings. */ -#define NSS_H2N_RING_COUNT 4 /**< Number of H2N rings. */ -#define NSS_RING_SIZE 128 /**< Ring size. */ - -#define NSS_IMEM_START 0x39000000 /**< NSS IMEM start address. */ -#define NSS_IMEM_SIZE 0x10000 /**< NSS IMEM size per core. */ - -/** - * @} - */ - -#endif /** __NSS_IPQ806X_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq807x.h b/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq807x.h deleted file mode 100644 index c8fc26dc2..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq807x.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipq807x.h - * Architecture dependent parameters. - */ -#ifndef __NSS_IPQ807X_H -#define __NSS_IPQ807X_H - -/** - * @addtogroup nss_arch_macros_ipq807x - * @{ - */ - -#define NSS_MAX_NUM_PRI 4 /**< Maximum number of priority queues in NSS. */ -#define NSS_HOST_CORES 4 /**< Number of host cores. */ -#define NSS_PPE_SUPPORTED /**< PPE supported flag. */ - -#define NSS_N2H_RING_COUNT 5 /**< Number of N2H rings. */ -#define NSS_H2N_RING_COUNT 11 /**< Number of H2N rings. */ -#define NSS_RING_SIZE 128 /**< Ring size. */ - -#define NSS_IMEM_START 0x38000000 /**< NSS IMEM start address. */ -#define NSS_IMEM_SIZE 0x30000 /**< NSS IMEM size per core. */ - -/** - * @} - */ - -#endif /** __NSS_IPQ807X_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq807x_64.h b/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq807x_64.h deleted file mode 100644 index fec7aa538..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/arch/nss_ipq807x_64.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipq807x_64.h - * Architecture dependent parameters. - */ -#ifndef __NSS_IPQ807x_64_H -#define __NSS_IPQ807x_64_H - -/** - * @addtogroup nss_arch_macros_ipq807x_64 - * @{ - */ - -#define NSS_MAX_NUM_PRI 4 /**< Maximum number of priority queues in NSS. */ -#define NSS_HOST_CORES 4 /**< Number of host cores. */ -#define NSS_PPE_SUPPORTED /**< PPE supported flag. */ - -#define NSS_N2H_RING_COUNT 5 /**< Number of N2H rings. */ -#define NSS_H2N_RING_COUNT 11 /**< Number of H2N rings. */ -#define NSS_RING_SIZE 128 /**< Ring size. */ - -#define NSS_IMEM_START 0x38000000 /**< NSS IMEM start address. */ -#define NSS_IMEM_SIZE 0x30000 /**< NSS IMEM size per core. */ - -/** - * @} - */ - -#endif /** __NSS_IPQ807x_64_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_api_if.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_api_if.h deleted file mode 100755 index ddf6b7c68..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_api_if.h +++ /dev/null @@ -1,319 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_api_if.h - * NSS driver APIs and Declarations. - * - * This file declares all the public interfaces for NSS driver. - */ - -#ifndef __NSS_API_IF_H -#define __NSS_API_IF_H - -#ifdef __KERNEL__ /* only kernel will use. */ - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -#include -#include -#include -#include "nss_arch.h" -#include "nss_def.h" -#include "nss_cmn.h" -#include "nss_tun6rd.h" -#include "nss_l2tpv2.h" -#include "nss_pptp.h" -#include "nss_map_t.h" -#include "nss_tunipip6.h" -#include "nss_lag.h" -#include "nss_stats_public.h" -#include "nss_ipv4.h" -#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" -#include "nss_ipsec.h" -#include "nss_ipsec_cmn.h" -#include "nss_gre.h" -#include "nss_gre_redir.h" -#include "nss_gre_redir_lag.h" -#include "nss_gre_tunnel.h" -#include "nss_sjack.h" -#include "nss_capwap.h" -#include "nss_wifi.h" -#include "nss_wifi_vdev.h" -#include "nss_n2h.h" -#include "nss_rps.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_bridge.h" -#include "nss_ppe.h" -#include "nss_trustsec_tx.h" -#include "nss_vlan.h" -#include "nss_igs.h" -#include "nss_mirror.h" -#include "nss_wifili_if.h" -#include "nss_project.h" -#include "nss_qrfs.h" -#include "nss_c2c_tx.h" -#include "nss_qvpn.h" -#include "nss_unaligned.h" -#include "nss_pvxlan.h" -#include "nss_vxlan.h" -#include "nss_pm.h" -#include "nss_freq.h" -#include "nss_tstamp.h" -#include "nss_gre_redir_mark.h" -#include "nss_clmap.h" -#include "nss_rmnet_rx.h" -#include "nss_match.h" -#include "nss_eth_rx.h" -#include "nss_c2c_rx.h" -#include "nss_ipv6_reasm.h" -#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" -#endif - -#endif /*__KERNEL__ */ - -/** - * @addtogroup nss_driver_subsystem - * @{ - */ - -#define NSS_MAX_CORES 2 /**< Maximum number of core interfaces. */ - -#define NSS_MAX_DEVICE_INTERFACES (NSS_MAX_PHYSICAL_INTERFACES + NSS_MAX_VIRTUAL_INTERFACES + NSS_MAX_TUNNEL_INTERFACES + NSS_MAX_DYNAMIC_INTERFACES) - /**< Maximum number of device interfaces. */ - -#define NSS_MAX_NET_INTERFACES (NSS_MAX_DEVICE_INTERFACES + NSS_MAX_SPECIAL_INTERFACES) - /**< Maximum number of network interfaces. */ - -#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 69 /**< Maximum number of special interfaces. */ -#define NSS_MAX_WIFI_RADIO_INTERFACES 3 /**< Maximum number of radio interfaces. */ - -/* - * Start of individual interface groups - */ -#define NSS_PHYSICAL_IF_START 0 - /**< Beginning of the physical interfaces. */ - -#define NSS_VIRTUAL_IF_START (NSS_PHYSICAL_IF_START + NSS_MAX_PHYSICAL_INTERFACES) - /**< Beginning of the virtual interfaces. */ - -#define NSS_TUNNEL_IF_START (NSS_VIRTUAL_IF_START + NSS_MAX_VIRTUAL_INTERFACES) - /**< Beginning of the tunnel interfaces. */ - -#define NSS_DYNAMIC_IF_START (NSS_TUNNEL_IF_START + NSS_MAX_TUNNEL_INTERFACES) - /**< Beginning of the dynamic interfaces. */ - -#define NSS_SPECIAL_IF_START (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES) - /**< Beginning of the special interfaces. */ - -/* - * Tunnel interface numbers - */ -#define NSS_IPSEC_ENCAP_IF_NUMBER (NSS_TUNNEL_IF_START + 0) - /**< Tunnel interface number for IPsec encapsulation interfaces. */ -#define NSS_IPSEC_DECAP_IF_NUMBER (NSS_TUNNEL_IF_START + 1) - /**< Tunnel interface number for IPsec decapsulation interfaces. */ -#define NSS_TUN6RD_INTERFACE (NSS_TUNNEL_IF_START + 2) - /**< Tunnel interface number for TUN6RD interfaces. */ -#define NSS_TUNIPIP6_INTERFACE (NSS_TUNNEL_IF_START + 3) - /**< Tunnel interface number for TUNIPIP6 interfaces. */ - -/* - * Special interface numbers - */ -#define NSS_N2H_INTERFACE (NSS_SPECIAL_IF_START + 0) - /**< Special interface number for N2H. */ -#define NSS_ETH_RX_INTERFACE (NSS_SPECIAL_IF_START + 2) - /**< Special interface number for Ethernet Rx. */ -#define NSS_PPPOE_INTERFACE (NSS_SPECIAL_IF_START + 3) - /**< Special interface number for PPPoE. */ -#define NSS_IPV4_RX_INTERFACE (NSS_SPECIAL_IF_START + 5) - /**< Special interface number for IPv4. */ -#define NSS_IPV6_RX_INTERFACE (NSS_SPECIAL_IF_START + 7) - /**< Special interface number for IPv6. */ -#define NSS_PROFILER_INTERFACE (NSS_SPECIAL_IF_START + 8) - /**< Special interface number for profile. */ -#define NSS_CRYPTO_INTERFACE (NSS_SPECIAL_IF_START + 9) - /**< Special interface number for crypto CE5. */ -#define NSS_DTLS_INTERFACE (NSS_SPECIAL_IF_START + 10) - /**< Special interface number for DTLS. */ -#define NSS_CRYPTO_CMN_INTERFACE (NSS_SPECIAL_IF_START + 11) - /**< Special interface number for crypto common. */ -#define NSS_C2C_TX_INTERFACE (NSS_SPECIAL_IF_START + 12) - /**< Virtual interface number for core-to-core transmissions. */ -#define NSS_C2C_RX_INTERFACE (NSS_SPECIAL_IF_START + 13) - /**< Virtual interface number for core-to-core reception. */ -#define NSS_IPSEC_CMN_INTERFACE (NSS_SPECIAL_IF_START + 18) - /**< Virtual interface number for IPSec rule. */ -#define NSS_COREFREQ_INTERFACE (NSS_SPECIAL_IF_START + 19) - /**< Virtual interface number for core frequency. */ -#define NSS_DYNAMIC_INTERFACE (NSS_SPECIAL_IF_START + 20) - /**< Special interface number for dynamic interfaces. */ -#define NSS_GRE_REDIR_INTERFACE (NSS_SPECIAL_IF_START + 21) - /**< Special interface number for GRE redirect base interfaces. */ -#define NSS_LSO_RX_INTERFACE (NSS_SPECIAL_IF_START + 22) - /**< Special interface number for LSO. */ -#define NSS_SJACK_INTERFACE (NSS_SPECIAL_IF_START + 23) - /**< Special interface number for GRE REDIR base interfaces. */ -#define NSS_IPV4_REASM_INTERFACE (NSS_SPECIAL_IF_START + 24) - /**< Special interface number for IPv4 reassembly interfaces. */ -#define NSS_DEBUG_INTERFACE (NSS_SPECIAL_IF_START + 25) - /**< Special interface number for debug. */ -#define NSS_WIFI_INTERFACE0 (NSS_SPECIAL_IF_START + 26) - /**< Special interface number for Wi-Fi radio 0. */ -#define NSS_WIFI_INTERFACE1 (NSS_SPECIAL_IF_START + 27) - /**< Special interface number for Wi-Fi radio 1. */ -#define NSS_WIFI_INTERFACE2 (NSS_SPECIAL_IF_START + 28) - /**< Special interface number for Wi-Fi radio 2. */ -#define NSS_IPV6_REASM_INTERFACE (NSS_SPECIAL_IF_START + 29) - /**< Special interface number for IPv6 reassembly. */ -#define NSS_LAG0_INTERFACE_NUM (NSS_SPECIAL_IF_START + 30) - /**< Special interface number for LAG0. */ -#define NSS_LAG1_INTERFACE_NUM (NSS_SPECIAL_IF_START + 31) - /**< Special interface number for LAG1. */ -#define NSS_LAG2_INTERFACE_NUM (NSS_SPECIAL_IF_START + 32) - /**< Special interface number for LAG2. */ -#define NSS_LAG3_INTERFACE_NUM (NSS_SPECIAL_IF_START + 33) - /**< Special interface number for LAG3. */ -#define NSS_L2TPV2_INTERFACE (NSS_SPECIAL_IF_START + 34) - /**< Special interface number for L2TPv2 UDP encapsulation. */ -#define NSS_PPTP_INTERFACE (NSS_SPECIAL_IF_START + 36) - /**< Special interface number for PPTP-to-decapsulation. */ -#define NSS_PORTID_INTERFACE (NSS_SPECIAL_IF_START + 37) - /**< Special interface number for port ID. */ -#define NSS_OAM_INTERFACE (NSS_SPECIAL_IF_START + 38) - /**< Special interface number for OAM. */ -#define NSS_MAP_T_INTERFACE (NSS_SPECIAL_IF_START + 39) - /**< Special interface number for MAP-T. */ -#define NSS_PPE_INTERFACE (NSS_SPECIAL_IF_START + 40) - /**< Special interface number for PPE. */ -#define NSS_EDMA_INTERFACE (NSS_SPECIAL_IF_START + 41) - /**< Special interface number for EDMA. */ -#define NSS_GRE_TUNNEL_INTERFACE (NSS_SPECIAL_IF_START + 42) - /**< Special interface number for NSS GRE tunnel. */ -#define NSS_TRUSTSEC_TX_INTERFACE (NSS_SPECIAL_IF_START + 43) - /**< Special interface number for TrustSec Tx. */ -#define NSS_VAP_INTERFACE (NSS_SPECIAL_IF_START + 44) - /**< Special interface number for NSS Wi-Fi VAPs base interfaces. */ -#define NSS_VLAN_INTERFACE (NSS_SPECIAL_IF_START + 45) - /**< Special interface number for VLAN. */ -#define NSS_GRE_INTERFACE (NSS_SPECIAL_IF_START + 46) - /**< Special interface number for GRE. */ -#define NSS_WIFILI_INTERNAL_INTERFACE (NSS_SPECIAL_IF_START + 47) - /**< Special interface number for wifili internal instance. */ -#define NSS_PROJECT_INTERFACE (NSS_SPECIAL_IF_START + 48) - /**< Special interface number for project node. */ -#define NSS_PBUF_MGR_FREE_INTERFACE (NSS_SPECIAL_IF_START + 49) - /**< Special interface number for PBUF_MGR_FREE node. */ -#define NSS_REDIR_RX_INTERFACE (NSS_SPECIAL_IF_START + 50) - /**< Special interface number for 802.3 redirect node. */ -#define NSS_QRFS_INTERFACE (NSS_SPECIAL_IF_START + 51) - /**< Special interface number for QRFS. */ -#define NSS_GRE_REDIR_LAG_INTERFACE (NSS_SPECIAL_IF_START + 52) - /**< Special interface number for GRE redirect link aggregation interface. */ -#define NSS_UNALIGNED_INTERFACE (NSS_SPECIAL_IF_START + 53) - /**< Special interface number for unaligned handler. */ -#define NSS_TSTAMP_TX_INTERFACE (NSS_SPECIAL_IF_START + 54) - /**< Special interface number for timestamp transmit. */ -#define NSS_TSTAMP_RX_INTERFACE (NSS_SPECIAL_IF_START + 55) - /**< Special interface number for timestamp receive. */ -#define NSS_GRE_REDIR_MARK_INTERFACE (NSS_SPECIAL_IF_START + 56) - /**< Special interface number for GRE redirect mark. */ -#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) - /**< Special interface number for remote wireless wide area network receive handler. */ -#define NSS_WIFILI_EXTERNAL_INTERFACE0 (NSS_SPECIAL_IF_START + 59) - /**< Special interface number for first external radio instance. */ -#define NSS_WIFILI_EXTERNAL_INTERFACE1 (NSS_SPECIAL_IF_START + 60) - /**< Special interface number for second external radio instance. */ -#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 (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. */ -#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. */ - -#ifdef __KERNEL__ /* only kernel will use. */ - -/* - * General utilities - */ - -/** - * General callback function for all interface 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_if_rx_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * nss_get_state - * Gets the NSS state. - * - * @param[in] nss_ctx Pointer to the NSS context. - * - * @return - * NSS state. - */ -extern nss_state_t nss_get_state(void *nss_ctx); - -#endif /*__KERNEL__ */ - -/* - * Once Everything is arranged correctly, will be placed at top - */ - -/** - *@} - */ - -#endif /** __NSS_API_IF_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_bridge.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_bridge.h deleted file mode 100644 index 783696912..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_bridge.h +++ /dev/null @@ -1,362 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_bridge.h - * NSS Bridge interface definitions. - */ - -#ifndef __NSS_BRIDGE_H -#define __NSS_BRIDGE_H - -/** - * @addtogroup nss_bridge_subsystem - * @{ - */ - -/** - * nss_bridge_msg_types - * Message types for the NSS bridge. - */ -enum nss_bridge_msg_types { - NSS_BRIDGE_MSG_JOIN = NSS_IF_MAX_MSG_TYPES + 1, - NSS_BRIDGE_MSG_LEAVE, - NSS_BRIDGE_MSG_SET_FDB_LEARN, - NSS_BRIDGE_MSG_TYPE_MAX, -}; - -/** - * nss_bridge_error_types - * Error types for the NSS bridge. - */ -enum nss_bridge_error_types { - NSS_BRIDGE_ERROR_UNKNOWN_MSG = NSS_IF_ERROR_TYPE_MAX + 1, - NSS_BRIDGE_ERROR_TYPE_MAX, -}; - -/** - * nss_bridge_fdb_learn_mode - * FDB learning mode for the NSS bridge. - */ -enum nss_bridge_fdb_learn_mode { - NSS_BRIDGE_FDB_LEARN_ENABLE, - NSS_BRIDGE_FDB_LEARN_DISABLE, - NSS_BRIDGE_FDB_LEARN_MODE_MAX, -}; - -/** - * nss_bridge_join_msg - * Information for joining the bridge. - */ -struct nss_bridge_join_msg { - uint32_t if_num; /**< NSS interface to add to a bridge. */ -}; - -/** - * nss_bridge_leave_msg - * Information for leaving the bridge. - */ -struct nss_bridge_leave_msg { - uint32_t if_num; /**< NSS interface to remove from a bridge. */ -}; - -/** - * nss_bridge_set_fdb_learn_msg - * Information for FDB learning status on bridge interface. - */ -struct nss_bridge_set_fdb_learn_msg { - uint32_t mode; /**< FDB learning mode of bridge interface. */ -}; - -/** - * nss_bridge_msg - * Data for sending and receiving bridge interface messages. - */ -struct nss_bridge_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a bridge interface message. - */ - union { - union nss_if_msgs if_msg; - /**< NSS interface base message. */ - struct nss_bridge_join_msg br_join; - /**< Join the bridge. */ - struct nss_bridge_leave_msg br_leave; - /**< Leave the bridge. */ - struct nss_bridge_set_fdb_learn_msg fdb_learn; - /**< FDB learning status of bridge. */ - } msg; /**< Message payload. */ -}; - -/** - * nss_bridge_verify_if_num - * Verifies if the interface is type bridge. - * - * @param[in] if_num Interface number to be verified. - * - * @return - * True if if_num is of type bridge. - */ -bool nss_bridge_verify_if_num(uint32_t if_num); - -/** - * nss_bridge_tx_msg - * Sends bridge messages to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_bridge_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_bridge_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_bridge_msg *msg); - -/** - * nss_bridge_tx_msg_sync - * Sends bridge messages synchronously to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_bridge_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in,out] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_bridge_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_bridge_msg *msg); - -/** - * nss_bridge_msg_init - * Initializes a bridge message. - * - * @datatypes - * nss_bridge_msg - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num 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. - */ -void nss_bridge_msg_init(struct nss_bridge_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); - -/** - * nss_bridge_get_context - * Gets the bridge context used in nss_bridge_tx. - * - * @return - * Pointer to the NSS core context. - */ -struct nss_ctx_instance *nss_bridge_get_context(void); - -/** - * Callback function for receiving bridge 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_bridge_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback function for receiving bridge messages. - * - * @datatypes - * nss_bridge_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_bridge_msg_callback_t)(void *app_data, struct nss_bridge_msg *msg); - -/** - * nss_bridge_register - * Registers the bridge interface with the NSS for sending and receiving - * messages. - * - * @param[in] if_num NSS interface number. - * @param[in] netdev Pointer to the associated network device. - * @param[in] bridge_data_cb Callback for the bridge data. - * @param[in] bridge_msg_cb Callback for the bridge message. - * @param[in] features Data socket buffer types supported by this interface. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * Pointer to the NSS core context. - */ -struct nss_ctx_instance *nss_bridge_register(uint32_t if_num, struct net_device *netdev, nss_bridge_callback_t bridge_data_cb, nss_bridge_msg_callback_t bridge_msg_cb, uint32_t features, void *app_data); - -/** - * nss_bridge_unregister - * Deregisters the bridge interface from the NSS. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - */ -void nss_bridge_unregister(uint32_t if_num); - -/** - * nss_bridge_notify_register - * Registers a notifier callback for bridge messages with the NSS. - * - * @datatypes - * nss_bridge_msg_callback_t - * - * @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_bridge_notify_register(nss_bridge_msg_callback_t cb, void *app_data); - -/** - * nss_bridge_notify_unregister - * Deregisters a bridge message notifier callback from the NSS. - * - * @return - * None. - */ -void nss_bridge_notify_unregister(void); - -/** - * nss_bridge_tx_set_mtu_msg - * Sends a message to the bridge to set the MTU. - * - * @param[in] bridge_if_num Interface number of the bridge. - * @param[in] mtu MTU value to set. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_bridge_tx_set_mtu_msg(uint32_t bridge_if_num, uint32_t mtu); - -/** - * nss_bridge_tx_set_mac_addr_msg - * Sends a message to the bridge to set the MAC address. - * - * @param[in] bridge_if_num Interface number of the bridge. - * @param[in] addr Pointer to the MAC address. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_bridge_tx_set_mac_addr_msg(uint32_t bridge_if_num, uint8_t *addr); - -/** - * nss_bridge_tx_join_msg - * Sends the bridge a message to join with a slave interface. - * - * @datatypes - * net_device - * - * @param[in] bridge_if_num Interface number of the bridge. - * @param[in] netdev Pointer to the associated network device (the - * slave interface). - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_bridge_tx_join_msg(uint32_t bridge_if_num, struct net_device *netdev); - -/** - * nss_bridge_tx_leave_msg - * Sends the bridge a message that the slave interface is leaving the bridge. - * - * @datatypes - * net_device - * - * @param[in] bridge_if_num Interface number of the bridge. - * @param[in] netdev Pointer to the associated network device (the - * slave interface). - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_bridge_tx_leave_msg(uint32_t bridge_if_num, struct net_device *netdev); - -/** - * nss_bridge_tx_vsi_assign_msg - * Sends the bridge a message to assign a VSI. - * - * @param[in] if_num Interface number of the bridge. - * @param[in] vsi VSI to assign. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_bridge_tx_vsi_assign_msg(uint32_t if_num, uint32_t vsi); - -/** - * nss_bridge_tx_vsi_unassign_msg - * Sends the bridge a message to unassign a VSI. - * - * @param[in] if_num Interface number of the bridge. - * @param[in] vsi VSI to unassign. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_bridge_tx_vsi_unassign_msg(uint32_t if_num, uint32_t vsi); - -/** - * nss_bridge_tx_set_fdb_learn_msg - * Sends a message to notify NSS about FDB learning enable/disable event. - * - * @datatypes - * nss_bridge_fdb_learn_mode - * - * @param[in] bridge_if_num Interface number of the bridge. - * @param[in] fdb_learn FDB learning disable/enable. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_bridge_tx_set_fdb_learn_msg(uint32_t bridge_if_num, enum nss_bridge_fdb_learn_mode fdb_learn); - -/** - * nss_bridge_init - * Initializes the bridge. - * - * @return - * None. - */ -void nss_bridge_init(void); - -/** - * @} - */ - -#endif /* __NSS_BRIDGE_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_c2c_rx.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_c2c_rx.h deleted file mode 100644 index 5605abd99..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_c2c_rx.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_c2c_rx.h - * NSS core-to-core reception interface definitions. - */ - -#ifndef __NSS_C2C_RX_H -#define __NSS_C2C_RX_H - -/** - * @addtogroup nss_c2c_rx_subsystem - * @{ - */ - -/** - * nss_c2c_rx_stats_types - * Core-to-core reception node statistics. - */ -enum nss_c2c_rx_stats_types { - NSS_C2C_RX_STATS_PBUF_SIMPLE = NSS_STATS_NODE_MAX, - /**< 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 of destination is invalid. */ - NSS_C2C_RX_STATS_MAX, /**< Maximum message type. */ -}; - -/** - * nss_c2c_rx_stats_notification - * Core-to-core reception statistics structure. - */ -struct nss_c2c_rx_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint64_t stats[NSS_C2C_RX_STATS_MAX]; /**< Core-to-core reception statistics. */ -}; - -#ifdef __KERNEL__ /* only kernel will use. */ -/** - * nss_c2c_rx_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_c2c_rx_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_c2c_rx_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_c2c_rx_stats_unregister_notifier(struct notifier_block *nb); -#endif /*__KERNEL__ */ - -/** - * @} - */ - -#endif /* __NSS_C2C_RX_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_c2c_tx.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_c2c_tx.h deleted file mode 100644 index a9ecc8ce0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_c2c_tx.h +++ /dev/null @@ -1,308 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/** - * @file nss_c2c_tx.h - * NSS core-to-core transmission interface definitions. - */ - -#ifndef __NSS_C2C_TX_H -#define __NSS_C2C_TX_H - -/** - * @addtogroup nss_c2c_tx_subsystem - * @{ - */ - -/** - * nss_c2c_tx_msg_type - * Supported message types. - */ -enum nss_c2c_tx_msg_type { - NSS_C2C_TX_MSG_TYPE_STATS, /**< Statistics synchronization. */ - NSS_C2C_TX_MSG_TYPE_TX_MAP, /**< Open engine synchronization. */ - NSS_C2C_TX_MSG_TYPE_PERFORMANCE_TEST, /**< Performance test. */ - NSS_C2C_TX_MSG_TYPE_MAX /**< Maximum message type. */ -}; - -/** - * nss_c2c_tx_msg_error - * Message error types. - */ -enum nss_c2c_tx_msg_error { - NSS_C2C_TX_MSG_ERROR_NONE, /**< No error. */ - NSS_C2C_TX_MSG_ERROR_INVAL_OP, /**< Invalid operation. */ - NSS_C2C_TX_MSG_ERROR_INVALID_TEST_ID, /**< Invalid test ID. */ - NSS_C2C_TX_MSG_ERROR_MAX /**< Maximum error type. */ -}; - -/** - * nss_c2c_tx_test_type - * Supported core-to core transmission tests. - */ -enum nss_c2c_tx_test_type { - NSS_C2C_TX_TEST_TYPE_SIMPLE = 1, - /**< Tests the performance of simple pbufs. */ - NSS_C2C_TX_TEST_TYPE_SG_CHAIN, - /**< Tests the performance of scatter-gather chain pbufs. */ - NSS_C2C_TX_TEST_TYPE_SG_REF, - /**< Tests the performance of scatter-gather pbuf that has references. */ - NSS_C2C_TX_TEST_TYPE_SG_REFED, - /**< Tests the performance of referenced pbuf. */ - NSS_C2C_TX_TEST_TYPE_MAX - /**< Maximum message type. */ -}; - -/** - * nss_c2c_tx_stats_types - * Core-to-core transmission node statistics. - */ -enum nss_c2c_tx_stats_types { - NSS_C2C_TX_STATS_PBUF_SIMPLE = NSS_STATS_NODE_MAX, - /**< 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. */ -}; - -/** - * nss_c2c_tx_stats_notification - * Core-to-core transmission statistics structure. - */ -struct nss_c2c_tx_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint64_t stats[NSS_C2C_TX_STATS_MAX]; /**< Core-to-core transmission statistics. */ -}; - -#ifdef __KERNEL__ /* only kernel will use. */ -/** - * nss_c2c_tx_map - * Core-to-core transmission queue address and interrupt address. - */ -struct nss_c2c_tx_map { - uint32_t tx_map; /**< Peer core core-to-core receiver queue start address. */ - uint32_t c2c_intr_addr; /**< Peer core core-to-core interrupt register address. */ -}; - -/** - * nss_c2c_tx_stats - * The NSS core-to-core transmission node statistics structure. - */ -struct nss_c2c_tx_stats { - struct nss_cmn_node_stats node_stats; - /**< Common node statistics for core-to-core transmissions. */ - uint32_t pbuf_simple; /**< Number of received simple pbuf. */ - uint32_t pbuf_sg; /**< Number of scattered/gathered pbuf received. */ - uint32_t pbuf_returning; /**< Number of returning scattered/gathered pbuf. */ -}; - -/** - * nss_c2c_tx_test - * Start performance test for the given test ID. - */ -struct nss_c2c_tx_test { - uint32_t test_id; /**< ID of the core-to-core communication test. */ -}; - -/** - * nss_c2c_tx_msg - * Message structure to send/receive core-to-core transmission commands. - */ -struct nss_c2c_tx_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a NSS core-to-core transmission rule or statistics message. - */ - union { - struct nss_c2c_tx_map map; /**< Core-to-core transmissions memory map. */ - struct nss_c2c_tx_stats stats; /**< Core-to-core transmissions statistics. */ - struct nss_c2c_tx_test test; /**< Core-to-core performance test. */ - } msg; /**< Message payload. */ -}; - -/** - * nss_c2c_tx_register_handler - * Registers the core-to-core transmissions message handler. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * - * @return - * None. - */ -void nss_c2c_tx_register_handler(struct nss_ctx_instance *nss_ctx); - -/** - * Callback function for receiving core-to-core transmissions 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_c2c_tx_msg_callback_t)(void *app_data, struct nss_c2c_tx_msg *msg); - -/** - * nss_c2c_tx_tx_msg - * Transmits a core-to-core transmissions message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_c2c_tx_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] nctm Pointer to the message data. - * - * @return - * Status of the transmit operation. - */ -extern nss_tx_status_t nss_c2c_tx_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_c2c_tx_msg *nctm); - -/** - * nss_c2c_tx_msg_init - * Initializes core-to-core transmissions messages. - * - * @datatypes - * nss_c2c_tx_msg \n - * nss_c2c_tx_msg_callback_t - * - * @param[in] nct 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_c2c_tx_msg_init(struct nss_c2c_tx_msg *nct, uint16_t if_num, uint32_t type, uint32_t len, - nss_c2c_tx_msg_callback_t cb, void *app_data); - -/** - * nss_c2c_tx_notify_register - * Registers a notifier callback for core-to-core transmission messages with the NSS. - * - * @datatypes - * nss_c2c_tx_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_c2c_tx_notify_register(int core, nss_c2c_tx_msg_callback_t cb, void *app_data); - -/** - * nss_c2c_tx_notify_unregister - * Deregisters a core-to-core transmission 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_c2c_tx_notify_unregister(int core); - -/** - * nss_c2c_tx_msg_cfg_map - * Sends core-to-core transmissions map to NSS - * - * @datatypes - * nss_ctx_instance \n - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] tx_map Peer core core-to-core receiver queue start address. - * @param[in] c2c_addr Peer core core-to-core interrupt register address. - * - * @return - * Status of the transmit operation. - */ -extern nss_tx_status_t nss_c2c_tx_msg_cfg_map(struct nss_ctx_instance *nss_ctx, uint32_t tx_map, uint32_t c2c_addr); - -/** - * nss_c2c_tx_register_sysctl - * Registers the core-to-core transmission sysctl entries to the sysctl tree. - * - * @return - * None. - */ -extern void nss_c2c_tx_register_sysctl(void); - -/** - * nss_c2c_tx_unregister_sysctl - * Deregisters the core-to-core transmission sysctl entries from the sysctl tree. - * - * @return - * None. - * - * @dependencies - * The system control must have been previously registered. - */ -extern void nss_c2c_tx_unregister_sysctl(void); - -/** - * nss_c2c_tx_init - * Initializes the core-to-core transmission. - * - * @return - * None. - */ -void nss_c2c_tx_init(void); - -/** - * nss_c2c_tx_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_c2c_tx_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_c2c_tx_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_c2c_tx_stats_unregister_notifier(struct notifier_block *nb); -#endif /*__KERNEL__ */ - -/** - * @} - */ - -#endif /* __NSS_C2C_TX_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_capwap.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_capwap.h deleted file mode 100644 index 525fff524..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_capwap.h +++ /dev/null @@ -1,659 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_capwap.h - * NSS CAPWAP interface definitions. - */ - -#ifndef __NSS_CAPWAP_H -#define __NSS_CAPWAP_H - -/** - * @addtogroup nss_capwap_subsystem - * @{ - */ - -/** - * Size of the headroom required for CAPWAP packets. - */ -#define NSS_CAPWAP_HEADROOM 256 - -/** - * nss_capwap_stats_encap_types - * CAPWAP encapsulation statistics. - */ -enum nss_capwap_stats_encap_types { - NSS_CAPWAP_STATS_ENCAP_TX_PKTS, - NSS_CAPWAP_STATS_ENCAP_TX_BYTES, - NSS_CAPWAP_STATS_ENCAP_TX_SEGMENTS, - NSS_CAPWAP_STATS_ENCAP_TX_DROP_SG_REF, - NSS_CAPWAP_STATS_ENCAP_TX_DROP_VER_MISMATCH, - NSS_CAPWAP_STATS_ENCAP_TX_DROP_UNALIGN, - NSS_CAPWAP_STATS_ENCAP_TX_DROP_HEADER_ROOM, - NSS_CAPWAP_STATS_ENCAP_TX_DROP_DTLS, - NSS_CAPWAP_STATS_ENCAP_TX_DROP_NWIRELESS, - NSS_CAPWAP_STATS_ENCAP_TX_DROP_QUEUE_FULL, - NSS_CAPWAP_STATS_ENCAP_TX_DROP_MEM_FAIL, - NSS_CAPWAP_STATS_ENCAP_FAST_MEM, - NSS_CAPWAP_STATS_ENCAP_MAX -}; - -/** - * nss_capwap_stats_decap_types - * CAPWAP decapsulation statistics. - */ -enum nss_capwap_stats_decap_types { - NSS_CAPWAP_STATS_DECAP_RX_PKTS, - NSS_CAPWAP_STATS_DECAP_RX_BYTES, - NSS_CAPWAP_STATS_DECAP_RX_DTLS_PKTS, - NSS_CAPWAP_STATS_DECAP_RX_SEGMENTS, - NSS_CAPWAP_STATS_DECAP_RX_DROP, - NSS_CAPWAP_STATS_DECAP_RX_DROP_OVERSIZE, - NSS_CAPWAP_STATS_DECAP_RX_DROP_FRAG_TIMEOUT, - NSS_CAPWAP_STATS_DECAP_RX_DROP_DUP_FRAG, - NSS_CAPWAP_STATS_DECAP_RX_DROP_FRAG_GAP, - NSS_CAPWAP_STATS_DECAP_RX_DROP_QUEUE_FULL, - NSS_CAPWAP_STATS_DECAP_RX_DROP_N2H_QUEUE_FULL, - NSS_CAPWAP_STATS_DECAP_RX_DROP_MEM_FAIL, - NSS_CAPWAP_STATS_DECAP_RX_DROP_CHECKSUM, - NSS_CAPWAP_STATS_DECAP_RX_MALFORMED, - NSS_CAPWAP_STATS_DECAP_FAST_MEM, - NSS_CAPWAP_STATS_DECAP_MAX -}; - -/** - * nss_capwap_msg_type - * CAPWAP message types. - */ -typedef enum nss_capwap_msg_type { - NSS_CAPWAP_MSG_TYPE_NONE, - NSS_CAPWAP_MSG_TYPE_CFG_RULE, - NSS_CAPWAP_MSG_TYPE_UNCFG_RULE, - NSS_CAPWAP_MSG_TYPE_ENABLE_TUNNEL, - NSS_CAPWAP_MSG_TYPE_DISABLE_TUNNEL, - NSS_CAPWAP_MSG_TYPE_UPDATE_PATH_MTU, - NSS_CAPWAP_MSG_TYPE_SYNC_STATS, - NSS_CAPWAP_MSG_TYPE_VERSION, /**< Default is version 1. */ - NSS_CAPWAP_MSG_TYPE_DTLS, - NSS_CAPWAP_MSG_TYPE_FLOW_RULE_ADD, - NSS_CAPWAP_MSG_TYPE_FLOW_RULE_DEL, - NSS_CAPWAP_MSG_TYPE_MAX, -} nss_capwap_msg_type_t; - -/** - * nss_capwap_msg_response - * Error types for CAPWAP responses to messages from the host. - */ -typedef enum nss_capwap_msg_response { - NSS_CAPWAP_ERROR_MSG_INVALID_REASSEMBLY_TIMEOUT, - NSS_CAPWAP_ERROR_MSG_INVALID_PATH_MTU, - NSS_CAPWAP_ERROR_MSG_INVALID_MAX_FRAGMENT, - NSS_CAPWAP_ERROR_MSG_INVALID_BUFFER_SIZE, - NSS_CAPWAP_ERROR_MSG_INVALID_L3_PROTO, - NSS_CAPWAP_ERROR_MSG_INVALID_UDP_PROTO, - NSS_CAPWAP_ERROR_MSG_INVALID_VERSION, - NSS_CAPWAP_ERROR_MSG_TUNNEL_DISABLED, - NSS_CAPWAP_ERROR_MSG_TUNNEL_ENABLED, - NSS_CAPWAP_ERROR_MSG_TUNNEL_NOT_CFG, - NSS_CAPWAP_ERROR_MSG_INVALID_IP_NODE, - NSS_CAPWAP_ERROR_MSG_INVALID_TYPE_FLAG, - NSS_CAPWAP_ERROR_MSG_INVALID_DTLS_CFG, - NSS_CAPWAP_ERROR_MSG_FLOW_TABLE_FULL, - NSS_CAPWAP_ERROR_MSG_FLOW_EXIST, - NSS_CAPWAP_ERROR_MSG_FLOW_NOT_EXIST, - NSS_CAPWAP_ERROR_MSG_MAX, -} nss_capwap_msg_response_t; - -/** - * nss_capwap_stats_msg - * Per-tunnel statistics messages from the NSS firmware. - */ -struct nss_capwap_stats_msg { - struct nss_cmn_node_stats pnode_stats; /**< Common firmware statistics. */ - uint32_t dtls_pkts; /**< Number of DTLS packets flowing through. */ - - /* - * Rx/decap stats - */ - uint32_t rx_dup_frag; /**< Number of duplicate fragments. */ - uint32_t rx_segments; /**< Number of segments or fragments. */ - - /** - * Packets dropped because they are larger than the payload size. - */ - uint32_t rx_oversize_drops; - - 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_n2h_queue_full_drops; - /**< Packets dropped because the NSS-to-host queue is full. */ - uint32_t rx_csum_drops; - /**< Packets dropped because of a checksum mismatch. */ - uint32_t rx_malformed; - /**< Packets dropped because of a malformed packet. */ - uint32_t rx_mem_failure_drops; - /**< Packets dropped because of a memory failure. */ - uint32_t rx_frag_gap_drops; - /**< Packets dropped because of a non-sequential fragment offset. */ - - /* - * Tx/encap stats - */ - uint32_t tx_segments; /**< Number of segments or fragments. */ - uint32_t tx_queue_full_drops; /**< Packets dropped because of a full queue. */ - uint32_t tx_mem_failure_drops; - /**< Packets dropped because of a memory failure. */ - uint32_t tx_dropped_sg_ref; - /**< Packets dropped because of a scatter-gather reference. */ - uint32_t tx_dropped_ver_mis; - /**< Packets dropped because of a version mismatch. */ - uint32_t Reserved; - /**< Reserved. */ - uint32_t tx_dropped_hroom; - /**< Packets dropped because of insufficent headroom. */ - uint32_t tx_dropped_dtls; - /**< Packets dropped because of a DTLS packet. */ - uint32_t tx_dropped_nwireless; - /**< Packets dropped because the nwireless field information is wrong. */ - - uint32_t fast_mem; - /**< Set to 1 when tunnel is operating in fast memory. */ -}; - -/** - * nss_capwap_ip - * IP versions. - */ -struct nss_capwap_ip { - /** - * Union of IPv4 and IPv6 IP addresses. - */ - union { - uint32_t ipv4; /**< IPv4 address. */ - uint32_t ipv6[4]; /**< IPv6 address. */ - } ip; /**< Union of IPv4 and IPv6 IP addresses. */ -}; - -/** - * nss_capwap_encap_rule - * Encapsulation information for a CAPWAP tunnel. - */ -struct nss_capwap_encap_rule { - struct nss_capwap_ip src_ip; /**< Source IP. */ - uint32_t src_port; /**< Source port. */ - struct nss_capwap_ip dest_ip; /**< Destination IP. */ - uint32_t dest_port; /**< Destination port. */ - uint32_t path_mtu; /**< MTU on the path. */ -}; - -/** - * nss_capwap_decap_rule - * Decapsulation information for a CAPWAP tunnel. - */ -struct nss_capwap_decap_rule { - uint32_t reassembly_timeout; /**< Timeout in milliseconds. */ - uint32_t max_fragments; /**< Maximum number of fragments expected. */ - uint32_t max_buffer_size; /**< Maximum size of the payload buffer. */ -}; - -/** - * nss_capwap_rule_msg - * CAPWAP rule message. - * - * The same rule structure applies for both encapsulation and decapsulation - * in a tunnel. - */ -struct nss_capwap_rule_msg { - struct nss_capwap_encap_rule encap; /**< Encapsulation portion of the rule. */ - struct nss_capwap_decap_rule decap; /**< Decapsulation portion of the rule. */ - uint32_t stats_timer; /**< Statistics interval timer in milliseconds. */ - - /** - * Core to choose for receiving packets. - * - * Set to -1 for the NSS firmware to decide. - */ - int8_t rps; - - uint8_t type_flags; /**< VLAN or PPPOE is configured. */ - uint8_t l3_proto; - /**< Prototype is NSS_CAPWAP_TUNNEL_IPV4 or NSS_CAPWAP_TUNNEL_IPV6. */ - uint8_t which_udp; /**< Tunnel uses the UDP or UDPLite protocol. */ - uint32_t mtu_adjust; /**< MTU is reserved for a DTLS process. */ - uint32_t gmac_ifnum; /**< Outgoing physical interface. */ - uint32_t enabled_features; - /**< Tunnel enabled features bit flag. */ - - /* - * Parameters for each features - */ - uint32_t dtls_inner_if_num; /**< Interface number of the associated DTLS node. */ - uint8_t bssid[ETH_ALEN]; /**< BSSID value. */ - uint16_t outer_sgt_value; - /**< Security Group Tag value configured for this tunnel. */ -}; - -/** - * nss_capwap_version_msg - * Message to set the CAPWAP version. - */ -struct nss_capwap_version_msg { - uint32_t version; /**< CAPWAP protocol version. */ -}; - -/** - * nss_capwap_path_mtu_msg - * Message information for the path MTU. - */ -struct nss_capwap_path_mtu_msg { - uint32_t path_mtu; /**< Path MTU value between the controller and access point. */ -}; - -/** - * nss_capwap_dtls_msg - * DTLS message information. - */ -struct nss_capwap_dtls_msg { - uint32_t enable; /**< Enable or disable DTLS. */ - uint32_t dtls_inner_if_num; /**< Interface number of the associated DTLS. */ - uint32_t mtu_adjust; /**< MTU adjustment reported by the DTLS node. */ - uint32_t reserved; /**< Reserved field for future use. */ -}; - -/** - * nss_capwap_flow_rule_msg - * CAPWAP flow rule message structure. - */ -struct nss_capwap_flow_rule_msg { - /* - * 5-tuple info. - */ - uint16_t ip_version; /**< IP version. */ - uint16_t protocol; /**< Layer 4 protocol. */ - uint16_t src_port; /**< Source port. */ - uint16_t dst_port; /**< Destination port. */ - uint32_t src_ip[4]; /**< Source IP address. */ - uint32_t dst_ip[4]; /**< Destination IP address. */ - - /* - * Flow attributes. - */ - uint32_t flow_id; /**< Flow identification. */ -}; - -/** - * 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_msg - * Data for sending and receiving CAPWAP messages. - */ -struct nss_capwap_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a CAPWAP common message. - */ - union { - struct nss_capwap_rule_msg rule; - /**< Rule information. */ - struct nss_capwap_path_mtu_msg mtu; - /**< New MTU information. */ - struct nss_capwap_stats_msg stats; - /**< CAPWAP statistics. */ - struct nss_capwap_version_msg version; - /**< CAPWAP version to use. */ - struct nss_capwap_dtls_msg dtls; - /**< DTLS configuration. */ - struct nss_capwap_flow_rule_msg flow_rule_add; - /**< 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. */ - } msg; /**< Message payload. */ -}; - -/** - * nss_capwap_pn_stats - * Pnode statistics (64-bit version). - */ -struct nss_capwap_pn_stats { - uint64_t rx_packets; /**< Number of packets received. */ - uint64_t rx_bytes; /**< Number of bytes received. */ - uint64_t rx_dropped; /**< Number of dropped Rx packets. */ - uint64_t tx_packets; /**< Number of packets transmitted. */ - uint64_t tx_bytes; /**< Number of bytes transmitted. */ -}; - -/** - * nss_capwap_tunnel_stats - * Per-tunnel statistics seen by the HLOS. - */ -struct nss_capwap_tunnel_stats { - struct nss_capwap_pn_stats pnode_stats; /**< Common firmware statistics. */ - uint64_t dtls_pkts; /**< Number of DTLS packets flowing through. */ - - /* - * Rx/decap stats - */ - uint64_t rx_dup_frag; /**< Number of duplicate fragments. */ - uint64_t rx_segments; /**< Number of segments or fragments. */ - - /** - * Packets dropped because they are larger than the payload size. - */ - uint64_t rx_oversize_drops; - - 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_n2h_queue_full_drops; - /**< Packets dropped because the NSS-to-host queue is full. */ - uint64_t rx_csum_drops; - /**< Packets dropped because of a checksum mismatch. */ - uint64_t rx_malformed; - /**< Packets dropped because of a malformed packet. */ - uint64_t rx_mem_failure_drops; - /**< Packets dropped because of a memory failure. */ - uint64_t rx_frag_gap_drops; - /**< Packets dropped because of a non-sequential fragment offset. */ - - /* - * Tx/encap stats - */ - uint64_t tx_dropped_inner; /**id + 1) << NSS_CORE_ID_SHIFT)) - -/** - * Macro to obtain a core local interface number. - */ -#define NSS_INTERFACE_NUM_GET(interface) ((interface) & 0xffffff) - -/** - * Macro to obtain an interface core number. - */ -#define NSS_INTERFACE_NUM_GET_COREID(interface) ((interface >> NSS_CORE_ID_SHIFT) & 0xff) - -/* - * Common enumerations. - */ - -/** - * nss_tx_status_t - * Tx command failure results. - * - * Types starting with NSS_TX_FAILURE_SYNC_ are only used by synchronous messages. - */ -typedef enum { - NSS_TX_SUCCESS = 0, - NSS_TX_FAILURE, - NSS_TX_FAILURE_QUEUE, - NSS_TX_FAILURE_NOT_READY, - NSS_TX_FAILURE_TOO_LARGE, - NSS_TX_FAILURE_TOO_SHORT, - NSS_TX_FAILURE_NOT_SUPPORTED, - NSS_TX_FAILURE_BAD_PARAM, - NSS_TX_FAILURE_NOT_ENABLED, - NSS_TX_FAILURE_SYNC_BAD_PARAM, - NSS_TX_FAILURE_SYNC_TIMEOUT, - NSS_TX_FAILURE_SYNC_FW_ERR, - NSS_TX_FAILURE_MAX, -} nss_tx_status_t; - -/** - * nss_state_t - * Initialization states. - */ -typedef enum { - NSS_STATE_UNINITIALIZED = 0, - NSS_STATE_INITIALIZED -} nss_state_t; - -/** - * nss_core_id_t - * NSS core IDs. - */ -typedef enum { - NSS_CORE_0 = 0, - NSS_CORE_1, - NSS_CORE_MAX -} nss_core_id_t; - -/** - * nss_cb_register_status_t - * Callback registration states. - */ -typedef enum { - NSS_CB_REGISTER_SUCCESS = 0, - NSS_CB_REGISTER_FAILED, -} nss_cb_register_status_t; - -/** - * nss_cb_unregister_status_t - * Callback deregistration states. - */ -typedef enum { - NSS_CB_UNREGISTER_SUCCESS = 0, - NSS_CB_UNREGISTER_FAILED, -} nss_cb_unregister_status_t; - -/** - * nss_cmn_response - * Responses for a common message. - */ -enum nss_cmn_response { - NSS_CMN_RESPONSE_ACK, - NSS_CMN_RESPONSE_EVERSION, - NSS_CMN_RESPONSE_EINTERFACE, - NSS_CMN_RESPONSE_ELENGTH, - NSS_CMN_RESPONSE_EMSG, - NSS_CMN_RESPONSE_NOTIFY, - NSS_CMN_RESPONSE_LAST -}; - -/** - * Array of log messages for common NSS responses. - */ -extern int8_t *nss_cmn_response_str[NSS_CMN_RESPONSE_LAST]; - -/** - * nss_cmn_msg - * Common message information. - */ -struct nss_cmn_msg { - uint16_t version; /**< Version ID for the main message format. */ - uint16_t len; /**< Length of the message, excluding the header. */ - uint32_t interface; /**< Primary key for all messages. */ - enum nss_cmn_response response; - /**< Primary response. All messages must specify one of these responses. */ - - uint32_t type; /**< Decentralized request number used to match response numbers. */ - uint32_t error; /**< Decentralized specific error message (response == EMSG). */ - - /** - * Padding used to start the callback from a 64-bit boundary. This field can be reused. - */ - uint32_t reserved; - - nss_ptr_t cb; /**< Contains the callback pointer. */ -#ifndef __LP64__ - uint32_t padding1; /**< Padding used to fit 64 bits. Do not reuse. */ -#endif - nss_ptr_t app_data; /**< Contains the application data. */ -#ifndef __LP64__ - uint32_t padding2; /**< Padding used to fit 64 bits. Do not reuse. */ -#endif -}; - -/** - * nss_cmn_node_stats - * Common per-node statistics. - */ -struct nss_cmn_node_stats { - uint32_t rx_packets; /**< Number of packets received. */ - uint32_t rx_bytes; /**< Number of bytes received. */ - uint32_t tx_packets; /**< Number of packets transmitted. */ - uint32_t tx_bytes; /**< Number of bytes transmitted. */ - uint32_t rx_dropped[NSS_MAX_NUM_PRI]; /**< Packets dropped on receive due to queue full. */ -}; - -/** - * nss_cmn_get_msg_len - * Gets the message length of a host-to-NSS message. - * - * @datatypes - * nss_cmn_get_msg_len - * - * @param[in] ncm Pointer to the common message. - * - * @return - * Length of the message specified in the argument to this function. - */ -static inline uint32_t nss_cmn_get_msg_len(struct nss_cmn_msg *ncm) -{ - return ncm->len + sizeof(struct nss_cmn_msg); -} - -#ifdef __KERNEL__ /* only for kernel to use. */ - -/** - * nss_cmn_msg_init - * Initializes the common area of an asynchronous host-to-NSS message. - * - * @datatypes - * nss_cmn_msg - * - * @param[in,out] ncm Pointer to the common message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the callback function. - * @param[in] app_data Pointer to the application context for this message. - * - * @return - * None. - */ -extern void nss_cmn_msg_init(struct nss_cmn_msg *ncm, uint32_t if_num, uint32_t type, uint32_t len, - void *cb, void *app_data); - -/** - * nss_cmn_msg_sync_init - * Initializes the common message of a synchronous host-to-NSS message. - * - * @datatypes - * nss_cmn_msg - * - * @param[in,out] ncm Pointer to the common message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * - * @return - * None. - */ -extern void nss_cmn_msg_sync_init(struct nss_cmn_msg *ncm, uint32_t if_num, uint32_t type, uint32_t len); - -/** - * nss_cmn_get_interface_number - * Gets the interface number. - * - * @datatypes - * nss_ctx_instance \n - * net_device - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] dev Pointer to the OS network device pointer. - * - * @return - * Interface number. - */ -extern int32_t nss_cmn_get_interface_number(struct nss_ctx_instance *nss_ctx, struct net_device *dev); - -/** - * nss_cmn_get_interface_number_by_dev - * Gets the interface number of a device. - * - * @datatypes - * net_device - * - * @param[in] dev Pointer to the OS network device pointer. - * - * @return - * Interface number, or -1 on failure. - */ -extern int32_t nss_cmn_get_interface_number_by_dev(struct net_device *dev); - -/** - * nss_cmn_get_interface_number_by_dev_and_type - * Gets the interface number by a device and its type. - * - * @datatypes - * net_device - * - * @param[in] dev Pointer to the OS network device pointer. - * @param[in] type Type of this interface. - * - * @return - * Interface number, or -1 on failure. - */ -extern int32_t nss_cmn_get_interface_number_by_dev_and_type(struct net_device *dev, uint32_t type); - -/** - * nss_cmn_interface_is_redirect - * Determines if the interface number is a redirect interface. - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] interface_num NSS interface number. - * - * @return - * TRUE if the number is a redirect interface. Otherwise FALSE. - */ -extern bool nss_cmn_interface_is_redirect(struct nss_ctx_instance *nss_ctx, int32_t interface_num); - -/** - * nss_cmn_append_core_id - * Append core ID on NSS interface number. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] if_num NSS interface number. - * - * @return - * Interface number with core ID. - */ -extern int nss_cmn_append_core_id(struct nss_ctx_instance *nss_ctx, int if_num); - -/** - * nss_cmn_get_interface_dev - * Gets an interface device pointer. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] if_num NSS interface number. - * - * @return - * Interface device pointer. - */ -extern struct net_device *nss_cmn_get_interface_dev(struct nss_ctx_instance *nss_ctx, uint32_t if_num); - -/** - * nss_cmn_get_state - * Obtains the NSS state. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * - * @return - * NSS state that indicates whether the NSS core is initialized. For possible values, see nss_state_t. - */ -extern nss_state_t nss_cmn_get_state(struct nss_ctx_instance *nss_ctx); - -/** - * Callback function for queue decongestion messages. - * - * @param[in] app_data Pointer to the application context for this message. - */ -typedef void (*nss_cmn_queue_decongestion_callback_t)(void *app_data); - -/** - * nss_cmn_register_queue_decongestion - * Registers a queue for a decongestion event. - * - * The callback function is called with the spinlock held. The function should avoid deadlocks - * caused by attempting to acquire multiple spinlocks. - - * @datatypes - * nss_ctx_instance \n - * nss_cmn_queue_decongestion_callback_t - * - * @param[in,out] nss_ctx Pointer to the NSS context. - * @param[in] event_callback Callback for the message. - * @param[in] app_data Pointer to the application context to be returned in the - * callback. - * - * @return - * #NSS_CB_REGISTER_SUCCESS if registration is successful. - * @par - * Otherwise, #NSS_CB_REGISTER_FAILED. - */ -extern nss_cb_register_status_t nss_cmn_register_queue_decongestion(struct nss_ctx_instance *nss_ctx, nss_cmn_queue_decongestion_callback_t event_callback, void *app_data); - -/** - * nss_cmn_unregister_queue_decongestion - * Deregisters a queue from receiving a decongestion event. - * - * @datatypes - * nss_ctx_instance \n - * nss_cmn_queue_decongestion_callback_t - * - * @param[in,out] nss_ctx Pointer to the NSS context. - * @param[in] event_callback Callback for the message. - * - * @return - * #NSS_CB_REGISTER_SUCCESS if registration is successful. - * @par - * Otherwise, #NSS_CB_REGISTER_FAILED. - * - * @dependencies - * The callback function must have been previously registered. - */ -extern nss_cb_unregister_status_t nss_cmn_unregister_queue_decongestion(struct nss_ctx_instance *nss_ctx, nss_cmn_queue_decongestion_callback_t event_callback); - -/** - * Callback function for packets with service code. - * - * @param[in] app_data Pointer to the application context for this message. - * @param[in] nbuf Pointer to the socket buffer. - */ -typedef void (*nss_cmn_service_code_callback_t)(void *app_data, struct sk_buff *nbuf); - -/** - * nss_cmn_register_service_code - * Registers a callback for a service code. - * - * @datatypes - * nss_ctx_instance \n - * nss_cmn_service_code_callback_t - * - * @param[in,out] nss_ctx Pointer to the NSS context. - * @param[in] cb Callback for the message. - * @param[in] service_code Service code found attached to the packet. - * @param[in] app_data Pointer to the application context to be returned in the - * callback. - * - * @return - * #NSS_CB_REGISTER_SUCCESS if registration is successful. - * @par - * Otherwise, #NSS_CB_REGISTER_FAILED. - */ -extern nss_cb_register_status_t nss_cmn_register_service_code(struct nss_ctx_instance *nss_ctx, nss_cmn_service_code_callback_t cb, uint8_t service_code, void *app_data); - -/** - * nss_cmn_unregister_service_code - * Deregisters a callback for the given service code. - * - * @datatypes - * nss_ctx_instance \n - * nss_cmn_service_code_callback_t - * - * @param[in,out] nss_ctx Pointer to the NSS context. - * @param[in] cb Callback for the message. - * @param[in] service_code Service code found attached to the packet. - * - * @return - * #NSS_CB_REGISTER_SUCCESS if registration is successful. - * @par - * Otherwise, #NSS_CB_REGISTER_FAILED. - * - * @dependencies - * The callback function must have been previously registered. - */ -extern nss_cb_unregister_status_t nss_cmn_unregister_service_code(struct nss_ctx_instance *nss_ctx, nss_cmn_service_code_callback_t cb, uint8_t service_code); - -/** - * nss_cmn_get_nss_enabled - * Checks whether the NSS mode is supported on the platform. - * - * @return - * TRUE if NSS is supported. \n - * Otherwise, FALSE. - */ -extern bool nss_cmn_get_nss_enabled(void); - -/** - * nss_cmn_rx_dropped_sum - * Sums dropped packet count of all NSS pnode queues. - * - * @datatypes - * nss_cmn_node_stats \n - * - * @param[in] node_stats Pointer to node statistics. - * - * @return - * Total dropped packets count. - */ -extern uint32_t nss_cmn_rx_dropped_sum(struct nss_cmn_node_stats *node_stats); - -#endif /* __KERNEL__ */ - -/** - * @} - */ - -#endif /* __NSS_CMN_MSG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_crypto.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_crypto.h deleted file mode 100644 index 5ef514d6e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_crypto.h +++ /dev/null @@ -1,392 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2014-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_crypto.h - * NSS Crypto interface definitions. - */ - -#ifndef __NSS_CRYPTO_H -#define __NSS_CRYPTO_H - -/** - * @addtogroup nss_crypto_subsystem - * @{ - */ - -#define NSS_CRYPTO_MAX_IDXS 64 /**< Maximum number of supported sessions. */ -#define NSS_CRYPTO_MAX_ENGINES 4 /**< Maximum number of engines available. */ -#define NSS_CRYPTO_BAM_PP 2 /**< Bus Access Manager pipe pairs. */ - -/** - * nss_crypto_hash - * Hash sizes supported by the hardware. - */ -enum nss_crypto_hash { - NSS_CRYPTO_HASH_SHA96 = 12, - NSS_CRYPTO_HASH_SHA128 = 16, - NSS_CRYPTO_HASH_SHA160 = 20, - NSS_CRYPTO_HASH_SHA256 = 32 -}; - -/** - * nss_crypto_cipher - * Cipher algorithms. - */ -enum nss_crypto_cipher { - NSS_CRYPTO_CIPHER_NONE = 0, - NSS_CRYPTO_CIPHER_AES_CBC, /**< AES, and CBC for 128-bit and 256-bit key sizes. */ - NSS_CRYPTO_CIPHER_DES, /**< DES, and CBC for 64-bit key size. */ - NSS_CRYPTO_CIPHER_NULL, /**< NULL and CBC. */ - NSS_CRYPTO_CIPHER_AES_CTR, /**< AES, and CTR for 128-bit and 256-bit key sizes. */ - NSS_CRYPTO_CIPHER_MAX -}; - -/** - * nss_crypto_auth - * Authentication algorithms. - */ -enum nss_crypto_auth { - NSS_CRYPTO_AUTH_NONE = 0, - NSS_CRYPTO_AUTH_SHA1_HMAC, - NSS_CRYPTO_AUTH_SHA256_HMAC, - NSS_CRYPTO_AUTH_NULL, - NSS_CRYPTO_AUTH_MAX -}; - -/** - * nss_crypto_msg_type - * Synchronization types. - */ -enum nss_crypto_msg_type { - NSS_CRYPTO_MSG_TYPE_NONE = 0, - NSS_CRYPTO_MSG_TYPE_OPEN_ENG = 1, - NSS_CRYPTO_MSG_TYPE_CLOSE_ENG = 2, - NSS_CRYPTO_MSG_TYPE_UPDATE_SESSION = 3, - NSS_CRYPTO_MSG_TYPE_STATS = 4, - NSS_CRYPTO_MSG_TYPE_MAX -}; - -/** - * nss_crypto_msg_error - * Response types. - */ -enum nss_crypto_msg_error { - NSS_CRYPTO_MSG_ERROR_NONE = 0, - NSS_CRYPTO_MSG_ERROR_INVAL_ENG = 1, - NSS_CRYPTO_MSG_ERROR_UNSUPP_OP = 2, - NSS_CRYPTO_MSG_ERROR_INVAL_OP = 3, - NSS_CRYPTO_MSG_ERROR_INVAL_IDX_RANGE = 4, - NSS_CRYPTO_MSG_ERROR_IDX_ALLOC_FAIL = 5, - NSS_CRYPTO_MSG_ERROR_MAX -}; - -/** - * nss_crypto_session_state - * Session states. - */ -enum nss_crypto_session_state { - NSS_CRYPTO_SESSION_STATE_NONE = 0, - NSS_CRYPTO_SESSION_STATE_ACTIVE = 1, - NSS_CRYPTO_SESSION_STATE_FREE = 2 -}; - -/** - * nss_crypto_buf_origin - * Origins of the crypto session. - */ -enum nss_crypto_buf_origin { - NSS_CRYPTO_BUF_ORIGIN_HOST = 0x001, - NSS_CRYPTO_BUF_ORIGIN_NSS = 0x0002, -}; - -/** - * nss_crypto_idx - * Crypto session index information. - */ -struct nss_crypto_idx { - uint16_t pp_num; /**< Pipe pair index. */ - uint16_t cmd_len; /**< Command block length to program. */ - uint32_t cblk_paddr; /**< Physical address of the command block. */ -}; - -/** - * nss_crypto_config_eng - * Engine configuration information for opening the engine from the host. - * - * This structure is called to initialize the crypto NSS engine-specific data - * structures. Ideally, the host can send a single probe for all engines, but - * the current implementation relies on probes per engine. - */ -struct nss_crypto_config_eng { - uint32_t eng_id; /**< Engine number to open. */ - uint32_t bam_pbase; /**< BAM base address (physical). */ - uint32_t crypto_pbase; /**< Crypto base address (physical). */ - uint32_t desc_paddr[NSS_CRYPTO_BAM_PP]; - /**< Pipe description address (physical). */ - struct nss_crypto_idx idx[NSS_CRYPTO_MAX_IDXS]; - /**< Allocated session indices. */ -}; - -/** - * nss_crypto_config_session - * Session-related state configuration. - */ -struct nss_crypto_config_session { - uint32_t idx; /**< Session index on which the state is reset. */ - uint32_t state; /**< Index state of the session. */ - uint32_t iv_len; /**< Length of the initialization vector. */ -}; - -/** - * nss_crypto_stats - * Crypto statistics. - */ -struct nss_crypto_stats { - uint32_t queued; /**< Number of frames waiting to be processed. */ - uint32_t completed; /**< Number of frames processed. */ - uint32_t dropped; /**< Number of frames dropped or not processed. */ -}; - -/** - * nss_crypto_sync_stats - * Statistics synchronized to the host. - */ -struct nss_crypto_sync_stats { - struct nss_crypto_stats eng_stats[NSS_CRYPTO_MAX_ENGINES]; - /**< Tx or Rx statistics captured per crypto engine. */ - struct nss_crypto_stats idx_stats[NSS_CRYPTO_MAX_IDXS]; - /**< Tx or Rx statistics captured per session. */ - struct nss_crypto_stats total; - /**< Total statistics captured in and out of the engine. */ -}; - -/** - * nss_crypto_msg - * Data for sending and receiving crypto messages. - */ -struct nss_crypto_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a crypto message. - */ - union { - struct nss_crypto_config_eng eng; - /**< Opens an engine. */ - struct nss_crypto_config_session session; - /**< Resets the statistics. */ - struct nss_crypto_sync_stats stats; - /**< Synchronized statistics for crypto. */ - } msg; /**< Message payload. */ -}; - -#ifdef __KERNEL__ /* only kernel will use. */ - -/** - * Message notification callback. - * - * @datatypes - * nss_crypto_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_crypto_msg_callback_t)(void *app_data, struct nss_crypto_msg *msg); - -/** - * Data callback. - * - * @datatypes - * net_device \n - * sk_buff \n - * napi_struct - * - * @param[in] netdev Pointer to the network device. - * @param[in] skb Pointer to the data socket buffer. - * @param[in] napi Pointer to the NAPI structure. - */ -typedef void (*nss_crypto_buf_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Power management event callback. - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] turbo Turbo mode event. - * @param[in] auto_scale Specifies the auto scaling of the NSS clock frequency. - * - * @return - * TRUE if crypto is scaled to turbo. - */ -typedef bool (*nss_crypto_pm_event_callback_t)(void *app_data, bool turbo, bool auto_scale); - -/** - * nss_crypto_tx_msg - * Sends a crypto message. - * - * @datatypes - * nss_ctx_instance \n - * nss_crypto_msg - * - * @param[in] nss_ctx Pointer to the NSS context of the HLOS driver. - * @param[in] msg Pointer to the message data. - * - * @return - * None. - */ -extern nss_tx_status_t nss_crypto_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_crypto_msg *msg); - -/** - * nss_crypto_tx_buf - * Sends a crypto data packet. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS context of the HLOS driver - * @param[in] if_num NSS interface number. - * @param[in] skb Pointer to the data socket buffer. - * - * @return - * None. - */ -extern nss_tx_status_t nss_crypto_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, struct sk_buff *skb); - -/** - * nss_crypto_notify_register - * Registers an event callback handler with the HLOS driver. - * - * @datatypes - * nss_crypto_msg_callback_t - * - * @param[in] cb Callback function for the message. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -extern struct nss_ctx_instance *nss_crypto_notify_register(nss_crypto_msg_callback_t cb, void *app_data); - -/** - * nss_crypto_data_register - * Registers a data callback handler with the HLOS driver. - * - * @datatypes - * nss_crypto_buf_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] cb Callback function for the data. - * @param[in] netdev Pointer to the network device. - * @param[in] features Data socket buffer types supported by this interface. - * - * @return - * None. - */ -extern struct nss_ctx_instance *nss_crypto_data_register(uint32_t if_num, nss_crypto_buf_callback_t cb, - struct net_device *netdev, uint32_t features); - -/** - * nss_crypto_pm_notify_register - * Registers a power management event callback handler with the HLOS driver. - * - * @datatypes - * nss_crypto_pm_event_callback_t - * - * @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_crypto_pm_notify_register(nss_crypto_pm_event_callback_t cb, void *app_data); - -/** - * nss_crypto_notify_unregister - * Deregisters an event callback handler notifier from the HLOS driver. - * - * @datatypes - * nss_ctx_instance - * - * @param[in,out] ctx Pointer to the context of the HLOS driver. - * - * @return - * None. - * - * @dependencies - * The event callback handler must have been previously registered. - */ -extern void nss_crypto_notify_unregister(struct nss_ctx_instance *ctx); - -/** - * nss_crypto_data_unregister - * Deregisters a data callback handler 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 callback handler must have been previously registered. - */ -extern void nss_crypto_data_unregister(struct nss_ctx_instance *ctx, uint32_t if_num); - -/** - * nss_crypto_pm_notify_unregister - * Deregisters a power management event callback handler from the HLOS driver. - * - * @return - * None. - * - * @dependencies - * The callback handler must have been previously registered. - */ -extern void nss_crypto_pm_notify_unregister(void); - -/** - * nss_crypto_msg_init - * Initializes a crypto-specific message. - * - * @datatypes - * nss_crypto_msg \n - * nss_crypto_msg_callback_t - * - * @param[in,out] ncm Pointer to the 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_crypto_msg_init(struct nss_crypto_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, - nss_crypto_msg_callback_t cb, void *app_data); - -#endif /*__KERNEL__ */ - -/** - * @} - */ - -#endif /* __NSS_CRYPTO_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_crypto_cmn.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_crypto_cmn.h deleted file mode 100644 index 61b97f1a8..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_crypto_cmn.h +++ /dev/null @@ -1,460 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_crypto_cmn.h - * NSS Crypto common interface definitions. - */ -#ifndef __NSS_CRYPTO_CMN_H -#define __NSS_CRYPTO_CMN_H - -/** - * @addtogroup nss_crypto_subsystem - * @{ - */ - -/* - * Context message related array sizes - */ -#define NSS_CRYPTO_CMN_CTX_SPARE 4 /**< Context spare words size. */ -#define NSS_CRYPTO_CMN_VER_WORDS 4 /**< Firmware version words size.*/ -#define NSS_CRYPTO_CIPHER_KEYLEN_MAX 32 /**< Maximum cipher keysize. */ -#define NSS_CRYPTO_AUTH_KEYLEN_MAX 128 /**< Maximum authorization keysize. */ -#define NSS_CRYPTO_NONCE_SIZE_MAX 4 /**< Maximum authorization keysize. */ - -/** - * nss_crypto_cmn_algo - * List of crypto algorithms supported. - */ -enum nss_crypto_cmn_algo { - NSS_CRYPTO_CMN_ALGO_NULL, /**< NULL transform. */ - NSS_CRYPTO_CMN_ALGO_3DES_CBC, /**< Asynchronous block cipher. */ - NSS_CRYPTO_CMN_ALGO_AES128_CBC, /**< Asynchronous block cipher. */ - NSS_CRYPTO_CMN_ALGO_AES192_CBC, /**< Asynchronous block cipher. */ - NSS_CRYPTO_CMN_ALGO_AES256_CBC, /**< Asynchronous block cipher. */ - NSS_CRYPTO_CMN_ALGO_AES128_CTR, /**< Asynchronous block cipher. */ - NSS_CRYPTO_CMN_ALGO_AES192_CTR, /**< Asynchronous block cipher. */ - NSS_CRYPTO_CMN_ALGO_AES256_CTR, /**< Asynchronous block cipher. */ - NSS_CRYPTO_CMN_ALGO_AES128_ECB, /**< Asynchronous block cipher. */ - NSS_CRYPTO_CMN_ALGO_AES192_ECB, /**< Asynchronous block cipher. */ - NSS_CRYPTO_CMN_ALGO_AES256_ECB, /**< Asynchronous block cipher. */ - NSS_CRYPTO_CMN_ALGO_AES128_GCM, /**< Asynchronous block cipher. */ - NSS_CRYPTO_CMN_ALGO_AES192_GCM, /**< Asynchronous block cipher. */ - NSS_CRYPTO_CMN_ALGO_AES256_GCM, /**< Asynchronous block cipher. */ - NSS_CRYPTO_CMN_ALGO_MD5_HASH, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_SHA160_HASH, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_SHA224_HASH, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_SHA256_HASH, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_SHA384_HASH, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_SHA512_HASH, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_MD5_HMAC, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_SHA160_HMAC, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_SHA224_HMAC, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_SHA256_HMAC, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_SHA384_HMAC, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_SHA512_HMAC, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_AES128_GMAC, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_AES192_GMAC, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_AES256_GMAC, /**< Asynchronous digest. */ - NSS_CRYPTO_CMN_ALGO_AES128_GCM_GMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES128_CBC_MD5_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES128_CBC_SHA160_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES128_CBC_SHA256_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES128_CBC_SHA384_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES128_CBC_SHA512_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES192_GCM_GMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES192_CBC_MD5_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES192_CBC_SHA160_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES192_CBC_SHA256_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES192_CBC_SHA384_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES192_CBC_SHA512_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES256_GCM_GMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES256_CBC_MD5_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES256_CBC_SHA160_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES256_CBC_SHA256_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES256_CBC_SHA384_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES256_CBC_SHA512_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES128_CTR_MD5_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES128_CTR_SHA160_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES128_CTR_SHA256_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES128_CTR_SHA384_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES128_CTR_SHA512_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES192_CTR_MD5_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES192_CTR_SHA160_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES192_CTR_SHA256_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES192_CTR_SHA384_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES192_CTR_SHA512_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES256_CTR_MD5_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES256_CTR_SHA160_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES256_CTR_SHA256_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES256_CTR_SHA384_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_AES256_CTR_SHA512_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_3DES_CBC_MD5_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_3DES_CBC_SHA160_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_3DES_CBC_SHA256_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_3DES_CBC_SHA384_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_3DES_CBC_SHA512_HMAC, /**< AEAD transform. */ - NSS_CRYPTO_CMN_ALGO_MAX -}; - -/** - * nss_crypto_cmn_resp_error - * Response errors from crypto hardware - */ -enum nss_crypto_cmn_resp_error { - NSS_CRYPTO_CMN_RESP_ERROR_NONE = 0, /**< No error. */ - NSS_CRYPTO_CMN_RESP_ERROR_HDR_VERSION, /**< Header version mismatch. */ - NSS_CRYPTO_CMN_RESP_ERROR_CTX_RANGE, /**< Crypto index out-of-range. */ - NSS_CRYPTO_CMN_RESP_ERROR_CTX_NOUSE, /**< Crypto index is freed. */ - NSS_CRYPTO_CMN_RESP_ERROR_DATA_EMPTY, /**< Crypto data is empty. */ - NSS_CRYPTO_CMN_RESP_ERROR_DATA_LEN, /**< Crypto data length. */ - NSS_CRYPTO_CMN_RESP_ERROR_DATA_TIMEOUT, /**< Data timeout from hardware. */ - NSS_CRYPTO_CMN_RESP_ERROR_CIPHER_ALGO, /**< Cipher algorithm is not supported. */ - NSS_CRYPTO_CMN_RESP_ERROR_CIPHER_MODE, /**< Cipher mode is not supported. */ - NSS_CRYPTO_CMN_RESP_ERROR_CIPHER_BLK_LEN, /**< Cipher block length is not aligned. */ - NSS_CRYPTO_CMN_RESP_ERROR_HASH_CHECK, /**< Hash check failed. */ - NSS_CRYPTO_CMN_RESP_ERROR_HASH_NOSPACE, /**< No space to write hash. */ - NSS_CRYPTO_CMN_RESP_ERROR_HW_STATUS, /**< More errors in hardware status. */ - NSS_CRYPTO_CMN_RESP_ERROR_MAX -}; - -/** - * nss_crypto_cmn_msg_type - * Message types supported. - */ -enum nss_crypto_cmn_msg_type { - NSS_CRYPTO_CMN_MSG_TYPE_NONE = 0, /**< Invalid message. */ - NSS_CRYPTO_CMN_MSG_TYPE_SETUP_NODE, /**< Initialize node. */ - NSS_CRYPTO_CMN_MSG_TYPE_SETUP_ENG, /**< Initialize engine. */ - NSS_CRYPTO_CMN_MSG_TYPE_SETUP_DMA, /**< Initialize DMA pair. */ - NSS_CRYPTO_CMN_MSG_TYPE_SETUP_CTX, /**< Update context information. */ - NSS_CRYPTO_CMN_MSG_TYPE_CLEAR_CTX, /**< Clear context information. */ - NSS_CRYPTO_CMN_MSG_TYPE_VERIFY_CTX, /**< Verify if context is active. */ - NSS_CRYPTO_CMN_MSG_TYPE_SYNC_NODE_STATS, /**< Synchronous node statistics. */ - NSS_CRYPTO_CMN_MSG_TYPE_SYNC_ENG_STATS, /**< Synchronous engine statistics. */ - NSS_CRYPTO_CMN_MSG_TYPE_SYNC_CTX_STATS, /**< Synchronous context statistics. */ - NSS_CRYPTO_CMN_MSG_TYPE_MAX -}; - -/** - * nss_crypto_cmn_msg_error - * Message error types supported. - */ -enum nss_crypto_cmn_msg_error { - NSS_CRYPTO_CMN_MSG_ERROR_NONE = 0, - NSS_CRYPTO_CMN_MSG_ERROR_HDR_VERSION_NOSUPP, /**< Common header version not supported. */ - NSS_CRYPTO_CMN_MSG_ERROR_NODE_CTX_RANGE, /**< Context index out-of-range for node. */ - NSS_CRYPTO_CMN_MSG_ERROR_DMA_MASK, /**< DMA mask is out-of-range. */ - NSS_CRYPTO_CMN_MSG_ERROR_DMA_POW2, /**< DMA count is not a power-of-two. */ - NSS_CRYPTO_CMN_MSG_ERROR_DMA_MAX_TOKEN, /**< DMA count exceeds token count. */ - NSS_CRYPTO_CMN_MSG_ERROR_DMA_TOKEN_ALLOC, /**< Failed to allocate token. */ - NSS_CRYPTO_CMN_MSG_ERROR_CTX_RANGE, /**< Context index out-of-range. */ - NSS_CRYPTO_CMN_MSG_ERROR_CTX_INUSE, /**< Context has references. */ - NSS_CRYPTO_CMN_MSG_ERROR_CTX_WORDS, /**< Context size is bad. */ - NSS_CRYPTO_CMN_MSG_ERROR_CTX_ALGO, /**< Context algorithm is bad. */ - NSS_CRYPTO_CMN_MSG_ERROR_CTX_ALLOC, /**< Context alloc failed. */ - NSS_CRYPTO_CMN_MSG_ERROR_CTX_NOUSE, /**< Context has no references. */ - NSS_CRYPTO_CMN_MSG_ERROR_CTX_FLAGS, /**< Invalid context flags. */ - NSS_CRYPTO_CMN_MSG_ERROR_MAX -}; - -/** - * nss_crypto_cmn_ctx_flags - * Context message specific flags. - */ -enum nss_crypto_cmn_ctx_flags { - NSS_CRYPTO_CMN_CTX_FLAGS_NONE = 0, /**< Invalid flags. */ - NSS_CRYPTO_CMN_CTX_FLAGS_SEC_OFFSET = 0x01, /**< Secure offset is valid. */ - NSS_CRYPTO_CMN_CTX_FLAGS_SPARE0 = 0x02, /**< Spare word-0 valid. */ - NSS_CRYPTO_CMN_CTX_FLAGS_SPARE1 = 0x04, /**< Spare word-1 valid. */ - NSS_CRYPTO_CMN_CTX_FLAGS_SPARE2 = 0x08, /**< Spare word-2 valid. */ - NSS_CRYPTO_CMN_CTX_FLAGS_SPARE3 = 0x10, /**< Spare word-3 valid. */ - NSS_CRYPTO_CMN_CTX_FLAGS_MAX -}; - -/** - * nss_crypto_cmn_node - * Node message for setting up the crypto node. - * - * Note: Upon boot this is the first message sent by Host to NSS crypto. - * - It notifies the maximum number of crypto context. - * - It notifies the maximum number of DMA rings. - * - It returns the maximum size of crypto context record. - */ -struct nss_crypto_cmn_node { - uint32_t max_dma_rings; /**< Maximum DMA rings supported. */ - uint32_t max_ctx; /**< Maximum contexts. */ - uint32_t max_ctx_size; /**< Maximum context size. */ -}; - -/** - * nss_crypto_cmn_engine - * Engine message for setting up the instance of crypto engine. - * - * Note: This is sent after 'node' message for each engine to - * - Get valid DMA pairs supported by firmware. - * - Get maximum request/token count available in firmware. - */ -struct nss_crypto_cmn_engine { - uint32_t fw_ver[NSS_CRYPTO_CMN_VER_WORDS]; /**< Firmware version. */ - uint32_t dma_mask; /**< Max DMA rings. */ - uint32_t req_count; /**< Token count. */ -}; - -/** - * nss_crypto_cmn_dma - * DMA message for setting up each DMA pair per engine. - */ -struct nss_crypto_cmn_dma { - uint16_t pair_id; /**< DMA pair ID. */ -}; - -/** - * nss_crypto_cmn_ctx - * Context message for setting up a crypto context in firmware. - */ -struct nss_crypto_cmn_ctx { - uint32_t spare[NSS_CRYPTO_CMN_CTX_SPARE]; /**< Context spare words. */ - uint16_t index; /**< Crypto index. */ - uint16_t sec_offset; /**< Secure offset for copying keys. */ - - uint8_t cipher_key[NSS_CRYPTO_CIPHER_KEYLEN_MAX]; /**< Array containing cipher keys. */ - uint8_t auth_key[NSS_CRYPTO_AUTH_KEYLEN_MAX]; /**< Array containing authorization keys. */ - uint8_t nonce[NSS_CRYPTO_NONCE_SIZE_MAX]; /**< Nonce value. */ - - uint16_t auth_keylen; /**< Authorization key length. */ - uint8_t res[2]; /**< Reserved. */ - - enum nss_crypto_cmn_algo algo; /**< Crypto algorithm. */ - enum nss_crypto_cmn_ctx_flags flags; /**< Context specific flags. */ -}; - -/** - * nss_crypto_cmn_stats - * Statistics message applicable for node/engine/context. - */ -struct nss_crypto_cmn_stats { - struct nss_cmn_node_stats nstats; /**< Common node statistics. */ - uint32_t fail_version; /**< Version mismatch failures. */ - uint32_t fail_ctx; /**< Context related failures. */ - uint32_t fail_dma; /**< DMA descriptor full. */ -}; - -/** - * nss_crypto_cmn_msg - * Crypto common configuration message. - */ -struct nss_crypto_cmn_msg { - struct nss_cmn_msg cm; /**< Common header. */ - uint32_t seq_num; /**< Sequence number for messages. */ - uint32_t uid; /**< Unique ID to identify engine and context. */ - - union { - struct nss_crypto_cmn_node node; /**< Node message. */ - struct nss_crypto_cmn_engine eng; /**< Engine message. */ - struct nss_crypto_cmn_dma dma; /**< DMA message. */ - struct nss_crypto_cmn_ctx ctx; /**< Context message. */ - struct nss_crypto_cmn_stats stats; /**< Statistics message. */ - } msg; -}; - -#ifdef __KERNEL__ /* only kernel will use */ - -/** - * Callback function for receiving crypto transformation upon completion. - * - * @datatypes - * net_device \n - * sk_buff \n - * napi_struct - * - * @param[in] netdev Networking device registered for callback. - * @param[in] skb Packet buffer. - * @param[in] napi NAPI pointer for Linux NAPI handling. - * - * @return - * None. - */ -typedef void (*nss_crypto_cmn_buf_callback_t)(struct net_device *netdev, struct sk_buff *skb, - struct napi_struct *napi); - -/** - * Callback function for receiving crypto_cmn messages. - * - * @datatypes - * nss_crypto_cmn_msg - * - * @param[in] app_data Context of the callback user. - * @param[in] msg Crypto common message. - * - * @return - * None. - */ -typedef void (*nss_crypto_cmn_msg_callback_t)(void *app_data, struct nss_crypto_cmn_msg *msg); - -/** - * nss_crypto_cmn_tx_buf - * Send crypto payload to firmware for transformation. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx NSS context per NSS core. - * @param[in] if_num Crypto interface to send the buffer. - * @param[in] skb Crypto payload. - * - * @return - * Status of the TX operation. - */ -extern nss_tx_status_t nss_crypto_cmn_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, struct sk_buff *skb); - -/** - * nss_crypto_cmn_tx_msg - * Send crypto message to firmware for configuration. - * - * @datatypes - * nss_ctx_instance \n - * nss_crypto_cmn_msg - * - * @param[in] nss_ctx] NSS context per NSS core. - * @param[in] msg Control message. - * - * @return - * Status of the TX operation. - */ -extern nss_tx_status_t nss_crypto_cmn_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_crypto_cmn_msg *msg); - -/** - * nss_crypto_cmn_tx_msg - * Send crypto message to firmware for configuration synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_crypto_cmn_msg - * - * @param[in] nss_ctx NSS context per NSS core. - * @param[in,out] msg Crypto message, response data is copied. - * - * @return - * Status of the TX operation. - * - * @note - * Response data for the message is copied into the 'msg'. - * The caller should read the content of the 'msg' to find out errors. - * The caller needs to invoke this from a non-atomic context. - */ -extern nss_tx_status_t nss_crypto_cmn_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_crypto_cmn_msg *msg); - -/** - * nss_crypto_cmn_notify_register - * Register a event callback handler with NSS driver - * - * @datatypes - * nss_crypto_cmn_msg_callback_t - * - * @param[in] cb Event callback function. - * @param[in] app_data Context of the callback user. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_crypto_cmn_notify_register(nss_crypto_cmn_msg_callback_t cb, void *app_data); - -/** - * nss_crypto_cmn_notify_unregister - * De-register the event callback handler with NSS driver. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] ctx Pointer to the NSS context per NSS core. - * - * @return - * None. - */ -extern void nss_crypto_cmn_notify_unregister(struct nss_ctx_instance *ctx); - -/** - * nss_crypto_cmn_data_register - * Crypto data register. - * - * @datatypes - * nss_crypto_cmn_buf_callback_t \n - * net_device - * - * @param[in] if_num Interface number. - * @param[in] cb Callback function. - * @param[in] netdev Net device. - * @param[in] features Features supported. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_crypto_cmn_data_register(uint32_t if_num, - nss_crypto_cmn_buf_callback_t cb, - struct net_device *netdev, - uint32_t features); - -/** - * nss_crypto_cmn_data_unregister - * Crypto data de-register. - * - * @param[in] ctx NSS context per NSS core. - * @param[in] if_num Interface number. - * - * @return - * None. - */ -extern void nss_crypto_cmn_data_unregister(struct nss_ctx_instance *ctx, uint32_t if_num); - -/** - * nss_crypto_cmn_get_context - * Get the per NSS core context enabled for crypto. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_crypto_cmn_get_context(void); - -/** - * nss_crypto_cmn_msg_init - * Crypto common message initialization. - * - * @datatypes - * nss_crypto_cmn_msg \n - * nss_crypto_cmn_msg_callback_t - * - * @param[in] ncm Crypto common message. - * @param[in] if_num Interface number. - * @param[in] type Message type. - * @param[in] len Common message length. - * @param[in] cb Callback function. - * @param[in] app_data Appllication data. - * - * @return - * None. - */ -extern void nss_crypto_cmn_msg_init(struct nss_crypto_cmn_msg *ncm, uint16_t if_num, - uint32_t type, uint32_t len, nss_crypto_cmn_msg_callback_t cb, - void *app_data); - -#endif /*__KERNEL__ */ - -/** - * @} - */ -#endif diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_def.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_def.h deleted file mode 100644 index 9bfab7909..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_def.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - ************************************************************************** - * 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_def.h - * NSS definitions - */ - -#ifndef __NSS_DEF_H -#define __NSS_DEF_H - -/** - * @addtogroup nss_common_subsystem - * @{ - */ - -#define NSS_ETH_NORMAL_FRAME_MTU 1500 /**< MTU of a normal frame.*/ -#define NSS_ETH_MINI_JUMBO_FRAME_MTU 1978 /**< MTU of a mini-jumbo frame. */ -#define NSS_ETH_FULL_JUMBO_FRAME_MTU 9600 /**< MTU of a full jumbo frame. */ - -/** - * Number of ingress or egress VLANS supported in a connection entry. - */ -#define MAX_VLAN_DEPTH 2 - -/** - * Number of egress interfaces supported in a multicast connection entry. - */ -#define NSS_MC_IF_MAX 16 - -/** - * Real pointer size of the system. - */ -#ifdef __LP64__ -typedef uint64_t nss_ptr_t; -#else -typedef uint32_t nss_ptr_t; -#endif - -/** - * @} - */ - -#endif /** __NSS_DEF_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_dma.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_dma.h deleted file mode 100755 index d0aaa01de..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_dma.h +++ /dev/null @@ -1,333 +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. - ************************************************************************** - */ -/** - * @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_stats_types - * DMA node statistics. - */ -enum nss_dma_stats_types { - NSS_DMA_STATS_NO_REQ = NSS_STATS_NODE_MAX, - /**< Request descriptor not available. */ - NSS_DMA_STATS_NO_DESC, /**< DMA descriptors not available. */ - NSS_DMA_STATS_NEXTHOP, /**< Failed to retrive next hop. */ - NSS_DMA_STATS_FAIL_NEXTHOP_QUEUE, - /**< Failed to queue next hop. */ - NSS_DMA_STATS_FAIL_LINEAR_SZ, /**< Failed to get memory for linearization. */ - NSS_DMA_STATS_FAIL_LINEAR_ALLOC,/**< Failed to allocate buffer for linearization. */ - NSS_DMA_STATS_FAIL_LINEAR_NO_SG,/**< Skip linearization due to non-SG packet. */ - NSS_DMA_STATS_FAIL_SPLIT_SZ, /**< Failed to spliting buffer into multiple buffers. */ - NSS_DMA_STATS_FAIL_SPLIT_ALLOC, /**< Failed to allocate buffer for split. */ - NSS_DMA_STATS_FAIL_SYNC_ALLOC, /**< Failed to allocate buffer for sending statistics. */ - NSS_DMA_STATS_FAIL_CTX_ACTIVE, /**< Failed to queue as the node is not active. */ - NSS_DMA_STATS_FAIL_HW_E0, /**< Failed to process in hardware, error code E0. */ - NSS_DMA_STATS_FAIL_HW_E1, /**< Failed to process in hardware, error code E1. */ - NSS_DMA_STATS_FAIL_HW_E2, /**< Failed to process in hardware, error code E2. */ - NSS_DMA_STATS_FAIL_HW_E3, /**< Failed to process in hardware, error code E3. */ - NSS_DMA_STATS_FAIL_HW_E4, /**< Failed to process in hardware, error code E4. */ - NSS_DMA_STATS_FAIL_HW_E5, /**< Failed to process in hardware, error code E5. */ - NSS_DMA_STATS_FAIL_HW_E6, /**< Failed to process in hardware, error code E6. */ - NSS_DMA_STATS_FAIL_HW_E7, /**< Failed to process in hardware, error code E7. */ - NSS_DMA_STATS_FAIL_HW_E8, /**< Failed to process in hardware, error code E8. */ - NSS_DMA_STATS_FAIL_HW_E9, /**< Failed to process in hardware, error code E9. */ - NSS_DMA_STATS_FAIL_HW_E10, /**< Failed to process in hardware, error code E10. */ - NSS_DMA_STATS_FAIL_HW_E11, /**< Failed to process in hardware, error code E11. */ - NSS_DMA_STATS_FAIL_HW_E12, /**< Failed to process in hardware, error code E12. */ - NSS_DMA_STATS_FAIL_HW_E13, /**< Failed to process in hardware, error code E13. */ - NSS_DMA_STATS_FAIL_HW_E14, /**< Failed to process in hardware, error code E14. */ - NSS_DMA_STATS_FAIL_HW_E15, /**< Failed to process in hardware, error code E15. */ - NSS_DMA_STATS_MAX, /**< Maximum message 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. */ -}; - -/** - * nss_dma_stats_notification - * DMA transmission statistics structure. - */ -struct nss_dma_stats_notification { - uint64_t stats_ctx[NSS_DMA_STATS_MAX]; /**< Context transmission statistics. */ - uint32_t core_id; /**< Core ID. */ -}; - -#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. - * - * @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); - -/** - * nss_dma_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_dma_stats_unregister_notifier(struct notifier_block *nb); - -/** - * nss_dma_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_dma_stats_register_notifier(struct notifier_block *nb); -#endif /*__KERNEL__ */ - -/** - * @} - */ - -#endif /* __NSS_C2C_TX_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_dtls.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_dtls.h deleted file mode 100644 index d237bfda2..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_dtls.h +++ /dev/null @@ -1,335 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_dtls.h - * NSS DTLS interface definitions. - */ - -#ifndef _NSS_DTLS_H_ -#define _NSS_DTLS_H_ - -/** - * @addtogroup nss_dtls_subsystem - * @{ - */ - -#define NSS_MAX_DTLS_SESSIONS 8 /**< Maximum number of supported DTLS sessions. */ - -/** - * nss_dtls_metadata_types - * Message types for DTLS requests and responses. - */ -enum nss_dtls_metadata_types { - NSS_DTLS_MSG_SESSION_CONFIGURE, - NSS_DTLS_MSG_SESSION_DESTROY, - NSS_DTLS_MSG_SESSION_STATS, - NSS_DTLS_MSG_REKEY_ENCAP_CIPHER_UPDATE, - NSS_DTLS_MSG_REKEY_ENCAP_CIPHER_SWITCH, - NSS_DTLS_MSG_REKEY_DECAP_CIPHER_UPDATE, - NSS_DTLS_MSG_REKEY_DECAP_CIPHER_SWITCH, - NSS_DTLS_MSG_MAX -}; - -/** - * nss_dtls_error_response_types - * Error types for DTLS responses. - */ -enum nss_dtls_error_response_types { - NSS_DTLS_ERR_UNKNOWN_MSG = 1, - NSS_DTLS_ERR_INVALID_APP_IF = 2, - NSS_DTLS_ERR_INVALID_CPARAM = 3, - NSS_DTLS_ERR_INVALID_VER = 4, - NSS_DTLS_ERR_NOMEM = 5, - NSS_DTLS_ERR_MAX, -}; - -/** - * nss_dtls_session_stats - * DTLS session statistics. - */ -struct nss_dtls_session_stats { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - uint32_t tx_auth_done; /**< Tx authentication is done. */ - uint32_t rx_auth_done; /**< Rx authentication is successful. */ - uint32_t tx_cipher_done; /**< Tx cipher is complete. */ - uint32_t rx_cipher_done; /**< Rx cipher is complete. */ - uint32_t tx_cbuf_alloc_fail; /**< Tx crypto buffer allocation failure. */ - uint32_t rx_cbuf_alloc_fail; /**< Rx crypto buffer allocation failure. */ - uint32_t tx_cenqueue_fail; /**< Tx enqueue-to-crypto failure. */ - uint32_t rx_cenqueue_fail; /**< Rx enqueue-to-crypto failure. */ - uint32_t tx_dropped_hroom; - /**< Tx packets dropped because of insufficent headroom. */ - uint32_t tx_dropped_troom; - /**< Tx packets dropped because of insufficent tailroom. */ - uint32_t tx_forward_enqueue_fail; - /**< Tx enqueue failed to forward a node after encapsulation. */ - uint32_t rx_forward_enqueue_fail; - /**< Rx enqueue failed to receive a node after decapsulation. */ - uint32_t rx_invalid_version; /**< Rx invalid DTLS version. */ - uint32_t rx_invalid_epoch; /**< Rx invalid DTLS epoch. */ - uint32_t rx_malformed; /**< Rx malformed DTLS record. */ - uint32_t rx_cipher_fail; /**< Rx cipher failure. */ - uint32_t rx_auth_fail; /**< Rx authentication failure. */ - uint32_t rx_capwap_classify_fail; /**< Rx CAPWAP classification failure. */ - uint32_t rx_single_rec_dgram; /**< Rx single record datagrams processed. */ - uint32_t rx_multi_rec_dgram; /**< Rx multi-record datagrams processed. */ - uint32_t rx_replay_fail; /**< Rx anti-replay failures. */ - uint32_t rx_replay_duplicate; - /**< Rx anti-replay failed because of a duplicate record. */ - uint32_t rx_replay_out_of_window; - /**< Rx anti-replay failed because of an out-of-window record. */ - uint32_t outflow_queue_full; - /**< Tx packets dropped because the encapsulation queue is full. */ - uint32_t decap_queue_full; - /**< Rx packets dropped because the decapsulation queue is full. */ - uint32_t pbuf_alloc_fail; - /**< Packets dropped because of a buffer allocation failure. */ - uint32_t pbuf_copy_fail; - /**< Packets dropped because of a buffer copy failure. */ - uint16_t epoch; /**< Current epoch. */ - uint16_t tx_seq_high; /**< Upper 16 bits of the current sequence number. */ - uint32_t tx_seq_low; /**< Lower 32 bits of the current sequence number. */ -}; - -/** - * nss_dtls_session_cipher_update - * Information for a cipher update message in a DTLS session. - */ -struct nss_dtls_session_cipher_update { - uint32_t crypto_idx; /**< Crypto index for encapsulation. */ - uint32_t hash_len; /**< Authentication hash length for encapsulation. */ - uint32_t iv_len; /**< Crypto IV length for encapsulation. */ - uint32_t cipher_algo; /**< Encapsulation cipher. */ - uint32_t auth_algo; /**< Encapsulation authentication algorithm. */ - uint16_t epoch; /**< Epoch indicator. */ - uint16_t reserved; /**< Reserved for message alignment.*/ -}; - -/** - * nss_dtls_session_configure - * Configuration message for a DTLS session. - */ -struct nss_dtls_session_configure { - uint32_t ver; /**< DTLS version. */ - uint32_t flags; /**< DTLS flags. */ - uint32_t crypto_idx_encap; /**< Crypto index for encapsulation. */ - uint32_t crypto_idx_decap; /**< Crypto index for decapsulation. */ - uint32_t iv_len_encap; /**< Crypto IV length for encapsulation. */ - uint32_t iv_len_decap; /**< Crypto IV length for decapsulation. */ - uint32_t hash_len_encap; - /**< Authentication hash length for encapsulation. */ - uint32_t hash_len_decap; - /**< Authentication hash length for decapsulation. */ - uint32_t cipher_algo_encap; /**< Cipher algorithm for encapsulation. */ - uint32_t auth_algo_encap; /**< Authentication algorithm encapsulation. */ - uint32_t cipher_algo_decap; /**< Cipher algorithm for decapsulation. */ - uint32_t auth_algo_decap; /**< Authentication algorithm decapsulation. */ - uint32_t nss_app_if; - /**< Interface of the node that receives decapsulated packets. */ - uint16_t sport; /**< Source UDP/UDPLite port. */ - uint16_t dport; /**< Destination UDP/UDPLite port. */ - uint32_t sip[4]; /**< Source IPv4/IPv6 address. */ - uint32_t dip[4]; /**< Destination IPv4/IPv6 address. */ - uint16_t window_size; /**< Anti-replay window size. */ - uint16_t epoch; /**< Epoch indicator. */ - uint8_t oip_ttl; /**< Maximum outer IP time-to-live value. */ - uint8_t reserved1; /**< Reserved for message alignment. */ - uint16_t reserved2; /**< Reserved for message alignment. */ -}; - -/** - * nss_dtls_msg - * Data for sending and receiving DTLS messages. - */ -struct nss_dtls_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a DTLS message. - */ - union { - struct nss_dtls_session_configure cfg; - /**< Session configuration. */ - struct nss_dtls_session_cipher_update cipher_update; - /**< Cipher update information. */ - struct nss_dtls_session_stats stats; - /**< Session statistics. */ - } msg; /**< Message payload for DTLS session messages exchanged with NSS core. */ -}; - -/** - * nss_dtls_tx_buf - * Sends a DTLS data packet to the NSS. - * - * @datatypes - * sk_buff \n - * nss_ctx_instance - * - * @param[in] os_buf Pointer to the OS data buffer. - * @param[in] if_num NSS interface number. - * @param[in] nss_ctx Pointer to the NSS core context. - * - * @return - * Status of Tx buffer forwarded to NSS for DTLS operation. - */ -nss_tx_status_t nss_dtls_tx_buf(struct sk_buff *os_buf, uint32_t if_num, - struct nss_ctx_instance *nss_ctx); - -/** - * nss_dtls_tx_msg - * Sends DTLS messages. - * - * @param[in] nss_ctx Pointer to the NSS core context. - * @param[in,out] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_dtls_tx_msg(struct nss_ctx_instance *nss_ctx, - struct nss_dtls_msg *msg); - -/** - * nss_dtls_tx_msg_sync - * Sends DTLS messages synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_dtls_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in,out] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_dtls_tx_msg_sync(struct nss_ctx_instance *nss_ctx, - struct nss_dtls_msg *msg); - -/** - * Callback function for receiving DTLS messages. - * - * @datatypes - * nss_dtls_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_dtls_msg_callback_t)(void *app_data, - struct nss_dtls_msg *msg); - -/** - * Callback function for receiving DTLS session 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_dtls_data_callback_t)(struct net_device *netdev, - struct sk_buff *skb, - struct napi_struct *napi); - -/** - * nss_dtls_register_if - * Registers a DTLS session interface with the NSS for sending and receiving - * messages. - * - * @datatypes - * nss_dtls_data_callback_t \n - * nss_dtls_msg_callback_t - * - * @param[in] if_num NSS interface number. - * @param[in] cb Callback function for the message. - * @param[in] msg_callback Callback for DTLS tunnel message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * @param[in] app_ctx Pointer to the application context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_dtls_register_if(uint32_t if_num, - nss_dtls_data_callback_t cb, - nss_dtls_msg_callback_t msg_callback, - struct net_device *netdev, - uint32_t features, - void *app_ctx); - -/** - * nss_dtls_unregister_if - * Deregisters a DTLS session interface from the NSS. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - * - * @dependencies - * The DTLS session interface must have been previously registered. - */ -extern void nss_dtls_unregister_if(uint32_t if_num); - -/** - * nss_dtls_msg_init - * Initializes a DTLS message. - * - * @datatypes - * nss_dtls_msg - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context. - * - * @return - * None. - */ -extern void nss_dtls_msg_init(struct nss_dtls_msg *ncm, uint16_t if_num, - uint32_t type, uint32_t len, void *cb, - void *app_data); - -/** - * nss_dtls_get_context - * Gets the NSS core context for the DTLS session. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_dtls_get_context(void); - -/** - * nss_dtls_get_ifnum_with_coreid - * Gets the DTLS interface number with a core ID. - * - * @param[in] if_num NSS interface number. - * - * @return - * Interface number with the core ID. - */ -extern int32_t nss_dtls_get_ifnum_with_coreid(int32_t if_num); - -/** - * @} - */ - -#endif /* _NSS_DTLS_H_. */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_dtls_cmn.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_dtls_cmn.h deleted file mode 100644 index 78b166365..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_dtls_cmn.h +++ /dev/null @@ -1,512 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2017-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. - ************************************************************************** - */ - -/** - * @file nss_dtls_cmn.h - * NSS DTLS common interface definitions, supports inner/outer interface split. - */ - -#ifndef _NSS_DTLS_CMN_H_ -#define _NSS_DTLS_CMN_H_ - -/** - * @addtogroup nss_dtls_subsystem - * @{ - */ - -#define NSS_DTLS_CMN_CTX_HDR_IPV6 0x0001 /**< DTLS with IPv6. */ -#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_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. */ - -/** - * nss_dtls_cmn_metadata_types - * Message types for DTLS requests and responses. - */ -enum nss_dtls_cmn_msg_type { - NSS_DTLS_CMN_MSG_TYPE_CONFIGURE_NODE, /**< Configure DTLS firmware node. */ - NSS_DTLS_CMN_MSG_TYPE_CONFIGURE_HDR, /**< Configure the base context parameter. */ - NSS_DTLS_CMN_MSG_TYPE_CONFIGURE_DTLS, /**< Configure DTLS parameters. */ - NSS_DTLS_CMN_MSG_TYPE_SWITCH_DTLS, /**< Switch to new DTLS transform. */ - NSS_DTLS_CMN_MSG_TYPE_DECONFIGURE, /**< Deconfigure context. */ - NSS_DTLS_CMN_MSG_TYPE_SYNC_STATS, /**< Synchronize statistics. */ - NSS_DTLS_CMN_MSG_TYPE_NODE_STATS, /**< Node statistics. */ - NSS_DTLS_CMN_MSG_MAX -}; - -/** - * nss_dtls_cmn_error_response_types - * Error types for DTLS responses. - */ -enum nss_dtls_cmn_error { - NSS_DTLS_CMN_ERROR_NONE = 0, - NSS_DTLS_CMN_ERROR_UNKNOWN_MSG, - NSS_DTLS_CMN_ERROR_INVALID_DESTIF, - NSS_DTLS_CMN_ERROR_INVALID_SRCIF, - NSS_DTLS_CMN_ERROR_INVALID_CRYPTO, - NSS_DTLS_CMN_ERROR_INVALID_VER, - NSS_DTLS_CMN_ERROR_INVALID_CTX_TYPE, - NSS_DTLS_CMN_ERROR_INVALID_CTX_WORDS, - NSS_DTLS_CMN_ERROR_FAIL_ALLOC_HWCTX, - NSS_DTLS_CMN_ERROR_FAIL_COPY_CTX, - NSS_DTLS_CMN_ERROR_FAIL_SWITCH_HWCTX, - NSS_DTLS_CMN_ERROR_ALREADY_CONFIGURED, - NSS_DTLS_CMN_ERROR_FAIL_NOMEM, - NSS_DTLS_CMN_ERROR_FAIL_COPY_NONCE, - NSS_DTLS_CMN_ERROR_MAX, -}; - -/** - * nss_dtls_cmn_ctx_stats_types - * DTLS common context statistics types. - */ -enum nss_dtls_cmn_ctx_stats_types { - NSS_DTLS_CMN_STATS_RX_SINGLE_REC = NSS_STATS_NODE_MAX, - /**< Received single DTLS record datagrams. */ - NSS_DTLS_CMN_STATS_RX_MULTI_REC, /**< Received multiple DTLS record datagrams. */ - NSS_DTLS_CMN_STATS_FAIL_CRYPTO_RESOURCE,/**< Failure in crypto resource allocation. */ - NSS_DTLS_CMN_STATS_FAIL_CRYPTO_ENQUEUE, /**< Failure due to full queue in crypto or hardware. */ - NSS_DTLS_CMN_STATS_FAIL_HEADROOM, /**< Failure in headroom check. */ - NSS_DTLS_CMN_STATS_FAIL_TAILROOM, /**< Failure in tailroom check. */ - NSS_DTLS_CMN_STATS_FAIL_VER, /**< Failure in DTLS version check. */ - NSS_DTLS_CMN_STATS_FAIL_EPOCH, /**< Failure in DTLS epoch check. */ - NSS_DTLS_CMN_STATS_FAIL_DTLS_RECORD, /**< Failure in reading DTLS record. */ - NSS_DTLS_CMN_STATS_FAIL_CAPWAP, /**< Failure in CAPWAP classification. */ - NSS_DTLS_CMN_STATS_FAIL_REPLAY, /**< Failure in anti-replay check. */ - NSS_DTLS_CMN_STATS_FAIL_REPLAY_DUP, /**< Failure in anti-replay; duplicate records. */ - NSS_DTLS_CMN_STATS_FAIL_REPLAY_WIN, /**< Failure in anti-replay; packet outside the window. */ - NSS_DTLS_CMN_STATS_FAIL_QUEUE, /**< Failure due to full queue in DTLS. */ - NSS_DTLS_CMN_STATS_FAIL_QUEUE_NEXTHOP, /**< Failure due to full queue in next hop. */ - NSS_DTLS_CMN_STATS_FAIL_PBUF_ALLOC, /**< Failure in pbuf allocation. */ - NSS_DTLS_CMN_STATS_FAIL_PBUF_LINEAR, /**< Failure in pbuf linearization. */ - NSS_DTLS_CMN_STATS_FAIL_PBUF_STATS, /**< Failure in pbuf allocation for statistics. */ - NSS_DTLS_CMN_STATS_FAIL_PBUF_ALIGN, /**< Failure in pbuf alignment. */ - NSS_DTLS_CMN_STATS_FAIL_CTX_ACTIVE, /**< Failure in enqueue due to inactive context. */ - NSS_DTLS_CMN_STATS_FAIL_HWCTX_ACTIVE, /**< Failure in enqueue due to inactive hardware context. */ - NSS_DTLS_CMN_STATS_FAIL_CIPHER, /**< Failure in decrypting the data. */ - NSS_DTLS_CMN_STATS_FAIL_AUTH, /**< Failure in authenticating the data. */ - NSS_DTLS_CMN_STATS_FAIL_SEQ_OVF, /**< Failure due to sequence number overflow. */ - NSS_DTLS_CMN_STATS_FAIL_BLK_LEN, /**< Failure in decapsulation due to bad cipher length. */ - NSS_DTLS_CMN_STATS_FAIL_HASH_LEN, /**< Failure in decapsulation due to bad hash length. */ - NSS_DTLS_CMN_STATS_LEN_ERROR, /**< Length error. */ - NSS_DTLS_CMN_STATS_TOKEN_ERROR, /**< Token error, unknown token command or instruction. */ - NSS_DTLS_CMN_STATS_BYPASS_ERROR, /**< Token contains too much bypass data. */ - NSS_DTLS_CMN_STATS_CONFIG_ERROR, /**< Invalid command, algorithm, or mode combination. */ - NSS_DTLS_CMN_STATS_ALGO_ERROR, /**< Unsupported algorithm. */ - NSS_DTLS_CMN_STATS_HASH_OVF_ERROR, /**< Hash input overflow. */ - NSS_DTLS_CMN_STATS_TTL_ERROR, /**< TTL or HOP-Limit underflow. */ - NSS_DTLS_CMN_STATS_CSUM_ERROR, /**< Checksum error. */ - NSS_DTLS_CMN_STATS_TIMEOUT_ERROR, /**< Data timed out. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_0, /**< Classification failure 0. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_1, /**< Classification failure 1. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_2, /**< Classification failure 2. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_3, /**< Classification failure 3. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_4, /**< Classification failure 4. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_5, /**< Classification failure 5. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_6, /**< Classification failure 6. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_7, /**< Classification failure 7. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_8, /**< Classification failure 8. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_9, /**< Classification failure 9. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_10, /**< Classification failure 10. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_11, /**< Classification failure 11. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_12, /**< Classification failure 12. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_13, /**< Classification failure 13. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_14, /**< Classification failure 14. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_15, /**< Classification failure 15. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_16, /**< Classification failure 16. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_17, /**< Classification failure 17. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_18, /**< Classification failure 18. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_19, /**< Classification failure 19. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_20, /**< Classification failure 20. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_21, /**< Classification failure 21. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_22, /**< Classification failure 22. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_23, /**< Classification failure 23. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_24, /**< Classification failure 24. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_25, /**< Classification failure 25. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_26, /**< Classification failure 26. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_27, /**< Classification failure 27. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_28, /**< Classification failure 28. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_29, /**< Classification failure 29. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_30, /**< Classification failure 30. */ - NSS_DTLS_CMN_STATS_CLE_ERROR_31, /**< Classification failure 31. */ - NSS_DTLS_CMN_STATS_SEQ_LOW, /**< Lower 32 bits of current transmit sequence number. */ - NSS_DTLS_CMN_STATS_SEQ_HIGH, /**< Upper 16 bits of current transmit sequence number. */ - NSS_DTLS_CMN_STATS_EPOCH, /**< Current epoch value. */ - NSS_DTLS_CMN_CTX_STATS_MAX, /**< Maximum message type. */ -}; - -/** - * nss_dtls_cmn_node_stats - * DTLS node statistics. - */ -struct nss_dtls_cmn_node_stats { - uint32_t fail_ctx_alloc; /**< Failure in allocating a context. */ - uint32_t fail_ctx_free; /**< Failure in freeing up the context. */ - uint32_t fail_pbuf_stats; /**< Failure in pbuf allocation for statistics. */ -}; - -/** - * nss_dtls_cmn_hw_stats - * DTLS hardware statistics. - */ -struct nss_dtls_cmn_hw_stats { - uint32_t len_error; /**< Length error. */ - uint32_t token_error; /**< Token error, unknown token command/instruction. */ - uint32_t bypass_error; /**< Token contains too much bypass data. */ - uint32_t config_error; /**< Invalid command/algorithm/mode/combination. */ - uint32_t algo_error; /**< Unsupported algorithm. */ - uint32_t hash_ovf_error; /**< Hash input overflow. */ - uint32_t ttl_error; /**< TTL or HOP-Limit underflow. */ - uint32_t csum_error; /**< Checksum error. */ - uint32_t timeout_error; /**< Data timed-out. */ -}; - -/** - * nss_dtls_cmn_ctx_stats - * DTLS session statistics. - */ -struct nss_dtls_cmn_ctx_stats { - struct nss_cmn_node_stats pkt; /**< Common node statistics. */ - uint32_t rx_single_rec; /**< Received single DTLS record datagrams. */ - uint32_t rx_multi_rec; /**< Received multiple DTLS record datagrams. */ - uint32_t fail_crypto_resource; /**< Failure in allocation of crypto resource. */ - uint32_t fail_crypto_enqueue; /**< Failure due to queue full in crypto or hardware. */ - uint32_t fail_headroom; /**< Failure in headroom check. */ - uint32_t fail_tailroom; /**< Failure in tailroom check. */ - uint32_t fail_ver; /**< Failure in DTLS version check. */ - uint32_t fail_epoch; /**< Failure in DTLS epoch check. */ - uint32_t fail_dtls_record; /**< Failure in reading DTLS record. */ - uint32_t fail_capwap; /**< Failure in CAPWAP classification. */ - uint32_t fail_replay; /**< Failure in anti-replay check. */ - uint32_t fail_replay_dup; /**< Failure in anti-replay; duplicate records. */ - uint32_t fail_replay_win; /**< Failure in anti-replay; packet outside the window. */ - uint32_t fail_queue; /**< Failure due to queue full in DTLS. */ - uint32_t fail_queue_nexthop; /**< Failure due to queue full in next_hop. */ - 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 alignment. */ - uint32_t fail_ctx_active; /**< Failure in enqueue due to inactive context. */ - uint32_t fail_hwctx_active; /**< Failure in enqueue due to inactive hardware context. */ - 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 overflow. */ - uint32_t fail_blk_len; /**< Failure in decapsulation due to bad cipher block length. */ - uint32_t fail_hash_len; /**< Failure in decapsulation due to bad hash block length. */ - - struct nss_dtls_cmn_hw_stats fail_hw; /**< Hardware failure statistics. */ - - uint32_t fail_cle[NSS_DTLS_CMN_CLE_MAX];/**< Classification errors. */ - - uint32_t seq_low; /**< Lower 32 bits of current Tx sequence number. */ - uint32_t seq_high; /**< Upper 16 bits of current Tx sequence number. */ - - uint16_t epoch; /**< Current epoch value. */ - uint8_t res1[2]; /**< Reserved for future use. */ - - uint8_t res2[16]; /**< Reserved for future use. */ -}; - -/** - * nss_dtls_cmn_ctx_config_hdr - * Parameters for outer header transform. - */ -struct nss_dtls_cmn_ctx_config_hdr { - uint32_t flags; /**< Context flags. */ - uint32_t dest_ifnum; /**< Destination interface for packets. */ - uint32_t src_ifnum; /**< Source interface of packets. */ - uint32_t sip[4]; /**< Source IPv4/v6 address. */ - uint32_t dip[4]; /**< Destination IPv4/v6 address. */ - - uint16_t sport; /**< Source UDP/UDPLite port. */ - uint16_t dport; /**< Destination UDP/UDPLite port. */ - - uint8_t hop_limit_ttl; /**< IP header TTL field. */ - uint8_t dscp; /**< DSCP value. */ - uint8_t dscp_copy; /**< Copy DSCP value. */ - uint8_t df; /**< Do not fragment DTLS over IPv4. */ -}; - -/** - * nss_dtls_cmn_ctx_config_dtls - * Parameters for DTLS transform. - */ -struct nss_dtls_cmn_ctx_config_dtls { - uint32_t ver; /**< Version (enum dtls_cmn_ver). */ - uint32_t crypto_idx; /**< Crypto index for cipher context. */ - - uint16_t window_size; /**< Anti-replay window size. */ - uint16_t epoch; /**< Initial epoch value. */ - - uint8_t iv_len; /**< Crypto IV length for encapsulation. */ - uint8_t hash_len; /**< Auth hash length for encapsulation. */ - uint8_t blk_len; /**< Cipher block length. */ - uint8_t res1; /**< Reserved for alignment. */ -}; - -/** - * nss_dtls_cmn_stats_notification - * DTLS common transmission statistics structure. - */ -struct nss_dtls_cmn_stats_notification { - uint64_t stats_ctx[NSS_DTLS_CMN_CTX_STATS_MAX]; /**< Context transmission statistics. */ - uint32_t core_id; /**< Core ID. */ - uint32_t if_num; /**< Interface number. */ -}; - -/** - * nss_dtls_cmn_msg - * Data for sending and receiving DTLS messages. - */ -struct nss_dtls_cmn_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a DTLS message. - */ - union { - struct nss_dtls_cmn_ctx_config_hdr hdr_cfg; /**< Session configuration. */ - struct nss_dtls_cmn_ctx_config_dtls dtls_cfg; /**< Cipher update information. */ - struct nss_dtls_cmn_ctx_stats stats; /**< Session statistics. */ - struct nss_dtls_cmn_node_stats node_stats; /**< Node statistics. */ - } msg; /**< Message payload for DTLS session messages exchanged with NSS core. */ -}; - -#ifdef __KERNEL__ /* only for kernel use. */ -/** - * Callback function for receiving DTLS messages. - * - * @datatypes - * nss_dtls_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_dtls_cmn_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * Callback function for receiving DTLS session 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_dtls_cmn_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_dtls_cmn_tx_buf - * Sends a DTLS data packet to the NSS. - * - * @datatypes - * sk_buff \n - * nss_ctx_instance - * - * @param[in] os_buf Pointer to the OS data buffer. - * @param[in] if_num NSS interface number. - * @param[in] nss_ctx Pointer to the NSS core context. - * - * @return - * Status of Tx buffer forwarded to NSS for DTLS operation. - */ -nss_tx_status_t nss_dtls_cmn_tx_buf(struct sk_buff *os_buf, uint32_t if_num, struct nss_ctx_instance *nss_ctx); - -/** - * nss_dtls_cmn_tx_msg - * Sends DTLS messages. - * - * @param[in] nss_ctx Pointer to the NSS core context. - * @param[in,out] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_dtls_cmn_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_dtls_cmn_msg *msg); - -/** - * nss_dtls_cmn_tx_msg_sync - * Sends DTLS messages synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_dtls_cmn_msg_type \n - * nss_dtls_cmn_msg \n - * nss_dtls_cmn_error - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] ndcm Pointer to the message data. - * @param[in,out] resp Response for the configuration. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_dtls_cmn_tx_msg_sync(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - enum nss_dtls_cmn_msg_type type, uint16_t len, - struct nss_dtls_cmn_msg *ndcm, enum nss_dtls_cmn_error *resp); - -/** - * nss_dtls_cmn_unregister_if - * Deregisters a DTLS session interface from the NSS. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - * - * @dependencies - * The DTLS session interface must have been previously registered. - */ -extern void nss_dtls_cmn_unregister_if(uint32_t if_num); - -/** - * nss_dtls_cmn_register_if - * Registers a DTLS session interface with the NSS for sending and receiving - * messages. - * - * @datatypes - * nss_dtls_cmn_data_callback_t \n - * nss_dtls_cmn_msg_callback_t - * - * @param[in] if_num NSS interface number. - * @param[in] data_cb Callback function for the message. - * @param[in] msg_cb Callback for DTLS tunnel message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * @param[in] type Type of message. - * @param[in] app_ctx Pointer to the application context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_dtls_cmn_register_if(uint32_t if_num, - nss_dtls_cmn_data_callback_t data_cb, - nss_dtls_cmn_msg_callback_t msg_cb, - struct net_device *netdev, - uint32_t features, - uint32_t type, - void *app_ctx); - -/** - * nss_dtls_cmn_notify_unregister - * Deregisters an event callback. - * - * @param[in] ifnum NSS interface number. - * - * @return - * None. - */ -extern void nss_dtls_cmn_notify_unregister(uint32_t ifnum); - -/** - * nss_dtls_cmn_notify_register - * Registers an event callback to handle notification from DTLS firmware package. - * - * @param[in] ifnum NSS interface number. - * @param[in] ev_cb Callback for DTLS tunnel message. - * @param[in] app_data Pointer to the application context. - * - * @return - * Pointer to NSS core context. - */ -extern struct nss_ctx_instance *nss_dtls_cmn_notify_register(uint32_t ifnum, nss_dtls_cmn_msg_callback_t ev_cb, - void *app_data); - -/** - * nss_dtls_cmn_msg_init - * Initializes a DTLS message. - * - * @datatypes - * nss_dtls_cmn_msg - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context. - * - * @return - * None. - */ -extern void nss_dtls_cmn_msg_init(struct nss_dtls_cmn_msg *ncm, uint32_t if_num, uint32_t type, uint32_t len, void *cb, - void *app_data); - -/** - * nss_dtls_cmn_get_context - * Gets the NSS core context for the DTLS session. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_dtls_cmn_get_context(void); - -/** - * nss_dtls_cmn_get_ifnum - * Gets the DTLS interface number with a core ID. - * - * @param[in] if_num NSS interface number. - * - * @return - * Interface number with the core ID. - */ -extern int32_t nss_dtls_cmn_get_ifnum(int32_t if_num); - -/** - * nss_dtls_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_dtls_cmn_stats_unregister_notifier(struct notifier_block *nb); - -/** - * nss_dtls_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_dtls_cmn_stats_register_notifier(struct notifier_block *nb); - -/** - * @} - */ - -#endif /* __KERNEL__ */ -#endif /* _NSS_DTLS_CMN_H_. */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_dynamic_interface.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_dynamic_interface.h deleted file mode 100644 index 7595af151..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_dynamic_interface.h +++ /dev/null @@ -1,343 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_dynamic_interface.h - * NSS Dynamic interface definitions. - */ - -#ifndef __NSS_DYNAMIC_INTERFACE_H -#define __NSS_DYNAMIC_INTERFACE_H - -/** - * @addtogroup nss_dynamic_interface_subsystem - * @{ - */ - -#define NSS_MAX_DYNAMIC_INTERFACES 128 /**< Maximum number of dynamic interfaces. */ - -/** - * nss_dynamic_interface_type - * Dynamic interface types. - * - * @note - * Every time a new dynamic interface type is added to an enumeration in the following list, - * a corresponding type name string should be added in the dynamic interface type string array. - */ -enum nss_dynamic_interface_type { - NSS_DYNAMIC_INTERFACE_TYPE_NONE, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR, - NSS_DYNAMIC_INTERFACE_TYPE_RESERVED_5, - NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_RESERVED, - NSS_DYNAMIC_INTERFACE_TYPE_VAP, - NSS_DYNAMIC_INTERFACE_TYPE_RESERVED_0, - NSS_DYNAMIC_INTERFACE_TYPE_PPPOE, - NSS_DYNAMIC_INTERFACE_TYPE_VIRTIF_DEPRECATED, - NSS_DYNAMIC_INTERFACE_TYPE_L2TPV2, - NSS_DYNAMIC_INTERFACE_TYPE_RESERVED_4, - NSS_DYNAMIC_INTERFACE_TYPE_PORTID, - NSS_DYNAMIC_INTERFACE_TYPE_DTLS, - NSS_DYNAMIC_INTERFACE_TYPE_QVPN_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_QVPN_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_BRIDGE, - NSS_DYNAMIC_INTERFACE_TYPE_VLAN, - NSS_DYNAMIC_INTERFACE_TYPE_RESERVED_3, - NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_INTERNAL, - NSS_DYNAMIC_INTERFACE_TYPE_MAP_T_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_MAP_T_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_HOST_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_OFFL_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_SJACK_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INLINE_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INLINE_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H, - NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N, - NSS_DYNAMIC_INTERFACE_TYPE_TUN6RD_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_TUN6RD_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INNER_EXCEPTION, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_US, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_DS, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_GRE_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_PPTP_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_PPTP_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_PPTP_HOST_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_MDATA_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_MDATA_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_REDIRECT, - NSS_DYNAMIC_INTERFACE_TYPE_PVXLAN_HOST_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_PVXLAN_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_IGS, - NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_US, - NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_DS, - NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_MATCH, - NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_N2H, - NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_H2N, - 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, - NSS_DYNAMIC_INTERFACE_TYPE_MAX -}; - -typedef enum nss_dynamic_interface_type nss_dynamic_interface_assigned; - -/** - * nss_dynamic_interface_message_types - * Message types for dynamic interface requests. - */ -enum nss_dynamic_interface_message_types { - NSS_DYNAMIC_INTERFACE_ALLOC_NODE, - NSS_DYNAMIC_INTERFACE_DEALLOC_NODE, - NSS_DYNAMIC_INTERFACE_MAX, -}; - -/** - * nss_dynamic_interface_error_types - * Error types for dynamic interface requests. - */ -enum nss_dynamic_interface_error_types { - NSS_DYNAMIC_INTERFACE_ERR_EUNKNOWN = 1, - NSS_DYNAMIC_INTERFACE_ERR_EUNAVAIL, - NSS_DYNAMIC_INTERFACE_ERR_INVALID_TYPE, - NSS_DYNAMIC_INTERFACE_ERR_INVALID_INTERFACE_NUM, - NSS_DYNAMIC_INTERFACE_ERR_ALLOC_FUNC_UNAVAILABLE, - NSS_DYNAMIC_INTERFACE_ERR_DEALLOC_FUNC_UNAVAILABLE, - NSS_DYNAMIC_INTERFACE_ERR_EALLOC, - NSS_DYNAMIC_INTERFACE_ERR_IFNUM_TYPE_MISMATCH, - NSS_DYNAMIC_INTERFACE_ERR_MAX, -}; - -/** - * nss_dynamic_interface_stats_notification - * Dynamic interface statistics structure. - */ -struct nss_dynamic_interface_notification { - uint32_t core_id; /**< Core ID. */ - uint32_t if_num; /**< Dynamic interface number. */ -}; - -#ifdef __KERNEL__ /* only kernel will use. */ -/** - * nss_dynamic_interface_alloc_node_msg - * Message information for a dynamic interface allocation node. - */ -struct nss_dynamic_interface_alloc_node_msg { - enum nss_dynamic_interface_type type; /**< Type of dynamic interface. */ - - /* - * Response. - */ - int if_num; /**< Dynamic interface number. */ -}; - -/** - * nss_dynamic_interface_dealloc_node_msg - * Message information for dynamic interface deallocation node. - */ -struct nss_dynamic_interface_dealloc_node_msg { - enum nss_dynamic_interface_type type; - /**< Type of dynamic interface. */ - int if_num; /**< Dynamic interface number. */ -}; - -/** - * nss_dynamic_interface_msg - * Data for sending and receiving dynamic interface messages. - */ -struct nss_dynamic_interface_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a dynamic interface message. - */ - union { - struct nss_dynamic_interface_alloc_node_msg alloc_node; - /**< Allocates a dynamic node. */ - struct nss_dynamic_interface_dealloc_node_msg dealloc_node; - /**< Deallocates a dynamic node. */ - } msg; /**< Message payload. */ -}; - -/** - * nss_dynamic_interface_alloc_node - * Allocates a node for a dynamic interface. - * - * @datatypes - * nss_dynamic_interface_type - * - * @param[in] type Type of dynamic interface. - * - * @return - * Number for the dynamic interface created. - * @par - * Otherwise, -1 for a failure. - */ -extern int nss_dynamic_interface_alloc_node(enum nss_dynamic_interface_type type); - -/** - * nss_dynamic_interface_dealloc_node - * Deallocates a node created for a dynamic interface on the NSS. - * - * @datatypes - * nss_dynamic_interface_type - * - * @param[in] if_num Dynamic interface number. - * @param[in] type Type of dynamic interface. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_dynamic_interface_dealloc_node(int if_num, enum nss_dynamic_interface_type type); - -/** - * nss_is_dynamic_interface - * Specifies whether the interface number belongs to the dynamic interface. - * - * @param[in] if_num Dynamic interface number. - * - * @return - * TRUE or FALSE - */ -extern bool nss_is_dynamic_interface(int if_num); - -/** - * nss_dynamic_interface_get_nss_ctx_by_type - * Returns NSS context corresponding to the dynamic interface type. - * - * @datatypes - * nss_dynamic_interface_type - * - * @param[in] type Type of dynamic interface. - * - * @return - * Pointer to the NSS context. - */ -extern struct nss_ctx_instance *nss_dynamic_interface_get_nss_ctx_by_type(enum nss_dynamic_interface_type type); - -/** - * nss_dynamic_interface_get_type - * Returns the type of dynamic interface. - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] if_num Interface number of dynamic interface. - * - * @return - * Type of dynamic interface per the dynamic interface number. - */ -extern enum nss_dynamic_interface_type nss_dynamic_interface_get_type(struct nss_ctx_instance *nss_ctx, int if_num); - -/** - * nss_dynamic_interface_tx - * Transmits an asynchronous message to the firmware. - * - * @datatypes - * nss_ctx_instance \n - * nss_dynamic_interface_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] msg Pointer to the message data. - * - * @return - * Status of the transmit operation. - */ -extern nss_tx_status_t nss_dynamic_interface_tx(struct nss_ctx_instance *nss_ctx, struct nss_dynamic_interface_msg *msg); - -/** - * Callback function for dynamic interface 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_dynamic_interface_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * nss_dynamic_interface_msg_init - * Initializes a dynamic interface message. - * - * @datatypes - * nss_dynamic_interface_msg - * - * @param[in] ndm Pointer to the dynamic interface message. - * @param[in] if_num Dynamic interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context that is passed to the callback function. - * - * @return - * None. - */ -void nss_dynamic_interface_msg_init(struct nss_dynamic_interface_msg *ndm, uint16_t if_num, uint32_t type, uint32_t len, - void *cb, void *app_data); - -/** - * nss_dynamic_interface_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_dynamic_interface_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_dynamic_interface_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_dynamic_interface_stats_unregister_notifier(struct notifier_block *nb); -#endif /*__KERNEL__ */ - -/** - * @} - */ - -#endif /* __NSS_DYNAMIC_INTERFACE_H*/ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_edma.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_edma.h deleted file mode 100644 index d5cecf79a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_edma.h +++ /dev/null @@ -1,375 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_edma.h - * NSS EDMA interface definitions. - */ - -#ifndef __NSS_EDMA_H -#define __NSS_EDMA_H - -/** - * @addtogroup nss_edma_subsystem - * @{ - */ - -/* - * NSS EDMA port and ring defines - */ -#define NSS_EDMA_NUM_PORTS_MAX 256 - /**< Maximum number of EDMA ports. */ -#define NSS_EDMA_NUM_RX_RING_MAX 16 - /**< Maximum number of physical EDMA Rx rings. */ -#define NSS_EDMA_NUM_RXFILL_RING_MAX 8 - /**< Maximum number of physical EDMA Rx fill rings. */ -#define NSS_EDMA_NUM_TX_RING_MAX 24 - /**< Maximum number of physical EDMA Tx rings. */ -#define NSS_EDMA_NUM_TXCMPL_RING_MAX 8 - /**< Maximum number of physical EDMA Tx complete rings. */ -#define NSS_EDMA_STATS_MSG_MAX_PORTS 16 - /**< Maximum ports processed per statistics message. */ - -/** - * nss_edma_metadata_types - * Message types for EDMA requests and responses. - */ -enum nss_edma_metadata_types { - NSS_METADATA_TYPE_EDMA_PORT_STATS_SYNC, - NSS_METADATA_TYPE_EDMA_RING_STATS_SYNC, - NSS_METADATA_TYPE_EDMA_ERR_STATS_SYNC, - NSS_METADATA_TYPE_EDMA_MAX -}; - -/** - * nss_edma_port_t - * EDMA port types. - */ -enum nss_edma_port_t { - NSS_EDMA_PORT_PHYSICAL, - NSS_EDMA_PORT_VIRTUAL, - NSS_EDMA_PORT_TYPE_MAX -}; - -/** - * nss_edma_stats_tx_t - * Types of EDMA Tx ring statistics. - */ -enum nss_edma_stats_tx_t { - NSS_EDMA_STATS_TX_ERR, - NSS_EDMA_STATS_TX_DROPPED, - NSS_EDMA_STATS_TX_DESC, - NSS_EDMA_STATS_TX_MAX -}; - -/** - * nss_edma_stats_rx_t - * Types of EDMA Rx ring statistics. - */ -enum nss_edma_stats_rx_t { - NSS_EDMA_STATS_RX_CSUM_ERR, - 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 -}; - -/** - * nss_edma_stats_txcmpl_t - * Types of EDMA Tx complete statistics. - */ -enum nss_edma_stats_txcmpl_t { - NSS_EDMA_STATS_TXCMPL_DESC, - NSS_EDMA_STATS_TXCMPL_MAX -}; - -/** - * nss_edma_stats_rxfill_t - * Types of EDMA Rx fill statistics. - */ -enum nss_edma_stats_rxfill_t { - NSS_EDMA_STATS_RXFILL_DESC, - NSS_EDMA_STATS_RXFILL_MAX -}; - -/** - * nss_edma_port_ring_map_t - * Port to EDMA ring map. - */ -enum nss_edma_port_ring_map_t { - NSS_EDMA_PORT_RX_RING, - NSS_EDMA_PORT_TX_RING, - NSS_EDMA_PORT_RING_MAP_MAX -}; - -/** - * nss_edma_err_t - * Types of EDMA error statistics. - */ -enum nss_edma_err_t { - NSS_EDMA_AXI_RD_ERR, - NSS_EDMA_AXI_WR_ERR, - NSS_EDMA_RX_DESC_FIFO_FULL_ERR, - NSS_EDMA_RX_BUF_SIZE_ERR, - NSS_EDMA_TX_SRAM_FULL_ERR, - NSS_EDMA_TX_CMPL_BUF_FULL_ERR, - NSS_EDMA_PKT_LEN_LA64K_ERR, - NSS_EDMA_PKT_LEN_LE33_ERR, - NSS_EDMA_DATA_LEN_ERR, - NSS_EDMA_ALLOC_FAIL_CNT, - NSS_EDMA_QOS_INVAL_DST_DROPS, - NSS_EDMA_ERR_STATS_MAX -}; - -/** - * nss_edma_rx_ring_stats - * EDMA Rx ring statistics. - */ -struct nss_edma_rx_ring_stats { - uint32_t rx_csum_err; /**< Number of Rx checksum errors. */ - 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. */ -}; - -/** - * nss_edma_tx_ring_stats - * EDMA Tx ring statistics. - */ -struct nss_edma_tx_ring_stats { - uint32_t tx_err; /**< Number of Tx errors. */ - uint32_t tx_dropped; /**< Number of Tx dropped packets. */ - uint32_t desc_cnt; /**< Number of descriptors processed. */ -}; - -/** - * nss_edma_rxfill_ring_stats - * EDMA Rx fill ring statistics. - */ -struct nss_edma_rxfill_ring_stats { - uint32_t desc_cnt; /**< Number of descriptors processed. */ -}; - -/** - * nss_edma_txcmpl_ring_stats - * EDMA Tx complete ring statistics. - */ -struct nss_edma_txcmpl_ring_stats { - uint32_t desc_cnt; /**< Number of descriptors processed. */ -}; - -/** - * nss_edma_port_stats - * Statistics for each EDMA port. - */ -struct nss_edma_port_stats { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - enum nss_edma_port_t port_type; /**< Type of port. */ - uint16_t edma_rx_ring; /**< Rx ring statistics. */ - uint16_t edma_tx_ring; /**< Tx ring statistics. */ -}; - -/** - * nss_edma_port_stats_sync - * Statistics for a group of EDMA ports. - */ -struct nss_edma_port_stats_sync { - uint16_t start_port; /**< Starting index of the subset. */ - uint16_t end_port; /**< Ending index of the subset. */ - struct nss_edma_port_stats port_stats[]; - /**< Subset of EDMA port statistics. */ -}; - -/** - * nss_edma_ring_stats_sync - * EDMA ring statistics. - */ -struct nss_edma_ring_stats_sync { - struct nss_edma_tx_ring_stats tx_ring[NSS_EDMA_NUM_TX_RING_MAX]; - /**< EDMA Tx ring statistics. */ - struct nss_edma_rx_ring_stats rx_ring[NSS_EDMA_NUM_RX_RING_MAX]; - /**< EDMA Rx ring statistics. */ - struct nss_edma_txcmpl_ring_stats txcmpl_ring[NSS_EDMA_NUM_TXCMPL_RING_MAX]; - /**< EDMA Tx complete ring statistics. */ - struct nss_edma_rxfill_ring_stats rxfill_ring[NSS_EDMA_NUM_RXFILL_RING_MAX]; - /**< EDMA Rx fill ring statistics. */ -}; - -/** - * nss_edma_misc_err_stats - * EDMA error statistics. - */ -struct nss_edma_misc_err_stats { - uint32_t axi_rd_err; /**< EDMA AXI read error. */ - uint32_t axi_wr_err; /**< EDMA AXI write error. */ - uint32_t rx_desc_fifo_full_err; /**< EDMA receive descriptor FIFO full error. */ - uint32_t rx_buf_size_err; /**< EDMA receive buffer size error. */ - uint32_t tx_sram_full_err; /**< EDMA transmit SRAM full error. */ - uint32_t tx_cmpl_buf_full_err; /**< EDMA transmit completion buffer full error. */ - uint32_t pkt_len_la64k_err; /**< EDMA packet length greater than 64k error. */ - uint32_t pkt_len_le33_err; /**< EDMA packet length smaller than 33b error. */ - uint32_t data_len_err; /**< EDMA data length error. */ - uint32_t alloc_fail_cnt; /**< EDMA number of times the allocation of pbuf for statistics failed. */ - uint32_t qos_inval_dst_drops; /**< EDMA number of QoS packet dropped due to invalid destination. */ -}; - -/** - * nss_edma_err_stats_sync - * Message for error statistics. - */ -struct nss_edma_err_stats_sync { - struct nss_edma_misc_err_stats msg_err_stats; /**< Message for error statistics. */ -}; - -/** - * nss_edma_msg - * Data for sending and receiving EDMA messages (to synchronize with - * the firmware EDMA). - */ -struct nss_edma_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of an EDMA message. - */ - union { - struct nss_edma_port_stats_sync port_stats; - /**< EDMA port statistics message payload. */ - struct nss_edma_ring_stats_sync ring_stats; - /**< EDMA ring statistics message payload. */ - struct nss_edma_err_stats_sync err_stats; - /**< EDMA error statistics message payload. */ - } msg; /**< EDMA message payload. */ -}; - -/** - * nss_edma_port_info - * NSS EDMA port statistics. - */ -struct nss_edma_port_info { - uint64_t port_stats[NSS_STATS_NODE_MAX]; /**< EDMA port statistics. */ - uint64_t port_type; /**< EDMA port type. */ - uint64_t port_ring_map[NSS_EDMA_PORT_RING_MAP_MAX]; /**< EDMA ring statistics. */ -}; - -/** - * nss_edma_stats - * NSS EDMA node statistics. - */ -struct nss_edma_stats { - struct nss_edma_port_info port[NSS_EDMA_NUM_PORTS_MAX]; - /**< EDMA port statistics. */ - uint64_t tx_stats[NSS_EDMA_NUM_TX_RING_MAX][NSS_EDMA_STATS_TX_MAX]; - /**< Physical EDMA Tx ring statistics. */ - uint64_t rx_stats[NSS_EDMA_NUM_RX_RING_MAX][NSS_EDMA_STATS_RX_MAX]; - /**< Physical EDMA Rx ring statistics. */ - uint64_t txcmpl_stats[NSS_EDMA_NUM_TXCMPL_RING_MAX][NSS_EDMA_STATS_TXCMPL_MAX]; - /**< Physical EDMA Tx complete statistics. */ - uint64_t rxfill_stats[NSS_EDMA_NUM_RXFILL_RING_MAX][NSS_EDMA_STATS_RXFILL_MAX]; - /**< Physical EDMA Rx fill statistics. */ - uint64_t misc_err[NSS_EDMA_ERR_STATS_MAX]; - /**< EDMA error complete statistics. */ -}; - -#ifdef __KERNEL__ - -/** - * Callback function for receiving EDMA messages. - * - * @datatypes - * nss_edma_msg - * - * @param[in] app_data Pointer to the application context for this message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_edma_msg_callback_t)(void *app_data, struct nss_edma_msg *msg); - -/** - * nss_edma_notify_register - * Registers a callback notifier with the NSS for sending and receiving messages. - * - * @datatypes - * nss_edma_msg_callback_t - * - * @param[in] cb Callback function for the message. - * @param[in] app_data Pointer to the application context for this message. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_edma_notify_register(nss_edma_msg_callback_t cb, void *app_data); - -/** - * nss_edma_notify_unregister - * Deregisters a callback notifier from the NSS. - * - * @return - * None. - * - * @dependencies - * The callback notifier must have been previously registered. - */ -extern void nss_edma_notify_unregister(void); - -/** - * nss_edma_get_stats - * Sends EDMA statistics to NSS clients. - * - * @param[in] stats EDMA statistics to be sent to Netlink. - * @param[in] port_id EDMA port ID. - * - * @return - * None. - */ -void nss_edma_get_stats(uint64_t *stats, int port_id); - -/** - * nss_edma_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_edma_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_edma_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_edma_stats_unregister_notifier(struct notifier_block *nb); - -#endif /* __KERNEL__ */ - -/** - * @} - */ - -#endif /* __NSS_EDMA_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_eth_rx.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_eth_rx.h deleted file mode 100644 index 90f5a5381..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_eth_rx.h +++ /dev/null @@ -1,100 +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. - ************************************************************************** - */ - -/** - * @file nss_eth_rx.h - * NSS Ethernet interface definitions. - */ - -#ifndef __NSS_ETH_RX_H -#define __NSS_ETH_RX_H - -/** - * @addtogroup nss_eth_rx_subsystem - * @{ - */ - -/** - * nss_eth_rx_stats - * Ethernet node statistics. - */ -enum nss_eth_rx_stats { - NSS_ETH_RX_STATS_TOTAL_TICKS, /**< Total clock ticks spent inside the Ethernet package. */ - NSS_ETH_RX_STATS_WORST_CASE_TICKS, /**< Worst case iteration of the Ethernet in ticks. */ - NSS_ETH_RX_STATS_ITERATIONS, /**< Number of iterations around Ethernet. */ - NSS_ETH_RX_STATS_MAX, /**< Maximum message type. */ -}; - -/** - * nss_eth_rx_exception_events - * Exception events from bridge or route handler. - */ -enum nss_eth_rx_exception_events { - NSS_ETH_RX_EXCEPTION_EVENT_UNKNOWN_L3_PROTOCOL, - NSS_ETH_RX_EXCEPTION_EVENT_ETH_HDR_MISSING, - NSS_ETH_RX_EXCEPTION_EVENT_VLAN_MISSING, - NSS_ETH_RX_EXCEPTION_EVENT_TRUSTSEC_HDR_MISSING, - NSS_ETH_RX_EXCEPTION_EVENT_MAX, -}; - -/** - * nss_eth_rx_stats_notification - * Data for sending Ethernet statistics. - */ -struct nss_eth_rx_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint64_t cmn_node_stats[NSS_STATS_NODE_MAX]; /**< Node statistics. */ - uint64_t special_stats[NSS_ETH_RX_STATS_MAX]; /**< Special statistics. */ - uint64_t exception_stats[NSS_ETH_RX_EXCEPTION_EVENT_MAX]; /**< Exception statistics. */ -}; - -#ifdef __KERNEL__ /* only kernel will use. */ -/** - * nss_eth_rx_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_eth_rx_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_eth_rx_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_eth_rx_stats_unregister_notifier(struct notifier_block *nb); -#endif /*__KERNEL__ */ - -/** - *@} - */ - -#endif /* __NSS_ETH_RX_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_freq.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_freq.h deleted file mode 100644 index 6ce11b1b8..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_freq.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2013-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. - */ - -/* - * @file nss_freq.h - * NSS frequency definitions. - */ - -#ifndef __NSS_FREQ_H -#define __NSS_FREQ_H - -/** - * @addtogroup nss_freq_subsystem - * @{ - */ - -/** - * nss_freq_change - * Changes the frequency of the NSS cores. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] eng Frequency value in Hz. - * @param[in] stats_enable Enable NSS to send scaling statistics. - * @param[in] start_or_end Start or end of the frequency change. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_freq_change(struct nss_ctx_instance *nss_ctx, uint32_t eng, uint32_t stats_enable, uint32_t start_or_end); - -/** - * nss_freq_get_cpu_usage - * Returns the CPU usage value in percentage at any instance for a required core. Range of usage is 0-100. - * - * @param[in] core_id NSS Core ID. - * - * @return - * CPU usage value in percentage averaged over 1 second. -1 in case of error. - * @note - * This API does not support gathering CPU usage data for core 1. - */ -extern int8_t nss_freq_get_cpu_usage(uint32_t core_id); - -/** - * @} - */ - -#endif /* __NSS_FREQ_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre.h deleted file mode 100644 index 986166835..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre.h +++ /dev/null @@ -1,494 +0,0 @@ -/* - **************************************************************************** - * Copyright (c) 2017-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. - * 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_gre.h - * NSS GRE interface definitions. - */ -#ifndef _NSS_GRE_H_ -#define _NSS_GRE_H_ - -#include -#include - -/** - * @addtogroup nss_gre_subsystem - * @{ - */ - -/** - * Maximum number of session debug statistics - */ -#define NSS_GRE_MAX_DEBUG_SESSION_STATS 16 - -/** - * GRE flags - */ -#define NSS_GRE_CONFIG_IKEY_VALID 0x00000001 /**< Incoming key of GRE header. */ -#define NSS_GRE_CONFIG_OKEY_VALID 0x00000002 /**< Key for outgoing GRE header. */ -#define NSS_GRE_CONFIG_ISEQ_VALID 0x00000004 /**< Enable sequence checking for incoming GRE traffic. */ -#define NSS_GRE_CONFIG_OSEQ_VALID 0x00000008 /**< Add sequence number for out going GRE packets. */ -#define NSS_GRE_CONFIG_ICSUM_VALID 0x00000010 /**< Validate incoming GRE header checksum. */ -#define NSS_GRE_CONFIG_OCSUM_VALID 0x00000020 /**< Add checksum header to GRE header. */ -#define NSS_GRE_CONFIG_TOS_INHERIT 0x00000040 /**< Inherit inner IP TOS to tunnel header, if not set configure provided TOS. */ -#define NSS_GRE_CONFIG_TTL_INHERIT 0x00000080 /**< Inherit inner IP TTL to tunnel header, if not set configure provided TTL. */ -#define NSS_GRE_CONFIG_SET_DF 0x00000100 /**< Enable DF bit on tunnel IP header. */ -#define NSS_GRE_CONFIG_SET_MAC 0x00000200 /**< Add MAC header to GRE+IP tunnel header. */ -#define NSS_GRE_CONFIG_SET_PADDING 0x00000400 /**< Add PADDING to align tunnel IP/GRE header. */ -#define NSS_GRE_CONFIG_NEXT_NODE_AVAILABLE 0x00000800 /**< Use provided next node instead of existing next node. */ -#define NSS_GRE_CONFIG_COPY_METADATA 0x00001000 /**< Enable metadata copy in NSS during alignment. */ -#define NSS_GRE_CONFIG_USE_UNALIGNED 0x00002000 /**< Use unaligned infrastructure in NSS. */ -#define NSS_GRE_CONFIG_DSCP_VALID 0x00004000 /**< Add DSCP per packet. */ - -/** - * nss_gre_error_types. - * Error types for GRE configuration messages. - */ -enum nss_gre_error_types { - NSS_GRE_ERR_UNKNOWN_MSG = 1, /**< Unknown message. */ - NSS_GRE_ERR_IF_INVALID = 2, /**< Invalid interface. */ - NSS_GRE_ERR_MODE_INVALID = 3, /**< Invalid mode type. */ - NSS_GRE_ERR_IP_INVALID = 4, /**< Invalid IP type. */ - NSS_GRE_ERR_GRE_SESSION_PARAMS_INVALID = 5, /**< Invalid GRE session parameters provided. */ - NSS_GRE_ERR_DSCP_CFG_INVALID = 6, /**< Both TOS and DSCP flags are enabled. */ - NSS_GRE_ERR_MAX, /**< Maximum GRE error. */ -}; - -/** - * nss_gre_info - * GRE private information. - */ -struct nss_gre_info { - /** - * Union of IPv4/IPv6 tunnel. - */ - union { - struct ip_tunnel t4; /**< IPv4 tunnel. */ - struct ip6_tnl t6; /**< IPv6 tunnel. */ - } t; /**< IPv4 and IPv6 tunnel. */ - int nss_if_number_inner; /**< NSS interface number for GRE inner. */ - struct net_device *next_dev_inner; /**< Next network device for inner flow. */ - struct net_device *next_dev_outer; /**< Next network device for outer flow. */ - uint8_t gre_hlen; /**< GRE header length. */ - uint8_t pad_len; /**< Pad length. */ -}; - -/** - * nss_gre_msg_types - * Message types for GRE requests and responses. - */ -enum nss_gre_msg_types { - NSS_GRE_MSG_ENCAP_CONFIGURE = NSS_IF_MAX_MSG_TYPES + 1, - NSS_GRE_MSG_DECAP_CONFIGURE, - NSS_GRE_MSG_ENCAP_DECONFIGURE, - NSS_GRE_MSG_DECAP_DECONFIGURE, - NSS_GRE_MSG_SESSION_STATS, - NSS_GRE_MSG_BASE_STATS, - NSS_GRE_MSG_MAX -}; - -/** - * GRE Mode Types - */ -enum nss_gre_mode { - NSS_GRE_MODE_TUN, /**< GRE Tunnel interface. */ - NSS_GRE_MODE_TAP, /**< GRE Tap interface. */ - NSS_GRE_MODE_MAX /**< Maxmum GRE mode. */ -}; - -/** - * GRE IP Types - */ -enum nss_gre_ip_types { - NSS_GRE_IP_IPV4, /**< Outer Tunnel is IPV4. */ - NSS_GRE_IP_IPV6, /**< Outer Tunnel is IPV6. */ - NSS_GRE_IP_MAX, /**< Maximum IP Types. */ -}; - -/** - * nss_gre_base_types - * 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. */ -}; - -/** - * 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 create message structure. - */ -struct nss_gre_config_msg { - 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 mode; /**< GRE TUN or TAP. */ - uint32_t ip_type; /**< IPv4 or IPv6 type. */ - uint32_t next_node_if_num; /**< To whom to forward packets. */ - uint32_t sibling_if_num; /**< Sibling interface number. */ - uint16_t src_mac[3]; /**< Source MAC address. */ - uint16_t dest_mac[3]; /**< Destination MAC address. */ - uint8_t ttl; /**< TTL or HOPLIMIT. */ - uint8_t tos; /**< Type of service. */ - uint16_t metadata_size; /**< Metadata copy size. */ -}; - -/** - * GRE link up message structure - */ -struct nss_gre_linkup_msg { - int if_number; /**< Interface number. */ -}; - -/** - * GRE link down message structure - */ -struct nss_gre_linkdown_msg { - int if_number; /**< Interface number. */ -}; - -/** - * GRE deconfig message structure - */ -struct nss_gre_deconfig_msg { - int if_number; /**< Interface number */ -}; - -/** - * 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. */ -}; - -/** - * 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. */ -}; - -/** - * nss_gre_msg - * Message structure to send/receive GRE messages - */ -struct nss_gre_msg { - struct nss_cmn_msg cm; /**< Common message header */ - - /** - * Payload of a GRE message. - */ - union { - struct nss_gre_config_msg cmsg; /**< GRE session config message. */ - struct nss_gre_deconfig_msg dmsg; /**< GRE session deconfig message. */ - struct nss_gre_linkup_msg linkup; /**< GRE link up message. */ - struct nss_gre_linkdown_msg linkdown; /**< GRE link down message. */ - struct nss_gre_session_stats_msg sstats; /**< GRE session statistics message. */ - struct nss_gre_base_stats_msg bstats; /**< Base statistics message. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function to receive GRE messages - * - * @datatypes - * nss_gre_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_gre_msg_callback_t)(void *app_data, struct nss_gre_msg *msg); - -/** - * nss_gre_tx_msg - * Sends GRE messages to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_gre_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_gre_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_gre_msg *msg); - -/** - * nss_gre_tx_msg_sync - * Sends GRE messages to the NSS synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_gre_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_gre_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_msg *msg); - -/** - * nss_gre_tx_buf - * Sends packet to the NSS - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] if_num Nss interface number. - * @param[in] skb Pointer to sk_buff. - * - * @return Tx status - */ -extern nss_tx_status_t nss_gre_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, struct sk_buff *skb); - -/** - * nss_gre_get_context. - * Gets the GRE context used in nss_gre_tx. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_gre_get_context(void); - -/** - * - * nss_gre_ifnum_with_core_id - * Append core ID on GRE interface. - * - * @param[in] if_num NSS interface number. - * - * @return - * GRE interface number with core ID. - */ -extern int nss_gre_ifnum_with_core_id(int if_num); - -/** - * Callback function for receiving GRE session 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_gre_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_gre_register_if - * Registers the GRE interface with the NSS for sending and - * receiving messages. - * - * @datatypes - * nss_gre_data_callback_t \n - * nss_gre_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] type NSS interface type. - * @param[in] gre_callback Callback for the data. - * @param[in] msg_callback Callback for the message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Socket buffer types supported by this interface. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_gre_register_if(uint32_t if_num, uint32_t type, nss_gre_data_callback_t gre_callback, - nss_gre_msg_callback_t msg_callback, struct net_device *netdev, uint32_t features); - -/** - * nss_gre_unregister_if - * Deregisters the GRE interface from the NSS. - * - * @param[in] if_num NSS interface number. -. * - * @return - * None. - * - * @dependencies - * The tunnel interface must have been previously registered. - */ -extern void nss_gre_unregister_if(uint32_t if_num); - -/** - * nss_gre_msg_init - * Initializes a GRE message. - * - * @datatypes - * nss_gre_msg - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num Interface number - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -extern void nss_gre_msg_init(struct nss_gre_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); - -/** - * nss_gre_register_handler - * Registers the GRE interface with the NSS debug statistics handler. - * - * @return - * None. - */ -extern void nss_gre_register_handler(void); - -/** - * Callback function for updating stats. - * - * @datatypes - * net_device \n - * sk_buff \n - * - * @param[in] netdev Pointer to the associated network device. - * @param[in] skb Pointer to the data socket buffer. - * - * @return - * None. - */ -typedef void (*nss_gre_pkt_callback_t)(struct net_device *netdev, struct sk_buff *skb); - -/** - * nss_gre_register_pkt_callback - * Register for rx packet call back. - * - * @datatypes - * nss_gre_pkt_callback_t - * - * @param[in] cb Call back function which needs to be registered. - * - * @return - * None. - */ -extern void nss_gre_register_pkt_callback(nss_gre_pkt_callback_t cb); - -/** - * nss_gre_unregister_pkt_callback - * Unregister for rx packet call back. - * - * @datatypes - * nss_gre_pkt_callback_t - * - * @return - * None. - */ -extern void nss_gre_unregister_pkt_callback(void); - -/** - * 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); - -/** - * @} - */ - -#endif /* _NSS_GRE_H_ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre_redir.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre_redir.h deleted file mode 100644 index 5d3150bf3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre_redir.h +++ /dev/null @@ -1,712 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2014-2015, 2017-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. - ************************************************************************** - */ - -/** - * @file nss_gre_redir.h - * NSS GRE Redirect interface definitions. - */ - -#ifndef __NSS_GRE_REDIR_H -#define __NSS_GRE_REDIR_H - -/** - * @addtogroup nss_gre_redirect_subsystem - * @{ - */ - -#define NSS_GRE_REDIR_MAX_INTERFACES 24 /**< Maximum number of redirect interfaces. */ -#define NSS_GRE_REDIR_IP_DF_OVERRIDE_FLAG 0x80 /**< Override Do not Fragment bit in IPv4 flags. */ -#define NSS_GRE_REDIR_PER_PACKET_METADATA_OFFSET 4 /**< Offset of per packet metadata from start of packet. */ -#define NSS_GRE_REDIR_MAX_RADIO 5 /**< Maximum number of radios. */ -#define NSS_GRE_REDIR_HEADER_VERSION 0 /**< Version for GRE header. */ - -/** - * nss_gre_redir_ip_hdr_type - * IP header types. - */ -enum nss_gre_redir_ip_hdr_type { - NSS_GRE_REDIR_IP_HDR_TYPE_IPV4 = 1, - NSS_GRE_REDIR_IP_HDR_TYPE_IPV6 = 2, -}; - -/** - * nss_gre_redir_message_types - * Message types for GRE redirect requests and responses. - */ -enum nss_gre_redir_message_types { - NSS_GRE_REDIR_TX_TUNNEL_INNER_CONFIGURE_MSG, /**< Configure message for inner node. */ - NSS_GRE_REDIR_TX_TUNNEL_OUTER_CONFIGURE_MSG, /**< Configure message for outer node. */ - NSS_GRE_REDIR_TX_INTERFACE_MAP_MSG, /**< Interface map message. */ - NSS_GRE_REDIR_TX_INTERFACE_UNMAP_MSG, /**< Interface unmap message. */ - NSS_GRE_REDIR_TX_SJACK_MAP_MSG, /**< SJACK map message. */ - NSS_GRE_REDIR_TX_SJACK_UNMAP_MSG, /**< SJACK unmap message. */ - NSS_GRE_REDIR_RX_STATS_SYNC_MSG, /**< Statistics synchronization message. */ - NSS_GRE_REDIR_EXCEPTION_DS_REG_CB_MSG, /**< Configure message to register callback. */ - NSS_GRE_REDIR_MAX_MSG_TYPES, /**< Maximum message type. */ -}; - -/** - * nss_gre_redir_error_types - * Error types for GRE redirect configuration messages. - */ -enum nss_gre_redir_error_types { - NSS_GRE_REDIR_ERROR_NONE, /**< Configuration successful. */ - NSS_GRE_REDIR_ERROR_UNKNOWN_MSG_TYPE, /**< Unknown configuration message type error. */ - NSS_GRE_REDIR_ERROR_INVALID_IP_HDR_TYPE, /**< Invalid IP header type error. */ - NSS_GRE_REDIR_ERROR_MAP_TABLE_FULL, /**< Map table full error. */ - NSS_GRE_REDIR_ERROR_MAP_INVALID_PARAM, /**< Invalid parameter with map message error. */ - NSS_GRE_REDIR_ERROR_UNMAP_INVALID_PARAM, /**< Invalid parameter with unmap message error. */ - NSS_GRE_REDIR_ERROR_ENCAP_MAP_EXIST, /**< Encapsulation map entry already exist. */ - NSS_GRE_REDIR_ERROR_DECAP_MAP_EXIST, /**< Decapsulation map entry already exist. */ - NSS_GRE_REDIR_ERROR_ENCAP_MAP_ALLOC_FAIL, /**< Encapsulation map entry allocation failure error. */ - NSS_GRE_REDIR_ERROR_DECAP_MAP_ALLOC_FAIL, /**< Decapsulation map entry allocation failure error. */ - NSS_GRE_REDIR_ERROR_ENCAP_ENTRY_UNMAPPED, /**< Encapsulation map entry already unmapped. */ - NSS_GRE_REDIR_ERROR_DECAP_ENTRY_UNMAPPED, /**< Decapsulation map entry already unmapped. */ - NSS_GRE_REDIR_ERROR_INVALID_ETH_IF, /**< Invalid Ethernet NSS interface. */ - NSS_GRE_REDIR_ERROR_INVALID_VAP_NEXTHOP_IF, /**< Invalid nexthop NSS interface. */ - NSS_GRE_REDIR_ERROR_INVALID_PEER_INTERFACE, /**< Invalid peer interface during tunnel configuration. */ -}; - -/** - * nss_gre_redir_tunnel_types - * GRE tunnel types. - */ -enum nss_gre_redir_tunnel_types { - NSS_GRE_REDIR_TUNNEL_TYPE_UNKNOWN, /**< Reserved. */ - NSS_GRE_REDIR_TUNNEL_TYPE_TUN, /**< Tunnel mode. */ - NSS_GRE_REDIR_TUNNEL_TYPE_DTUN, /**< D-tunnel mode. */ - NSS_GRE_REDIR_TUNNEL_TYPE_SPLIT, /**< Split mode. */ - NSS_GRE_REDIR_TUNNEL_TYPE_MAX, /**< Maximum tunnel type. */ -}; - -/** - * 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. - */ -struct nss_gre_redir_inner_configure_msg { - uint32_t ip_hdr_type; /**< IP header type (IPv4 or IPv6). */ - - /** - * IPv4 or IPv6 source address (lower 4 bytes are applicable for IPv4). - */ - uint32_t ip_src_addr[4]; - - /** - * IPv4 or IPv6 destination address (lower 4 bytes are applicable for IPv4). - */ - uint32_t ip_dest_addr[4]; - - /** - * The host outer-interface which handles post-encapsulation exception packets - * originating from this inner interface. - */ - uint32_t except_outerif; - - uint8_t ip_df_policy; /**< Default Do Not Fragment policy for the IP header. */ - uint8_t ip_ttl; /**< Time-to-live value for the IP header. */ - uint8_t gre_version; /**< Header version. */ -}; - -/** - * nss_gre_redir_outer_configure_msg - * Message information for configuring GRE outer node. - */ -struct nss_gre_redir_outer_configure_msg { - uint32_t ip_hdr_type; /**< IP header type (IPv4 or IPv6). */ - - /** - * The host inner-interface which handles post-decapsulation exception packets - * originating from this outer interface, for flows destined to a VAP handled - * by host. - */ - uint32_t except_hostif; - - /** - * The host inner-interface which handles post-decapsulation exception packets - * originating from this outer interface, for flows destined to a VAP handled - * by NSS. - */ - uint32_t except_offlif; - - /** - * The host inner-interface which handles post-decapsulation exception packets - * originating from this outer interface, for flows destined to SJACK. - */ - uint32_t except_sjackif; - - /** - * CPU core to which these packets should be steered. - * - 0 -- Use core 0 - * - 1 -- Use core 1 - * - 2 -- Use core 2 - * - 3 -- Use core 3 - */ - uint8_t rps_hint; - - /** - * Flag to indicate validity of RPS hint. - */ - uint8_t rps_hint_valid; - -}; - -/** - * nss_gre_redir_exception_ds_reg_cb_msg - * Message information to register callback on VAP for GRE exception downstream. - */ -struct nss_gre_redir_exception_ds_reg_cb_msg { - uint32_t dst_vap_nssif; /**< NSS VAP interface on which the callback is registered. */ -}; - -/** - * nss_gre_redir_interface_map_msg - * Message information for adding a VAP interface-to-tunnel ID mapping. - */ -struct nss_gre_redir_interface_map_msg { - uint32_t vap_nssif; /**< NSS VAP interface. */ - uint32_t nexthop_nssif; /**< Next hop NSS interface number. */ - uint16_t radio_id; /**< Radio ID to derive tunnel ID. */ - uint16_t vap_id; /**< VAP ID to derive tunnel ID. */ - uint16_t lag_en; /**< Flag for LAG mode. */ - uint16_t tunnel_type; /**< Type of tunnel. */ - - /** - * IPsec security association pattern. Pattern - * 0x5A is supported only. - */ - uint8_t ipsec_pattern; -}; - -/** - * nss_gre_redir_interface_unmap_msg - * Message information for deleting a VAP interface-to-tunnel ID mapping. - */ -struct nss_gre_redir_interface_unmap_msg { - uint32_t vap_nssif; /**< NSS VAP interface. */ - uint16_t radio_id; /**< Radio ID to derive tunnel ID. */ - uint16_t vap_id; /**< VAP ID to derive tunnel ID. */ -}; - -/** - * nss_gre_redir_sjack_map_msg - * Message information for adding an Ethernet interface-to-tunnel ID mapping. - */ -struct nss_gre_redir_sjack_map_msg { - uint32_t eth_nssif; /**< NSS Ethernet interface number. */ - uint32_t eth_id; /**< Ethernet interface ID. */ - - /** - * IPsec security association pattern. Pattern - * 0x5A is supported only. - */ - uint8_t ipsec_pattern; -}; - -/** - * nss_gre_redir_sjack_unmap_msg - * Message information for deleting an Ethernet interface-to-tunnel ID mapping. - */ -struct nss_gre_redir_sjack_unmap_msg { - uint32_t eth_nssif; /**< NSS Ethernet interface number. */ - uint32_t eth_id; /**< Ethernet interface ID. */ -}; - -/** - * nss_gre_redir_stats_sync_msg - * Message information for synchronized GRE redirect statistics. - */ -struct nss_gre_redir_stats_sync_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - uint32_t sjack_rx_packets; /**< SJACK packet counter. */ - uint32_t offl_rx_pkts[NSS_GRE_REDIR_MAX_RADIO]; /**< Offload packet counter. */ - uint32_t encap_sg_alloc_drop; /**< Encapsulation drop counters due to scatter gather buffer allocation failure. */ - uint32_t decap_fail_drop; /**< Decapsulation drop counters due to invalid IP header. */ - uint32_t decap_split_drop; /**< Decapsulation drop counters due to split flow processing. */ - uint32_t split_sg_alloc_fail; /**< Split processing fail counter due to scatter gather buffer allocation failure. */ - uint32_t split_linear_copy_fail; /**< Split processing fail counter due to linear copy fail. */ - uint32_t split_not_enough_tailroom; /**< Split processing fail counter due to insufficient tailroom. */ - uint32_t exception_ds_invalid_dst_drop; /**< Downstream exception handling fail counter due to invalid destination. */ - uint32_t decap_eapol_frames; /**< Decapsulation EAPoL frame counters. */ - uint32_t exception_ds_inv_appid; /**< Invalid application ID for the Tx completion packets on exception downstream node. */ - uint32_t headroom_unavail; /**< Packet headroom unavailable to write metadata. */ - uint32_t tx_completion_success; /**< Host enqueue success count for the Tx completion packets. */ - uint32_t tx_completion_drop; /**< Host enqueue drop count for the Tx completion packets. */ -}; - -/** - * nss_gre_redir_tun_stats - * GRE redirect statistics to accumulate all the 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. */ -}; - -/** - * nss_gre_redir_msg - * Data for sending and receiving GRE tunnel redirect messages. - */ -struct nss_gre_redir_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a GRE tunnel redirect message. - */ - union { - struct nss_gre_redir_inner_configure_msg inner_configure; - /**< Configure a GRE inner node. */ - struct nss_gre_redir_outer_configure_msg outer_configure; - /**< Configure a GRE outer node. */ - struct nss_gre_redir_interface_map_msg interface_map; - /**< Add a VAP interface-to-tunnel ID mapping. */ - struct nss_gre_redir_interface_unmap_msg interface_unmap; - /**< Delete a VAP interafce-to-tunnel ID mapping. */ - struct nss_gre_redir_sjack_map_msg sjack_map; - /**< Add an Ethernet interface-to-tunnel ID mapping for SJACK. */ - struct nss_gre_redir_sjack_unmap_msg sjack_unmap; - /**< Delete an Ethernet interface-to-tunnel ID mapping for SJACK. */ - struct nss_gre_redir_stats_sync_msg stats_sync; - /**< Synchronized tunnel statistics. */ - struct nss_gre_redir_exception_ds_reg_cb_msg exception_ds_configure; - /**< Registering callback on VAP for the GRE downstream flows. */ - } msg; /**< Message payload for GRE redirect messages exchanged with NSS core. */ - -}; - -/** - * nss_gre_redir_encap_per_pkt_metadata - * Metadata information for an HLOS-to-NSS packet. - */ -struct nss_gre_redir_encap_per_pkt_metadata { - uint16_t gre_tunnel_id; /**< ID of the tunnel. */ - uint8_t gre_flags; /**< Flags field from GRE header. */ - uint8_t gre_prio; /**< Priority field from GRE header. */ - uint8_t gre_seq; /**< Sequence number. */ - uint8_t ip_dscp; /**< DSCP values. */ - - /** - * Override the default DF policy for the packet by setting bit 8. - * The lower 7 bits provide the DF value to be used for this packet. - */ - uint8_t ip_df_override; - - /** - * IPsec security association pattern. Pattern - * 0x5A is supported only. - */ - uint8_t ipsec_pattern; -}; - -/** - * nss_gre_redir_decap_per_pkt_metadata - * Metadata information for an NSS-to-HLOS packet. - */ -struct nss_gre_redir_decap_per_pkt_metadata { - uint32_t src_if_num; /**< Number of the source Ethernet interface. */ - uint16_t gre_tunnel_id; /**< ID of the tunnel. */ - uint8_t gre_flags; /**< Flags from GRE header. */ - uint8_t gre_prio; /**< Priority from GRE header. */ - uint8_t gre_seq; /**< Sequence number. */ -}; - -/** - * nss_gre_redir_exception_us_metadata - * Metadata information for upstream exception packet. - * - * Note: Additional fields need to be added by customer as required. - */ -struct nss_gre_redir_exception_us_metadata { - uint8_t tid; /**< TID value. */ -}; - -/** - * nss_gre_redir_exception_ds_metadata - * Metadata information for downstream exception packet. - * - * Note: Additional fields need to be added by customer as required. - */ -struct nss_gre_redir_exception_ds_metadata { - uint32_t dst_vap_nssif; /**< Destination VAP interface number. */ - uint8_t tid; /**< TID value. */ - uint8_t app_id; /**< Application ID. */ - uint16_t hw_hash_idx; /**< Hardware AST hash index value. */ - uint32_t tx_status; /**< Tx status. */ -}; - -/** - * Callback function for receiving GRE tunnel 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_gre_redir_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback function for receiving GRE tunnel 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_gre_redir_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * nss_gre_redir_unregister_if - * Deregisters a GRE 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_gre_redir_unregister_if(uint32_t if_num); - -/** - * nss_gre_redir_tx_msg - * Sends GRE redirect tunnel messages. - * - * @datatypes - * nss_ctx_instance \n - * nss_gre_redir_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_gre_redir_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_msg *msg); - -/** - * nss_gre_redir_tx_buf - * Sends GRE redirect tunnel packets. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] os_buf Pointer to the OS buffer (e.g., skbuff). - * @param[in] if_num Tunnel interface number. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_gre_redir_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, - uint32_t if_num); - -/** - * nss_gre_redir_tx_buf_noreuse - * Sends GRE redirect tunnel packets. - * - * Note: The buffers will be not be reused or - * kept in the accelerator. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] os_buf Pointer to the OS buffer (e.g., skbuff). - * @param[in] if_num Tunnel interface number. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_gre_redir_tx_buf_noreuse(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, - uint32_t if_num); - -/** - * nss_gre_redir_stats_get - * Gets GRE redirect tunnel statistics. - * - * @datatypes - * nss_gre_redir_tunnel_stats - * - * @param[in] index Index in the tunnel statistics array. - * @param[out] stats Pointer to the tunnel statistics. - * - * @return - * TRUE or FALSE. - */ -extern bool nss_gre_redir_stats_get(int index, struct nss_gre_redir_tunnel_stats *stats); - -/** - * nss_gre_redir_alloc_and_register_node - * Allocates and registers GRE redirect dynamic node with NSS. - * - * @datatypes - * net_device \n - * nss_gre_redir_data_callback_t \n - * nss_gre_redir_msg_callback_t \n - * - * @param[in] dev Pointer to the associated network device. - * @param[in] data_cb Callback for the data. - * @param[in] msg_cb Callback for the message. - * @param[in] type Type of dynamic node. - * @param[in] app_ctx Application context for notify callback. - * - * @return - * NSS interface number allocated. - */ -extern int nss_gre_redir_alloc_and_register_node(struct net_device *dev, - nss_gre_redir_data_callback_t data_cb, - nss_gre_redir_msg_callback_t msg_cb, - uint32_t type, void *app_ctx); - -/** - * nss_gre_redir_configure_inner_node - * Configures inner GRE redirect node. - * - * @datatypes - * nss_gre_redir_inner_configure_msg - * - * @param[in] ifnum NSS interface number. - * @param[in] ngrcm Inner node configuration message. - * - * @return - * Status of Tx operation. - */ -extern nss_tx_status_t nss_gre_redir_configure_inner_node(int ifnum, - struct nss_gre_redir_inner_configure_msg *ngrcm); - -/** - * nss_gre_redir_configure_outer_node - * Configures outer GRE redirect node. - * - * @datatypes - * nss_gre_redir_outer_configure_msg - * - * @param[in] ifnum NSS interface number. - * @param[in] ngrcm Outer node configuration message. - * - * @return - * Status of Tx operation. - */ -extern nss_tx_status_t nss_gre_redir_configure_outer_node(int ifnum, - struct nss_gre_redir_outer_configure_msg *ngrcm); - -/** - * nss_gre_redir_exception_ds_reg_cb - * Configure a callback on VAP for downstream GRE exception flows. - * - * @datatypes - * nss_gre_redir_exception_ds_reg_cb_msg - * - * @param[in] ifnum NSS interface number. - * @param[in] ngrcm Downstream exception callback registration message. - * - * @return - * Status of Tx operation. - */ -extern nss_tx_status_t nss_gre_redir_exception_ds_reg_cb(int ifnum, - struct nss_gre_redir_exception_ds_reg_cb_msg *ngrcm); - -/** - * nss_gre_redir_tx_msg_sync - * Sends messages to NSS firmware synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_gre_redir_msg - * - * @param[in] nss_ctx NSS core context. - * @param[in] ngrm Pointer to GRE redirect message data. - * - * @return - * Status of Tx operation. - */ -extern nss_tx_status_t nss_gre_redir_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_msg *ngrm); - -/** - * nss_gre_redir_get_context - * Gets the GRE redirect context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_gre_redir_get_context(void); - -/** - * nss_gre_redir_get_dentry - * Returns directory entry created in debugfs for statistics. - * - * @return - * Pointer to created directory entry for GRE redirect. - */ -extern struct dentry *nss_gre_redir_get_dentry(void); - -/** - * nss_gre_redir_get_device - * Gets the original device from probe. - * - * @return - * Pointer to the device. - */ -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); - -/** - * @} - */ - -#endif /* __NSS_GRE_REDIR_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre_redir_lag.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre_redir_lag.h deleted file mode 100644 index b10264dcf..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre_redir_lag.h +++ /dev/null @@ -1,732 +0,0 @@ -/* - ************************************************************************** - * 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 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_gre_redir_lag.h - * NSS GRE redirect LAG interface definitions. - */ - -#ifndef __NSS_GRE_REDIR_LAG_H -#define __NSS_GRE_REDIR_LAG_H - -/** - * @addtogroup nss_gre_redirect_subsystem - * @{ - */ - -#define NSS_GRE_REDIR_LAG_MAX_NODE 12 /**< Maximum number of LAG nodes. */ -#define NSS_GRE_REDIR_LAG_MAX_SLAVE 8 /**< Maximum number of GRE redirect nodes per LAG node. */ -#define NSS_GRE_REDIR_LAG_MIN_SLAVE 2 /**< Minimum required GRE redirect nodes per LAG node. */ -#define NSS_GRE_REDIR_LAG_US_STATS_SYNC_RETRY 3 /**< Number of retries for sending query hash messages. */ -#define NSS_GRE_REDIR_LAG_US_MAX_HASH_PER_MSG 80 /**< Maximum hash entries per message. */ - -/* - * nss_gre_redir_lag_err_types - * GRE redirect LAG error types. - */ -enum nss_gre_redir_lag_err_types { - NSS_GRE_REDIR_LAG_SUCCESS, - NSS_GRE_REDIR_LAG_ERR_INCORRECT_IFNUM, - NSS_GRE_REDIR_LAG_ERR_CORE_UNREGISTER_FAILED, - NSS_GRE_REDIR_LAG_ERR_STATS_INDEX_NOT_FOUND, - NSS_GRE_REDIR_LAG_ERR_DEALLOC_FAILED, - NSS_GRE_REDIR_LAG_ERR_MAX, -}; - -/** - * nss_gre_redir_lag_us_message_types - * GRE redirect LAG upstream message types. - */ -enum nss_gre_redir_lag_us_message_types { - NSS_GRE_REDIR_LAG_US_CONFIG_MSG, - NSS_GRE_REDIR_LAG_US_ADD_HASH_NODE_MSG, - NSS_GRE_REDIR_LAG_US_DEL_HASH_NODE_MSG, - NSS_GRE_REDIR_LAG_US_QUERY_HASH_NODE_MSG, - NSS_GRE_REDIR_LAG_US_CMN_STATS_SYNC_MSG, - NSS_GRE_REDIR_LAG_US_DB_HASH_NODE_MSG, - NSS_GRE_REDIR_LAG_US_MAX_MSG_TYPES, -}; - -/** - * nss_gre_redir_lag_ds_message_types - * GRE redirect LAG downstream message types. - */ -enum nss_gre_redir_lag_ds_message_types { - NSS_GRE_REDIR_LAG_DS_ADD_STA_MSG, - NSS_GRE_REDIR_LAG_DS_DEL_STA_MSG, - NSS_GRE_REDIR_LAG_DS_UPDATE_STA_MSG, - NSS_GRE_REDIR_LAG_DS_STATS_SYNC_MSG, - NSS_GRE_REDIR_LAG_DS_MAX_MSG_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. - */ -enum nss_gre_redir_lag_us_hash_mode { - NSS_GRE_REDIR_LAG_US_HASH_MODE_SRC_AND_DEST, - NSS_GRE_REDIR_LAG_US_HASH_MODE_SRC, - NSS_GRE_REDIR_LAG_US_HASH_MODE_DEST, - NSS_GRE_REDIR_LAG_US_HASH_MODE_MAX, -}; - -/** - * nss_gre_redir_lag_us_config_msg - * Upstream configure message. - */ -struct nss_gre_redir_lag_us_config_msg { - uint32_t hash_mode; /**< Hash operating mode. */ - uint32_t num_slaves; /**< Number of slaves. */ - uint32_t if_num[NSS_GRE_REDIR_LAG_MAX_SLAVE]; /**< NSS interface numbers of GRE redirect tunnels. */ -}; - -/** - * nss_gre_redir_lag_us_add_hash_node_msg - * Message to add hash entry. - */ -struct nss_gre_redir_lag_us_add_hash_node_msg { - uint32_t if_num; /**< NSS interface number of GRE redirect. */ - uint16_t src_mac[ETH_ALEN / 2]; /**< Source MAC address. */ - uint16_t dest_mac[ETH_ALEN / 2]; /**< Destination MAC address. */ -}; - -/** - * nss_gre_redir_lag_us_del_hash_node_msg - * Message to delete hash entry. - */ -struct nss_gre_redir_lag_us_del_hash_node_msg { - uint16_t src_mac[ETH_ALEN / 2]; /**< Source MAC address. */ - uint16_t dest_mac[ETH_ALEN / 2]; /**< Destination MAC address. */ -}; - -/** - * nss_gre_redir_lag_us_query_hash_node_msg - * Message to query if a hash entry is present. - */ -struct nss_gre_redir_lag_us_query_hash_node_msg { - uint16_t src_mac[ETH_ALEN / 2]; /**< Source MAC address. */ - uint16_t dest_mac[ETH_ALEN / 2]; /**< Destination MAC address. */ - uint32_t ifnum; /**< NSS interface number of GRE redirect. */ -}; - -/** - * nss_gre_redir_lag_us_cmn_sync_stats - * GRE redirect LAG upstream statistics. - */ -struct nss_gre_redir_lag_us_cmn_sync_stats { - uint32_t amsdu_pkts; /**< Number of AMSDU packets seen. */ - uint32_t amsdu_pkts_enqueued; /**< Number of AMSDU packets enqueued. */ - uint32_t amsdu_pkts_exceptioned; /**< Number of AMSDU packets exceptioned. */ - uint32_t exceptioned; /**< Number of exceptioned packets. */ - uint32_t freed; /**< Number of freed packets. */ -}; - -/** - * nss_gre_redir_lag_us_cmn_db_sync_stats - * Upstream database statistics. - */ -struct nss_gre_redir_lag_us_cmn_db_sync_stats { - uint32_t add_attempt; /**< Add hash attempts. */ - uint32_t add_success; /**< Add hash success. */ - uint32_t add_fail_table_full; /**< Add hash failed due to full table. */ - uint32_t add_fail_exists; /**< Add hash failed as entry already exists. */ - uint32_t del_attempt; /**< Delete hash attempts. */ - uint32_t del_success; /**< Delete hash success. */ - uint32_t del_fail_not_found; /**< Delete hash failed as entry not found in hash table. */ -}; - -/** - * nss_gre_redir_lag_us_tunnel_hash_node_stats - * Hash statistics for GRE redirect LAG. - */ -struct nss_gre_redir_lag_us_tunnel_hash_node_stats { - uint64_t hits; /**< Number of hits on this hash entry. */ - uint32_t if_num; /**< GRE redirect interface number. */ - uint16_t src_mac[ETH_ALEN / 2]; /**< Source MAC address. */ - uint16_t dest_mac[ETH_ALEN / 2]; /**< Destination MAC address. */ -}; - -/** - * nss_gre_redir_lag_us_hash_stats_query_msg - * Hash statistics synchronization message. - */ -struct nss_gre_redir_lag_us_hash_stats_query_msg { - /* - * Request. - * Hash stats request has starting index of hash entry. - * Request is initiated by driver periodically. - */ - uint16_t db_entry_idx; /**< Starting index of request. */ - - /* - * Response. - * Response contains count of hash entries. It also has next field - * which used as the request index in subsequent request by caller. - */ - uint16_t db_entry_next; /**< Next index to be requested. */ - uint16_t count; /**< Number of hash entries in the message. */ - uint16_t reserved; /**< Reserved. */ - struct nss_gre_redir_lag_us_tunnel_hash_node_stats hstats[NSS_GRE_REDIR_LAG_US_MAX_HASH_PER_MSG]; - /**< Array of hash table entries. */ -}; - -/** - * nss_gre_redir_lag_us_cmn_sync_stats_msg - * Upstream statistics synchronization message. - */ -struct nss_gre_redir_lag_us_cmn_sync_stats_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - struct nss_gre_redir_lag_us_cmn_sync_stats us_stats; /**< Upstream statistics. */ - struct nss_gre_redir_lag_us_cmn_db_sync_stats db_stats; /**< Common hash statistics. */ -}; - -/** - *nss_gre_redir_lag_us_msg - * GRE redirect LAG upstream messages. - */ -struct nss_gre_redir_lag_us_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /* - * Payload of a GRE redirect LAG message. - */ - union { - struct nss_gre_redir_lag_us_config_msg config_us; /**< Upstream configuration message. */ - struct nss_gre_redir_lag_us_add_hash_node_msg add_hash; /**< Add hash entry. */ - struct nss_gre_redir_lag_us_del_hash_node_msg del_hash; /**< Delete hash entry. */ - struct nss_gre_redir_lag_us_query_hash_node_msg query_hash; /**< Hash entry query message. */ - struct nss_gre_redir_lag_us_cmn_sync_stats_msg us_sync_stats; /**< Upstream statistics. */ - struct nss_gre_redir_lag_us_hash_stats_query_msg hash_stats; /**< Hash statistics message. */ - } msg; /**< GRE redirect LAG upstream message payload. */ -}; - -/** - * nss_gre_redir_lag_us_cmn_stats - * GRE redirect LAG upstream statistics. - */ -struct nss_gre_redir_lag_us_cmn_stats { - uint64_t amsdu_pkts; /**< Number of AMSDU packets seen. */ - uint64_t amsdu_pkts_enqueued; /**< Number of AMSDU packets enqueued. */ - uint64_t amsdu_pkts_exceptioned; /**< Number of AMSDU packets exceptioned. */ - uint64_t exceptioned; /**< Number of exceptioned packets. */ - uint64_t freed; /**< Freed packets when equeue to NSS to host fails. */ -}; - -/** - * nss_gre_redir_lag_us_cmn_db_stats - * Upstream database statistics. - */ -struct nss_gre_redir_lag_us_cmn_db_stats { - uint64_t add_attempt; /**< Add hash attempts. */ - uint64_t add_success; /**< Add hash success. */ - uint64_t add_fail_table_full; /**< Add hash failed due to full table. */ - uint64_t add_fail_exists; /**< Add hash failed as entry already exists. */ - uint64_t del_attempt; /**< Delete hash attempts. */ - uint64_t del_success; /**< Delete hash success. */ - uint64_t del_fail_not_found; /**< Delete hash failed as entry not found in hash table. */ -}; - -/** - * nss_gre_redir_lag_us_tunnel_stats - * Upstream tunnel node statistics. - */ -struct nss_gre_redir_lag_us_tunnel_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. */ - struct nss_gre_redir_lag_us_cmn_stats us_stats; /**< Common node statistics. */ - struct nss_gre_redir_lag_us_cmn_db_stats db_stats; /**< Common hash statistics. */ -}; - -/** - * 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. - */ -struct nss_gre_redir_lag_ds_add_sta_msg { - uint16_t mac[ETH_ALEN / 2]; /**< Station MAC address. */ - uint8_t reorder_type; /**< Reorder type for downstream. */ -}; - -/** - * nss_gre_redir_lag_ds_delete_sta_msg - * Message to delete station in LAG deployment. - */ -struct nss_gre_redir_lag_ds_delete_sta_msg { - uint16_t mac[ETH_ALEN / 2]; /**< Station MAC address. */ -}; - -/** - * nss_gre_redir_lag_ds_update_sta_msg - * Message to update station. - */ -struct nss_gre_redir_lag_ds_update_sta_msg { - uint16_t mac[ETH_ALEN / 2]; /**< Station MAC address. */ - uint8_t reorder_type; /**< Reorder type for downstream. */ -}; - -/** - * nss_gre_redir_lag_ds_stats - * GRE redirect link aggregation downstream statistics structure. - */ -struct nss_gre_redir_lag_ds_stats { - uint32_t dst_invalid; /**< Invalid destination packets. */ - uint32_t exception_cnt; /**< Exception count. */ -}; - -/** - * nss_gre_redir_lag_ds_sync_stats_msg - * Downstream statistics synchronization message. - */ -struct nss_gre_redir_lag_ds_sync_stats_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - struct nss_gre_redir_lag_ds_stats ds_stats; /**< GRE redirect LAG downstream statistics. */ -}; - -/** - *nss_gre_redir_lag_ds_msg - * GRE redirect LAG downstream messages. - */ -struct nss_gre_redir_lag_ds_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a GRE redirect LAG downstream message. - */ - union { - struct nss_gre_redir_lag_ds_add_sta_msg add_sta; /**< Add station entry. */ - struct nss_gre_redir_lag_ds_delete_sta_msg del_sta; /**< Delete station entry. */ - struct nss_gre_redir_lag_ds_update_sta_msg update_sta; /**< Station entry update message. */ - struct nss_gre_redir_lag_ds_sync_stats_msg ds_sync_stats; /**< Downstream statistics. */ - } msg; /**< GRE redirect LAG downstream message payload. */ -}; - -/** - * nss_gre_redir_lag_ds_tun_stats - * 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. */ -}; - -/** - * Callback function for receiving GRE redirect LAG upstream 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_gre_redir_lag_us_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback function for receiving GRE redirect LAG downstream 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_gre_redir_lag_ds_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - - /** - * Callback function for receiving GRE redirect LAG upstream 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_gre_redir_lag_us_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - - /** - * Callback function for receiving GRE redirect LAG downstream 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_gre_redir_lag_ds_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * nss_gre_redir_lag_us_alloc_and_register_node - * Allocates and registers GRE redirect upstream LAG node. - * - * @datatypes - * net_device \n - * nss_gre_redir_lag_us_data_callback_t \n - * nss_gre_redir_lag_us_msg_callback_t - * - * @param[in] dev Net device pointer. - * @param[in] cb_func_data Data callback function. - * @param[in] cb_func_msg Message callback function. - * @param[in] app_ctx Application context for notify callback. - * - * @return - * Interface number if allocation and registration is succesful, else -1. - */ -extern int nss_gre_redir_lag_us_alloc_and_register_node(struct net_device *dev, - nss_gre_redir_lag_us_data_callback_t cb_func_data, - nss_gre_redir_lag_us_msg_callback_t cb_func_msg, void *app_ctx); - -/** - * nss_gre_redir_lag_ds_alloc_and_register_node - * Allocates and registers GRE redirect downstream LAG node. - * - * @datatypes - * net_device \n - * nss_gre_redir_lag_ds_data_callback_t \n - * nss_gre_redir_lag_ds_msg_callback_t - * - * @param[in] dev Net device pointer. - * @param[in] cb_func_data Data callback function. - * @param[in] cb_func_msg Message callback function. - * @param[in] app_ctx Application context for notify callback. - * - * @return - * Interface number if allocation and registration is succesful, else -1. - */ -extern int nss_gre_redir_lag_ds_alloc_and_register_node(struct net_device *dev, - nss_gre_redir_lag_ds_data_callback_t cb_func_data, - nss_gre_redir_lag_ds_msg_callback_t cb_func_msg, void *app_data); - -/** - * nss_gre_redir_lag_us_configure_node - * Configures LAG upstream node. - * - * @datatypes - * nss_gre_redir_lag_us_config_msg - * - * @param[in] ifnum NSS interface number. - * @param[in] ngluc Pointer to LAG upstream node configuration message. - * - * @return - * True if successful, else false. - */ -extern bool nss_gre_redir_lag_us_configure_node(uint32_t ifnum, - struct nss_gre_redir_lag_us_config_msg *ngluc); - -/** - * nss_gre_redir_lag_us_unregister_and_dealloc - * Deregister and deallocate GRE redirect upstream node. - * - * @param[in] if_num NSS interface number. - * - * @return - * Error code. - * - * @dependencies - * The GRE redirect LAG interface must have been previously registered. - */ -extern enum nss_gre_redir_lag_err_types nss_gre_redir_lag_us_unregister_and_dealloc(uint32_t if_num); - -/** - * nss_gre_redir_lag_ds_unregister_and_dealloc - * Deregisters and dealloc GRE redirect LAG downstream interface from the NSS. - * - * @param[in] if_num NSS interface number. - * - * @return - * Error code. - * - * @dependencies - * The GRE redirect LAG interface must have been previously registered. - */ -extern enum nss_gre_redir_lag_err_types nss_gre_redir_lag_ds_unregister_and_dealloc(uint32_t if_num); - -/** - * nss_gre_redir_lag_us_tx_msg - * Sends GRE redirect upstream LAG messages asynchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_gre_redir_lag_us_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_gre_redir_lag_us_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_lag_us_msg *msg); - -/** - * nss_gre_redir_lag_ds_tx_msg - * Sends GRE redirect downstream LAG messages asynchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_gre_redir_lag_ds_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_gre_redir_lag_ds_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_lag_ds_msg *msg); - -/** - * nss_gre_redir_lag_us_tx_buf - * Sends packets to GRE Redirect LAG upstream node. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] os_buf Pointer to the OS buffer (e.g., skbuff). - * @param[in] if_num Tunnel interface number. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_gre_redir_lag_us_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, - uint32_t if_num); - -/** - * nss_gre_redir_lag_ds_tx_buf - * Sends packets to GRE Redirect LAG downstream node. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] os_buf Pointer to the OS buffer (e.g., skbuff). - * @param[in] if_num Tunnel interface number. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_gre_redir_lag_ds_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, - uint32_t if_num); - -/** - * nss_gre_redir_lag_us_tx_msg_sync - * Sends upstream LAG messages to NSS firmware synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_gre_redir_lag_us_msg - * - * @param[in] nss_ctx NSS core context. - * @param[in] ngrm Pointer to GRE redirect upstream LAG message data. - * - * @return - * Status of Tx operation. - */ -extern nss_tx_status_t nss_gre_redir_lag_us_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_lag_us_msg *ngrm); - -/** - * nss_gre_redir_lag_ds_tx_msg_sync - * Sends downstream LAG messages to NSS firmware synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_gre_redir_lag_ds_msg - * - * @param[in] nss_ctx NSS core context. - * @param[in] ngrm Pointer to GRE redirect downstream LAG message data. - * - * @return - * Status of Tx operation. - */ -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 - * Fetches common node statistics for upstream GRE Redir LAG. - * - * @datatypes - * nss_gre_redir_lag_us_tunnel_stats - * - * @param[out] cmn_stats Pointer to common node statistics structure. - * @param[in] index Index to fetch statistics from. - * - * @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); - -/** - * nss_gre_redir_lag_ds_stats_get - * Fetches common node statistics for downstream GRE Redir LAG. - * - * @datatypes - * nss_gre_redir_lag_ds_tun_stats - * - * @param[out] cmn_stats Pointer to common node statistics structure. - * @param[in] index Index to fetch statistics from. - * - * @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); - -/** - * nss_gre_redir_lag_us_get_context - * Gets the GRE redirect LAG upstream context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_gre_redir_lag_us_get_context(void); - -/** - * nss_gre_redir_lag_ds_get_context - * Gets the GRE redirect LAG downstream context. - * - * @return - * Pointer to the NSS core context. - */ -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); - -/** - * @} - */ - -#endif /* __NSS_GRE_REDIR_LAG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre_redir_mark.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre_redir_mark.h deleted file mode 100644 index 39e024bfb..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre_redir_mark.h +++ /dev/null @@ -1,338 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_gre_redir_mark.h - * NSS GRE Redirect mark interface definitions. - */ - -#ifndef __NSS_GRE_REDIR_MARK_H -#define __NSS_GRE_REDIR_MARK_H - -#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. - */ -enum nss_gre_redir_mark_msg_types { - NSS_GRE_REDIR_MARK_REG_CB_MSG, /**< Register callback configuration message. */ - NSS_GRE_REDIR_MARK_STATS_SYNC_MSG, /**< Statistics synchronization message. */ - NSS_GRE_REDIR_MARK_MSG_MAX, /**< Maximum message type. */ -}; - -/** - * nss_gre_redir_mark errors - * Error codes for GRE redirect mark configuration message. - */ -enum nss_gre_redir_mark_error_types { - NSS_GRE_REDIR_MARK_ERROR_NONE, /**< Configuration successful. */ - NSS_GRE_REDIR_MARK_ERROR_INV_IF_NUM, /**< Invalid interface number for callback registration. */ - NSS_GRE_REDIR_MARK_ERROR_INV_ETH_TYPE, /**< Invalid Ethernet type for the destination interface. */ - NSS_GRE_REDIR_MARK_ERROR_TYPE_MAX -}; - -/** - * 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. - */ -struct nss_gre_redir_mark_metadata { - uint32_t dst_ifnum; /**< Destination Tx interface number. */ - 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. */ - uint16_t offset; /**< Buffer offset from the metadata. */ - uint16_t magic; /**< Metadata magic. */ -}; - -/** - * nss_gre_redir_mark_stats - * GRE redirect mark statistics. - */ -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 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 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. */ -}; - -/** - * nss_gre_redir_mark_register_cb_msg - * Transmit 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. */ -}; - -/** - * nss_gre_redir_mark_msg - * Structure that describes the interface message. - */ -struct nss_gre_redir_mark_msg { - struct nss_cmn_msg cm; /**< Common message. */ - - /** - * Payload of a GRE redirect mark message. - */ - union { - struct nss_gre_redir_mark_register_cb_msg reg_cb_msg; - /**< Configuration message to register for callback on completion. */ - struct nss_gre_redir_mark_stats_sync_msg stats_sync; - /**< Mark node statistics synchronization. */ - } msg; /**< Message payload for GRE redirect mark messages exchanged with NSS core. */ -}; - -/** - * Callback function for receiving GRE redirect mark 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_gre_redir_mark_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback function for receiving GRE redirect mark 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_gre_redir_mark_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * nss_gre_redir_mark_unregister_if - * Deregisters a GRE redirect mark interface from the NSS. - * - * @param[in] if_num GRE redirect mark interface number. - * - * @return - * None. - * - * @dependencies - * The GRE redirect mark interface must have been previously registered. - * - * @return - * True if successful, else false. - */ -extern bool nss_gre_redir_mark_unregister_if(uint32_t if_num); - -/** - * nss_gre_redir_mark_tx_buf - * Sends data buffers to NSS firmware asynchronously. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] os_buf Pointer to the OS buffer (e.g. skbuff). - * @param[in] if_num GRE redirect mark interface number. - * - * @return - * Status of the Tx operation. - */ -extern 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_gre_redir_mark_reg_cb - * Configure a callback on VAP for downstream application flows. - * - * @datatypes - * nss_gre_redir_mark_register_cb_msg - * - * @param[in] ifnum NSS interface number. - * @param[in] ngrcm Downstream application callback registration message. - * - * @return - * Status of Tx operation. - */ -extern nss_tx_status_t nss_gre_redir_mark_reg_cb(int ifnum, - struct nss_gre_redir_mark_register_cb_msg *ngrcm); - -/** - * nss_gre_redir_mark_tx_msg - * Sends GRE redirect mark messages. - * - * @datatypes - * nss_ctx_instance \n - * nss_gre_redir_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_gre_redir_mark_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_mark_msg *msg); - -/** - * nss_gre_redir_mark_tx_msg_sync - * Sends messages to NSS firmware synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_gre_redir_mark_msg - * - * @param[in] nss_ctx NSS core context. - * @param[in] ngrm Pointer to GRE redirect mark message data. - * - * @return - * Status of Tx operation. - */ -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 - * Gets GRE redirect mark statistics. - * - * @datatypes - * nss_gre_redir_mark_stats - * - * @param[out] stats Pointer to the memory address, which must be large enough to - * hold all the statistics. - * - * @return - * TRUE or FALSE. - */ -extern bool nss_gre_redir_mark_stats_get(struct nss_gre_redir_mark_stats *stats); - -/** - * nss_gre_redir_alloc_and_register_node - * Registers GRE redirect mark static node with NSS. - * - * @datatypes - * net_device \n - * nss_gre_redir_mark_data_callback_t \n - * nss_gre_redir_mark_msg_callback_t - * - * @param[in] netdev Pointer to the associated network device. - * @param[in] if_num NSS interface number. - * @param[in] cb_func_data Callback for the data. - * @param[in] cb_func_msg Callback for the message. - * @param[in] features Data socket buffer types supported by this interface. - * - * @return - * NSS interface number allocated. - */ -extern struct nss_ctx_instance *nss_gre_redir_mark_register_if(struct net_device *netdev, uint32_t if_num, - nss_gre_redir_mark_data_callback_t cb_func_data, nss_gre_redir_mark_msg_callback_t cb_func_msg, - uint32_t features); - -/** - * nss_gre_redir_mark_get_context - * Gets the GRE redirect mark context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_gre_redir_mark_get_context(void); - -/** - * nss_gre_redir_mark_get_dentry - * Returns directory entry created in debug filesystem for statistics. - * - * @return - * Pointer to created directory entry for GRE redirect mark. - */ -extern struct dentry *nss_gre_redir_mark_get_dentry(void); - -/* - * nss_gre_redir_mark_get_device - * Gets the original device from probe. - * - * @return - * Pointer to the device. - */ -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); - -/** - * @} - */ - -#endif /* __NSS_GRE_REDIR_MARK_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre_tunnel.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre_tunnel.h deleted file mode 100644 index 53f76ed1e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_gre_tunnel.h +++ /dev/null @@ -1,428 +0,0 @@ -/* - **************************************************************************** - * Copyright (c) 2016-2018, 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. - **************************************************************************** - */ - -/** - * @file nss_gre_tunnel.h - * NSS GRE Tunnel interface definitions. - */ - -#ifndef __NSS_GRE_TUNNEL_H -#define __NSS_GRE_TUNNEL_H - -/** - * @addtogroup nss_gre_tunnel_subsystem - * @{ - */ - -/** - * Maximum number of supported GRE tunnel sessions. - */ -#define NSS_MAX_GRE_TUNNEL_SESSIONS 16 - -/** - * nss_gre_tunnel_message_types - * Message types for a GRE tunnel rule. - */ -enum nss_gre_tunnel_message_types { - NSS_GRE_TUNNEL_MSG_CONFIGURE, - NSS_GRE_TUNNEL_MSG_SESSION_DESTROY, - NSS_GRE_TUNNEL_MSG_STATS, - NSS_GRE_TUNNEL_MSG_CONFIGURE_DI_TO_WLAN_ID, - NSS_GRE_TUNNEL_MSG_INQUIRY, - NSS_GRE_TUNNEL_MSG_MAX, -}; - -/** - * nss_gre_tunnel_encrypt_types - * Encryption types for a GRE tunnel. - */ -enum nss_gre_tunnel_encrypt_types { - NSS_GRE_TUNNEL_ENCRYPT_NONE, - NSS_GRE_TUNNEL_ENCRYPT_AES128_CBC, - NSS_GRE_TUNNEL_ENCRYPT_AES256_CBC, - NSS_GRE_TUNNEL_ENCRYPT_MAX, -}; - -/** - * nss_gre_tunnel_mode_types - * Mode types for a GRE tunnel. - */ -enum nss_gre_tunnel_mode_types { - NSS_GRE_TUNNEL_MODE_GRE, - NSS_GRE_TUNNEL_MODE_GRE_UDP, - NSS_GRE_TUNNEL_MODE_MAX, -}; - -/** - * nss_gre_tunnel_ip_types - * IP types for a GRE tunnel. - */ -enum nss_gre_tunnel_ip_types { - NSS_GRE_TUNNEL_IP_IPV4, - NSS_GRE_TUNNEL_IP_IPV6, - NSS_GRE_TUNNEL_IP_MAX, -}; - -/** - * nss_gre_tunnel_error_types - * Error types for a GRE tunnel. - */ -enum nss_gre_tunnel_error_types { - NSS_GRE_TUNNEL_ERR_UNKNOWN_MSG = 1, - NSS_GRE_TUNNEL_ERR_IF_INVALID = 2, - NSS_GRE_TUNNEL_ERR_CPARAM_INVALID = 3, - NSS_GRE_TUNNEL_ERR_MODE_INVALID = 4, - NSS_GRE_TUNNEL_ERR_ENCRYPT_INVALID = 5, - NSS_GRE_TUNNEL_ERR_IP_INVALID = 6, - NSS_GRE_TUNNEL_ERR_ENCRYPT_IDX_INVALID = 7, - NSS_GRE_TUNNEL_ERR_NOMEM = 8, - NSS_GRE_TUNNEL_ERR_PROTO_TEB_INVALID = 9, - NSS_GRE_TUNNEL_ERR_SIBLING_IF = 10, - NSS_GRE_TUNNEL_ERR_CRYPTO_NODE_ID = 11, - NSS_GRE_TUNNEL_ERR_RPS = 12, - NSS_GRE_TUNNEL_ERR_DI_INVALID = 13, - NSS_GRE_TUNNEL_ERR_MAX, -}; - -/** - * 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. - */ -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 fwd_policy; /**< Forward policy bits. */ -}; - -/** - * nss_gre_tunnel_configure - * Message information for configuring a GRE tunnel. - */ -struct nss_gre_tunnel_configure { - uint32_t mh_version; /**< Meta header version. */ - uint8_t gre_mode; /**< GRE or GRE plus UDP. */ - uint8_t ip_type; /**< IPv4 or IPv6. */ - uint16_t encrypt_type; /**< Encryption type. */ - uint32_t src_ip[4]; /**< Source IPv4 or IPv6 address. */ - uint32_t dest_ip[4]; /**< Destination IPv4 or IPv6 address. */ - uint16_t src_port; /**< GRE plus UDP only for the source. */ - uint16_t dest_port; /**< GRE plus UDP only for the destination. */ - uint32_t crypto_node_id; /**< Cryto node identifier. */ - uint32_t crypto_idx_encrypt; /**< Crypto index for encryption. */ - uint32_t crypto_idx_decrypt; /**< Crypto index for decryption. */ - uint32_t word0; /**< Word0 header. */ - uint8_t iv_val[16]; /**< Initialization vector value. */ - uint32_t sibling_if; /**< Sibling interface number. */ - uint8_t ttl; /**< Time-to-live value of the IP header. */ - int8_t rps; /**< Steer packets to host core. */ - uint16_t reserved; /**< Reserved space. */ - uint32_t word1; /**< Word1 header. */ - uint32_t word2; /**< Word2 header. */ - uint32_t word3; /**< Word3 header. */ -}; - -/** - * nss_gre_tunnel_stats - * Message statistics for a GRE tunnel. - */ -struct nss_gre_tunnel_stats { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - uint32_t rx_malformed; /**< Malformed packet was received. */ - uint32_t rx_invalid_prot; /**< Invalid protocol was received. */ - uint32_t decap_queue_full; /**< Decapsulation queue is full. */ - uint32_t rx_single_rec_dgram; /**< Single fragment was received. */ - uint32_t rx_invalid_rec_dgram; /**< Invalid fragment was received. */ - uint32_t buffer_alloc_fail; /**< Buffer memory allocation failed. */ - uint32_t buffer_copy_fail; /**< Buffer memory copy failed. */ - uint32_t outflow_queue_full; /**< Outflow queue is full. */ - 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. */ - uint32_t tx_cbuf_alloc_fail; - /**< Receive crypto buffer allocation failed. */ - uint32_t tx_cenqueue_fail; /**< Transmit 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 crypto_nosupp; - /**< Error count for non-supported crypto packets. */ - uint32_t rx_dropped_mh_ver; /**< Receive 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]; - /** Crypto response errors. */ -#endif -}; - -/** - * 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. - */ -struct nss_gre_tunnel_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a GRE tunnel message. - */ - union { - struct nss_gre_tunnel_configure configure; /**< Tunnel configuration data. */ - struct nss_gre_tunnel_stats stats; /**< Tunnel statistics. */ - struct nss_gre_tunnel_di_to_wlan_id dtwi; /**< Tunnel dynamic interface number to WLAN ID mapping. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving GRE tunnel messages. - * - * @datatypes - * nss_gre_tunnel_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_gre_tunnel_msg_callback_t)(void *app_data, struct nss_gre_tunnel_msg *msg); - -/** - * Callback function for receiving GRE tunnel session 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_gre_tunnel_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_gre_tunnel_tx_buf - * Sends a GRE tunnel packet. - * - * @datatypes - * sk_buff \n - * nss_ctx_instance - * - * @param[in] skb Pointer to the data socket buffer. - * @param[in] if_num Tunnel interface number. - * @param[in] nss_ctx Pointer to the NSS context. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_gre_tunnel_tx_buf(struct sk_buff *skb, uint32_t if_num, struct nss_ctx_instance *nss_ctx); - -/** - * nss_gre_tunnel_tx_msg - * Sends a GRE tunnel message. - * - * @datatypes - * nss_ctx_instance \n - * nss_gre_tunnel_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_gre_tunnel_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_gre_tunnel_msg *msg); - -/** - * nss_gre_tunnel_tx_msg_sync - * Sends a GRE tunnel message synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_gre_tunnel_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_gre_tunnel_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_tunnel_msg *msg); - -/** - * nss_gre_tunnel_msg_init - * Initalizes a GRE tunnel message. - * - * @datatypes - * nss_gre_tunnel_msg - * - * @param[in] ngtm Pointer to the tunnel message. - * @param[in] if_num Tunnel interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -extern void nss_gre_tunnel_msg_init(struct nss_gre_tunnel_msg *ngtm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); - -/** - * nss_gre_tunnel_get_ctx - * Returns the NSS context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_gre_tunnel_get_ctx(void); - -/** - * nss_gre_tunnel_register_if - * Registers a network device with the NSS for sending and receiving tunnel - * messages. - * - * @datatypes - * nss_gre_tunnel_data_callback_t \n - * nss_gre_tunnel_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] cb Callback function for the message. - * @param[in] ev_cb Callback for the GRE tunnel message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * @param[in] app_ctx Pointer to the application context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_gre_tunnel_register_if(uint32_t if_num, - nss_gre_tunnel_data_callback_t cb, - nss_gre_tunnel_msg_callback_t ev_cb, - struct net_device *netdev, - uint32_t features, - void *app_ctx); - -/** - * nss_gre_tunnel_unregister_if - * Deregisters a network device from the NSS. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - * - * @dependencies - * The network device must have been previously registered. - */ -extern void nss_gre_tunnel_unregister_if(uint32_t if_num); - -/** - * nss_gre_tunnel_inquiry() - * Inquiry if a GRE tunnel has been established in NSS FW. - * - * @param[in] inquiry_info Query parameters similar to creation parameters. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * Status of the Tx operation - */ -extern nss_tx_status_t nss_gre_tunnel_inquiry( - struct nss_gre_tunnel_configure *inquiry_info, - 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); - -/** - * @} - */ - -#endif /* __NSS_GRE_TUNNEL_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_if.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_if.h deleted file mode 100644 index abda94189..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_if.h +++ /dev/null @@ -1,454 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_if.h - * NSS interface definitions. - */ - -#ifndef __NSS_IF_H -#define __NSS_IF_H - -#define NSS_IF_TX_TIMEOUT 3000 /* 3 Seconds */ - -/** - * @addtogroup nss_driver_subsystem - * @{ - */ - -/** - * nss_if_message_types - * Message types for the NSS interface. - */ -enum nss_if_message_types { - NSS_IF_OPEN, - NSS_IF_CLOSE, - NSS_IF_LINK_STATE_NOTIFY, - NSS_IF_MTU_CHANGE, - NSS_IF_MAC_ADDR_SET, - NSS_IF_STATS, - NSS_IF_ISHAPER_ASSIGN, - NSS_IF_BSHAPER_ASSIGN, - NSS_IF_ISHAPER_UNASSIGN, - NSS_IF_BSHAPER_UNASSIGN, - NSS_IF_ISHAPER_CONFIG, - NSS_IF_BSHAPER_CONFIG, - NSS_IF_PAUSE_ON_OFF, - NSS_IF_VSI_ASSIGN, - NSS_IF_VSI_UNASSIGN, - NSS_IF_SET_NEXTHOP, - 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, -}; - -/** - * nss_if_error_types - * Error types for the NSS interface. - */ -enum nss_if_error_types { - NSS_IF_ERROR_NO_ISHAPERS, - NSS_IF_ERROR_NO_BSHAPERS, - NSS_IF_ERROR_NO_ISHAPER, - NSS_IF_ERROR_NO_BSHAPER, - NSS_IF_ERROR_ISHAPER_OLD, - NSS_IF_ERROR_BSHAPER_OLD, - NSS_IF_ERROR_ISHAPER_CONFIG_FAILED, - NSS_IF_ERROR_BSHAPER_CONFIG_FAILED, - NSS_IF_ERROR_TYPE_UNKNOWN, - NSS_IF_ERROR_TYPE_EOPEN, - NSS_IF_ERROR_TYPE_INVALID_MTU, - NSS_IF_ERROR_TYPE_INVALID_MAC_ADDR, - NSS_IF_ERROR_TYPE_VSI_NOT_MATCH, - NSS_IF_ERROR_TYPE_VSI_REASSIGN, - NSS_IF_ERROR_TYPE_VSI_INVALID, - NSS_IF_ERROR_TYPE_MAX = 9999, -}; - -/** - * nss_if_data_align - * Data alignment modes for the NSS interface. - */ -enum nss_if_data_align { - NSS_IF_DATA_ALIGN_2BYTE = 0, - NSS_IF_DATA_ALIGN_4BYTE = 2, -}; - -/** - * nss_if_open - * Message information for opening the NSS interface. - */ -struct nss_if_open { - uint32_t tx_desc_ring; /**< Tx descriptor ring address. */ - uint32_t rx_desc_ring; /**< Rx descriptor ring address. */ - uint32_t rx_forward_if; /**< Forward received packets to this interface. */ - uint32_t alignment_mode;/**< Header alignment mode. */ -}; - -/** - * nss_if_close - * Message information for closing the NSS interface. - */ -struct nss_if_close { - uint32_t reserved; /**< Placeholder for the structure. */ -}; - -/** - * nss_if_link_state_notify - * Link state notification sent to the NSS interface. - */ -struct nss_if_link_state_notify { - uint32_t state; - /**< Link state UP is bit 0 set. Other bits are as defined by Linux to indicate speed and duplex. */ -}; - -/** - * nss_if_mtu_change - * MTU change for the NSS interface. - */ -struct nss_if_mtu_change { - uint16_t min_buf_size; /**< Changed value for the minimum buffer size. */ -}; - -/** - * nss_if_pause_on_off - * Enables or disables a pause frame for the NSS interface. - */ -struct nss_if_pause_on_off { - uint32_t pause_on; /**< Turn the pause frame ON or OFF. */ -}; - -/** - * nss_if_mac_address_set - * MAC address setting. - */ -struct nss_if_mac_address_set { - uint8_t mac_addr[ETH_ALEN]; /**< MAC address. */ -}; - -/** - * nss_if_shaper_assign - * Shaper assignment message. - */ -struct nss_if_shaper_assign { - uint32_t shaper_id; /**< ID of the request. */ - uint32_t new_shaper_id; /**< ID of the response. */ -}; - -/** - * nss_if_shaper_unassign - * Shaper unassign message. - */ -struct nss_if_shaper_unassign { - uint32_t shaper_id; /**< ID of the request. */ -}; - -/** - * nss_if_shaper_configure - * Shaper configuration message. - */ -struct nss_if_shaper_configure { - struct nss_shaper_configure config; /**< Specific shaper message for a particular interface. */ -}; - -/** - * nss_if_vsi_assign - * VSI assignment message. - */ -struct nss_if_vsi_assign { - uint32_t vsi; /**< Virtual interface number. */ -}; - -/** - * nss_if_vsi_unassign - * VSI unassign message. - */ -struct nss_if_vsi_unassign { - uint32_t vsi; /**< Virtual interface number. */ -}; - -/** - * nss_if_set_nexthop - * Message to set nexthop for an interface. - */ -struct nss_if_set_nexthop { - uint32_t nexthop; /**< Nexthop interface number. */ -}; - -/** - * nss_if_igs_config - * Ingress shaper set/clear configure message structure. - */ -struct nss_if_igs_config { - int32_t igs_num; /**< Ingress shaper interface number. */ -}; - -/** - * 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. - */ -union nss_if_msgs { - struct nss_if_link_state_notify link_state_notify; - /**< Link status notification. */ - struct nss_if_open open; - /**< Open the NSS interface. */ - struct nss_if_close close; - /**< Close the NSS interface. */ - struct nss_if_mtu_change mtu_change; - /**< MTU change notification. */ - struct nss_if_mac_address_set mac_address_set; - /**< MAC address setting. */ - struct nss_cmn_node_stats stats; - /**< Synchronize the satistics. */ - struct nss_if_shaper_assign shaper_assign; - /**< Assign the shaper. */ - struct nss_if_shaper_unassign shaper_unassign; - /**< Unassign the shaper. */ - struct nss_if_shaper_configure shaper_configure; - /**< Configure the shaper. */ - struct nss_if_pause_on_off pause_on_off; - /**< ON or OFF notification for a Pause frame. */ - struct nss_if_vsi_assign vsi_assign; - /**< Assign the VSI. */ - struct nss_if_vsi_unassign vsi_unassign; - /**< Remove the VSI assignment. */ - struct nss_if_set_nexthop set_nexthop; - /**< 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. */ -}; - -/** - * nss_if_msg - * Data for sending and receiving base class messages for all interface types. - */ -struct nss_if_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - union nss_if_msgs msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving NSS interface messages. - * - * @datatypes - * nss_if_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_if_msg_callback_t)(void *app_data, struct nss_if_msg *msg); - -/** - * Callback function for receiving NSS interface data. - * - * TODO: Adjust to pass app_data as unknown to the - * list layer and netdev/sk as known. - * - * @datatypes - * net_device \n - * sk_buff - * - * @param[in] netdev Pointer to the associated network device. - * @param[in] skb Pointer to the data socket buffer. - */ -typedef void (*nss_if_rx_callback_t)(struct net_device *netdev, struct sk_buff *skb); - -/** - * nss_if_register - * Registers the NSS interface for sending and receiving GMAC packets and messages. - * - * @datatypes - * nss_if_rx_callback_t \n - * nss_if_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] rx_callback Receive callback for the packet. - * @param[in] msg_callback Receive callback for message. - * @param[in] if_ctx Pointer to the interface context provided in the - callback. This context must be the OS network - device context pointer (net_device in Linux). - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_if_register(uint32_t if_num, - nss_if_rx_callback_t rx_callback, - nss_if_msg_callback_t msg_callback, - struct net_device *if_ctx); - -/** - * nss_if_tx_buf - * Sends GMAC packets to a specific physical or virtual network interface. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] os_buf Pointer to the OS buffer (e.g., skbuff). - * @param[in] if_num Network physical or virtual interface number. - * - * @return - * Status of the Tx operation. - */ -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 - * 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. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_if_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_if_msg *nim); - -/** - * 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 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_if_reset_nexthop(struct nss_ctx_instance *nss_ctx, uint32_t if_num); - -/** - * nss_if_change_mtu - * Change 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 - * Change 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 - * Detach 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 - * Attach 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); - -/** - * @} - */ - -#endif /* __NSS_IF_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_igs.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_igs.h deleted file mode 100644 index 651fea4e9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_igs.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_igs.h - * NSS ingress shaper interface definitions. - */ - -#ifndef _NSS_IGS_H_ -#define _NSS_IGS_H_ - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -#ifdef CONFIG_NET_CLS_ACT -#include -#endif -#endif - -/** - * @addtogroup nss_ingress_shaper_subsystem - * @{ - */ - -/** - * Maximum number of supported ingress shaping interfaces. - */ -#define NSS_MAX_IGS_DYNAMIC_INTERFACES 8 - -/** - * nss_igs_msg_types - * Message types for ingress shaper requests and responses. - */ -enum nss_igs_msg_types { - NSS_IGS_MSG_SYNC_STATS = NSS_IF_MAX_MSG_TYPES + 1, - NSS_IGS_MSG_MAX -}; - -/** - * nss_igs_node_stats - * Ingress shaping node debug statistics structure. - */ -struct nss_igs_node_stats { - uint32_t tx_dropped; /**< Dropped post shaping. */ - uint32_t shaper_drop; /**< Dropped during shaper enqueue. */ - uint32_t ipv4_parse_fail; /**< IPv4 parse fail. */ - uint32_t ipv4_unknown_gre_type; /**< IPv4 unknown GRE type. */ - uint32_t ipv4_unknown_l4; /**< IPv4 unknown L4 type. */ - uint32_t ipv4_no_cme; /**< IPv4 connection match entry not found. */ - uint32_t ipv4_frag_initial; /**< IPv4 initial fragment. */ - uint32_t ipv4_frag_non_initial; /**< Ipv4 subsequent fragment. */ - uint32_t ipv4_malformed_udp; /**< Incomplete IPv4 UDP packet. */ - uint32_t ipv4_malformed_tcp; /**< Incomplete IPv4 TCP packet. */ - uint32_t ipv4_malformed_udpl; /**< Incomplete IPv4 UDP-Lite packet. */ - uint32_t ipv4_malformed_gre; /**< Incomplete IPv4 GRE packet. */ - uint32_t ipv6_parse_fail; /**< IPv6 parse fail. */ - uint32_t ipv6_unknown_l4; /**< IPv6 unknown L4 type. */ - uint32_t ipv6_no_cme; /**< IPv6 connection match entry not found. */ - uint32_t ipv6_frag_initial; /**< IPv6 initial fragment. */ - uint32_t ipv6_frag_non_initial; /**< Ipv6 subsequent fragment. */ - uint32_t ipv6_malformed_udp; /**< Incomplete IPv6 UDP packet. */ - uint32_t ipv6_malformed_tcp; /**< Incomplete IPv6 TCP packet. */ - uint32_t ipv6_malformed_udpl; /**< Incomplete IPv6 UDP-Lite packet. */ - uint32_t ipv6_malformed_frag; /**< Incomplete IPv6 fragment. */ - uint32_t event_no_si; /**< No shaper configured. */ - uint32_t eth_parse_fail; /**< Ethernet header parse failed. */ - uint32_t eth_unknown_type; /**< Non-IP/PPPoE ether type. */ - uint32_t pppoe_non_ip; /**< Non-IP PPPoE packet. */ - uint32_t pppoe_malformed; /**< Incomplete PPPoE packet. */ -}; - -/** - * nss_igs_stats_sync_msg - * Message information for ingress shaping synchronization statistics. - */ -struct nss_igs_stats_sync_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - struct nss_igs_node_stats igs_stats; /**< Debug statistics for ingress shaping. */ -}; - -/** - * nss_igs_msg - * Data for sending and receiving ingress shaper messages. - */ -struct nss_igs_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a ingress shaper message. - */ - union { - union nss_if_msgs if_msg; - /**< NSS interface base message. */ - struct nss_igs_stats_sync_msg stats; - /**< Statistics message to host. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving ingress shaper 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_igs_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * nss_igs_get_context - * Gets the ingress shaper context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_igs_get_context(void); - -/** - * nss_igs_register_if - * Registers a ingress shaper interface with the NSS for sending and receiving messages. - * - * @datatypes - * nss_igs_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] type NSS interface type. - * @param[in] msg_callback Callback for the ingress shaper message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_igs_register_if(uint32_t if_num, uint32_t type, - nss_igs_msg_callback_t msg_callback, struct net_device *netdev, uint32_t features); - -/** - * nss_igs_unregister_if - * Deregisters a ingress shaper interface from the NSS. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - */ -extern void nss_igs_unregister_if(uint32_t if_num); - -/** - * nss_igs_verify_if_num - * Verify whether interface is an ingress shaper interface or not. - * - * @param[in] if_num NSS interface number. - * - * @return - * True if interface is an ingress shaper interface. - */ -extern bool nss_igs_verify_if_num(uint32_t if_num); - - -#ifdef CONFIG_NET_CLS_ACT -/* - * nss_igs_module_save() - * Save the ingress shaping module reference. - * - * @datatypes - * tc_action_ops \n - * module - * - * @param[in] act Operation structure for ingress shaping action. - * @param[in] module Module structure of ingress shaping module. - * - * @return - * None. - */ -extern void nss_igs_module_save(struct tc_action_ops *act, struct module *module); -#endif - -/* - * nss_igs_module_get() - * Get the ingress shaping module reference. - * - * @return - * False if not able to take the ingress shaping module reference, otherwise true. - * - */ -extern bool nss_igs_module_get(void); - -/* - * nss_igs_module_put() - * Release the ingress shaping module reference. - * - * @return - * None. - */ -extern void nss_igs_module_put(void); - -/** - * @} - */ -#endif diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipsec.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipsec.h deleted file mode 100644 index 3a9de9339..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipsec.h +++ /dev/null @@ -1,550 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipsec.h - * NSS IPSec interface definitions. - */ - -#ifndef __NSS_IPSEC_H -#define __NSS_IPSEC_H - -/* - * For some reason Linux doesn't define this in if_arp.h, - * refer http://www.iana.org/assignments/arp-parameters/arp-parameters.xhtml - * for the full list - */ - -/** - * @addtogroup nss_ipsec_subsystem - * @{ - */ - -#define NSS_IPSEC_ARPHRD_IPSEC 31 - /**< ARP (iana.org) hardware type for an IPsec tunnel. */ -#define NSS_IPSEC_MAX_RULES 256 - /**< Maximum number of rules supported. */ -#define NSS_IPSEC_MAX_SA NSS_CRYPTO_MAX_IDXS - /**< Maximum number of SAs supported. */ - -#if (~(NSS_IPSEC_MAX_RULES - 1) & (NSS_IPSEC_MAX_RULES >> 1)) -#error "NSS Max SA should be a power of 2" -#endif - -/** - * Size of an IPsec message. - */ -#define NSS_IPSEC_MSG_LEN (sizeof(struct nss_ipsec_msg) - sizeof(struct nss_cmn_msg)) - -/** - * nss_ipsec_msg_type - * Rules for the IPsec interface. - */ -enum nss_ipsec_msg_type { - NSS_IPSEC_MSG_TYPE_NONE = 0, - NSS_IPSEC_MSG_TYPE_ADD_RULE = 1, - NSS_IPSEC_MSG_TYPE_DEL_RULE = 2, - NSS_IPSEC_MSG_TYPE_FLUSH_TUN = 3, - NSS_IPSEC_MSG_TYPE_SYNC_SA_STATS = 4, - NSS_IPSEC_MSG_TYPE_SYNC_FLOW_STATS = 5, - NSS_IPSEC_MSG_TYPE_SYNC_NODE_STATS = 6, - NSS_IPSEC_MSG_TYPE_CONFIGURE_NODE = 7, - NSS_IPSEC_MSG_TYPE_MAX -}; - -/** - * nss_ipsec_status - * Status types for the IPsec interface. - */ -typedef enum nss_ipsec_status { - NSS_IPSEC_STATUS_OK = 0, - NSS_IPSEC_STATUS_ENOMEM = 1, - NSS_IPSEC_STATUS_ENOENT = 2, - NSS_IPSEC_STATUS_MAX -} nss_ipsec_status_t; - -/** - * nss_ipsec_error_type - * Error types for the IPsec interface. - */ -enum nss_ipsec_error_type { - NSS_IPSEC_ERROR_TYPE_NONE = 0, - NSS_IPSEC_ERROR_TYPE_HASH_DUPLICATE = 1, - NSS_IPSEC_ERROR_TYPE_HASH_COLLISION = 2, - NSS_IPSEC_ERROR_TYPE_UNHANDLED_MSG = 3, - NSS_IPSEC_ERROR_TYPE_INVALID_RULE = 4, - NSS_IPSEC_ERROR_TYPE_MAX_SA = 5, - NSS_IPSEC_ERROR_TYPE_MAX_FLOW = 6, - NSS_IPSEC_ERROR_TYPE_INVALID_CINDEX = 7, - NSS_IPSEC_ERROR_TYPE_INVALID_IPVER = 8, - NSS_IPSEC_ERROR_TYPE_MAX -}; - -/** - * nss_ipsec_type - * Operation types for the IPsec interface. - */ -enum nss_ipsec_type { - NSS_IPSEC_TYPE_NONE = 0, - NSS_IPSEC_TYPE_ENCAP = 1, - NSS_IPSEC_TYPE_DECAP = 2, - NSS_IPSEC_TYPE_MAX -}; - -/** - * nss_ipsec_tuple - * Common IPsec rule selector tuple for encapsulation and decapsulation. - * - * This selector is used for preparing a lookup tuple for incoming packets. - * The tuple is used to derive the index into the rule table. - * - * Choosing the selector fields depends on the IPsec encapsulation or decapsulation - * package. The host has no understanding of the index derived from the selector fields, - * and thus it provides information for all entries in the structure. - * - * The encapsulation and decapsulation packages return the index in their respective - * tables to the host. The host stores the rule for future reference purposes. - */ -struct nss_ipsec_tuple { - uint32_t dst_addr[4]; /**< Destination IP address. */ - uint32_t src_addr[4]; /**< Source IP address. */ - - uint32_t esp_spi; /**< SPI index. */ - - uint16_t dst_port; /**< Destination port (UDP or TCP). */ - uint16_t src_port; /**< Source port (UDP or TCP). */ - - uint8_t proto_next_hdr; /**< IP header type. */ - uint8_t ip_ver; /**< IP version. */ - uint8_t res[2]; /**< Reserved for 4-byte alignment. */ -}; - -/** - * nss_ipsec_rule_oip - * Common information about the IPsec rule outer IP header. - */ -struct nss_ipsec_rule_oip { - uint32_t dst_addr[4]; /**< IPv4 destination address to apply. */ - uint32_t src_addr[4]; /**< IPv4 source address to apply. */ - - uint32_t esp_spi; /**< ESP SPI index to apply. */ - - uint16_t dst_port; /**< Destination port (UDP or TCP). */ - uint16_t src_port; /**< Source port (UDP or TCP). */ - - uint8_t ttl_hop_limit; /**< IPv4 time-to-live value to apply. */ - uint8_t ip_ver; /**< IP version. */ - uint8_t proto_next_hdr; /**< IP header type. */ - uint8_t res; /**< Reserved for 4-byte alignment. */ -}; - -/** - * nss_ipsec_rule_data - * IPsec rule data used for per-packet transformation. - */ -struct nss_ipsec_rule_data { - - uint16_t crypto_index; /**< Crypto index for the security association. */ - uint16_t window_size; /**< ESP sequence number window. */ - - uint8_t cipher_blk_len; /**< Size of the cipher block. */ - uint8_t iv_len; /**< Size of the initialization vector. */ - uint8_t nat_t_req; /**< NAT-T required. */ - uint8_t esp_icv_len; /**< Size of the ICV to be produced as a result of authentication. */ - - uint8_t esp_seq_skip; /**< Skip an ESP sequence number. */ - uint8_t esp_tail_skip; /**< Skip an ESP trailer. */ - uint8_t use_pattern; /**< Use random pattern in a hash calculation. */ - uint8_t enable_esn; /**< Enable extended sequence number. */ - - uint8_t dscp; /**< Default DSCP value of the SA. */ - uint8_t df; /**< Default dont fragment value of the SA. */ - uint8_t copy_dscp; /**< The flag tells whether to copy DSCP from inner header. */ - uint8_t copy_df; /**< The flag tells Whether to copy DF from inner header. */ - - uint32_t res2[4]; /**< Reserved 16 bytes for future use. */ -}; - -/** - * nss_ipsec_rule - * Push message for IPsec rules. - * - * This message is sent from the host to the NSS for performing an operation - * on NSS rule tables. - */ -struct nss_ipsec_rule { - struct nss_ipsec_rule_oip oip; /**< Per rule outer IP information. */ - struct nss_ipsec_rule_data data;/**< Per rule data. */ - - uint32_t index; /**< Index provided by the NSS. */ - uint32_t sa_idx; /**< Rule index for the security association table. */ -}; - -/** - * nss_ipsec_configure_node - * Push message for setting IPsec inline mode and initializing DMA rings. - */ -struct nss_ipsec_configure_node { - bool dma_redirect; /**< Program redirect DMA ring. */ - bool dma_lookaside; /**< Program lookaside DMA ring. */ -}; - -/** - * nss_ipsec_sa_stats - * Packet statistics per security association. - */ -struct nss_ipsec_sa_stats { - uint32_t count; /**< Packets processed. */ - uint32_t bytes; /**< Bytes processed. */ - uint32_t no_headroom; /**< Insufficient headroom. */ - uint32_t no_tailroom; /**< Insufficient tailroom. */ - uint32_t no_resource; /**< No crypto buffer. */ - uint32_t fail_queue; /**< Failed to enqueue. */ - uint32_t fail_hash; /**< Hash mismatch. */ - uint32_t fail_replay; /**< Replay check failure. */ - uint64_t seq_num; /**< Current sequence number. */ - uint64_t window_max; /**< Maximum size of the window. */ - uint32_t window_size; /**< Current window size. */ - uint32_t fail_hash_cont; /**< Consecutive hash fail count. */ - uint8_t esn_enabled; /**< Indicates whether ESN is enabled. */ - uint8_t res[3]; /**< Reserved for future use. */ -} /** @cond */ __attribute__((packed))/** @endcond */; - -/** - * nss_ipsec_flow_stats - * Per-flow statistics. - */ -struct nss_ipsec_flow_stats { - uint32_t processed; /**< Packets processed for this flow. */ - - uint8_t use_pattern; /**< Use random pattern. */ - uint8_t res[3]; /**< Reserved for 4-byte alignment padding. */ -}; - -/** - * nss_ipsec_node_stats - * Per-node statistics. - */ -struct nss_ipsec_node_stats { - uint32_t enqueued; /**< Packets enqueued to the node. */ - uint32_t completed; /**< Packets processed by the node. */ - uint32_t linearized; /**< Packet is linear. */ - uint32_t exceptioned; /**< Packets exception from the NSS. */ - uint32_t fail_enqueue; /**< Packets failed to enqueue. */ - uint32_t redir_rx; /**< Packets received in redirect ring. */ - uint32_t fail_redir; /**< Packets dropped in redirect ring. */ -}; - -/** - * nss_ipsec_stats - * Common statistics structure. - */ -union nss_ipsec_stats { - struct nss_ipsec_sa_stats sa; /**< Security association statistics. */ - struct nss_ipsec_flow_stats flow; /**< Flow statistics. */ - struct nss_ipsec_node_stats node; /**< Node statistics. */ -}; - -/** - * nss_ipsec_msg - * Data for sending and receiving IPsec messages. - */ -struct nss_ipsec_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - uint32_t tunnel_id; /**< ID of the tunnel associated with the message. */ - struct nss_ipsec_tuple tuple; - /**< Tuple to look up the SA table for encapsulation or decapsulation. */ - enum nss_ipsec_type type; /**< Encapsulation or decapsulation operation. */ - - /** - * Payload of an IPsec message. - */ - union { - struct nss_ipsec_rule rule; - /**< IPsec rule message. */ - struct nss_ipsec_configure_node node; - /**< IPsec node message. */ - union nss_ipsec_stats stats; - /**< Retrieve statistics for the tunnel. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving message notifications. - * - * @datatypes - * nss_ipsec_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_ipsec_msg_callback_t)(void *app_data, struct nss_ipsec_msg *msg); - -/** - * Callback function for receiving 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 message data. - * @param[in] napi Pointer to the NAPI structure. - */ -typedef void (*nss_ipsec_buf_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_ipsec_tx_msg - * Sends an IPsec message to the NSS HLOS driver. - * - * @datatypes - * nss_ctx_instance \n - * nss_ipsec_msg - * - * @param[in] nss_ctx Pointer to the NSS HLOS driver context. - * @param[in] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_ipsec_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_ipsec_msg *msg); - -/** - * nss_ipsec_tx_msg_sync - * Sends IPsec messages synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_ipsec_msg_type \n - * nss_ipsec_msg \n - * nss_ipsec_error_type - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] if_num Configuration interface number. - * @param[in] type Type of the message. - * @param[in] len Size of the payload. - * @param[in] nim Pointer to the message data. - * @param[in,out] resp Response for the configuration. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_ipsec_tx_msg_sync(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - enum nss_ipsec_msg_type type, uint16_t len, - struct nss_ipsec_msg *nim, enum nss_ipsec_error_type *resp); - -/** - * nss_ipsec_tx_buf - * Sends a plain text packet to NSS for IPsec encapsulation or decapsulation. - * - * @datatypes - * sk_buff - * - * @param[in] skb Pointer to the message data. - * @param[in] if_num Pointer to the NSS interface number. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_ipsec_tx_buf(struct sk_buff *skb, uint32_t if_num); - -/** - * nss_ipsec_notify_register - * Registers an event callback handler with the HLOS driver. - * - * When registered, the message callback is called when the NSS - * sends a response to the message sent by the host. - * - * @datatypes - * nss_ipsec_msg_callback_t - * - * @param[in] if_num NSS interface number. - * @param[in] cb Callback function for the message. - * @param[in] app_data Pointer to the context of the message. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_ipsec_notify_register(uint32_t if_num, nss_ipsec_msg_callback_t cb, void *app_data); - -/** - * nss_ipsec_data_register - * Registers a data callback handler with the HLOS driver. - * - * The HLOS driver calls the registered data callback to return - * the packet to the OS. - * - * @datatypes - * nss_ipsec_buf_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] cb Callback function for the data. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_ipsec_data_register(uint32_t if_num, nss_ipsec_buf_callback_t cb, struct net_device *netdev, uint32_t features); - -/** - * nss_ipsec_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_notify_unregister(struct nss_ctx_instance *ctx, uint32_t if_num); - -/** - * nss_ipsec_data_unregister - * Deregisters the data 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 data notifier must have been previously registered. - */ -extern void nss_ipsec_data_unregister(struct nss_ctx_instance *ctx, uint32_t if_num); - -/** - * nss_ipsec_get_context - * Gets the NSS context for the IPsec handle. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_ipsec_get_context(void); - -/** - * nss_ipsec_get_ifnum - * Gets the IPsec interface number with a core ID. - * - * @param[in] if_num NSS interface number. - * - * @return - * Interface number with the core ID. - */ -extern int32_t nss_ipsec_get_ifnum(int32_t if_num); - -/** - * nss_ipsec_msg_init - * Initializes an IPsec message. - * - * @datatypes - * nss_ipsec_msg \n - * nss_ipsec_msg_callback_t - * - * @param[in,out] nim 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_ipsec_msg_init(struct nss_ipsec_msg *nim, uint16_t if_num, uint32_t type, uint32_t len, - nss_ipsec_msg_callback_t cb, void *app_data); - -/** - * nss_ipsec_get_encap_interface - * Gets the NSS interface number to be used for IPsec encapsulation message. - * - * @return - * Encapsulation interface number. - */ -extern int32_t nss_ipsec_get_encap_interface(void); - -/** - * nss_ipsec_get_decap_interface - * Gets the NSS interface number to be used for an IPsec decapsulation message. - * - * @return - * Decapsulation interface number. - */ -extern int32_t nss_ipsec_get_decap_interface(void); - -/** - * nss_ipsec_get_data_interface - * Gets the NSS interface number to be used for an IPsec data transfer. - * - * @return - * NSS interface number. - */ -extern int32_t nss_ipsec_get_data_interface(void); - -/** - * nss_ipsec_ppe_port_config - * Configure Packet Processing Engine IPsec port. - * - * @datatypes - * nss_ctx_instance \n - * net_device - * - * @param[in] ctx Pointer to the context of the HLOS driver. - * @param[in] netdev Pointer to the associated network device. - * @param[in] if_num Data interface number. - * @param[in] vsi_num Virtual switch instance number. - * - * @return - * True if successful, else false. - */ -extern bool nss_ipsec_ppe_port_config(struct nss_ctx_instance *ctx, struct net_device *netdev, - uint32_t if_num, uint32_t vsi_num); - -/** - * nss_ipsec_ppe_mtu_update() - * Configure Packet Processing Engine MTU for IPsec in-line. - * - * @datatypes - * nss_ctx_instance \n - * - * @param[in] ctx Pointer to the context of the HLOS driver. - * @param[in] if_num Data interface number. - * @param[in] mtu Maximum transmission unit of Interface number. - * @param[in] mru Maximum Receive unit of Interface number. - * - * @return - * True if successful, else false. - */ -bool nss_ipsec_ppe_mtu_update(struct nss_ctx_instance *ctx, uint32_t if_num, uint16_t mtu, uint16_t mru); - -/** - * @} - */ - -#endif /* __NSS_IPSEC_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipsec_cmn.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipsec_cmn.h deleted file mode 100644 index f9f4c78c5..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipsec_cmn.h +++ /dev/null @@ -1,691 +0,0 @@ -/* - ************************************************************************** - * 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 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_ipsec_cmn.h - * NSS IPsec interface definitions. - */ - -#ifndef __NSS_IPSEC_CMN_H_ -#define __NSS_IPSEC_CMN_H_ - -/** - * @addtogroup nss_ipsec_subsystem - * @{ - */ - -#define NSS_IPSEC_CMN_ARPHRD_IPSEC 31 /**< ARP (iana.org) hardware type for an IPsec tunnel. */ - -/** - * Flags for SA configuration. - */ -#define NSS_IPSEC_CMN_FLAG_IPV6 (0x1 << 0) /**< IPv6 header. */ -#define NSS_IPSEC_CMN_FLAG_IPV4_NATT (0x1 << 1) /**< IPv4 NAT traversal. */ -#define NSS_IPSEC_CMN_FLAG_IPV4_UDP (0x1 << 2) /**< IPv4 UDP traversal. */ -#define NSS_IPSEC_CMN_FLAG_ESP_ESN (0x1 << 3) /**< Enable ESP extended sequence number. */ -#define NSS_IPSEC_CMN_FLAG_ESP_SKIP (0x1 << 4) /**< Skip ESP sequence number and ICV. */ -#define NSS_IPSEC_CMN_FLAG_ESP_REPLAY (0x1 << 5) /**< Check ESP replay counter. */ -#define NSS_IPSEC_CMN_FLAG_CIPHER_NULL (0x1 << 6) /**< NULL cipher mode. */ -#define NSS_IPSEC_CMN_FLAG_CIPHER_GCM (0x1 << 7) /**< Galios counter mode. */ -#define NSS_IPSEC_CMN_FLAG_COPY_DSCP (0x1 << 8) /**< Copy DSCP from inner to outer header. */ -#define NSS_IPSEC_CMN_FLAG_COPY_DF (0x1 << 9) /**< Copy DF from inner node to outer node. */ -#define NSS_IPSEC_CMN_FLAG_MODE_TRANS (0x1 << 10) /**< Encapsulate or decapsulate in transport mode (default is tunnel mode). */ - -#define NSS_IPSEC_CMN_FLAG_HDR_MASK \ - (NSS_IPSEC_CMN_FLAG_IPV6 | NSS_IPSEC_CMN_FLAG_IPV4_NATT | NSS_IPSEC_CMN_FLAG_IPV4_UDP) - /**< Flag header mask. */ - -#define NSS_IPSEC_CMN_FEATURE_INLINE_ACCEL 0x1 /**< Interface enabled for inline exception. */ - -#define NSS_IPSEC_CMN_MDATA_VERSION 0x01 /**< Metadata version. */ -#define NSS_IPSEC_CMN_MDATA_MAGIC 0x8893 /**< Metadata magic. */ -#define NSS_IPSEC_CMN_MDATA_ORIGIN_HOST 0x01 /**< Metadata originates at the host. */ -#define NSS_IPSEC_CMN_MDATA_ALIGN_SZ sizeof(uint32_t) /**< Metadata alignment size. */ -/** - * nss_ipsec_cmn_msg_type - * IPsec message types. - */ -enum nss_ipsec_cmn_msg_type { - NSS_IPSEC_CMN_MSG_TYPE_NONE = 0, /**< Nothing to do. */ - NSS_IPSEC_CMN_MSG_TYPE_NODE_CONFIG = 1, /**< Configure IPsec node. */ - NSS_IPSEC_CMN_MSG_TYPE_CTX_CONFIG = 2, /**< Configure IPsec dynamic node. */ - NSS_IPSEC_CMN_MSG_TYPE_CTX_SYNC = 3, /**< Synchronize context statistics to host. */ - NSS_IPSEC_CMN_MSG_TYPE_SA_CREATE = 4, /**< Create SA. */ - NSS_IPSEC_CMN_MSG_TYPE_SA_DESTROY = 5, /**< Destroy SA. */ - NSS_IPSEC_CMN_MSG_TYPE_SA_SYNC = 6, /**< Synchronize SA statistics to host. */ - NSS_IPSEC_CMN_MSG_TYPE_FLOW_CREATE = 7, /**< Create flow. */ - NSS_IPSEC_CMN_MSG_TYPE_FLOW_DESTROY = 8, /**< Delete flow. */ - NSS_IPSEC_CMN_MSG_TYPE_MAX -}; - -/** - * nss_ipsec_cmn_msg_error - * IPsec message error types. - */ -enum nss_ipsec_cmn_msg_error { - NSS_IPSEC_CMN_MSG_ERROR_NONE = 0, /**< No error. */ - NSS_IPSEC_CMN_MSG_ERROR_CTX_INVAL = 1, /**< Invalid context. */ - NSS_IPSEC_CMN_MSG_ERROR_SA_ALLOC = 2, /**< Failed to allocate SA. */ - NSS_IPSEC_CMN_MSG_ERROR_SA_INVAL = 3, /**< Invalid SA. */ - NSS_IPSEC_CMN_MSG_ERROR_SA_DUP = 4, /**< SA exists. */ - NSS_IPSEC_CMN_MSG_ERROR_SA_INUSE = 5, /**< SA is in use. */ - NSS_IPSEC_CMN_MSG_ERROR_FLOW_ALLOC = 6, /**< Failed to allocate flow. */ - NSS_IPSEC_CMN_MSG_ERROR_FLOW_INVAL = 7, /**< Flow not found. */ - NSS_IPSEC_CMN_MSG_ERROR_FLOW_DUP = 8, /**< Duplicate flow. */ - NSS_IPSEC_CMN_MSG_ERROR_FLOW_SA = 9, /**< Failed to find SA for the flow. */ - NSS_IPSEC_CMN_MSG_ERROR_NODE_REG_DYNIF = 10, - /**< Error registering dynamic interface. */ - NSS_IPSEC_CMN_MSG_ERROR_UNHANDLED_MSG= 11, /**< Unhandled message type. */ - NSS_IPSEC_CMN_MSG_ERROR_MAX /**< Maximum error message. */ -}; - -/** - * nss_ipsec_cmn_ctx_type - * IPsec context type. - */ -enum nss_ipsec_cmn_ctx_type { - NSS_IPSEC_CMN_CTX_TYPE_NONE = 0, /**< Invalid direction. */ - NSS_IPSEC_CMN_CTX_TYPE_INNER, /**< Encapsulation. */ - NSS_IPSEC_CMN_CTX_TYPE_MDATA_INNER, /**< Metadata for encapsulation. */ - NSS_IPSEC_CMN_CTX_TYPE_OUTER, /**< Decapsulation. */ - NSS_IPSEC_CMN_CTX_TYPE_MDATA_OUTER, /**< Metadata for decapsulation. */ - NSS_IPSEC_CMN_CTX_TYPE_REDIR, /**< Redirect. */ - NSS_IPSEC_CMN_CTX_TYPE_MAX -}; - -/** - * 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. - * - * Note: This is a common selector which is used for preparing - * a lookup tuple for incoming packets. The tuple is used - * for computing the hash index in the flow table. There are multiple - * fields in the tuple and the recipient node decides which fields - * it must use from the tuple to calculate the hash index. The host - * has no view of the hash index and hence must compute its own index - * based on the tuple. - */ -struct nss_ipsec_cmn_flow_tuple { - uint32_t dest_ip[4]; /**< Destination IP. */ - uint32_t src_ip[4]; /**< Source IP. */ - uint32_t spi_index; /**< ESP SPI index. */ - - uint16_t dst_port; /**< Destination L4 port. */ - uint16_t src_port; /**< Source L4 port. */ - - uint8_t user_pattern; /**< User defined field. */ - uint8_t protocol; /**< IP protocol types. */ - uint8_t ip_ver; /**< IP version. */ -}; - -/** - *nss_ipsec_cmn_sa_tuple - * IPsec outer header configuration. - */ -struct nss_ipsec_cmn_sa_tuple { - uint32_t dest_ip[4]; /**< Destination IP. */ - uint32_t src_ip[4]; /**< Source IP. */ - uint32_t spi_index; /**< ESP SPI index. */ - - uint16_t dest_port; /* Destination L4 port. */ - uint16_t src_port; /* Source L4 port. */ - - uint16_t crypto_index; /**< Crypto index for the SA. */ - uint8_t protocol; /**< Outer protocol. */ - uint8_t ip_ver; /**< IP version. */ - - uint8_t hop_limit; /**< Time-to-Live or next hop limit. */ - uint8_t res[3]; /**< Reserved. */ -}; - -/** - *nss_ipsec_cmn_sa_data - * IPsec SA data used for transformation. - */ -struct nss_ipsec_cmn_sa_data { - uint32_t seq_start; /**< Starting sequence number. */ - uint32_t flags; /**< Configuration flags. */ - - uint16_t window_size; /**< ESP sequence number window. */ - uint8_t dscp; /**< Default DSCP value of the SA. */ - uint8_t df; /**< Default do not fragment value of the SA. */ - - uint8_t blk_len; /**< Cipher block length. */ - uint8_t iv_len; /**< IV length. */ - uint8_t icv_len; /**< ESP trailers ICV length to apply. */ - uint8_t res1; /**< Reserved. */ - - uint32_t res2[4]; /**< Reserved for future use. */ -}; - -/** - * nss_ipsec_cmn_flow - * IPsec flow configuration message. - */ -struct nss_ipsec_cmn_flow { - struct nss_ipsec_cmn_flow_tuple flow_tuple; /**< Flow tuple. */ - struct nss_ipsec_cmn_sa_tuple sa_tuple; /**< SA tuple. */ -}; - -/** - * nss_ipsec_cmn_sa - * IPsec SA configuration message. - */ -struct nss_ipsec_cmn_sa { - struct nss_ipsec_cmn_sa_tuple sa_tuple; /**< SA tuple. */ - struct nss_ipsec_cmn_sa_data sa_data; /**< SA data. */ -}; - -/** - * nss_ipsec_cmn_ctx - * IPsec context configuration. - */ -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. */ -}; - -/** - * nss_ipsec_cmn_node - * IPsec node configuration. - */ -struct nss_ipsec_cmn_node { - bool dma_redirect; /**< Enable redirect DMA ring. */ - bool dma_lookaside; /**< Enable lookaside DMA ring. */ - uint16_t max_sa; /**< Maximum number of SA(s) supported. */ -}; - -/** - * nss_ipsec_cmn_sa_replay - * IPsec replay statistics - */ -struct nss_ipsec_cmn_sa_replay { - uint64_t seq_start; /**< Start of replay window. */ - uint64_t seq_cur; /**< Current sequence number. */ - uint16_t window_size; /**< Window size. */ - uint8_t res[6]; /**< Reserved for future use. */ -}; - -/** - * nss_ipsec_cmn_sa_stats - * IPsec SA statistics. - */ -struct nss_ipsec_cmn_sa_stats { - struct nss_cmn_node_stats cmn_stats; /**< Packet statistics. */ - uint32_t fail_headroom; /**< Failed headroom check. */ - uint32_t fail_tailroom; /**< Failed tailroom check. */ - uint32_t fail_replay; /**< Failure in anti-replay check. */ - uint32_t fail_replay_dup; /**< Failure in anti-replay; duplicate records. */ - uint32_t fail_replay_win; /**< Failure in anti-replay; packet outside the window. */ - uint32_t fail_pbuf_crypto; /**< Failed to allocate crypto pbuf. */ - uint32_t fail_queue; /**< Failure due to queue full in IPsec. */ - uint32_t fail_queue_crypto; /**< Failure due to queue full in crypto. */ - uint32_t fail_queue_nexthop; /**< Failure due to queue full in next hop. */ - 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_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. */ - uint32_t fail_blk_len; /**< Failure in decapsulation due to bad cipher block length. */ - uint32_t fail_hash_len; /**< Failure in decapsulation due to bad hash block length. */ - 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, seq overflow. */ -}; - -/** - * nss_ipsec_cmn_sa_sync - * IPsec SA sync message. - */ -struct nss_ipsec_cmn_sa_sync { - struct nss_ipsec_cmn_sa_replay replay; /**< Replay statistics. */ - struct nss_ipsec_cmn_sa_tuple sa_tuple; /**< SA tuple. */ - struct nss_ipsec_cmn_sa_stats stats; /**< Packet and failure statistics. */ -}; - -/** - * nss_ipsec_cmn_ctx_stats - * IPsec context statistics. - */ -struct nss_ipsec_cmn_ctx_stats { - struct nss_cmn_node_stats cmn_stats; - /**< Packet statistics. */ - 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. */ - uint32_t fail_exception; /**< Failed to exception. */ - 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. */ -}; - -/** - * nss_ipsec_cmn_ctx_sync - * IPsec context synchronous message. - */ -struct nss_ipsec_cmn_ctx_sync { - enum nss_ipsec_cmn_ctx_type type; /**< IPsec context type. */ - struct nss_ipsec_cmn_ctx_stats stats; /**< Context statistics. */ -}; - -/** - * nss_ipsec_cmn_mdata_cmn - * IPsec common metadata information. - */ -struct nss_ipsec_cmn_mdata_cmn { - uint8_t version; /**< Metadata version. */ - uint8_t origin; /**< Metadata origin (host or NSS). */ - uint16_t len; /**< Metadata length including extra bytes. */ - uint8_t res[2]; /**< Reserved for future. */ - uint16_t magic; /**< Metadata magic. */ -}; - -/** - * nss_ipsec_cmn_mdata_encap - * IPsec encapsulation metadata information. - */ -struct nss_ipsec_cmn_mdata_encap { - struct nss_ipsec_cmn_sa_tuple sa; /**< SA tuple. */ - uint32_t seq_num; /**< Sequence number for encapsulation (zero disables it). */ - uint16_t data_len; /**< Length of data to encapsulate. */ - uint16_t flags; /**< Encapsulation metadata flags. */ -}; - -/** - * nss_ipsec_cmn_mdata_decap - * IPsec decapsulation metadata information. - */ -struct nss_ipsec_cmn_mdata_decap { - struct nss_ipsec_cmn_sa_tuple sa; /**< SA tuple. */ -}; - -/** - * nss_ipsec_cmn_mdata - * IPsec metadata for host originated packets. - */ -struct nss_ipsec_cmn_mdata { - struct nss_ipsec_cmn_mdata_cmn cm; /**< Common metadata. */ - - union { - struct nss_ipsec_cmn_mdata_encap encap; /**< Encapsulation metadata. */ - struct nss_ipsec_cmn_mdata_decap decap; /**< Decapsulation metadata. */ - } data; /**< Metadata payload. */ -}; - -/** - * 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. - */ -struct nss_ipsec_cmn_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of IPsec interface message. - */ - union { - struct nss_ipsec_cmn_node node; /**< Node configuration message. */ - struct nss_ipsec_cmn_ctx ctx; /**< Context configuration message. */ - struct nss_ipsec_cmn_sa sa; /**< SA configuration message. */ - struct nss_ipsec_cmn_flow flow; /**< Flow configuration message. */ - struct nss_ipsec_cmn_sa_sync sa_sync; /**< SA statistics message. */ - struct nss_ipsec_cmn_ctx_sync ctx_sync; /**< Context statistics message. */ - } msg; /**< Message payload. */ -}; - -/** - * nss_ipsec_cmn_mdata_init - * Initialize the metadata common fields. - * - * @datatypes - * nss_ipsec_cmn_mdata - * - * @param[in] mdata Metadata pointer. - * @param[in] len Metadata length including extra bytes. - * - * @return - * Pointer to metadata payload. - */ -static inline void *nss_ipsec_cmn_mdata_init(struct nss_ipsec_cmn_mdata *mdata, uint16_t len) -{ - mdata->cm.len = len; - mdata->cm.magic = NSS_IPSEC_CMN_MDATA_MAGIC; - mdata->cm.version = NSS_IPSEC_CMN_MDATA_VERSION; - mdata->cm.origin = NSS_IPSEC_CMN_MDATA_ORIGIN_HOST; - - return &mdata->data; -} - -/** - * Callback function for receiving message notifications. - * - * @datatypes - * nss_ipsec_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_ipsec_cmn_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * Callback function for receiving 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 message data. - * @param[in] napi Pointer to the NAPI structure. - */ -typedef void (*nss_ipsec_cmn_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_ipsec_cmn_get_context - * Gets the NSS context for the IPsec handle. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_ipsec_cmn_get_context(void); - -/** - * nss_ipsec_cmn_get_ifnum_with_coreid - * Gets the IPsec interface number with a core ID. - * - * @param[in] ifnum NSS interface number. - * - * @return - * Interface number with the core ID. - */ -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. - * - * @datatypes - * nss_ipsec_cmn_data_callback_t \n - * nss_ipsec_cmn_msg_callback_t \n - * nss_dynamic_interface_type \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] netdev Pointer to the associated network device. - * @param[in] cb_data Callback for the data. - * @param[in] cb_msg Callback for the message. - * @param[in] features Socket buffer types supported by this interface. - * @param[in] type Dynamic interface type. - * @param[in] app_data Application context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_ipsec_cmn_register_if(uint32_t if_num, struct net_device *netdev, - nss_ipsec_cmn_data_callback_t cb_data, - nss_ipsec_cmn_msg_callback_t cb_msg, - 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. - * - * @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_notify_register - * Registers an event callback to handle notifications from the IPsec firmware package. - * - * @datatypes - * nss_ipsec_cmn_msg_callback_t \n - * - * @param[in] ifnum NSS interface number. - * @param[in] cb Callback for IPsec message. - * @param[in] app_data Pointer to the application context. - * - * @return - * Pointer to the 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_msg_init - * Initializes an IPsec message. - * - * @datatypes - * nss_ipsec_cmn_msg \n - * nss_ipsec_cmn_msg_type \n - * nss_ipsec_cmn_msg_callback_t - * - * @param[in,out] nim 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_ipsec_cmn_msg_init(struct nss_ipsec_cmn_msg *nim, uint16_t if_num, enum nss_ipsec_cmn_msg_type type, - uint16_t len, nss_ipsec_cmn_msg_callback_t cb, void *app_data); - -/** - * nss_ipsec_cmn_tx_msg - * Sends an asynchronous IPsec message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_ipsec_cmn_msg - * - * @param[in] nss_ctx Pointer to the NSS HLOS driver context. - * @param[in] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_ipsec_cmn_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_ipsec_cmn_msg *msg); - -/** - * nss_ipsec_cmn_tx_msg_sync - * Sends a synchronous IPsec message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_ipsec_cmn_msg_type \n - * nss_ipsec_cmn_msg - * - * @param[in] nss_ctx Pointer to the NSS HLOS driver context. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] nicm Pointer to the NSS IPsec message. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_ipsec_cmn_tx_msg_sync(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - enum nss_ipsec_cmn_msg_type type, uint16_t len, - struct nss_ipsec_cmn_msg *nicm); - -/** - * nss_ipsec_cmn_tx_buf - * Sends a buffer to NSS for IPsec encapsulation or de-capsulation. - * - * @datatypes - * sk_buff \n - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS HLOS driver context. - * @param[in] skb Pointer to the message data. - * @param[in] if_num Pointer to the NSS interface number. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_ipsec_cmn_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *skb, uint32_t if_num); - -/** - * nss_ipsec_cmn_ppe_port_config - * Configure Packet Processing Engine IPsec port. - * - * @datatypes - * nss_ctx_instance \n - * net_device - * - * @param[in] ctx Pointer to the context of the HLOS driver. - * @param[in] netdev Pointer to the associated network device. - * @param[in] if_num Data interface number. - * @param[in] vsi_num Virtual switch instance number. - * - * @return - * True if successful, else false. - */ -extern bool nss_ipsec_cmn_ppe_port_config(struct nss_ctx_instance *ctx, struct net_device *netdev, - uint32_t if_num, uint32_t vsi_num); - -/** - * nss_ipsec_cmn_ppe_mtu_update() - * Configure Packet Processing Engine MTU for IPsec inline. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] ctx Pointer to the context of the HLOS driver. - * @param[in] if_num Data interface number. - * @param[in] mtu Maximum transmission unit of interface number. - * @param[in] mru Maximum receive unit of interface number. - * - * @return - * True if successful, else false. - */ -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); - -/** - * @} - */ - -#endif /* !__NSS_IPSEC_CMN_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipsecmgr.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipsecmgr.h deleted file mode 100644 index 3fe3460f9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipsecmgr.h +++ /dev/null @@ -1,443 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2014-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_ipsecmgr.h - * NSS IPSec Manager interface definitions. - */ - -#ifndef __NSS_IPSECMGR_H -#define __NSS_IPSECMGR_H - -/** - * @addtogroup nss_ipsec_subsystem - * @{ - */ - -#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. */ -#define NSS_IPSECMGR_DEBUG_LVL_INFO 3 /**< Turn on debug for information. */ -#define NSS_IPSECMGR_DEBUG_LVL_TRACE 4 /**< Turn on debug for trace. */ - -#define NSS_IPSECMGR_TUN_NAME "ipsectun%d" - /**< IPsec tunnel name. */ -#define NSS_IPSECMGR_MAX_TUNNELS (NSS_CRYPTO_MAX_IDXS/2) - /**< Maximum number of IPsec tunnels. */ - -/** - * Length of the header added after encapsulation. - * - * This estimate must be accurate but large enough to accomodate most use cases. - */ -#define NSS_IPSECMGR_TUN_MAX_HDR_LEN 96 - -/* - * Space required in the head and tail of the buffer - */ -#define NSS_IPSECMGR_TUN_HEADROOM 128 /**< Size of the buffer headroom. */ -#define NSS_IPSECMGR_TUN_TAILROOM 192 /**< Size of the buffer tailroom. */ - -#define NSS_IPSECMGR_TUN_MTU(x) (x - NSS_IPSECMGR_TUN_MAX_HDR_LEN) - /**< MTU of the IPsec tunnel. */ - -#define NSS_IPSECMGR_NATT_PORT_DATA 4500 /**< Number of the NATT port. */ - -#define NSS_IPSECMGR_MIN_REPLAY_WIN 32 /**< Minimum size of the replay window. */ -#define NSS_IPSECMGR_MAX_REPLAY_WIN 1024 /**< Maximum size of the replay window. */ -#define NSS_IPSECMGR_MAX_ICV_LEN 32 /**< Maximum size of the ICV. */ -#define NSS_IPSECMGR_MAX_DSCP 63 /**< Maximum size of the descriptor. */ - -/** - * nss_ipsecmgr_flow_type - * Flow types for the IPsec manager. - */ -enum nss_ipsecmgr_flow_type { - NSS_IPSECMGR_FLOW_TYPE_NONE = 0, - NSS_IPSECMGR_FLOW_TYPE_V4_TUPLE = 1, - NSS_IPSECMGR_FLOW_TYPE_V6_TUPLE = 2, - NSS_IPSECMGR_FLOW_TYPE_V4_SUBNET = 3, - NSS_IPSECMGR_FLOW_TYPE_V6_SUBNET = 4, - NSS_IPSECMGR_FLOW_TYPE_MAX -}; - -/** - * nss_ipsecmgr_sa_type - * Security association types for the IPsec manager. - */ -enum nss_ipsecmgr_sa_type { - NSS_IPSECMGR_SA_TYPE_NONE = 0, - NSS_IPSECMGR_SA_TYPE_V4 = 1, - NSS_IPSECMGR_SA_TYPE_V6 = 2, - NSS_IPSECMGR_SA_TYPE_MAX -}; - -/** - * nss_ipsecmgr_event_type - * Event types for the IPsec manager. - */ -enum nss_ipsecmgr_event_type { - NSS_IPSECMGR_EVENT_NONE = 0, - NSS_IPSECMGR_EVENT_SA_STATS, - NSS_IPSECMGR_EVENT_MAX -}; - -/** - * nss_ipsecmgr_sa_v4 - * IPv4 security associations for the IPsec manager. - */ -struct nss_ipsecmgr_sa_v4 { - uint32_t src_ip; /**< IPv4 source IP. */ - uint32_t dst_ip; /**< IPv4 destination IP. */ - uint32_t ttl; /**< IPv4 time-to-live. */ - uint32_t spi_index; /**< ESP SPI index. */ -}; - -/** - * nss_ipsecmgr_sa_v6 - * IPv6 security associations for the IPsec manager. - */ -struct nss_ipsecmgr_sa_v6 { - uint32_t src_ip[4]; /**< IPv6 source IP. */ - uint32_t dst_ip[4]; /**< IPv6 destination IP. */ - uint32_t hop_limit; /**< IPv6 hop limit. */ - uint32_t spi_index; /**< SPI index of the encapsulating security payload (ESP). */ -}; - -/** - * nss_ipsecmgr_sa_data - * Security association data for the IPsec manager. - * - * For DSCP marking, use the following settings: - * - Copy inner header to outer header: - * - dscp_copy = 1 - * - dscp = 0 - * - Fixed mark on outer header: - * - dscp_copy = 0 - * - dscp = <0 to 63> - */ -struct nss_ipsecmgr_sa_data { - uint32_t crypto_index; /**< Crypto session index returned by the driver. */ - - /** - * Security association data for the IPsec manager. - */ - struct { - uint16_t replay_win; - /**< Sequence number window size for anti-replay. */ - uint8_t icv_len; - /**< Hash length. */ - uint8_t dscp; - /**< Default DSCP value of the security association. */ - - bool dscp_copy; - /**< Copy DSCP from the inner header to the outer header. */ - bool nat_t_req; - /**< NAT-T is required. */ - bool seq_skip; - /**< Skip the ESP sequence for encapsulation. */ - bool trailer_skip; - /**< Skip the ESP trailer for encapsulation. */ - bool df_copy; - /**< Copy DF from the inner header to the outer header. */ - uint8_t df; - /**< DF value for the outer header, if nocopy is selected. */ - } esp; /**< Payload of security association data. */ - - bool enable_esn; /**< Enable the extended sequence number. */ - bool use_pattern; /**< Use a random pattern in a hash calculation. */ - uint32_t fail_hash_thresh; /**< Threshold for consecutive hash failure. */ -}; - -/** - * nss_ipsecmgr_encap_v4_tuple - * IPv4 encapsulation flow tuple for the IPsec manager. - */ -struct nss_ipsecmgr_encap_v4_tuple { - uint32_t src_ip; /**< Source IP. */ - uint32_t dst_ip; /**< Destination IP. */ - uint32_t protocol; /**< Protocol. */ -}; - -/** - * nss_ipsecmgr_encap_v6_tuple - * IPv6 encapsulation flow tuple for the IPsec manager. - */ -struct nss_ipsecmgr_encap_v6_tuple { - uint32_t src_ip[4]; /**< Source IP. */ - uint32_t dst_ip[4]; /**< Destination IP. */ - uint32_t next_hdr; /**< Transport layer protocol. */ -}; - -/** - * nss_ipsecmgr_encap_v4_subnet - * IPv4 encapsulation flow subnet for the IPsec manager. - */ -struct nss_ipsecmgr_encap_v4_subnet { - uint32_t dst_subnet; /**< Destination subnet. */ - uint32_t dst_mask; /**< Destination subnet mask. */ - uint32_t protocol; /**< IPv4 or IPv6 protocol. */ -}; - -/** - * nss_ipsecmgr_encap_v6_subnet - * IPv6 encapsulation flow subnet for the IPsec manager. - * - * Store least significant word in dst_subnet[0] and the most significant word - * in dst_subnet[3]. - */ -struct nss_ipsecmgr_encap_v6_subnet { - uint32_t dst_subnet[4]; /**< Destination subnet. */ - uint32_t dst_mask[4]; /**< Destination subnet mask. */ - uint32_t next_hdr; /**< Transport layer protocol. */ -}; - -/** - * nss_ipsecmgr_sa - * Security association information for the IPsec manager. - */ -struct nss_ipsecmgr_sa { - enum nss_ipsecmgr_sa_type type; /**< Security association type. */ - - /** - * IPsec manager security association data. - */ - union { - struct nss_ipsecmgr_sa_v4 v4; /**< IPv4 security association. */ - struct nss_ipsecmgr_sa_v6 v6; /**< IPv6 security association. */ - } data; /**< IPsec manager security association data. */ -}; - -/** - * nss_ipsecmgr_sa_stats - * Security association statistics exported by the IPsec manager. - */ -struct nss_ipsecmgr_sa_stats { - struct nss_ipsecmgr_sa sa; /**< Security association information. */ - uint32_t crypto_index; /**< Crypto session index. */ - - /** - * Security association statistics used by the IPsec manager. - */ - struct { - uint32_t bytes; /**< Number of bytes processed. */ - uint32_t count; /**< Number of packets processed. */ - } pkts; /**< Processing statistics. */ - - uint64_t seq_num; /**< Current sequence number. */ - uint64_t window_max; /**< Maximum size of the window. */ - uint32_t window_size; /**< Current size of the window. */ - - bool fail_hash_alarm; - /**< Alarm for consecutive hash fail. */ - bool esn_enabled; - /**< Specifies whether ESN is enabled. */ -}; - -/** - * nss_ipsecmgr_event - * Event information for the IPsec manager. - */ -struct nss_ipsecmgr_event { - enum nss_ipsecmgr_event_type type; /**< Event type. */ - - /** - * Event information statistics for the IPsec manager. - */ - union { - struct nss_ipsecmgr_sa_stats stats; - /**< Security association statistics. */ - } data; /**< Event information. */ -}; - -/** - * nss_ipsecmgr_encap_flow - * Encapsulation flow information for the IPsec manager. - */ -struct nss_ipsecmgr_encap_flow { - enum nss_ipsecmgr_flow_type type; /**< Flow type. */ - - /** - * Payload of encapsulation flow data for the IPsec manager. - */ - union { - struct nss_ipsecmgr_encap_v4_tuple v4_tuple; - /**< IPv4 tuple. */ - struct nss_ipsecmgr_encap_v4_subnet v4_subnet; - /**< IPv4 subnet. */ - struct nss_ipsecmgr_encap_v6_tuple v6_tuple; - /**< IPv6 tuple. */ - struct nss_ipsecmgr_encap_v6_subnet v6_subnet; - /**< IPv6 subnet. */ - } data; /**< Encapsulation flow information. */ -}; - -#ifdef __KERNEL__ /* only kernel will use. */ - -/** - * Callback function for receiving IPsec data. - * - * @datatypes - * sk_buff - * - * @param[in] ctx Pointer to the context of the data. - * @param[in] skb Pointer to the data socket buffer. - */ -typedef void (*nss_ipsecmgr_data_cb_t) (void *ctx, struct sk_buff *skb); - -/** - * Callback function for receiving IPsec events. - * - * @datatypes - * nss_ipsecmgr_event - * - * @param[in] ctx Pointer to the context of the event. - * @param[in] ev Pointer to the event. - */ -typedef void (*nss_ipsecmgr_event_cb_t) (void *ctx, struct nss_ipsecmgr_event *ev); - -/** - * nss_ipsecmgr_callback - * Callback information. - */ -struct nss_ipsecmgr_callback { - void *ctx; /**< Context of the caller. */ - nss_ipsecmgr_data_cb_t data_fn; /**< Data callback function. */ - nss_ipsecmgr_event_cb_t event_fn; /**< Event callback function. */ -}; - -/** - * nss_ipsecmgr_tunnel_add - * Adds a new IPsec tunnel. - * - * @datatypes - * nss_ipsecmgr_callback - * - * @param[in] cb Pointer to the message callback. - * - * @return - * Linux NETDEVICE or NULL. - */ -struct net_device *nss_ipsecmgr_tunnel_add(struct nss_ipsecmgr_callback *cb); - -/** - * nss_ipsecmgr_tunnel_del - * Deletes an existing IPsec tunnel. - * - * @datatypes - * net_device - * - * @param[in] tun Pointer to the network device associated with the tunnel. - * - * @return - * Success or failure. - */ -bool nss_ipsecmgr_tunnel_del(struct net_device *tun); - -/** - * nss_ipsecmgr_tunnel_update_callback - * Updates the binding of netdevice and callback. - * - * @datatypes - * net_device - * - * @param[in] tun Pointer to IPsec tunnel. - * @param[in] cur Pointer to Linux netdevice. - * - * @return - * None. - */ -void nss_ipsecmgr_tunnel_update_callback(struct net_device *tun, struct net_device *cur); - -/** - * nss_ipsecmgr_encap_add - * Adds an encapsulation flow rule to the IPsec offload database. - * - * @datatypes - * net_device \n - * nss_ipsecmgr_encap_flow \n - * nss_ipsecmgr_sa \n - * nss_ipsecmgr_sa_data - * - * @param[in] tun Pointer to the network device associated with the tunnel. - * @param[in] flow Pointer to the flow or subnet to add. - * @param[in] sa Pointer to the security association for the flow. - * @param[in] data Pointer to additional security association data. - * - * @return - * Success or failure. - */ -bool nss_ipsecmgr_encap_add(struct net_device *tun, struct nss_ipsecmgr_encap_flow *flow, struct nss_ipsecmgr_sa *sa, - struct nss_ipsecmgr_sa_data *data); - -/** - * nss_ipsecmgr_encap_del - * Deletes an encapsulation flow rule from the IPsec offload database. - * - * @datatypes - * net_device \n - * nss_ipsecmgr_encap_flow \n - * nss_ipsecmgr_sa - * - * @param[in] tun Pointer to the network device associated with the tunnel. - * @param[in] flow Pointer to the flow or subnet to delete. - * @param[in] sa Pointer to the security association for the flow. - * - * @return - * Success or failure. - */ -bool nss_ipsecmgr_encap_del(struct net_device *tun, struct nss_ipsecmgr_encap_flow *flow, struct nss_ipsecmgr_sa *sa); - -/** - * nss_ipsecmgr_decap_add - * Adds a decapsulation security association to the offload database. - * - * @datatypes - * net_device \n - * nss_ipsecmgr_sa \n - * nss_ipsenss_ipsecmgr_sa_datacmgr_sa - * - * @param[in] tun Pointer to the network device associated with the tunnel. - * @param[in] sa Pointer to the security association for the decapsulation. - * @param[in] data Pointer to additional security association data. - * - * @return - * Success or failure. - */ -bool nss_ipsecmgr_decap_add(struct net_device *tun, struct nss_ipsecmgr_sa *sa, struct nss_ipsecmgr_sa_data *data); - -/** - * nss_ipsecmgr_sa_flush - * Flushes the security association and all associated flows and subnets. - * - * @datatypes - * net_device \n - * nss_ipsecmgr_sa - * - * @param[in] tun Pointer to the network device associated with the tunnel. - * @param[in] sa Pointer to the security association to flush. - * - * @return - * Success or failure. - */ -bool nss_ipsecmgr_sa_flush(struct net_device *tun, struct nss_ipsecmgr_sa *sa); - -#endif /* __KERNEL__ */ - -/** - * @} - */ - -#endif /* __NSS_IPSECMGR_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipv4.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipv4.h deleted file mode 100644 index ee3a552eb..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipv4.h +++ /dev/null @@ -1,1310 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipv4.h - * NSS IPv4 interface definitions. - */ - -#ifndef __NSS_IPV4_H -#define __NSS_IPV4_H - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -#include "nss_stats_public.h" -#endif - -/** - * @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 (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. */ -}; - -/** - * 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. - * - * NSS_IPV4_RX_DEPRECATED0 is a deprecated type. It is kept for backward compatibility. - */ -enum nss_ipv4_message_types { - NSS_IPV4_TX_CREATE_RULE_MSG, - NSS_IPV4_TX_DESTROY_RULE_MSG, - NSS_IPV4_RX_DEPRECATED0, - NSS_IPV4_RX_CONN_STATS_SYNC_MSG, - NSS_IPV4_RX_NODE_STATS_SYNC_MSG, - NSS_IPV4_TX_CONN_CFG_RULE_MSG, - NSS_IPV4_TX_CREATE_MC_RULE_MSG, - NSS_IPV4_TX_CONN_STATS_SYNC_MANY_MSG, - NSS_IPV4_TX_ACCEL_MODE_CFG_MSG, - NSS_IPV4_TX_CONN_CFG_INQUIRY_MSG, - NSS_IPV4_TX_CONN_TABLE_SIZE_MSG, - NSS_IPV4_TX_DSCP2PRI_CFG_MSG, - NSS_IPV4_TX_RPS_HASH_BITMAP_CFG_MSG, - NSS_IPV4_MAX_MSG_TYPES, -}; - -/** - * nss_ipv4_dscp_map_actions - * Action types mapped to DSCP values. - */ -enum nss_ipv4_dscp_map_actions { - NSS_IPV4_DSCP_MAP_ACTION_ACCEL, - NSS_IPV4_DSCP_MAP_ACTION_DONT_ACCEL, - NSS_IPV4_DSCP_MAP_ACTION_MAX, -}; - -/** - * nss_ipv4_stats_types - * IPv4 node statistics. - */ -enum nss_ipv4_stats_types { - NSS_IPV4_STATS_ACCELERATED_RX_PKTS = 0, - /**< Accelerated IPv4 Rx packets. */ - NSS_IPV4_STATS_ACCELERATED_RX_BYTES, - /**< Accelerated IPv4 Rx bytes. */ - NSS_IPV4_STATS_ACCELERATED_TX_PKTS, - /**< Accelerated IPv4 Tx packets. */ - NSS_IPV4_STATS_ACCELERATED_TX_BYTES, - /**< Accelerated IPv4 Tx bytes. */ - NSS_IPV4_STATS_CONNECTION_CREATE_REQUESTS, - /**< Number of IPv4 connection create requests. */ - NSS_IPV4_STATS_CONNECTION_CREATE_COLLISIONS, - /**< Number of IPv4 connection create requests that collided with existing entries. */ - NSS_IPV4_STATS_CONNECTION_CREATE_INVALID_INTERFACE, - /**< Number of IPv4 connection create requests that had invalid interface. */ - NSS_IPV4_STATS_CONNECTION_DESTROY_REQUESTS, - /**< Number of IPv4 connection destroy requests. */ - NSS_IPV4_STATS_CONNECTION_DESTROY_MISSES, - /**< Number of IPv4 connection destroy requests that missed the cache. */ - NSS_IPV4_STATS_CONNECTION_HASH_HITS, - /**< Number of IPv4 connection hash hits. */ - NSS_IPV4_STATS_CONNECTION_HASH_REORDERS, - /**< Number of IPv4 connection hash reorders. */ - NSS_IPV4_STATS_CONNECTION_FLUSHES, - /**< Number of IPv4 connection flushes. */ - NSS_IPV4_STATS_CONNECTION_EVICTIONS, - /**< Number of IPv4 connection evictions. */ - NSS_IPV4_STATS_FRAGMENTATIONS, - /**< Number of successful IPv4 fragmentations performed. */ - NSS_IPV4_STATS_DROPPED_BY_RULE, - /**< Number of IPv4 packets dropped because of a drop rule.*/ - NSS_IPV4_STATS_MC_CONNECTION_CREATE_REQUESTS, - /**< Number of successful IPv4 multicast create requests. */ - NSS_IPV4_STATS_MC_CONNECTION_UPDATE_REQUESTS, - /**< Number of successful IPv4 multicast update requests. */ - NSS_IPV4_STATS_MC_CONNECTION_CREATE_INVALID_INTERFACE, - /**< Number of IPv4 multicast connection create requests that had invalid interface. */ - NSS_IPV4_STATS_MC_CONNECTION_DESTROY_REQUESTS, - /**< Number of IPv4 multicast connection destroy requests. */ - NSS_IPV4_STATS_MC_CONNECTION_DESTROY_MISSES, - /**< 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. */ -}; - -/* - * NSS IPv4 rule creation & rule update flags. - */ -#define NSS_IPV4_RULE_CREATE_FLAG_NO_SEQ_CHECK 0x01 - /**< Do not perform TCP sequence number checks. */ -#define NSS_IPV4_RULE_CREATE_FLAG_BRIDGE_FLOW 0x02 - /**< Pure bridge forwarding flow. */ -#define NSS_IPV4_RULE_CREATE_FLAG_ROUTED 0x04 - /**< Rule for a routed connection. */ -#define NSS_IPV4_RULE_CREATE_FLAG_DSCP_MARKING 0x08 - /**< Rule for configuring DSCP marking. */ -#define NSS_IPV4_RULE_CREATE_FLAG_VLAN_MARKING 0x10 - /**< Rule for configuring VLAN marking. */ -#define NSS_IPV4_RULE_UPDATE_FLAG_CHANGE_MTU 0x20 - /**< Update MTU of the connection interfaces. */ -#define NSS_IPV4_RULE_CREATE_FLAG_ICMP_NO_CME_FLUSH 0x40 - /**< Rule for not flushing connection match entry on an ICMP packet. */ - -/** - * L2 payload is not IPv4, but it consists of an encapsulating protocol that - * 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. - */ -#define NSS_IPV4_RULE_CREATE_CONN_VALID 0x01 /**< Connection is valid. */ -#define NSS_IPV4_RULE_CREATE_TCP_VALID 0x02 /**< TCP protocol fields are valid. */ -#define NSS_IPV4_RULE_CREATE_PPPOE_VALID 0x04 /**< PPPoE fields are valid. */ -#define NSS_IPV4_RULE_CREATE_QOS_VALID 0x08 /**< QoS fields are valid. */ -#define NSS_IPV4_RULE_CREATE_VLAN_VALID 0x10 /**< VLAN fields are valid. */ -#define NSS_IPV4_RULE_CREATE_DSCP_MARKING_VALID 0x20 - /**< DSCP marking fields are valid. */ -#define NSS_IPV4_RULE_CREATE_VLAN_MARKING_VALID 0x40 - /**< VLAN marking fields are valid. */ -#define NSS_IPV4_RULE_CREATE_SRC_MAC_VALID 0x80 - /**< Source MAC address fields are valid. */ -#define NSS_IPV4_RULE_CREATE_NEXTHOP_VALID 0x100 - /**< Next hop interface number fields are valid. */ -#define NSS_IPV4_RULE_CREATE_RPS_VALID 0x200 - /**< RPS for core selection is valid. */ -#define NSS_IPV4_RULE_CREATE_DEST_MAC_VALID 0x400 - /**< 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 - */ -#define NSS_IPV4_MC_RULE_CREATE_FLAG_QOS_VALID 0x01 - /**< QoS fields are valid. */ -#define NSS_IPV4_MC_RULE_CREATE_FLAG_DSCP_MARKING_VALID 0x02 - /**< DSCP fields are valid. */ -#define NSS_IPV4_MC_RULE_CREATE_FLAG_INGRESS_VLAN_VALID 0x04 - /**< Ingress VLAN fields are valid. */ -#define NSS_IPV4_MC_RULE_CREATE_FLAG_INGRESS_PPPOE 0x08 - /**< Ingress PPPoE fields are valid. */ -#define NSS_IPV4_MC_RULE_CREATE_FLAG_IGS_VALID 0x10 - /**< Ingress shaping fields are valid. */ - -/* - * Per-interface rule flags for a multicast connection (to be used with the rule_flags - * field of nss_ipv4_mc_if_rule structure). - */ -#define NSS_IPV4_MC_RULE_CREATE_IF_FLAG_BRIDGE_FLOW 0x01 - /**< Multicast connection rule is created for a bridge flow. */ -#define NSS_IPV4_MC_RULE_CREATE_IF_FLAG_ROUTED_FLOW 0x02 - /**< Multicast connection rule is created for a routed flow. */ -#define NSS_IPV4_MC_RULE_CREATE_IF_FLAG_JOIN 0x04 - /**< Interface has joined the flow. */ -#define NSS_IPV4_MC_RULE_CREATE_IF_FLAG_LEAVE 0x08 - /**< Interface has left the flow. */ - -/* - * Per-interface valid flags for a multicast connection (to be used with the valid_flags - * field of nss_ipv4_mc_if_rule structure). - */ -#define NSS_IPV4_MC_RULE_CREATE_IF_FLAG_VLAN_VALID 0x01 - /**< VLAN fields are valid. */ -#define NSS_IPV4_MC_RULE_CREATE_IF_FLAG_PPPOE_VALID 0x02 - /**< PPPoE fields are valid. */ -#define NSS_IPV4_MC_RULE_CREATE_IF_FLAG_NAT_VALID 0x4 - /**< Interface is configured with the source NAT. */ - -/* - * Source MAC address valid flags (to be used with mac_valid_flags field of nss_ipv4_src_mac_rule structure) - */ -#define NSS_IPV4_SRC_MAC_FLOW_VALID 0x01 - /**< MAC address for the flow interface is valid. */ -#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. - */ -struct nss_ipv4_5tuple { - uint32_t flow_ip; /**< Flow IP address. */ - uint32_t flow_ident; /**< Flow identifier (e.g., TCP or UDP port). */ - uint32_t return_ip; /**< Return IP address. */ - uint32_t return_ident; /**< Return identier (e.g., TCP or UDP port). */ - uint8_t protocol; /**< Protocol number. */ - uint8_t reserved[3]; /**< Padded for alignment. */ -}; - -/** - * nss_ipv4_connection_rule - * Information for creating a connection. - */ -struct nss_ipv4_connection_rule { - uint16_t flow_mac[3]; /**< Flow MAC address. */ - uint16_t return_mac[3]; /**< Return MAC address. */ - int32_t flow_interface_num; /**< Flow interface number. */ - int32_t return_interface_num; /**< Return interface number. */ - uint32_t flow_mtu; /**< MTU for the flow interface. */ - uint32_t return_mtu; /**< MTU for the return interface. */ - uint32_t flow_ip_xlate; /**< Translated flow IP address. */ - uint32_t return_ip_xlate; /**< Translated return IP address. */ - uint32_t flow_ident_xlate; /**< Translated flow identifier (e.g., port). */ - uint32_t return_ident_xlate; /**< Translated return identifier (e.g., port). */ -}; - -/** - * nss_ipv4_pppoe_rule - * Information for PPPoE connection rules. - */ -struct nss_ipv4_pppoe_rule { - uint32_t flow_if_exist; - /**< PPPoE interface existence flag for the flow direction. */ - int32_t flow_if_num; - /**< PPPoE interface number for the flow direction. */ - uint32_t return_if_exist; - /**< PPPoE interface existence flag for the return direction. */ - int32_t return_if_num; - /**< PPPoE interface number for the return direction. */ -}; - -/** - * nss_ipv4_dscp_rule - * Information for DSCP connection rules. - */ -struct nss_ipv4_dscp_rule { - uint8_t flow_dscp; /**< Egress DSCP value for the flow direction. */ - uint8_t return_dscp; /**< Egress DSCP value for the return direction. */ - uint8_t reserved[2]; /**< Padded for alignment. */ -}; - -/** - * nss_ipv4_vlan_rule - * Information for VLAN connection rules. - */ -struct nss_ipv4_vlan_rule { - uint32_t ingress_vlan_tag; /**< VLAN tag for the ingress packets. */ - uint32_t egress_vlan_tag; /**< VLAN tag for egress packets. */ -}; - -/** - * nss_ipv4_nexthop - * Information for next hop interface numbers. - * - * A next hop is the next interface that will receive the packet (as opposed to - * the final interface when the packet leaves the device. - */ -struct nss_ipv4_nexthop { - /** - * Next hop interface number of the flow direction (from which the connection - * originated). - */ - int32_t flow_nexthop; - /** - * Next hop interface number of the return direction (to which the connection - * is destined). - */ - int32_t return_nexthop; -}; - -/** - * nss_ipv4_protocol_tcp_rule - * Information for TCP connection rules. - */ -struct nss_ipv4_protocol_tcp_rule { - uint32_t flow_max_window; - /**< Largest seen window for the flow direction. */ - uint32_t return_max_window; - /**< Largest seen window for the return direction. */ - - /** - * Largest seen sequence + segment length for the flow direction. - */ - uint32_t flow_end; - - /** - * Largest seen sequence + segment length for the return direction. - */ - uint32_t return_end; - - uint32_t flow_max_end; - /**< Largest seen ack + max(1, win) for the flow direction. */ - uint32_t return_max_end; - /**< Largest seen ack + max(1, win) for the return direction. */ - uint8_t flow_window_scale; - /**< Window scaling factor for the flow direction. */ - uint8_t return_window_scale; - /**< Window scaling factor for the return direction. */ - uint16_t reserved; /**< Alignment padding. */ -}; - -/** - * nss_ipv4_igs_rule - * Information for ingress shaping connection rules. - */ -struct nss_ipv4_igs_rule { - uint16_t igs_flow_qos_tag; - /**< Ingress shaping QoS tag associated with this rule for the flow direction. */ - uint16_t igs_return_qos_tag; - /**< Ingress shaping QoS tag associated with this rule for the return direction. */ -}; - -/** - * nss_ipv4_qos_rule - * Information for QoS connection rules. - */ -struct nss_ipv4_qos_rule { - uint32_t flow_qos_tag; - /**< QoS tag associated with this rule for the flow direction. */ - uint32_t return_qos_tag; - /**< QoS tag associated with this rule for the return direction. */ -}; - -/** - * nss_ipv4_src_mac_rule - * Information for source MAC address rules. - */ -struct nss_ipv4_src_mac_rule { - uint32_t mac_valid_flags; /**< MAC address validity flags. */ - uint16_t flow_src_mac[3]; /**< Source MAC address for the flow direction. */ - uint16_t return_src_mac[3]; /**< Source MAC address for the return direction. */ -}; - -/** - * nss_ipv4_rps_rule - * RPS rule structure. - */ -struct nss_ipv4_rps_rule { - uint8_t flow_rps; - /**< RPS for core selection for flow direction. */ - uint8_t return_rps; - /**< RPS for core selection for return direction. */ - uint8_t reserved[2]; - /**< Padded for alignment. */ -}; - -/** - * 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. - */ -enum nss_ipv4_error_response_types { - NSS_IPV4_UNKNOWN_MSG_TYPE = 1, - NSS_IPV4_CR_INVALID_PNODE_ERROR, - NSS_IPV4_CR_MISSING_CONNECTION_RULE_ERROR, - NSS_IPV4_CR_BUFFER_ALLOC_FAIL_ERROR, - NSS_IPV4_DR_NO_CONNECTION_ENTRY_ERROR, - NSS_IPV4_CR_CONN_CFG_ALREADY_CONFIGURED_ERROR, - NSS_IPV4_CR_CONN_CFG_NOT_MULTIPLE_OF_QUANTA_ERROR, - NSS_IPV4_CR_CONN_CFG_EXCEEDS_LIMIT_ERROR, - NSS_IPV4_CR_CONN_CFG_MEM_ALLOC_FAIL_ERROR, - NSS_IPV4_CR_MULTICAST_INVALID_PROTOCOL, - NSS_IPV4_CR_MULTICAST_UPDATE_INVALID_FLAGS, - NSS_IPV4_CR_MULTICAST_UPDATE_INVALID_IF, - NSS_IPV4_CR_ACCEL_MODE_CONFIG_INVALID, - NSS_IPV4_CR_INVALID_MSG_ERROR, - NSS_IPV4_CR_DSCP2PRI_PRI_INVALID, - NSS_IPV4_CR_DSCP2PRI_CONFIG_INVALID, - NSS_IPV4_CR_INVALID_RPS, - 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 -}; - -/** - * nss_ipv4_rule_create_msg - * IPv4 rule for creating sub-messages. - */ -struct nss_ipv4_rule_create_msg { - /* - * Request - */ - uint16_t valid_flags; - /**< Bit flags associated with the validity of parameters. */ - uint16_t rule_flags; - /**< Bit flags associated with the rule. */ - struct nss_ipv4_5tuple tuple; - /**< Holds values of the 5 tuple. */ - struct nss_ipv4_connection_rule conn_rule; - /**< Basic connection-specific data. */ - struct nss_ipv4_protocol_tcp_rule tcp_rule; - /**< TCP-related accleration parameters. */ - struct nss_ipv4_pppoe_rule pppoe_rule; - /**< PPPoE-related accleration parameters. */ - struct nss_ipv4_qos_rule qos_rule; - /**< QoS-related accleration parameters. */ - struct nss_ipv4_dscp_rule dscp_rule; - /**< DSCP-related accleration parameters. */ - struct nss_ipv4_vlan_rule vlan_primary_rule; - /**< Primary VLAN-related accleration parameters. */ - struct nss_ipv4_vlan_rule vlan_secondary_rule; - /**< Secondary VLAN-related accleration parameters. */ - struct nss_ipv4_src_mac_rule src_mac_rule; - /**< Source MAC address-related acceleration parameters. */ - struct nss_ipv4_nexthop nexthop_rule; - /**< Parameters related to the next hop. */ - struct nss_ipv4_rps_rule rps_rule; - /**< 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. */ -}; - -/** - * nss_ipv4_inquiry_msg - * IPv4 connection inquiry naming structure. - */ -struct nss_ipv4_inquiry_msg { - /** - * Request by its 5-tuple and get response for other items. - */ - struct nss_ipv4_rule_create_msg rr; -}; - -/** - * nss_ipv4_mc_if_rule - * IPv4 multicast rule for creating per-interface information. - */ -struct nss_ipv4_mc_if_rule { - uint16_t rule_flags; /**< Bit flags associated with the rule. */ - uint16_t valid_flags; - /**< Bit flags associated with the validity of parameters. */ - uint32_t xlate_src_ip; /**< Translated flow IP address. */ - uint32_t xlate_src_ident; /**< Translated flow identifier (e.g., port). */ - uint32_t egress_vlan_tag[MAX_VLAN_DEPTH]; - /**< VLAN tag stack for the egress packets. */ - int32_t pppoe_if_num; /**< PPPoE interface number. */ - uint32_t if_num; /**< Interface number. */ - uint32_t if_mtu; /**< Interface MTU. */ - uint16_t if_mac[3]; /**< Interface MAC address. */ - uint8_t reserved[2]; /**< Reserved 2 bytes for alignment. */ -}; - -/** - * nss_ipv4_mc_rule_create_msg - * IPv4 multicast rule for creating sub-messages. - */ -struct nss_ipv4_mc_rule_create_msg { - struct nss_ipv4_5tuple tuple; /**< Holds values of the 5 tuple. */ - - uint32_t rule_flags; /**< Multicast command rule flags. */ - uint32_t valid_flags; /**< Multicast command validity flags. */ - uint32_t src_interface_num; - /**< Source interface number (virtual or physical). */ - uint32_t ingress_vlan_tag[MAX_VLAN_DEPTH]; - /**< VLAN tag stack for the ingress packets. */ - uint32_t qos_tag; /**< QoS tag for the rule. */ - uint16_t dest_mac[3]; /**< Destination multicast MAC address. */ - uint16_t if_count; /**< Number of destination interfaces. */ - uint8_t egress_dscp; /**< Egress DSCP value for the flow. */ - uint8_t reserved[1]; /**< Reserved 1 byte for alignment. */ - uint16_t igs_qos_tag; /**< Ingress shaping QoS tag for the rule. */ - - struct nss_ipv4_mc_if_rule if_rule[NSS_MC_IF_MAX]; - /**< Per-interface information. */ -}; - -/** - * nss_ipv4_rule_destroy_msg - * IPv4 rule for destroying sub-messages. - */ -struct nss_ipv4_rule_destroy_msg { - struct nss_ipv4_5tuple tuple; /**< Holds values of the 5 tuple. */ -}; - -/** - * nss_ipv4_rule_conn_get_table_size_msg - * IPv4 rule for fetching connection tables size. - */ -struct nss_ipv4_rule_conn_get_table_size_msg { - uint32_t num_conn; /**< Number of supported IPv4 connections. */ - uint32_t ce_table_size; /**< Size of the connection entry table in NSS firmware. */ - uint32_t cme_table_size; /**< Size of the connection match entry table in NSS firmware. */ -}; - -/** - * nss_ipv4_rule_conn_cfg_msg - * IPv4 rule for connection configuration sub-messages. - */ -struct nss_ipv4_rule_conn_cfg_msg { - uint32_t num_conn; /**< Number of supported IPv4 connections. */ - uint32_t ce_mem; /**< Memory allocated by host for connection entries table. */ - uint32_t cme_mem; /**< Memory allocated by host for connection match entries table. */ -}; - -/* - * IPv4 rule synchronization reasons. - */ -#define NSS_IPV4_RULE_SYNC_REASON_STATS 0 - /**< Rule for synchronizing statistics. */ -#define NSS_IPV4_RULE_SYNC_REASON_FLUSH 1 - /**< Rule for flushing a cache entry. */ -#define NSS_IPV4_RULE_SYNC_REASON_EVICT 2 - /**< Rule for evicting a cache entry. */ -#define NSS_IPV4_RULE_SYNC_REASON_DESTROY 3 - /**< Rule for destroying a cache entry (requested by the host OS). */ - -/** - * nss_ipv4_conn_sync - * IPv4 connection synchronization message. - */ -struct nss_ipv4_conn_sync { - uint32_t reserved; /**< Reserved field for backward compatibility. */ - uint8_t protocol; /**< Protocol number. */ - 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). */ - uint32_t flow_max_window; /**< Largest seen window for the flow direction. */ - - /** - * Largest seen sequence + segment length for the flow direction. - */ - uint32_t flow_end; - - uint32_t flow_max_end; - /**< Largest seen ack + max(1, win) for the flow direction. */ - 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_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). */ - uint32_t return_max_window; - /**< Largest seen window for the return direction. */ - - /** - * Largest seen sequence + segment length for the return direction. - */ - uint32_t return_end; - - uint32_t return_max_end; - /**< Largest seen ack + max(1, win) for the return direction. */ - uint32_t return_rx_packet_count; - /**< Rx packet count for the return interface. */ - uint32_t return_rx_byte_count; - /**< Rx byte count for the return interface. */ - uint32_t return_tx_packet_count; - /**< Tx packet count for the return interface. */ - uint32_t return_tx_byte_count; - /**< Tx byte count for the return interface. */ - uint32_t inc_ticks; /**< Number of ticks since the last synchronization. */ - uint32_t reason; /**< Reason for the synchronization. */ - - uint8_t flags; /**< Bit flags associated with the rule. */ - uint32_t qos_tag; /**< QoS tag. */ - uint32_t cause; /**< Flush cause associated with the rule. */ -}; - -/** - * nss_ipv4_conn_sync_many_msg - * Information for a multiple IPv4 connection statistics synchronization message. - */ -struct nss_ipv4_conn_sync_many_msg { - /* - * Request - */ - uint16_t index; /**< Request connection statistics from the index. */ - uint16_t size; /**< Buffer size of this message. */ - - /* - * Response - */ - uint16_t next; /**< Firmware response for the next connection to be requested. */ - uint16_t count; /**< Number of synchronized connections included in this message. */ - struct nss_ipv4_conn_sync conn_sync[]; /**< Array for the statistics. */ -}; - -/** - * nss_ipv4_accel_mode_cfg_msg - * IPv4 acceleration mode configuration. - */ -struct nss_ipv4_accel_mode_cfg_msg { - uint32_t mode; /**< Type of acceleration mode. */ -}; - -/** - * nss_ipv4_dscp2pri_cfg_msg - * IPv4 dscp2pri configuration msg. - */ -struct nss_ipv4_dscp2pri_cfg_msg { - uint8_t dscp; /**< Value of DSCP. */ - uint8_t priority; /**< Corresponding priority. */ -}; - -/** - * nss_ipv4_rps_hash_bitmap_cfg_msg - * RPS hash mask configuration. - * - * The bitmap represents the host cores to which NSS firmware can steer - * packets based on packet hash. The least significant bit represents core0. - */ -struct nss_ipv4_rps_hash_bitmap_cfg_msg { - uint32_t hash_bitmap; /**< Hash mask. */ -}; - -/** - * nss_ipv4_exception_events - * Exception events from the bridge or route handler. - */ -enum nss_ipv4_exception_events { - NSS_IPV4_EXCEPTION_EVENT_ICMP_HEADER_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_ICMP_UNHANDLED_TYPE, - NSS_IPV4_EXCEPTION_EVENT_ICMP_IPV4_HEADER_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_ICMP_IPV4_UDP_HEADER_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_ICMP_IPV4_TCP_HEADER_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_ICMP_IPV4_UNKNOWN_PROTOCOL, - NSS_IPV4_EXCEPTION_EVENT_ICMP_NO_ICME, - NSS_IPV4_EXCEPTION_EVENT_ICMP_FLUSH_TO_HOST, - NSS_IPV4_EXCEPTION_EVENT_TCP_HEADER_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_TCP_NO_ICME, - NSS_IPV4_EXCEPTION_EVENT_TCP_IP_OPTION, - NSS_IPV4_EXCEPTION_EVENT_TCP_IP_FRAGMENT, - NSS_IPV4_EXCEPTION_EVENT_TCP_SMALL_TTL, - NSS_IPV4_EXCEPTION_EVENT_TCP_NEEDS_FRAGMENTATION, - NSS_IPV4_EXCEPTION_EVENT_TCP_FLAGS, - NSS_IPV4_EXCEPTION_EVENT_TCP_SEQ_EXCEEDS_RIGHT_EDGE, - NSS_IPV4_EXCEPTION_EVENT_TCP_SMALL_DATA_OFFS, - NSS_IPV4_EXCEPTION_EVENT_TCP_BAD_SACK, - NSS_IPV4_EXCEPTION_EVENT_TCP_BIG_DATA_OFFS, - NSS_IPV4_EXCEPTION_EVENT_TCP_SEQ_BEFORE_LEFT_EDGE, - NSS_IPV4_EXCEPTION_EVENT_TCP_ACK_EXCEEDS_RIGHT_EDGE, - NSS_IPV4_EXCEPTION_EVENT_TCP_ACK_BEFORE_LEFT_EDGE, - NSS_IPV4_EXCEPTION_EVENT_UDP_HEADER_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_UDP_NO_ICME, - NSS_IPV4_EXCEPTION_EVENT_UDP_IP_OPTION, - NSS_IPV4_EXCEPTION_EVENT_UDP_IP_FRAGMENT, - NSS_IPV4_EXCEPTION_EVENT_UDP_SMALL_TTL, - NSS_IPV4_EXCEPTION_EVENT_UDP_NEEDS_FRAGMENTATION, - NSS_IPV4_EXCEPTION_EVENT_WRONG_TARGET_MAC, - NSS_IPV4_EXCEPTION_EVENT_HEADER_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_BAD_TOTAL_LENGTH, - NSS_IPV4_EXCEPTION_EVENT_BAD_CHECKSUM, - NSS_IPV4_EXCEPTION_EVENT_NON_INITIAL_FRAGMENT, - NSS_IPV4_EXCEPTION_EVENT_DATAGRAM_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_OPTIONS_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_UNKNOWN_PROTOCOL, - NSS_IPV4_EXCEPTION_EVENT_ESP_HEADER_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_ESP_NO_ICME, - NSS_IPV4_EXCEPTION_EVENT_ESP_IP_OPTION, - NSS_IPV4_EXCEPTION_EVENT_ESP_IP_FRAGMENT, - NSS_IPV4_EXCEPTION_EVENT_ESP_SMALL_TTL, - NSS_IPV4_EXCEPTION_EVENT_ESP_NEEDS_FRAGMENTATION, - NSS_IPV4_EXCEPTION_EVENT_IVID_MISMATCH, - NSS_IPV4_EXCEPTION_EVENT_IVID_MISSING, - NSS_IPV4_EXCEPTION_EVENT_6RD_NO_ICME, - NSS_IPV4_EXCEPTION_EVENT_6RD_IP_OPTION, - NSS_IPV4_EXCEPTION_EVENT_6RD_IP_FRAGMENT, - NSS_IPV4_EXCEPTION_EVENT_6RD_NEEDS_FRAGMENTATION, - NSS_IPV4_EXCEPTION_EVENT_DSCP_MARKING_MISMATCH, - NSS_IPV4_EXCEPTION_EVENT_VLAN_MARKING_MISMATCH, - NSS_IPV4_EXCEPTION_EVENT_INTERFACE_MISMATCH, - NSS_IPV4_EXCEPTION_EVENT_GRE_HEADER_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_GRE_NO_ICME, - NSS_IPV4_EXCEPTION_EVENT_GRE_IP_OPTION, - NSS_IPV4_EXCEPTION_EVENT_GRE_IP_FRAGMENT, - NSS_IPV4_EXCEPTION_EVENT_GRE_SMALL_TTL, - NSS_IPV4_EXCEPTION_EVENT_GRE_NEEDS_FRAGMENTATION, - NSS_IPV4_EXCEPTION_EVENT_PPTP_GRE_SESSION_MATCH_FAIL, - NSS_IPV4_EXCEPTION_EVENT_PPTP_GRE_INVALID_PROTO, - NSS_IPV4_EXCEPTION_EVENT_PPTP_GRE_NO_CME, - NSS_IPV4_EXCEPTION_EVENT_PPTP_GRE_IP_OPTION, - NSS_IPV4_EXCEPTION_EVENT_PPTP_GRE_IP_FRAGMENT, - NSS_IPV4_EXCEPTION_EVENT_PPTP_GRE_SMALL_TTL, - NSS_IPV4_EXCEPTION_EVENT_PPTP_GRE_NEEDS_FRAGMENTATION, - NSS_IPV4_EXCEPTION_EVENT_DESTROY, - NSS_IPV4_EXCEPTION_EVENT_FRAG_DF_SET, - NSS_IPV4_EXCEPTION_EVENT_FRAG_FAIL, - NSS_IPV4_EXCEPTION_EVENT_ICMP_IPV4_UDPLITE_HEADER_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_UDPLITE_HEADER_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_UDPLITE_NO_ICME, - NSS_IPV4_EXCEPTION_EVENT_UDPLITE_IP_OPTION, - NSS_IPV4_EXCEPTION_EVENT_UDPLITE_IP_FRAGMENT, - NSS_IPV4_EXCEPTION_EVENT_UDPLITE_SMALL_TTL, - NSS_IPV4_EXCEPTION_EVENT_UDPLITE_NEEDS_FRAGMENTATION, - NSS_IPV4_EXCEPTION_EVENT_MC_UDP_NO_ICME, - NSS_IPV4_EXCEPTION_EVENT_MC_MEM_ALLOC_FAILURE, - NSS_IPV4_EXCEPTION_EVENT_MC_UPDATE_FAILURE, - NSS_IPV4_EXCEPTION_EVENT_MC_PBUF_ALLOC_FAILURE, - NSS_IPV4_EXCEPTION_EVENT_PPPOE_BRIDGE_NO_ICME, - NSS_IPV4_EXCEPTION_EVENT_PPPOE_NO_SESSION, - 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_MAX -}; - -/** - * nss_ipv4_node_sync - * IPv4 node synchronization statistics. - */ -struct nss_ipv4_node_sync { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - uint32_t ipv4_connection_create_requests; - /**< Number of connection create requests. */ - - /** - * Number of connection create requests that collided with existing entries. - */ - uint32_t ipv4_connection_create_collisions; - - /** - * Number of connection create requests that had invalid interfaces. - */ - uint32_t ipv4_connection_create_invalid_interface; - - uint32_t ipv4_connection_destroy_requests; - /**< Number of connection destroy requests. */ - uint32_t ipv4_connection_destroy_misses; - /**< Number of connection destroy requests that missed the cache. */ - uint32_t ipv4_connection_hash_hits; /**< Number of connection hash hits. */ - uint32_t ipv4_connection_hash_reorders; /**< Number of connection hash reorders. */ - uint32_t ipv4_connection_flushes; /**< Number of connection flushes. */ - uint32_t ipv4_connection_evictions; /**< Number of connection evictions. */ - uint32_t ipv4_fragmentations; - /**< Number of successful IPv4 fragmentations performed. */ - uint32_t ipv4_dropped_by_rule; - /**< Number of IPv4 packets dropped because of a drop rule. */ - uint32_t ipv4_mc_connection_create_requests; - /**< Number of multicast connection create requests. */ - uint32_t ipv4_mc_connection_update_requests; - /**< Number of multicast connection update requests. */ - - /** - * Number of multicast connection create requests that had invalid interfaces. - */ - uint32_t ipv4_mc_connection_create_invalid_interface; - - uint32_t ipv4_mc_connection_destroy_requests; - /**< Number of multicast connection destroy requests. */ - - /** - * Number of multicast connection destroy requests that missed the cache. - */ - uint32_t ipv4_mc_connection_destroy_misses; - - uint32_t ipv4_mc_connection_flushes; - /**< Number of multicast connection flushes. */ - - uint32_t ipv4_connection_create_invalid_mirror_ifnum; - /**< Number of create request failed with an invalid mirror interface number. */ - - uint32_t ipv4_connection_create_invalid_mirror_iftype; - /**< Number of create request failed 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. */ -}; - -/** - * nss_ipv4_msg - * Data for sending and receiving IPv4 bridge or routing messages. - */ -struct nss_ipv4_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of an IPv4 bridge or routing message. - */ - union { - struct nss_ipv4_rule_create_msg rule_create; - /**< Create a rule. */ - struct nss_ipv4_rule_destroy_msg rule_destroy; - /**< Destroy a rule. */ - struct nss_ipv4_conn_sync conn_stats; - /**< Synchronize connection statistics. */ - struct nss_ipv4_node_sync node_stats; - /**< Synchronize node statistics. */ - struct nss_ipv4_rule_conn_get_table_size_msg size; - /**< Get the size for connection tables. */ - struct nss_ipv4_rule_conn_cfg_msg rule_conn_cfg; - /**< Configure a rule connection. */ - struct nss_ipv4_mc_rule_create_msg mc_rule_create; - /**< Create a multicast rule. */ - struct nss_ipv4_conn_sync_many_msg conn_stats_many; - /**< Synchronize multiple connection statistics. */ - struct nss_ipv4_accel_mode_cfg_msg accel_mode_cfg; - /**< Acceleration mode. */ - struct nss_ipv4_inquiry_msg inquiry; - /**< Inquiry if a connection has created. */ - struct nss_ipv4_dscp2pri_cfg_msg dscp2pri_cfg; - /**< Configure dscp2pri mapping. */ - struct nss_ipv4_rps_hash_bitmap_cfg_msg rps_hash_bitmap; - /**< Configure rps_hash_bitmap. */ - } msg; /**< Message payload. */ -}; - -/** - * nss_ipv4_stats_notification - * Data for sending IPv4 statistics. - */ -struct nss_ipv4_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint64_t cmn_node_stats[NSS_STATS_NODE_MAX]; /**< Node statistics. */ - uint64_t special_stats[NSS_IPV4_STATS_MAX]; /**< IPv4 special statistics. */ - uint64_t exception_stats[NSS_IPV4_EXCEPTION_EVENT_MAX]; /**< IPv4 exception statistics. */ -}; - -/** - * Configured IPv4 connection number to use for calculating the total number of - * connections. - */ -extern int nss_ipv4_conn_cfg; - -#ifdef __KERNEL__ /* only kernel will use. */ - -/** - * nss_ipv4_max_conn_count - * Returns the maximum number of IPv4 connections that the NSS acceleration - * engine supports. - * - * @return - * Number of connections that can be accelerated. - */ -int nss_ipv4_max_conn_count(void); - -/** - * Callback function for receiving IPv4 messages. - * - * @datatypes - * nss_ipv4_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_ipv4_msg_callback_t)(void *app_data, struct nss_ipv4_msg *msg); - -/** - * nss_ipv4_tx - * Transmits an IPv4 message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_ipv4_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_ipv4_tx(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_msg *msg); - -/** - * nss_ipv4_tx_sync - * Transmits a synchronous IPv4 message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_ipv4_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_ipv4_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_msg *msg); - -/** - * nss_ipv4_tx_with_size - * Transmits an IPv4 message with a specified size to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_ipv4_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] msg Pointer to the message data. - * @param[in] size Actual size of this message. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_ipv4_tx_with_size(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_msg *msg, uint32_t size); - -/** - * nss_ipv4_notify_register - * Registers a notifier callback to forward the IPv4 messages received from the NSS - * firmware to the registered subsystem. - * - * @datatypes - * nss_ipv4_msg_callback_t - * - * @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. - */ -extern struct nss_ctx_instance *nss_ipv4_notify_register(nss_ipv4_msg_callback_t cb, void *app_data); - -/** - * nss_ipv4_notify_unregister - * Degisters an IPv4 message notifier callback from the NSS. - * - * @return - * None. - * - * @dependencies - * The notifier callback must have been previously registered. - */ -extern void nss_ipv4_notify_unregister(void); - -/** - * nss_ipv4_conn_sync_many_notify_register - * Registers a notifier callback with the NSS for connection synchronization - * message responses. - * - * @datatypes - * nss_ipv4_msg_callback_t - * - * @param[in] cb Callback function for the message. - * - * @return - * None. - */ -extern void nss_ipv4_conn_sync_many_notify_register(nss_ipv4_msg_callback_t cb); - -/** - * nss_ipv4_conn_sync_many_notify_unregister - * Degisters a connection synchronization notifier callback from the NSS. - * - * @return - * None. - * - * @dependencies - * The notifier callback must have been previously registered. - */ -extern void nss_ipv4_conn_sync_many_notify_unregister(void); - -/** - * nss_ipv4_get_mgr - * Gets the NSS context that is managing IPv4 processes. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_ipv4_get_mgr(void); - -/** - * nss_ipv4_register_handler - * Registers the IPv4 message handler. - * - * @return - * None. - */ -void nss_ipv4_register_handler(void); - -/** - * nss_ipv4_register_sysctl - * Registers the IPv4 system control table. - * - * @return - * None. - */ -void nss_ipv4_register_sysctl(void); - -/** - * nss_ipv4_unregister_sysctl - * Deregisters the IPv4 system control table. - * - * @return - * None. - * - * @dependencies - * The system control table must have been previously registered. - */ -void nss_ipv4_unregister_sysctl(void); - -/** - * nss_ipv4_msg_init - * Initializes IPv4 messages. - * - * @datatypes - * nss_ipv4_msg \n - * nss_ipv4_msg_callback_t - * - * @param[in,out] nim 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_ipv4_msg_init(struct nss_ipv4_msg *nim, uint16_t if_num, uint32_t type, uint32_t len, - nss_ipv4_msg_callback_t cb, void *app_data); - -/** - * nss_ipv4_update_conn_count - * Sets the maximum number of IPv4 connections. - * - * @param[in] ipv4_max_conn Maximum number. - * - * @return - * 0 -- Success - */ -int nss_ipv4_update_conn_count(int ipv4_max_conn); - -/** - * nss_ipv4_free_conn_tables - * Frees memory allocated for connection tables. - * - * @return - * None. - */ -extern void nss_ipv4_free_conn_tables(void); - -/** - * nss_ipv4_dscp_action_get - * Gets the action value of the DSCP. - * - * @param[in] dscp Value of the DSCP field. - * - * @return - * Action value of the DSCP field. - */ -enum nss_ipv4_dscp_map_actions nss_ipv4_dscp_action_get(uint8_t dscp); - -/* - * Logger APIs - */ - -/** - * nss_ipv4_log_tx_msg - * Logs an IPv4 message that is sent to the NSS firmware. - * - * @datatypes - * nss_ipv4_msg - * - * @param[in] nim Pointer to the NSS interface message. - * - * @return - * None. - */ -void nss_ipv4_log_tx_msg(struct nss_ipv4_msg *nim); - -/** - * nss_ipv4_log_rx_msg - * Logs an IPv4 message that is received from the NSS firmware. - * - * @datatypes - * nss_ipv4_msg - * - * @param[in] nim Pointer to the NSS interface message. - * - * @return - * None. - */ -void nss_ipv4_log_rx_msg(struct nss_ipv4_msg *nim); - -/** - * nss_ipv4_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_ipv4_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_ipv4_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_ipv4_stats_unregister_notifier(struct notifier_block *nb); - -#endif /*__KERNEL__ */ - -/** - * @} - */ - -#endif /* __NSS_IPV4_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipv4_reasm.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipv4_reasm.h deleted file mode 100644 index f7785cfe1..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipv4_reasm.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_ipv4_reasm.h - * NSS IPv4 reassembly interface definitions. - */ - -#ifndef __NSS_IPV4_REASM_H -#define __NSS_IPV4_REASM_H - -/** - * @addtogroup nss_ipv4_reasm_subsystem - * @{ - */ - -/* - * nss_ipv4_reasm_stats_types - * IPv4 reassembly node statistics. - */ -enum nss_ipv4_reasm_stats_types { - NSS_IPV4_REASM_STATS_EVICTIONS, /**< Number of evicted fragment queues due to set memory threshold. */ - NSS_IPV4_REASM_STATS_ALLOC_FAILS, /**< Number of fragment queue allocation failures. */ - NSS_IPV4_REASM_STATS_TIMEOUTS, /**< Number of expired fragment queues. */ - NSS_IPV4_REASM_STATS_MAX, /**< Maximum message type. */ -}; - -/** - * nss_ipv4_reasm_stats_notification - * Data for sending IPv4 reassembly statistics. - */ -struct nss_ipv4_reasm_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint64_t cmn_node_stats[NSS_STATS_NODE_MAX]; /**< Common node statistics. */ - uint64_t ipv4_reasm_stats[NSS_IPV4_REASM_STATS_MAX]; /**< IPv4 reassembly statistics. */ -}; - -#ifdef __KERNEL__ /* only kernel will use. */ - -/** - * nss_ipv4_reasm_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_ipv4_reasm_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_ipv4_reasm_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_ipv4_reasm_stats_unregister_notifier(struct notifier_block *nb); - -#endif /*__KERNEL__ */ - -/** - * @} - */ - -#endif /* __NSS_IPV4_REASM_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipv6.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipv6.h deleted file mode 100644 index 930e74cba..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipv6.h +++ /dev/null @@ -1,1304 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipv6.h - * NSS IPv6 interface definitions. - */ - -#ifndef __NSS_IPV6_H -#define __NSS_IPV6_H - -/** - * @addtogroup nss_ipv6_subsystem - * @{ - */ - -/** - * 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 (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. */ -}; - -/** - * 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. - */ -enum nss_ipv6_stats_types { - NSS_IPV6_STATS_ACCELERATED_RX_PKTS, - /**< Accelerated IPv6 Rx packets. */ - NSS_IPV6_STATS_ACCELERATED_RX_BYTES, - /**< Accelerated IPv6 Rx bytes. */ - NSS_IPV6_STATS_ACCELERATED_TX_PKTS, - /**< Accelerated IPv6 Tx packets. */ - NSS_IPV6_STATS_ACCELERATED_TX_BYTES, - /**< Accelerated IPv6 Tx bytes. */ - NSS_IPV6_STATS_CONNECTION_CREATE_REQUESTS, - /**< Number of IPv6 connection create requests. */ - NSS_IPV6_STATS_CONNECTION_CREATE_COLLISIONS, - /**< Number of IPv6 connection create requests that collided with existing entries. */ - NSS_IPV6_STATS_CONNECTION_CREATE_INVALID_INTERFACE, - /**< Number of IPv6 connection create requests that had invalid interface. */ - NSS_IPV6_STATS_CONNECTION_DESTROY_REQUESTS, - /**< Number of IPv6 connection destroy requests. */ - NSS_IPV6_STATS_CONNECTION_DESTROY_MISSES, - /**< Number of IPv6 connection destroy requests that missed the cache. */ - NSS_IPV6_STATS_CONNECTION_HASH_HITS, - /**< Number of IPv6 connection hash hits. */ - NSS_IPV6_STATS_CONNECTION_HASH_REORDERS, - /**< Number of IPv6 connection hash reorders. */ - NSS_IPV6_STATS_CONNECTION_FLUSHES, - /**< Number of IPv6 connection flushes. */ - NSS_IPV6_STATS_CONNECTION_EVICTIONS, - /**< Number of IPv6 connection evictions. */ - NSS_IPV6_STATS_FRAGMENTATIONS, - /**< Number of successful IPv6 fragmentations performed. */ - NSS_IPV6_STATS_FRAG_FAILS, - /**< Number of IPv6 fragmentation fails. */ - NSS_IPV6_STATS_DROPPED_BY_RULE, - /**< Number of IPv6 packets dropped by a drop rule. */ - NSS_IPV6_STATS_MC_CONNECTION_CREATE_REQUESTS, - /**< Number of successful IPv6 multicast create requests. */ - NSS_IPV6_STATS_MC_CONNECTION_UPDATE_REQUESTS, - /**< Number of successful IPv6 multicast update requests. */ - NSS_IPV6_STATS_MC_CONNECTION_CREATE_INVALID_INTERFACE, - /**< Number of IPv6 multicast connection create requests that had invalid interface. */ - NSS_IPV6_STATS_MC_CONNECTION_DESTROY_REQUESTS, - /**< Number of IPv6 multicast connection destroy requests. */ - NSS_IPV6_STATS_MC_CONNECTION_DESTROY_MISSES, - /**< 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. */ -}; - -/** - * nss_ipv6_message_types - * IPv6 bridge and routing rule message types. - * - * NSS_IPV6_RX_DEPRECATED0 is a deprecated type. It is kept for backward compatibility. - */ -enum nss_ipv6_message_types { - NSS_IPV6_TX_CREATE_RULE_MSG, - NSS_IPV6_TX_DESTROY_RULE_MSG, - NSS_IPV6_RX_DEPRECATED0, - NSS_IPV6_RX_CONN_STATS_SYNC_MSG, - NSS_IPV6_RX_NODE_STATS_SYNC_MSG, - NSS_IPV6_TX_CONN_CFG_RULE_MSG, - NSS_IPV6_TX_CREATE_MC_RULE_MSG, - NSS_IPV6_TX_CONN_STATS_SYNC_MANY_MSG, - NSS_IPV6_TX_ACCEL_MODE_CFG_MSG, - NSS_IPV6_TX_CONN_CFG_INQUIRY_MSG, - NSS_IPV6_TX_CONN_TABLE_SIZE_MSG, - NSS_IPV6_TX_DSCP2PRI_CFG_MSG, - NSS_IPV6_TX_RPS_HASH_BITMAP_CFG_MSG, - NSS_IPV6_MAX_MSG_TYPES, -}; - -/** - * nss_ipv6_dscp_map_actions - * Action types mapped to DSCP values. - */ -enum nss_ipv6_dscp_map_actions { - NSS_IPV6_DSCP_MAP_ACTION_ACCEL, - NSS_IPV6_DSCP_MAP_ACTION_DONT_ACCEL, - NSS_IPV6_DSCP_MAP_ACTION_MAX, -}; - -/* - * NSS IPv6 rule creation flags. - */ -#define NSS_IPV6_RULE_CREATE_FLAG_NO_SEQ_CHECK 0x01 - /**< Do not perform TCP sequence number checks. */ -#define NSS_IPV6_RULE_CREATE_FLAG_BRIDGE_FLOW 0x02 - /**< This is a pure bridge forwarding flow. */ -#define NSS_IPV6_RULE_CREATE_FLAG_ROUTED 0x04 - /**< Rule is for a routed connection. */ -#define NSS_IPV6_RULE_CREATE_FLAG_DSCP_MARKING 0x08 - /**< Rule has for a DSCP marking configured. */ -#define NSS_IPV6_RULE_CREATE_FLAG_VLAN_MARKING 0x10 - /**< Rule has for a VLAN marking configured. */ -#define NSS_IPV6_RULE_CREATE_FLAG_ICMP_NO_CME_FLUSH 0x20 - /**< Rule for not flushing connection match entry on ICMP packet. */ -#define NSS_IPV6_RULE_UPDATE_FLAG_CHANGE_MTU 0x40 - /**< Rule updation for MTU change. */ - -/** The L2 payload is not IPv6 but consists of an encapsulating protocol that carries an IPv6 payload within it. - */ -#define NSS_IPV6_RULE_CREATE_FLAG_L2_ENCAP 0x80 - -#define NSS_IPV6_RULE_CREATE_FLAG_DROP 0x100 - /**< 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. - */ -#define NSS_IPV6_RULE_CREATE_CONN_VALID 0x01 /**< Connection is valid. */ -#define NSS_IPV6_RULE_CREATE_TCP_VALID 0x02 /**< TCP protocol fields are valid. */ -#define NSS_IPV6_RULE_CREATE_PPPOE_VALID 0x04 /**< PPPoE fields are valid. */ -#define NSS_IPV6_RULE_CREATE_QOS_VALID 0x08 /**< QoS fields are valid. */ -#define NSS_IPV6_RULE_CREATE_VLAN_VALID 0x10 /**< VLAN fields are valid. */ -#define NSS_IPV6_RULE_CREATE_DSCP_MARKING_VALID 0x20 - /**< DSCP marking fields are valid. */ -#define NSS_IPV6_RULE_CREATE_VLAN_MARKING_VALID 0x40 - /**< VLAN marking fields are valid. */ -#define NSS_IPV6_RULE_CREATE_SRC_MAC_VALID 0x80 - /**< Source MAC address fields are valid. */ -#define NSS_IPV6_RULE_CREATE_NEXTHOP_VALID 0x100 - /**< Next hop interface number fields are valid. */ -#define NSS_IPV6_RULE_CREATE_RPS_VALID 0x200 /**< RPS for core selection is valid. */ -#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 - */ -#define NSS_IPV6_MC_RULE_CREATE_FLAG_QOS_VALID 0x01 - /**< QoS fields are valid. */ -#define NSS_IPV6_MC_RULE_CREATE_FLAG_DSCP_MARKING_VALID 0x02 - /**< DSCP fields are valid. */ -#define NSS_IPV6_MC_RULE_CREATE_FLAG_INGRESS_VLAN_VALID 0x04 - /**< Ingress VLAN fields are valid. */ -#define NSS_IPV6_MC_RULE_CREATE_FLAG_INGRESS_PPPOE 0x08 - /**< Ingress PPPoE fields are valid. */ -#define NSS_IPV6_MC_RULE_CREATE_FLAG_IGS_VALID 0x10 - /**< Ingress shaping fields are valid. */ - -/* - * Per-interface rule flags for a multicast connection (to be used with the rule_flags - * field of nss_ipv6_mc_if_rule structure). - */ -#define NSS_IPV6_MC_RULE_CREATE_IF_FLAG_BRIDGE_FLOW 0x01 - /**< Bridge flow. */ -#define NSS_IPV6_MC_RULE_CREATE_IF_FLAG_ROUTED_FLOW 0x02 - /**< Routed flow. */ -#define NSS_IPV6_MC_RULE_CREATE_IF_FLAG_JOIN 0x04 - /**< Interface has joined the flow. */ -#define NSS_IPV6_MC_RULE_CREATE_IF_FLAG_LEAVE 0x08 - /**< Interface has left the flow. */ - -/* - * Per-interface valid flags for a multicast connection (to be used with the valid_flags - * field of nss_ipv6_mc_if_rule structure). - */ -#define NSS_IPV6_MC_RULE_CREATE_IF_FLAG_VLAN_VALID 0x01 - /**< VLAN fields are valid. */ -#define NSS_IPV6_MC_RULE_CREATE_IF_FLAG_PPPOE_VALID 0x02 - /**< PPPoE fields are valid. */ - -/* - * Source MAC address valid flags (to be used with mac_valid_flags field of nss_ipv6_src_mac_rule structure) - */ -#define NSS_IPV6_SRC_MAC_FLOW_VALID 0x01 - /**< MAC address for the flow interface is valid. */ -#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. - */ -enum nss_ipv6_exception_events { - NSS_IPV6_EXCEPTION_EVENT_ICMP_HEADER_INCOMPLETE, - NSS_IPV6_EXCEPTION_EVENT_ICMP_UNHANDLED_TYPE, - NSS_IPV6_EXCEPTION_EVENT_ICMP_IPV6_HEADER_INCOMPLETE, - NSS_IPV6_EXCEPTION_EVENT_ICMP_IPV6_UDP_HEADER_INCOMPLETE, - NSS_IPV6_EXCEPTION_EVENT_ICMP_IPV6_TCP_HEADER_INCOMPLETE, - NSS_IPV6_EXCEPTION_EVENT_ICMP_IPV6_UNKNOWN_PROTOCOL, - NSS_IPV6_EXCEPTION_EVENT_ICMP_NO_ICME, - NSS_IPV6_EXCEPTION_EVENT_ICMP_FLUSH_TO_HOST, - NSS_IPV6_EXCEPTION_EVENT_TCP_HEADER_INCOMPLETE, - NSS_IPV6_EXCEPTION_EVENT_TCP_NO_ICME, - NSS_IPV6_EXCEPTION_EVENT_TCP_SMALL_HOP_LIMIT, - NSS_IPV6_EXCEPTION_EVENT_TCP_NEEDS_FRAGMENTATION, - NSS_IPV6_EXCEPTION_EVENT_TCP_FLAGS, - NSS_IPV6_EXCEPTION_EVENT_TCP_SEQ_EXCEEDS_RIGHT_EDGE, - NSS_IPV6_EXCEPTION_EVENT_TCP_SMALL_DATA_OFFS, - NSS_IPV6_EXCEPTION_EVENT_TCP_BAD_SACK, - NSS_IPV6_EXCEPTION_EVENT_TCP_BIG_DATA_OFFS, - NSS_IPV6_EXCEPTION_EVENT_TCP_SEQ_BEFORE_LEFT_EDGE, - NSS_IPV6_EXCEPTION_EVENT_TCP_ACK_EXCEEDS_RIGHT_EDGE, - NSS_IPV6_EXCEPTION_EVENT_TCP_ACK_BEFORE_LEFT_EDGE, - NSS_IPV6_EXCEPTION_EVENT_UDP_HEADER_INCOMPLETE, - NSS_IPV6_EXCEPTION_EVENT_UDP_NO_ICME, - NSS_IPV6_EXCEPTION_EVENT_UDP_SMALL_HOP_LIMIT, - NSS_IPV6_EXCEPTION_EVENT_UDP_NEEDS_FRAGMENTATION, - NSS_IPV6_EXCEPTION_EVENT_WRONG_TARGET_MAC, - NSS_IPV6_EXCEPTION_EVENT_HEADER_INCOMPLETE, - NSS_IPV6_EXCEPTION_EVENT_UNKNOWN_PROTOCOL, - NSS_IPV6_EXCEPTION_EVENT_IVID_MISMATCH, - NSS_IPV6_EXCEPTION_EVENT_IVID_MISSING, - NSS_IPV6_EXCEPTION_EVENT_DSCP_MARKING_MISMATCH, - NSS_IPV6_EXCEPTION_EVENT_VLAN_MARKING_MISMATCH, - NSS_IPV6_EXCEPTION_EVENT_INTERFACE_MISMATCH, - NSS_IPV6_EXCEPTION_EVENT_GRE_NO_ICME, - NSS_IPV6_EXCEPTION_EVENT_GRE_NEEDS_FRAGMENTATION, - NSS_IPV6_EXCEPTION_EVENT_GRE_SMALL_HOP_LIMIT, - NSS_IPV6_EXCEPTION_EVENT_DESTROY, - NSS_IPV6_EXCEPTION_EVENT_ICMP_IPV6_UDPLITE_HEADER_INCOMPLETE, - NSS_IPV6_EXCEPTION_EVENT_UDPLITE_HEADER_INCOMPLETE, - NSS_IPV6_EXCEPTION_EVENT_UDPLITE_NO_ICME, - NSS_IPV6_EXCEPTION_EVENT_UDPLITE_SMALL_HOP_LIMIT, - NSS_IPV6_EXCEPTION_EVENT_UDPLITE_NEEDS_FRAGMENTATION, - NSS_IPV6_EXCEPTION_EVENT_MC_UDP_NO_ICME, - NSS_IPV6_EXCEPTION_EVENT_MC_MEM_ALLOC_FAILURE, - NSS_IPV6_EXCEPTION_EVENT_MC_UPDATE_FAILURE, - NSS_IPV6_EXCEPTION_EVENT_MC_PBUF_ALLOC_FAILURE, - NSS_IPV6_EXCEPTION_EVENT_ESP_HEADER_INCOMPLETE, - NSS_IPV6_EXCEPTION_EVENT_ESP_NO_ICME, - NSS_IPV6_EXCEPTION_EVENT_ESP_IP_FRAGMENT, - NSS_IPV6_EXCEPTION_EVENT_ESP_SMALL_HOP_LIMIT, - NSS_IPV6_EXCEPTION_EVENT_ESP_NEEDS_FRAGMENTATION, - NSS_IPV6_EXCEPTION_EVENT_TUNIPIP6_NO_ICME, - NSS_IPV6_EXCEPTION_EVENT_TUNIPIP6_SMALL_HOP_LIMIT, - NSS_IPV6_EXCEPTION_EVENT_TUNIPIP6_NEEDS_FRAGMENTATION, - NSS_IPV6_EXCEPTION_EVENT_PPPOE_BRIDGE_NO_ICME, - NSS_IPV6_EXCEPTION_EVENT_DONT_FRAG_SET, - NSS_IPV6_EXCEPTION_EVENT_REASSEMBLY_NOT_SUPPORTED, - NSS_IPV6_EXCEPTION_EVENT_PPPOE_NO_SESSION, - 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_MAX -}; - -/** - * nss_ipv6_5tuple - * Common 5-tuple information. - */ -struct nss_ipv6_5tuple { - uint32_t flow_ip[4]; /**< Flow IP address. */ - uint32_t flow_ident; /**< Flow identifier (e.g., TCP or UDP port). */ - uint32_t return_ip[4]; /**< Return IP address. */ - uint32_t return_ident; /**< Return identier (e.g., TCP or UDP port). */ - uint8_t protocol; /**< Protocol number. */ - uint8_t reserved[3]; /**< Padded for alignment. */ -}; - -/** - * nss_ipv6_connection_rule - * Information for creating a connection. - */ -struct nss_ipv6_connection_rule { - uint16_t flow_mac[3]; /**< Flow MAC address. */ - uint16_t return_mac[3]; /**< Return MAC address. */ - int32_t flow_interface_num; /**< Flow interface number. */ - int32_t return_interface_num; /**< Return interface number. */ - uint32_t flow_mtu; /**< MTU for the flow interface. */ - uint32_t return_mtu; /**< MTU for the return interface. */ -}; - -/** - * nss_ipv6_pppoe_rule - * Information for PPPoE connection rules. - */ -struct nss_ipv6_pppoe_rule { - uint32_t flow_if_exist; - /**< PPPoE interface existence flag for the flow direction. */ - int32_t flow_if_num; - /**< PPPoE interface number for the flow direction. */ - uint32_t return_if_exist; - /**< PPPoE interface existence flag for the return direction. */ - int32_t return_if_num; - /**< PPPoE interface number for the return direction. */ -}; - -/** - * nss_ipv6_dscp_rule - * Information for DSCP connection rules. - */ -struct nss_ipv6_dscp_rule { - uint8_t flow_dscp; /**< Egress DSCP value for the flow direction. */ - uint8_t return_dscp; /**< Egress DSCP value for the return direction. */ - uint8_t reserved[2]; /**< Padded for alignment. */ -}; - -/** - * nss_ipv6_vlan_rule - * Information for VLAN connection rules. - */ -struct nss_ipv6_vlan_rule { - uint32_t ingress_vlan_tag; /**< VLAN tag for the ingress packets. */ - uint32_t egress_vlan_tag; /**< VLAN tag for egress packets. */ -}; - -/** - * nss_ipv6_nexthop - * Information for the next hop interface numbers. - * - * A next hop is the next interface that will receive the packet as opposed to - * the final interface when the packet leaves the device. - */ -struct nss_ipv6_nexthop { - /** - * Next hop interface number of the flow direction (from which the connection - * originated). - */ - int32_t flow_nexthop; - /** - * Next hop interface number of the return direction (to which the connection - * is destined). - */ - int32_t return_nexthop; -}; - -/** - * nss_ipv6_protocol_tcp_rule - * Information for TCP connection rules. - */ -struct nss_ipv6_protocol_tcp_rule { - uint32_t flow_max_window; - /**< Largest seen window for the flow direction. */ - uint32_t flow_end; - /**< Largest seen sequence + segment length for the flow direction. */ - uint32_t flow_max_end; - /**< Largest seen ack + max(1, win) for the flow direction. */ - uint32_t return_max_window; - /**< Largest seen window for the return direction. */ - uint32_t return_end; - /**< Largest seen sequence + segment length for the return direction. */ - uint32_t return_max_end; - /**< Largest seen ack + max(1, win) for the return direction. */ - uint8_t flow_window_scale; - /**< Window scaling factor for the flow direction. */ - uint8_t return_window_scale; - /**< Window scaling factor for the return direction. */ - uint16_t reserved; - /**< Alignment padding. */ -}; - -/** - * nss_ipv6_igs_rule - * Information for ingress shaping connection rules. - */ -struct nss_ipv6_igs_rule { - uint16_t igs_flow_qos_tag; - /**< Ingress shaping QoS tag associated with this rule for the flow direction. */ - uint16_t igs_return_qos_tag; - /**< Ingress shaping QoS tag associated with this rule for the return direction. */ -}; - -/** - * nss_ipv6_qos_rule - * Information for QoS connection rules. - */ -struct nss_ipv6_qos_rule { - uint32_t flow_qos_tag; - /**< QoS tag associated with this rule for the flow direction. */ - uint32_t return_qos_tag; - /**< QoS tag associated with this rule for the return direction. */ -}; - -/** - * nss_ipv6_src_mac_rule - * Information for source MAC address rules. - */ -struct nss_ipv6_src_mac_rule { - uint32_t mac_valid_flags; /**< MAC address validity flags. */ - uint16_t flow_src_mac[3]; /**< Source MAC address for the flow direction. */ - uint16_t return_src_mac[3]; /**< Source MAC address for the return direction. */ -}; - -/** - * nss_ipv6_rps_rule - * RPS rule structure. - */ -struct nss_ipv6_rps_rule { - uint8_t flow_rps; - /**< RPS for core selection for flow direction. */ - uint8_t return_rps; - /**< RPS for core selection for return direction. */ - uint8_t reserved[2]; - /**< Padded for alignment. */ -}; - -/** - * 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. - */ -enum nss_ipv6_error_response_types { - NSS_IPV6_UNKNOWN_MSG_TYPE = 1, /**< Unknown error. */ - NSS_IPV6_CR_INVALID_PNODE_ERROR, /**< Invalid interface number. */ - NSS_IPV6_CR_MISSING_CONNECTION_RULE_ERROR, /**< Missing connection rule. */ - NSS_IPV6_CR_BUFFER_ALLOC_FAIL_ERROR, /**< Buffer allocation failed. */ - NSS_IPV6_DR_NO_CONNECTION_ENTRY_ERROR, - /**< No connection was found to delete. */ - NSS_IPV6_CR_CONN_CFG_ALREADY_CONFIGURED_ERROR, - /**< Connection configuration was already done once. */ - - NSS_IPV6_CR_CONN_CFG_NOT_MULTIPLE_OF_QUANTA_ERROR, - /**< Input for connection configuration is not a multiple of quanta. */ - - /** - * Input for connection configuration exceeds the maximum number of supported - * connections. - */ - NSS_IPV6_CR_CONN_CFG_EXCEEDS_LIMIT_ERROR, - - /** - * Memory allocation for connection configuration failed at the NSS firmware. - */ - NSS_IPV6_CR_CONN_CFG_MEM_ALLOC_FAIL_ERROR, - - NSS_IPV6_CR_MULTICAST_INVALID_PROTOCOL, - /**< Invalid L4 protocol for creating a multicast rule. */ - NSS_IPV6_CR_MULTICAST_UPDATE_INVALID_FLAGS, - /**< Invalid multicast flags for updating multicast. */ - NSS_IPV6_CR_MULTICAST_UPDATE_INVALID_IF, - /**< Invalid interface for updating multicast. */ - NSS_IPV6_CR_ACCEL_MODE_CONFIG_INVALID, - /**< Invalid config value for acceleration mode. */ - 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. */ - NSS_IPV6_CR_INVALID_RPS, - /**< Invalid RPS Value. */ - NSS_IPV6_HASH_BITMAP_INVALID, - /**< Invalid hash bitmap. */ - 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. */ - NSS_IPV6_LAST - /**< Maximum number of error responses. */ -}; - -/** - * nss_ipv6_rule_create_msg - * IPv6 rule for creating sub-messages. - */ -struct nss_ipv6_rule_create_msg { - /* - * Request - */ - uint16_t valid_flags; - /**< Bit flags associated with the validity of parameters. */ - uint16_t rule_flags; - /**< Bit flags associated with the rule. */ - struct nss_ipv6_5tuple tuple; - /**< Holds values of the 5 tuple. */ - struct nss_ipv6_connection_rule conn_rule; - /**< Basic connection-specific data. */ - struct nss_ipv6_protocol_tcp_rule tcp_rule; - /**< Protocol-related accleration parameters. */ - struct nss_ipv6_pppoe_rule pppoe_rule; - /**< PPPoE-related accleration parameters. */ - struct nss_ipv6_qos_rule qos_rule; - /**< QoS-related accleration parameters. */ - struct nss_ipv6_dscp_rule dscp_rule; - /**< DSCP-related accleration parameters. */ - struct nss_ipv6_vlan_rule vlan_primary_rule; - /**< VLAN-related accleration parameters. */ - struct nss_ipv6_vlan_rule vlan_secondary_rule; - /**< VLAN-related accleration parameters. */ - struct nss_ipv6_src_mac_rule src_mac_rule; - /**< Source MAC address-related acceleration parameters. */ - struct nss_ipv6_nexthop nexthop_rule; - /**< Parameters related to the next hop. */ - struct nss_ipv6_rps_rule rps_rule; - /**< 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. */ -}; - -/** - * nss_ipv6_inquiry_msg - * IPv6 connection inquiry sub-messages. - */ -struct nss_ipv6_inquiry_msg { - /** - * Request by 5-tuple and response in other items. - */ - struct nss_ipv6_rule_create_msg rr; -}; - -/** - * nss_ipv6_mc_if_rule - * IPv6 multicast rule for creating a per-interface payload. - */ -struct nss_ipv6_mc_if_rule { - uint16_t rule_flags; - /**< Bit flags associated with the rule for this interface. */ - - /** - * Bit flags associated with the validity of parameters for this interface. - */ - uint16_t valid_flags; - - uint32_t egress_vlan_tag[MAX_VLAN_DEPTH]; - /**< VLAN tag stack for the egress packets. */ - int32_t pppoe_if_num; /**< PPPoE interface number. */ - uint32_t if_num; /**< Interface number. */ - uint32_t if_mtu; /**< MTU of the interface. */ - uint16_t if_mac[3]; /**< Interface MAC address. */ - uint8_t reserved[2]; /**< Reserved 2 bytes for alignment. */ -}; - -/** - * nss_ipv6_mc_rule_create_msg - * IPv6 multicast rule for creating sub-messages. - */ -struct nss_ipv6_mc_rule_create_msg { - struct nss_ipv6_5tuple tuple; /**< Holds values of the 5 tuple. */ - - uint32_t rule_flags; /**< Multicast command rule flags. */ - uint32_t valid_flags; /**< Multicast command validity flags. */ - uint32_t src_interface_num; - /**< Source interface number (virtual or physical). */ - uint32_t ingress_vlan_tag[MAX_VLAN_DEPTH]; - /**< VLAN tag stack for the ingress packets. */ - uint32_t qos_tag; /**< QoS tag for the flow. */ - uint16_t dest_mac[3]; /**< Destination multicast MAC address. */ - uint16_t if_count; /**< Number of destination interfaces. */ - uint8_t egress_dscp; /**< Egress DSCP value for the flow. */ - uint8_t reserved[1]; /**< Reserved 1 byte for alignment. */ - uint16_t igs_qos_tag; /**< Ingress shaping QoS tag for the flow. */ - - struct nss_ipv6_mc_if_rule if_rule[NSS_MC_IF_MAX]; - /**< Per-interface information. */ -}; - -/** - * nss_ipv6_rule_destroy_msg - * IPv6 rule for deleting sub-messages. - */ -struct nss_ipv6_rule_destroy_msg { - struct nss_ipv6_5tuple tuple; /**< Holds values of the 5 tuple. */ -}; - -/** - * nss_ipv6_rule_conn_get_table_size_msg - * IPv6 rule for fetching connection tables size. - */ -struct nss_ipv6_rule_conn_get_table_size_msg { - uint32_t num_conn; - /**< Number of supported IPv6 connections. */ - uint32_t ce_table_size; - /**< Size of the connection entry table in NSS firmware. */ - uint32_t cme_table_size; - /**< Size of the connection match entry table in NSS firmware. */ -}; - -/** - * nss_ipv6_rule_conn_cfg_msg - * IPv6 rule for connection configuration sub-messages. - */ -struct nss_ipv6_rule_conn_cfg_msg { - uint32_t num_conn; /**< Number of supported IPv6 connections. */ - uint32_t ce_mem; /**< Memory allocated by host for connection entries table. */ - uint32_t cme_mem; /**< Memory allocated by host for connection match entries table. */ -}; - -/* - * IPv6 rule synchronization reasons. - */ -#define NSS_IPV6_RULE_SYNC_REASON_STATS 0 - /**< Rule for synchronizing statistics. */ -#define NSS_IPV6_RULE_SYNC_REASON_FLUSH 1 - /**< Rule for flushing a cache entry. */ -#define NSS_IPV6_RULE_SYNC_REASON_EVICT 2 - /**< Rule for evicting a cache entry. */ -#define NSS_IPV6_RULE_SYNC_REASON_DESTROY 3 - /**< Rule for destroying a cache entry (requested by the host OS). */ - -/** - * nss_ipv6_conn_sync - * IPv6 connection synchronization message. - */ -struct nss_ipv6_conn_sync { - uint32_t reserved; /**< Reserved field for backward compatibility. */ - uint8_t protocol; /**< Protocol number. */ - uint32_t flow_ip[4]; /**< Flow IP address. */ - uint32_t flow_ident; /**< Flow identifier (e.g., port). */ - uint32_t flow_max_window; /**< Largest seen window for the flow direction. */ - - /** - * Largest seen sequence + segment length for the flow direction. - */ - uint32_t flow_end; - - uint32_t flow_max_end; - /**< Largest seen ack + max(1, win) for the flow direction. */ - 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_ip[4]; /**< Return IP address. */ - uint32_t return_ident; /**< Return identier (e.g., port). */ - uint32_t return_max_window; - /**< Largest seen window for the return direction. */ - - /** - * Largest seen sequence + segment length for the return direction. - */ - uint32_t return_end; - - uint32_t return_max_end; - /**< Largest seen ack + max(1, win) for the return direction. */ - uint32_t return_rx_packet_count; - /**< Rx packet count for the return interface. */ - uint32_t return_rx_byte_count; - /**< Rx byte count for the return interface. */ - uint32_t return_tx_packet_count; - /**< Tx packet count for the return interface. */ - uint32_t return_tx_byte_count; - /**< Tx byte count for the return interface. */ - uint32_t inc_ticks; /**< Number of ticks since the last synchronization. */ - uint32_t reason; /**< Reason for the synchronization. */ - uint8_t flags; /**< Bit flags associated with the rule. */ - uint32_t qos_tag; /**< QoS tag. */ - uint32_t cause; /**< Flush cause associated with the rule. */ -}; - -/** - * nss_ipv6_conn_sync_many_msg - * Information for a multiple IPv6 connection statistics synchronization message. - */ -struct nss_ipv6_conn_sync_many_msg { - /* Request. */ - uint16_t index; /**< Request connection statistics from the index. */ - uint16_t size; /**< Buffer size of this message. */ - - /* Response. */ - uint16_t next; /**< Firmware response for the next connection to be requested. */ - uint16_t count; /**< Number of synchronized connections included in this message. */ - - struct nss_ipv6_conn_sync conn_sync[]; /**< Array for the statistics. */ -}; - -/** - * nss_ipv6_accel_mode_cfg_msg - * IPv6 acceleration mode configuration. - */ -struct nss_ipv6_accel_mode_cfg_msg { - uint32_t mode; /**< Type of acceleration mode. */ -}; - -/** - * nss_ipv6_dscp2pri_cfg_msg - * IPv6 dscp2pri configuration msg. - */ -struct nss_ipv6_dscp2pri_cfg_msg { - uint8_t dscp; /**< Value of DSCP. */ - uint8_t priority; /**< Corresponding priority. */ -}; - -/** - * nss_ipv6_rps_hash_bitmap_cfg_msg - * RPS hash mask configuration. - * - * The bitmap represents the host cores to which NSS firmware can steer - * packets based on packet hash. The least significant bit represents core0. - */ -struct nss_ipv6_rps_hash_bitmap_cfg_msg { - uint32_t hash_bitmap; /**< Hash mask. */ -}; - -/** - * nss_ipv6_node_sync - * IPv6 node synchronization statistics. - */ -struct nss_ipv6_node_sync { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - uint32_t ipv6_connection_create_requests; - /**< Number of connection create requests. */ - - /** - * Number of connection create requests that collided with the existing entries. - */ - uint32_t ipv6_connection_create_collisions; - - /** - * Number of connection create requests that had invalid interfaces. - */ - uint32_t ipv6_connection_create_invalid_interface; - - uint32_t ipv6_connection_destroy_requests; - /**< Number of connection destroy requests. */ - uint32_t ipv6_connection_destroy_misses; - /**< Number of connection destroy requests that missed the cache. */ - uint32_t ipv6_connection_hash_hits; /**< Number of connection hash hits. */ - uint32_t ipv6_connection_hash_reorders; /**< Number of connection hash reorders. */ - uint32_t ipv6_connection_flushes; /**< Number of connection flushes. */ - uint32_t ipv6_connection_evictions; /**< Number of connection evictions. */ - uint32_t ipv6_fragmentations; /**< Number of successful fragmentations. */ - uint32_t ipv6_frag_fails; /**< Number of fragmentation fails. */ - uint32_t ipv6_dropped_by_rule; /**< Number of packets dropped by a drop rule.*/ - uint32_t ipv6_mc_connection_create_requests; - /**< Number of multicast connection create requests. */ - uint32_t ipv6_mc_connection_update_requests; - /**< Number of multicast connection update requests. */ - - /** - * Number of multicast connection create requests that had invalid interfaces. - */ - uint32_t ipv6_mc_connection_create_invalid_interface; - - uint32_t ipv6_mc_connection_destroy_requests; - /**< Number of multicast connection destroy requests. */ - - /** - * Number of multicast connection destroy requests that missed the cache. - */ - uint32_t ipv6_mc_connection_destroy_misses; - - uint32_t ipv6_mc_connection_flushes; - /**< Number of multicast connection flushes. */ - - uint32_t ipv6_connection_create_invalid_mirror_ifnum; - /**< Number of create request failed with an invalid mirror interface number. */ - - uint32_t ipv6_connection_create_invalid_mirror_iftype; - /**< Number of create request failed 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. */ -}; - -/** - * nss_ipv6_msg - * Data for sending and receiving IPv6 bridge or routing messages. - */ -struct nss_ipv6_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of an IPv6 bridge or routing message. - */ - union { - struct nss_ipv6_rule_create_msg rule_create; - /**< Create a rule. */ - struct nss_ipv6_rule_destroy_msg rule_destroy; - /**< Destroy a rule. */ - struct nss_ipv6_conn_sync conn_stats; - /**< Synchronize statistics. */ - struct nss_ipv6_node_sync node_stats; - /**< Synchronize node statistics. */ - struct nss_ipv6_rule_conn_get_table_size_msg size; - /**< Get the size for connection tables. */ - struct nss_ipv6_rule_conn_cfg_msg rule_conn_cfg; - /**< Configure a rule connection. */ - struct nss_ipv6_mc_rule_create_msg mc_rule_create; - /**< Create a multicast rule. */ - struct nss_ipv6_conn_sync_many_msg conn_stats_many; - /**< Synchronize multiple connection statistics. */ - struct nss_ipv6_accel_mode_cfg_msg accel_mode_cfg; - /**< Configure acceleration mode. */ - struct nss_ipv6_inquiry_msg inquiry; - /**< Inquiry if a connection has been created. */ - struct nss_ipv6_dscp2pri_cfg_msg dscp2pri_cfg; - /**< Configure DSCP-to-priority mapping. */ - struct nss_ipv6_rps_hash_bitmap_cfg_msg rps_hash_bitmap; - /**< Configure rps_hash_bitmap. */ - } msg; /**< Message payload. */ -}; - -/** - * nss_ipv6_stats_notification - * Data for sending IPv6 statistics. - */ -struct nss_ipv6_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint64_t cmn_node_stats[NSS_STATS_NODE_MAX]; /**< Common node statistics. */ - uint64_t special_stats[NSS_IPV6_STATS_MAX]; /**< IPv6 special statistics. */ - uint64_t exception_stats[NSS_IPV6_EXCEPTION_EVENT_MAX]; /**< IPv6 exception statistics. */ -}; - -/** - * Configured IPv6 connection number to use for calculating the total number of - * connections. - */ -extern int nss_ipv6_conn_cfg; - -#ifdef __KERNEL__ - -/** - * nss_ipv6_max_conn_count - * Returns the maximum number of IPv6 connections that the NSS acceleration - * engine supports. - * - * @return - * Number of connections that can be accelerated. - */ -extern int nss_ipv6_max_conn_count(void); - -/** - * Callback function for receiving IPv6 messages. - * - * @datatypes - * nss_ipv6_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_ipv6_msg_callback_t)(void *app_data, struct nss_ipv6_msg *msg); - -/** - * nss_ipv6_tx - * Transmits an IPv6 message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_ipv6_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_ipv6_tx(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *msg); - -/** - * nss_ipv6_tx_sync - * Transmits a synchronous IPv6 message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_ipv6_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_ipv6_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *msg); - -/** - * nss_ipv6_tx_with_size - * Transmits an IPv6 message with a specified size to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_ipv6_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] msg Pointer to the message data. - * @param[in] size Actual size of this message. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_ipv6_tx_with_size(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *msg, uint32_t size); - -/** - * nss_ipv6_notify_register - * Registers a notifier callback to forward the IPv6 messages received from the NSS - * firmware to the registered subsystem. - * - * @datatypes - * nss_ipv6_msg_callback_t - * - * @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. - */ -extern struct nss_ctx_instance *nss_ipv6_notify_register(nss_ipv6_msg_callback_t cb, void *app_data); - -/** - * nss_ipv6_notify_unregister - * Deregisters a notifier callback from the NSS. - * - * @return - * None. - * - * @dependencies - * The notifier callback must have been previously registered. - */ -extern void nss_ipv6_notify_unregister(void); - -/** - * nss_ipv6_conn_sync_many_notify_register - * Registers a notifier callback with the NSS for connection synchronization - * message responses. - * - * @datatypes - * nss_ipv6_msg_callback_t - * - * @param[in] cb Callback function for the message. - * - * @return - * None. - */ -extern void nss_ipv6_conn_sync_many_notify_register(nss_ipv6_msg_callback_t cb); - -/** - * nss_ipv6_conn_sync_many_notify_unregister - * Degisters a notifier callback from the NSS. - * - * @return - * None. - * - * @dependencies - * The notifier callback must have been previously registered. - */ -extern void nss_ipv6_conn_sync_many_notify_unregister(void); - -/** - * nss_ipv6_get_mgr - * Gets the NSS context that is managing the IPv6 processes. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_ipv6_get_mgr(void); - -/** - * nss_ipv6_msg_init - * Initializes IPv6-specific messages. - * - * @datatypes - * nss_ipv6_msg \n - * nss_ipv6_msg_callback_t - * - * @param[in,out] nim 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_ipv6_msg_init(struct nss_ipv6_msg *nim, uint16_t if_num, uint32_t type, uint32_t len, - nss_ipv6_msg_callback_t cb, void *app_data); - -/** - * nss_ipv6_register_handler - * Registers the IPv6 message handler. - * - * @return - * None. - */ -void nss_ipv6_register_handler(void); - -/** - * nss_ipv6_register_sysctl - * Registers the IPv6 system control table. - * - * @return - * None. - */ -void nss_ipv6_register_sysctl(void); - -/** - * nss_ipv6_unregister_sysctl - * Deregisters the IPv6 system control table. - * - * @return - * None. - * - * @dependencies - * The system control table must have been previously registered. - */ -void nss_ipv6_unregister_sysctl(void); - -/** - * nss_ipv6_update_conn_count - * Sets the maximum number of IPv6 connections. - * - * @param[in] ipv6_num_conn Maximum number. - * - * @return - * 0 -- Success - */ -int nss_ipv6_update_conn_count(int ipv6_num_conn); - -/** - * nss_ipv6_free_conn_tables - * Frees memory allocated for connection tables. - * - * @return - * None. - */ -void nss_ipv6_free_conn_tables(void); - -/** - * nss_ipv6_dscp_action_get - * Gets the action value of the DSCP. - * - * @param[in] dscp Value of the DSCP field. - * - * @return - * Action value of the DSCP field. - */ -enum nss_ipv6_dscp_map_actions nss_ipv6_dscp_action_get(uint8_t dscp); - -/* - * Logger APIs - */ - -/** - * nss_ipv6_log_tx_msg - * Logs an IPv6 message that is sent to the NSS firmware. - * - * @datatypes - * nss_ipv6_msg - * - * @param[in] nim Pointer to the NSS interface message. - * - * @return - * None. - */ -void nss_ipv6_log_tx_msg(struct nss_ipv6_msg *nim); - -/** - * nss_ipv6_log_rx_msg - * Logs an IPv6 message that is received from the NSS firmware. - * - * @datatypes - * nss_ipv6_msg - * - * @param[in] nim Pointer to the NSS interface message. - * - * @return - * None. - */ -void nss_ipv6_log_rx_msg(struct nss_ipv6_msg *nim); - -/** - * nss_ipv6_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_ipv6_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_ipv6_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_ipv6_stats_unregister_notifier(struct notifier_block *nb); -#endif - -/** - * @} - */ - -#endif /* __NSS_IPV6_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipv6_reasm.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipv6_reasm.h deleted file mode 100644 index 806bf0041..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ipv6_reasm.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_ipv6_reasm.h - * NSS IPv6 reassembly interface definitions. - */ - -#ifndef __NSS_IPV6_REASM_H -#define __NSS_IPV6_REASM_H - -/** - * @addtogroup nss_ipv6_reasm_subsystem - * @{ - */ - -/** - * nss_ipv6_reasm_stats - * IPv6 reassembly node statistics. - */ -enum nss_ipv6_reasm_stats { - NSS_IPV6_REASM_STATS_ALLOC_FAILS, - /**< Number of fragment queue allocation failures. */ - NSS_IPV6_REASM_STATS_TIMEOUTS, - /**< Number of expired fragment queues. */ - NSS_IPV6_REASM_STATS_DISCARDS, - /**< Number of fragment queues discarded due to malformed fragments. */ - NSS_IPV6_REASM_STATS_MAX, - /**< Maximum message type. */ -}; - -/** - * nss_ipv6_reasm_stats_notification - * Data for sending IPv6 reassembly statistics. - */ -struct nss_ipv6_reasm_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint64_t cmn_node_stats[NSS_STATS_NODE_MAX]; /**< Common node statistics. */ - uint64_t ipv6_reasm_stats[NSS_IPV6_REASM_STATS_MAX]; /**< IPv6 reassembly statistics. */ -}; - -#ifdef __KERNEL__ - -/** - * nss_ipv6_reasm_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_ipv6_reasm_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_ipv6_reasm_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_ipv6_reasm_stats_unregister_notifier(struct notifier_block *nb); -#endif - -/** - * @} - */ - -#endif /* __NSS_IPV6_REASM_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_l2tpv2.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_l2tpv2.h deleted file mode 100644 index e36c8504f..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_l2tpv2.h +++ /dev/null @@ -1,327 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_l2tpv2.h - * NSS L2TPv2 interface definitions. - */ - -#ifndef _NSS_L2TP_V2_H_ -#define _NSS_L2TP_V2_H_ - -/** - * @addtogroup nss_l2tpv2_subsystem - * @{ - */ - -/** - * Maximum number of supported L2TPv2 sessions. - */ -#define NSS_MAX_L2TPV2_DYNAMIC_INTERFACES 4 - -/** - * nss_l2tpv2_metadata_types - * Message types for L2TPv2 requests and responses. - */ -enum nss_l2tpv2_metadata_types { - NSS_L2TPV2_MSG_SESSION_CREATE, - NSS_L2TPV2_MSG_SESSION_DESTROY, - NSS_L2TPV2_MSG_SYNC_STATS, - NSS_L2TPV2_MSG_BIND_IPSEC_IF, - NSS_L2TPV2_MSG_MAX -}; - -/** - * nss_l2tpv2_stats_session - * L2TPv2 debug statistics. - */ -enum nss_l2tpv2_stats_session { - NSS_L2TPV2_STATS_SESSION_RX_PPP_LCP_PKTS, /**< Number of PPP LCP packets received. */ - NSS_L2TPV2_STATS_SESSION_RX_EXP_DATA_PKTS, /**< Number of Rx exceptioned packets. */ - NSS_L2TPV2_STATS_SESSION_ENCAP_PBUF_ALLOC_FAIL_PKTS, /**< Number of times packet buffer allocation failed during encapsulation. */ - NSS_L2TPV2_STATS_SESSION_DECAP_PBUF_ALLOC_FAIL_PKTS, /*< Number of times packet buffer allocation failed during decapsulation. */ - NSS_L2TPV2_STATS_SESSION_DECAP_L2TPOIPSEC_SRC_ERR, - /**< Number of packets dropped due to source error in L2TP over IPsec flow in decapsulation. */ - NSS_L2TPV2_STATS_SESSION_MAX /**< Maximum message type. */ -}; - -/** - * nss_l2tpv2_stats_notification - * L2TPv2 statistics structure. - */ -struct nss_l2tpv2_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint32_t if_num; /**< Interface number. */ - uint64_t stats[NSS_L2TPV2_STATS_SESSION_MAX]; /**< L2TPv2 statistics. */ -}; - -#ifdef __KERNEL__ /* only kernel will use. */ -/** - * nss_l2tpv2_session_create_msg - * Payload for creating an L2TPv2 session. - */ -struct nss_l2tpv2_session_create_msg { - uint16_t local_tunnel_id; /**< Local identifier for the control connection. */ - uint16_t local_session_id; /**< Local identifier of session inside a tunnel. */ - uint16_t peer_tunnel_id; /**< Remote identifier for the control connection. */ - uint16_t peer_session_id; /**< Remote identifier of session inside a tunnel. */ - - uint32_t sip; /**< Local tunnel endpoint IP address. */ - uint32_t dip; /**< Remote tunnel endpoint IP address. */ - uint32_t reorder_timeout; /**< Reorder timeout for out of order packets */ - - uint16_t sport; /**< Local source port. */ - uint16_t dport; /**< Remote source port. */ - - uint8_t recv_seq; /**< Sequence number received. */ - uint8_t oip_ttl; /**< Maximum time-to-live value for outer IP packet. */ - uint8_t udp_csum; /**< UDP checksum. */ - uint8_t reserved; /**< Alignment padding. */ -}; - -/** - * nss_l2tpv2_session_destroy_msg - * Payload for deletion an L2TPv2 session. - */ -struct nss_l2tpv2_session_destroy_msg { - uint16_t local_tunnel_id; /**< ID of the local tunnel. */ - uint16_t local_session_id; /**< ID of the local session. */ -}; - -/** - * nss_l2tpv2_bind_ipsec_if_msg - * Message for binding the IPsec interface with L2TP. - * - * Message for configuring the L2TP session with an - * IPsec inner interface number. This is used when - * L2TP tunnel is enabled with IPsec. - */ -struct nss_l2tpv2_bind_ipsec_if_msg { - uint32_t ipsec_ifnum; /**< Inner IPSec interface number. */ -}; - -/** - * nss_l2tpv2_sync_session_stats_msg - * Message information for L2TPv2 synchronization statistics. - */ -struct nss_l2tpv2_sync_session_stats_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - uint32_t rx_errors; /**< Not used. Reserved for backward compatibility. */ - uint32_t rx_seq_discards; - /**< Rx packets discarded because of a sequence number check. */ - uint32_t rx_oos_packets; /**< Number of out of sequence packets received. */ - uint32_t tx_errors; /**< Not used. Reserved for backward compatibility. */ - uint32_t tx_dropped; /**< Tx packets dropped because of encapsulation failure or next node's queue is full. */ - - /** - * Debug statistics for L2tp v2. - */ - struct { - uint32_t rx_ppp_lcp_pkts; - /**< Number of PPP LCP packets received. */ - uint32_t rx_exception_data_pkts; - /**< Data packet exceptions sent to the host. */ - uint32_t encap_pbuf_alloc_fail; - /**< Buffer allocation failure during encapsulation. */ - uint32_t decap_pbuf_alloc_fail; - /**< Buffer allocation failure during decapsulation. */ - uint32_t decap_l2tpoipsec_src_error; - /**< Packets dropped due to the wrong source for the L2TPoIPsec flow. */ - } debug_stats; /**< Debug statistics object for l2tp v2. */ -}; - -/** - * nss_l2tpv2_msg - * Data for sending and receiving L2TPv2 messages. - */ -struct nss_l2tpv2_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of an L2TPv2 message. - */ - union { - struct nss_l2tpv2_session_create_msg session_create_msg; - /**< Session create message. */ - struct nss_l2tpv2_session_destroy_msg session_destroy_msg; - /**< Session delete message. */ - struct nss_l2tpv2_sync_session_stats_msg stats; - /**< Session statistics. */ - struct nss_l2tpv2_bind_ipsec_if_msg bind_ipsec_if_msg; - /**< Bind IPsec interface message. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving L2TPv2 messages. - * - * @datatypes - * nss_l2tpv2_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_l2tpv2_msg_callback_t)(void *app_data, struct nss_l2tpv2_msg *msg); - -/** - * nss_l2tpv2_tx - * Sends L2TPv2 messages to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_l2tpv2_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_l2tpv2_tx(struct nss_ctx_instance *nss_ctx, struct nss_l2tpv2_msg *msg); - -/** - * nss_l2tpv2_get_context. - * Gets the L2TPv2 context used in L2TPv2 messages sent to the NSS. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_l2tpv2_get_context(void); - -/** - * Callback function for receiving L2TPv2 tunnel 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_l2tpv2_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_register_l2tpv2_if - * Registers the L2TPv2 tunnel interface with the NSS for sending and - * receiving messages. - * - * @datatypes - * nss_l2tpv2_callback_t \n - * nss_l2tpv2_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] l2tpv2_callback Callback for the L2TP tunnel data. - * @param[in] msg_callback Callback for the L2TP tunnel message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features SKB types supported by this interface. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_register_l2tpv2_if(uint32_t if_num, nss_l2tpv2_callback_t l2tpv2_callback, - nss_l2tpv2_msg_callback_t msg_callback, struct net_device *netdev, uint32_t features); - -/** - * nss_unregister_l2tpv2_if - * Deregisters the L2TPv2 tunnel interface from the NSS. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - * - * @dependencies - * The tunnel interface must have been previously registered. - */ -extern void nss_unregister_l2tpv2_if(uint32_t if_num); - -/** - * nss_l2tpv2_msg_init - * Initializes an L2TPv2 message. - * - * @datatypes - * nss_l2tpv2_msg - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num Interface number - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -extern void nss_l2tpv2_msg_init(struct nss_l2tpv2_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); - -/** - * nss_l2tpv2_register_handler - * Registers the L2TPv2 interface with the NSS debug statistics handler. - * - * @return - * None. - */ -extern void nss_l2tpv2_register_handler(void); - -/** - * nss_l2tpv2_session_debug_stats_get - * Gets L2TPv2 NSS session debug statistics. - * - * @param[out] stats_mem Pointer to the memory address, which must be large - * enough to hold all the statistics. - * - * @return - * None. - */ -extern void nss_l2tpv2_session_debug_stats_get(void *stats_mem); - -/** - * nss_l2tpv2_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_l2tpv2_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_l2tpv2_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_l2tpv2_stats_unregister_notifier(struct notifier_block *nb); -#endif /*__KERNEL__ */ - -/** - * @} - */ - -#endif /* _NSS_L2TP_V2_H_ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_lag.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_lag.h deleted file mode 100644 index 4e7e7ea25..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_lag.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2014, 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_lag.h - * NSS LAG APIs - */ - -/** - * @addtogroup nss_lag_subsystem - * @{ - */ - -/** - * nss_lag_metadata_types - * Types of LAG metadata. - */ -enum nss_lag_metadata_types { - NSS_TX_METADATA_LAG_STATE_CHANGE = 0, - NSS_TX_METADATA_LAG_MAX, -}; - -/** - * nss_lag_state_change_ev - * LAG change events. - */ -enum nss_lag_state_change_ev { - NSS_LAG_RELEASE = 0, - NSS_LAG_ENSLAVE = 1, -}; - -/** - * nss_lag_error_types - * LAG return values. - */ -enum nss_lag_error_types { - NSS_LAG_ERROR_EINTERFACE = 1, - NSS_LAG_ERROR_EMSG = 2, -}; - -/** - * nss_lag_state_change - * Link aggregation (LAG) state changes. - */ -struct nss_lag_state_change { - uint32_t lagid; /**< ID of the link aggregation group. */ - uint32_t interface; - /**< Physical interface on which the state change occurred. */ - enum nss_lag_state_change_ev event; /**< Type of state change event. */ -}; - -/** - * nss_lag_msg - * Data for sending and receiving LAG messages. - */ -struct nss_lag_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a LAG message. - */ - union { - struct nss_lag_state_change state; - /**< State change message. */ - } msg; /**< Message payload for LAG configuration messages exchanged with NSS core. */ -}; - -/** - * nss_lag_tx - * Sends a LAG message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_lag_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_lag_tx(struct nss_ctx_instance *nss_ctx, struct nss_lag_msg *msg); - -/** - * Callback function for receiving LAG data. - * - * @datatypes - * net_device \n - * sk_buff \n - * napi_struct - * - * @param[in] dev 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_lag_callback_t)(struct net_device *dev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback function for receiving a LAG message. - * - * @datatypes - * nss_lag_msg - * - * @param[in] ctx Pointer to the application context for this message. - * @param[in] nm Pointer to the message data. - */ -typedef void (*nss_lag_msg_callback_t)(void *ctx, struct nss_lag_msg *nm); - -/** - * Callback function for receiving a LAG event. - * - * @datatypes - * nss_lag_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_lag_event_callback_t)(void *app_data, struct nss_lag_msg *msg); - -/** - * nss_register_lag_if - * Registers the LAG interface with the NSS for sending and receiving data - * and messages. - * - * @datatypes - * nss_lag_callback_t \n - * nss_lag_event_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] lag_cb Callback to receive LAG data. - * @param[in] lag_ev_cb Callback to receive LAG events. - * @param[in] netdev Pointer to the associated network device. - * - * @return - * Pointer to the NSS core context. - */ -extern void *nss_register_lag_if(uint32_t if_num, - nss_lag_callback_t lag_cb, - nss_lag_event_callback_t lag_ev_cb, - struct net_device *netdev); - -/** - * nss_unregister_lag_if - * Deregisters the LAG interface from the NSS. - * - * @param[in] if_num LAG interface number - * - * @return - * None. - * - * @dependencies - * The LAG interface must have been previously registered. - */ -extern void nss_unregister_lag_if(uint32_t if_num); - -/** - * nss_lag_msg_init - * Initializes a LAG message. - * - * @datatypes - * nss_lag_msg \n - * nss_lag_msg_callback_t - * - * @param[in,out] nlm Pointer to the message. - * @param[in] lag_num LAG interface number. - * @param[in] type Type of buffer. - * @param[in] len Length of the buffer. - * @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_lag_msg_init(struct nss_lag_msg *nlm, uint16_t lag_num, uint32_t type, uint32_t len, - nss_lag_msg_callback_t cb, void *app_data); - -/** - * nss_lag_tx_slave_state - * Sends LAG slave state. - * - * @datatypes - * nss_lag_state_change_ev - * - * @param[in] lagid LAG Group ID. - * @param[in] slave_ifnum Slave interface number. - * @param[in] slave_state Slave state. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_lag_tx_slave_state(uint16_t lagid, - int32_t slave_ifnum, - enum nss_lag_state_change_ev slave_state); - -/** - * @} - */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_lso_rx.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_lso_rx.h deleted file mode 100644 index e8f4babae..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_lso_rx.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_lso_rx.h - * NSS driver LSO (Large Send Offload) Rx header file. - */ - -#ifndef __NSS_LSO_RX_H -#define __NSS_LSO_RX_H - -/** - * @addtogroup nss_lso_rx_subsystem - * @{ - */ - -/** - * nss_lso_rx_stats_types - * LSO Rx driver statistics. - */ -enum nss_lso_rx_stats_types { - NSS_LSO_RX_STATS_TX_DROPPED, /**< Number of packets dropped because transmit queue is full. */ - NSS_LSO_RX_STATS_DROPPED, /**< Number of packets dropped because of node internal errors. */ - NSS_LSO_RX_STATS_PBUF_ALLOC_FAIL, /**< Number of pbuf allocation failures. */ - NSS_LSO_RX_STATS_PBUF_REFERENCE_FAIL, /**< Number of pbuf reference failures. */ - NSS_LSO_RX_STATS_MAX, /**< Maximum message type. */ -}; - -/** - * nss_lso_rx_stats_notification - * Data for sending LSO Rx statistics. - */ -struct nss_lso_rx_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint64_t cmn_node_stats[NSS_STATS_NODE_MAX]; /**< Common node statistics. */ - uint64_t node_stats[NSS_LSO_RX_STATS_MAX]; /**< LSO Rx special statistics. */ -}; - -#ifdef __KERNEL__ /* only kernel will use. */ -/** - * nss_lso_rx_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_lso_rx_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_lso_rx_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_lso_rx_stats_unregister_notifier(struct notifier_block *nb); -#endif /*__KERNEL__ */ - -/** - * @} - */ - -#endif /* __NSS_LSO_RX_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_map_t.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_map_t.h deleted file mode 100644 index ebfd62f4f..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_map_t.h +++ /dev/null @@ -1,382 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_map_t.h - * NSS MAP-T interface definitions. - */ - -#ifndef _NSS_MAP_T_H_ -#define _NSS_MAP_T_H_ - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -#include "nss_dynamic_interface.h" -#endif - -/** - * @addtogroup nss_map_t_subsystem - * @{ - */ - -/** - * Maximum number of supported MAP-T instances. - */ -#define NSS_MAX_MAP_T_DYNAMIC_INTERFACES 4 - -#define NSS_MAPT_MDATA_FLAG_DF_BIT (1 << 0) - -/* - * mapt meta data - */ -struct nss_map_t_mdata { - uint16_t flags; - uint16_t res[6]; -}; - -/** - * nss_map_t_msg_types - * Message types for MAP-T requests and responses. - */ -enum nss_map_t_msg_types { - NSS_MAP_T_MSG_INSTANCE_RULE_CONFIGURE, - NSS_MAP_T_MSG_INSTANCE_RULE_DECONFIGURE, - NSS_MAP_T_MSG_SYNC_STATS, - NSS_MAP_T_MSG_MAX -}; - -/** - * nss_map_t_stats_instance - * MAP-T debug error types. - */ -enum nss_map_t_stats_instance { - NSS_MAP_T_STATS_V4_TO_V6_PBUF_EXCEPTION, - NSS_MAP_T_STATS_V4_TO_V6_PBUF_NO_MATCHING_RULE, - NSS_MAP_T_STATS_V4_TO_V6_PBUF_NOT_TCP_OR_UDP, - NSS_MAP_T_STATS_V4_TO_V6_RULE_ERR_LOCAL_PSID, - NSS_MAP_T_STATS_V4_TO_V6_RULE_ERR_LOCAL_IPV6, - NSS_MAP_T_STATS_V4_TO_V6_RULE_ERR_REMOTE_PSID, - NSS_MAP_T_STATS_V4_TO_V6_RULE_ERR_REMOTE_EA_BITS, - NSS_MAP_T_STATS_V4_TO_V6_RULE_ERR_REMOTE_IPV6, - NSS_MAP_T_STATS_V6_TO_V4_PBUF_EXCEPTION, - NSS_MAP_T_STATS_V6_TO_V4_PBUF_NO_MATCHING_RULE, - NSS_MAP_T_STATS_V6_TO_V4_PBUF_NOT_TCP_OR_UDP, - NSS_MAP_T_STATS_V6_TO_V4_RULE_ERR_LOCAL_IPV4, - NSS_MAP_T_STATS_V6_TO_V4_RULE_ERR_REMOTE_IPV4, - NSS_MAP_T_STATS_MAX -}; - -/** - * nss_map_t_stats_notification - * MAP-T statistics structure. - */ -struct nss_map_t_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint32_t if_num; /**< Interface number. */ - enum nss_dynamic_interface_type if_type; /**< Dynamic interface type. */ - uint64_t stats[NSS_MAP_T_STATS_MAX]; /**< MAP-T statistics. */ -}; - -#ifdef __KERNEL__ /* only kernel will use. */ -/** - * nss_map_t_instance_rule_config_msg - * Message information for configuring a MAP-T instance. - */ -struct nss_map_t_instance_rule_config_msg { - uint32_t rule_num; /**< Rule sequence number */ - uint32_t total_rules; /**< Total number of NAT64 rules configured. */ - uint32_t local_ipv6_prefix_len; /**< Local IPv6 prefix length. */ - uint32_t local_ipv4_prefix; /**< Local IPv4 prefix. */ - uint32_t local_ipv4_prefix_len; /**< Local IPv4 prefix length. */ - uint32_t local_ea_len; /**< Local EA bits length. */ - uint32_t local_psid_offset; /**< Local PSID offset. */ - - uint32_t reserve_a; /**< Reserved for backward compatibility. */ - - uint32_t remote_ipv6_prefix_len; /**< Remote IPv6 prefix length. */ - uint32_t remote_ipv4_prefix; /**< Remote IPv4 prefix. */ - uint32_t remote_ipv4_prefix_len; /**< Remote IPv4 prefix length. */ - uint32_t remote_ea_len; /**< Remote EA bits length. */ - uint32_t remote_psid_offset; /**< Remote PSID offset. */ - - uint32_t local_map_style; /**< Local MAP style. */ - uint32_t remote_map_style; /**< Remote MAP style. */ - - uint32_t sibling_if; /**< Sibling interface number. */ - - uint8_t local_ipv6_prefix[16]; /**< Local IPv6 prefix. */ - uint8_t reserve_b[16]; /**< Reserved for backward compatibility. */ - uint8_t remote_ipv6_prefix[16]; /**< Remote IPv6 prefix. */ - - uint8_t valid_rule; /**< MAP-T rule validity. */ - uint8_t flags; /**< MAP-T flags. */ - uint8_t reserved[2]; /**< Reserved for byte alignment. */ -}; - -/** - * nss_map_t_instance_rule_deconfig_msg - * Message information for deleting a MAP-T instance. - */ -struct nss_map_t_instance_rule_deconfig_msg { - int32_t if_number; /**< Interface number. */ -}; - -/** - * nss_map_t_sync_stats_msg - * Message information for MAP-T synchronization statistics. - */ -struct nss_map_t_sync_stats_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - uint32_t tx_dropped; /**< Dropped Tx packets. */ - - /** - * Debug statistics for MAP-T. - */ - union { - - /** - * IPv4 to IPv6 path debug statistics. - */ - struct { - uint32_t exception_pkts; - /**< Number of packets exceptioned to host in IPv4 to IPv6 fast path. */ - uint32_t no_matching_rule; - /**< No matching of any rule. */ - uint32_t not_tcp_or_udp; - /**< Number of packets which are neither UDP nor TCP. */ - uint32_t rule_err_local_psid; - /**< Calculate the local PSID error. */ - uint32_t rule_err_local_ipv6; - /**< Calculate local IPv6 error. */ - uint32_t rule_err_remote_psid; - /**< Calculate remote PSID error. */ - uint32_t rule_err_remote_ea_bits; - /**< Calculate remote EA bits error. */ - uint32_t rule_err_remote_ipv6; - /**< Calculate remote IPv6 error. */ - } v4_to_v6; /**< IPv4 to IPv6 debug statistics object. */ - - /** - * IPv6 to IPv4 path debug statistics. - */ - struct { - uint32_t exception_pkts; - /**< Number of packets exception to host in IPv6 to IPv4 fast path. */ - uint32_t no_matching_rule; - /**< No matching of any rule. */ - uint32_t not_tcp_or_udp; - /**< Number of packets which are neither UDP nor TCP. */ - uint32_t rule_err_local_ipv4; - /**< Calculate local IPv4 error. */ - uint32_t rule_err_remote_ipv4; - /**< Calculate remote IPv4 error. */ - } v6_to_v4; /**< IPv6 to IPv4 debug statistics object */ - - } debug_stats; /**< Payload of debug statistics. */ -}; - -/** - * nss_map_t_msg - * Data for sending and receiving MAP-T messages. - */ -struct nss_map_t_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a MAP-T message. - */ - union { - struct nss_map_t_instance_rule_config_msg create_msg; - /**< Create message. */ - struct nss_map_t_instance_rule_deconfig_msg destroy_msg; - /**< Destroy message. */ - struct nss_map_t_sync_stats_msg stats; - /**< Statistics message to host. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving MAP-T messages. - * - * @datatypes - * nss_map_t_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_map_t_msg_callback_t)(void *app_data, struct nss_map_t_msg *msg); - -/** - * nss_map_t_tx - * Sends a MAP-T message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_map_t_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_map_t_tx(struct nss_ctx_instance *nss_ctx, struct nss_map_t_msg *msg); - -/** - * nss_map_t_tx_sync - * Sends a MAP-T message synchronously to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_map_t_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_map_t_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_map_t_msg *msg); - -/** - * nss_map_t_get_context - * Gets the MAP-T context used in nss_map_t_tx. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_map_t_get_context(void); - -/** - * Callback function for receiving MAP-T tunnel 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_map_t_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_map_t_register_if - * Registers a MAP-T interface with the NSS for sending and receiving tunnel messages. - * - * @datatypes - * nss_map_t_callback_t \n - * nss_map_t_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] type NSS interface type. - * @param[in] map_t_callback Callback for the MAP-T data. - * @param[in] msg_callback Callback for the MAP-T message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_map_t_register_if(uint32_t if_num, uint32_t type, nss_map_t_callback_t map_t_callback, - nss_map_t_msg_callback_t msg_callback, struct net_device *netdev, uint32_t features); - -/** - * nss_map_t_unregister_if - * Deregisters a MAP-T tunnel interface from the NSS. - * - * @param[in] if_num NSS interface number - * - * @return - * None. - */ -extern void nss_map_t_unregister_if(uint32_t if_num); - -/** - * nss_map_t_msg_init - * Initializes a MAP-T message. - * - * @datatypes - * nss_map_t_msg_init - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num Interface number - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -extern void nss_map_t_msg_init(struct nss_map_t_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); - -/** - * nss_map_t_register_handler - * Registers the MAP-T debug statistics handler with the NSS. - * - * @return - * None. - */ -extern void nss_map_t_register_handler(void); - -/** - * nss_map_t_instance_debug_stats_get - * Gets debug statistics for a MAP-T instance. - * - * @param[out] stats_mem Pointer to the memory address, which must be large enough to - hold all the statistics. - * - * @return - * None. - */ -extern void nss_map_t_instance_debug_stats_get(void *stats_mem); - -/** - * nss_map_t_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_map_t_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_map_t_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_map_t_stats_unregister_notifier(struct notifier_block *nb); -#endif /*__KERNEL__ */ - -/** - * @} - */ - -#endif /* _NSS_MAP_T_H_ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_match.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_match.h deleted file mode 100644 index ae1e30855..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_match.h +++ /dev/null @@ -1,296 +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. - ************************************************************************** - */ - -/** - * @file nss_match.h - * NSS match interface definitions. - */ - -#ifndef _NSS_MATCH_H_ -#define _NSS_MATCH_H_ - - -/** - * @addtogroup nss_match_subsystem - * @{ - */ - -/** - * Maximum number of supported match instances. - */ -#define NSS_MATCH_INSTANCE_MAX 4 - -/** - * Maximum number of rules supported per instance. - */ -#define NSS_MATCH_INSTANCE_RULE_MAX 32 - -/** - * Maximum number of masksets. - */ -#define NSS_MATCH_MASK_MAX 2 - -/** - * Maximum number of words per maskset. - */ -#define NSS_MATCH_MASK_WORDS_MAX 4 - -/** - * nss_match_error_type - * Match message error types. - */ -typedef enum nss_match_error_type { - NSS_MATCH_SUCCESS, /**< No error. */ - NSS_MATCH_ERROR_UNKNOWN_MSG, /**< Message unknown. */ - NSS_MATCH_ERROR_DSCP_OUTOFBOUND, /**< DSCP out of bound. */ - NSS_MATCH_ERROR_OUTER_8021P_OUTOFBOUND, /**< Outer 802.1p out of bound. */ - NSS_MATCH_ERROR_INNER_8021P_OUTOFBOUND, /**< Inner 802.1p out of bound. */ - NSS_MATCH_ERROR_RULE_ID_OUTOFBOUND, /**< Rule ID is out of bound. */ - NSS_MATCH_ERROR_ACTION_TYPE_INVALID, /**< Invalid action type. */ - NSS_MATCH_ERROR_RULE_EXISTS, /**< Rule ID already in use. */ - NSS_MATCH_ERROR_RULE_DOES_NOT_EXIST, /**< Rule does not exist. */ - NSS_MATCH_ERROR_INSTANCE_CONFIGURED, /**< Error in instance configuration. */ - NSS_MATCH_ERROR_PROFILE_CONFIG_INVALID, /**< Invalid profile configuration message. */ - NSS_MATCH_ERROR_DB_INIT_FAILED, /**< Database initialization failed. */ - NSS_MATCH_ERROR_TABLE_ID_OUTOFBOUND, /**< Table ID is out of bound. */ - NSS_MATCH_ERROR_RULE_ADD, /**< Error in adding rule. */ - NSS_MATCH_ERROR_RULE_DELETE, /**< Error in deleting rule. */ - NSS_MATCH_ERROR_TABLE_ADD, /**< Error in adding table. */ - NSS_MATCH_ERROR_TABLE_DELETE, /**< Error in deleting table. */ - NSS_MATCH_ERROR_MASK_ID_OUTOFBOUND, /**< Mask ID is out of bound. */ - NSS_MATCH_ERROR_IFNUM_INVALID, /**< Next node interface number is invalid. */ - NSS_MATCH_ERROR_MAX, /**< Maximum error. */ -} nss_match_status_t; - -/** - * nss_match_action_type - * Bit positions for possible actions that can be taken. - */ -enum nss_match_action_type { - NSS_MATCH_ACTION_NONE, /**< No action. */ - NSS_MATCH_ACTION_SETPRIO = 1, /**< Set given priority to the packet. */ - NSS_MATCH_ACTION_FORWARD = 2, /**< Forward the packet to a given node. */ - NSS_MATCH_ACTION_DROP = 4, /**< Drop the packet. */ - NSS_MATCH_ACTION_MAX, /**< Maximum action type. */ -}; - -/** - * nss_match_profile_type - * Different profile types. - */ -enum nss_match_profile_type { - NSS_MATCH_PROFILE_TYPE_NONE, - NSS_MATCH_PROFILE_TYPE_VOW, /**< Matches on interface number/DSCP/802.1P. */ - NSS_MATCH_PROFILE_TYPE_L2, /**< Matches on interface number/destination MAC/source MAC/Ether type. */ - NSS_MATCH_PROFILE_TYPE_MAX, /**< Maximum profile type. */ -}; - -/** - * nss_match_msg_types. - * Message types for match requests and responses. - */ -enum nss_match_msg_types { - NSS_MATCH_INSTANCE_NONE, /**< Invalid message. */ - NSS_MATCH_TABLE_CONFIGURE_MSG, /**< Instance configure. */ - NSS_MATCH_ADD_VOW_RULE_MSG, /**< Insert VoW rule. */ - NSS_MATCH_ADD_L2_RULE_MSG, /**< Insert l2 rule. */ - NSS_MATCH_DELETE_VOW_RULE_MSG, /**< Delete VoW rule. */ - NSS_MATCH_DELETE_L2_RULE_MSG, /**< Delete l2 rule. */ - NSS_MATCH_STATS_SYNC, /**< Instance statistics. */ - NSS_MATCH_MSG_MAX, /**< Maximum instance messages. */ -}; - -/** - * nss_match_stats_sync - * Synchronization message structure. - */ -struct nss_match_stats_sync { - struct nss_cmn_node_stats p_stats; /**< Pnode statistics. */ - uint32_t hit_count[NSS_MATCH_INSTANCE_RULE_MAX]; /**< Exception events. */ -}; - -/** - * nss_match_profile_configure_msg - * Message for configuring the profile for a match instance. - */ -struct nss_match_profile_configure_msg { - uint32_t profile_type; /**< Profile type. */ - uint32_t valid_mask_flag; /**< Valid maskset flag. */ - uint32_t maskset[NSS_MATCH_MASK_MAX][NSS_MATCH_MASK_WORDS_MAX]; /**< Maskset. */ -}; - -/* - * nss_match_rule_action - * Message information for action. - */ -struct nss_match_rule_action { - uint32_t action_flag; /**< Action bit map. */ - uint32_t forward_ifnum; /**< Next node interface number. */ - uint16_t setprio; /**< Priority number to be set in packet. */ - uint16_t reserved; /**< Reserved 2 bytes. */ -}; - -/** - * nss_match_rule_vow_msg - * Rule message for VoW profile. - */ -struct nss_match_rule_vow_msg { - uint16_t rule_id; /**< Rule ID for the rule. */ - uint16_t mask_id; /**< Mask number used for the rule. */ - struct nss_match_rule_action action; /**< Action related with the rule. */ - uint32_t if_num; /**< Interface number. */ - uint8_t dscp; /**< DSCP. */ - uint8_t outer_8021p; /**< Outer 802.1p. */ - uint8_t inner_8021p; /**< Inner 802.1p. */ - uint8_t reserved; /**< Reserved byte. */ -}; - -/** - * nss_match_rule_l2_msg - * Rule message for L2 profile. - */ -struct nss_match_rule_l2_msg { - uint16_t rule_id; /**< Rule ID for the rule. */ - uint16_t mask_id; /**< Mask number used for the rule. */ - struct nss_match_rule_action action; /**< Action related with the rule. */ - uint32_t if_num; /**< Interface number. */ - uint16_t dmac[3]; /**< Destination MAC address. */ - uint16_t smac[3]; /**< Source MAC address. */ - uint16_t ethertype; /**< Ethernet type. */ -}; - -/** - * nss_match_msg - * Data for sending and receiving match messages. - */ -struct nss_match_msg { - struct nss_cmn_msg cm; /**< Message header. */ - - /** - * Payload of a match message. - */ - union { - struct nss_match_profile_configure_msg configure_msg; /**< Configure message. */ - struct nss_match_rule_vow_msg vow_rule; /**< Insertion or deletion message for VoW profile. */ - struct nss_match_rule_l2_msg l2_rule; /**< Insertion or deletion message for l2 profile. */ - struct nss_match_stats_sync stats; /**< Instance synchronization statistics. */ - } msg; /**< Message payload. */ -}; - -/** - * nss_match_msg_tx_sync - * Sends proxy match messages to the NSS. - * - * Do not call this function from a softirq or interrupt because it - * might sleep if the NSS firmware is busy serving another host thread. - * - * @datatypes - * nss_ctx_instance \n - * nss_match_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_match_msg_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_match_msg *msg); - -/** - * Callback function for receiving match messages. - * - * @datatypes - * nss_match_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_match_msg_sync_callback_t)(void *app_data, struct nss_match_msg *msg); - -/** - * nss_match_get_context - * Returns NSS context of match. - * - * @datatypes - * nss_ctx_instance - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_match_get_context(void); - -/** - * nss_match_register_instance - * Registers match dynamic node to NSS. - * - * @datatypes - * nss_match_msg_sync_callback_t - * - * @param[in] if_num Interface number of match instance. - * @param[in] notify_cb Notify callback function for the message. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_match_register_instance(int if_num, nss_match_msg_sync_callback_t notify_cb); - -/** - * nss_match_unregister_instance - * Unregisters match dynamic node to NSS. - * - * @param[in] if_num Interface number of match instance. - * - * @return - * True if successful, else false. - */ -extern bool nss_match_unregister_instance(int if_num); - -/** - * nss_match_msg_init - * Initializes a match message. - * - * @datatypes - * nss_match_msg \n - * nss_match_msg_sync_callback_t - * - * @param[in,out] nmm Pointer to the 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_match_msg_init(struct nss_match_msg *nmm, uint16_t if_num, uint32_t type, uint32_t len, - nss_match_msg_sync_callback_t cb, void *app_data); - -/** - * nss_match_init - * Initializes match. - * - * @return - * None. - */ -extern void nss_match_init(void); -/** - * @} - */ - -#endif /* _NSS_MATCH_H_ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_mirror.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_mirror.h deleted file mode 100644 index 39853e5ce..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_mirror.h +++ /dev/null @@ -1,317 +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. - ************************************************************************** - */ - -/** - * @file nss_mirror.h - * NSS mirror interface definitions. - */ - -#ifndef _NSS_MIRROR_H_ -#define _NSS_MIRROR_H_ - -/** - * @addtogroup nss_mirror_subsystem - * @{ - */ - -/** - * Maximum number of supported mirror interfaces. - */ -#define NSS_MAX_MIRROR_DYNAMIC_INTERFACES 8 - -/** - * nss_mirror_msg_types - * Message types for mirror interface requests and responses. - */ -enum nss_mirror_msg_types { - NSS_MIRROR_MSG_CONFIGURE, /**< Configure message type. */ - NSS_MIRROR_MSG_ENABLE, /**< Enable message type. */ - NSS_MIRROR_MSG_DISABLE, /**< Disable message type. */ - NSS_MIRROR_MSG_SET_NEXTHOP, /**< Set nexthop message type. */ - NSS_MIRROR_MSG_RESET_NEXTHOP, /**< Reset nexthop message type. */ - NSS_MIRROR_MSG_SYNC_STATS, /**< Statistics synchronization message type. */ - NSS_MIRROR_MSG_MAX /**< Maximum message type. */ -}; - -/** - * nss_mirror_pkt_clone_point - * Clone point to use for mirroring the packet. - */ -enum nss_mirror_pkt_clone_point { - NSS_MIRROR_PKT_CLONE_POINT_DEFAULT = 1, /**< Clone the packet from the start. */ - NSS_MIRROR_PKT_CLONE_POINT_BEFORE_PACKET_START, /**< Clone n-bytes before packet start. */ - NSS_MIRROR_PKT_CLONE_POINT_AFTER_PACKET_START, /**< Clone n-bytes after packet start. */ - NSS_MIRROR_PKT_CLONE_POINT_MAX -}; - -/** - * nss_mirror_error_type - * Error types for mirror responses to messages from the host. - */ -enum nss_mirror_error_type { - NSS_MIRROR_ERROR_TYPE_NONE, /**< No error. */ - NSS_MIRROR_ERROR_TYPE_NO_MEMORY, /**< No memory to copy. */ - NSS_MIRROR_ERROR_TYPE_TX_FAILURE, /**< Transmit failure. */ - NSS_MIRROR_ERROR_TYPE_BAD_PARAM, /**< Bad parameter. */ - NSS_MIRROR_ERROR_TYPE_BAD_CLONE_POINT, /**< Bad packet clone point. */ - NSS_MIRROR_ERROR_TYPE_INSTANCE_CONFIGURED, /**< Instance already active. */ - NSS_MIRROR_ERROR_TYPE_INSTANCE_DISABLED, /**< Instance already disabled. */ - NSS_MIRROR_ERROR_TYPE_BAD_NEXTHOP, /**< Incorrect nexthop interface. */ - NSS_MIRROR_ERROR_TYPE_NEXTHOP_CONFIGURED, /**< Nexthop already interface. */ - NSS_MIRROR_ERROR_TYPE_NEXTHOP_RESET, /**< Nexthop already reset. */ - NSS_MIRROR_ERROR_TYPE_UNKNOWN_MSG, /**< Unknown message. */ - NSS_MIRROR_ERROR_TYPE_MAX, /**< Maximum message 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. - */ -struct nss_mirror_configure_msg { - uint32_t pkt_clone_point; /**< Point in the packet to copy from. */ - uint16_t pkt_clone_size; /**< Number of bytes to copy. */ - uint16_t pkt_clone_offset; /**< Copy offset. */ -}; - -/** - * nss_mirror_set_nexthop_msg - * Mirror interface set nexthop information. - */ -struct nss_mirror_set_nexthop_msg { - uint32_t if_num; /**< Nexthop interface number. */ -}; - -/** - * nss_mirror_node_stats - * Mirror interface debug statistics structure. - */ -struct nss_mirror_node_stats { - uint32_t mirror_pkts; /**< Number of packets exceptioned to host. */ - uint32_t mirror_bytes; /**< Number of bytes exceptioned to host. */ - uint32_t tx_send_fail; /**< Transmit send failures. */ - uint32_t dest_lookup_fail; /**< Destination lookup failures. */ - uint32_t mem_alloc_fail; /**< Memory allocation failures. */ - uint32_t copy_fail; /**< Copy failures. */ - uint32_t bad_param; /**< Bad parameter. */ -}; - -/** - * nss_mirror_stats_sync_msg - * Message information for mirror interface synchronization statistics. - */ -struct nss_mirror_stats_sync_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - struct nss_mirror_node_stats mirror_stats; /**< Debug statistics for mirror. */ -}; - -/** - * 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. - */ -struct nss_mirror_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a mirror interface message. - */ - union { - struct nss_mirror_configure_msg config; - /**< Mirror interface configure message. */ - struct nss_mirror_set_nexthop_msg nexthop; - /**< Mirror interface set nexthop message. */ - struct nss_mirror_stats_sync_msg stats; - /**< Statistics message to host. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving mirror instance 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_mirror_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback function for receiving mirror interface 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_mirror_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * nss_mirror_get_context - * Gets the mirror interface context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_mirror_get_context(void); - -/** - * nss_mirror_tx_msg - * Sends mirror interface messages to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_mirror_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_mirror_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_mirror_msg *msg); - -/** - * nss_mirror_tx_msg_sync - * Sends a mirror interface message to the NSS synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_mirror_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_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. - * - * @datatypes - * nss_mirror_data_callback_t \n - * nss_mirror_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] data_callback Callback for the mirror interface data. - * @param[in] event_callback Callback for the mirror interface message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_mirror_register_if(uint32_t if_num, - nss_mirror_data_callback_t data_callback, - nss_mirror_msg_callback_t event_callback, - struct net_device *netdev, uint32_t features); - -/** - * nss_mirror_verify_if_num - * Verify whether the interface is an mirror interface or not. - * - * @param[in] if_num NSS interface number. - * - * @return - * True if the interface is an mirror interface. - */ -extern bool nss_mirror_verify_if_num(uint32_t if_num); - -/** - * nss_mirror_register_handler - * Registers the mirror interface debug statistics handler with the NSS. - * - * @return - * None. - */ -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 diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_n2h.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_n2h.h deleted file mode 100644 index 1613f41c0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_n2h.h +++ /dev/null @@ -1,572 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_n2h.h - * NSS to HLOS interface definitions. - */ - -#ifndef __NSS_N2H_H -#define __NSS_N2H_H - -/** - * @addtogroup nss_n2h_subsystem - * @{ - */ - -#define MAX_PAGES_PER_MSG 32 /**< Maximum number of pages per message. */ -#define NSS_N2H_RPS_PRI_DEFAULT -1 /**< Default RPS priority mapping. */ - -/** - * nss_n2h_payload_info - * Payload configuration based on the watermark. - */ -struct nss_n2h_payload_info { - uint32_t pool_size; /**< Empty buffer pool size. */ - - /** - * Low watermark. - * Set this field to 0 for the system to automatically determine the watermark. - */ - uint32_t low_water; - - /** - * High watermark. - * Set this field to 0 for the system to automatically determine the watermark. - */ - uint32_t high_water; -}; - -#ifdef __KERNEL__ /* only kernel will use. */ - -/** - * nss_n2h_cfg_pvt - * N2H private data configuration. - */ -struct nss_n2h_cfg_pvt { - struct semaphore sem; /**< Semaphore for SMP synchronization. */ - struct completion complete; /**< Waits for the NSS to process the message. */ - 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 response; /**< Response from the firmware. */ -}; - -#endif /*__KERNEL__ */ - -/** - * nss_n2h_stats_types - * N2H node statistics. - */ -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. */ - NSS_N2H_STATS_PBUF_OCM_ALLOC_FAILS_WITH_PAYLOAD, - /**< Number of pbuf OCM allocations that have failed with payload. */ - 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. */ - NSS_N2H_STATS_PBUF_DEFAULT_ALLOC_FAILS_WITH_PAYLOAD, - /**< Number of pbuf default allocations that have failed with payload. */ - NSS_N2H_STATS_PBUF_DEFAULT_ALLOC_FAILS_NO_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_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_MAX, /**< Maximum message type. */ -}; - -/** - * nss_n2h_metadata_types - * Message types for N2H requests and responses. - */ -enum nss_n2h_metadata_types { - NSS_RX_METADATA_TYPE_N2H_STATS_SYNC = 0, - NSS_TX_METADATA_TYPE_N2H_RPS_CFG, - NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG, - NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS, - NSS_TX_METADATA_TYPE_N2H_MITIGATION_CFG, - NSS_METADATA_TYPE_N2H_ADD_BUF_POOL, - NSS_TX_METADATA_TYPE_SET_WATER_MARK, - NSS_TX_METADATA_TYPE_GET_WATER_MARK, - NSS_TX_METADATA_TYPE_N2H_WIFI_POOL_BUF_CFG, - NSS_TX_DDR_INFO_VIA_N2H_CFG, - NSS_TX_METADATA_TYPE_N2H_SET_PNODE_QUEUE_CFG, - NSS_TX_METADATA_TYPE_N2H_EMPTY_PAGED_POOL_BUF_CFG, - NSS_TX_METADATA_TYPE_SET_PAGED_WATER_MARK, - NSS_TX_METADATA_TYPE_GET_PAGED_WATER_MARK, - NSS_TX_METADATA_TYPE_N2H_RPS_PRI_MAP_CFG, - 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_METADATA_TYPE_N2H_MAX, -}; - -/* - * nss_n2h_error_types - * N2H error types. - */ -enum nss_n2h_error_types { - N2H_EUNKNOWN = 1, - N2H_ALREADY_CFG, - N2H_LOW_WATER_MIN_INVALID, - N2H_HIGH_WATER_LESS_THAN_LOW, - N2H_HIGH_WATER_LIMIT_INVALID, - N2H_LOW_WATER_LIMIT_INVALID, - N2H_WATER_MARK_INVALID, - N2H_EMPTY_BUFFER_TOO_HIGH, - N2H_EMPTY_BUFFER_TOO_LOW, - N2H_MMU_ENTRY_IS_INVALID, - N2H_PN_QUEUE_SET_FAILED, - N2H_PAGES_PER_MSG_EXCEEDED, - N2H_RPS_PRI_MAP_TOO_HIGH, -}; - -/** - * nss_n2h_stats_notification - * N2H statistics structure. - */ -struct nss_n2h_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint64_t n2h_stats[NSS_N2H_STATS_MAX]; /**< N2H statistics. */ - uint64_t drv_stats[NSS_STATS_DRV_MAX]; /**< Driver statistics. */ -}; - -/** - * nss_n2h_rps - * N2H RPS configuration. - */ -struct nss_n2h_rps { - uint32_t enable; /**< Enable RPS. */ -}; - -/** - * nss_n2h_rps_pri_map - * N2H priority configuration. - * - * This is used to direct packets with a given priority to a specific host CPU. - * A value of -1 in pri_map[pri] is treated as invalid and will not override - * RPS for that priority. - */ -struct nss_n2h_rps_pri_map { - int32_t pri_map[NSS_MAX_NUM_PRI]; /**< Priority to RPS map. */ -}; - -/** - * nss_n2h_mitigation - * N2H mitigation configuration. - */ -struct nss_n2h_mitigation { - uint32_t enable; /**< Enable NSS mitigation. */ -}; - -/** - * nss_n2h_buf_pool - * N2H buffer pool configuration. - */ -struct nss_n2h_buf_pool { - uint32_t nss_buf_page_size; /**< Size of the buffer page. */ - uint32_t nss_buf_num_pages; /**< Number of buffer pages. */ - - uint32_t nss_buf_pool_addr[MAX_PAGES_PER_MSG]; - /**< Buffer addresses. */ - nss_ptr_t nss_buf_pool_vaddr[MAX_PAGES_PER_MSG]; - /**< Virtual addresses of the buffers. */ -#ifndef __LP64__ - uint32_t padding[MAX_PAGES_PER_MSG]; - /**< Pad to fit 64 bits, do not reuse. */ -#endif -}; - -/** - * nss_n2h_pnode_queue_config - * Queue configuration command for pnodes in NSS. - */ -struct nss_n2h_pnode_queue_config { - uint8_t mq_en; /**< Enable multiple queues. */ - uint8_t reserved[3]; /**< Reserved for alignment. */ - uint16_t qlimits[NSS_MAX_NUM_PRI]; - /**< Limits of each queue. */ -#if (NSS_MAX_NUM_PRI & 1) - uint16_t reserved2; -#endif -}; - -/** - * nss_n2h_empty_pool_buf - * Old way of setting the number of empty pool buffers (payloads). - * - * The NSS firmware sets the low watermark to n -- ring_size, and the high - * watermark to n + ring_size. - */ -struct nss_n2h_empty_pool_buf { - uint32_t pool_size; /**< Size of the empty buffer pool. */ -}; - -/** - * nss_n2h_water_mark - * New way of setting the low and high watermarks in the NSS firmware. - */ -struct nss_n2h_water_mark { - /** - * Low watermark. - * Lower threshold for the number of payloads that can be held by NSS firmware. - * Setting this value to 0 gets the system to automatically determine the watermark. - */ - uint32_t low_water; - - /** - * High watermark. - * Upper threshold for the number of paylods that be held by the NSS firmware. - * Setting this value to 0 gets the system to automatically determine the watermark. - */ - uint32_t high_water; -}; - -/** - * nss_n2h_flush_payloads - * Flush payload configuration. - */ -struct nss_n2h_flush_payloads { - uint32_t reserved; /**< Reserved for future use. */ -}; - -/** - * nss_n2h_wifi_payloads - * Payloads required for Wi-Fi offloading. - */ -struct nss_n2h_wifi_payloads { - uint32_t payloads; /**< Number of payloads for Wi-Fi use. */ -}; - -/** - * nss_n2h_pbuf_mgr_stats - * Payload buffer manager statistics. - */ -struct nss_n2h_pbuf_mgr_stats { - uint32_t pbuf_total_count; /**< Total number of buffers, free or in use. */ - uint32_t pbuf_free_count; /**< Number of currently free buffers. */ - uint32_t pbuf_alloc_fails_with_payload; - /**< Number of buffer allocation failures. */ - uint32_t pbuf_alloc_fails_no_payload; - /**< Number of buffer allocation failures without payload. */ -}; - -/** - * nss_n2h_paged_buffer_pool_init - * Paged buffer configuration initialization. - */ -struct nss_n2h_paged_buffer_pool_init { - uint32_t reserved; /**< Reserved for future use. */ -}; - -/** - * nss_n2h_stats_sync - * N2H synchronization statistics. - */ -struct nss_n2h_stats_sync { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - uint32_t queue_dropped; - /**< Number of packets dropped because the N2H queue is too full. */ - uint32_t total_ticks; /**< Total clock ticks spent inside the N2H handler. */ - uint32_t worst_case_ticks; /**< Worst case iteration of the N2H handler in ticks. */ - uint32_t iterations; /**< Number of iterations around the N2H handler. */ - - struct nss_n2h_pbuf_mgr_stats pbuf_ocm_stats; - /**< Statistics for on-chip memory payload buffers. */ - struct nss_n2h_pbuf_mgr_stats pbuf_default_stats; - /**< Statistics for DDR memory payload buffers. */ - - uint32_t payload_alloc_fails; /**< Number of payload allocation failures. */ - uint32_t payload_free_count; /**< Number of free payloads. */ - - uint32_t h2n_ctrl_pkts; /**< Control packets received from the HLOS. */ - uint32_t h2n_ctrl_bytes; /**< Control bytes received from the HLOS. */ - uint32_t n2h_ctrl_pkts; /**< Control packets sent to the HLOS. */ - uint32_t n2h_ctrl_bytes; /**< Control bytes sent to the HLOS. */ - - uint32_t h2n_data_pkts; /**< Data packets received from the HLOS. */ - uint32_t h2n_data_bytes; /**< Data bytes received from the HLOS. */ - uint32_t n2h_data_pkts; /**< Data packets sent to the HLOS. */ - uint32_t n2h_data_bytes; /**< Data bytes sent to the HLOS. */ - uint32_t tot_payloads; /**< Total number of payloads in the NSS firmware. */ - - /** - * Number of data packets with invalid interface received from the host. - */ - uint32_t data_interface_invalid; - uint32_t enqueue_retries; /**< Number of times N2H retried enqueue to next node. */ -}; - -/** - * nss_mmu_ddr_info - * System DDR memory information required by the firmware MMU to set range guards. - */ -struct nss_mmu_ddr_info { - uint32_t ddr_size; /**< Total size of the DDR. */ - uint32_t start_address; /**< System start address. */ - uint32_t num_active_cores; - /**< Number of active cores. */ - uint32_t nss_ddr_size; /**< Total memory for NSS SoC. */ -}; - -/** - * nss_n2h_queue_limit_config - * Queue length limit for N2H node. - */ -struct nss_n2h_queue_limit_config { - uint32_t qlimit; /**< Queue length size. */ -}; - -/** - * nss_n2h_host_back_pressure - * Host back pressure configuration. - */ -struct nss_n2h_host_back_pressure { - uint32_t enable; /**< Enable host back pressure. */ -}; - -/** - * nss_n2h_msg - * Data for sending and receiving N2H messages. - */ -struct nss_n2h_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of an N2H message. - */ - union { - struct nss_n2h_stats_sync stats_sync; - /**< N2H statistics synchronization. */ - struct nss_n2h_rps rps_cfg; - /**< RPS configuration. */ - struct nss_n2h_rps_pri_map rps_pri_map; - /**< RPS priority map. */ - struct nss_n2h_empty_pool_buf empty_pool_buf_cfg; - /**< Empty pool buffer configuration. */ - struct nss_n2h_empty_pool_buf empty_paged_pool_buf_cfg; - /**< Empty paged pool buffer configuration. */ - struct nss_n2h_flush_payloads flush_payloads; - /**< Flush payloads present in the NSS. */ - struct nss_n2h_mitigation mitigation_cfg; - /**< Mitigation configuration. */ - struct nss_n2h_buf_pool buf_pool; - /**< Pool buffer coniguration. */ - struct nss_n2h_water_mark wm; - /**< Sets low and high watermarks. */ - struct nss_n2h_water_mark wm_paged; - /**< Sets low and high watermarks for paged pool. */ - struct nss_n2h_payload_info payload_info; - /**< Gets the payload information. */ - struct nss_n2h_payload_info paged_payload_info; - /**< Gets the paged payload information. */ - struct nss_n2h_wifi_payloads wp; - /**< Sets the number of Wi-Fi payloads. */ - struct nss_mmu_ddr_info mmu; - /**< Gets the DDR size and start address to configure the MMU. */ - struct nss_n2h_pnode_queue_config pn_q_cfg; - /**< Pnode queueing configuration. */ - struct nss_n2h_queue_limit_config ql_cfg; - /**< Queue limit configuration. */ - struct nss_n2h_paged_buffer_pool_init paged_buffer_pool_init; - /**< Paged buffer pool initialization. */ - struct nss_n2h_host_back_pressure host_bp_cfg; - /**< Host back pressure configuration. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving N2H messages. - * - * @datatypes - * nss_n2h_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the N2H message. - */ -typedef void (*nss_n2h_msg_callback_t)(void *app_data, struct nss_n2h_msg *msg); - -/** - * nss_n2h_tx_msg - * Sends messages to the N2H package. - * - * @datatypes - * nss_ctx_instance \n - * nss_n2h_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] nnm Pointer to the N2H message. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_n2h_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_n2h_msg *nnm); - -/** - * nss_n2h_single_core_register_sysctl - * Registers the N2H sysctl entry to the sysctl tree for a single-core system. - * - * @return - * None. - */ -extern void nss_n2h_single_core_register_sysctl(void); - -/** - * nss_n2h_multi_core_register_sysctl - * Registers the N2H sysctl entry to the sysctl tree for a multi-core system. - * - * @return - * None. - */ -extern void nss_n2h_multi_core_register_sysctl(void); - -/** - * nss_n2h_unregister_sysctl - * Deregisters the N2H sysctl entry from the sysctl tree. - * - * @return - * None. - * - * @dependencies - * The system control must have been previously registered. - */ -extern void nss_n2h_unregister_sysctl(void); - -/** - * nss_n2h_flush_payloads - * Sends flush payloads message to NSS - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_n2h_flush_payloads(struct nss_ctx_instance *nss_ctx); - -/** - * nss_n2h_msg_init - * Initializes messages from the host to the NSS. - * - * @datatypes - * nss_n2h_msg \n - * nss_n2h_msg_callback_t - * - * @param[in,out] nim 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_n2h_msg_init(struct nss_n2h_msg *nim, uint16_t if_num, uint32_t type, uint32_t len, - nss_n2h_msg_callback_t cb, void *app_data); - -/** - * nss_n2h_update_queue_config_sync - * Synchrounous method to update pnode queue configuration to NSS. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] mq_en Enable multiple pnode queues. - * @param[in] qlimits Maximum number of packets in each queues. - * - * @return - * Status of the configuration update operation. - */ -extern nss_tx_status_t nss_n2h_update_queue_config_sync(struct nss_ctx_instance *nss_ctx, bool mq_en, uint16_t *qlimits); - -/** - * nss_n2h_update_queue_config_async - * Asynchrounous method to update pnode queue configuration to NSS. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] mq_en Enable multiple pnode queues. - * @param[in] qlimits Maximum number of packets in each queues. - * - * @return - * Status of the configuration update operation. - */ -extern nss_tx_status_t nss_n2h_update_queue_config_async(struct nss_ctx_instance *nss_ctx, bool mq_en, uint16_t *qlimits); - -#ifdef __KERNEL__ /* only kernel will use. */ - -/** - * nss_n2h_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_n2h_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_n2h_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_n2h_stats_unregister_notifier(struct notifier_block *nb); - -#endif /*__KERNEL__ */ - -/** - * @} - */ - -#endif /* __NSS_N2H_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_oam.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_oam.h deleted file mode 100644 index af25e3703..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_oam.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_oam.h - * NSS OAM - Operations, Administration and Maintenance Service - */ - -#ifndef __NSS_OAM_H -#define __NSS_OAM_H - -/** - * @addtogroup nss_oam_subsystem - * @{ - */ - -#define NSS_OAM_FW_VERSION_LEN 132 /**< Size of the OAM firmware version. */ - -/** - * nss_oam_msg_types - * OAM command types. - * - * The OAM proxy sends these command messages to the NSS OAM server via the OAM adapter. - */ -enum nss_oam_msg_types { - NSS_OAM_MSG_TYPE_NONE, - NSS_OAM_MSG_TYPE_GET_FW_VER, - NSS_OAM_MSG_TYPE_MAX, -}; - -/** - * nss_oam_error - * OAM error responses. - */ -enum nss_oam_error { - NSS_OAM_ERROR_NONE, - NSS_OAM_ERROR_INVAL_MSG_TYPE, - NSS_OAM_ERROR_INVAL_MSG_LEN, - NSS_OAM_ERROR_MAX, -}; - -/** - * nss_oam_fw_ver - * OAM firmware version. - */ -struct nss_oam_fw_ver { - uint8_t string[NSS_OAM_FW_VERSION_LEN]; /**< OAM firmware version. */ -}; - -/** - * nss_oam_msg - * Data for sending and receiving OAM messages. - */ -struct nss_oam_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of an OAM message. - */ - union { - struct nss_oam_fw_ver fw_ver; - /**< Firmware version. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving OAM messages. - * - * @datatypes - * nss_oam_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_oam_msg_callback_t)(void *app_data, struct nss_oam_msg *msg); - -/** - * nss_oam_tx_msg - * Transmits an OAM message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_oam_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_oam_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_oam_msg *msg); - -/** - * nss_oam_notify_register - * Registers a notifier callback with the NSS for sending and receiving OAM messages. - * - * @datatypes - * nss_oam_msg_callback_t - * - * @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. - */ -extern struct nss_ctx_instance *nss_oam_notify_register(nss_oam_msg_callback_t cb, void *app_data); - -/** - * nss_oam_notify_unregister - * Deregisters an OAM message notifier callback from the NSS. - * - * @return - * None. - */ -extern void nss_oam_notify_unregister(void); - -/** - * nss_register_oam_if - * Registers the OAM interface handler with the NSS. - * - * @param[in] if_number Interface number of the OAM interface. - * - * @return - * Boolean status of handler registration - */ -extern bool nss_register_oam_if(uint16_t if_number); - -/** - * @} - */ - -#endif /* __NSS_OAM_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_phy_if.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_phy_if.h deleted file mode 100644 index cc52d86f0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_phy_if.h +++ /dev/null @@ -1,67 +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. - ************************************************************************** - */ - -/** - * @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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_pm.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_pm.h deleted file mode 100644 index 8e0cce88d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_pm.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2013-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. - */ - -/* - * @file nss_pm.h - * NSS power management definitions. - */ - -#ifndef __NSS_PM_H -#define __NSS_PM_H - -/** - * @addtogroup nss_pm_subsystem - * @{ - */ - -/** - * nss_pm_client - * Power management (PM) clients. - * - * These clients can query for bus or clock performance levels. - */ -typedef enum nss_pm_client { - NSS_PM_CLIENT_GMAC, - NSS_PM_CLIENT_CRYPTO, - NSS_PM_CLIENT_NETAP, - NSS_PM_MAX_CLIENTS, -} nss_pm_client_t; - -/** - * nss_pm_perf_level - * Performance levels. - * - * This enumeration is passed as a parameter to NSS PM performance-level - * requests. - */ -typedef enum nss_pm_perf_level { - NSS_PM_PERF_LEVEL_SUSPEND = 0, - NSS_PM_PERF_LEVEL_IDLE, - NSS_PM_PERF_LEVEL_NOMINAL, - NSS_PM_PERF_LEVEL_TURBO, - NSS_PM_PERF_MAX_LEVELS, -} nss_pm_perf_level_t; - -/** - * nss_pm_interface_status_t - * Status of the PM client interface. - */ -typedef enum { - NSS_PM_API_SUCCESS = 0, - NSS_PM_API_FAILED, -} nss_pm_interface_status_t; - -/** - * nss_pm_client_register - * Registers a power management driver client. - * - * @datatypes - * nss_pm_client_t - * - * @param[in] client_id ID of the client driver. - * - * @return - * None. - */ -extern void *nss_pm_client_register(nss_pm_client_t client_id); - -/** - * nss_pm_client_unregister - * Deregisters a power management driver client. - * - * @datatypes - * nss_pm_client_t - * - * @param[in] client_id ID of the client driver. - * - * @return - * None. - */ -int nss_pm_client_unregister(nss_pm_client_t client_id); - -/** - * nss_pm_set_perf_level - * Updates the bus bandwidth level for a client. - * - * @datatypes - * nss_pm_perf_level_t - * - * @param[in,out] handle Handle of the client. - * @param[in,out] lvl Performance level. - * - * @return - * None. - */ -extern nss_pm_interface_status_t nss_pm_set_perf_level(void *handle, nss_pm_perf_level_t lvl); - -/** - * @} - */ - -#endif /* __NSS_PM_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_portid.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_portid.h deleted file mode 100644 index 61e8ac6d8..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_portid.h +++ /dev/null @@ -1,284 +0,0 @@ -/* - ************************************************************************** - * 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_portid.h - * NSS Port ID interface definitions. - */ - -#ifndef __NSS_PORTID_H -#define __NSS_PORTID_H - -/** - * @addtogroup nss_portid_subsystem - * @{ - */ - -/** - * Maximum number of ports on the S17c switch chip. - * - * If a new switch has more ports than S17c, this value must be updated. - */ -#define NSS_PORTID_MAX_SWITCH_PORT 7 - -/** - * nss_portid_msg_types - * Message types for port ID requests and responses. - */ -enum nss_portid_msg_types { - NSS_PORTID_CONFIGURE_MSG, - NSS_PORTID_UNCONFIGURE_MSG, - NSS_PORTID_STATS_SYNC_MSG, - NSS_PORTID_MAX_MSG_TYPE -}; - -/** - * nss_portid_configure_msg - * Message information for configuring a port ID. - */ -struct nss_portid_configure_msg { - uint32_t port_if_num; - /**< Interface number corresponding to the port ID of the device. */ - uint8_t port_id; /**< ID of the mapped switch port. */ - uint8_t gmac_id; /**< ID of the mapped GMAC interface. */ - uint8_t reserved[2]; /**< Reserved for word alignment. */ -}; - -/** - * nss_portid_unconfigure_msg - * Message information for deleting a port ID. - */ -struct nss_portid_unconfigure_msg { - uint32_t port_if_num; - /**< Interface number corresponding to the port ID of the device. */ - uint8_t port_id; /**< ID of the mapped switch port. */ - uint8_t reserved[3]; /**< Reserved for word alignment. */ -}; - -/** - * nss_portid_stats_sync_msg - * Message information for port ID synchronization statistics. - */ -struct nss_portid_stats_sync_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - uint32_t rx_invalid_header; /**< Rx with an invalid header. */ - uint8_t port_id; /**< ID of the mapped switch port. */ - uint8_t reserved[3]; /**< Reserved for word alignment. */ -}; - -/** - * nss_portid_msg - * Data for sending and receiving port ID messages. - */ -struct nss_portid_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a port ID message. - */ - union { - struct nss_portid_configure_msg configure; - /**< Port ID configuration information. */ - struct nss_portid_unconfigure_msg unconfigure; - /**< Port ID de-configuration information. */ - struct nss_portid_stats_sync_msg stats_sync; - /**< Synchronization statistics for the port ID. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving port ID messages. - * - * @datatypes - * nss_portid_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] npm Pointer to the NSS Profiler message. - */ -typedef void (*nss_portid_msg_callback_t)(void *app_data, struct nss_portid_msg *npm); - -/** - * Callback function for receiving port ID interface 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_portid_buf_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_portid_get_stats - * Gets statistics from a port interface. - * - * @datatypes - * rtnl_link_stats64 - * - * @param[in] if_num NSS interface number. - * @param[out] stats Container for the statistic counters. - * - * @return - * TRUE or FALSE. - */ -bool nss_portid_get_stats(uint32_t if_num, struct rtnl_link_stats64 *stats); - -/** - * nss_portid_msg_init - * Initializes a port ID message. - * - * @datatypes - * nss_portid_msg \n - * nss_portid_msg_callback_t - * - * @param[in,out] npm Pointer to the NSS port ID 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_portid_msg_init(struct nss_portid_msg *npm, uint16_t if_num, uint32_t type, uint32_t len, - nss_portid_msg_callback_t cb, void *app_data); - -/** - * nss_portid_if_tx_data - * Transmits a data packet to the NSS port ID interface. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] os_buf Pointer to the OS data buffer. - * @param[in] if_num NSS interface number. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_portid_if_tx_data(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, uint32_t if_num); - -/** - * nss_portid_tx_msg - * Sends a port ID message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_portid_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_portid_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_portid_msg *msg); - -/** - * nss_portid_tx_msg_sync - * Sends a port ID message to the NSS and waits for a response. - * - * @datatypes - * nss_ctx_instance \n - * nss_portid_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in,out] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_portid_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_portid_msg *msg); - -/** - * nss_portid_register_port_if - * Registers the port interface with the NSS. - * - * @datatypes - * net_device \n - * nss_portid_buf_callback_t - * - * @param[in] if_num NSS interface number. - * @param[in] port_id Physical port ID of this interface. - * @param[in] ndev Pointer to the associated network device. - * @param[in] buf_cb Callback for the data. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_portid_register_port_if(uint32_t if_num, uint32_t port_id, struct net_device *ndev, nss_portid_buf_callback_t buf_cb); - -/** - * nss_portid_unregister_port_if - * Deregisters the port interface from the NSS. - * - * @param[in] if_num NSS interface number. - * - * @return - * TRUE or FALSE. - * - * @dependencies - * The interface must have been previously registered. - */ -extern bool nss_portid_unregister_port_if(uint32_t if_num); - -/** - * nss_portid_tx_configure_port_if_msg - * Sends a port interface configuration message to the NSS. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] port_if_num Interface number of the port node. - * @param[in] port_id ID of the mapped switch port. - * @param[in] gmac_id ID of the mapped GMAC interface. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_portid_tx_configure_port_if_msg(struct nss_ctx_instance *nss_ctx, uint32_t port_if_num, uint8_t port_id, uint8_t gmac_id); - -/** - * nss_portid_tx_unconfigure_port_if_msg - * Sends a port interface de-configuration message to the NSS. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] port_if_num Interface number of the port node. - * @param[in] port_id ID of the mapped switch port. - * - * @return - * Status of the Tx operation. - * - * @dependencies - * The interface must have been previously configured. - */ -extern nss_tx_status_t nss_portid_tx_unconfigure_port_if_msg(struct nss_ctx_instance *nss_ctx, uint32_t port_if_num, uint8_t port_id); - -/** - * @} - */ - -#endif /* __NSS_PORTID_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ppe.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_ppe.h deleted file mode 100644 index 648bb6638..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ppe.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2016-2018, 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. - ************************************************************************** - */ - -/** - * @file nss_ppe.h - * NSS PPE interface definitions. - */ - -#ifndef _NSS_PPE_H_ -#define _NSS_PPE_H_ - -typedef int32_t nss_ppe_port_t; - -/** - * @addtogroup nss_ppe_subsystem - * @{ - */ - -/* - * NSS PORT defines - */ -#define NSS_PPE_NUM_PHY_PORTS_MAX 8 - /**< Maximum number of PPE physical ports. */ -#define NSS_PPE_PORT_IPSEC 7 - /**< Port number of PPE inline IPsec port. */ - -/** - * nss_ppe_sc_type - * PPE service code types. - */ -enum nss_ppe_sc_type { - NSS_PPE_SC_NONE, /**< Normal PPE processing. */ - NSS_PPE_SC_BYPASS_ALL, /**< Bypasses all stages in PPE. */ - NSS_PPE_SC_ADV_QOS_BRIDGED, /**< Advance QoS redirection for bridged flow. */ - NSS_PPE_SC_BR_QOS, /**< Bridge QoS redirection. */ - NSS_PPE_SC_BNC_0, /**< QoS bounce. */ - NSS_PPE_SC_BNC_CMPL_0, /**< QoS bounce complete. */ - NSS_PPE_SC_ADV_QOS_ROUTED, /**< Advance QoS redirection for routed flow. */ - NSS_PPE_SC_IPSEC_PPE2EIP, /**< Inline IPsec redirection from PPE-to-EIP. */ - NSS_PPE_SC_IPSEC_EIP2PPE, /**< Inline IPsec redirection from EIP-to-PPE. */ - 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_ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ppe_vp.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_ppe_vp.h deleted file mode 100644 index 64e1f5ecf..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_ppe_vp.h +++ /dev/null @@ -1,79 +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. - ************************************************************************** - */ - -/** - * @file nss_ppe_vp.h - * NSS PPE Virtual Port definitions. - */ - -#ifndef _NSS_PPE_VP_H_ -#define _NSS_PPE_VP_H_ - -/** - * nss_if_ppe_vp_destroy - * Destroy the PPE VP for a given NSS interface number. - * - * @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_ppe_vp_destroy(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num); - -/** - * nss_ppe_vp_create - * Create the PPE VP for a given NSS interface number. - * - * @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_ppe_vp_create(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num); - -/** - * nss_ppe_vp_get_ppe_port_by_nssif - * Returns the PPE VP number for a given NSS interface number. - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] nss_if NSS interface number. - * - * @return - * Returns the PPE VP number corresponding to the NSS interface number. - */ -nss_ppe_port_t nss_ppe_vp_get_ppe_port_by_nssif(struct nss_ctx_instance *nss_ctx, nss_if_num_t nss_if); - -/** - * nss_ppe_vp_get_context - * Return the NSS context of PPE VP. - * - * @datatypes - * nss_ctx_instance - * - * @return - * Pointer to the NSS core context. - */ -struct nss_ctx_instance *nss_ppe_vp_get_context(void); - -#endif /* _NSS_PPE_VP_H_ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_pppoe.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_pppoe.h deleted file mode 100644 index f082d3067..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_pppoe.h +++ /dev/null @@ -1,384 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_pppoe.h - * NSS PPPoE interface definitions. - */ - -#ifndef __NSS_PPPOE_H -#define __NSS_PPPOE_H - -/** - * @addtogroup nss_pppoe_subsystem - * @{ - */ - -/** - * Maximum number of supported PPPoE sessions. - */ -#define NSS_MAX_PPPOE_DYNAMIC_INTERFACES 8 - -/** - * nss_pppoe_metadata_types - * Message types for PPPoE requests and responses. - */ -enum nss_pppoe_metadata_types { - NSS_PPPOE_MSG_SESSION_CREATE, - NSS_PPPOE_MSG_SESSION_DESTROY, - NSS_PPPOE_MSG_SYNC_STATS, - NSS_PPPOE_MSG_BR_ACCEL_CFG, - NSS_PPPOE_MSG_MAX -}; - -/** - * nss_pppoe_session_exception_events - * Session exception events from the PPPoE handler. - */ -enum nss_pppoe_session_exception_events { - NSS_PPPOE_SESSION_EXCEPTION_EVENT_WRONG_VERSION_OR_TYPE, - NSS_PPPOE_SESSION_EXCEPTION_EVENT_WRONG_CODE, - NSS_PPPOE_SESSION_EXCEPTION_EVENT_UNSUPPORTED_PPP_PROTOCOL, - NSS_PPPOE_SESSION_EXCEPTION_EVENT_MAX -}; - -/** - * pppoe_base_exception_events - * Base node exception events from the PPPoE handler. - */ -enum nss_pppoe_base_exception_events { - NSS_PPPOE_BASE_EXCEPTION_EVENT_SHORT_PPPOE_HDR_LENGTH, - NSS_PPPOE_BASE_EXCEPTION_EVENT_SHORT_PACKET_LENGTH, - NSS_PPPOE_BASE_EXCEPTION_EVENT_WRONG_VERSION_OR_TYPE, - NSS_PPPOE_BASE_EXCEPTION_EVENT_WRONG_CODE, - NSS_PPPOE_BASE_EXCEPTION_EVENT_UNSUPPORTED_PPP_PROTOCOL, - NSS_PPPOE_BASE_EXCEPTION_EVENT_DISABLED_BRIDGE_PACKET, - NSS_PPPOE_BASE_EXCEPTION_EVENT_MAX -}; - -/** - * nss_pppoe_br_accel_mode - * PPPoE bridge acceleration modes. - */ -enum nss_pppoe_br_accel_modes { - NSS_PPPOE_BR_ACCEL_MODE_DIS, - NSS_PPPOE_BR_ACCEL_MODE_EN_5T, - NSS_PPPOE_BR_ACCEL_MODE_EN_3T, - NSS_PPPOE_BR_ACCEL_MODE_MAX -}; - -/** - * nss_pppoe_base_stats - * PPPoE base node synchronization statistics. - */ -struct nss_pppoe_base_stats { - struct nss_cmn_node_stats node; /**< Common node statistics. */ - uint32_t exception[NSS_PPPOE_BASE_EXCEPTION_EVENT_MAX]; - /**< PPPoE base node exception events. */ -}; - -/** - * nss_pppoe_session_stats - * PPPoE synchronization statistics per session. - */ -struct nss_pppoe_session_stats { - struct nss_cmn_node_stats node; /**< Common node statistics. */ - uint32_t exception[NSS_PPPOE_SESSION_EXCEPTION_EVENT_MAX]; - /**< PPPoE session exception events. */ -}; - -/** - * nss_pppoe_stats_session - * PPPoE session statistics. - */ -enum nss_pppoe_stats_session { - NSS_PPPOE_STATS_SESSION_RX_PACKETS, - NSS_PPPOE_STATS_SESSION_RX_BYTES, - NSS_PPPOE_STATS_SESSION_TX_PACKETS, - NSS_PPPOE_STATS_SESSION_TX_BYTES, - NSS_PPPOE_STATS_SESSION_WRONG_VERSION_OR_TYPE, - NSS_PPPOE_STATS_SESSION_WRONG_CODE, - NSS_PPPOE_STATS_SESSION_UNSUPPORTED_PPP_PROTOCOL, - NSS_PPPOE_STATS_SESSION_MAX -}; - -/** - * nss_pppoe_stats_base - * PPPoE base node statistics. - */ -enum nss_pppoe_stats_base { - NSS_PPPOE_STATS_BASE_RX_PACKETS, - NSS_PPPOE_STATS_BASE_RX_BYTES, - NSS_PPPOE_STATS_BASE_TX_PACKETS, - NSS_PPPOE_STATS_BASE_TX_BYTES, - NSS_PPPOE_STATS_BASE_RX_QUEUE_0_DROPPED, - NSS_PPPOE_STATS_BASE_RX_QUEUE_1_DROPPED, - NSS_PPPOE_STATS_BASE_RX_QUEUE_2_DROPPED, - NSS_PPPOE_STATS_BASE_RX_QUEUE_3_DROPPED, - NSS_PPPOE_STATS_BASE_SHORT_PPPOE_HDR_LENGTH, - NSS_PPPOE_STATS_BASE_SHORT_PACKET_LENGTH, - NSS_PPPOE_STATS_BASE_WRONG_VERSION_OR_TYPE, - NSS_PPPOE_STATS_BASE_WRONG_CODE, - NSS_PPPOE_STATS_BASE_UNSUPPORTED_PPP_PROTOCOL, - NSS_PPPOE_STATS_BASE_DISABLED_BRIDGE_PACKET, - NSS_PPPOE_STATS_BASE_MAX -}; - -/** - * nss_pppoe_stats_notification - * PPPoE statistics structure. - */ -struct nss_pppoe_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint32_t if_num; /**< Interface number. */ - uint64_t session_stats[NSS_PPPOE_STATS_SESSION_MAX]; /**< PPPoE statistics. */ - uint64_t base_stats[NSS_PPPOE_STATS_BASE_MAX]; /**< PPPoE base node statistics. */ -}; - -#ifdef __KERNEL__ /* only kernel will use. */ - -/** - * nss_pppoe_sync_stats_msg - * PPPoE synchronization statistics. - */ -struct nss_pppoe_sync_stats_msg { - struct nss_pppoe_session_stats session_stats; /**< Session statistics. */ - struct nss_pppoe_base_stats base_stats; /**< Base node statistics. */ -}; - -/** - * nss_pppoe_destroy_msg - * PPPoE session destroy message. - */ -struct nss_pppoe_destroy_msg { - uint16_t session_id; /**< PPPoE session identification number. */ - uint8_t server_mac[ETH_ALEN]; /**< PPPoE server MAC address. */ - uint8_t local_mac[ETH_ALEN]; /**< Local physical interface MAC address. */ -}; - -/** - * nss_pppoe_create_msg - * PPPoE session create message. - */ -struct nss_pppoe_create_msg { - int32_t base_if_num; /**< Base NSS interface number which PPPoE session created on. */ - uint32_t mtu; /**< PPPoE interface MTU value. */ - uint8_t server_mac[ETH_ALEN]; /**< PPPoE server MAC address. */ - uint8_t local_mac[ETH_ALEN]; /**< Local physical interface MAC address. */ - uint16_t session_id; /**< PPPoE session identification number. */ -}; - -/** - * nss_pppoe_br_accel_cfg_msg - * PPPoE bridge acceleration configuration message. - */ -struct nss_pppoe_br_accel_cfg_msg { - uint32_t br_accel_cfg; /**< PPPoE bridge acceleration configuration. */ -}; - -/** - * nss_pppoe_msg - * Data for sending and receiving PPPoE messages. - */ -struct nss_pppoe_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a PPPoE message. - */ - union { - struct nss_pppoe_create_msg create; - /**< Session create message. */ - struct nss_pppoe_destroy_msg destroy; - /**< Session destroy message. */ - struct nss_pppoe_sync_stats_msg sync_stats; - /**< Session statistics message. */ - struct nss_pppoe_br_accel_cfg_msg br_accel; - /**< PPPoE bridge acceleration configuration message. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving PPPoE messages. - * - * @datatypes - * nss_pppoe_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_pppoe_msg_callback_t)(void *app_data, struct nss_pppoe_msg *msg); - -/** - * nss_pppoe_tx_msg_sync - * Sends a PPPoE message synchronously to NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_pppoe_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_pppoe_tx_msg_sync(struct nss_ctx_instance *nss_ctx, - struct nss_pppoe_msg *msg); - -/** - * nss_register_pppoe_session_if - * Registers the PPPoE session interface with the NSS for sending and - * receiving messages. - * - * @datatypes - * nss_pppoe_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] notification_callback Callback for the message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Socket buffer types supported by this interface. - * @param[in] app_ctx Pointer to the application context of the message. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_register_pppoe_session_if(uint32_t if_num, - nss_pppoe_msg_callback_t notification_callback, - struct net_device *netdev, uint32_t features, void *app_ctx); - -/** - * nss_unregister_pppoe_session_if - * Deregisters the PPPoE session interface from the NSS. - * - * @param[in] if_num NSS interface number. -. * - * @return - * None. - * - * @dependencies - * The tunnel interface must have been previously registered. - */ -extern void nss_unregister_pppoe_session_if(uint32_t if_num); - -/** - * nss_pppoe_get_context - * Gets the PPPoE context used in PPPoE transmit message. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_pppoe_get_context(void); - -/** - * nss_pppoe_debug_stats_get - * Gets NSS session debug statistics. - * - * @param[out] stats_mem Pointer to the memory address, which must be large - * enough to hold all the statistics. - * - * @return - * None. - */ -extern void nss_pppoe_debug_stats_get(void *stats_mem); - -/** - * nss_pppoe_get_bridge_accel_mode - * Gets the PPPoE bridge acceleration mode. - * - * @return - * Current PPPoE bridge acceleration mode. - */ -extern enum nss_pppoe_br_accel_modes nss_pppoe_get_br_accel_mode(void); - -/** - * nss_pppoe_register_sysctl - * Registers the PPPoE system control table. - * - * @return - * None. - */ -void nss_pppoe_register_sysctl(void); - -/** - * nss_pppoe_unregister_sysctl - * Deregisters the PPPoE system control table. - * - * @return - * None. - * - * @dependencies - * The system control table must have been previously registered. - */ -void nss_pppoe_unregister_sysctl(void); - -/** - * nss_pppoe_msg_init - * Initializes a PPPoE message. - * - * @datatypes - * nss_pppoe_msg - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num Interface number - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -extern void nss_pppoe_msg_init(struct nss_pppoe_msg *ncm, - uint16_t if_num, uint32_t type, uint32_t len, - void *cb, void *app_data); - -/** - * nss_pppoe_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_pppoe_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_pppoe_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_pppoe_stats_unregister_notifier(struct notifier_block *nb); - -#endif /*__KERNEL__ */ - -/** - * @} - */ - -#endif /* __NSS_PPPOE_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_pptp.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_pptp.h deleted file mode 100644 index 6478684b9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_pptp.h +++ /dev/null @@ -1,345 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/** - * @file nss_pptp.h - * NSS PPTP interface definitions. - */ - -#ifndef _NSS_PPTP_H_ -#define _NSS_PPTP_H_ - -#include "nss_dynamic_interface.h" - -/** - * @addtogroup nss_pptp_subsystem - * @{ - */ - -/** - * Maximum number of supported PPTP sessions is 4. - * Number of dynamic intefaces per session is 3. - * Total 4 * 3 = 12 - */ -#define NSS_MAX_PPTP_DYNAMIC_INTERFACES 12 - -/** - * nss_pptp_metadata_types - * Message types for PPTP requests and responses. - */ -enum nss_pptp_metadata_types { - NSS_PPTP_MSG_SESSION_CONFIGURE, - NSS_PPTP_MSG_SESSION_DECONFIGURE, - NSS_PPTP_MSG_SYNC_STATS, - NSS_PPTP_MSG_MAX -}; - -/** - * nss_pptp_exception_events - * Exception events for PPTP encapsulation and decapsulation packets. - */ -enum nss_pptp_exception_events { - PPTP_EXCEPTION_EVENT_ENCAP_HEADROOM_ERR, - PPTP_EXCEPTION_EVENT_ENCAP_SMALL_SIZE, - PPTP_EXCEPTION_EVENT_ENCAP_PNODE_ENQUEUE_FAIL, - PPTP_EXCEPTION_EVENT_DECAP_NO_SEQ_NOR_ACK, - PPTP_EXCEPTION_EVENT_DECAP_INVAL_GRE_FLAGS, - PPTP_EXCEPTION_EVENT_DECAP_INVAL_GRE_PROTO, - PPTP_EXCEPTION_EVENT_DECAP_WRONG_SEQ, - PPTP_EXCEPTION_EVENT_DECAP_INVAL_PPP_HDR, - PPTP_EXCEPTION_EVENT_DECAP_PPP_LCP, - PPTP_EXCEPTION_EVENT_DECAP_UNSUPPORTED_PPP_PROTO, - PPTP_EXCEPTION_EVENT_DECAP_PNODE_ENQUEUE_FAIL, - PPTP_EXCEPTION_EVENT_MAX, -}; - -/** - * nss_pptp_stats_session - * PPTP debug statistics. - */ -enum nss_pptp_stats_session { - NSS_PPTP_STATS_ENCAP_RX_PACKETS, - NSS_PPTP_STATS_ENCAP_RX_BYTES, - NSS_PPTP_STATS_ENCAP_TX_PACKETS, - NSS_PPTP_STATS_ENCAP_TX_BYTES, - NSS_PPTP_STATS_ENCAP_RX_QUEUE_0_DROP, - NSS_PPTP_STATS_ENCAP_RX_QUEUE_1_DROP, - NSS_PPTP_STATS_ENCAP_RX_QUEUE_2_DROP, - NSS_PPTP_STATS_ENCAP_RX_QUEUE_3_DROP, - NSS_PPTP_STATS_DECAP_RX_PACKETS, - NSS_PPTP_STATS_DECAP_RX_BYTES, - NSS_PPTP_STATS_DECAP_TX_PACKETS, - NSS_PPTP_STATS_DECAP_TX_BYTES, - NSS_PPTP_STATS_DECAP_RX_QUEUE_0_DROP, - NSS_PPTP_STATS_DECAP_RX_QUEUE_1_DROP, - NSS_PPTP_STATS_DECAP_RX_QUEUE_2_DROP, - NSS_PPTP_STATS_DECAP_RX_QUEUE_3_DROP, - NSS_PPTP_STATS_SESSION_ENCAP_HEADROOM_ERR, - NSS_PPTP_STATS_SESSION_ENCAP_SMALL_SIZE, - NSS_PPTP_STATS_SESSION_ENCAP_PNODE_ENQUEUE_FAIL, - NSS_PPTP_STATS_SESSION_DECAP_NO_SEQ_NOR_ACK, - NSS_PPTP_STATS_SESSION_DECAP_INVAL_GRE_FLAGS, - NSS_PPTP_STATS_SESSION_DECAP_INVAL_GRE_PROTO, - NSS_PPTP_STATS_SESSION_DECAP_WRONG_SEQ, - NSS_PPTP_STATS_SESSION_DECAP_INVAL_PPP_HDR, - NSS_PPTP_STATS_SESSION_DECAP_PPP_LCP, - NSS_PPTP_STATS_SESSION_DECAP_UNSUPPORTED_PPP_PROTO, - NSS_PPTP_STATS_SESSION_DECAP_PNODE_ENQUEUE_FAIL, - NSS_PPTP_STATS_SESSION_MAX -}; - -/** - * nss_pptp_stats_notification - * PPTP statistics structure. - */ -struct nss_pptp_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint32_t if_num; /**< Interface number. */ - enum nss_dynamic_interface_type if_type; /**< Dynamic interface type. */ - uint64_t stats[NSS_PPTP_STATS_SESSION_MAX]; /**< PPTP statistics. */ -}; - -/** - * nss_pptp_session_configure_msg - * Message information for configuring a PPTP session. - */ -struct nss_pptp_session_configure_msg { - uint16_t src_call_id; /**< Local call ID for caller or callee. */ - uint16_t dst_call_id; /**< Peer call ID for caller or callee. */ - uint32_t sip; /**< Local tunnel endpoint. */ - uint32_t dip; /**< Remote tunnel endpoint. */ - uint32_t sibling_ifnum_pri; /**< Primary sibling interface. */ - uint32_t sibling_ifnum_aux; /**< Auxiliary sibling interface. */ -}; - -/** - * nss_pptp_session_deconfigure_msg - * Message information for deleting a PPTP session. - */ -struct nss_pptp_session_deconfigure_msg { - uint16_t src_call_id; /**< Local call ID */ -}; - -/** - * nss_pptp_sync_session_stats_msg - * Message information for PPTP synchronization statistics. - */ -struct nss_pptp_sync_session_stats_msg { - struct nss_cmn_node_stats node_stats; - /**< Common node statistics for the encapsulation direction. */ - uint32_t exception_events[PPTP_EXCEPTION_EVENT_MAX]; - /**< Statistics of events which casued packets to exception to host. */ -}; - -/** - * nss_pptp_msg - * Data for sending and receiving PPTP messages. - */ -struct nss_pptp_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a PPTP message. - */ - union { - struct nss_pptp_session_configure_msg session_configure_msg; - /**< Session configuration message. */ - struct nss_pptp_session_deconfigure_msg session_deconfigure_msg; - /**< Session de-configuration message. */ - struct nss_pptp_sync_session_stats_msg stats; - /**< Session statistics message. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving PPTP messages. - * - * @datatypes - * nss_pptp_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_pptp_msg_callback_t)(void *app_data, struct nss_pptp_msg *msg); - -/** - * nss_pptp_tx_msg_sync - * Sends a PPTP message synchronously to NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_pptp_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_pptp_tx_msg_sync(struct nss_ctx_instance *nss_ctx, - struct nss_pptp_msg *msg); - -/** - * nss_pptp_tx_buf - * Sends a data packet to the firmware. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] if_num NSS interface number. - * @param[in] skb Pointer to the data socket buffer. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_pptp_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, struct sk_buff *skb); - -/** - * nss_pptp_get_context - * Gets the PPTP context used in nss_pptp_tx. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_pptp_get_context(void); - -/** - * Callback function for receiving PPTP tunnel 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_pptp_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_register_pptp_if - * Registers the PPTP tunnel interface with the NSS for sending and - * receiving messages. - * - * @datatypes - * nss_pptp_callback_t \n - * nss_pptp_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] type Dynamic interface type. - * @param[in] pptp_data_callback Callback for the data. - * @param[in] notification_callback Callback for the message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Socket buffer types supported by this interface. - * @param[in] app_ctx Pointer to the application context of the message. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_register_pptp_if(uint32_t if_num, uint32_t type, nss_pptp_callback_t pptp_data_callback, - nss_pptp_msg_callback_t notification_callback, struct net_device *netdev, uint32_t features, void *app_ctx); - -/** - * nss_unregister_pptp_if - * Deregisters the PPTP tunnel interface from the NSS. - * - * @param[in] if_num NSS interface number. -. * - * @return - * None. - * - * @dependencies - * The tunnel interface must have been previously registered. - */ -extern void nss_unregister_pptp_if(uint32_t if_num); - -/** - * nss_pptp_msg_init - * Initializes a PPTP message. - * - * @datatypes - * nss_pptp_msg - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num Interface number - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -extern void nss_pptp_msg_init(struct nss_pptp_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); - -/** - * nss_pptp_register_handler - * Registers the PPTP interface with the NSS debug statistics handler. - * - * @return - * None. - */ -extern void nss_pptp_register_handler(void); - -/** - * nss_pptp_session_debug_stats_get - * Gets NSS session debug statistics. - * - * @param[out] stats_mem Pointer to the memory address, which must be large - * enough to hold all the statistics. - * - * @return - * None. - */ -extern void nss_pptp_session_debug_stats_get(void *stats_mem); - -/** - * nss_pptp_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_pptp_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_pptp_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_pptp_stats_unregister_notifier(struct notifier_block *nb); - -/** - * @} - */ - -#endif /* _NSS_PPTP_H_ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_profiler.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_profiler.h deleted file mode 100644 index 89ddf6586..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_profiler.h +++ /dev/null @@ -1,406 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2014-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. - * 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_profiler.h - * NSS Profiler APIs - */ - -#ifndef __NSS_PROFILER_H -#define __NSS_PROFILER_H - -/** - * @addtogroup nss_profiler_subsystem - * @{ - */ - -/** - * Length of the counter name. - * - * This value allows all counter values to fit in a single 1400-byte UDP packet. - */ -#define PROFILE_COUNTER_NAME_LENGTH 20 - -#define PROFILE_MAX_APP_COUNTERS 24 /**< Maximum number of application counters. */ - -/** - * nss_profile_counter - * Counter statistics. - */ -struct nss_profile_counter { - char name[PROFILE_COUNTER_NAME_LENGTH]; /**< Counter name. */ - uint32_t value; /**< Current value. */ -}; - -/** - * nss_profiler_message_types - * Message types for the Profiler. - * - * Do not alter this enumeration. However, adding more types is allowed. - */ -enum nss_profiler_message_types { - NSS_PROFILER_CHANGE_SAMPLING_RATE_MSG, /**< Host-to-NSS: ask to do a rate change. */ - NSS_PROFILER_START_MSG, /**< Host-to-NSS: start the NSS Profiler. */ - NSS_PROFILER_STOP_MSG, /**< Host-to-NSS: stop the NSS Profiler. */ - NSS_PROFILER_FLOWCTRL_MSG, /**< Host-to-NSS: do flow control on sampling. */ - NSS_PROFILER_DEBUG_RD_MSG, /**< Host-to-NSS: debug the output. */ - NSS_PROFILER_DEBUG_WR_MSG, /**< Host-to-NSS: debug the input. */ - NSS_PROFILER_DEBUG_REPLY_MSG, /**< NSS-to-host: debug response. */ - NSS_PROFILER_REPLY_MSG, /**< Check the response. */ - NSS_PROFILER_FIXED_INFO_MSG, /**< NSS-to-host: constant data. */ - NSS_PROFILER_COUNTERS_MSG, /**< NSS-to-host: counter information. */ - NSS_PROFILER_SAMPLES_MSG, /**< NSS-to-host: main sample data. */ - NSS_PROFILER_START_CAL, /**< Not for the host to use. */ - NSS_PROFILER_GET_SYS_STAT_EVENT, /**< Get the system status event. */ - NSS_PROFILER_SET_SYS_STAT_EVENT, /**< Set the system status event. */ - NSS_PROFILER_MAX_MSG_TYPES, /**< Maximum number of message types. */ -}; - -/** - * nss_profile_errors - * Profiler error types returned from the NSS. - */ -enum nss_profile_errors { - PROFILE_ERROR_NO_PROF_INIT = 1, - PROFILE_ERROR_EMEM, - PROFILE_ERROR_BAD_PKT, - PROFILE_ERROR_UNKNOWN_CMD, - PROFILE_ERROR_NO_DMA, - PROFILE_ERROR_MAX -}; - -/** - * nss_profiler_cmd_param - * Parameter information for the Profiler. - * - * Use this structure for per-session commands: START, STOP, FLOWCTRL, RATE. - */ -struct nss_profiler_cmd_param { - uint32_t hd_magic; /**< Common overlay in all headers. */ - uint32_t num_counters; - /**< Number of registered performance (application) counters. */ - uint32_t ocm_size; /**< Size of the on-chip-memory. */ - uint32_t sram_start; /**< DDR starting address. */ - uint32_t rate; /**< Sampling rate. */ - uint32_t cpu_id; /**< ID of the chip register. */ - uint32_t cpu_freq; /**< Chip clock frequency. */ - uint32_t ddr_freq; /**< DDR memory speed. */ - - struct nss_profile_counter counters[PROFILE_MAX_APP_COUNTERS]; - /**< Application profiling counters. */ -}; - -/** - * nss_profiler_data_msg - * Message information for the Profiler. - */ -struct nss_profiler_data_msg { - uint32_t hd_magic; /**< Magic header for verification. */ - uint32_t msg_data[1]; /**< Variable length private data. */ -}; - -/** - * nss_profiler_debug_msg - * Message information for Profiler debugging. - */ -struct nss_profiler_debug_msg { - uint32_t hd_magic; /**< Magic header for verification. */ - uint32_t debug_data[256]; /**< Fixed length debug data. */ -}; - -/** - * nss_profiler_msg - * Data for sending and receiving Profiler messages. - */ -struct nss_profiler_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a Profiler message. - */ - union npm_body { - struct nss_profiler_cmd_param pcmdp; /**< Command parameters. */ - struct nss_profiler_debug_msg pdm; /**< Debug packet. */ - struct nss_profiler_data_msg msg; /**< Sampling data. */ - } payload; /**< Message payload. The data length is set in common message header. */ -}; - -/** - * nss_profile_sdma_producer - * DMA descriptor of producer. - */ -struct nss_profile_sdma_producer { - uint32_t intr_num; /**< Interrupt number. */ - uint32_t pkg_id; /**< Package ID that registered this entry. */ - uint32_t buf_size; /**< DMA buffer size. */ - uint32_t num_bufs; /**< Number of ring buffers. */ - uint32_t desc_ring; /**< Ring address (physical 32-bit). */ - uint32_t pad3w[3]; /**< Pad 32-byte alignment. */ -}; - -/** - * nss_u64_32_data - * 64-bit union for both 32/64 bits data aligned at 64-bit boundary. - */ -union nss_u64_32_data { - uint64_t d64; /**< 64-bit space holder: may not be used. */ - uint32_t d32; /**< 32-bit direct data. */ - void *kp; /**< Kernel data pointer either 32 or 64 bits. */ -}; - -/** - * nss_u64_32_func - * 64-bit union for both 32/64 bits function aligned at 64-bit boundary. - */ -union nss_u64_32_func { - uint64_t f64; /**< 64-bit space holder: do not use. */ - void (*fp)(void*); /**< Function pointer: either 32 or 64 bits. */ -}; - -/** - * nss_profile_sdma_consumer - * DMA descriptor of consumer. - */ -struct nss_profile_sdma_consumer { - union nss_u64_32_data arg; /**< Dispatch function argument. */ - union nss_u64_32_func dispatch; /**< Dispatch function pointer. */ - union nss_u64_32_data ring; /**< DMA descriptor ring kernel address. */ - int64_t unused_lw; /**< Extra room in a Ubi32 cache line. */ -}; - -#define ARM_CACHE_LINE_SIZE 128 /**< ARM CPU cache line size in bytes. */ -#define NSS_CACHE_LINE_WORDS 8 /**< Ubi32 CPU cache line size in words. */ - -/** - * Number of DMA per control block. - */ -#define NSS_PROFILE_MAX_DMA_DESCRIPTORS (ARM_CACHE_LINE_SIZE / sizeof(struct nss_profile_sdma_producer) - 1) - -/** - * nss_profile_sdma_ctrl - * Soft DMA control block. - */ -struct nss_profile_sdma_ctrl { - int32_t num_rings; /**< Number of descriptor rings allocated, maximum is 3. */ - int32_t cur_ring; /**< Which ring is in use: Default 0. */ - int32_t pidx[NSS_PROFILE_MAX_DMA_DESCRIPTORS]; /**< Producer index. */ - - /** - * Pad for the first Ubi32 cache line in the first ARM cache line: Unused. - */ - int32_t pad_for_1st_cl_in_1st_arm_cl[NSS_CACHE_LINE_WORDS - 2 - NSS_PROFILE_MAX_DMA_DESCRIPTORS]; - struct nss_profile_sdma_producer producer[NSS_PROFILE_MAX_DMA_DESCRIPTORS]; /**< DMA producer structure. */ - - int32_t cidx[NSS_PROFILE_MAX_DMA_DESCRIPTORS]; /**< Consumer index. */ - - /** - * Pad for the first Ubi32 cache line in the second ARM cache line: Unused. - */ - int32_t pad_for_1st_cl_in_2nd_arm_cl[NSS_CACHE_LINE_WORDS - NSS_PROFILE_MAX_DMA_DESCRIPTORS]; - struct nss_profile_sdma_consumer consumer[NSS_PROFILE_MAX_DMA_DESCRIPTORS]; /**< DMA consumer structure. */ -}; - -/** - * Callback function for receiving Profiler messages. - * - * @note: Memory (buffer) pointed by npm is owned by caller, that is, NSS driver. - * - * @datatypes - * nss_profiler_msg - * - * @param[in] ctx Pointer to the context of the NSS process (core). - * @param[in] npm Pointer to the NSS Profiler message. - */ -typedef void (*nss_profiler_callback_t)(void *ctx, struct nss_profiler_msg *npm); - -/** - * nss_profiler_notify_register - * Registers the Profiler interface with the NSS driver for sending and receiving messages. - * - * This function must be called once for each core. - * - * @datatypes - * nss_core_id_t \n - * nss_profiler_callback_t - * - * @param[in] profiler_callback Callback for the data. - * @param[in] core_id NSS core ID. - * @param[in] ctx Pointer to the context of the NSS core. The context is - provided to caller in the registered callback function. - * - * @return - * Pointer to the NSS core context. - * - * @dependencies - * The caller must provide the valid core ID that is being profiled. - */ -extern void *nss_profiler_notify_register(nss_core_id_t core_id, nss_profiler_callback_t profiler_callback, void *ctx); - -/** - * nss_profiler_notify_unregister - * Deregisters the Profiler interface from the NSS driver. - * - * @datatypes - * nss_core_id_t - * - * @param[in] core_id NSS core ID. - * - * @return - * None. - * - * @dependencies - * The interface must have been previously registered. - */ -extern void nss_profiler_notify_unregister(nss_core_id_t core_id); - -/** - * nss_profiler_if_tx_buf - * Sends a Profiler command to the NSS firmware. - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] buf Buffer to send to NSS firmware. - * @param[in] len Length of the buffer. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * Status of the Tx operation. - * - * @dependencies - * A valid context must be provided (for the right core). - * This context was returned during registration. - */ -extern nss_tx_status_t nss_profiler_if_tx_buf(void *nss_ctx, - void *buf, uint32_t len, void *cb, void *app_data); - -/** - * nss_profiler_alloc_dma - * Allocate profiler DMA for transmitting samples. - * - * @datatypes - * nss_ctx_instance \n - * nss_profile_sdma_producer - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] dma_p Pointer to return DMA control. - * - * @return - * Buffer adddress. - */ -extern void *nss_profiler_alloc_dma(struct nss_ctx_instance *nss_ctx, struct nss_profile_sdma_producer **dma_p); - -/** - * nss_profiler_release_dma() - * Free profiler DMA. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * - * @return - * None. - */ -extern void nss_profiler_release_dma(struct nss_ctx_instance *nss_ctx); - -/* - * nss_profile_dma_register_cb - * Register a handler for profile DMA. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] id DMA ID; typical value is 0. - * @param[in] cb Callback function pointer. - * @param[in] arg Callback function argument pointer. - * - * @return - * True on success; or false on failure. - */ -extern bool nss_profile_dma_register_cb(struct nss_ctx_instance *nss_ctx, int id, - void (*cb)(void*), void *arg); - -/** - * nss_profile_dma_deregister_cb() - * Deregister callback for profile DMA. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] id DMA ID; typical value is 0. - * - * @return - * True on success; or false on failure. - */ -extern bool nss_profile_dma_deregister_cb(struct nss_ctx_instance *nss_ctx, int id); - -/** - * nss_profile_dma_get_ctrl() - * API to get profile DMA control. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * - * @return - * DMA controller. - */ -extern struct nss_profile_sdma_ctrl *nss_profile_dma_get_ctrl(struct nss_ctx_instance *nss_ctx); - -/** - * profile_register_performance_counter - * Registers a Linux counter with the profiler for any variables. - * - * @param[in] counter Pointer to the variable address. - * @param[in] name Pointer to the variable name: if name is longer than - 23 characters, then only the first 23 bytes are used. - * - * @return - * 0 if counter array is full -- too many registered counters. - * 1 on success - */ -extern int profile_register_performance_counter(volatile unsigned int *counter, char *name); - -/** - * nss_profiler_msg_init - * Initializes a Profiler-specific message. - * - * @datatypes - * nss_profiler_msg \n - * nss_profiler_callback_t - * - * @param[in,out] npm Pointer to the NSS Profiler message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the message. - * @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_profiler_msg_init(struct nss_profiler_msg *npm, uint16_t if_num, - uint32_t type, uint32_t len, - nss_profiler_callback_t cb, void *app_data); - -/** - * @} - */ - -#endif diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_project.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_project.h deleted file mode 100644 index 4b1b7119b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_project.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_project.h - * NSS project interface definitions. - */ - -#ifndef __NSS_PROJECT_H -#define __NSS_PROJECT_H - -/** - * @addtogroup nss_project_subsystem - * @{ - */ - - /** - * Maximum number of IRQs for which a message will have statistics. - * - * Must be defined on firmware and host such that NSS_PROJECT_IRQS_PER_MESSAGE * - * sizeof(struct nss_project_irq_stats) + 8 + sizeof(struct nss_cmn_msg) is smaller - * than the maximum payload size of an sk_buff (1792), 8 being the number of - * bytes needed to store the thread number and number of statistics written. - */ -#define NSS_PROJECT_IRQS_PER_MESSAGE 32 - -/** - * nss_project_message_types - * Project message types. - */ -enum nss_project_message_types { - NSS_PROJECT_MSG_WT_STATS_ENABLE, - /**< 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_MAX, -}; - -/** - * nss_project_error_types - * Project error types. - */ -enum nss_project_error_types { - NSS_PROJECT_ERROR_UNKNOWN_MSG, - /**< Unrecognized message type. */ - NSS_PROJECT_ERROR_WT_STATS_UNSUPPORTED, - /**< 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_MAX, -}; - -/** - * nss_project_msg_wt_stats_enable - * Enables or disables worker thread statistics collection. - */ -struct nss_project_msg_wt_stats_enable { - - /* - * NSS to HLOS - */ - uint32_t worker_thread_count; - /**< Number of worker threads supported by this core. */ - uint32_t irq_count; - /**< Number of IRQs supported by this core. */ - - /* - * HLOS to NSS - */ - bool enable; /**< True to enable, false to disable. */ -}; - -/** - * nss_project_irq_stats - * Statistics for an individual IRQ on a worker thread. - */ -struct nss_project_irq_stats { - uint64_t count; /**< Number of times callback has been executed */ - uint32_t callback; /**< Address of the callback function */ - uint32_t irq; /**< IRQ number to which callback function is bound */ - uint32_t ticks_min; /**< Fewest ticks taken in callback function */ - uint32_t ticks_avg; /**< Exponential moving average of ticks */ - uint32_t ticks_max; /**< Maximum ticks */ - uint32_t insn_min; /**< Fewest instructions executed in callback function */ - uint32_t insn_avg; /**< Exponential moving average of instruction count */ - uint32_t insn_max; /**< Maximum instructions */ -}; - -/** - * nss_project_msg_wt_stats_notify - * Message containing statistics for active worker_thread IRQs. - */ -struct nss_project_msg_wt_stats_notify { - uint32_t threadno; /**< The thread whose stats are contained. */ - uint32_t stats_written; /**< The number of statistics written to the array. */ - struct nss_project_irq_stats stats[NSS_PROJECT_IRQS_PER_MESSAGE]; - /**< The per-IRQ statistics for the worker thread */ -}; - -/** - * nss_project_msg - * General message structure for project messages. - */ -struct nss_project_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a message to or from the project code. - */ - union { - struct nss_project_msg_wt_stats_enable wt_stats_enable; - /**< Enable or disable worker thread statistics. */ - struct nss_project_msg_wt_stats_notify wt_stats_notify; - /**< One-way worker thread statistics message. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving project messages. - * - * @datatypes - * nss_project_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the project message. - */ -typedef void (*nss_project_msg_callback_t)(void *app_data, struct nss_project_msg *msg); - -/** - * nss_project_register_sysctl - * Registers the project sysctl table to the sysctl tree. - * - * @return - * None. - */ -void nss_project_register_sysctl(void); - -/** - * nss_project_unregister_sysctl - * De-registers the project sysctl table from the sysctl tree. - * - * @return - * None. - * - * @dependencies - * The system control must have been previously registered. - */ -void nss_project_unregister_sysctl(void); - -/** - * nss_project_register_handler - * Registers the project message handler. - * - * @return - * None. - */ -void nss_project_register_handler(struct nss_ctx_instance *nss_ctx); - -/** - * @} - */ - -#endif /* __NSS_PROJECT_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_pvxlan.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_pvxlan.h deleted file mode 100644 index 2de0da2b5..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_pvxlan.h +++ /dev/null @@ -1,371 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_pvxlan.h - * NSS proxy VxLAN interface definitions. - */ - -#ifndef __NSS_PVXLAN_H -#define __NSS_PVXLAN_H - -/** - * @addtogroup nss_pvxlan_subsystem - * @{ - */ - -/** - * Size of the headroom required for proxy VxLAN packets. - */ -#define NSS_PVXLAN_HEADROOM 256 - -/** - * Maximum number of supported proxy VxLAN tunnel sessions. - */ -#define NSS_PVXLAN_MAX_INTERFACES 32 - -/* - * Proxy VxLAN Rule configure message flags - */ -#define NSS_PVXLAN_TUNNEL_IPV4 0x0001 /**< IPv4 tunnel. */ -#define NSS_PVXLAN_TUNNEL_IPV6 0x0002 /**< IPv6 tunnel. */ -#define NSS_PVXLAN_TUNNEL_UDP 0x0010 /**< UDP tunnel. */ -#define NSS_PVXLAN_TUNNEL_UDPLite 0x0020 /**< UDPLite tunnel. */ -#define NSS_PVXLAN_TUNNEL_ENCAP_UDPLITE_HDR_CSUM 0x0100 - /**< Generate only UDPLite header checksum. Otherwise whole UDPLite payload. */ - -/** - * nss_pvxlan_msg_type - * Proxy VxLAN message types. - */ -typedef enum nss_pvxlan_msg_type { - NSS_PVXLAN_MSG_TYPE_SYNC_STATS, /**< Statistics synchronization message. */ - NSS_PVXLAN_MSG_TYPE_TUNNEL_CREATE_RULE, /**< Creating tunnel rule. */ - NSS_PVXLAN_MSG_TYPE_TUNNEL_DESTROY_RULE, - /**< Destroying tunnel rule. */ - NSS_PVXLAN_MSG_TYPE_TUNNEL_ENABLE, /**< Enable the tunnel. */ - NSS_PVXLAN_MSG_TYPE_TUNNEL_DISABLE, /**< Disable the tunnel. */ - NSS_PVXLAN_MSG_TYPE_MAC_ADD, /**< Add MAC rule to the database. */ - NSS_PVXLAN_MSG_TYPE_MAC_DEL, /**< Remove MAC rule from the database. */ - NSS_PVXLAN_MSG_TYPE_MAX, /**< Maximum message type. */ -} nss_pvxlan_msg_type_t; - -/** - * nss_pvxlan_error_response_types - * Error types for proxy VxLAN responses to messages from the host. - */ -typedef enum nss_pvxlan_error_response_types { - NSS_PVXLAN_ERROR_UNKNOWN_TYPE = 1, /**< Unknown type error. */ - NSS_PVXLAN_ERROR_INVALID_L3_PROTO, /**< L3 Protocol is invalid error. */ - NSS_PVXLAN_ERROR_INVALID_UDP_PROTO, /**< UDP Protocol is invalid error. */ - NSS_PVXLAN_ERROR_TUNNEL_DISABLED, /**< Tunnel is already disabled error. */ - NSS_PVXLAN_ERROR_TUNNEL_ENABLED, /**< Tunnel is already enabled error. */ - NSS_PVXLAN_ERROR_TUNNEL_ENTRY_EXIST, - /**< Tunnel is already exist error. */ - NSS_PVXLAN_ERROR_TUNNEL_TABLE_FULL, - /**< Tunnel table is full error. */ - NSS_PVXLAN_ERROR_INVALID_TUNNEL_ID, /**< Tunnel ID is invalid error. */ - NSS_PVXLAN_ERROR_MAC_TABLE_FULL, /**< MAC table is full error. */ - NSS_PVXLAN_ERROR_MAC_EXIST, /**< MAC does already exist in the table error. */ - NSS_PVXLAN_ERROR_MAC_NOT_EXIST, /**< MAC does not exist in the table error. */ - NSS_PVXLAN_ERROR_MAC_ENTRY_UNHASHED, - /**< MAC entry is not hashed in table. */ - NSS_PVXLAN_ERROR_MAC_ENTRY_INSERT_FAILED, - /**< Insertion to MAC table is failed. */ - NSS_PVXLAN_ERROR_UDP_ENCAP_TUNNEL_ID_IN_USE, - /**< Given tunnel ID is currently used. */ - PVXLAN_ERROR_MSG_TUNNEL_ADD_FAILED, /**< Tunnel add information failed. */ - PVXLAN_ERROR_MSG_MAC_ENTRY_ALLOC_FAILED, - /**< MAC entry allocation failed. */ - PVXLAN_ERROR_MSG_MAC_ENTRY_DELETE_FAILED, - /**< MAC entry deletion failed. */ - NSS_PVXLAN_ERROR_MAX, /**< Maximum error type. */ -} nss_pvxlan_error_response_t; - -/** - * nss_pvxlan_stats_msg - * Per-tunnel statistics messages from the NSS firmware. - */ -struct nss_pvxlan_stats_msg { - struct nss_cmn_node_stats node_stats; /**< Common firmware statistics. */ - uint32_t mac_db_lookup_failed; /**< MAC Database look up failed. */ - uint32_t udp_encap_lookup_failed; /**< MAC Database look up failed. */ - uint32_t dropped_malformed; /**< Packet is malformed. */ - uint32_t dropped_next_node_queue_full; /**< Next node dropped the packet. */ - uint32_t dropped_hroom; /**< Transmit dropped due to insufficent headroom. */ - uint32_t dropped_ver_mis; /**< Transmit dropped due to version mismatch. */ - uint32_t dropped_zero_sized_packet; /**< Transmit dropped due to zero sized packet. */ - uint32_t dropped_pbuf_alloc_failed; /**< Receive side pbuf allocation failed. */ - uint32_t dropped_linear_failed; /**< Receive side linearization failed. */ -}; - -/** - * nss_pvxlan_ip - * IP versions. - */ -struct nss_pvxlan_ip { - /** - * Union of IPv4 and IPv6 IP addresses. - */ - union { - uint32_t ipv4; /**< IPv4 address. */ - uint32_t ipv6[4]; /**< IPv6 address. */ - } ip; /**< Union of IPv4 and IPv6 IP addresses. */ -}; - -/** - * nss_pvxlan_encap_rule - * Encapsulation information for a proxy VxLAN tunnel. - */ -struct nss_pvxlan_encap_rule { - struct nss_pvxlan_ip src; /**< Source IP. */ - uint32_t src_port; /**< Source port. */ - struct nss_pvxlan_ip dest; /**< Destination IP. */ - uint32_t dest_port; /**< Destination port. */ -}; - -/** - * nss_pvxlan_rule_msg - * Proxy VxLAN rule message. - * - * The same rule structure applies for both encapsulation and decapsulation - * in a tunnel. - */ -struct nss_pvxlan_rule_msg { - struct nss_pvxlan_encap_rule encap; /**< Encapsulation portion of the rule. */ - uint32_t tunnel_id; /**< Tunnel ID. */ - uint16_t flags; /**< Tunnel type flags. */ - int8_t rps; - /**< Receive packet steering number. Set -1 to let NSS firmware decide. */ -}; - -/** - * nss_pvxlan_tunnel_state_msg - * To enable/disable the tunnel. - */ -struct nss_pvxlan_tunnel_state_msg { - uint32_t sibling_if_num; /**< Sibling interface number. */ -}; - -/** - * nss_pvxlan_mac_msg - * Proxy VxLAN MAC message structure. - */ -struct nss_pvxlan_mac_msg { - uint16_t mac_addr[3]; /**< MAC address. */ - uint16_t flags; /**< Flags. */ - uint32_t vnet_id; /**< Virtual net ID. */ - uint32_t tunnel_id; /**< Tunnel ID. */ - uint16_t policy_id; /**< Policy ID. */ -}; - -/** - * nss_pvxlan_msg - * Data for sending and receiving proxy VxLAN messages. - */ -struct nss_pvxlan_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a proxy VxLAN common message. - */ - union { - struct nss_pvxlan_stats_msg stats; - /**< Proxy VxLAN statistics. */ - struct nss_pvxlan_rule_msg rule_cfg; - /**< Rule information. */ - struct nss_pvxlan_rule_msg rule_uncfg; - /**< Rule information. */ - struct nss_pvxlan_tunnel_state_msg enable; - /**< Enable the tunnel. */ - struct nss_pvxlan_mac_msg mac_add; - /**< MAC rule add message. */ - struct nss_pvxlan_mac_msg mac_del; - /**< MAC rule delete message. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving proxy VxLAN tunnel 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_pvxlan_buf_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback function for receiving proxy VxLAN tunnel messages. - * - * @datatypes - * nss_pvxlan_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_pvxlan_msg_callback_t)(void *app_data, struct nss_pvxlan_msg *msg); - -/** - * nss_pvxlan_tx_msg - * Sends proxy VxLAN tunnel messages to the NSS. - * - * Do not call this function from a softirq or interrupt because it - * might sleep if the NSS firmware is busy serving another host thread. - * - * @datatypes - * nss_ctx_instance \n - * nss_pvxlan_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in,out] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_pvxlan_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_pvxlan_msg *msg); - -/** - * nss_pvxlan_tx_msg_sync - * Sends proxy VxLAN tunnel messages to the NSS. - * - * Do not call this function from a softirq or interrupt because it - * might sleep if the NSS firmware is busy serving another host thread. - * - * @datatypes - * nss_ctx_instance \n - * nss_pvxlan_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in,out] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_pvxlan_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_pvxlan_msg *msg); - -/** - * nss_pvxlan_tx_buf - * Sends a proxy VXLAN tunnel data buffer to the NSS interface. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] buf Pointer to the data buffer. - * @param[in] if_num NSS interface number. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_pvxlan_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *buf, uint32_t if_num); - -/** - * nss_pvxlan_unregister - * Deregisters the proxy VxLAN tunnel interface from the NSS interface. - * - * @param[in] if_num NSS interface number. - * - * @return - * TRUE or FALSE - * - * @dependencies - * The tunnel interface must have been previously registered. - */ -extern bool nss_pvxlan_unregister(uint32_t if_num); - -/** - * nss_pvxlan_register - * Registers the proxy VxLAN tunnel interface with the NSS for sending and - * receiving tunnel messages. - * - * @datatypes - * nss_pvxlan_msg_callback_t \n - * nss_pvxlan_buf_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] data_cb Data callback for the proxy VXLAN tunnel data. - * @param[in] notify_cb Notify callback for the proxy VXLAN tunnel data. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_pvxlan_register(uint32_t if_num, nss_pvxlan_buf_callback_t data_cb, - nss_pvxlan_msg_callback_t notify_cb, struct net_device *netdev, uint32_t features); - -/** - * nss_pvxlan_get_ctx - * Gets the NSS context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_pvxlan_get_ctx(void); - -/** - * nss_pvxlan_ifnum_with_core_id - * Gets the proxy VxLAN interface number with the core ID. - * - * @param[in] if_num NSS interface number. - * - * @return - * Interface number with the core ID. - */ -extern int nss_pvxlan_ifnum_with_core_id(int if_num); - -/** - * nss_pvxlan_init - * Initializes the proxy VXLAN interface. - * - * @return - * None. - */ -extern void nss_pvxlan_init(void); - -/** - * nss_pvxlan_msg_init - * Initializes a proxy VxLAN message. - * - * @datatypes - * nss_pvxlan_msg \n - * nss_pvxlan_msg_callback_t - * - * @param[in,out] ncm Pointer to the 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_pvxlan_msg_init(struct nss_pvxlan_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, - nss_pvxlan_msg_callback_t cb, void *app_data); - -/** - * @} - */ - -#endif /* __NSS_PVXLAN_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_qrfs.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_qrfs.h deleted file mode 100644 index 486baf9d4..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_qrfs.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_qrfs.h - * NSS QRFS interface definitions. - */ - -#ifndef __NSS_QRFS_H -#define __NSS_QRFS_H - -/** - * @addtogroup nss_qrfs_subsystem - * @{ - */ - -/** - * nss_qrfs_msg_types - * Message types for the NSS QRFS. - */ -enum nss_qrfs_msg_types { - NSS_QRFS_MSG_FLOW_ADD, - NSS_QRFS_MSG_FLOW_DELETE, - NSS_QRFS_MSG_MAC_ADD, - NSS_QRFS_MSG_MAC_DELETE, - NSS_QRFS_MSG_STATS_SYNC, - NSS_QRFS_MSG_MAX, -}; - -/** - * nss_qrfs_error_types - * Error types for the NSS QRFS. - */ -enum nss_qrfs_error_types { - NSS_QRFS_ERROR_INVALID_MSG_TYPE, - NSS_QRFS_ERROR_INVALID_MSG_SIZE, - NSS_QRFS_ERROR_INVALID_IP_VERSION, - NSS_QRFS_ERROR_V4_FLOW_TABLE_FULL, - NSS_QRFS_ERROR_V6_FLOW_TABLE_FULL, - NSS_QRFS_ERROR_MAC_TABLE_FULL, - NSS_QRFS_ERROR_MAX, -}; - -/** - * nss_qrfs_flow_rule_msg - * Information for the NSS QRFS flow rule message. - */ -struct nss_qrfs_flow_rule_msg { - uint16_t src_port; /**< Source port. */ - uint16_t dst_port; /**< Destination port. */ - uint32_t ip_version; /**< IPv4:4 IPv6:6. */ - uint32_t src_addr[4]; /**< Source IP address. */ - uint32_t dst_addr[4]; /**< Destination IP address. */ - uint16_t protocol; /**< IP protocol. */ - uint16_t cpu; /**< CPU core ID. */ - uint32_t if_num; /**< Physical interface number. */ -}; - -/** - * nss_qrfs_mac_rule_msg - * Information for the NSS QRFS MAC rule message. - */ -struct nss_qrfs_mac_rule_msg { - uint8_t mac[ETH_ALEN]; /**< Ethernet address. */ - uint16_t cpu; /**< CPU core ID. */ - uint32_t if_num; /**< Physical interface number. */ -}; - -/** - * nss_qrfs_stats_sync_msg - * Information for the NSS QRFS statistics message. - */ -struct nss_qrfs_stats_sync_msg { - struct nss_cmn_node_stats node_stats; /**< Common pnode statistics. */ - uint32_t invalid_offset; /**< Packets with invalid offset. */ - uint32_t unknown_protocol; /**< Protocol other than TCP, UDP. */ - uint32_t ipv4_flow_rule_hits; /**< Number of IPv4 flow rule hits. */ - uint32_t ipv6_flow_rule_hits; /**< Number of IPv6 flow rule hits. */ -}; - -/** - * nss_qrfs_msg - * Data for sending and receiving NSS QRFS rule or statistics messages. - */ -struct nss_qrfs_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a NSS QRFS rule or statistics message. - */ - union { - struct nss_qrfs_flow_rule_msg flow_add; /**< Add flow rule. */ - struct nss_qrfs_flow_rule_msg flow_delete; /**< Delete flow rule. */ - struct nss_qrfs_mac_rule_msg mac_add; /**< Add MAC rule. */ - struct nss_qrfs_mac_rule_msg mac_delete; /**< Delete MAC rule. */ - struct nss_qrfs_stats_sync_msg stats_sync; /**< Synchronize statistics. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving QRFS messages. - * - * @datatypes - * nss_qrfs_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_qrfs_msg_callback_t)(void *app_data, struct nss_qrfs_msg *msg); - -/** - * nss_qrfs_register_handler - * Registers the QRFS interface with the NSS for sending and receiving - * messages. - * - * @datatypes - * nss_ctx_instance - * - * @return - * None. - */ -void nss_qrfs_register_handler(struct nss_ctx_instance *nss_ctx); - -/** - * nss_qrfs_notify_register - * Registers a notifier callback for QRFS messages with the NSS. - * - * @datatypes - * nss_qrfs_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_qrfs_notify_register(int core, nss_qrfs_msg_callback_t cb, void *app_data); - -/** - * nss_qrfs_notify_unregister - * Deregisters a QRFS message notifier callback from the NSS. - * - * @param[in] core NSS core number index to the notifier callback table. - * - * @return - * None. - */ -void nss_qrfs_notify_unregister(int core); - -/** - * nss_qrfs_set_flow_rule - * Sends a QRFS message to the NSS core to set the flow rule. - * - * @datatypes - * sk_buff - * - * @param[in] skb Pointer to the SKB buffer. - * @param[in] cpu CPU number to set in the flow table. - * @param[in] action Action to perform on the flow table. - * - * @return - * 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_init - * Initializes the QRFS. - * - * @return - * None. - */ -void nss_qrfs_init(void); - -/** - * @} - */ - -#endif /* __NSS_QRFS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_qvpn.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_qvpn.h deleted file mode 100644 index 931da43dc..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_qvpn.h +++ /dev/null @@ -1,522 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_qvpn.h - * NSS QVPN interface definitions. - */ - -#ifndef _NSS_QVPN_H_ -#define _NSS_QVPN_H_ - -/** - * @addtogroup nss_qvpn_subsystem - * @{ - */ - -#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. */ -#define NSS_QVPN_IV_SIZE_MAX 16 /**< Maximum size of IV supported. */ -#define NSS_QVPN_SESS_ID_SIZE_MAX 8 /**< Maximum size of session ID. */ - -/* - * QVPN L3/L4 header flags. - */ -#define NSS_QVPN_HDR_FLAG_IPV6 0x0001 /**< Outer L3 header is IPv6. */ -#define NSS_QVPN_HDR_FLAG_L4_UDP 0x0002 /**< L4 is UDP. */ - -/** - * nss_qvpn_msg_type - * Message types for QVPN NSS firmware. - */ -enum nss_qvpn_msg_type { - NSS_QVPN_MSG_TYPE_TUNNEL_CONFIGURE, /**< Configure QVPN tunnel instance. */ - NSS_QVPN_MSG_TYPE_TUNNEL_DECONFIGURE, /**< Deconfigure QVPN tunnel instance. */ - NSS_QVPN_MSG_TYPE_CRYPTO_KEY_ADD, /**< Add a new crypto key. */ - NSS_QVPN_MSG_TYPE_CRYPTO_KEY_DEL, /**< Delete crypto key. */ - NSS_QVPN_MSG_TYPE_CRYPTO_KEY_ACTIVATE, /**< Activate crypto key. */ - NSS_QVPN_MSG_TYPE_CRYPTO_KEY_DEACTIVATE,/**< Deactivate crypto key. */ - NSS_QVPN_MSG_TYPE_SYNC_STATS, /**< Statistics synchronization. */ - NSS_QVPN_MSG_TYPE_MAX /**< Maximum QVPN message type. */ -}; - -/** - * nss_qvpn_cmds_type - * Processing commands for QVPN. - */ -enum nss_qvpn_cmds_type { - NSS_QVPN_CMDS_TYPE_NONE, /**< Add VPN header to packet. */ - NSS_QVPN_CMDS_TYPE_ADD_VPN_HDR, /**< Add VPN header to packet. */ - NSS_QVPN_CMDS_TYPE_REMOVE_VPN_HDR, /**< Remove VPN header from packet. */ - NSS_QVPN_CMDS_TYPE_ADD_L3_L4_HDR, /**< Add L3/L4 header to packet. */ - NSS_QVPN_CMDS_TYPE_REMOVE_L3_L4_HDR, /**< Remove L3/L4 header from packet. */ - NSS_QVPN_CMDS_TYPE_ENCRYPT, /**< Send packet for encryption. */ - NSS_QVPN_CMDS_TYPE_DECRYPT, /**< Send packet for decryption. */ - NSS_QVPN_CMDS_TYPE_ANTI_REPLAY, /**< Sequence number processing. */ - NSS_QVPN_CMDS_TYPE_MAX /**< Maximum command supported. */ -}; - -/** - * nss_qvpn_profile - * QVPN profiles supported. - */ -enum nss_qvpn_profile { - NSS_QVPN_PROFILE_NONE, /**< No profile supported. */ - NSS_QVPN_PROFILE_CRYPTO_ENCAP, /**< Encapsulation profile with crypto enabled. */ - NSS_QVPN_PROFILE_CRYPTO_DECAP, /**< Decapsulation profile with crypto enabled. */ - NSS_QVPN_PROFILE_ENCAP, /**< Encapsulation Profile with crypto disabled. */ - NSS_QVPN_PROFILE_DECAP, /**< Decapsulation Profile with crypto disabled. */ - NSS_QVPN_PROFILE_MAX, /**< Maximum profile. */ -}; - -/** - * nss_qvpn_pkt_drop_event - * Packets drop statistics from QVPN node. - */ -enum nss_qvpn_pkt_drop_event { - NSS_QVPN_PKT_DROP_EVENT_NO_TAILROOM, /**< Packet tail room not enough to copy HMAC to tail. */ - NSS_QVPN_PKT_DROP_EVENT_NO_HEADROOM, /**< Packet head room not enough to add QVPN headers. */ - NSS_QVPN_PKT_DROP_EVENT_CBUF_ALLOC_FAIL, /**< Received packet dropped as crypto buffer allocation failed. */ - NSS_QVPN_PKT_DROP_EVENT_PBUF_ALLOC_FAIL, /**< Received packet dropped as associated pbuf allocation failed. */ - NSS_QVPN_PKT_DROP_EVENT_SYNC_ALLOC_FAIL, /**< Pbuf dropped while doing statistics synchronization. */ - NSS_QVPN_PKT_DROP_EVENT_PBUF_UNALIGN, /**< Received packet dropped as unaligned buffer. */ - NSS_QVPN_PKT_DROP_EVENT_CRYPTO_ENQ_FAIL, /**< Received packet dropped as crypto enqueue failed. */ - NSS_QVPN_PKT_DROP_EVENT_LINEAR_COPY_FAIL, /**< Received packet dropped as scatter-gather linear copy failed. */ - NSS_QVPN_PKT_DROP_EVENT_FWD_ENQ_FAIL, /**< Received packet dropped as enqueue to next node failed. */ - NSS_QVPN_PKT_DROP_EVENT_POST_CRYPTO_Q_FULL, /**< Post crypto queue is full dropping pbuf. */ - NSS_QVPN_PKT_DROP_EVENT_NODE_INACTIVE, /**< Node is inactive dropping crypto processed packet. */ - NSS_QVPN_PKT_DROP_EVENT_NON_CRYPTO_PB, /**< Non crypto processed packet enqueued to post crypto queue. */ - NSS_QVPN_PKT_DROP_EVENT_PAD_INVALID, /**< Packet received with invalid padding. */ - NSS_QVPN_PKT_DROP_EVENT_BLK_UNALIGNED, /**< Received pbuf length is not cipher block aligned. */ - NSS_QVPN_PKT_DROP_EVENT_MAX /**< End of packet drop event list. */ -}; - -/** - * nss_qvpn_exception_event - * Exception events from QVPN node. - */ -enum nss_qvpn_exception_event { - NSS_QVPN_EXCEPTION_EVENT_RX_CONTROL_PKT, /**< QVPN control packet received. */ - NSS_QVPN_EXCEPTION_EVENT_RX_TAIL_NOSUPP, /**< Protocol with tail not supported. */ - QVPN_TUN_EXCEPTION_EVENT_RX__HR_INSUFF, /**< Insufficient headroom. */ - NSS_QVPN_EXCEPTION_EVENT_RX_SESS_ID_INVALID, /**< Invalid session ID. */ - NSS_QVPN_EXCEPTION_EVENT_RX_DATA_PKT, /**< Data packets exceptioned to host. */ - NSS_QVPN_EXCEPTION_EVENT_RX_MALFORMED, /**< Malformed packet received. */ - NSS_QVPN_EXCEPTION_EVENT_MAX /**< End of exception event list. */ -}; - -/** - * nss_qvpn_error_type - * Error types for the QVPN interface. - */ -enum nss_qvpn_error_type { - NSS_QVPN_ERROR_TYPE_NONE, /**< No error. */ - NSS_QVPN_ERROR_TYPE_UNKNOWN_MSG, /**< Unknown message. */ - NSS_QVPN_ERROR_TUN_ALREADY_CONFIGURED, /**< Tunnel already configured. */ - NSS_QVPN_ERROR_TYPE_IF_INVALID, /**< Invalid interface. */ - NSS_QVPN_ERROR_TYPE_SIBLING_IF, /**< Invalid sibling interface number. */ - NSS_QVPN_ERROR_TYPE_IV_SIZE_INVALID, /**< Invalid IV size. */ - NSS_QVPN_ERROR_TYPE_HMAC_SIZE_INVALID, /**< Invalid HMAC size. */ - NSS_QVPN_ERROR_TYPE_CRYPTO_BLK_SIZE_INVALID, /**< Invalid crypto block size. */ - NSS_QVPN_ERROR_TYPE_SESSION_IDX_SIZE_INVALID, /**< Invalid session index size. */ - NSS_QVPN_ERROR_TYPE_CMD_NOT_SUPPORTED, /**< Command not supported. */ - NSS_QVPN_ERROR_TYPE_L4_PROTO_INVALID, /**< L4 protocol encapsulation is not supported. */ - NSS_QVPN_ERROR_TYPE_SIBLING_IF_TYPE, /**< Invalid sibling interface type. */ - NSS_QVPN_ERROR_TYPE_CMDS_COUNT_INVALID, /**< Total number of commands is invalid. */ - NSS_QVPN_ERROR_TYPE_ENTRY_NOT_FOUND, /**< Entry not found. */ - NSS_QVPN_ERROR_TYPE_ENTRY_NOT_ACTIVE, /**< Entry not active. */ - NSS_QVPN_ERROR_TYPE_ENTRY_ALREADY_ACTIVE, /**< Entry already active. */ - NSS_QVPN_ERROR_TYPE_CRYPTO_IDX_MISMATCH, /**< Invalid crypto index. */ - NSS_QVPN_ERROR_TYPE_KI_ALLOC_FAIL, /**< Key information allocation failure. */ - NSS_QVPN_ERROR_TYPE_PROFILE_INVALID, /**< Invalid command profile. */ - NSS_QVPN_ERROR_TYPE_RX_TAIL_NOSUPP, /**< VPN with tail not supported. */ - NSS_QVPN_ERROR_TYPE_MAX /**< End of error list. */ -}; - -/** - * nss_qvpn_iv_type - * IV type for generating and copying in packet. - */ -enum nss_qvpn_iv_type { - NSS_QVPN_IV_TYPE_NONE, /**< No IV. */ - NSS_QVPN_IV_TYPE_STATIC, /**< Use static IV configured. */ - NSS_QVPN_IV_TYPE_DYNAMIC_RAND, /**< Generate IV randomly. */ - NSS_QVPN_IV_TYPE_MAX /**< End of IV type list. */ -}; - -/** - * nss_qvpn_pad_type - * Pad type for generating and copying in packet. - */ -enum nss_qvpn_pad_type { - NSS_QVPN_PAD_TYPE_NONE, /**< No padding. */ - NSS_QVPN_PAD_TYPE_PKCS7, /**< Generate pad buffer using PKCS7. */ - NSS_QVPN_PAD_TYPE_INC, /**< Generate pad buffer monotonically increasing sequence. */ - NSS_QVPN_PAD_TYPE_MAX /**< End of pad type. */ -}; - -/** - * nss_qvpn_anti_replay_alg - * Anti-replay algorithms supported. - */ -enum nss_qvpn_anti_replay_alg { - NSS_QVPN_ANTI_REPLAY_ALG_NONE, /**< No anti-replay. */ - NSS_QVPN_ANTI_REPLAY_ALG_REPLAY_WINDOW, /**< Generate pad buffer monotonically increasing sequence. */ - NSS_QVPN_ANTI_REPLAY_ALG_MAX /**< End of anti-replay algorithm. */ -}; - -/** - * nss_qvpn_crypto_mode - * Crypto modes supported. - */ -enum nss_qvpn_crypto_mode { - NSS_QVPN_CRYPTO_MODE_NONE, /**< NULL cipher and NULL authentication. */ - NSS_QVPN_CRYPTO_MODE_ENC, /**< Encryption only. */ - NSS_QVPN_CRYPTO_MODE_DEC, /**< Decryption only. */ - NSS_QVPN_CRYPTO_MODE_AUTH, /**< Authentication only. */ - NSS_QVPN_CRYPTO_MODE_ENC_AUTH, /**< Encryption and then authentication. */ - NSS_QVPN_CRYPTO_MODE_AUTH_DEC, /**< Authentication and then decryption. */ - NSS_QVPN_CRYPTO_MODE_AUTH_ENC, /**< Authentication and then encryption. */ - NSS_QVPN_CRYPTO_MODE_DEC_AUTH, /**< Decryption and then authentication. */ - NSS_QVPN_CRYPTO_MODE_MAX /**< End of crypto mode. */ -}; - -/** - * nss_qvpn_hdr_configure_msg - * QVPN header configuration. - */ -struct nss_qvpn_hdr_configure_msg { - uint32_t src_ip[4]; /**< Source IP address. */ - uint32_t dst_ip[4]; /**< Destination IP address. */ - uint16_t src_port; /**< Source port. */ - uint16_t dst_port; /**< Destination port. */ - uint16_t hdr_flags; /**< Header flags. */ - uint16_t seqnum_size; /**< Size of sequence number. */ - uint16_t seqnum_offset; /**< Sequence number offset. */ - uint16_t anti_replay_alg; /**< Anti-replay algorithm. */ - uint16_t session_id_size; /**< Session ID size. */ - uint16_t session_id_offset; /**< Session ID offset. */ - uint16_t vpn_hdr_head_size; /**< VPN header size. */ - uint16_t vpn_hdr_head_offset; /**< VPN header offset. */ - uint16_t vpn_hdr_tail_size; /**< Size of tail. */ - uint16_t res; /**< Reserved for alignment. */ - uint8_t vpn_hdr_head[NSS_QVPN_VPN_HDR_HEAD_SIZE_MAX]; /**< Content of VPN header. */ - uint8_t vpn_hdr_tail[NSS_QVPN_VPN_HDR_TAIL_SIZE_MAX]; /**< VPN header tail content. */ - uint8_t hop_limit; /**< TTL or hop limit. */ - uint8_t res1[3]; /**< Reserved for alignment. */ -}; - -/** - * nss_qvpn_crypto_configure_msg - * QVPN crypto configuration message. - */ -struct nss_qvpn_crypto_configure_msg { - uint16_t hmac_len; /**< Length of HMAC to copy. */ - uint16_t hmac_offset; /**< Offset to copy HMAC. */ - uint16_t auth_offset; /**< Data offset to start authentication. */ - uint16_t cipher_op_offset; /**< Start of cipher data. */ - uint16_t cipher_blk_size; /**< Cipher block size. */ - uint16_t pad_type; /**< Pad algorithm. */ - uint16_t crypto_mode; /**< Crypto mode. */ - uint16_t iv_len; /**< Length of IV. */ - uint16_t iv_offset; /**< IV offset. */ - uint16_t iv_type; /**< IV generation algorithm. */ - uint8_t iv_val[NSS_QVPN_IV_SIZE_MAX]; /**< IV to be used. */ -}; - -/** - * nss_qvpn_crypto_key_add_msg - * QVPN key add message. - */ -struct nss_qvpn_crypto_key_add_msg { - uint32_t crypto_idx; /**< Crypto session ID. */ - uint8_t session_id[NSS_QVPN_SESS_ID_SIZE_MAX]; /**< Session ID. */ -}; - -/** - * nss_qvpn_crypto_key_del_msg - * Delete/Deactivate key message. - */ -struct nss_qvpn_crypto_key_del_msg { - uint32_t crypto_idx; /**< Crypto index to delete/deactivate. */ -}; - -/** - * nss_qvpn_tunnel_config_msg - * QVPN tunnel configure message. - */ -struct nss_qvpn_tunnel_config_msg { - uint32_t sibling_if; /**< Sibling interface number. */ - uint16_t total_cmds; /**< Total number of commands. */ - uint16_t cmd_profile; /**< Command processing profile. */ - uint16_t cmd[NSS_QVPN_CMDS_MAX]; /**< Commands to execute. */ - struct nss_qvpn_crypto_key_add_msg crypto_key; /**< Initial crypto key. */ - struct nss_qvpn_hdr_configure_msg hdr_cfg; /**< VPN header configuration. */ - struct nss_qvpn_crypto_configure_msg crypto_cfg; /**< Crypto configuration. */ -}; - -/** - * nss_qvpn_crypto_key_activate_msg - * Activate key message. - */ -struct nss_qvpn_crypto_key_activate_msg { - uint32_t crypto_idx; /**< Crypto session ID. */ - uint8_t vpn_hdr_head[NSS_QVPN_VPN_HDR_HEAD_SIZE_MAX]; /**< Content of VPN header. */ -}; - -/** - * nss_qvpn_stats_sync_msg - * Message information for QVPN synchronization statistics. - */ -struct nss_qvpn_stats_sync_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - uint32_t crypto_resp_error[NSS_CRYPTO_CMN_RESP_ERROR_MAX]; /**< Crypto response errors. */ - uint32_t pkt_drop_event[NSS_QVPN_PKT_DROP_EVENT_MAX]; /**< Packet drop events. */ - uint32_t exception_event[NSS_QVPN_EXCEPTION_EVENT_MAX]; /**< QVPN exception events. */ -}; - -/** - * 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. - */ -struct nss_qvpn_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /**< QVPN configuration messages. */ - union { - struct nss_qvpn_tunnel_config_msg tunnel_config; /**< QVPN tunnel configure message. */ - struct nss_qvpn_crypto_key_add_msg key_add; /**< Crypto key add message. */ - struct nss_qvpn_crypto_key_del_msg key_del; /**< Crypto key delete message. */ - struct nss_qvpn_crypto_key_activate_msg key_activate; /**< Crypto key active message. */ - struct nss_qvpn_stats_sync_msg stats; /**< QVPN statistics synchronization message. */ - } msg; /**< QVPN configuration message. */ -}; - -/** - * nss_qvpn_tx_msg - * Sends an QVPN message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_qvpn_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_qvpn_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_qvpn_msg *msg); - -/** - * nss_qvpn_tx_msg_sync - * Sends an QVPN message to the NSS synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_qvpn_msg \n - * nss_qvpn_msg_type \n - * nss_qvpn_error_type - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] nvm Pointer to the message data. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in,out] resp Response for the configuration. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_qvpn_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_qvpn_msg *nvm, - uint32_t if_num, enum nss_qvpn_msg_type type, uint16_t len, - enum nss_qvpn_error_type *resp); - -/** - * nss_qvpn_tx_buf - * Sends data packet for QVPN encapsulation/decapsulation. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] if_num NSS interface number. - * @param[in] skb Pointer to sk_buff. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_qvpn_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, struct sk_buff *skb); - -/** - * nss_qvpn_msg_init - * Initializes an QVPN message. - * - * @datatypes - * nss_qvpn_msg - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -void nss_qvpn_msg_init(struct nss_qvpn_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); - -/** - * nss_qvpn_get_context - * Gets the QVPN context used in nss_qvpn_tx. - * - * @return - * Pointer to the NSS core context. - */ -struct nss_ctx_instance *nss_qvpn_get_context(void); - -/** - * Callback when QVPN data is received. - * - * @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_qvpn_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback to receive QVPN 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_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. - * - * @datatypes - * nss_qvpn_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] qvpn_data_callback Callback for the data. - * @param[in] qvpn_event_callback Callback for receiving events. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * @param[in] app_ctx Pointer to the application context of the message. - * - * @return - * Pointer to the NSS core context. - */ -struct nss_ctx_instance *nss_qvpn_register_if(uint32_t if_num, nss_qvpn_callback_t qvpn_data_callback, - nss_qvpn_msg_callback_t qvpn_event_callback, struct net_device *netdev, - uint32_t features, void *app_ctx); - -/** - * nss_qvpn_ifnum_with_core_id - * Gets the QVPN interface number with the core ID. - * - * @param[in] if_num NSS interface number. - * - * @return - * Interface number with the core ID. - */ -int nss_qvpn_ifnum_with_core_id(int if_num); - -/** - * nss_qvpn_register_handler - * Registers the QVPN handler with the NSS. - * - * @return - * None. - */ -void nss_qvpn_register_handler(void); - -/** - * nss_qvpn_ifmap_get - * Returns active QVPN interfaces. - * - * @return - * Pointer to interface map. - */ -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); - -/** - * @} - */ - -#endif /* _NSS_QVPN_H_ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_rmnet_rx.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_rmnet_rx.h deleted file mode 100644 index 2b7e7156e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_rmnet_rx.h +++ /dev/null @@ -1,392 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_rmnet_rx.h - * NSS RMNET interface message Structure and APIs - */ - -#ifndef __NSS_RMNET_RX_H -#define __NSS_RMNET_RX_H - -#include "nss_if.h" - -/** - * @addtogroup nss_rmnet_subsystem - * @{ - */ - -/** - * Maximum number of DMA channel. - */ -#define NSS_RMNET_RX_CHANNEL_MAX 12 - -/** - * nss_rmnet_rx_dp_type - * Interface datapath types. NSS-to-host path will be seen by ECM for rules. - */ -enum nss_rmnet_rx_dp_type { - NSS_RMNET_RX_DP_N2H, /**< Interface on NSS-to-host path has zero value. */ - NSS_RMNET_RX_DP_H2N, /**< Interface on host-to-NSS path has non-zero value. */ -}; - -/** - * nss_rmnet_rx_msg_types - * Message types for interface requests and responses. - */ -enum nss_rmnet_rx_msg_types { - NSS_RMNET_RX_TX_CONFIG_MSG = NSS_IF_MAX_MSG_TYPES + 1, - /**< Configuration message. */ - NSS_RMNET_RX_STATS_SYNC_MSG, /**< Statistic synchronization message. */ - NSS_RMNET_RX_MAX_MSG_TYPES, /**< Maximum message type. */ -}; - -/** - * nss_rmnet_rx_error_types - * Error types for the RMNET interface. - */ -enum nss_rmnet_rx_error_types { - NSS_RMNET_RX_SUCCESS, /**< No error. */ - NSS_RMNET_RX_ERROR_TYPE_MSG_UNKNOWN, /**< Unknown message type. */ - NSS_RMNET_RX_ERROR_TYPE_ALREADY_CONFIGURED, /**< Tunnel is already configured. */ - NSS_RMNET_RX_ERROR_TYPE_SIBLING_NOTFOUND, /**< Sibling interface is not found. */ - NSS_RMNET_RX_ERROR_TYPE_NEXTHOP_NOTFOUND, /**< Next hop is not found. */ - NSS_RMNET_RX_ERROR_TYPE_SIBLING_MISMATCH, /**< Sibling interface type mismatches. */ - NSS_RMNET_RX_ERROR_TYPE_DMA_CHANNEL_FAIL, /**< DMA Channel allocation failed. */ - NSS_RMNET_RX_ERROR_TYPE_RMNET_INVALID, /**< Interface type is invalid. */ - NSS_RMNET_RX_ERROR_TYPE_SHAPER_INVALID, /**< Shaper is invalid. */ - NSS_RMNET_RX_REG_FAILURE, /**< Registration failed. */ - NSS_RMNET_RX_ALLOC_FAILURE, /**< Memory allocation failed. */ - NSS_RMNET_RX_ERROR_MAX, /**< Maximum error type. */ -}; - -/** - * nss_rmnet_rx_pvt - * Private data information for the interface. - */ -struct nss_rmnet_rx_pvt { - struct semaphore sem; - /**< Semaphore to ensure that only one instance of a message is sent to the NSS. */ - struct completion complete; - /**< Waits for message completion or time out. */ - int response; /**< Message process response from the NSS firmware. */ - int sem_init_done; /**< Semaphore initialization is done. */ -}; - -/** - * nss_rmnet_rx_config_msg - * Message information for configuring the interface. - */ -struct nss_rmnet_rx_config_msg { - uint32_t flags; /**< Interface flags. */ - uint32_t sibling; /**< Sibling interface number. */ - uint32_t nexthop; /**< Next hop interface number. */ - uint32_t no_channel; /**< Number of channels. */ -}; - -/** - * nss_rmnet_rx_stats - * Interface statistics received from the NSS. - */ -struct nss_rmnet_rx_stats { - struct nss_cmn_node_stats node_stats; - /**< Common statistics. */ - uint32_t enqueue_failed; /**< Enqueue to next node is failed. */ - uint32_t no_avail_channel; /**< No available DMA channel. */ - uint32_t num_linear_pbuf; /**< Number of linear pbufs. */ - uint32_t no_pbuf_to_linear; /**< No pbuf to linearize. */ - uint32_t no_enough_room; /**< Not enough headroom to linearize the pbuf. */ - uint32_t using_channel[NSS_RMNET_RX_CHANNEL_MAX]; - /**< How many times a channel is used. */ - uint32_t dma_failed; /**< DMA copy call failed. */ -}; - - -/** - * nss_rmnet_rx_msg - * Data for sending and receiving interface messages. - */ -struct nss_rmnet_rx_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of an RMNET interface message. - */ - union { - struct nss_rmnet_rx_config_msg if_config; - /**< Rule for creating an RMNET interface. */ - struct nss_rmnet_rx_stats stats; - /**< RMNET interface statistics. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback to transmit interface data received from NSS - * to the transmit path of the RMNET interface. - * - * @datatypes - * net_device \n - * sk_buff - * - * @param[in] netdev Pointer to the associated network device. - * @param[in] skb Pointer to the data socket buffer. - */ -typedef void (*nss_rmnet_rx_xmit_callback_t)(struct net_device *netdev, struct sk_buff *skb); - -/** - * Callback function for interface 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_rmnet_rx_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback function for interface 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_rmnet_rx_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * nss_rmnet_rx_handle - * Context information for NSS communication. - */ -struct nss_rmnet_rx_handle { - struct nss_ctx_instance *nss_ctx; /**< NSS context. */ - int32_t if_num_n2h; /**< Redirect interface number on NSS-to-host path. */ - 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. */ - 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. */ -}; - -/** - * nss_rmnet_rx_destroy_sync - * Destroys the RMNET interface synchronously. - * - * @datatypes - * nss_rmnet_rx_handle - * - * @param[in,out] handle Pointer to the RMNET interface handle (provided during - * dynamic interface allocation). - * - * @return - * Status of the Tx operation. - * - * @dependencies - * The interface must have been previously created. - */ -extern nss_tx_status_t nss_rmnet_rx_destroy_sync(struct nss_rmnet_rx_handle *handle); - -/** - * nss_rmnet_rx_create_sync_nexthop - * Creates an RMNET interface synchronously with specified nexthops. - * - * @datatypes - * net_device - * - * @param[in] netdev Pointer to the associated network device. - * @param[in] nexthop_n2h Nexthop interface number of NSS-to-host dynamic interface. - * @param[in] nexthop_h2n Nexthop interface number of host-to-NSS dynamic interface. - * - * @return - * Pointer to the NSS RMNET 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. - * - * @datatypes - * nss_rmnet_rx_handle \n - * sk_buff - * - * @param[in,out] handle Pointer to the RMNET interface handle (provided during - * registration). - * @param[in] skb Pointer to the data socket buffer. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_rmnet_rx_tx_buf(struct nss_rmnet_rx_handle *handle, - struct sk_buff *skb); - -/** - * nss_rmnet_rx_tx_msg - * Sends a message to the RMNET 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. - * - * @return - * Command Tx status. - */ -extern nss_tx_status_t nss_rmnet_rx_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_rmnet_rx_msg *nvim); - -/** - * nss_rmnet_rx_xmit_callback_unregister - * Deregisters the transmit callback from the RMNET interface. - * - * @datatypes - * nss_rmnet_rx_handle - * - * @param[in,out] handle Pointer to the RMNET interface handle. - * - * @return - * None. - */ -extern void nss_rmnet_rx_xmit_callback_unregister(struct nss_rmnet_rx_handle *handle); - -/** - * nss_rmnet_rx_xmit_callback_register - * Registers a transmit callback to an RMNET 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 - * dynamic interface allocation). - * @param[in] cb Callback handler for RMNET data packets. - * - * @return - * None. - */ -extern void nss_rmnet_rx_xmit_callback_register(struct nss_rmnet_rx_handle *handle, - nss_rmnet_rx_xmit_callback_t cb); - -/** - * nss_rmnet_rx_unregister - * Deregisters an RMNET interface from the NSS driver. - * - * @datatypes - * nss_rmnet_rx_handle - * - * @param[in,out] handle Pointer to the RMNET interface handle. - * - * @return - * None. - */ -extern void nss_rmnet_rx_unregister(struct nss_rmnet_rx_handle *handle); - -/** - * nss_rmnet_rx_register - * Registers an RMNET 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 - * dynamic interface allocation). - * @param[in] data_callback Callback handler for RMNET data packets. - * @param[in] netdev Pointer to the associated network device. - * - * @return - * Status of the Tx operation. - */ -extern void nss_rmnet_rx_register(struct nss_rmnet_rx_handle *handle, - nss_rmnet_rx_data_callback_t data_callback, - struct net_device *netdev); - -/** - * nss_rmnet_rx_get_ifnum_with_coreid - * Returns the interface number with the core ID. - * - * @param[in] if_num NSS interface number - * - * @return - * Interface number with the core ID. - */ -extern int32_t nss_rmnet_rx_get_ifnum_with_core_id(int32_t if_num); - -/** - * nss_rmnet_rx_get_ifnum - * Returns the interface number with appending core ID. - * - * @param[in] dev Net device - * - * @return - * Interface number with the core ID. - */ -extern int32_t nss_rmnet_rx_get_ifnum(struct net_device *dev); - -/** - * nss_rmnet_rx_get_interface_num - * Returns the RMNET interface number associated with the handle. - * - * @datatypes - * nss_rmnet_rx_handle - * - * @param[in] handle Pointer to the RMNET interface handle (provided during - dynamic interface allocation). - * - * @return - * RMNET 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. - * - * @return - * Pointer to the NSS core context. - */ -struct nss_ctx_instance *nss_rmnet_rx_get_context(void); - -/** - * @} - */ - -#endif /* __NSS_RMNET_RX_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_rps.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_rps.h deleted file mode 100644 index 213604ea3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_rps.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2013-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. - ************************************************************************** - */ - -/** - * @file nss_rps.h - * RPS related definitions. - */ - -#ifndef __NSS_RPS_H -#define __NSS_RPS_H - -/** - * @addtogroup nss_rps_subsystem - * @{ - */ - -/** - * nss_rps_register_sysctl - * Registers the RPS sysctl entries to the sysctl tree. - * - * @return - * None. - */ -extern void nss_rps_register_sysctl(void); - -/** - * nss_rps_unregister_sysctl - * Deregisters the RPS sysctl entries from the sysctl tree. - * - * @return - * None. - * - * @dependencies - * The system control must have been previously registered. - */ -extern void nss_rps_unregister_sysctl(void); - -/** - * @} - */ - -#endif /* __NSS_RPS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_shaper.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_shaper.h deleted file mode 100644 index fbb0415ae..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_shaper.h +++ /dev/null @@ -1,901 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/** - * @file nss_shaper.h - * NSS Shaper definitions - */ - -#ifndef __NSS_SHAPER_H -#define __NSS_SHAPER_H - -/** - * @addtogroup nss_shaper_subsystem - * @{ - */ - -/** - * nss_shaper_node_types - * Types of shaper nodes that are exported to the HLOS. - */ -enum nss_shaper_node_types { - NSS_SHAPER_NODE_TYPE_CODEL = 1, - NSS_SHAPER_NODE_TYPE_PRIO = 3, - NSS_SHAPER_NODE_TYPE_FIFO = 4, - NSS_SHAPER_NODE_TYPE_TBL = 5, - NSS_SHAPER_NODE_TYPE_BF = 6, - NSS_SHAPER_NODE_TYPE_BF_GROUP = 7, - NSS_SHAPER_NODE_TYPE_WRR = 9, - NSS_SHAPER_NODE_TYPE_WRR_GROUP = 10, - NSS_SHAPER_NODE_TYPE_HTB = 11, - NSS_SHAPER_NODE_TYPE_HTB_GROUP = 12, - NSS_SHAPER_NODE_TYPE_WRED = 13, - NSS_SHAPER_NODE_TYPE_PPE_SN = 14, - NSS_SHAPER_NODE_TYPE_MAX, -}; - -typedef enum nss_shaper_node_types nss_shaper_node_type_t; - /**< Types of shaper nodes that are exported to the HLOS. */ - -/** - * nss_shaper_config_types - * Types of shaper configuration messages. - */ -enum nss_shaper_config_types { - NSS_SHAPER_CONFIG_TYPE_ALLOC_SHAPER_NODE, - 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_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, - NSS_SHAPER_CONFIG_TYPE_HYBRID_MODE_ENABLE, - NSS_SHAPER_CONFIG_TYPE_HYBRID_MODE_DISABLE, - NSS_SHAPER_CONFIG_TYPE_SHAPER_NODE_MEM_REQ, -}; - -typedef enum nss_shaper_config_types nss_shaper_config_type_t; - /**< Types of shaper configuration messages. */ - -/** - * nss_shaper_response_types - * Types of shaper configuration responses. - */ -enum nss_shaper_response_types { - NSS_SHAPER_RESPONSE_TYPE_SUCCESS, - NSS_SHAPER_RESPONSE_TYPE_NO_SHAPER_NODE, - NSS_SHAPER_RESPONSE_TYPE_NO_SHAPER_NODES, - NSS_SHAPER_RESPONSE_TYPE_OLD, - NSS_SHAPER_RESPONSE_TYPE_UNRECOGNISED, - NSS_SHAPER_RESPONSE_TYPE_BAD_DEFAULT_CHOICE, - NSS_SHAPER_RESPONSE_TYPE_DUPLICATE_QOS_TAG, - NSS_SHAPER_RESPONSE_TYPE_TBL_CIR_RATE_AND_BURST_REQUIRED, - NSS_SHAPER_RESPONSE_TYPE_TBL_CIR_BURST_LESS_THAN_MTU, - NSS_SHAPER_RESPONSE_TYPE_CODEL_ALL_PARAMS_REQUIRED, - NSS_SHAPER_RESPONSE_TYPE_BF_GROUP_RATE_AND_BURST_REQUIRED, - NSS_SHAPER_RESPONSE_TYPE_BF_GROUP_BURST_LESS_THAN_MTU, - NSS_SHAPER_RESPONSE_TYPE_CHILD_NOT_BF_GROUP, - NSS_SHAPER_RESPONSE_TYPE_WRR_GROUP_INVALID_QUANTUM, - NSS_SHAPER_RESPONSE_TYPE_CHILD_NOT_WRR_GROUP, - NSS_SHAPER_RESPONSE_TYPE_WRR_INVALID_OPERATION_MODE, - NSS_SHAPER_RESPONSE_TYPE_HTB_GROUP_BURST_LESS_THAN_MTU, - NSS_SHAPER_RESPONSE_TYPE_HTB_GROUP_PRIORITY_OUT_OF_RANGE, - NSS_SHAPER_RESPONSE_TYPE_CHILDREN_BELONG_TO_MIXED_TYPES, - NSS_SHAPER_RESPONSE_TYPE_CHILD_ALREADY_PRESENT, - NSS_SHAPER_RESPONSE_TYPE_CHILD_MISMATCH, - NSS_SHAPER_RESPONSE_TYPE_CHILD_UNSUPPORTED, - NSS_SHAPER_RESPONSE_TYPE_CHILD_NOT_FOUND, - NSS_SHAPER_RESPONSE_TYPE_ATTACH_FAIL, - NSS_SHAPER_RESPONSE_TYPE_WRED_WEIGHT_MODE_INVALID, - NSS_SHAPER_RESPONSE_TYPE_PPE_SN_UCAST_BASE_OFFSET_INVALID, - NSS_SHAPER_RESPONSE_TYPE_PPE_SN_MCAST_BASE_OFFSET_INVALID, - NSS_SHAPER_RESPONSE_TYPE_PPE_SN_UCAST_QUEUE_ALLOC_FAILED, - NSS_SHAPER_RESPONSE_TYPE_PPE_SN_MCAST_QUEUE_ALLOC_FAILED, - NSS_SHAPER_RESPONSE_TYPE_PPE_SN_INVALID_LIMIT, - NSS_SHAPER_RESPONSE_TYPE_PPE_SN_UCAST_QUEUE_CHANGED, - NSS_SHAPER_RESPONSE_TYPE_PPE_SN_MCAST_QUEUE_CHANGED, - NSS_SHAPER_RESPONSE_TYPE_CODEL_FQ_MEM_INSUFFICIENT, - NSS_SHAPER_RESPONSE_TYPE_CODEL_FQ_COUNT_CHANGE_NOT_ALLOWED, - NSS_SHAPER_RESPONSE_TYPE_CODEL_FQ_COUNT_INVALID, - NSS_SHAPER_RESPONSE_TYPE_CODEL_MODE_CHANGE_NOT_ALLOWED, -}; - -typedef enum nss_shaper_response_types nss_shaper_response_type_t; - /**< Types of shaper configuration responses. */ - -/** - * nss_shaper_config_alloc_shaper_node - * Message information for allocating a shaper node for a NSS interface. - */ -struct nss_shaper_config_alloc_shaper_node { - nss_shaper_node_type_t node_type; /**< Type of shaper node. */ - uint32_t qos_tag; /**< QoS tag of the node. */ -}; - -/** - * nss_shaper_config_free_shaper_node - * Message information for freeing a shaper node from a NSS interface. - */ -struct nss_shaper_config_free_shaper_node { - uint32_t qos_tag; /**< QoS tag of the node. */ -}; - -/** - * nss_shaper_config_set_root_node - * Message information for setting a shaper node as the root. - */ -struct nss_shaper_config_set_root_node { - uint32_t qos_tag; /**< QoS tag of the node. */ -}; - -/** - * nss_shaper_config_set_default_node - * Message information for setting a shaper node as the default node for enqueueing. - */ -struct nss_shaper_config_set_default_node { - uint32_t qos_tag; /**< QoS tag of the node. */ -}; - -/** - * nss_shaper_config_set_hybrid_mode - * Message information for setting a shaper to operate in hybrid mode. - */ -struct nss_shaper_config_set_hybrid_mode { - uint32_t offset; /**< Queue offset for packets sent to the hardware. */ -}; - -/** - * nss_shaper_config_prio_attach - * Message information for attaching a shaper node to a PRIO shaper node. - */ -struct nss_shaper_config_prio_attach { - uint32_t child_qos_tag; /**< QoS tag of the child shaper node. */ - uint32_t priority; /**< Priority of the child shaper node. */ -}; - -/** - * nss_shaper_config_prio_detach - * Message information for detaching a shaper node from a PRIO shaper node. - */ -struct nss_shaper_config_prio_detach { - uint32_t priority; /**< Priority of the child shaper node. */ -}; - -/** - * nss_shaper_config_codel_alg_param - * Message information for configuring a CoDel algorithm. - */ -struct nss_shaper_config_codel_alg_param { - uint16_t interval; /**< Buffer time to smooth a state transition. */ - uint16_t target; /**< Acceptable delay associated with a queue. */ - uint16_t mtu; /**< MTU for the associated interface. */ - uint16_t reserved; /**< Alignment padding. */ -}; - -/** - * nss_shaper_config_codel_param - * Message information for configuring a CoDel shaper node. - */ -struct nss_shaper_config_codel_param { - int32_t qlen_max; /**< Maximum number of packets that can be enqueued. */ - struct nss_shaper_config_codel_alg_param cap; - /**< Configuration for the CoDel algorithm. */ - uint32_t flows; /**< Number of flow hash buckets. */ - uint32_t flows_mem; /**< Host allocated memory for flow queues. */ - uint32_t flows_mem_sz; /**< Memory size allocated for flow queues. */ - uint32_t quantum; /**< Quantum (in bytes) to round-robin the flow buckets. */ - uint32_t ecn; /**< 0 - ECN disabled, 1 - ECN enabled. */ -}; - -/** - * nss_shaper_config_codel_mem_req - * Message to get CoDel memory requirement per flow queue (needed for fq_codel). - */ -struct nss_shaper_config_codel_mem_req { - uint32_t mem_req; /**< Memory needed per flow queue (in bytes). */ -}; - -/** - * nss_shaper_config_rate_param - * Message information for configuring the rate limiter algorithm. - */ -struct nss_shaper_config_rate_param { - uint32_t rate; - /**< Allowed traffic rate measured in bytes per second. */ - uint32_t burst; - /**< Maximum bytes that can be sent in a burst. */ - uint32_t max_size; - /**< Maximum size of the supported packets (in bytes). */ - - /** - * Specifies whether the rate limiter will be bypassed (short circuited). - */ - bool short_circuit; -}; - -/** - * nss_shaper_configure_tbl_attach - * Message information for attaching a shaper node to a TBL shaper node. - */ -struct nss_shaper_config_tbl_attach { - uint32_t child_qos_tag; /**< QoS tag of the child shaper node. */ -}; - -/** - * nss_shaper_configure_tbl_param - * Message information for detaching a shaper node from a TBL shaper node. - */ -struct nss_shaper_config_tbl_param { - struct nss_shaper_config_rate_param lap_cir; - /**< Configuration parameters for the committed information rate. */ - struct nss_shaper_config_rate_param lap_pir; - /**< Configuration parameters for the peak information rate. */ -}; - -/** - * nss_shaper_config_bf_attach - * Message information for attaching a shaper node to a BF shaper node. - */ -struct nss_shaper_config_bf_attach { - uint32_t child_qos_tag; /**< QoS tag of the child shaper node. */ -}; - -/** - * nss_shaper_config_bf_detach - * Message information for detaching a shaper node from a BF shaper node. - */ -struct nss_shaper_config_bf_detach { - uint32_t child_qos_tag; /**< QoS tag of the child shaper node. */ -}; - -/** - * nss_shaper_config_bf_group_attach - * Message information for attaching a shaper node to a BF group shaper node. - */ -struct nss_shaper_config_bf_group_attach { - uint32_t child_qos_tag; /**< QoS tag of the child shaper node. */ -}; - -/** - * nss_shaper_config_bf_group_param - * Configuration parameters for a BF group shaper node. - */ -struct nss_shaper_config_bf_group_param { - uint32_t quantum; - /**< Smallest increment value for the DRRs. */ - struct nss_shaper_config_rate_param lap; - /**< Configuration of the rate control algorithm. */ -}; - -/** - * nss_shaper_config_fifo_limit_set - * Drop modes for the FIFO shaper in the NSS interface. - */ -enum nss_shaper_config_fifo_drop_modes { - NSS_SHAPER_FIFO_DROP_MODE_HEAD = 0, - NSS_SHAPER_FIFO_DROP_MODE_TAIL, - NSS_SHAPER_FIFO_DROP_MODES, -}; - -typedef enum nss_shaper_config_fifo_drop_modes nss_shaper_config_fifo_drop_mode_t; - /**< Drop modes for the FIFO shaper in the NSS interface. */ - -/** - * nss_shaper_config_fifo_param - * Message information for configuring a FIFO shaper node. - */ -struct nss_shaper_config_fifo_param { - uint32_t limit; /**< Queue limit in packets. */ - nss_shaper_config_fifo_drop_mode_t drop_mode; - /**< FIFO drop mode when a queue is full. */ -}; - -/** - * nss_shaper_config_wred_weight_modes - * Supported weight modes. - */ -enum nss_shaper_config_wred_weight_modes { - NSS_SHAPER_WRED_WEIGHT_MODE_DSCP = 0, - NSS_SHAPER_WRED_WEIGHT_MODES, -}; - -typedef enum nss_shaper_config_wred_weight_modes nss_shaper_config_wred_weight_mode_t; - /**< Supported weight modes. */ - -/** - * nss_shaper_red_alg_param - * Message information for configuring the RED algorithm. - */ -struct nss_shaper_red_alg_param { - uint32_t min; /**< Minimum size of the queue. */ - uint32_t max; /**< Maximum size of the queue. */ - - /** - * Probability of dropped packets when the average queue size (qlen_avg) = max. - */ - uint32_t probability; - - /** - * Exponential weight factor to calculate the average queue size. - */ - uint32_t exp_weight_factor; -}; - -/** - * nss_shaper_config_wred_param - * Message information for configuring the WRED algorithm. - */ -struct nss_shaper_config_wred_param { - uint32_t limit; /**< Queue limit in bytes. */ - nss_shaper_config_wred_weight_mode_t weight_mode; - /**< WRED weight mode. */ - uint32_t traffic_classes; /**< Number of traffic classes (drop probability). */ - uint32_t def_traffic_class; /**< Default traffic class used when there is no match. */ - uint32_t traffic_id; /**< Traffic class to configure. */ - uint32_t weight_mode_value; /**< Value to match the selected header field against. */ - struct nss_shaper_red_alg_param rap; - /**< Configuration parameters for the RED algorithm. */ - uint8_t ecn; /**< Mark an ECN bit or drop packet. */ -}; - -/** - * nss_shaper_config_wrr_attach - * Message information for attaching a shaper node to a WRR shaper node. - */ -struct nss_shaper_config_wrr_attach { - uint32_t child_qos_tag; /**< QoS tag of the child shaper node. */ -}; - -/** - * nss_shaper_config_wrr_detach - * Message information for detaching a child node from a WRR shaper node. - */ -struct nss_shaper_config_wrr_detach { - uint32_t child_qos_tag; /**< QoS tag of the child shaper node. */ -}; - -/** - * nss_shaper_config_wrr_group_attach - * Message information for attaching a shaper node to a WRR group. - */ -struct nss_shaper_config_wrr_group_attach { - uint32_t child_qos_tag; /**< QoS tag of the child shaper node. */ -}; - -/** - * nss_shaper_wrr_operation_modes - * Modes of WRR operation. - */ -enum nss_shaper_wrr_operation_modes { - NSS_SHAPER_WRR_MODE_ROUND_ROBIN = 0, - NSS_SHAPER_WRR_MODE_FAIR_QUEUEING = 1, - NSS_SHAPER_WRR_MODE_TYPE_MAX, -}; - -/** - * nss_shaper_config_wrr_param - * Message information for configuring the operation mode of a WRR shaper node. - */ -struct nss_shaper_config_wrr_param { - uint32_t operation_mode; /**< Mode in which to operate. */ -}; - -/** - * nss_shaper_config_wrr_group_param - * Message information for configuring a quantum value of a WRR group shaper node. - */ -struct nss_shaper_config_wrr_group_param { - uint32_t quantum; /**< Smallest increment value for the DRRs. */ -}; - -/** - * nss_shaper_config_htb_attach - * Message information for attaching a shaper node to an HTB shaper node. - */ -struct nss_shaper_config_htb_attach { - uint32_t child_qos_tag; /**< QoS tag of the child shaper node. */ -}; - -/** - * nss_shaper_config_htb_group_attach - * Message information for attaching a shaper node to an HTB group. - */ -struct nss_shaper_config_htb_group_attach { - uint32_t child_qos_tag; /**< QoS tag of the child shaper node. */ -}; - -/** - * nss_shaper_config_htb_group_detach - * Message information for detaching a shaper node from an HTB group. - */ -struct nss_shaper_config_htb_group_detach { - uint32_t child_qos_tag; /**< QoS tag of the child shaper node. */ -}; - -/** - * nss_shaper_config_htb_group_param - * Message information for configuring an HTB group shaper node. - */ -struct nss_shaper_config_htb_group_param { - uint32_t quantum; /**< Smallest increment value for the DRRs. */ - uint32_t priority; /**< Value of the priority for this group. */ - uint32_t overhead; /**< Overhead in bytes to be added per packet. */ - struct nss_shaper_config_rate_param rate_police; - /**< Configuration parameters for the policing rate. */ - struct nss_shaper_config_rate_param rate_ceil; - /**< Configuration parameters for the ceiling rate. */ -}; - -/** - * nss_shaper_config_ppe_sn_attach - * Message information for attaching a shaper node to a PPE shaper node. - */ -struct nss_shaper_config_ppe_sn_attach { - uint32_t child_qos_tag; /**< QoS tag of the child shaper node. */ -}; - -/** - * nss_shaper_config_ppe_sn_detach - * Message information for detaching a shaper node from a PPE shaper node. - */ -struct nss_shaper_config_ppe_sn_detach { - uint32_t child_qos_tag; /**< QoS tag of the child shaper node. */ -}; - -/** - * nss_shaper_config_ppe_sn_type - * Types of PPE shaper nodes. - */ -enum nss_shaper_config_ppe_sn_type { - /* - * Scheduler types. - */ - NSS_SHAPER_CONFIG_PPE_SN_TYPE_HTB, - NSS_SHAPER_CONFIG_PPE_SN_TYPE_HTB_GROUP, - NSS_SHAPER_CONFIG_PPE_SN_TYPE_TBL, - NSS_SHAPER_CONFIG_PPE_SN_TYPE_WRR, - NSS_SHAPER_CONFIG_PPE_SN_TYPE_WRR_GROUP, - NSS_SHAPER_CONFIG_PPE_SN_TYPE_PRIO, - NSS_SHAPER_CONFIG_PPE_SN_SCH_MAX = 0xFF, - - /* - * Queue types. - */ - NSS_SHAPER_CONFIG_PPE_SN_TYPE_FIFO, - NSS_SHAPER_CONFIG_PPE_SN_TYPE_RED, - NSS_SHAPER_CONFIG_PPE_SN_TYPE_MAX, -}; - -/** - * nss_shaper_config_ppe_sn_param - * Message information for configuring a PPE shaper node. - */ -struct nss_shaper_config_ppe_sn_param { - enum nss_shaper_config_ppe_sn_type type; - /**< Type of PPE shaper node. */ - uint16_t ucast_base; /**< Resource ID of the base hardware for unicast queue. */ - uint16_t ucast_offset; /**< Offset from the base resource ID for unicast queue. */ - uint16_t mcast_base; /**< Resource ID of the base hardware for multicast queue. */ - uint16_t mcast_offset; /**< Offset from the base resource ID for multicast queue. */ - uint8_t port; /**< PPE port on which this shaper node is configured. */ - uint8_t reserved; /**< Reserved for padding. */ - uint16_t limit; /**< Limit of the queue. */ -}; - -/* - * nss_shaper_node_config - * Configuration messages for all types of shaper nodes. - */ -struct nss_shaper_node_config { - uint32_t qos_tag; /**< ID of the shaper node to be configured. */ - - /** - * Configuration messages for all types of shaper nodes. - */ - union { - struct nss_shaper_config_prio_attach prio_attach; - /**< Attach a shaper node to a PRIO shaper node. */ - struct nss_shaper_config_prio_detach prio_detach; - /**< Detach a shaper node from a PRIO shaper node. */ - - struct nss_shaper_config_codel_param codel_param; - /**< Configure a CoDel shaper node. */ - - struct nss_shaper_config_codel_mem_req codel_mem_req; - /**< Get CoDel memory requirement. */ - - struct nss_shaper_config_tbl_attach tbl_attach; - /**< Attach a shaper node to a TBL shaper node. */ - struct nss_shaper_config_tbl_param tbl_param; - /**< Configuration parameters for a TBL shaper node. */ - - struct nss_shaper_config_bf_attach bf_attach; - /**< Attach a shaper node to a BF shaper node. */ - struct nss_shaper_config_bf_detach bf_detach; - /**< Detach a child shaper node from BF shaper node. */ - struct nss_shaper_config_bf_group_attach bf_group_attach; - /**< Attach a shaper node to a BF group shaper node. */ - struct nss_shaper_config_bf_group_param bf_group_param; - /**< Configure parameters for a BF group shaper node. */ - - struct nss_shaper_config_fifo_param fifo_param; - /**< Configure a FIFO shaper node. */ - - struct nss_shaper_config_wrr_attach wrr_attach; - /**< Attach a shaper node to a WRR shaper node. */ - struct nss_shaper_config_wrr_detach wrr_detach; - /**< Detach a shaper node from a WRR shaper node. */ - struct nss_shaper_config_wrr_param wrr_param; - /**< Configuration parameters for a WRR shaper node . */ - struct nss_shaper_config_wrr_group_attach wrr_group_attach; - /**< Attach a shaper node to a WRR group shaper node. */ - struct nss_shaper_config_wrr_group_param wrr_group_param; - /**< Configure a WRR group shaper node with a quantum value. */ - struct nss_shaper_config_htb_attach htb_attach; - /**< Attach a shaper node to an HTB shaper node. */ - struct nss_shaper_config_htb_group_attach htb_group_attach; - /**< Attach a shaper node to an HTB group shaper node. */ - struct nss_shaper_config_htb_group_detach htb_group_detach; - /**< Detach a shaper node from an HTB group shaper node. */ - struct nss_shaper_config_htb_group_param htb_group_param; - /**< Configuration parameters for an HTB group shaper node. */ - struct nss_shaper_config_wred_param wred_param; - /**< Configuration parameters for a WRED shaper node. */ - struct nss_shaper_config_ppe_sn_attach ppe_sn_attach; - /**< Attach a shaper node to a PPE shaper node. */ - struct nss_shaper_config_ppe_sn_detach ppe_sn_detach; - /**< Detach a shaper node from a PPE shaper node. */ - struct nss_shaper_config_ppe_sn_param ppe_sn_param; - /**< Configuration parameters for a PPE shaper node. */ - } snc; /**< Types of shaper node configuration messages. */ -}; - -/** - * nss_shaper_node_codel_fq_stats_delta - * CoDel flow queue mode statistics sent as deltas. - */ -struct nss_shaper_node_codel_fq_stats_delta { - uint32_t new_flow_cnt; /**< Total number of new flows seen. */ - uint32_t ecn_mark_cnt; /**< Number of packets marked with ECN. */ -}; - -/** - * nss_shaper_node_codel_fq_stats - * CoDel flow queue mode statistics. - */ -struct nss_shaper_node_codel_fq_stats { - struct nss_shaper_node_codel_fq_stats_delta delta; - /**< CoDel flow queue statistics sent as deltas. */ - uint32_t new_flows_len; /**< Current number of new flows. */ - uint32_t old_flows_len; /**< Current number of old flows. */ - uint32_t maxpacket; /**< Largest packet seen so far. */ -}; - -/** - * nss_shaper_node_codel_sq_stats - * CoDel single queue mode statistics. - */ -struct nss_shaper_node_codel_sq_stats { - /** - * Maximum amount of time (in milliseconds) that a packet was in this shaper - * node before being dequeued. - */ - uint32_t packet_latency_peak_msec_dequeued; - - /** - * Maximum amount of time (in milliseconds) that a packet was in this shaper - * node before being dropped. - */ - uint32_t packet_latency_peak_msec_dropped; -}; - -/** - * nss_shaper_node_codel_stats - * CoDel shaper node statistics. - */ -struct nss_shaper_node_codel_stats { - struct nss_shaper_node_codel_sq_stats sq; /**< Single queue mode statistics. */ - struct nss_shaper_node_codel_fq_stats fq; /**< Flow queue mode statistics. */ -}; - -/** - * nss_shaper_node_stats_delta - * Statistics that are sent as deltas. - */ -struct nss_shaper_node_stats_delta { - uint32_t enqueued_bytes; /**< Bytes enqueued successfully. */ - uint32_t enqueued_packets; /**< Packets enqueued successfully. */ - - /** - * Bytes dropped during an enqueue operation because of node limits. - */ - uint32_t enqueued_bytes_dropped; - - /** - * Packets dropped during an enqueue operation because of node limits. - */ - uint32_t enqueued_packets_dropped; - - uint32_t dequeued_bytes; - /**< Bytes dequeued successfully from a shaper node. */ - uint32_t dequeued_packets; - /**< Packets dequeued successfully from a shaper node. */ - - /** - * Bytes dropped by this node during dequeuing (some nodes drop packets during - * dequeuing rather than enqueuing). - */ - uint32_t dequeued_bytes_dropped; - - /** - * Packets dropped by this node during dequeuing (some nodes drop packets during - * dequeuing rather than enqueuing). - */ - uint32_t dequeued_packets_dropped; - - /** - * Number of times any queue limit was overrun, leading to packet drops. - */ - uint32_t queue_overrun; - - uint32_t unused[4]; /**< Reserved for future statistics expansion. */ -}; - -/** - * nss_shaper_node_stats - * Common shaper node statistics. - */ -struct nss_shaper_node_stats { - uint32_t qlen_bytes; /**< Total size of packets waiting in the queue. */ - uint32_t qlen_packets; /**< Number of packets waiting in the queue. */ - uint32_t unused[4]; /**< Reserved for future statistics expansion. */ - struct nss_shaper_node_stats_delta delta; - /**< Statistics that are sent as deltas. */ -}; - -/** - * nss_shaper_node_stats_response - * Statistics response for shaper nodes. - */ -struct nss_shaper_node_stats_response { - struct nss_shaper_node_stats sn_stats; /**< Common shaper node statistics. */ - - /** - * All shaper nodes that need to maintain unique statistics need - * to add their statistics structure here. - */ - union { - struct nss_shaper_node_codel_stats codel; - /**< CoDel specific statistics. */ - } per_sn_stats; /**< Shaper specific statistics. */ -}; - -/** - * nss_shaper_node_stats_get - * Statistics of a shaper node. - */ -struct nss_shaper_node_stats_get { - - /* - * Request - */ - uint32_t qos_tag; /**< QoS tag of the shaper node. */ - - /* - * Response - */ - struct nss_shaper_node_stats_response response; - /**< Shaper node statistics response */ -}; - -/** - * nss_shaper_configure - * Configuration message for a shaper node. - */ -struct nss_shaper_configure { - nss_shaper_config_type_t request_type; /**< Message is a request. */ - nss_shaper_response_type_t response_type; /**< Message is a response. */ - - /** - * Types of configuration messages for a shaper node. - */ - union { - struct nss_shaper_config_alloc_shaper_node alloc_shaper_node; - /**< Allocate a shaper node in the NSS interface. */ - struct nss_shaper_config_free_shaper_node free_shaper_node; - /**< Free a shaper node from the NSS interface. */ - struct nss_shaper_config_set_default_node set_default_node; - /**< Set a shaper node as the default node for a queue. */ - struct nss_shaper_config_set_root_node set_root_node; - /**< Set a shaper node as the root shaper nod. */ - struct nss_shaper_config_set_hybrid_mode set_hybrid_mode; - /**< 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_get shaper_node_stats_get; - /**< Statistics for a shaper node. */ - } msg; /**< Types of configuration messages. */ -}; - -/** - * Registrant callback to receive shaper bounced packets - * - * @datatypes - * sk_buff - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] skb Pointer to the data socket buffer. - */ -typedef void (*nss_shaper_bounced_callback_t)(void *app_data, struct sk_buff *skb); - -/** - * nss_shaper_register_shaping - * Registers a shaper node with the NSS interface for basic shaping operations. - * - * @return - * Pointer to the NSS core context. - */ -extern void *nss_shaper_register_shaping(void); - -/** - * nss_shaper_unregister_shaping - * Deregisters a shaper node from the NSS interface. - * - * @param[in] ctx Pointer to the NSS context. - * - * @dependencies - * The shaper node must have been previously registered. - */ -extern void nss_shaper_unregister_shaping(void *ctx); - -/** - * nss_shaper_register_shaper_bounce_interface - * Registers a shaper bounce interface with the NSS interface for receiving - * shaper-bounced packets. - * - * @datatypes - * nss_shaper_bounced_callback_t \n - * module - * - * @param[in] if_num NSS interface number. - * @param[in] cb Callback function for the message. This callback is - * invoked when the NSS returns a sk_buff after shaping. - * @param[in] app_data Pointer to the application context of the message. - * This context is passed to the callback together with the - * sk_buff to provide context to the registrant (state). - * @param[in] owner Pointer to the kernel module. The module is held until it deregisters. - * - * @return - * Pointer to the NSS core context. - */ -extern void *nss_shaper_register_shaper_bounce_interface(uint32_t if_num, nss_shaper_bounced_callback_t cb, void *app_data, struct module *owner); - -/** - * nss_shaper_unregister_shaper_bounce_interface - * Deregisters a shaper bounce interface from the NSS interface. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - * - * @dependencies - * The shaper bounce interface must have been previously registered. - */ -extern void nss_shaper_unregister_shaper_bounce_interface(uint32_t if_num); - -/** - * nss_shaper_register_shaper_bounce_bridge - * Registers a shaper bounce bridge with the NSS interface for receiving - * shaper-bounced packets. - * - * @datatypes - * nss_shaper_bounced_callback_t \n - * module - * - * @param[in] if_num NSS interface number. - * @param[in] cb Callback function for the message. This callback is - * invoked when the NSS returns a sk_buff after shaping. - * @param[in] app_data Pointer to the application context of the message. - * This context is passed to the callback together with the - * sk_buff to provide context to the registrant (state). - * @param[in] owner Pointer to the kernel module. - * - * @return - * Pointer to the NSS core context. - */ -extern void *nss_shaper_register_shaper_bounce_bridge(uint32_t if_num, nss_shaper_bounced_callback_t cb, void *app_data, struct module *owner); - -/** - * nss_shaper_unregister_shaper_bounce_bridge - * Deregisters a shaper bounce bridge from the NSS interface. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - * - * @dependencies - * The shaper bounce bridge must have been previously registered. - */ -extern void nss_shaper_unregister_shaper_bounce_bridge(uint32_t if_num); - -/** - * nss_shaper_bounce_interface_packet - * Issues a packet for shaping via a bounce operation. - * - * @datatypes - * sk_buff - * - * @param[in] ctx Pointer to the NSS context provided during registration. - * @param[in] if_num NSS interface number. - * @param[in] skb Pointer to the data socket buffer. - * - * @return - * Success or failure. - */ -extern nss_tx_status_t nss_shaper_bounce_interface_packet(void *ctx, uint32_t if_num, struct sk_buff *skb); - -/** - * nss_shaper_bounce_bridge_packet - * Issues a packet for shaping via a bounce bridge. - * - * @datatypes - * sk_buff - * - * @param[in] ctx Pointer to the NSS context provided during registration. - * @param[in] if_num NSS interface number. - * @param[in] skb Pointer to the data socket buffer. - * - * @return - * Success or failure. - */ -extern nss_tx_status_t nss_shaper_bounce_bridge_packet(void *ctx, uint32_t if_num, struct sk_buff *skb); - -/** - * nss_shaper_config_send - * Sends a shaping configuration message. - * - * @datatypes - * nss_shaper_configure - * - * @param[in] ctx Pointer to the NSS context. - * @param[in] config Pointer to the configuration message. - * - * @return - * Indication if the configuration message was issued. - * @par - * This indication does not mean the configuration message was successfully - * processed. Success or failure is provided in the response issued to the - * given callback function as specified in nss_shaper_configure. - */ -nss_tx_status_t nss_shaper_config_send(void *ctx, struct nss_shaper_configure *config); - -/** - * nss_shaper_get_device - * Gets the original device from probe. - * - * @return - * Pointer to the device. - */ -extern struct device *nss_shaper_get_dev(void); - -/** - * @} - */ - -#endif diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_sjack.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_sjack.h deleted file mode 100644 index 32ef356b0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_sjack.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2014-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_sjack.h - * NSS SJACK interface definitions. - */ - -#ifndef __NSS_SJACK_H -#define __NSS_SJACK_H - -/** - * @addtogroup nss_sjack_subsystem - * @{ - */ - -/** - * nss_sjack_msg_types - * Message types for SJACK requests and responses. - */ -enum nss_sjack_msg_types { - NSS_SJACK_CONFIGURE_MSG, - NSS_SJACK_UNCONFIGURE_MSG, - NSS_SJACK_STATS_SYNC_MSG, - NSS_SJACK_MAX_MSG_TYPE -}; - -/** - * nss_sjack_configure_msg - * Message information for configuring the SJACK interface. - */ -struct nss_sjack_configure_msg { - uint32_t ingress_if_num; - /**< Ingress interface number corresponding to the SJACK device. */ - uint32_t egress_if_num; - /**< Egress interface number corresponding to the SJACK device. */ - uint16_t tunnel_id; /**< SJACK tunnel ID. */ - uint8_t ip_dscp; /**< Differentiated services code point value. */ - uint8_t gre_prio; /**< GRE priority information. */ - uint8_t gre_flags; /**< GRE flags. */ - uint8_t use_ipsec_sa_pattern; /**< IPsec security association pattern flag. */ -}; - -/** - * nss_sjack_unconfigure_msg - * Message information for de-configuring the SJACK interface. - */ -struct nss_sjack_unconfigure_msg { - uint32_t ingress_if_num; - /**< Ingress interface number corresponding to the SJACK device. */ -}; - -/** - * nss_sjack_stats_sync_msg - * Message information for SJACK synchronization statistics. - */ -struct nss_sjack_stats_sync_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ -}; - -/** - * nss_sjack_msg - * Data for sending and receiving SJACK messages. - */ -struct nss_sjack_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of an SJACK message. - */ - union { - struct nss_sjack_configure_msg configure; - /**< Configure SJACK. */ - struct nss_sjack_unconfigure_msg unconfigure; - /**< De-configure SJACK. */ - struct nss_sjack_stats_sync_msg stats_sync; - /**< Synchronized statistics for SJACK. */ - } msg; /**< Message payload for SJACK interface messages exchanged with NSS core. */ -}; - -/** - * Callback function for receiving SJACK 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_sjack_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * nss_sjack_register_if - * Registers with the NSS for sending and receiving SJACK messages. - * - * @datatypes - * net_device \n - * nss_sjack_msg_callback_t - * - * @param[in] dev Pointer to the associated network device. - * @param[in] if_num NSS interface number. - * @param[in] event_callback Callback for the message. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_sjack_register_if(uint32_t if_num, struct net_device *dev, nss_sjack_msg_callback_t event_callback); - -/** - * nss_sjack_unregister_if - * Deregisters the SJACK interface from the NSS. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - * - * @dependencies - * The interface must have been previously registered. - */ -extern void nss_sjack_unregister_if(uint32_t if_num); - -/** - * nss_sjack_tx_msg - * Send SJACK messages to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_sjack_msg - * - * @param[in,out] 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_sjack_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_sjack_msg *msg); - -/** @} */ /* end_addtogroup nss_sjack_subsystem */ - -#endif /* __NSS_SJACK_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_stats_public.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_stats_public.h deleted file mode 100644 index f282ffdf3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_stats_public.h +++ /dev/null @@ -1,131 +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. - ************************************************************************** - */ - -/** - * @file nss_stats_public.h - * NSS statistics Structure and APIs - */ - -#ifndef __NSS_STATS_PUBLIC_H -#define __NSS_STATS_PUBLIC_H - -/** - * @addtogroup nss_stats_public_subsystem - * @{ - */ - -/** - * Maximum string length. - * - * This should be equal to maximum string size of any statistics - * inclusive of statistics value. - */ -#define NSS_STATS_MAX_STR_LENGTH 96 - -/** - * nss_stats_node - * Node statistics. - */ -enum nss_stats_node { - NSS_STATS_NODE_RX_PKTS, /**< Accelerated node Rx packets. */ - NSS_STATS_NODE_RX_BYTES, /**< Accelerated node Rx bytes. */ - NSS_STATS_NODE_TX_PKTS, /**< Accelerated node Tx packets. */ - NSS_STATS_NODE_TX_BYTES, /**< Accelerated node Tx bytes. */ - NSS_STATS_NODE_RX_QUEUE_0_DROPPED, /**< Accelerated node Rx Queue 0 dropped. */ - NSS_STATS_NODE_RX_QUEUE_1_DROPPED, /**< Accelerated node Rx Queue 1 dropped. */ - NSS_STATS_NODE_RX_QUEUE_2_DROPPED, /**< Accelerated node Rx Queue 2 dropped. */ - NSS_STATS_NODE_RX_QUEUE_3_DROPPED, /**< Accelerated node Rx Queue 3 dropped. */ - NSS_STATS_NODE_MAX, /**< Maximum message type. */ -}; - -/* - * WARNING: There is a 1:1 mapping between values of enum nss_stats_drv and corresponding - * statistics string array in nss_drv_strings.c. - */ -/** - * nss_stats_drv - * HLOS driver statistics. - */ -enum nss_stats_drv { - NSS_STATS_DRV_NBUF_ALLOC_FAILS = 0, /**< Networking buffer allocation errors. */ - NSS_STATS_DRV_PAGED_BUF_ALLOC_FAILS, /**< Paged buffer allocation errors. */ - NSS_STATS_DRV_TX_QUEUE_FULL_0, /**< Tx queue full for Core 0. */ - NSS_STATS_DRV_TX_QUEUE_FULL_1, /**< Tx queue full for Core 1. */ - NSS_STATS_DRV_TX_EMPTY, /**< Host-to-network empty buffers. */ - NSS_STATS_DRV_PAGED_TX_EMPTY, /**< Host-to-network paged empty buffers. */ - NSS_STATS_DRV_TX_PACKET, /**< Host-to-network data packets. */ - NSS_STATS_DRV_TX_CMD_REQ, /**< Host-to-network control packets. */ - NSS_STATS_DRV_TX_CRYPTO_REQ, /**< Host-to-network crypto requests. */ - NSS_STATS_DRV_TX_BUFFER_REUSE, /**< Host-to-network reuse buffer count. */ - NSS_STATS_DRV_RX_EMPTY, /**< Network-to-host empty buffers. */ - NSS_STATS_DRV_RX_PACKET, /**< Network-to-host data packets. */ - NSS_STATS_DRV_RX_CMD_RESP, /**< Network-to-host command responses. */ - NSS_STATS_DRV_RX_STATUS, /**< Network-to-host status packets. */ - NSS_STATS_DRV_RX_CRYPTO_RESP, /**< Network-to-host crypto responses. */ - NSS_STATS_DRV_RX_VIRTUAL, /**< Network-to-host virtual packets. */ - NSS_STATS_DRV_TX_SIMPLE, /**< Host-to-network simple SKB packets. */ - NSS_STATS_DRV_TX_NR_FRAGS, /**< Host-to-network number of fragmented SKB packets. */ - NSS_STATS_DRV_TX_FRAGLIST, /**< Host-to-network fragmentation list of SKB packets. */ - NSS_STATS_DRV_RX_SIMPLE, /**< Network-to-host simple SKB packets. */ - NSS_STATS_DRV_RX_NR_FRAGS, /**< Network-to-host number of fragmented SKB packets. */ - NSS_STATS_DRV_RX_SKB_FRAGLIST, /**< Network-to-host fragmentation list of SKB packets. */ - NSS_STATS_DRV_RX_BAD_DESCRIPTOR, /**< Network-to-host bad descriptor reads. */ - NSS_STATS_DRV_NSS_SKB_COUNT, /**< NSS SKB pool count. */ - NSS_STATS_DRV_CHAIN_SEG_PROCESSED, /**< Network-to-host SKB chain processed count. */ - NSS_STATS_DRV_FRAG_SEG_PROCESSED, /**< Network-to-host fragments processed count. */ - NSS_STATS_DRV_TX_CMD_QUEUE_FULL, /**< Tx host-to-network control packets fail due to queue full. */ -#ifdef NSS_MULTI_H2N_DATA_RING_SUPPORT - NSS_STATS_DRV_TX_PACKET_QUEUE_0, /**< Host-to-network data packets on queue0. */ - NSS_STATS_DRV_TX_PACKET_QUEUE_1, /**< Host-to-network data packets on queue1. */ - NSS_STATS_DRV_TX_PACKET_QUEUE_2, /**< Host-to-network data packets on queue2. */ - NSS_STATS_DRV_TX_PACKET_QUEUE_3, /**< Host-to-network data packets on queue3. */ - NSS_STATS_DRV_TX_PACKET_QUEUE_4, /**< Host-to-network data packets on queue4. */ - NSS_STATS_DRV_TX_PACKET_QUEUE_5, /**< Host-to-network data packets on queue5. */ - NSS_STATS_DRV_TX_PACKET_QUEUE_6, /**< Host-to-network data packets on queue6. */ - NSS_STATS_DRV_TX_PACKET_QUEUE_7, /**< Host-to-network data packets on queue7. */ -#endif - NSS_STATS_DRV_MAX, /**< Maximum message type. */ -}; - -/** - * nss_stats_types - * List of statistics categories. - */ -enum nss_stats_types { - NSS_STATS_TYPE_COMMON, /**< Common pnode statistics. */ - NSS_STATS_TYPE_DROP, /**< Packet drop statistics. */ - NSS_STATS_TYPE_ERROR, /**< Hardware or software errors different from drop or exception statistics. */ - NSS_STATS_TYPE_EXCEPTION, /**< Packet exception (to host) statistics. */ - NSS_STATS_TYPE_SPECIAL, /**< Statistics that do not fall into the above types. */ - NSS_STATS_TYPE_MAX /**< Maximum message type. */ -}; - -/** - * nss_stats_notifier_action - * Statistics notification types. - */ -enum nss_stats_notifier_action { - NSS_STATS_EVENT_NOTIFY, - NSS_STATS_EVENT_MAX -}; - -/** - * @} - */ - -#endif /* __NSS_STATS_PUBLIC_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_tls.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_tls.h deleted file mode 100644 index b23268e58..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_tls.h +++ /dev/null @@ -1,469 +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 - ************************************************************************** - */ - -/** - * @file nss_tls.h - * NSS TLS common interface definitions, supports inner/outer interface split. - */ - -#ifndef _NSS_TLS_H_ -#define _NSS_TLS_H_ - -/** - * @addtogroup nss_tls_subsystem - * @{ - */ -#define NSS_TLS_VER_TLS_1_1 0x0301 /**< TLS version 1.1, major and minor version. */ -#define NSS_TLS_VER_TLS_1_2 0x0302 /**< TLS version 1.2, major and minor version. */ -#define NSS_TLS_CLE_MAX 32 /**< Maximum classification error. */ - -/** - * tls_msg_types - * Message types for TLS requests and responses. - */ -enum nss_tls_msg_type { - NSS_TLS_MSG_TYPE_NODE_CONFIG, /**< Configure TLS firmware node. */ - NSS_TLS_MSG_TYPE_NODE_SYNC, /**< Node statistics. */ - NSS_TLS_MSG_TYPE_CTX_CONFIG, /**< Send exception interface number. */ - NSS_TLS_MSG_TYPE_CTX_DECONFIG, /**< Context deconfigure message. */ - NSS_TLS_MSG_TYPE_CTX_SYNC, /**< Synchronize statistics. */ - NSS_TLS_MSG_TYPE_CIPHER_UPDATE, /**< Context session update. */ - NSS_TLS_MSG_MAX, /**< Maximum message. */ -}; - -/** - * nss_tls_error - * TLS error. - */ -enum nss_tls_error { - NSS_TLS_ERROR_NONE = 0, /**< No error. */ - NSS_TLS_ERROR_UNKNOWN_MSG, /**< Unknown message. */ - NSS_TLS_ERROR_ALREADY_CONFIGURE, /**< Node already configured. */ - NSS_TLS_ERROR_FAIL_REG_INNER_CTX, /**< Register inner context error. */ - NSS_TLS_ERROR_FAIL_REG_OUTER_CTX, /**< Register outer context error. */ - NSS_TLS_ERROR_FAIL_REQ_POOL_ALLOC, /**< Request pool allocation failed. */ - NSS_TLS_ERROR_INVALID_BLK_LEN, /**< Invalid block length. */ - NSS_TLS_ERROR_INVALID_HASH_LEN, /**< Invalid hash length. */ - NSS_TLS_ERROR_INVALID_VER, /**< Invalid TLS version. */ - NSS_TLS_ERROR_INVALID_CTX_WORDS, /**< Context words size mismatch with TLS. */ - NSS_TLS_ERROR_FAIL_ALLOC_HWCTX, /**< Failed to allocate hardware context. */ - NSS_TLS_ERROR_FAIL_COPY_CTX, /**< Failed to copy context. */ - NSS_TLS_ERROR_FAIL_NOMEM, /**< Failed memory allocation. */ - NSS_TLS_ERROR_FAIL_INVAL_ALGO, /**< Invalid algorithm. */ - NSS_TLS_ERROR_MAX, /**< Maximum 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. - */ -struct nss_tls_hw_stats { - /* - * Dont change the order below - */ - uint32_t hw_len_error; /**< Length error. */ - uint32_t hw_token_error; /**< Token error, unknown token command/instruction. */ - uint32_t hw_bypass_error; /**< Token contains too much bypass data. */ - uint32_t hw_crypto_error; /**< Cryptograhic block size error. */ - uint32_t hw_hash_error; /**< Hash block size error. */ - uint32_t hw_config_error; /**< Invalid command/algorithm/mode/combination. */ - uint32_t hw_algo_error; /**< Unsupported algorithm. */ - uint32_t hw_hash_ovf_error; /**< Hash input overflow. */ - uint32_t hw_auth_error; /**< Hash input overflow. */ - uint32_t hw_pad_verify_error; /**< Pad verification error. */ - uint32_t hw_timeout_error; /**< Data timed out. */ -}; - -/** - * nss_tls_ctx_perf_stats - * TLS performance statistics. - */ -struct nss_tls_ctx_perf_stats { - uint32_t no_desc_in; /**< Ingress DMA descriptor not available. */ - uint32_t no_desc_out; /**< Egress DMA descriptor not available. */ - uint32_t no_reqs; /**< Not enough requests available for records. */ -}; - -/** - * nss_tls_ctx_stats - * TLS session statistics. - */ -struct nss_tls_ctx_stats { - struct nss_cmn_node_stats pkt; /**< Common node statistics. */ - uint32_t single_rec; /**< Number of Tx single record datagrams. */ - uint32_t multi_rec; /**< Number of multiple Tx record datagrams. */ - uint32_t tx_inval_reqs; /**< Number of Tx invalidation successfully requested. */ - uint32_t rx_ccs_rec; /**< Number of change cipher spec records received. */ - uint32_t fail_ccs; /**< Failed to switch to new crypto. */ - uint32_t eth_node_deactive; /**< Ethernet node deactivated as no crypto available. */ - uint32_t crypto_alloc_success; /**< Number of crypto allocation succeeded. */ - uint32_t crypto_free_req; /**< Number of crypto free request. */ - uint32_t crypto_free_success; /**< Number of crypto free succeeded. */ - uint32_t fail_crypto_alloc; /**< Number of crypto allocation failed. */ - uint32_t fail_crypto_lookup; /**< Failed to find active crypto session. */ - uint32_t fail_req_alloc; /**< Failure to allocate request memory pool. */ - uint32_t fail_pbuf_stats; /**< Failure in pbuf allocation for statistics. */ - uint32_t fail_ctx_active; /**< Failure in enqueue due to inactive context. */ - - struct nss_tls_hw_stats fail_hw; /**< Hardware failure. */ - struct nss_tls_ctx_perf_stats perf; /**< Performance related statistics. */ -}; - -/** - * nss_tls_node_stats - * TLS node statistics. - */ -struct nss_tls_node_stats { - uint32_t fail_ctx_alloc; /**< Failure in allocating a context. */ - uint32_t fail_ctx_free; /**< Failure in freeing up the context. */ - uint32_t fail_pbuf_stats; /**< Failure in pbuf allocation for statistics. */ -}; - -/** - * nss_tls_ctx_config - * TLS context configuration. - */ -struct nss_tls_ctx_config { - uint32_t except_ifnum; /**< Exception interface number. */ - uint32_t headroom; /**< Headroom required for encapsulation. */ - uint32_t tailroom; /**< Tailroom required for encapsulation. */ -}; - -/** - * nss_tls_cipher_update - * TLS cipher update message. - * - */ -struct nss_tls_cipher_update { - uint32_t crypto_idx; /**< Crypto index for cipher context. */ - uint16_t ver; /**< Version (TLS minor and major versions). */ - uint8_t skip; /**< Skip hardware processing. */ - uint8_t reserved; /**< Reserved for future use. */ -}; - -/** - * 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. - */ -struct nss_tls_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a TLS message. - */ - union { - struct nss_tls_cipher_update cipher_update; /**< Crypto configuration. */ - struct nss_tls_ctx_config ctx_cfg; /**< Context configuration. */ - struct nss_tls_ctx_stats stats; /**< Context statistics. */ - struct nss_tls_node_stats node_stats; /**< Node statistics. */ - } msg; /**< Message payload for TLS session messages exchanged with NSS core. */ -}; - -/** - * Callback function for receiving TLS 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_tls_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * Callback function for receiving TLS session 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_tls_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_tls_tx_buf - * Sends a TLS data packet to the NSS. - * - * @datatypes - * sk_buff \n - * nss_ctx_instance - * - * @param[in] os_buf Pointer to the OS data buffer. - * @param[in] if_num NSS interface number. - * @param[in] nss_ctx Pointer to the NSS core context. - * - * @return - * Status of Tx buffer forwarded to NSS for TLS operation. - */ -nss_tx_status_t nss_tls_tx_buf(struct sk_buff *os_buf, uint32_t if_num, struct nss_ctx_instance *nss_ctx); - -/** - * nss_tls_tx_msg - * Sends an asynchronous IPsec message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_tls_msg - * - * @param[in] nss_ctx Pointer to the NSS HLOS driver context. - * @param[in] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_tls_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_tls_msg *msg); - -/** - * nss_tls_tx_msg_sync - * Sends a synchronous IPsec message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_tls_msg_type \n - * nss_tls_msg - * - * @param[in] nss_ctx Pointer to the NSS HLOS driver context. - * @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. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_tls_tx_msg_sync(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - enum nss_tls_msg_type type, uint16_t len, - 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. - * - * @datatypes - * nss_tls_data_callback_t \n - * nss_tls_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] data_cb Callback function for the message. - * @param[in] msg_cb Callback for TLS tunnel message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * @param[in] type Type of message. - * @param[in] app_ctx Pointer to the application context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_tls_register_if(uint32_t if_num, - nss_tls_data_callback_t data_cb, - nss_tls_msg_callback_t msg_cb, - struct net_device *netdev, - uint32_t features, - uint32_t type, - void *app_ctx); - -/** - * nss_tls_notify_unregister - * Deregisters an event callback. - * - * @param[in] ifnum NSS interface number. - * - * @return - * None. - */ -extern void nss_tls_notify_unregister(uint32_t ifnum); - -/** - * nss_tls_notify_register - * Registers an event callback to handle notification from TLS firmware package. - * - * @datatypes - * nss_tls_msg_callback_t - * - * @param[in] ifnum NSS interface number. - * @param[in] ev_cb Callback for TLS tunnel message. - * @param[in] app_data Pointer to the application context. - * - * @return - * Pointer to NSS core context. - */ -extern struct nss_ctx_instance *nss_tls_notify_register(uint32_t ifnum, nss_tls_msg_callback_t ev_cb, void *app_data); - -/** - * nss_tls_msg_init - * Initializes a TLS message sent asynchronously. - * - * @datatypes - * nss_tls_msg - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context. - * - * @return - * None. - */ -extern void nss_tls_msg_init(struct nss_tls_msg *ncm, uint32_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); - -/** - * nss_tls_msg_sync_init - * Initializes a TLS message. - * - * @datatypes - * nss_tls_msg - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * - * @return - * None. - */ -extern void nss_tls_msg_sync_init(struct nss_tls_msg *ncm, uint32_t if_num, uint32_t type, uint32_t len); - -/** - * nss_tls_get_context - * Gets the NSS core context for the TLS session. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_tls_get_context(void); - -/** - * nss_tls_get_device - * Gets the original device from probe. - * - * @return - * 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); - -/** - * @} - */ - -#endif /* _NSS_TLS_H_. */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_trustsec_tx.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_trustsec_tx.h deleted file mode 100644 index b71fac54d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_trustsec_tx.h +++ /dev/null @@ -1,234 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_trustsec_tx.h - * NSS TrustSec interface definitions. - */ - -#ifndef __NSS_TRUSTSEC_TX_H -#define __NSS_TRUSTSEC_TX_H - -/** - * @addtogroup nss_trustsec_tx_subsystem - * @{ - */ - -/** - * nss_trustsec_tx_msg_types - * Message types for TrustSec Tx requests and responses. - */ -enum nss_trustsec_tx_msg_types { - 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. */ -}; - -/** - * nss_trustsec_tx_error_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_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. */ -}; - -/** - * nss_trustsec_tx_configure_msg - * Message information for configuring a TrustSec Tx interface. - */ -struct nss_trustsec_tx_configure_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_unconfigure_msg - * Message information for de-configuring a TrustSec Tx interface. - */ -struct nss_trustsec_tx_unconfigure_msg { - uint32_t src; /**< Interface number of the source tunnel. */ - uint16_t sgt; /**< Security Group Tag value configured for this interface. */ - uint8_t reserved[2]; /**< Reserved for word alignment. */ -}; - -/** - * nss_trustsec_tx_stats_sync_msg - * Statistics synchronization message for the TrustSec Tx interface. - */ -struct nss_trustsec_tx_stats_sync_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - uint32_t invalid_src; /**< Received packets with an invalid source interface. */ - uint32_t unconfigured_src; /**< Received packets with a de-configured source interface. */ - uint32_t headroom_not_enough; /**< Not enough headroom to insert a TrustSec header. */ -}; - -/** - * 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. - */ -struct nss_trustsec_tx_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a TrustSec Tx message. - */ - union { - struct nss_trustsec_tx_configure_msg configure; - /**< Configure TrustSec Tx. */ - struct nss_trustsec_tx_unconfigure_msg unconfigure; - /**< 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. */ -}; - -/** - * Callback function for receiving TrustSec Tx messages. - * - * @datatypes - * nss_trustsec_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_trustsec_tx_msg_callback_t)(void *app_data, struct nss_trustsec_tx_msg *npm); - -/** - * nss_trustsec_tx_msg_init - * Initializes a TrustSec Tx message. - * - * @datatypes - * nss_trustsec_tx_msg - * - * @param[in,out] npm Pointer to the NSS Profiler message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the message. - * @param[in] cb Callback function for the message. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * TRUE or FALSE. - */ -extern void nss_trustsec_tx_msg_init(struct nss_trustsec_tx_msg *npm, uint16_t if_num, uint32_t type, uint32_t len, - nss_trustsec_tx_msg_callback_t cb, void *app_data); - -/** - * nss_trustsec_tx_msg - * Sends a TrustSec Tx message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_trustsec_tx_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_trustsec_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_trustsec_tx_msg *msg); - -/** - * nss_trustsec_tx_msg_sync - * Sends a TrustSec Tx message to the NSS and waits for a response. - * - * @datatypes - * nss_ctx_instance \n - * nss_trustsec_tx_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_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. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_trustsec_tx_get_ctx(void); - -/** - * nss_trustsec_tx_configure_sgt - * Configures the Security Group Tag value for a source interface. - * - * @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_configure_sgt(uint32_t src, uint32_t dest, uint16_t sgt); - -/** - * nss_trustsec_tx_unconfigure_sgt - * De-configures the Security Group Tag value for a source interface. - * - * @param[in] src Source interface number. - * @param[in] sgt Security Group Tag value. - * - * @return - * Pointer to the NSS core context. - */ -extern nss_tx_status_t nss_trustsec_tx_unconfigure_sgt(uint32_t src, uint16_t sgt); - -/** @} */ /* end_addtogroup nss_trustsec_tx_subsystem */ - -#endif /* __NSS_TRUSTSEC_TX_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_tstamp.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_tstamp.h deleted file mode 100644 index 3c23e4eed..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_tstamp.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_tstamp.h - * NSS to HLOS Tstamp interface definitions. - */ - -#ifndef __NSS_TSTAMP_H -#define __NSS_TSTAMP_H - -/** - * nss_tstamp_msg_type - * Time stamp message types. - */ -enum nss_tstamp_msg_type { - NSS_TSTAMP_MSG_TYPE_SYNC_STATS, /**< Statistic synchronization message. */ - NSS_TSTAMP_MSG_TYPE_MAX, /**< Maximum message type. */ -}; - -/** - * nss_tstamp_h2n_pre_hdr - * Metadata added by the time stamp HLOS driver. - * - * It is used while sending the packet to the NSS time stamp module. - */ -struct nss_tstamp_h2n_pre_hdr { - uint32_t ts_ifnum; /**< Time stamp interface number. */ - uint32_t ts_tx_hdr_sz; /**< Total header size. */ -}; - -/* - * nss_tstamp_n2h_pre_hdr - * Metadata added by the NSS time stamp module. - * - * It is added before sending the packet to host. - */ -struct nss_tstamp_n2h_pre_hdr { - uint32_t ts_ifnum; /**< Time stamp interface number. */ - uint32_t ts_data_lo; /**< Time stamp lower order bits. */ - uint32_t ts_data_hi; /**< Time stamp higher order bits. */ - - uint32_t ts_tx; /**< Time stamp direction. */ - uint32_t ts_hdr_sz; /**< Size of the header including the skb data alignment padding. */ - uint32_t reserved; /**< Reserved for cache alignment. */ -}; - -/** - * nss_tstamp_stats_msg - * Statistics messages from the NSS firmware. - */ -struct nss_tstamp_stats_msg { - struct nss_cmn_node_stats node_stats; - /**< Common node statistics for time stamp. */ - uint32_t boomeranged; /**< Boomeranged packets. */ - uint32_t dropped_fail_enqueue; /**< Enqueue failed. */ - uint32_t dropped_fail_alloc; /**< Allocation for copy failed. */ - uint32_t dropped_fail_copy; /**< Copy failed. */ - uint32_t dropped_no_interface; /**< Next interface not found. */ - uint32_t dropped_no_headroom; /**< Packet does not have enough headroom. */ -}; - -/** - * nss_tstamp_msg - * Data for sending and receiving time stamp messages. - */ -struct nss_tstamp_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a time stamp common message. - */ - union { - struct nss_tstamp_stats_msg stats; - /**< Time stamp statistics. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving core-to-core transmissions messages. - * - * @datatypes - * nss_tstamp_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_tstamp_msg_callback_t)(void *app_data, struct nss_tstamp_msg *msg); - -/** - * nss_tstamp_notify_register - * Registers a notifier callback for time stamp messages with the NSS. - * - * @datatypes - * nss_tstamp_msg_callback_t - * - * @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_tstamp_notify_register(nss_tstamp_msg_callback_t cb, void *app_data); - -/** - * @brief Transfer the packet to time stamp NSS module. - * - * @return nss_tx_status - */ -nss_tx_status_t nss_tstamp_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *skb, uint32_t if_num); - -#endif /* __NSS_TSTAMP_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_tun6rd.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_tun6rd.h deleted file mode 100644 index b0675e86d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_tun6rd.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_tun6rd.h - * NSS TUN6RD interface definitions. - */ - -#ifndef __NSS_TUN6RD_H -#define __NSS_TUN6RD_H - -/** - * @addtogroup nss_tun6rd_subsystem - * @{ - */ - -/** - * nss_tun6rd_metadata_types - * Message types for 6RD (IPv6 in IPv4) tunnel requests and responses. - */ -enum nss_tun6rd_metadata_types { - NSS_TUN6RD_ATTACH_PNODE, - NSS_TUN6RD_RX_STATS_SYNC, - NSS_TUN6RD_ADD_UPDATE_PEER, - NSS_TUN6RD_MAX, -}; - -/** - * nss_tun6rd_attach_tunnel_msg - * Message information for configuring the 6RD tunnel. - */ -struct nss_tun6rd_attach_tunnel_msg { - uint32_t saddr; /**< Source address of the tunnel. */ - uint32_t daddr; /**< Destination address of the tunnel. */ - uint8_t tos; /**< Type Of Service field added to the outer header. */ - uint8_t ttl; /**< Time-to-live value for the tunnel. */ - uint32_t sibling_if_num; /**< Sibling interface number. */ - uint16_t reserved; /**< Reserved field added for alignment. */ -}; - -/** - * nss_tun6rd_sync_stats_msg - * Message information for 6RD tunnel synchronization statistics. - */ -struct nss_tun6rd_sync_stats_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ -}; - -/** - * nss_tun6rd_set_peer_msg - * Message information for the 6RD tunnel peer address. - */ -struct nss_tun6rd_set_peer_msg { - uint32_t ipv6_address[4]; /**< IPv6 address. */ - uint32_t dest; /**< IPv4 address. */ -}; - -/** - * nss_tun6rd_msg - * Data for sending and receiving 6RD tunnel messages. - */ -struct nss_tun6rd_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a 6RD tunnel message. - */ - union { - struct nss_tun6rd_attach_tunnel_msg tunnel; - /**< Attach a 6RD tunnel. */ - struct nss_tun6rd_sync_stats_msg stats; - /**< Synchronized statistics for the interface. */ - struct nss_tun6rd_set_peer_msg peer; - /**< Add or update the peer. */ - } msg; /**< Message payload for 6RD tunnel messages exchanged with NSS core. */ -}; - -/** - * Callback function for receiving 6RD tunnel messages. - * - * @datatypes - * nss_tun6rd_msg - * - * @param[in] app_data Pointer to the application context of the message - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_tun6rd_msg_callback_t)(void *app_data, struct nss_tun6rd_msg *msg); - -/** - * nss_tun6rd_tx - * Sends a 6RD tunnel message. - * - * @datatypes - * nss_ctx_instance \n - * nss_tun6rd_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_tun6rd_tx(struct nss_ctx_instance *nss_ctx, struct nss_tun6rd_msg *msg); - -/** - * nss_tun6rd_get_context - * Gets the TUN6RD context used in nss_tun6rd_tx(). - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_tun6rd_get_context(void); - -/** - * Callback function for receiving 6RD tunnel 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_tun6rd_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_register_tun6rd_if - * Registers the TUN6RD interface with the NSS for sending and receiving messages. - * - * @datatypes - * nss_tun6rd_callback_t \n - * nss_tun6rd_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] type NSS interface type. - * @param[in] tun6rd_callback Callback for the data. - * @param[in] msg_callback Callback for the message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_register_tun6rd_if(uint32_t if_num, uint32_t type, nss_tun6rd_callback_t tun6rd_callback, - nss_tun6rd_msg_callback_t msg_callback, struct net_device *netdev, uint32_t features); - -/** - * nss_unregister_tun6rd_if - * Deregisters the TUN6RD interface from the NSS. - * - * @param[in] if_num NSS interface number. -. * - * @return - * None. - * - * @dependencies - * The 6RD tunnel interface must have been previously registered. - */ -extern void nss_unregister_tun6rd_if(uint32_t if_num); - -/** - * nss_tun6rd_msg_init - * Initializes a TUN6RD message. - * - * @datatypes - * nss_tun6rd_msg - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -extern void nss_tun6rd_msg_init(struct nss_tun6rd_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); - -/** @} */ /* end_addtogroup nss_tun6rd_subsystem */ - -#endif /* __NSS_TUN6RD_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_tunipip6.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_tunipip6.h deleted file mode 100644 index 6edc73ba7..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_tunipip6.h +++ /dev/null @@ -1,293 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_tunipip6.h - * NSS TUNIPIP6 interface definitions. - */ - -#ifndef __NSS_TUNIPIP6_H -#define __NSS_TUNIPIP6_H - -/** - * Maximum number of supported TUNIPIP6 tunnels. - */ -#define NSS_TUNIPIP6_TUNNEL_MAX 32 - -/** - * @addtogroup nss_tunipip6_subsystem - * @{ - */ - -/** - * nss_tunipip6_map_rule - * Mapping rule (FMR/BMR) for forwarding traffic to the node in the same domain. - */ -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 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. */ -}; - -/** - * nss_tunipip6_metadata_types - * Message types for TUNIPIP6 (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_MAX, -}; - -/** - * nss_tunipip6_create_msg - * Payload for configuring the TUNIPIP6 interface. - */ -struct nss_tunipip6_create_msg { - 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 sibling_if_num; /**< Sibling interface number. */ - 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. - */ -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. */ -}; - -/** - * nss_tunipip6_msg - * Data for sending and receiving TUNIPIP6 messages. - */ -struct nss_tunipip6_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a TUNIPIP6 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. */ -}; - -/** - * Callback function for receiving TUNIPIP6 messages. - * - * @datatypes - * nss_tunipip6_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_tunipip6_msg_callback_t)(void *app_data, struct nss_tunipip6_msg *msg); - -/** - * nss_tunipip6_tx - * Sends a TUNIPIP6 message to NSS core. - * - * @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(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. - * - * @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_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. - * - * @datatypes - * nss_tunipip6_callback_t \n - * nss_tunipip6_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] type Dynamic interface type. - * @param[in] tunipip6_callback Callback for the data. - * @param[in] event_callback Callback for the message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_register_tunipip6_if(uint32_t if_num, uint32_t type, nss_tunipip6_callback_t tunipip6_callback, - nss_tunipip6_msg_callback_t event_callback, struct net_device *netdev, uint32_t features); - -/** - * nss_unregister_tunipip6_if - * Deregisters the TUNIPIP6 interface from the NSS. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - */ -extern void nss_unregister_tunipip6_if(uint32_t if_num); - -/** - * nss_tunipip6_msg_init - * Initializes a TUNIPIP6 message. - * - * @datatypes - * nss_tunipip6_msg - * - * @param[in,out] ntm Pointer to the IPIP6 tunnel message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the message. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -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. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_tunipip6_get_context(void); - -/** @} */ /* end_addtogroup nss_tunipip6_subsystem */ - -#endif /* __NSS_TUN6RD_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_udp_st.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_udp_st.h deleted file mode 100755 index d6f3aa4dd..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_udp_st.h +++ /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. - ************************************************************************** - */ - -/** - * @file nss_udp_st.h - * NSS Ethernet interface definitions. - */ - -#ifndef __NSS_UDP_ST_H -#define __NSS_UDP_ST_H - -/** - * @addtogroup nss_udp_st_subsystem - * @{ - */ - -#define NSS_UDP_ST_TX_CONN_MAX 16 -#define NSS_UDP_ST_FLAG_IPV4 4 /**< L3 Protocol - IPv4. */ -#define NSS_UDP_ST_FLAG_IPV6 6 /**< L3 Protocol - IPv6. */ - -/** - * nss_udp_st_message_types - * UDP speed test message types. - */ -enum nss_udp_st_message_types { - NSS_UDP_ST_START_MSG, /**< Start message. */ - NSS_UDP_ST_STOP_MSG, /**< Stop message. */ - NSS_UDP_ST_CFG_RULE_MSG, /**< Configure IPv4/IPv6 rule. */ - NSS_UDP_ST_UNCFG_RULE_MSG, /**< Unconfigure IPv4/IPv6 rule. */ - NSS_UDP_ST_STATS_SYNC_MSG, /**< Statistic syncronization. */ - NSS_UDP_ST_TX_CREATE_MSG, /**< Create transmit node. */ - NSS_UDP_ST_TX_DESTROY_MSG, /**< Destroy transmit node. */ - NSS_UDP_ST_RESET_STATS_MSG, /**< Reset existing statistics. */ - NSS_UDP_ST_MAX_MSG_TYPES, /**< Maximum message type. */ -}; - -/** - * nss_udp_st_test_types - * Test types of the UDP speed test. - */ -enum nss_udp_st_test_types { - NSS_UDP_ST_TEST_RX, /**< Test type is receive. */ - NSS_UDP_ST_TEST_TX, /**< Test type is transmit. */ - NSS_UDP_ST_TEST_MAX /**< Maximum test type. */ -}; - -/** - * nss_udp_st_error - * UDP speed test error types. - */ -enum nss_udp_st_error { - NSS_UDP_ST_ERROR_NONE, /**< No error. */ - NSS_UDP_ST_ERROR_INCORRECT_RATE, /**< Incorrect Tx rate. */ - NSS_UDP_ST_ERROR_INCORRECT_BUFFER_SIZE, /**< Incorrect buffer size. */ - NSS_UDP_ST_ERROR_MEMORY_FAILURE, /**< Memory allocation failed. */ - NSS_UDP_ST_ERROR_INCORRECT_STATE, /**< Trying to configure during incorrect state. */ - NSS_UDP_ST_ERROR_INCORRECT_FLAGS, /**< Incorrect flag configuration. */ - NSS_UDP_ST_ERROR_ENTRY_EXIST, /**< Given tunnel entry already exists. */ - NSS_UDP_ST_ERROR_ENTRY_ADD_FAILED, /**< UDP ST Encap entry addition failed. */ - NSS_UDP_ST_ERROR_ENTRY_NOT_EXIST, /**< Given tunnel entry does not exists. */ - NSS_UDP_ST_ERROR_WRONG_START_MSG_TYPE, /**< Start message type error. */ - NSS_UDP_ST_ERROR_WRONG_STOP_MSG_TYPE, /**< Stop message type error. */ - NSS_UDP_ST_ERROR_TOO_MANY_USERS, /**< Too many users tried to be added. */ - NSS_UDP_ST_ERROR_UNKNOWN_MSG_TYPE, /**< Unknown message type failure. */ - NSS_UDP_ST_ERROR_PB_ALLOC, /**< Pbuf allocation failed. */ - NSS_UDP_ST_ERROR_PB_SIZE, /**< Pbuf size is too small to fit buffer. */ - NSS_UDP_ST_ERROR_DROP_QUEUE, /**< Packet dropped enqueue next node. */ - UDP_ST_ERROR_TIMER_MISSED, /**< Timer call is missed. */ - NSS_UDP_ST_ERROR_MAX, /**< Maximum error type. */ -}; - -/** - * nss_udp_st_stats_time - * UDP speed test time statistics types. - */ -enum nss_udp_st_stats_time { - NSS_UDP_ST_STATS_TIME_START, /**< Start time of the test. */ - NSS_UDP_ST_STATS_TIME_CURRENT, /**< Current time of the running test. */ - NSS_UDP_ST_STATS_TIME_ELAPSED, /**< Elapsed time of the current test. */ - NSS_UDP_ST_STATS_TIME_MAX /**< Maximum time statistics. */ -}; - -/** - * Create TX node to start pushing rules. - */ -struct nss_udp_st_tx_create { - uint32_t rate; /**< Rate in Mbps. */ - uint32_t buffer_size; /**< UDP buffer size. */ - uint8_t dscp; /**< DSCP value. */ -}; - -/** - * Destroy Tx node. - */ -struct nss_udp_st_tx_destroy { - uint32_t flag; /**< Tx destroy flag. */ -}; - -/** - * NSS UDP speed test start structure. - */ -struct nss_udp_st_start { - uint32_t type; /**< Started test type (for example, receive or transmit). */ - -}; - -/** - * NSS UDP speed test stop structure. - */ -struct nss_udp_st_stop { - uint32_t type; /**< Stopped test type (for example, receive or transmit). */ -}; - -/** - * NSS UDP speed test ip structure - */ -struct nss_udp_st_ip { - union { - uint32_t ipv4; /**< IPv4 address. */ - uint32_t ipv6[4]; /**< IPv6 address. */ - } ip; -}; - -/** - * NSS UDP speed test IPv4/IPv6 configuration structure. - */ -struct nss_udp_st_cfg { - struct nss_udp_st_ip src_ip; /**< Source IP address. */ - int32_t src_port; /**< Source L4 port. */ - struct nss_udp_st_ip dest_ip; /**< Destination IP address. */ - int32_t dest_port; /**< Destination L4 port. */ - uint32_t type; /**< Started test type (for example, receive or transmit). */ - uint16_t ip_version; /**< IP version to indicate IPv4 or IPv6. */ -}; - -/** - * NSS UDP speed test node statistics structure. - */ -struct nss_udp_st_node_stats { - struct nss_cmn_node_stats node_stats; /**< Common node statistics for the UDP speed test. */ - uint32_t errors[NSS_UDP_ST_ERROR_MAX]; /**< Error statistics. */ -}; - -/** - * NSS UDP speed test statistics structure. - */ -struct nss_udp_st_stats { - struct nss_udp_st_node_stats nstats; /**< Node statistics for the UDP speed test. */ - uint32_t time_stats[NSS_UDP_ST_TEST_MAX][NSS_UDP_ST_STATS_TIME_MAX]; - /**< Time statistics. */ -}; - -/** - * NSS UDP speed test reset statistics structure. - */ -struct nss_udp_st_reset_stats { - uint32_t flag; /**< Reset statistics flag. */ -}; - -/** - * Message structure of the UDP speed test commands. - */ -struct nss_udp_st_msg { - struct nss_cmn_msg cm; /**< Message header. */ - union { - struct nss_udp_st_tx_create create; /**< Prepare transmit message. */ - struct nss_udp_st_tx_destroy destroy; /**< Destroy transmit message. */ - struct nss_udp_st_start start; /**< Start message. */ - struct nss_udp_st_stop stop; /**< Stop message. */ - struct nss_udp_st_cfg cfg; /**< IPv4/IPv6 configuration message. */ - struct nss_udp_st_cfg uncfg; /**< IPv4/IPv6 unconfiguration message. */ - struct nss_udp_st_stats stats; /**< Statistics synchronization message. */ - struct nss_udp_st_reset_stats reset_stats; - /**< Reset statistics message. */ - } msg; -}; - -/** - * Callback function for receiving UDP speed test messages. - * - * @datatypes - * nss_udp_st_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_udp_st_msg_callback_t)(void *app_data, struct nss_udp_st_msg *msg); - -/** - * nss_udp_st_register_handler - * Registers the UDP speed test message handler. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * - * @return - * None. - */ -extern void nss_udp_st_register_handler(struct nss_ctx_instance *nss_ctx); - -/** - * nss_udp_st_tx - * Transmits a UDP speed test message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_udp_st_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] num Pointer to the message data. - * - * @return - * Status of the transmit operation. - */ -extern nss_tx_status_t nss_udp_st_tx(struct nss_ctx_instance *nss_ctx, struct nss_udp_st_msg *num); - -/** - * nss_udp_st_tx_sync - * Transmits a synchronous UDP speed test message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_udp_st_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] num Pointer to the message data. - * - * @return - * Status of the transmit operation. - */ -extern nss_tx_status_t nss_udp_st_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_udp_st_msg *num); - -/** - * nss_udp_st_msg_init - * Initializes UDP speed test messages. - * - * @datatypes - * nss_udp_st_msg \n - * nss_udp_st_msg_callback_t - * - * @param[in,out] num 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_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_udp_st_get_mgr - * Gets the NSS context that is managing UDP speed sest processes. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_udp_st_get_mgr(void); - -/** - *@} - */ - -#endif /* __NSS_UDP_ST_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_unaligned.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_unaligned.h deleted file mode 100644 index 2eb6e1a4a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_unaligned.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_unaligned.h - * NSS unaligned interface definitions. - */ - -#ifndef __NSS_UNALIGNED_H -#define __NSS_UNALIGNED_H - -/** - * @addtogroup nss_unaligned_subsystem - * @{ - */ - -#define NSS_UNALIGNED_OPS_PER_MSG 54 - /**< The number of operations whose statistics are included in a message. */ -#define NSS_UNALIGNED_EMULATED_OPS 64 - /**< The number of operations that are emulated. */ - -/** - * nss_unaligned_msg_types - * Unaligned message types. - */ -enum nss_unaligned_msg_types { - NSS_UNALIGNED_MSG_STATS, /**< Performance statistics message. */ - NSS_UNALIGNED_MSG_MAX, /**< Maximum unaligned message type. */ -}; - -/** - * nss_unaligned_stats_op - * Performance statistics for emulating a single operation. - */ -struct nss_unaligned_stats_op { - uint32_t opcode_primary; - /**< Primary operation code. */ - uint32_t opcode_extension; - /**< Extension operation code, if applicable. */ - uint64_t count; - /**< Number of times operation was emulated. */ - uint32_t ticks_min; - /**< Minimum number of ticks spent emulating operation. */ - uint32_t ticks_avg; - /**< Average number of ticks spent emulating operation. */ - uint32_t ticks_max; - /**< Maximum number of ticks spent emulating operation. */ - uint32_t padding; - /**< Used for consistent alignment, can be re-used. */ -}; - -/** - * nss_unaligned_stats - * Message containing all non-zero operation statistics. - */ -struct nss_unaligned_stats { - uint64_t trap_count; - /**< Number of unaligned traps encountered. */ - struct nss_unaligned_stats_op ops[NSS_UNALIGNED_EMULATED_OPS]; - /**< Statistics for each operation. */ -}; - -/** - * nss_unaligned_stats_msg - * Message containing all non-zero operation statistics. - */ -struct nss_unaligned_stats_msg { - uint64_t trap_count; /**< Number of unaligned traps encountered. */ - struct nss_unaligned_stats_op ops[NSS_UNALIGNED_OPS_PER_MSG]; - /**< Statistics for each operation. */ - uint32_t current_iteration; /**< Number of full statistics messages sent without reaching the end. */ -}; - -/** - * nss_unaligned_msg - * Message from unaligned handler node. - */ -struct nss_unaligned_msg { - struct nss_cmn_msg cm; /**< Message header. */ - - /** - * Unaligned message payload. - */ - union { - struct nss_unaligned_stats_msg stats_msg; - /**< Message containing statistics. */ - } msg; /**< Message payload. */ -}; - -/** - * nss_unaligned_register_handler() - * Registers message handler on the NSS unaligned interface and - * statistics dentry. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS context. - * - * @return - * None. - */ -void nss_unaligned_register_handler(struct nss_ctx_instance *nss_ctx); - -/** - * @} - */ -#endif diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_virt_if.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_virt_if.h deleted file mode 100644 index 443e6cf86..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_virt_if.h +++ /dev/null @@ -1,436 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_virt_if.h - * NSS Virtual interface message Structure and APIs - */ - -#ifndef __NSS_VIRT_IF_H -#define __NSS_VIRT_IF_H - -#include "nss_if.h" - -/** - * @addtogroup nss_virtual_if_subsystem - * @{ - */ - -/** - * nss_virt_if_msg_types - * Message types for virtual interface requests and responses. - */ -enum nss_virt_if_msg_types { - NSS_VIRT_IF_OPEN = NSS_IF_OPEN, - NSS_VIRT_IF_CLOSE = NSS_IF_CLOSE, - NSS_VIRT_IF_LINK_STATE_NOTIFY = NSS_IF_LINK_STATE_NOTIFY, - NSS_VIRT_IF_MTU_CHANGE = NSS_IF_MTU_CHANGE, - NSS_VIRT_IF_MAC_ADDR_SET = NSS_IF_MAC_ADDR_SET, - NSS_VIRT_IF_STATS_SYNC = NSS_IF_STATS, - NSS_VIRT_IF_ISHAPER_ASSIGN = NSS_IF_ISHAPER_ASSIGN, - NSS_VIRT_IF_BSHAPER_ASSIGN = NSS_IF_BSHAPER_ASSIGN, - NSS_VIRT_IF_ISHAPER_UNASSIGN = NSS_IF_ISHAPER_UNASSIGN, - NSS_VIRT_IF_BSHAPER_UNASSIGN = NSS_IF_BSHAPER_UNASSIGN, - NSS_VIRT_IF_ISHAPER_CONFIG = NSS_IF_ISHAPER_CONFIG, - NSS_VIRT_IF_BSHAPER_CONFIG = NSS_IF_BSHAPER_CONFIG, - NSS_VIRT_IF_VSI_ASSIGN = NSS_IF_VSI_ASSIGN, - NSS_VIRT_IF_VSI_UNASSIGN = NSS_IF_VSI_UNASSIGN, - NSS_VIRT_IF_TX_CONFIG_MSG = NSS_IF_MAX_MSG_TYPES + 1, - NSS_VIRT_IF_STATS_SYNC_MSG, - NSS_VIRT_IF_MAX_MSG_TYPES, -}; - -/** - * nss_virt_if_error_types - * Error types for the virtual interface. - */ -enum nss_virt_if_error_types { - NSS_VIRT_IF_SUCCESS, - NSS_VIRT_IF_CORE_FAILURE, - NSS_VIRT_IF_ALLOC_FAILURE, - NSS_VIRT_IF_DYNAMIC_IF_FAILURE, - NSS_VIRT_IF_MSG_TX_FAILURE, - NSS_VIRT_IF_REG_FAILURE, - NSS_VIRT_IF_CORE_NOT_INITIALIZED, -}; - -/** - * nss_virt_if_base_node_stats - * Virtual interface statistics of NSS base node. - */ -struct nss_virt_if_base_node_stats { - uint32_t active_interfaces; /**< Number of active virtual interfaces. */ - uint32_t ocm_alloc_failed; /**< Number of interface allocation failure on OCM. */ - uint32_t ddr_alloc_failed; /**< Number of interface allocation failure on DDR. */ -}; - -/** - * nss_virt_if_interface_stats - * Virtual interface statistics of each pair of interfaces. - */ -struct nss_virt_if_interface_stats { - struct nss_cmn_node_stats node_stats; /**< Common statistics. */ - uint32_t tx_enqueue_failed; /**< Tx enqueue failures in the firmware. */ - uint32_t shaper_enqueue_failed; /**< Shaper enqueue failures in the firmware. */ - uint32_t ocm_alloc_failed; /**< Number of allocation failure on OCM. */ -}; - -/** - * nss_virt_if_stats - * Virtual interface statistics received from the NSS. - */ -struct nss_virt_if_stats { - struct nss_virt_if_base_node_stats base_stats; - struct nss_virt_if_interface_stats if_stats; -}; - -/** - * nss_virt_if_config_msg - * Message information for configuring the virtual interface. - */ -struct nss_virt_if_config_msg { - uint32_t flags; /**< Interface flags. */ - uint32_t sibling; /**< Sibling interface number. */ - uint32_t nexthop; /**< Next hop interface number. */ - uint8_t mac_addr[ETH_ALEN]; /**< MAC address. */ -}; - -/** - * nss_virt_if_msg - * Data for sending and receiving virtual interface messages. - */ -struct nss_virt_if_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a virtual interface message. - */ - union { - union nss_if_msgs if_msgs; - /**< NSS interface base message. */ - struct nss_virt_if_config_msg if_config; - /**< Rule for creating a virtual interface. */ - struct nss_virt_if_stats stats; - /**< Virtual interface statistics. */ - } msg; /**< Message payload. */ -}; - -/* - * nss_virt_if_pvt - * Private data information for the virtual interface. - */ -struct nss_virt_if_pvt { - struct semaphore sem; - /**< Semaphore to ensure that only one instance of a message is sent to the NSS. */ - struct completion complete; - /**< Waits for message completion or time out. */ - int response; /**< Message process response from the NSS firmware. */ - int sem_init_done; /**< Semaphore initialization is done. */ -}; - -/** - * Callback to transmit virtual interface data received from NSS - * to the transmit path of the virtual interface. - * - * @datatypes - * net_device \n - * sk_buff - * - * @param[in] netdev Pointer to the associated network device. - * @param[in] skb Pointer to the data socket buffer. - */ -typedef void (*nss_virt_if_xmit_callback_t)(struct net_device *netdev, struct sk_buff *skb); - -/** - * Callback function for virtual interface 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_virt_if_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback function for virtual interface 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_virt_if_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * nss_virt_if_handle - * Context information for WLAN-to-NSS communication. - */ -struct nss_virt_if_handle { - struct nss_ctx_instance *nss_ctx; /**< NSS context. */ - int32_t if_num_n2h; /**< Redirect interface number on NSS-to-host path. */ - int32_t if_num_h2n; /**< Redirect interface number on host-to-NSS path. */ - struct net_device *ndev; /**< Associated network device. */ - struct nss_virt_if_pvt *pvt; /**< Private data structure. */ - struct nss_virt_if_stats stats; /**< Virtual interface statistics. */ - atomic_t refcnt; /**< Reference count. */ - nss_virt_if_msg_callback_t cb; /**< Message callback. */ - void *app_data; /**< Application data to be passed to the callback. */ -}; - -/** - * nss_virt_if_dp_type - * Virtual interface datapath types. Redirect interface on NSS-to-host path will be seen by ECM for rules. - */ -enum nss_virt_if_dp_type { - NSS_VIRT_IF_DP_REDIR_N2H, /**< Redirect interface on NSS-to-host path has zero value. */ - NSS_VIRT_IF_DP_REDIR_H2N, /**< Redirect interface on host-to-NSS path has non-zero value. */ -}; - -/** - * nss_virt_if_create - * Creates a virtual interface asynchronously. - * - * @datatypes - * net_device \n - * nss_virt_if_msg_callback_t - * - * @param[in] netdev Pointer to the associated network device. - * @param[in] cb Callback function for the message. This callback is - invoked when the response from the firmware is received. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * Status of the Tx operation. - */ -extern int nss_virt_if_create(struct net_device *netdev, nss_virt_if_msg_callback_t cb, void *app_data); - -/** - * nss_virt_if_create_sync - * Creates a virtual interface synchronously with the default nexthop values - * NSS_N2H_INTERFACE and NSS_ETH_RX_INTERFACE. - * - * @datatypes - * net_device - * - * @param[in] netdev Pointer to the associated network device. - * - * @return - * Pointer to nss_virt_if_handle. - */ -extern struct nss_virt_if_handle *nss_virt_if_create_sync(struct net_device *netdev); - -/** - * nss_virt_if_create_sync_nexthop - * Creates a virtual interface synchronously with specified nexthops. - * - * @datatypes - * net_device - * - * @param[in] netdev Pointer to the associated network device. - * @param[in] nexthop_n2h Nexthop interface number of network-to-host dynamic interface. - * @param[in] nexthop_h2n Nexthop interface number of host-to-network dynamic interface. - * - * @return - * Pointer to NSS virtual interface handle. - */ -extern struct nss_virt_if_handle *nss_virt_if_create_sync_nexthop(struct net_device *netdev, uint32_t nexthop_n2h, uint32_t nexthop_h2n); - -/** - * nss_virt_if_destroy - * Destroys the virtual interface asynchronously. - * - * @datatypes - * nss_virt_if_handle \n - * nss_virt_if_msg_callback_t - * - * @param[in,out] handle Pointer to the virtual interface handle (provided during - * dynamic interface allocation). - * @param[in] cb Callback function for the message. This callback is - * invoked when the response from the firmware is received. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * Status of the Tx operation. - * - * @dependencies - * The interface must have been previously created. - */ -extern nss_tx_status_t nss_virt_if_destroy(struct nss_virt_if_handle *handle, nss_virt_if_msg_callback_t cb, void *app_data); - -/** - * nss_virt_if_destroy_sync - * Destroys the virtual interface synchronously. - * - * @datatypes - * nss_virt_if_handle - * - * @param[in,out] handle Pointer to the virtual interface handle (provided during - * dynamic interface allocation). - * - * @return - * Status of the Tx operation. - * - * @dependencies - * The interface must have been previously created. - */ -extern nss_tx_status_t nss_virt_if_destroy_sync(struct nss_virt_if_handle *handle); - -/** - * nss_virt_if_tx_msg - * Sends a message to the virtual interface. - * - * @datatypes - * nss_ctx_instance \n - * nss_virt_if_msg - * - * @param[in] nss_ctx Pointer to the NSS context (provided during registration). - * @param[in] nvim Pointer to the virtual interface message. - * - * @return - * Command Tx status. - */ -extern nss_tx_status_t nss_virt_if_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_virt_if_msg *nvim); - -/** - * nss_virt_if_tx_buf - * Forwards virtual interface packets to the NSS. - * - * @datatypes - * nss_virt_if_handle \n - * sk_buff - * - * @param[in,out] handle Pointer to the virtual interface handle (provided during - * registration). - * @param[in] skb Pointer to the data socket buffer. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_virt_if_tx_buf(struct nss_virt_if_handle *handle, - struct sk_buff *skb); - -/** - * nss_virt_if_xmit_callback_register - * Registers a transmit callback to a virtual interface. - * - * @datatypes - * nss_virt_if_handle \n - * nss_virt_if_xmit_callback_t - * - * @param[in,out] handle Pointer to the virtual interface handle (provided during - * dynamic interface allocation). - * @param[in] cb Callback handler for virtual data packets. - * - * @return - * None. - */ -extern void nss_virt_if_xmit_callback_register(struct nss_virt_if_handle *handle, - nss_virt_if_xmit_callback_t cb); - -/** - * nss_virt_if_xmit_callback_unregister - * Deregisters the transmit callback from the virtual interface. - * - * @datatypes - * nss_virt_if_handle - * - * @param[in,out] handle Pointer to the virtual interface handle. - * - * @return - * None. - */ -extern void nss_virt_if_xmit_callback_unregister(struct nss_virt_if_handle *handle); - -/** - * nss_virt_if_register - * Registers a virtual Interface with NSS driver. - * - * @datatypes - * nss_virt_if_handle \n - * nss_virt_if_data_callback_t \n - * net_device - * - * @param[in,out] handle Pointer to the virtual interface handle(provided during - * dynamic interface allocation). - * @param[in] data_callback Callback handler for virtual data packets - * @param[in] netdev Pointer to the associated network device. - * - * @return - * Status of the Tx operation. - */ -extern void nss_virt_if_register(struct nss_virt_if_handle *handle, - nss_virt_if_data_callback_t data_callback, - struct net_device *netdev); - -/** - * nss_virt_if_unregister - * Deregisters a virtual interface from the NSS driver. - * - * @datatypes - * nss_virt_if_handle - * - * @param[in,out] handle Pointer to the virtual interface handle. - * - * @return - * None. - */ -extern void nss_virt_if_unregister(struct nss_virt_if_handle *handle); - -/** - * nss_virt_if_get_interface_num - * Returns the virtual interface number associated with the handle. - * - * @datatypes - * nss_virt_if_handle - * - * @param[in] handle Pointer to the virtual interface handle(provided during - dynamic interface allocation). - * - * @return - * Virtual interface number. - */ -extern int32_t nss_virt_if_get_interface_num(struct nss_virt_if_handle *handle); - -/** - * nss_virt_if_verify_if_num - * Verifies if the interface is 802.3 redirect type. - * - * @param[in] if_num Interface number to be verified. - * - * @return - * True if if_num is 802.3 redirect type. - */ -bool nss_virt_if_verify_if_num(uint32_t if_num); - -/** - * nss_virt_if_get_context - * Gets the virtual interface context. - * - * @return - * Pointer to the NSS core context. - */ -struct nss_ctx_instance *nss_virt_if_get_context(void); - -/** - * @} - */ - -#endif /* __NSS_VIRT_IF_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_vlan.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_vlan.h deleted file mode 100644 index 872d2e042..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_vlan.h +++ /dev/null @@ -1,265 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/** - * @file nss_vlan.h - * NSS VLAN interface definitions. - */ - -#ifndef __NSS_VLAN_H -#define __NSS_VLAN_H - -/** - * @addtogroup nss_vlan_subsystem - * @{ - */ - -/** - * nss_vlan_msg_types - * VLAN message types. - */ -enum nss_vlan_msg_types { - NSS_VLAN_MSG_ADD_TAG = NSS_IF_MAX_MSG_TYPES + 1, - NSS_VLAN_MSG_TYPE_MAX, -}; - -/** - * nss_vlan_error_types - * VLAN error types - */ -enum nss_vlan_error_types { - NSS_VLAN_ERROR_UNKNOWN_MSG = NSS_IF_ERROR_TYPE_MAX + 1, - NSS_VLAN_ERROR_TYPE_MAX, -}; - -#define NSS_VLAN_TYPE_SINGLE 0 /**< Single VLAN tag in message. */ -#define NSS_VLAN_TYPE_DOUBLE 1 /**< Double VLAN tag in message. */ - -/** - * nss_vlan_msg_add_tag - * VLAN message data for adding a VLAN tag. - */ -struct nss_vlan_msg_add_tag { - uint32_t vlan_tag; /**< VLAN tag information. */ - uint32_t next_hop; /**< Parent interface. */ - uint32_t if_num; /**< Actual physical interface. */ -}; - -/** - * nss_vlan_msg - * Data for sending and receiving VLAN messages. - */ -struct nss_vlan_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a VLAN message. - */ - union { - union nss_if_msgs if_msg; - /**< NSS interface base messages. */ - struct nss_vlan_msg_add_tag add_tag; - /**< VLAN add-a-tag message. */ - } msg; /**< Message payload. */ -}; - -/** - * nss_vlan_tx_msg - * Sends a VLAN message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_vlan_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_vlan_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_vlan_msg *msg); - -/** - * nss_vlan_tx_msg_sync - * Sends a VLAN message to the NSS synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_vlan_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_vlan_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_vlan_msg *msg); - -/** - * Initializes a VLAN message. - * - * @datatypes - * nss_vlan_msg - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -void nss_vlan_msg_init(struct nss_vlan_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); - -/** - * nss_vlan_get_context - * Gets the VLAN context used in nss_vlan_tx. - * - * @return - * Pointer to the NSS core context. - */ -struct nss_ctx_instance *nss_vlan_get_context(void); - -/** - * Callback when VLAN data is received - * - * @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_vlan_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback to receive VLAN messages - * - * @datatypes - * nss_vlan_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_vlan_msg_callback_t)(void *app_data, struct nss_vlan_msg *msg); - -/** - * nss_register_vlan_if - * Register to send/receive VLAN messages to NSS - * - * @datatypes - * nss_vlan_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] vlan_data_callback Callback for the data. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * @param[in] app_ctx Pointer to the application context of the message. - * - * @return - * Pointer to the NSS core context. - */ -struct nss_ctx_instance *nss_register_vlan_if(uint32_t if_num, nss_vlan_callback_t vlan_data_callback, - struct net_device *netdev, uint32_t features, void *app_ctx); - -/** - * Deregisters the VLAN interface from the NSS. - * - * @return - * None. - */ -void nss_unregister_vlan_if(uint32_t if_num); - -/** - * nss_vlan_tx_set_mtu_msg - * Sends a VLAN message to set the MTU. - * - * @param[in] vlan_if_num VLAN interface number. - * @param[in] mtu MTU value to set. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_vlan_tx_set_mtu_msg(uint32_t vlan_if_num, uint32_t mtu); - -/** - * nss_vlan_tx_set_mac_addr_msg - * Sends a VLAN message to set the MAC address. - * - * @param[in] vlan_if_num VLAN interface number. - * @param[in] addr Pointer to the MAC address. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_vlan_tx_set_mac_addr_msg(uint32_t vlan_if_num, uint8_t *addr); - -/** - * nss_vlan_tx_vsi_attach_msg - * Send a VLAN message to attach a VSI. - * - * @param[in] vlan_if_num VLAN interface number. - * @param[in] vsi PPE VSI to attach. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_vlan_tx_vsi_attach_msg(uint32_t vlan_if_num, uint32_t vsi); - -/** - * nss_vlan_tx_vsi_detach_msg - * Sends a VLAN message to detach VSI. - * - * @param[in] vlan_if_num VLAN interface number. - * @param[in] vsi VSI to detach. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_vlan_tx_vsi_detach_msg(uint32_t vlan_if_num, uint32_t vsi); - -/** - * nss_vlan_tx_add_tag_msg - * Sends a VLAN add tag message. - * - * @param[in] vlan_if_num VLAN interface number. - * @param[in] vlan_tag VLAN tag information. - * @param[in] next_hop Parent interface. - * @param[in] physical_dev Physical port to which to add the VLAN tag. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_vlan_tx_add_tag_msg(uint32_t vlan_if_num, uint32_t vlan_tag, uint32_t next_hop, uint32_t physical_dev); - -/** - * Registers the VLAN handler with the NSS. - * - * @return - * None. - */ -void nss_vlan_register_handler(void); - -/** - * @} - */ - -#endif /* __NSS_VLAN_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_vxlan.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_vxlan.h deleted file mode 100644 index 254f4bee1..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_vxlan.h +++ /dev/null @@ -1,350 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_vxlan.h - * NSS VxLAN interface definitions. - */ - -#ifndef __NSS_VXLAN_H -#define __NSS_VXLAN_H - -/** - * @addtogroup nss_vxlan_subsystem - * @{ - */ - -/** - * Maximum number of supported VxLAN tunnel sessions. - */ -#define NSS_VXLAN_MAX_TUNNELS 64 - -/** - * Maximum number of supported VxLAN FDB entries. - */ -#define NSS_VXLAN_MACDB_ENTRIES_MAX 1024 - -/** - * MAC database entries per message. - */ -#define NSS_VXLAN_MACDB_ENTRIES_PER_MSG 20 - -/* - * VxLAN Rule configure message flags - */ -#define NSS_VXLAN_RULE_FLAG_GBP_ENABLED 0x0001 /**< Group Policy ID is eanbled. */ -#define NSS_VXLAN_RULE_FLAG_INHERIT_TOS 0x0002 /**< Use inner TOS for encapsulation. */ -#define NSS_VXLAN_RULE_FLAG_ENCAP_L4_CSUM_REQUIRED 0x0004 /**< Generate transmit checksum. */ -#define NSS_VXLAN_RULE_FLAG_IPV4 0x0010 /**< IPv4 tunnel. */ -#define NSS_VXLAN_RULE_FLAG_IPV6 0x0020 /**< IPv6 tunnel. */ -#define NSS_VXLAN_RULE_FLAG_UDP 0x0100 /**< UDP tunnel. */ - -/** - * nss_vxlan_msg_type - * Message types for VxLAN tunnel. - */ -enum nss_vxlan_msg_type { - NSS_VXLAN_MSG_TYPE_STATS_SYNC, /**< Statistics synchronization message. */ - NSS_VXLAN_MSG_TYPE_TUN_CONFIGURE, /**< Creating tunnel rule. */ - NSS_VXLAN_MSG_TYPE_TUN_UNCONFIGURE, /**< Destroying tunnel rule. */ - NSS_VXLAN_MSG_TYPE_TUN_ENABLE, /**< Enable the tunnel. */ - NSS_VXLAN_MSG_TYPE_TUN_DISABLE, /**< Disable the tunnel. */ - NSS_VXLAN_MSG_TYPE_MAC_ADD, /**< Add MAC rule to the database. */ - NSS_VXLAN_MSG_TYPE_MAC_DEL, /**< Remove MAC rule from the database. */ - NSS_VXLAN_MSG_TYPE_MACDB_STATS, /**< MAC database statistics synchronization message. */ - NSS_VXLAN_MSG_TYPE_MAX, /**< Maximum message type. */ -}; - -/** - * nss_vxlan_error_response_types - * Error types for VxLAN responses to messages from the host. - */ -enum nss_vxlan_error_type { - NSS_VXLAN_ERROR_TYPE_NONE = 1, /**< Unknown type error. */ - NSS_VXLAN_ERROR_TYPE_DECAP_REGISTER_FAIL, /**< Decapsulation node registration failed. */ - NSS_VXLAN_ERROR_TYPE_DEST_IP_MISMATCH, /**< Destination IP address mismatch. */ - NSS_VXLAN_ERROR_TYPE_INVALID_VNI, /**< Invalid virtual network ID. */ - NSS_VXLAN_ERROR_TYPE_INVALID_L3_PROTO, /**< L3 Protocol is invalid error. */ - NSS_VXLAN_ERROR_TYPE_INVALID_UDP_PROTO, /**< UDP Protocol is invalid error. */ - NSS_VXLAN_ERROR_TYPE_INVALID_SRC_PORT, /**< Source port range is invalid. */ - NSS_VXLAN_ERROR_TYPE_MAC_BAD_ENTRY, /**< MAC table has a bad entry. */ - NSS_VXLAN_ERROR_TYPE_MAC_EXISTS, /**< MAC entry exists in the table error. */ - NSS_VXLAN_ERROR_TYPE_MAC_NOT_EXIST, /**< MAC does not exist in the table error. */ - NSS_VXLAN_ERROR_TYPE_MAC_ENTRY_UNHASHED, /**< MAC entry is not hashed in table. */ - NSS_VXLAN_ERROR_TYPE_MAC_ENTRY_ALLOC_FAILED, /**< MAC entry allocation failed. */ - NSS_VXLAN_ERROR_TYPE_MAC_ENTRY_DELETE_FAILED, /**< MAC entry deletion failed. */ - NSS_VXLAN_ERROR_TYPE_MAC_TABLE_FULL, /**< MAC table is full error. */ - NSS_VXLAN_ERROR_TYPE_SIBLING_NODE_NOT_EXIST, /**< Sibling node does not exist. */ - NSS_VXLAN_ERROR_TYPE_TUNNEL_CONFIGURED, /**< Tunnel is already configured. */ - NSS_VXLAN_ERROR_TYPE_TUNNEL_UNCONFIGURED, /**< Tunnel is not configured. */ - NSS_VXLAN_ERROR_TYPE_TUNNEL_ADD_FAILED, /**< Adding tunnel information failed. */ - NSS_VXLAN_ERROR_TYPE_TUNNEL_DISABLED, /**< Tunnel is already disabled error. */ - NSS_VXLAN_ERROR_TYPE_TUNNEL_ENABLED, /**< Tunnel is already enabled error. */ - NSS_VXLAN_ERROR_TYPE_TUNNEL_ENTRY_EXISTS, /**< Tunnel already exists. */ - NSS_VXLAN_ERROR_TYPE_MAX, /**< Maximum error type. */ -}; - -/** - * nss_vxlan_stats_msg - * Per-tunnel statistics messages from the NSS firmware. - */ -struct nss_vxlan_stats_msg { - struct nss_cmn_node_stats node_stats; /**< Common firmware statistics. */ - uint32_t except_mac_db_lookup_failed; /**< MAC database look up failed. */ - uint32_t except_mac_move; /**< User is moved. */ - uint32_t except_low_hroom; /**< Transmit exception due to insufficient headroom. */ - uint32_t except_no_policy_id; /**< Policy ID does not exist. */ - uint32_t except_extra_vxlan_hdr_flags; /**< More flags are set than NSS can process. */ - 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. */ -}; - -/** - * nss_vxlan_rule_msg - * VxLAN rule message. - * - * The same rule structure applies for both encapsulation and decapsulation - * in a tunnel. - */ -struct nss_vxlan_rule_msg { - /* - * VxLAN Rules - */ - uint32_t sibling_if_num; /**< Sibling node interface number. */ - uint32_t vni; /**< Virtual network ID. */ - uint16_t tunnel_flags; /**< VxLAN tunnel flags. */ - - /* - * IP rules - */ - uint16_t flow_label; /**< Flow label. */ - uint8_t tos; /**< Type of service/traffic class. */ - uint8_t ttl; /**< TTL/Hop Limit. */ - - /* - * L4 rules - */ - uint16_t src_port_min; /**< Minimum permissible port number. */ - uint16_t src_port_max; /**< Maximum permissible port number. */ - uint16_t dest_port; /**< UDP destination port. */ -}; - -/** - * nss_vxlan_encap_rule - * Encapsulation information for a VxLAN tunnel. - */ -struct nss_vxlan_encap_rule { - uint32_t src_ip[4]; /**< Source IP. */ - uint32_t dest_ip[4]; /**< Destination IP. */ -}; - -/** - * nss_vxlan_mac_msg - * VxLAN MAC message structure. - */ -struct nss_vxlan_mac_msg { - struct nss_vxlan_encap_rule encap; - /**< Tunnel encapsulation header. */ - uint32_t vni; /**< VxLAN network identifier. */ - uint16_t mac_addr[3]; /**< MAC address. */ -}; - -/** - * nss_vxlan_macdb_stats_entry - * MAC database statistics entry. - */ -struct nss_vxlan_macdb_stats_entry { - uint32_t hits; /**< Total hash hits on this hash entry. */ - uint16_t mac[3]; /**< MAC address. */ -}; - -/** - * nss_vxlan_macdb_stats_msg - * VxLAN MAC database statistics. - */ -struct nss_vxlan_macdb_stats_msg { - uint16_t cnt; /**< Number of MAC database entries copied. */ - uint16_t reserved; /**< Reserved for future use. */ - struct nss_vxlan_macdb_stats_entry entry[NSS_VXLAN_MACDB_ENTRIES_PER_MSG]; - /**< MAC database entries. */ -}; - -/** - * nss_vxlan_msg - * Data structure for sending and receiving VxLAN messages. - */ -struct nss_vxlan_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a VxLAN message. - */ - union { - struct nss_vxlan_stats_msg stats; - /**< Synchronized statistics for the VxLAN interface. */ - struct nss_vxlan_rule_msg vxlan_create; - /**< Allocate VxLAN tunnel node. */ - struct nss_vxlan_rule_msg vxlan_destroy; - /**< Destroy VxLAN tunnel node. */ - struct nss_vxlan_mac_msg mac_add; - /**< MAC add message for UDP encapsulation. */ - struct nss_vxlan_mac_msg mac_del; - /**< MAC delete message. */ - struct nss_vxlan_macdb_stats_msg db_stats; - /**< MAC database statistics. */ - } msg; /**< Payload for VxLAN tunnel messages exchanged with the NSS core. */ -}; - -/** - * Callback function for receiving VxLAN tunnel 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_vxlan_buf_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback function for receiving VxLAN 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_vxlan_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - -/** - * nss_vxlan_tx_msg - * Sends VxLAN tunnel messages to the NSS. - * - * Do not call this function from a softirq or interrupt because it - * might sleep if the NSS firmware is busy serving another host thread. - * - * @datatypes - * nss_ctx_instance \n - * nss_vxlan_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] nvm Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_vxlan_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_vxlan_msg *nvm); - -/** - * nss_vxlan_tx_msg_sync - * Sends a VxLAN message to the NSS synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_vxlan_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] nvm Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -extern nss_tx_status_t nss_vxlan_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_vxlan_msg *nvm); - -/** - * nss_vxlan_unregister_if - * Deregisters the VxLAN interface from the NSS. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - */ -extern bool nss_vxlan_unregister_if(uint32_t if_num); - -/** - * nss_vxlan_register_if - * Registers the VxLAN interface with the NSS. - * - * @datatypes - * nss_vxlan_buf_callback_t \n - * nss_vxlan_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] type Dynamic interface type. - * @param[in] data_cb Callback for the data. - * @param[in] notify_cb Callback for the message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_vxlan_register_if(uint32_t if_num, uint32_t type, nss_vxlan_buf_callback_t data_cb, - nss_vxlan_msg_callback_t notify_cb, struct net_device *netdev, uint32_t features); - -/** - * nss_vxlan_register_handler - * Initializes VxLAN module in NSS - * - * @return - * None. - */ -extern void nss_vxlan_init(void); - -/** - * nss_vxlan_msg_init - * Initializes a VxLAN message. - * - * @datatypes - * nss_vxlan_msg \n - * nss_vxlan_msg_callback_t - * - * @param[in,out] nvm Pointer to the VxLAN tunnel message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the message. - * @param[in] cb Pointer to the message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -extern void nss_vxlan_msg_init(struct nss_vxlan_msg *nvm, uint16_t if_num, uint32_t type, uint32_t len, - nss_vxlan_msg_callback_t cb, void *app_data); - -/** - * nss_vxlan_get_ctx() - * Get VxLAN context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_vxlan_get_ctx(void); - -/** - * @} - */ - -#endif -/* __NSS_VXLAN_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi.h deleted file mode 100644 index 4b82904ee..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi.h +++ /dev/null @@ -1,1015 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2015-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 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.h - * NSS TO HLOS Wi-Fi interface definitions. - */ - -#ifndef __NSS_WIFI_H -#define __NSS_WIFI_H - -/** - * @addtogroup nss_wifi_subsystem - * @{ - */ - -#define NSS_WIFI_MGMT_DATA_LEN 128 /**< Size of the Wi-Fi management data. */ -#define NSS_WIFI_FW_STATS_DATA_LEN 480 /**< Size of the firmware statictics data. */ -#define NSS_WIFI_RAWDATA_MAX_LEN 64 /**< Maximum size of the raw Wi-Fi data. */ -#define NSS_WIFI_TX_NUM_TOS_TIDS 8 /**< Number of TIDs. */ -#define NSS_WIFI_PEER_STATS_DATA_LEN 232 /**< Size of the peer statistics data. */ -#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. */ - -/** - * Maximum number of Wi-Fi peers per radio as a sum of - * maximum number of station peers (513), - * maximum numbero of AP VAP peers (16), and - * maximum number of monitor VAP peers (1). - */ -#define NSS_WIFI_MAX_PEER 530 - -/** - * nss_wifi_metadata_types - * Wi-Fi interface request and response message types. - */ -enum nss_wifi_metadata_types { - NSS_WIFI_INIT_MSG, - NSS_WIFI_POST_RECV_MSG, - NSS_WIFI_HTT_INIT_MSG, - NSS_WIFI_TX_INIT_MSG, - NSS_WIFI_RAW_SEND_MSG, - NSS_WIFI_MGMT_SEND_MSG, - NSS_WIFI_WDS_PEER_ADD_MSG, - NSS_WIFI_WDS_PEER_DEL_MSG, - NSS_WIFI_STOP_MSG, - NSS_WIFI_RESET_MSG, - NSS_WIFI_STATS_MSG, - NSS_WIFI_PEER_FREELIST_APPEND_MSG, - NSS_WIFI_RX_REORDER_ARRAY_FREELIST_APPEND_MSG, - NSS_WIFI_SEND_PEER_MEMORY_REQUEST_MSG, - NSS_WIFI_SEND_RRA_MEMORY_REQUEST_MSG, - NSS_WIFI_FW_STATS_MSG, - NSS_WIFI_MONITOR_FILTER_SET_MSG, - NSS_WIFI_PEER_BS_STATE_MSG, - NSS_WIFI_MSDU_TTL_SET_MSG, - NSS_WIFI_RX_VOW_EXTSTATS_SET_MSG, - NSS_WIFI_PKTLOG_CFG_MSG, - NSS_WIFI_ENABLE_PERPKT_TXSTATS_MSG, - NSS_WIFI_IGMP_MLD_TOS_OVERRIDE_MSG, - NSS_WIFI_OL_STATS_CFG_MSG, - NSS_WIFI_OL_STATS_MSG, - NSS_WIFI_TX_QUEUE_CFG_MSG, - NSS_WIFI_TX_MIN_THRESHOLD_CFG_MSG, - NSS_WIFI_DBDC_PROCESS_ENABLE_MSG, - NSS_WIFI_PRIMARY_RADIO_SET_MSG, - NSS_WIFI_FORCE_CLIENT_MCAST_TRAFFIC_SET_MSG, - NSS_WIFI_STORE_OTHER_PDEV_STAVAP_MSG, - NSS_WIFI_STA_KICKOUT_MSG, - NSS_WIFI_WNM_PEER_RX_ACTIVITY_MSG, - NSS_WIFI_PEER_STATS_MSG, - NSS_WIFI_WDS_VENDOR_MSG, - NSS_WIFI_TX_CAPTURE_SET_MSG, - NSS_WIFI_ALWAYS_PRIMARY_SET_MSG, - NSS_WIFI_FLUSH_HTT_CMD_MSG, - 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 -}; - -/* - * wifi_error_types - * Wi-Fi error types. - */ -enum wifi_error_types { - NSS_WIFI_EMSG_NONE = 0, - NSS_WIFI_EMSG_UNKNOWN, - NSS_WIFI_EMSG_MGMT_DLEN, - NSS_WIFI_EMSG_MGMT_SEND, - NSS_WIFI_EMSG_CE_INIT_FAIL, - NSS_WIFI_EMSG_PDEV_INIT_FAIL, - NSS_WIFI_EMSG_HTT_INIT_FAIL, - NSS_WIFI_EMSG_PEER_ADD, - NSS_WIFI_EMSG_WIFI_START_FAIL, - NSS_WIFI_EMSG_STATE_NOT_RESET, - NSS_WIFI_EMSG_STATE_NOT_INIT_DONE, - NSS_WIFI_EMSG_STATE_NULL_CE_HANDLE, - NSS_WIFI_EMSG_STATE_NOT_CE_READY, - NSS_WIFI_EMSG_STATE_NOT_HTT_READY, - NSS_WIFI_EMSG_FW_STATS_DLEN, - NSS_WIFI_EMSG_FW_STATS_SEND, - NSS_WIFI_EMSG_STATE_TX_INIT_FAILED, - NSS_WIFI_EMSG_IGMP_MLD_TOS_OVERRIDE_CFG, - NSS_WIFI_EMSG_PDEV_INVALID, - NSS_WIFI_EMSG_OTHER_PDEV_STAVAP_INVALID, - NSS_WIFI_EMSG_HTT_SEND_FAIL, - NSS_WIFI_EMSG_CE_RING_INIT, - NSS_WIFI_EMSG_NOTIFY_CB, - NSS_WIFI_EMSG_PEERID_INVALID, - NSS_WIFI_EMSG_PEER_INVALID, - NSS_WIFI_EMSG_UNKNOWN_CMD, - NSS_WIFI_EMSG_MAX, -}; - -/** - * nss_wifi_ext_data_pkt_type - * Exception types for Wi-Fi extended data. - */ -enum nss_wifi_ext_data_pkt_type { - NSS_WIFI_RX_EXT_INV_PEER_TYPE, - NSS_WIFI_RX_EXT_PKTLOG_TYPE, - NSS_WIFI_RX_STATS_V2_EXCEPTION, - NSS_WIFI_RX_MGMT_NULL_TYPE, - NSS_WIFI_RX_EXT_MAX_TYPE, -}; - -/** - * nss_wifi_cmd - * Wi-Fi commands. - */ -enum nss_wifi_cmd { - NSS_WIFI_FILTER_NEIGH_PEERS_CMD, - NSS_WIFI_MAX_CMD -}; - -/** - * nss_wifi_ce_ring_state_msg - * Internal state information for the copy engine ring. - */ -struct nss_wifi_ce_ring_state_msg { - uint32_t nentries; /**< Number of entries in the copy engine ring. */ - uint32_t nentries_mask; /**< Number of entry masks. */ - uint32_t sw_index; /**< Initial software index. */ - uint32_t write_index; /**< Initial write index. */ - uint32_t hw_index; /**< Initial hardware index. */ - uint32_t base_addr_CE_space; - /**< Physical address of the copy engine hardware ring. */ - uint32_t base_addr_owner_space; - /**< Virtual address of the copy engine hardware ring. */ -}; - -/** - * nss_wifi_ce_state_msg - * Internal state information for the copy engine. - */ -struct nss_wifi_ce_state_msg { - struct nss_wifi_ce_ring_state_msg src_ring; - /**< Source ring information. */ - struct nss_wifi_ce_ring_state_msg dest_ring; - /**< Destination ring information. */ - uint32_t ctrl_addr; - /**< Control address relative to PCIe BAR. */ -}; - -/** - * nss_wifi_init_msg - * Wi-Fi initialization data. - */ -struct nss_wifi_init_msg { - uint32_t radio_id ; /**< Radio index. */ - uint32_t pci_mem; /**< PCI memory address. */ - uint32_t target_type; /**< Wi-Fi target type. */ - uint32_t mu_mimo_enhancement_en; - /**< Enable MU-MIMO enhancement. */ - struct nss_wifi_ce_state_msg ce_tx_state; - /**< Transmit copy engine information. */ - struct nss_wifi_ce_state_msg ce_rx_state; - /**< Receive copy engine information. */ - - /** - * Indicates whether network processing is bypassed for this radio. - */ - uint32_t bypass_nw_process; -}; - -/** - * nss_wifi_htt_init_msg - * Wi-Fi Host-to-Target (HTT) initialization data. - */ -struct nss_wifi_htt_init_msg { - uint32_t radio_id; /**< Radio index. */ - uint32_t ringsize; /**< WLAN hardware MAC ring size. */ - uint32_t fill_level; /**< Initial fill level. */ - uint32_t paddrs_ringptr; - /**< Physical address of the WLAN MAC hardware ring. */ - uint32_t paddrs_ringpaddr; - /**< Virtual address of the WLAN MAC hardware ring. */ - uint32_t alloc_idx_vaddr; - /**< Virtual address of the hardware ring index. */ - uint32_t alloc_idx_paddr; - /**< Physical address of the hardware ring index. */ -}; - -/** - * nss_wifi_tx_init_msg - * Wi-Fi Tx initialization data. - */ -struct nss_wifi_tx_init_msg { - uint32_t radio_id; /**< Radio index. */ - uint32_t desc_pool_size; /**< Number of descriptor pools allocated. */ - uint32_t tx_desc_array; - /**< Host-initialized software WLAN descriptor pool memory. */ - uint32_t wlanextdesc_addr; - /**< Starting address of the WLAN MAC extenstion descriptor pool. */ - uint32_t wlanextdesc_size; - /**< Descriptor size of the WLAN MAC extenstion. */ - - /** - * Starting virtual address, as shared by the Wi-Fi firmware, for HTT Tx descriptor memory. - */ - uint32_t htt_tx_desc_base_vaddr; - - /** - * HTT Tx descriptor memory start physical address as shared by Wi-Fi firmware. - */ - uint32_t htt_tx_desc_base_paddr; - - uint32_t htt_tx_desc_offset; - /**< Descriptor size of the firmware shared HTT Tx. */ - uint32_t pmap_addr; - /**< Firmware shared peer or TID map. */ -}; - -/** - * nss_wifi_tx_queue_cfg_msg - * Wi-Fi Tx queue configuration. - */ -struct nss_wifi_tx_queue_cfg_msg { - uint32_t size; /**< Size of the Tx queue. */ - uint32_t range; /**< Peer range. */ -}; - -/** - * nss_wifi_tx_min_threshold_cfg_msg - * Minimum threshold configuration data for the Wi-Fi Tx queue. - */ -struct nss_wifi_tx_min_threshold_cfg_msg { - uint32_t min_threshold; /**< Minimum threshold value of Tx queue. */ -}; - -/** - * nss_wifi_rawsend_msg - * Information for Wi-Fi raw data. - */ -struct nss_wifi_rawsend_msg { - uint32_t radio_id ; /**< Radio index. */ - uint32_t len; /**< Size of the raw data. */ - uint32_t array[NSS_WIFI_RAWDATA_MAX_LEN]; - /**< Array of raw data. */ -}; - -/** - * nss_wifi_mgmtsend_msg - * Information for Wi-Fi management data. - */ -struct nss_wifi_mgmtsend_msg { - uint32_t desc_id; /**< Descriptor index. */ - uint32_t len; /**< Size of the management data. */ - uint8_t array[NSS_WIFI_MGMT_DATA_LEN]; - /**< Array of management data. */ -}; - -/** - * nss_wifi_fw_stats_msg - * Information for Wi-Fi firmware statistics. - */ -struct nss_wifi_fw_stats_msg { - uint32_t len; /**< Size of the statistics data. */ - uint8_t array[NSS_WIFI_FW_STATS_DATA_LEN]; - /**< Array of statistics data. */ -}; - -/** - * nss_wifi_monitor_set_filter_msg - * Wi-Fi Monitor mode for setting filter messages. - */ -struct nss_wifi_monitor_set_filter_msg { - uint32_t filter_type; /**< Type of Monitor mode filter. */ -}; - -/** - * nss_wifi_wds_peer_msg - * Wi-Fi WDS peer-specific message. - */ -struct nss_wifi_wds_peer_msg { - uint8_t dest_mac[ETH_ALEN]; /**< MAC address of the destination. */ - uint8_t reserved[2]; /**< Reserved for 4-byte alignment padding. */ - uint8_t peer_mac[ETH_ALEN]; /**< MAC address of the base peer. */ - uint8_t reserved1[2]; /**< Reserved for 4-byte alignment padding. */ -}; - -/** - * nss_wifi_tx_capture_msg - * Wi-Fi Tx data capture configuration. - */ -struct nss_wifi_tx_capture_msg { - uint32_t tx_capture_enable; /**< Enable or disable Tx data capture. */ -}; - -/** - * nss_wifi_reset_msg - * Message to reset the Wi-Fi Radio. - */ -struct nss_wifi_reset_msg { - uint32_t radio_id; /**< Radio index. */ -}; - -/** - * nss_wifi_stop_msg - * Message to stop the Wi-Fi Radio. - */ -struct nss_wifi_stop_msg { - uint32_t radio_id; /**< Radio index. */ -}; - -/** - * nss_wifi_pktlog_cfg_msg - * Configuration information for a Wi-Fi packet log. - */ -struct nss_wifi_pktlog_cfg_msg { - uint32_t enable; /**< Enables or disables a packet log. */ - uint32_t bufsize; /**< Size of the packet log buffer. */ - uint32_t hdrsize; /**< Size of the packet log header. */ - uint32_t msdu_id_offset; /**< Offset for the MSDU ID in the message. */ -}; - -/** - * nss_wifi_ol_stats_cfg_msg - * Wi-Fi offload statistics configuration. - */ -struct nss_wifi_ol_stats_cfg_msg { - uint32_t stats_cfg; /**< Enable or disable offload statistics configuration. */ -}; - -/** - * nss_wifi_enable_perpkt_txstats_msg - * Wi-Fi per-packet Tx statistics configuration. - */ -struct nss_wifi_enable_perpkt_txstats_msg { - uint32_t perpkt_txstats_flag; /**< Enable or disable Tx statistics. */ -}; - -/** - * nss_wifi_peer_txtime_stats - * Peer Tx timestamp statistics per TID. - */ -struct nss_wifi_peer_txtime_stats { - uint32_t sum_tx; /**< Sum of sojourn for each packet. */ - uint32_t sum_msdus; /**< Number of MSDU per peer per TID. */ -}; - -/** - * nss_wifi_peer_tstamp_stats - * Peer ID and timestamp statistics per TID. - */ -struct nss_wifi_peer_tstamp_stats { - uint32_t peer_id; /**< TID value. */ - struct nss_wifi_peer_txtime_stats sum[NSS_WIFI_TX_NUM_TOS_TIDS]; - /**< Timestamps. */ - uint32_t avg[NSS_WIFI_TX_NUM_TOS_TIDS]; /**< Exponential weighted average. */ -}; - -/** - * nss_wifi_ol_peer_time_msg - * NSS Wi-Fi Tx timestamp message for n number of peers. - */ -struct nss_wifi_ol_peer_time_msg { - uint32_t npeers; /**< Number of peers. */ - struct nss_wifi_peer_tstamp_stats tstats[1]; - /**< One instance of struct. */ -}; - -/** - * nss_wifi_enable_ol_statsv2 - * Wi-Fi enable/disable send packet to host. - */ -struct nss_wifi_enable_ol_statsv2 { - uint32_t enable_ol_statsv2; /**< Flag to send packet to host. */ -}; - -/** - * nss_wifi_dbdc_process_enable_msg - * Wi-Fi DBDC repeater process configuration. - */ -struct nss_wifi_dbdc_process_enable_msg { - uint32_t dbdc_process_enable; /**< Enable or disable the DBDC process. */ -}; - -/** - * nss_wifi_primary_radio_set_msg - * Wi-Fi primary radio configuration message. - */ -struct nss_wifi_primary_radio_set_msg { - /** - * Enable/Disable Flag to set the current radio as primary. - */ - uint32_t flag; -}; - -/** - * nss_wifi_always_primary_set_msg - * Always set the Wi-Fi primary radio. - * - * The primary radio is set using the nss_wifi_primary_radio_set_msg flag. - * When the nss_wifi_always_primary_set_msg flag is set: - * - Tx -- Do not drop a unicast packet on the secondary station the VAP. Instead, give that - * packet to the primary station the VAP. - * - Rx -- Do not drop a received unicast packet on the secondary station the VAP. Instead, - * give that packet to the bridge by changing the SKB device as the primary station - * VAP. - * - * Primary usage of this feature is to avoid a loopback. - */ -struct nss_wifi_always_primary_set_msg { - /** - * Always use the primary radio for Tx and Rx in the DBDC repeater process. - */ - uint32_t flag; -}; - -/** - * nss_wifi_force_client_mcast_traffic_set_msg - * Wi-Fi message to set the client multi-cast traffic for a radio. - */ -struct nss_wifi_force_client_mcast_traffic_set_msg { - uint32_t flag; /**< Flag to force set the multi-cast traffic in a radio. */ -}; - -/** - * wifi_store_other_pdev_stavap_msg - * Store the other radio's station vap. - */ -struct nss_wifi_store_other_pdev_stavap_msg { - int stavap_ifnum; /**< Station VAP interface number of the other radio. */ -}; - -/** - * nss_wifi_pl_metadata - * Wi-Fi packet log metadata. - */ -struct nss_wifi_pl_metadata { - uint32_t len; /**< Length of single buffer in MSDU. */ - uint32_t msdu_len; /**< Total MSDU length. */ - uint16_t da_tail; /**< Destination address tail bytes. */ - uint16_t sa_tail; /**< Source address tail bytes. */ - uint8_t vdev_id; /**< Virtual device ID. */ - uint8_t res1; /**< Reserved for alignment. */ - uint16_t res2; /**< Reserved for alignment. */ -}; - -/** - * nss_wifi_rx_ext_metadata - * Wi-Fi Rx extended data plane metadata. - */ -struct nss_wifi_rx_ext_metadata{ - uint16_t peer_id; /**< ID of associated Peer. */ - uint8_t htt_rx_status; /**< Rx status of the HTT. */ - uint8_t type; /**< Reserved for 4 byte alignment. */ -}; - -/** - * nss_wifi_mc_enhance_stats - * Wi-Fi multicast enhancement statistics. - */ -struct nss_wifi_mc_enhance_stats { - uint32_t rcvd; /**< Number of multicast frames received for conversion. */ - - /** - * Number of unicast frames sent as part of multicast enhancement conversion. - */ - uint32_t ucast_converted; - - /** - * Number of multicast enhancement frames dropped because of an allocation - * failure. - */ - uint32_t alloc_fail; - - /** - * Number of multicast enhancement frames dropped because of an enqueue failure. - */ - uint32_t enqueue_fail; - - /** - * Number of multicast enhancement frames dropped because of a copy failure. - */ - uint32_t copy_fail; - - /** - * Number of multicast enhancement frames dropped because of a peer flow control - * send failure. - */ - uint32_t peer_flow_ctrl_send_fail; - - /** - * Number of multicast enhancement frames dropped when the destination MAC - * address is the same as the source MAC address. - */ - uint32_t loopback_err; - - /** - * Number of multicast enhancement buffer frames dropped because of an empty - * destination MAC address. - */ - uint32_t dst_addr_err; -}; - -/** - * nss_wifi_stats_sync_msg - * Wi-Fi synchronization statistics. - */ -struct nss_wifi_stats_sync_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - uint32_t tx_transmit_dropped; - /**< Number of packets dropped during transmission. */ - uint32_t tx_transmit_completions; - /**< Number of packets for which Tx completions are received. */ - uint32_t tx_mgmt_rcv_cnt; - /**< Number of management packets received from the host for Tx. */ - uint32_t tx_mgmt_pkts; - /**< Number of management packets transmitted over Wi-Fi. */ - - /** - * Number of management packets dropped because of a Tx failure. - */ - uint32_t tx_mgmt_dropped; - - /** - * Number of management packets for which Tx completions are received. - */ - uint32_t tx_mgmt_completions; - - /** - * Number of packets for which an Tx enqueue failed because of an invalid peer. - */ - uint32_t tx_inv_peer_enq_cnt; - - /** - * Number of packets with an invalid peer ID received from Wi-Fi. - */ - uint32_t rx_inv_peer_rcv_cnt; - - uint32_t rx_pn_check_failed; - /**< Number of Rx packets that failed a packet number check. */ - - /** - * Number of Rx packets that the Wi-Fi driver successfully processed. - */ - uint32_t rx_pkts_deliverd; - - /** - * Number of Rx bytes that the Wi-Fi driver successfully processed. - */ - uint32_t rx_bytes_deliverd; - - uint32_t tx_bytes_transmit_completions; - /**< Number of bytes for which Tx completions are received. */ - - /** - * Number of unaligned data packets that were received from Wi-Fi and dropped. - */ - uint32_t rx_deliver_unaligned_drop_cnt; - - uint32_t tidq_enqueue_cnt[NSS_WIFI_TX_NUM_TOS_TIDS]; - /**< Number of packets enqueued to TID Queue (TIDQ). */ - uint32_t tidq_dequeue_cnt[NSS_WIFI_TX_NUM_TOS_TIDS]; - /**< Number of packets dequeued from TIDQ. */ - uint32_t tidq_enqueue_fail_cnt[NSS_WIFI_TX_NUM_TOS_TIDS]; - /**< Number of enqueue failures. */ - uint32_t tidq_ttl_expire_cnt[NSS_WIFI_TX_NUM_TOS_TIDS]; - /**< Number of packets expired from TIDQ. */ - uint32_t tidq_dequeue_req_cnt[NSS_WIFI_TX_NUM_TOS_TIDS]; - /**< Number of dequeue requests from the Wi-Fi firmware. */ - uint32_t total_tidq_depth; - /**< Current queue Depth. */ - - /** - * Total number of HTT fetch messages received from the Wi-Fi firmware. - */ - uint32_t rx_htt_fetch_cnt; - - /** - * Total number of packets that bypassed TIDQ and are sent to the Wi-Fi - * firmware. - */ - uint32_t total_tidq_bypass_cnt; - - /** - * Total number of packets dropped because of a global queue full condition. - */ - uint32_t global_q_full_cnt; - - /** - * Total number of packets dropped because of a TID queue full condition. - */ - uint32_t tidq_full_cnt; - - struct nss_wifi_mc_enhance_stats mc_enhance_stats; - /**< Multicast enhancement statistics. */ - - /** - * Number of times a group entry was not present for multicast enhancement. - */ - uint32_t mc_enhance_group_entry_miss; - - /** - * Number of times a deny list was hit during multicast enhancement. - */ - uint32_t mc_enhance_denylist_hit; -}; - -/** - * nss_wifi_peer_freelist_append_msg - * Information for creating a Wi-Fi peer freelist. - */ -struct nss_wifi_peer_freelist_append_msg { - 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. */ -}; - -/** - * nss_wifi_rx_reorder_array_freelist_append_msg - * Information for creating a Wi-Fi TIDQ peer freelist array. - */ -struct nss_wifi_rx_reorder_array_freelist_append_msg { - uint32_t addr; /**< Starting address of the TIDQ freelist pool. */ - uint32_t length; /**< Size of the TIDQ freelist pool. */ - - /** - * Maximum number of Rx reorder array entries supported in the freelist pool. - */ - uint32_t num_rra; -}; - -/** - * wifi_bs_peer_inactivity - * Active state information of the peer. - */ -struct nss_wifi_bs_peer_activity { - uint16_t nentries; /**< Number of entries in the peer ID array. */ - uint16_t peer_id[1]; /**< Array holding the peer IDs. */ -}; - -/** - * nss_wifi_msdu_ttl_set_msg - * Information for setting the Wi-Fi MSDU time-to-live value. - */ -struct nss_wifi_msdu_ttl_set_msg { - uint32_t msdu_ttl; /**< TTL value to be set. */ -}; - -/** - * nss_wifi_rx_vow_extstats_set_msg - * VoW extended statitics set. - */ -struct nss_wifi_rx_vow_extstats_set_msg { - uint32_t vow_extstats_en; /**< VoW extended statistics enable. */ -}; - -/** - * nss_wifi_igmp_mld_override_tos_msg - * Information for overriding TOS. - */ -struct nss_wifi_igmp_mld_override_tos_msg { - uint8_t igmp_mld_ovride_tid_en; - /**< Flag to enable TID override feature for IGMP/MLD configuration. */ - uint8_t igmp_mld_ovride_tid_val; - /**< Value of TID to be overriden for IGMP/MLD. */ - uint8_t res[2]; /**< Reserved for 4-byte alignment. */ -}; - -/** - * nss_wifi_peer_ol_stats - * Wi-Fi offload statistics. - */ -struct nss_wifi_peer_ol_stats { - uint32_t peer_id; /**< ID of associated peer. */ - uint32_t seq_num; /**< Sequence number of the PPDU. */ - uint32_t tx_unaggr; /**< Number of unaggregated packets transmitted. */ - uint32_t tx_aggr; /**< Number of aggregated packets transmitted. */ - 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 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. */ - uint32_t tx_bcast_bytes;/**< Number of broadcast bytes sent. */ - uint32_t tx_mgmt; /**< Number of Tx management frames. */ - uint32_t tx_wme[NSS_WIFI_WME_NUM_AC]; - /**< Data frames transmitted per AC. */ - uint32_t rx_wme[NSS_WIFI_WME_NUM_AC]; - /**< Data frames received per AC. */ - 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. */ -}; - -/** - * nss_wifi_ol_stats_msg - * Wi-Fi offload statistics. - */ -struct nss_wifi_ol_stats_msg { - uint32_t bawadv_cnt; /**< Number of block-acknowledgment window advancements. */ - uint32_t bcn_cnt; /**< Number of beacons. */ - uint32_t npeers; /**< Number of peer statistics entries. */ - struct nss_wifi_peer_ol_stats peer_ol_stats[1]; - /**< Array to hold the peer statistics. */ -}; - -/** - * nss_wifi_sta_kickout_msg - * Station kickout message from NSS Firmware - */ -struct nss_wifi_sta_kickout_msg { - 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. */ -}; - -/** - * nss_wifi_wnm_peer_rx_activity_msg - * Rx active state information for the peer. - */ -struct nss_wifi_wnm_peer_rx_activity_msg { - uint16_t nentries; /**< Number of entries. */ - - /** - * Array to hold the peer IDs for which the activity is reported. - */ - uint16_t peer_id[NSS_WIFI_MAX_PEER]; -}; - -/** - * nss_wifi_append_metaheader - * Append metaheader after pbuf->data for stats_v2. - */ -struct nss_wifi_append_statsv2_metahdr { - uint32_t rxstatsmagic; /**< Magic to be verified on host. */ - uint32_t seq_number; /**< Sequence number of packets sent from NSS. */ - uint16_t peer_id; /**< Peer ID of peer. */ - uint16_t num_msdus; /**< Number of MSDU in PPDU. */ - uint16_t num_retries; /**< Number of retries in PPDU. */ - uint16_t num_mpdus; /**< Number of MPDU in PPDU. */ - uint32_t num_bytes; /**< Number of bytes in PPDU. */ -}; - -/** - * nss_wifi_peer_stats_msg - * Wi-Fi peer statistics. - */ -struct nss_wifi_peer_stats_msg { - uint32_t peer_id; /**< Peer ID. */ - uint32_t tidq_byte_cnt[NSS_WIFI_TX_NUM_TOS_TIDS]; - /**< Number of bytes in each TIDQ. */ - uint32_t tidq_queue_max[NSS_WIFI_TX_NUM_TOS_TIDS]; - /**< Maximum depth for the TID queue. */ - uint32_t tidq_enqueue_cnt[NSS_WIFI_TX_NUM_TOS_TIDS]; - /**< Number of packets enqueued to the TIDQ. */ - uint32_t tidq_dequeue_cnt[NSS_WIFI_TX_NUM_TOS_TIDS]; - /**< Number of packets dequeued from the TIDQ. */ - uint32_t tidq_ttl_expire_cnt[NSS_WIFI_TX_NUM_TOS_TIDS]; - /**< Number of expired packets from the TIDQ. */ - uint32_t tidq_dequeue_req_cnt[NSS_WIFI_TX_NUM_TOS_TIDS]; - /**< Number of dequeue requests from the Wi-Fi firmware. */ - - /** - * Total number of packets dropped because the TID queue is full. - */ - uint32_t tidq_full_cnt[NSS_WIFI_TX_NUM_TOS_TIDS]; -}; - -/** - * nss_wifi_wds_extn_peer_cfg_msg - * Configuration information when the WDS extension is enabled. - */ -struct nss_wifi_wds_extn_peer_cfg_msg { - uint8_t mac_addr[ETH_ALEN]; /**< Mac address of the peer. */ - uint8_t wds_flags; /**< WDS flags populated from the host. */ - uint8_t reserved; /**< Alignment padding. */ - uint16_t peer_id; /**< ID of the peer. */ -}; - -/** - * nss_wifi_cmd_msg - * Wi-Fi radio specific special commands to NSS Firmware - */ -struct nss_wifi_cmd_msg { - uint32_t cmd; /**< Type of command message. */ - uint32_t value; /**< Value of the command. */ -}; - -/** - * nss_wifi_msg - * Data for sending and receiving Wi-Fi messages. - */ -struct nss_wifi_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Message Payload. - */ - union { - struct nss_wifi_init_msg initmsg; - /**< Wi-Fi Radio initialization message. */ - struct nss_wifi_stop_msg stopmsg; - /**< Wi-Fi Radio stop message. */ - struct nss_wifi_reset_msg resetmsg; - /**< Wi-Fi Radio reset message. */ - struct nss_wifi_htt_init_msg httinitmsg; - /**< HTT initialization message. */ - struct nss_wifi_tx_init_msg pdevtxinitmsg; - /**< Tx initialization message. */ - struct nss_wifi_rawsend_msg rawmsg; - /**< Wi-Fi raw data send message. */ - struct nss_wifi_mgmtsend_msg mgmtmsg; - /**< Wi-Fi management data send message. */ - struct nss_wifi_wds_peer_msg pdevwdspeermsg; - /**< WDS peer-specific message. */ - struct nss_wifi_stats_sync_msg statsmsg; - /**< Synchronization statistics. */ - struct nss_wifi_peer_freelist_append_msg peer_freelist_append; - /**< Message for creating/appending peer freelist memory. */ - - /** - * Message for creating/appending a reorder array for Wi-Fi Receive Defragmentation. - */ - struct nss_wifi_rx_reorder_array_freelist_append_msg rx_reorder_array_freelist_append; - - struct nss_wifi_fw_stats_msg fwstatsmsg; - /**< Wi-Fi firmware statistics information message. */ - struct nss_wifi_monitor_set_filter_msg monitor_filter_msg; - /**< Set the filter message for Monitor mode. */ - struct nss_wifi_bs_peer_activity peer_activity; - /**< Message to get the active peer for a radio. */ - struct nss_wifi_msdu_ttl_set_msg msdu_ttl_set_msg; - /**< Set MSDU time-to-live. */ - struct nss_wifi_rx_vow_extstats_set_msg vow_extstats_msg; - /**< Enable VoW extended statistics message. */ - struct nss_wifi_pktlog_cfg_msg pcm_msg; - /**< Packet log configuration message. */ - struct nss_wifi_enable_perpkt_txstats_msg ept_msg; - /**< Enable or disable per-packet Tx statistics. */ - struct nss_wifi_igmp_mld_override_tos_msg wigmpmldtm_msg; - /**< Message to enable TID override for IGMP/MLD. */ - struct nss_wifi_ol_stats_cfg_msg scm_msg; - /**< Enable or disable offload statistics configuration. */ - struct nss_wifi_ol_stats_msg ol_stats_msg; - /**< Offload statistics. */ - struct nss_wifi_tx_queue_cfg_msg wtxqcm; - /**< Tx queue configuration. */ - - /** - * Minimum threshold configuration data for the Tx queue. - */ - struct nss_wifi_tx_min_threshold_cfg_msg wtx_min_threshold_cm; - - struct nss_wifi_dbdc_process_enable_msg dbdcpe_msg; - /**< Enable or disable the DBDC repeater process. */ - struct nss_wifi_primary_radio_set_msg wprs_msg; - /**< Set the current radio as the primary radio. */ - struct nss_wifi_force_client_mcast_traffic_set_msg wfcmts_msg; - /**< Message to force multicast traffic for a radio. */ - struct nss_wifi_store_other_pdev_stavap_msg wsops_msg; - /**< Message to store the other radio's station vap. */ - struct nss_wifi_sta_kickout_msg sta_kickout_msg; - /**< Station kickout message from NSS firmware. */ - struct nss_wifi_wnm_peer_rx_activity_msg wprm; - /**< Rx activity for the peer. */ - struct nss_wifi_peer_stats_msg peer_stats_msg; - /**< Peer statistics message. */ - struct nss_wifi_wds_extn_peer_cfg_msg wpeercfg; - /**< Configuartion information message when the WDS extension is enabled. */ - struct nss_wifi_tx_capture_msg tx_capture_msg; - /**< Enable or disable Tx data capture. */ - struct nss_wifi_always_primary_set_msg waps_msg; - /**< Message to always set the current radio as primary radio. */ - struct nss_wifi_cmd_msg wcmdm; - /**< Pdev command information. */ - struct nss_wifi_enable_ol_statsv2 wesh_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. */ -}; - -/** - * nss_wifi_get_context - * Gets the Wi-Fi context used in nss_gre_tx. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_wifi_get_context(void); - -/** - * nss_wifi_tx_msg - * Sends a Wi-Fi message to the NSS firmware. - * - * @datatypes - * nss_ctx_instance \n - * nss_wifi_if_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_wifi_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_wifi_msg *msg); - -/** - * Callback function for receiving Wi-Fi messages. - * - * @datatypes - * nss_wifi_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_msg_callback_t)(void *app_data, struct nss_wifi_msg *msg); - -/** - * 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_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_register_wifi_if - * Registers the Wi-Fi interface with the NSS for sending and receiving messages. - * - * @datatypes - * nss_wifi_callback_t \n - * nss_wifi_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] wifi_callback Callback for the data. - * @param[in] wifi_ext_callback Callback for the extended data. - * @param[in] event_callback Callback for the message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this interface. - * - * @return - * Pointer to the NSS core context. - */ -struct nss_ctx_instance *nss_register_wifi_if(uint32_t if_num, nss_wifi_callback_t wifi_callback, - nss_wifi_callback_t wifi_ext_callback, nss_wifi_msg_callback_t event_callback, struct net_device *netdev, uint32_t features); - -/** - * nss_unregister_wifi_if - * Deregisters the Wi-Fi interface from the NSS. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - */ -void nss_unregister_wifi_if(uint32_t if_num); - -/** - * @} - */ - -#endif /* __NSS_WIFI_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi_ext_vdev_if.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi_ext_vdev_if.h deleted file mode 100644 index df48a5848..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi_ext_vdev_if.h +++ /dev/null @@ -1,297 +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. - ************************************************************************** - */ - -/** - * @file nss_wifi_ext_vdev_if.h - * NSS Wi-Fi extended virtual device interface definitions. - */ - -#ifndef __NSS_WIFI_EXT_VDEV_IF_H -#define __NSS_WIFI_EXT_VDEV_IF_H - -#define NSS_WIFI_EXT_VDEV_MAX 16 - -/* - * nss_wifi_ext_vdev_msg_types - * WiFi extension virtual device mesage types. - */ -enum nss_wifi_ext_vdev_msg_types { - NSS_WIFI_EXT_VDEV_MSG_CONFIGURE_IF = NSS_IF_MAX_MSG_TYPES + 1, - NSS_WIFI_EXT_VDEV_MSG_CONFIGURE_WDS, - NSS_WIFI_EXT_VDEV_SET_NEXT_HOP, - NSS_WIFI_EXT_VDEV_MSG_STATS_SYNC, - NSS_WIFI_EXT_VDEV_MSG_CONFIGURE_VLAN, - NSS_WIFI_EXT_VDEV_MSG_MAX -}; - -/** - * nss_wifi_ext_vdev_error_tyes - * WiFi extension error types. - */ -enum nss_wifi_ext_vdev_error_types { - NSS_WIFI_EXT_VDEV_ERROR_NONE = NSS_IF_ERROR_TYPE_MAX + 1, - /** Configuration successful. */ - NSS_WIFI_EXT_VDEV_ERROR_NULL_MAC, /**< NULL MAC received. */ - NSS_WIFI_EXT_VDEV_ERROR_INV_RADIO_ID, /**< Invalid radio interface number. */ - NSS_WIFI_EXT_VDEV_ERROR_INV_PVAP_ID, /**< Invalid parent virtual device interface number. */ - NSS_WIFI_EXT_VDEV_ERROR_RADIO_NOT_PRESENT, /**< Radio node is not present. */ - NSS_WIFI_EXT_VDEV_ERROR_INV_IF, /**< Message sent on invalid interface number. */ - NSS_WIFI_EXT_VDEV_ERROR_INV_VLAN_ID, /**< Invalid VLAN ID. */ - NSS_WIFI_EXT_VDEV_ERROR_INV_CMD, /**< Invalid command. */ - NSS_WIFI_EXT_VDEV_ERROR_PEERID_ALREADY_CONFIGURED, - /**< Peer ID is already configured. */ - NSS_WIFI_EXT_VDEV_ERROR_MAX /**< Maxiumum error types. */ -}; - -/** - * nss_wifi_ext_vdev_wds_msg - * Extended WDS configuration message. - */ -struct nss_wifi_ext_vdev_wds_msg { - uint16_t wds_peer_id; /**< WDS station peer ID. */ - uint16_t mac_addr[3]; /**< Remote MAC address. */ -}; - -/** - * nss_wifi_ext_vdev_stats - * Statistics message structure. - */ -struct nss_wifi_ext_vdev_stats { - struct nss_cmn_node_stats node_stats; /**< Ethernet node statistics. */ - uint32_t mc_count; /**< Number of mulitcast counts. */ - uint32_t nxt_hop_drp; /**< Next hop drop. */ -}; - -/** - * nss_wifi_vdev_config_msg - * NSS Wi-Fi virtual device configuration message. - */ -struct nss_wifi_ext_vdev_configure_if_msg { - uint8_t mac_addr[ETH_ALEN]; /**< MAC address. */ - uint16_t radio_ifnum; /**< Radio interface corresponding to virtual AP. */ - uint16_t pvap_ifnum; /**< Parent virtual device interface number. */ -}; - -/** - * nss_wifi_ext_vdev_set_next_hop_msg - * Message to set the next hop. - */ -struct nss_wifi_ext_vdev_set_next_hop_msg { - uint32_t if_num; /**< Interface number. */ -}; - -/** - * nss_wifi_ext_vdev_vlan_msg - * Extended VLAN configuration message. - */ -struct nss_wifi_ext_vdev_vlan_msg { - uint16_t vlan_id; /**< VLAN ID. */ -}; - -/** - * nss_wifi_ext_vdev_msg - * Message structure to Send/Receive commands. - */ -struct nss_wifi_ext_vdev_msg { - struct nss_cmn_msg cm; /**< Cnode message. */ - union { - union nss_if_msgs if_msg; /**< NSS interface base message. */ - struct nss_wifi_ext_vdev_configure_if_msg cmsg; /**< Interface configuration message. */ - struct nss_wifi_ext_vdev_wds_msg wmsg; /**< WDS configure message. */ - struct nss_wifi_ext_vdev_set_next_hop_msg wnhm; /**< Next hop set message. */ - struct nss_wifi_ext_vdev_stats stats; /**< Statistics messasge. */ - struct nss_wifi_ext_vdev_vlan_msg vmsg; /**< VLAN message. */ - } msg; -}; - -/** - * Callback function for receiving Wi-Fi extended virtual device 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_ext_vdev_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback function for receiving Wi-Fi extended virtual device messages. - * - * @datatypes - * nss_wifi_ext_vdev_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] wevm Pointer to the message data. - */ -typedef void (*nss_wifi_ext_vdev_msg_callback_t)(void *app_data, struct nss_cmn_msg *ncm); - -/** - * Callback function for receiving extended data from the Wi-Fi extended virtual device interface. - * - * @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. - * @param[in] netdev Pointer to the associated network device. - */ -typedef void (*nss_wifi_ext_vdev_ext_data_callback_t)(struct net_device *netdev, - struct sk_buff *skb, struct napi_struct *napi); -/** - * nss_wifi_ext_vdev_msg_init - * Initializes a Wi-Fi extended virtual device message. - * - * @datatypes - * nss_wifi_vdev_msg \n - * nss_wifi_vdev_msg_callback_t - * - * @param[in] nim Pointer to the NSS interface message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Length of message. - * @param[in] cb Message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -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_wifi_ext_vdev_unregister_if - * Deregisters a Wi-Fi extended virtual interface from the NSS. - * - * @param[in] if_num Wi-Fi extended virtual interface number. - * - * @return - * None. - * - * @dependencies - * The Wi-Fi extended virtual interface must have been previously registered. - * - * @return - * True if successful, else false. - */ -extern bool nss_wifi_ext_vdev_unregister_if(uint32_t if_num); - -/** - * nss_wifi_ext_vdev_tx_buf - * Sends data buffers to NSS firmware asynchronously. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] os_buf Pointer to the OS buffer (e.g. skbuff). - * @param[in] if_num Wi-Fi extended virtual interface number. - * - * @return - * Status of the transmit operation. - */ -extern nss_tx_status_t nss_wifi_ext_vdev_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, - uint32_t if_num); - -/** - * nss_wifi_ext_vdev_tx_msg - * Sends Wi-Fi extended virtual interface messages. - * - * @datatypes - * nss_ctx_instance \n - * nss_wifi_ext_vdev_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] wevm Pointer to the message data. - * - * @return - * Status of the transmit operation. - */ -extern nss_tx_status_t nss_wifi_ext_vdev_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_wifi_ext_vdev_msg *wevm); - -/** - * nss_wifi_ext_vdev_tx_msg_sync - * Sends messages to NSS firmware synchronously. - * - * @datatypes - * nss_ctx_instance \n - * nss_wifi_ext_vdev_msg - * - * @param[in] nss_ctx NSS core context. - * @param[in] nwevm Pointer to Wi-Fi extended virtual interface message data. - * - * @return - * Status of the transmit operation. - */ -extern 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_wifi_ext_vdev_set_next_hop - * Sets the extended virtual interface next hop. - * - * @datatypes - * nss_ctx_instance \n - * - * @param[in] ctx NSS core context. - * @param[in] if_num NSS interface number. - * @param[in] next_hop Next hop interface number. - */ -extern nss_tx_status_t nss_wifi_ext_vdev_set_next_hop(struct nss_ctx_instance *ctx, int if_num, int next_hop); - -/** - * nss_wifi_ext_vdev_get_ctx - * Gets the NSS Wi-Fi extended virtual interface context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_wifi_ext_vdev_get_ctx(void); - -/** - * nss_wifi_ext_vdev_register_if - * Registers Wi-Fi extended virtual interface with NSS. - * - * @datatypes - * net_device \n - * nss_wifi_ext_vdev_data_callback_t \n - * nss_wifi_ext_vdev_ext_data_callback_t \n - * nss_wifi_ext_vdev_msg_callback_t - * - * @param[in] if_num NSS interface number. - * @param[in] cb_func_data Callback for the data. - * @param[in] cb_func_ext Callback for the message. - * @param[in] cb_func_msg Callback for the event message. - * @param[in] features Data socket buffer types supported by this interface. - * @param[in] netdev Pointer to the associated network device. - * @param[in] app_ctx Pointer to the application context. - * - * @return - * NSS interface number allocated. - */ -extern struct nss_ctx_instance *nss_wifi_ext_vdev_register_if(uint32_t if_num, - nss_wifi_ext_vdev_data_callback_t cb_func_data, nss_wifi_ext_vdev_ext_data_callback_t cb_func_ext, - nss_wifi_ext_vdev_msg_callback_t cb_func_msg, struct net_device *netdev, uint32_t features, - void *app_ctx); -#endif diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi_mac_db_if.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi_mac_db_if.h deleted file mode 100644 index 05b942553..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi_mac_db_if.h +++ /dev/null @@ -1,277 +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. - ************************************************************************** - */ - - /** - * @file nss_wifi_mac_db_if.h - * NSS-to-HLOS interface definitions. - */ -#ifndef __NSS_WIFI_MAC_DB_H -#define __NSS_WIFI_MAC_DB_H - -#define NSS_WIFI_MAC_DB_ENTRY_IF_LOCAL 0x1 - -/* - * 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. - */ -enum nss_wifi_mac_db_msg_types { - NSS_WIFI_MAC_DB_INIT_MSG, /**< Wi-Fi MAC database initialization message. */ - NSS_WIFI_MAC_DB_ADD_ENTRY_MSG, /**< Wi-Fi MAC database add entry message. */ - 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 -}; - -/** - * nss_wifi_mac_db_iftype - * Wi-Fi MAC database interface type. - */ -enum nss_wifi_mac_db_iftype { - NSS_WIFI_MAC_DB_ENTRY_IFTYPE_NONE, - NSS_WIFI_MAC_DB_ENTRY_IFTYPE_VAP, /**< Wi-Fi MAC database VAP entry interface. */ - NSS_WIFI_MAC_DB_ENTRY_IFTYPE_NON_VAP, /**< Wi-Fi MAC database non-VAP entry interface. */ - NSS_WIFI_MAC_DB_ENTRY_IFTYPE_MAX /**< Wi-Fi MAC database maximum interface. */ -}; - -/** - * nss_wifi_mac_db_if_opmode - * Wi-Fi MAC database interface operation mode. - */ -enum nss_wifi_mac_db_if_opmode { - NSS_WIFI_MAC_DB_ENTRY_IF_OPMODE_NONE, /**< No entry database interface operation mode. */ - NSS_WIFI_MAC_DB_ENTRY_IF_OPMODE_ETH, /**< Ethernet entry database interface operation mode. */ - NSS_WIFI_MAC_DB_ENTRY_IF_OPMODE_WIFI_AP, /**< Wi-Fi AP entry database interface operation mode. */ - NSS_WIFI_MAC_DB_ENTRY_IF_OPMODE_WIFI_STA, /**< Wi-Fi station entry database interface operation mode. */ - NSS_WIFI_MAC_DB_ENTRY_IF_OPMODE_MAX /**< Maximum entry database interface operation mode. */ -}; - -/** - * 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. */ - uint16_t flag; /**< Flag information about NSS interface. */ - int32_t nss_if; /**< NSS interface number. */ - uint32_t iftype; /**< NSS interface type. */ - uint32_t opmode; /**< NSS interface operation mode. */ - uint32_t wiphy_ifnum; /**< NSS interface for wireless physical device. */ -}; - -/** - * 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. - */ -struct nss_wifi_mac_db_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of Wi-Fi MAC database message. - */ - 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. */ -}; - -/** - * nss_wifi_mac_db_msg_callback_t - * Callback to receive Wi-Fi MAC database messages. - * - * @datatypes - * nss_wifi_mac_db_msg - * - * @param[in] app_data Application context of the message. - * @param[in] msg Message data. - * - * @return - * void - */ -typedef void (*nss_wifi_mac_db_msg_callback_t)(void *app_data, struct nss_wifi_mac_db_msg *msg); - -/** - * nss_wifi_mac_db_callback_t - * Callback to receive Wi-Fi MAC database messages. - * - * @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. - * - * @return - * void - */ -typedef void (*nss_wifi_mac_db_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - - -/** - * nss_wifi_mac_db_tx_msg - * Send Wi-Fi MAC database messages. - * - * @datatypes - * nss_ctx_instance \n - * nss_wifi_mac_db_msg - * - * @param[in] nss_ctx NSS context. - * @param[in] msg NSS Wi-Fi MAC database message. - * - * @return - * nss_tx_status_t Tx status - */ -extern nss_tx_status_t nss_wifi_mac_db_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_wifi_mac_db_msg *msg); - -/** - * nss_register_wifi_mac_db_if - * Register to send/receive Wi-Fi MAC database messages to NSS. - * - * @datatypes - * nss_wifi_mac_db_callback_t \n - * nss_wifi_mac_db_msg_callback_t \n - * net_device - * - * @param[in] if_num NSS interface number. - * @param[in] mfdb_callback Callback for the Wi-Fi MAC database device data. - * @param[in] mfdb_ext_callback Callback for the extended data. - * @param[in] event_callback Callback for the message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this - * interface. - * - * @return - * nss_ctx_instance* NSS context - */ -struct nss_ctx_instance *nss_register_wifi_mac_db_if(uint32_t if_num, nss_wifi_mac_db_callback_t wifi_mac_db_callback, - nss_wifi_mac_db_callback_t wifi_mac_db_ext_callback, nss_wifi_mac_db_msg_callback_t event_callback, struct net_device *netdev, uint32_t features); - -/** - * nss_unregister_wifi_mac_db_if - * Deregister Wi-Fi MAC database SoC interface with NSS. - * - * @param[in] if_num NSS interface number. - * - * @return - * void - */ -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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi_mesh.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi_mesh.h deleted file mode 100644 index 986170a43..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi_mesh.h +++ /dev/null @@ -1,1000 +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. - ************************************************************************** - */ - -/** - * @file nss_wifi_mesh.h - * NSS TO HLOS Wi-Fi mesh device interface definitions. - */ - -#ifndef __NSS_WIFI_MESH_H -#define __NSS_WIFI_MESH_H - -/** - * @addtogroup nss_wifi_mesh_subsystem - * @{ - */ -#define NSS_WIFI_MESH_WIFI_HDRLEN_MAX 48 -/* - * Wi-Fi mesh maximum dynamic interface. - */ -#define NSS_WIFI_MESH_MAX_DYNAMIC_INTERFACE 32 - -/** - * Mesh path update flags. - */ -#define NSS_WIFI_MESH_PATH_UPDATE_FLAG_NEXTHOP 0x01 -#define NSS_WIFI_MESH_PATH_UPDATE_FLAG_HOPCOUNT 0x02 -#define NSS_WIFI_MESH_PATH_UPDATE_FLAG_METRIC 0x04 -#define NSS_WIFI_MESH_PATH_UPDATE_FLAG_MESH_FLAGS 0x08 -#define NSS_WIFI_MESH_PATH_UPDATE_FLAG_EXPIRY_TIME 0x10 -#define NSS_WIFI_MESH_PATH_UPDATE_FLAG_MESH_GATE 0x20 -#define NSS_WIFI_MESH_PATH_UPDATE_FLAG_BLOCK_MESH_FWD 0x40 -#define NSS_WIFI_MESH_PATH_UPDATE_FLAG_METADATA_ENABLE_VALID 0x80 - -/** - * Mesh proxy path update flags. - */ -#define NSS_WIFI_MESH_PROXY_PATH_UPDATE_FLAG_MDA 0x1 -#define NSS_WIFI_MESH_PROXY_PATH_UPDATE_FLAG_MESH 0x2 - -/** - * Mesh path update flags. - */ -#define NSS_WIFI_MESH_PATH_FLAG_REFRESH_SENT 0x1 - -/** - * Mesh path maximum entries. - */ -#define NSS_WIFI_MESH_PATH_MAX_ENTRIES 10 - -/** - * Mesh proxy path maximum entries. - */ -#define NSS_WIFI_MESH_PROXY_PATH_MAX_ENTRIES 10 - -/** - * Mesh configuration flags. - */ -#define NSS_WIFI_MESH_CONFIG_FLAG_TTL_VALID 0x01 -#define NSS_WIFI_MESH_CONFIG_FLAG_MPATH_REFRESH_VALID 0x02 -#define NSS_WIFI_MESH_CONFIG_FLAG_BLOCK_MESH_FORWARDING_VALID 0x04 -#define NSS_WIFI_MESH_CONFIG_FLAG_LOCAL_MAC_VALID 0x08 -#define NSS_WIFI_MESH_CONFIG_FLAG_MPP_LEARNING_MODE_VALID 0x10 -#define NSS_WIFI_MESH_CONFIG_FLAG_SIBLING_IF_NUM_VALID 0x20 -#define NSS_WIFI_MESH_CONFIG_FLAG_BLOCK_MESH_FWD_VALID 0x40 -#define NSS_WIFI_MESH_CONFIG_FLAG_METADATA_ENABLE_VALID 0x80 - -/** - * nss_wifi_mesh_path_flags - * Wi-Fi mesh path flags. - */ -#define NSS_WIFI_MESH_PATH_FLAG_ACTIVE 0x01 -#define NSS_WIFI_MESH_PATH_FLAG_RESOLVING 0x02 -#define NSS_WIFI_MESH_PATH_FLAG_RESOLVED 0x04 -#define NSS_WIFI_MESH_PATH_FLAG_FIXED 0x08 - -#define NSS_WIFI_MESH_ENCAP_METADATA_OFFSET_TYPE 4 - -/* - * nss_wifi_mesh_pre_header_type { - * Wi-Fi pre header types. - */ -enum nss_wifi_mesh_pre_header_type { - NSS_WIFI_MESH_PRE_HEADER_NONE = 0xdcb, /**< No preheader. */ - NSS_WIFI_MESH_PRE_HEADER_80211 = 0xabc, /**< 802.11 preheader. */ - NSS_WIFI_MESH_PRE_HEADER_MAX = 0xdea /**< Max preheader. */ -}; - -/* - * nss_wifi_mesh_extended_data_pkt_types - * Wi-Fi mesh extended data pkt types. - */ -enum nss_wifi_mesh_extended_data_pkt_types { - WIFI_MESH_EXT_DATA_PKT_TYPE_NONE, /**< No packet type. */ - WIFI_MESH_EXT_DATA_PKT_TYPE_EXCEPTION /**< Exception packet type. */ -}; - -/* - * nss_wifi_mesh_ieee80211_hdr - * Wi-Fi header - */ -struct nss_wifi_mesh_ieee80211_hdr { - uint16_t frame_ctl; /* Frame control. */ - uint16_t duration_id; /* Duration ID. */ - uint8_t addr1[ETH_ALEN]; /* Address 1. */ - uint8_t addr2[ETH_ALEN]; /* Address 2. */ - uint8_t addr3[ETH_ALEN]; /* Address 3. */ - uint16_t seq_ctrl; /* Sequence control. */ - uint8_t addr4[ETH_ALEN]; /* Address 4. */ -}__packed; - -/* - * nss_wifi_mesh_ieee80211s_hdr - * Wi-Fi mesh header - */ -struct nss_wifi_mesh_ieee80211s_hdr { - uint8_t flags; /* Mesh flags. */ - uint8_t ttl; /* TTL. */ - uint32_t seq_num; /* Sequence number. */ - uint8_t eaddr1[ETH_ALEN]; /* Mesh Address1. */ - uint8_t eaddr2[ETH_ALEN]; /* Mesh Address2. */ -}__packed; - -/* - * nss_wifi_mesh_per_packet_metadata - * Wi-Fi mesh per packet metadata structure. - */ -struct nss_wifi_mesh_per_packet_metadata { - uint16_t pkt_type; /* Packet type of the metadata. */ - uint8_t wifi_hdr_bytes[NSS_WIFI_MESH_WIFI_HDRLEN_MAX]; /* Wi-Fi header byte stream. */ -}; - -/** - * nss_wifi_mesh_dp_type - * Interface datapath types. - * NSS-to-host path will be seen by ECM for rules. - */ -enum nss_wifi_mesh_dp_type { - NSS_WIFI_MESH_DP_INNER, /**< Inner/Encapsulation Interface. */ - NSS_WIFI_MESH_DP_OUTER, /**< Outer/Decapsulation Interface. */ -}; - -/** - * nss_wifi_mesh_msg_types - * Wi-Fi mesh messages. - */ -enum nss_wifi_mesh_msg_types { - NSS_WIFI_MESH_MSG_INTERFACE_CONFIGURE = NSS_IF_MAX_MSG_TYPES + 1, /**< Wi-Fi mesh interface configure message. */ - NSS_WIFI_MESH_MSG_MPATH_ADD, /**< Wi-Fi mesh path add message. */ - NSS_WIFI_MESH_MSG_MPATH_DELETE, /**< Wi-Fi mesh path delete message. */ - NSS_WIFI_MESH_MSG_MPATH_UPDATE, /**< Wi-Fi mesh path update. */ - NSS_WIFI_MESH_MSG_PROXY_PATH_LEARN, /**< Wi-Fi mesh proxy path learn. */ - NSS_WIFI_MESH_MSG_PROXY_PATH_ADD, /**< Wi-Fi mesh proxy path add. */ - NSS_WIFI_MESH_MSG_PROXY_PATH_DELETE, /**< Wi-Fi mesh proxy path delete. */ - NSS_WIFI_MESH_MSG_PROXY_PATH_UPDATE, /**< Wi-Fi mesh proxy path update. */ - NSS_WIFI_MESH_MSG_PATH_NOT_FOUND, /**< Wi-Fi mesh path not found message. */ - NSS_WIFI_MESH_MSG_PATH_REFRESH, /**< Wi-Fi mesh path refresh message. */ - NSS_WIFI_MESH_MSG_PATH_EXPIRY, /**< Wi-Fi mesh path expiry message. */ - NSS_WIFI_MESH_MSG_PATH_TABLE_DUMP, /**< Wi-Fi mesh path table dump. */ - NSS_WIFI_MESH_MSG_PROXY_PATH_TABLE_DUMP, /**< Wi-Fi mesh proxy path table dump. */ - NSS_WIFI_MESH_MSG_STATS_SYNC, /**< Wi-Fi mesh statistics sync messgae. */ - NSS_WIFI_MESH_MSG_EXCEPTION_FLAG, /**< Wi-Fi mesh exception Flag. */ - NSS_WIFI_MESH_CONFIG_EXCEPTION, /**< Wi-Fi mesh configuration exception. */ - NSS_WIFI_MESH_MSG_MAX /**< Wi-Fi mesh maximum message. */ -}; - -/* - * nss_wifi_mesh_error_types - * Wi-Fi mesh error types. - */ -enum nss_wifi_mesh_error_types { - NSS_WIFI_MESH_ERROR_NONE = NSS_IF_ERROR_TYPE_MAX + 1, /**< Wi-Fi mesh no error type. */ - NSS_WIFI_MESH_ERROR_UNKNOWN_MSG, /**< Wi-Fi mesh unknown message error. */ - NSS_WIFI_MESH_ERROR_TTL_CONFIG, /**< Wi-Fi mesh invalid ttl error. */ - NSS_WIFI_MESH_ERROR_REFRESH_TIME_CONFIG, /**< Wi-Fi mesh invalid refresh time. */ - NSS_WIFI_MESH_ERROR_MPP_LEARNING_MODE_CONFIG, /**< Wi-Fi mesh invalid mpp learning mode. */ - NSS_WIFI_MESH_ERROR_PATH_ADD_MAX_RADIO_CNT, /**< Wi-Fi mesh path add error due to maximum radio count. */ - NSS_WIFI_MESH_ERROR_PATH_ADD_INVALID_INTERFACE_NUM, /**< Wi-Fi mesh path invalid interface number. */ - NSS_WIFI_MESH_ERROR_PATH_ADD_INTERFACE_NUM_NOT_FOUND, /**< Wi-Fi mesh path interface number not found. */ - NSS_WIFI_MESH_ERROR_PATH_TABLE_FULL, /**< Wi-Fi mesh path table full error. */ - NSS_WIFI_MESH_ERROR_PATH_ALLOC_FAIL, /**< Wi-Fi mesh path alloc error. */ - NSS_WIFI_MESH_ERROR_PATH_INSERT_FAIL, /**< Wi-Fi mesh path insert fail. */ - NSS_WIFI_MESH_ERROR_PATH_NOT_FOUND, /**< Wi-Fi mesh path not found error. */ - NSS_WIFI_MESH_ERROR_PATH_UNHASHED, /**< Wi-Fi mesh proxy path unhashed error. */ - NSS_WIFI_MESH_ERROR_PATH_DELETE_FAIL, /**< Wi-Fi mesh proxy path delete error. */ - NSS_WIFI_MESH_ERROR_PROXY_PATH_NOT_FOUND, /**< Wi-Fi mesh proxy path not found error. */ - NSS_WIFI_MESH_ERROR_PROXY_PATH_UNHASHED, /**< Wi-Fi mesh proxy path unhashed error. */ - NSS_WIFI_MESH_ERROR_PROXY_PATH_DELETE_FAIL, /**< Wi-Fi mesh proxy path delete error. */ - NSS_WIFI_MESH_ERROR_PROXY_PATH_EXISTS, /**< Wi-Fi mesh proxy path exists error. */ - NSS_WIFI_MESH_ERROR_PROXY_PATH_ALLOC_FAIL, /**< Wi-Fi mesh proxy path alloc error. */ - NSS_WIFI_MESH_ERROR_PROXY_PATH_INSERT_FAIL, /**< Wi-Fi mesh proxy path insert error. */ - NSS_WIFI_MESH_ERROR_PROXY_PATH_TABLE_FULL, /**< Wi-Fi mesh proxy path table full error. */ - NSS_WIFI_MESH_ERROR_PB_ALLOC_FAIL, /**< Wi-Fi mesh pbuf allocation failures. */ - NSS_WIFI_MESH_ERROR_ENQUEUE_TO_HOST_FAIL, /**< Wi-Fi mesh enqueue to host failures. */ - NSS_WIFI_MESH_ERROR_ENABLE_INTERFACE_FAIL, /**< Wi-Fi mesh enabling interface failures. */ - NSS_WIFI_MESH_ERROR_DISABLE_INTERFACE_FAIL, /**< Wi-Fi mesh disabling interface failures. */ - NSS_WIFI_MESH_ERROR_INVALID_EXCEPTION_NUM, /**< Wi-Fi mesh invalid exception number. */ - NSS_WIFI_MESH_ERROR_ONESHOT_ALREADY_ATTACHED, /**< Wi-Fi mesh oneshot already attached error. */ -}; - -/** - * nss_wifi_mesh_mpp_learning_mode - * Mesh device proxy path learning types. - */ -enum nss_wifi_mesh_mpp_learning_mode { - NSS_WIFI_MESH_MPP_LEARNING_MODE_INDEPENDENT_NSS, /**< Independent NSS learning. */ - NSS_WIFI_MESH_MPP_LEARNING_MODE_NSS_ASSISTED_HOST, /**< NSS assisted host learning. */ - NSS_WIFI_MESH_MPP_LEARNING_MODE_MAX /**< Mesh maximum learning type. */ -}; - -/** - * nss_wifi_mesh_configurable_exceptions - * Mesh configurable exceptions. - */ -enum nss_wifi_mesh_configurable_exceptions { - NSS_WIFI_MESH_DS_MESH_PATH_NOT_FOUND = 1, /**< Downstream (Eth - Wi-Fi) mesh path not found exception. */ - NSS_WIFI_MESH_US_MESH_PROXY_NOT_FOUND = 2, /**< Upstream (Wi-Fi - Eth) mesh proxy path not found exception. */ - NSS_WIFI_MESH_US_MESH_PATH_NOT_FOUND = 3, /**< Upstream (Wi-Fi - Eth) mesh path not found exception. */ - NSS_WIFI_MESH_EXCEPTION_MAX = 4 -}; - -/* - * nss_wifi_mesh_encap_ext_data_pkt_type - * Mesh encap extended data packet type. - */ -enum nss_wifi_mesh_encap_ext_data_pkt_type { - NSS_WIFI_MESH_ENCAP_EXT_DATA_PKT_TYPE_NONE, /**< No packet type. */ - NSS_WIFI_MESH_ENCAP_EXT_DATA_PKT_TYPE_MPATH_NOT_FOUND_EXC, /**< Packet when mesh path is not found. */ - NSS_WIFI_MESH_ENCAP_EXT_DATA_PKT_TYPE_MAX, /**< Maximum packet type. */ -}; - -/** - * nss_wifi_mesh_config_msg - * Mesh device configuration. - */ -struct nss_wifi_mesh_config_msg { - uint8_t local_mac_addr[ETH_ALEN]; /**< Local MAC address. */ - uint16_t reserved; /**< Reserved field. */ - uint32_t ttl; /**< TTL for packet. */ - uint32_t mesh_path_refresh_time; /**< Mesh path refresh time. */ - uint32_t config_flags; /**< Flags indicating which fields are valid. */ - uint32_t sibling_ifnum; /**< Sibling interface number. */ - uint8_t mpp_learning_mode; /**< Mesh proxy path learning mode. */ - uint8_t block_mesh_forwarding; /**< If enabled, blocks packet forwarding. */ - uint8_t reserved_2[2]; /**< Reserved bytes. */ - uint32_t metadata_type; /**< Indicates if metadata should be enabled when block_mesh_forwarding is true. */ -}; - -/** - * nss_wifi_mesh_mpath_add_msg - * Add a mesh path message for a mesh device. - */ -struct nss_wifi_mesh_mpath_add_msg { - uint8_t dest_mac_addr[ETH_ALEN]; /**< Destination MAC address. */ - uint8_t next_hop_mac_addr[ETH_ALEN]; /**< Next hop MAC address. */ - uint32_t metric; /**< Metric for a mesh path. */ - uint32_t link_vap_id; /**< Radio ID of the mesh path. */ - uint32_t expiry_time; /**< Expiry time in order of ms. */ - uint8_t hop_count; /**< Hop count. */ - uint8_t path_flags; /**< Mesh path flags. */ - uint8_t is_mesh_gate; /**< Destination of this path is a mesh gate. */ - uint8_t block_mesh_fwd; /**< Block intra mesh forward. */ - uint32_t metadata_type; /**< Indicates if metadata should be enabled when block_mesh_forwarding is true. */ -}; - -/** - * nss_wifi_mesh_mpath_delete_msg - * Delete a mesh path message for a mesh device. - */ -struct nss_wifi_mesh_mpath_del_msg { - uint32_t link_vap_id; /**< Radio ID of the mesh path. */ - uint8_t mesh_dest_mac_addr[ETH_ALEN]; /**< Destination MAC address. */ - uint8_t next_hop_mac_addr[ETH_ALEN]; /**< Next hop MAC address. */ -}; - -/** - * nss_wifi_mesh_mpath_update_msg - * Update a mesh path message for a mesh device. - */ -struct nss_wifi_mesh_mpath_update_msg { - uint8_t dest_mac_addr[ETH_ALEN]; /**< Destination MAC address. */ - uint8_t next_hop_mac_addr[ETH_ALEN]; /**< Next hop MAC address. */ - uint8_t old_next_hop_mac_addr[ETH_ALEN];/**< Old next hop MAC address. */ - uint32_t metric; /**< Metric for a mesh path. */ - uint32_t link_vap_id; /**< Radio ID of the mesh path. */ - uint32_t expiry_time; /**< Expiration time of mesh path. */ - uint8_t hop_count; /**< Hop count. */ - uint8_t path_flags; /**< Mesh path flags. */ - uint8_t is_mesh_gate; /**< Indicates if the mesh path is a mesh gate. */ - uint8_t update_flags; /**< Update flags. */ - uint8_t block_mesh_fwd; /**< Block intra mesh forward. */ - uint8_t reserved[3]; /**< Reserved bytes. */ - uint8_t metadata_type; /**< Indicates if metadata should be enabled when block_mesh_forwarding is true. */ -}; - -/** - * nss_wifi_mesh_proxy_path_learn_msg - * Learn a mesh proxy path message for a mesh device. - */ -struct nss_wifi_mesh_proxy_path_learn_msg { - uint8_t mesh_dest_mac[ETH_ALEN]; /**< Mesh destination MAC address. */ - uint8_t dest_mac_addr[ETH_ALEN]; /**< Destination MAC address. */ - uint8_t path_flags; /**< Mesh path flags. */ - uint8_t is_update; /**< Indicates if the learn is an update. */ -}; - -/** - * nss_wifi_mesh_proxy_path_add_msg - * Add a mesh proxy path message for a mesh device. - */ -struct nss_wifi_mesh_proxy_path_add_msg { - uint8_t mesh_dest_mac[ETH_ALEN]; /**< Mesh destination MAC address. */ - uint8_t dest_mac_addr[ETH_ALEN]; /**< Destination MAC address. */ - uint8_t path_flags; /**< Mesh path flags. */ -}; - -/** - * nss_wifi_mesh_proxy_path_update_msg - * Update a mesh proxy path message for a mesh device. - */ -struct nss_wifi_mesh_proxy_path_update_msg { - uint8_t mesh_dest_mac[ETH_ALEN]; /**< Mesh destination MAC address. */ - uint8_t dest_mac_addr[ETH_ALEN]; /**< Destination MAC address. */ - uint8_t path_flags; /**< Mesh path flags. */ - uint8_t bitmap; /**< Bitmap indicating valid fields in the update msg. */ -}; - -/** - * nss_wifi_mesh_proxy_path_del_msg - * Delete a mesh proxy path message for a mesh device. - */ -struct nss_wifi_mesh_proxy_path_del_msg { - uint8_t mesh_dest_mac_addr[ETH_ALEN]; /**< Mesh destination MAC. */ - uint8_t dest_mac_addr[ETH_ALEN]; /**< Destination MAC address. */ -}; - -/** - * nss_wifi_mesh_mpath_not_found_msg - * Wi-Fi mesh path not found meesage. - */ -struct nss_wifi_mesh_mpath_not_found_msg { - uint8_t dest_mac_addr[ETH_ALEN]; /**< Destination MAC address. */ - uint8_t transmitter_mac_addr[ETH_ALEN]; /**< Transmitter address. */ - uint32_t link_vap_id; /**< NSS interface number of the link vap if received from WiFi. */ - uint8_t is_mesh_forward_path; /**< Indicates if the message is from a forward path. */ -}; - -/** - * nss_wifi_mesh_path_refresh_msg - * Refresh mesh path message. - */ -struct nss_wifi_mesh_path_refresh_msg { - uint8_t dest_mac_addr[ETH_ALEN]; /**< Destination MAC address. */ - uint8_t next_hop_mac_addr[ETH_ALEN]; /**< Next hop MAC address. */ - uint32_t link_vap_id; /**< Link VAP of the mesh path. */ - uint8_t path_flags; /**< Mesh path flags. */ -}; - -/** - * nss_wifi_mesh_path_expiry_msg - * Mesh path expiration message. - */ -struct nss_wifi_mesh_path_expiry_msg { - uint8_t mesh_dest_mac_addr[ETH_ALEN]; /**< Destination MAC address. */ - uint8_t next_hop_mac_addr[ETH_ALEN]; /**< Next hop MAC address. */ - uint32_t link_vap_id; /**< Link VAP of the mesh path. */ - uint8_t path_flags; /**< Mesh path flags. */ -}; - -/* - * nss_wifi_mesh_encap_stats - * Encapsulation statistics. - */ -struct nss_wifi_mesh_encap_stats { - uint32_t expiry_notify_sent; /* Number of times expiry notification sent to host. */ - uint32_t mc_count; /* Number of multicast packets. */ - uint32_t mp_not_found; /* Number of times mesh path is not found. */ - uint32_t mp_active; /* Number of times mesh path is active. */ - uint32_t mpp_not_found; /* Number of times proxy path is not found. */ - uint32_t mpp_found; /* Number of times proxy path is found. */ - uint32_t encap_hdr_fail; /* Number of times encapsulating mesh header failed. */ - uint32_t mp_del_notify_fail; /* Number of times notifying mesh path delete failed. */ - uint32_t link_enqueue; /* Number of packets enqueued to the link VAP. */ - uint32_t link_enq_fail; /* Number of times enqueue to link vap failed. */ - uint32_t ra_lup_fail; /* Number of times receiver address look up is failed. */ - uint32_t dummy_add_count; /* Number of times dummy path is added. */ - uint32_t encap_mp_add_notify_fail; /* Number of times add notification failed. */ - uint32_t dummy_add_fail; /* Number of times dummy addition failed. */ - uint32_t dummy_lup_fail; /* Number of times dummy lookup failed. */ - uint32_t send_to_host_failed; /* Number of packets failed to be sent to host. */ - uint32_t sent_to_host; /* Number of packets sent to host. */ - uint32_t expiry_notify_fail; /* Number of times expiry notification to host failed. */ - uint32_t no_headroom; /* Number of packets dropped because there is no headroom. */ - uint32_t path_refresh_sent; /* Number of times path refresh is sent to host. */ - uint32_t linearise_failed; /* Number of packets dropped because pb_linearise. */ -}; - -/* - * nss_wifi_mesh_decap_stats - * Mesh decapsulation statistics. - */ -struct nss_wifi_mesh_decap_stats { - uint32_t path_refresh_sent; /**< Number of times path refresh is sent to host. */ - uint32_t reserved; /**< Reserved field. */ - uint32_t mc_drop; /**< Number of MC drop counts. */ - uint32_t ttl_0; /**< Number of TTL0 counts. */ - uint32_t mpp_lup_fail; /**< Number of mpp lookup failures. */ - uint32_t decap_hdr_fail; /**< Number of decap HDR failures. */ - uint32_t rx_fwd_fail; /**< Number of receive forward failures. */ - uint32_t rx_fwd_success; /**< Number of receive forward success counts. */ - uint32_t mp_fwd_lookup_fail; /**< Number of mpath forward lookup failures. */ - uint32_t mp_fwd_inactive; /**< Number of mpath forward inactive. */ - uint32_t nxt_mnode_fwd_success; /**< Number of next mnode forward successes. */ - uint32_t nxt_mnode_fwd_fail; /**< Number of next mnode forward failures. */ - uint32_t mpp_add_fail; /**< Number of MPP add failures. */ - uint32_t mpp_add_event2host_fail; /**< Number of MPP add event-to-host failures. */ - uint32_t mpp_upate_fail; /**< Number of MPP update failures. */ - uint32_t mpp_update_even2host_fail; /**< Number of MPP update event-to-host failure counts. */ - uint32_t mpp_learn2host_fail; /**< Number of MPP learn-to-host failure counts. */ - uint32_t block_mesh_fwd_packets; /**< Number of packets that are blocked for intra mesh forward. */ - uint32_t no_headroon; /**< Number of packets dropped due to insufficient headroom.. */ - uint32_t linearise_failed; /**< Number of packets dropped due to linear copy failure. */ - uint32_t mpp_learn_events_rate_limited; /**< Number of mesh proxy path learn events dropped due to rate limiting */ - uint32_t mp_missing_events_rate_limited;/**< Number of path missing notifications dropped due to rate limiting */ -}; - -/** - * nss_wifi_mesh_path_dump_entry - * Wi-Fi mesh path dump entry. - */ -struct nss_wifi_mesh_path_dump_entry { - uint8_t dest_mac_addr[ETH_ALEN]; /**< Destination MAC address. */ - uint8_t next_hop_mac_addr[ETH_ALEN]; /**< Next hop MAC address. */ - uint32_t metric; /**< Mesh path metric. */ - uint32_t expiry_time[2]; /**< Mesh path expiration time. */ - uint8_t hop_count; /**< Number of hop counts. */ - uint8_t flags; /**< Mesh path flags. */ - uint8_t is_mesh_gate; /**< Determines whether gateway capability is enabled. */ - uint8_t reserved[1]; /**< Reserved field. */ - uint32_t link_vap_id; /**< Link interface number. */ -}; - -/** - * nss_wifi_mesh_proxy_path_dump_entry - * Wi-Fi mesh proxy path dump entry. - */ -struct nss_wifi_mesh_proxy_path_dump_entry { - uint8_t dest_mac_addr[ETH_ALEN]; /**< Destination MAC address. */ - uint8_t mesh_dest_mac[ETH_ALEN]; /**< Mesh destination address. */ - uint8_t flags; /**< Mesh path flags. */ - uint8_t reserved[3]; /**< Reserved field. */ - uint32_t time_diff; /**< Difference of current time and active time. */ -}; - -/** - * nss_wifi_mesh_path_table_dump - * Wi-Fi mesh path table dump. - */ -struct nss_wifi_mesh_path_table_dump { - uint32_t num_entries; /**< Number of entries. */ - uint32_t more_events; /**< Determines whether more events are pending. */ - struct nss_wifi_mesh_path_dump_entry path_entry[0]; /**< Mesh path entries. */ -}; - -/** - * nss_wifi_mesh_proxy_path_table_dump - * Wi-Fi mesh proxy path table dump. - */ -struct nss_wifi_mesh_proxy_path_table_dump { - uint32_t num_entries; /**< Number of entries. */ - uint32_t more_events; /**< More events are pending. */ - struct nss_wifi_mesh_proxy_path_dump_entry path_entry[0]; /**< Mesh proxy path entry. */ -}; - -/** - * nss_wifi_mesh_assoc_link_vap - * Associate a link VAP to mesh. - */ -struct nss_wifi_mesh_assoc_link_vap { - uint32_t link_vap_id; /**< Link interface number. */ -}; - -/** - * nss_wifi_mesh_path_stats - * Wi-Fi mesh path statistics. - */ -struct nss_wifi_mesh_path_stats { - uint32_t alloc_failures; /**< Mesh path allocation failures. */ - uint32_t error_max_radio_count; /**< Mesh path error maximum radio count. */ - uint32_t invalid_interface_failures; /**< Mesh path invalid interface number failures count. */ - uint32_t add_success; /**< Mesh path add success count. */ - uint32_t table_full_errors; /**< Mesh path table full error count. */ - uint32_t insert_failures; /**< Mesh path insert failure count. */ - uint32_t not_found; /**< Mesh path not found failure count. */ - uint32_t delete_success; /**< Mesh path delete success count. */ - uint32_t update_success; /**< Mesh path update success count. */ - uint32_t mesh_path_expired; /**< Mesh path expired. */ - uint32_t mesh_path_refresh_needed; /**< Mesh path refresh needed. */ - uint32_t add_requests; /**< Mesh path add request. */ - uint32_t del_requests; /**< Mesh path delete request. */ - uint32_t update_requests; /**< Mesh path update requests. */ - uint32_t next_hop_updations; /**< Mesh path next hop updations. */ - uint32_t hop_count_updations; /**< Mesh path hop count updations. */ - uint32_t flag_updations; /**< Mesh path mesh flag updations. */ - uint32_t metric_updations; /**< Mesh path metric updations. */ - uint32_t block_mesh_fwd_updations; /**< Mesh path block mesh forward updations. */ - uint32_t delete_failures; /**< Mesh path delete failures. */ -}; - -/** - * nss_wifi_mesh_proxy_path_stats - * Wi-Fi mesh proxy path statistics. - */ -struct nss_wifi_mesh_proxy_path_stats { - uint32_t alloc_failures; /**< Mesh proxy path alloc failure count. */ - uint32_t entry_exist_failures; /**< Mesh proxy path entry already exists. */ - uint32_t add_success; /**< Mesh proxy path add success count. */ - uint32_t table_full_errors; /**< Mesh proxy path table full count. */ - uint32_t insert_failures; /**< Mesh proxy path insert failure count. */ - uint32_t not_found; /**< Mesh proxy path not found count. */ - uint32_t unhashed_errors; /**< Mesh proxy path unhased erorr count. */ - uint32_t delete_failures; /**< Mesh proxy path delete failure count. */ - uint32_t delete_success; /**< Mesh proxy path delete success count. */ - uint32_t update_success; /**< Mesh proxy path update success count. */ - uint32_t lookup_success; /**< Mesh proxy path lookup success count. */ - uint32_t add_requests; /**< Mesh proxy path addition requests. */ - uint32_t del_requests; /**< Mesh proxy path deletion requests. */ - uint32_t update_requests; /**< Mesh proxy path updation requests. */ - uint32_t mda_updations; /**< Mesh proxy path mda updations. */ - uint32_t flag_updations; /**< Mesh proxy path flags updations. */ -}; - -/** - * nss_wifi_mesh_exception_stats - * Wi-Fi mesh exception statistics. - */ -struct nss_wifi_mesh_exception_stats { - uint32_t packets_success; /**< Mesh exception successful packets count. */ - uint32_t packets_dropped; /**< Mesh exception dropped packets count. */ -}; - -/** - * nss_wifi_mesh_stats_sync_msg - * Message to get mesh device statistics from NSS firmware to the host. - */ -struct nss_wifi_mesh_stats_sync_msg { - struct nss_cmn_node_stats pnode_stats; /**< Common firmware statistics. */ - struct nss_wifi_mesh_encap_stats mesh_encap_stats; /**< Encapsulation statistics. */ - struct nss_wifi_mesh_decap_stats mesh_decap_stats; /**< Decapsulation statistics. */ - struct nss_wifi_mesh_path_stats mesh_path_stats; /**< Mesh path statistics. */ - struct nss_wifi_mesh_proxy_path_stats mesh_proxy_path_stats; /**< Mesh proxy path statistics. */ - struct nss_wifi_mesh_exception_stats mesh_except_stats; /**< Mesh exception statistics. */ -}; - -/* nss_wifi_mesh_exception_flag_msg - * Messsage to send exception packets to host. - */ -struct nss_wifi_mesh_exception_flag_msg { - uint8_t dest_mac_addr[ETH_ALEN]; /**< Destination MAC address. */ - uint8_t exception; /**< Exception flag bit. */ - uint8_t reserved[2]; /**< Reserved field. */ -}; - -/** - * nss_wifi_mesh_rate_limit_config - * Message to configure exceptions - */ -struct nss_wifi_mesh_rate_limit_config { - uint32_t exception_num; /**< Indicates the exception - enum wifi_mesh_configurable_exceptions. */ - uint32_t enable; /**< Indicates if exception is enabled. */ - uint32_t rate_limit; /**< Rate limit value in us. */ -}; - -/** - * nss_wifi_mesh_encap_ext_pkt_metadata - * Metadata to extended data callback - */ -struct nss_wifi_mesh_encap_ext_pkt_metadata { - uint16_t pkt_type; /**< Packet type of the exception packet. */ -}; - -/** - * nss_wifi_mesh_msg - * Data sent and received in mesh device-specific messages. - */ -struct nss_wifi_mesh_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a virtual device specific message. - */ - union { - union nss_if_msgs if_msg; - /**< NSS interface base message. */ - struct nss_wifi_mesh_config_msg mesh_config; - /**< Mesh device configuration. */ - struct nss_wifi_mesh_mpath_add_msg mpath_add; - /**< Add a message for a mesh path addition. */ - struct nss_wifi_mesh_mpath_del_msg mpath_del; - /**< Add a message for a mesh path deletion. */ - struct nss_wifi_mesh_mpath_update_msg mpath_update; - /**< Add a message for a mesh path update. */ - struct nss_wifi_mesh_proxy_path_learn_msg proxy_learn_msg; - /**< Add a message for a mesh proxy path learning. */ - struct nss_wifi_mesh_proxy_path_add_msg proxy_add_msg; - /**< Add a message for a mesh proxy path addition. */ - struct nss_wifi_mesh_proxy_path_update_msg proxy_update_msg; - /**< Add a message for a mesh proxy path update. */ - struct nss_wifi_mesh_proxy_path_del_msg proxy_del_msg; - /**< Add a message for a mesh proxy path deletion. */ - struct nss_wifi_mesh_mpath_not_found_msg mpath_not_found_msg; - /**< Mesh path not found message. */ - struct nss_wifi_mesh_path_refresh_msg path_refresh_msg; - /**< Add a message for a mesh path refresh. */ - struct nss_wifi_mesh_path_expiry_msg path_expiry_msg; - /**< Add a message for a mesh path expiration. */ - struct nss_wifi_mesh_path_table_dump mpath_table_dump; - /**< Add a message to dump mesh path table. */ - struct nss_wifi_mesh_proxy_path_table_dump proxy_path_table_dump; - /**< Add a message to dump mesh proxy path table. */ - struct nss_wifi_mesh_stats_sync_msg stats_sync_msg; - /**< Statistics synchronization message. */ - struct nss_wifi_mesh_exception_flag_msg exception_msg; - /**< Exception to host message. */ - struct nss_wifi_mesh_rate_limit_config exc_cfg; - /**< Add a message to configure the rate limit for exception events. */ - } msg; /**< Virtual device message payload. */ -}; - -/** - * nss_wifi_mesh_encap_stats_type - * Wi-Fi mesh encapsulation statistics types. - */ -enum nss_wifi_mesh_encap_stats_type { - NSS_WIFI_MESH_ENCAP_STATS_TYPE_PNODE_RX_PACKETS, /**< Wi-Fi mesh common node receive packets. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_PNODE_RX_BYTES, /**< Wi-Fi mesh common node receive bytes. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_PNODE_TX_PACKETS, /**< Wi-Fi mesh common node transmit packets. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_PNODE_TX_BYTES, /**< Wi-Fi mesh common node transmit bytes. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_PNODE_RX_DROPPED, /**< Wi-Fi mesh common node receive dropped. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_EXPIRY_NOTIFY_SENT, /**< Wi-Fi mesh encapsulation statistics expiry notify sent. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_MC_COUNT, /**< Wi-Fi mesh encapsulation statistics mc count. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_MP_NOT_FOUND, /**< Wi-Fi mesh encapsulation statistics mpath not found. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_MP_ACTIVE, /**< Wi-Fi mesh encapsulation statistics mpath active */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_MPP_NOT_FOUND, /**< Wi-Fi mesh encapsulation statistics mpp not found. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_MPP_FOUND, /**< Wi-Fi mesh encapsulation statistics mpp found. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_HDR_FAIL, /**< Wi-Fi mesh encapsulation statistics header failed. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_MP_DEL_NOTIFY_FAIL, /**< Wi-Fi mesh encapsulation statistics mpath delete notify. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_LINK_ENQUEUE, /**< Wi-Fi mesh encapsulation statistics link enqueue. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_LINK_ENQUEUE_FAIL, /**< Wi-Fi mesh encapsulation statistics link enqueue failed. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_RA_LOOKUP_FAIL, /**< Wi-Fi mesh encapsulation statistics receiver lookup failed. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_DUMMY_ADD_COUNT, /**< Wi-Fi mesh encapsulation statistics dummy add count. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_MP_ADD_NOTIFY_FAIL, /**< Wi-Fi mesh encapsulation statistics mpath add notify failed. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_DUMMY_ADD_FAIL, /**< Wi-Fi mesh encapsulation statistics dummy add failed. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_DUMMY_LOOKUP_FAIL, /**< Wi-Fi mesh encapsulation statistics dummy look-up failed. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_SEND_TO_HOST_FAILED, /**< Wi-Fi mesh encapsulation statistics when a packet fails to send to host. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_SENT_TO_HOST, /**< Wi-Fi mesh encapsulation statistics when packet is sent to host. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_EXPIRY_NOTIFY_FAIL, /**< Wi-Fi mesh encapsulation statistics expiry notified fail. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_NO_HEADROOM, /**< Wi-Fi mesh encapsulation statistics no headroom. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_PATH_REFRESH_SENT, /**< Wi-Fi mesh encapsulation statistics path refresh sent. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_LINEARISE_FAILED, /**< Wi-Fi mesh encapsulation statistics when linearisation failed. */ - NSS_WIFI_MESH_ENCAP_STATS_TYPE_MAX /**< Wi-Fi mesh encapsulation statistics maximum. */ -}; - -/** - * nss_wifi_mesh_decap_stats_type - * Wi-Fi mesh decapsulation statistics types. - */ -enum nss_wifi_mesh_decap_stats_type { - NSS_WIFI_MESH_DECAP_STATS_TYPE_PNODE_RX_PACKETS, /**< Wi-Fi mesh common node receive packets. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_PNODE_RX_BYTES, /**< Wi-Fi mesh common node receive bytes. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_PNODE_TX_PACKETS, /**< Wi-Fi mesh common node transmit packets. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_PNODE_TX_BYTES, /**< Wi-Fi mesh common node transmit bytes. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_PNODE_RX_DROPPED, /**< Wi-Fi mesh common node receive dropped. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_PATH_REFRESH_SENT, /**< Wi-Fi mesh decapsulation statistics path refresh sent. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_RESERVED, /**< Wi-Fi mesh decapsulation statistics reserved field. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MC_DROP, /**< Wi-Fi mesh decapsulation statistics MAC dropped count. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_TTL0, /**< Wi-Fi mesh decapsulation statistics ttl0. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MPP_LOOKUP_FAIL, /**< Wi-Fi mesh decapsulation statistics mpp lookup failed. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_HDR_FAIL, /**< Wi-Fi mesh decapsulation statistics header failed. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_RX_FWD_FAIL, /**< Wi-Fi mesh decapsulation statistics receive forward failed. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_RX_FWD_SUCCESS, /**< Wi-Fi mesh decapsulation statistics receive forward successful. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MP_FWD_LOOKUP_FAIL, /**< Wi-Fi mesh decapsulation statistics mpath forward lookup failed. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MP_FWD_INACTIVE, /**< Wi-Fi mesh decapsulation statistics mpath forward inactive. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MNODE_FWD_SUCCESS, /**< Wi-Fi mesh decapsulation statistics mnode forward successful. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MNODE_FWD_FAIL, /**< Wi-Fi mesh decapsulation statistics mnode forward failed. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MPP_ADD_FAIL, /**< Wi-Fi mesh decapsulation statistics mpp add failed. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MPP_ADD_EVENT_TO_HOST_FAIL, /**< Wi-Fi mesh decapsulation statistics mpp add event to host failed. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MPP_UPDATE_FAIL, /**< Wi-Fi mesh decapsulation statistics mpp update failed. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MPP_UPDATE_EVENT_TO_HOST_FAIL, /**< Wi-Fi mesh decapsulation statistics mpp update event to host failed. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MPP_LEARN_TO_HOST_FAIL, /**< Wi-Fi mesh decapsulation statistics mpp learn to host failed. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_BLOCK_MESH_FWD_PACKETS, /**< Wi-Fi mesh decapsulation statistics block mesh fwd packets. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_NO_HEADROOM, /**< Wi-Fi mesh decapsulation statistics no headroom. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_LINEARISE_FAILED, /**< Wi-Fi mesh decapsulation statistics linearise failed. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MPP_LEARN_EVENT_RL_DROPPED, /**< Wi-Fi mesh decapsulation statistics mpp learn event rl dropped. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MP_MISSING_EVENT_RL_DROPPED, /**< Wi-Fi mesh decapsulation statistics mp missing event rl dropped. */ - NSS_WIFI_MESH_DECAP_STATS_TYPE_MAX /**< Wi-Fi mesh decapsulation statistics maximum. */ -}; - -/** - * nss_wifi_mesh_path_stats_type - * Wi-Fi mesh path statistics types. - */ -enum nss_wifi_mesh_path_stats_type { - NSS_WIFI_MESH_PATH_STATS_TYPE_ALLOC_FAILURES, /**< Wi-Fi mesh path statistics allocation failures. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_ERROR_MAX_RADIO_COUNT, /**< Wi-Fi mesh path statistics maximum radio error count. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_INVALID_INTERFACE_FAILURES, /**< Wi-Fi mesh path statistics invalid interface failures. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_ADD_SUCCESS, /**< Wi-Fi mesh path statistics add success. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_TABLE_FULL_ERRORS, /**< Wi-Fi mesh path statistics table full errors. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_INSERT_FAILURES, /**< Wi-Fi mesh path statistics insertion failures. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_NOT_FOUND, /**< Wi-Fi mesh path statistics not found. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_DELETE_SUCCESS, /**< Wi-Fi mesh path statistics successful deletion. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_UPDATE_SUCCESS, /**< Wi-Fi mesh path statistics successful updation. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_EXPIRED, /**< Wi-Fi mesh path statistics expired. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_REFRESH_NEEDED, /**< Wi-Fi mesh path statistics refresh needed. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_ADD_REQUESTS, /**< Wi-Fi mesh path statistics add requests. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_DELETE_REQUESTS, /**< Wi-Fi mesh path statistics delete requests. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_UPDATE_REQUESTS, /**< Wi-Fi mesh path statistics update requests. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_NEXT_HOP_UPDATIONS, /**< Wi-Fi mesh path statistics next hop updations. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_HOP_COUNT_UPDATIONS, /**< Wi-Fi mesh path statistics hop count updations. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_MESH_FLAG_UPDATIONS, /**< Wi-Fi mesh path statistics mesh flag updations. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_METRIC_UPDATIONS, /**< Wi-Fi mesh path statistics metric updations. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_BLOCK_MESH_FWD_UPDATIONS, /**< Wi-Fi mesh path statistics block mesh forward updations. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_MESH_PATH_DELETE_FAILURES, /**< Wi-Fi mesh path statistics mesh path delete failures. */ - NSS_WIFI_MESH_PATH_STATS_TYPE_MAX /**< Wi-Fi mesh path statistics maximum. */ -}; - -/** - * nss_wifi_mesh_proxy_path_stats_type - * Wi-Fi mesh proxy path statistics types. - */ -enum nss_wifi_mesh_proxy_path_stats_type { - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_ALLOC_FAILURES, /**< Wi-Fi mesh proxy path statistics allocation failures. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_ENTRY_EXIST_FAILURES, /**< Wi-Fi mesh proxy path statistics entry exist failures. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_ADD_SUCCESS, /**< Wi-Fi mesh proxy path statistics add success. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_TABLE_FULL_ERRORS, /**< Wi-Fi mesh proxy path statistics table full errors. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_INSERT_FAILURES, /**< Wi-Fi mesh proxy path statistics insert failures. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_NOT_FOUND, /**< Wi-Fi mesh proxy path statistics not found. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_UNHASHED_ERRORS, /**< Wi-Fi mesh proxy path statistics unhashed errors. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_DELTE_FAILURES, /**< Wi-Fi mesh proxy path statistics delete failures */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_DELETE_SUCCESS, /**< Wi-Fi mesh proxy path statistics delete success. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_UPDATE_SUCCESS, /**< Wi-Fi mesh proxy path statistics update_success. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_LOOKUP_SUCCESS, /**< Wi-Fi mesh proxy path statistics lookup sccesss. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_ADD_REQUESTS, /**< Wi-Fi mesh proxy path statistics add requests. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_DELETE_REQUESTS, /**< Wi-Fi mesh proxy path statistics delete requests. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_UPDATE_REQUESTS, /**< Wi-Fi mesh proxy path statistics update request. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_MDA_UPDATIONS, /**< Wi-Fi mesh proxy path statistics mda updations. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_FLAGS_UPDATIONS, /**< Wi-Fi mesh proxy path statistics flags updations. */ - NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_MAX /**< Wi-Fi mesh proxy path statistics maximum. */ -}; - -/** - * nss_wifi_mesh_exception_stats_type - * Wi-Fi mesh exception statistics types. - */ -enum nss_wifi_mesh_exception_stats_type { - NSS_WIFI_MESH_EXCEPTION_STATS_TYPE_PACKETS_SUCCESS, /**< Wi-Fi mesh exception statistics packets success. */ - NSS_WIFI_MESH_EXCEPTION_STATS_TYPE_PACKETS_DROPPED, /**< Wi-Fi mesh exception statistics packets dropped. */ - NSS_WIFI_MESH_EXCEPTION_STATS_TYPE_MAX /**< Wi-Fi mesh exception statistics maximum. */ -}; - -/** - * nss_wifi_mesh_hdl_stats_sync_msg - * Message to get mesh device statistics from NSS firmware to the host. - */ -struct nss_wifi_mesh_hdl_stats_sync_msg { - uint64_t encap_stats[NSS_WIFI_MESH_ENCAP_STATS_TYPE_MAX]; /**< Encap statistics. */ - uint64_t decap_stats[NSS_WIFI_MESH_DECAP_STATS_TYPE_MAX]; /**< Decap statistics. */ - uint64_t path_stats[NSS_WIFI_MESH_PATH_STATS_TYPE_MAX]; /**< Path statistics. */ - uint64_t proxy_path_stats[NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_MAX]; /**< Proxy path statistics. */ - uint64_t except_stats[NSS_WIFI_MESH_EXCEPTION_STATS_TYPE_MAX]; /**< Exception statistics. */ -}; - -/** - * nss_wifi_mesh_stats_notification - * Wi-Fi mesh statistics structure. - */ -struct nss_wifi_mesh_stats_notification { - uint32_t core_id; /**< Core ID. */ - nss_if_num_t if_num; /**< Interface number. */ - struct nss_wifi_mesh_hdl_stats_sync_msg stats; /**< Encapsulation-decapsulation statistics. */ -}; - -/** - * nss_wifi_mesh_tx_msg - * Sends a Wi-Fi mesh message to the NSS interface. - * - * @datatypes - * nss_ctx_instance \n - * nss_wifi_mesh_msg - * - * @param[in] nss_ctx Pointer to the NSS core context. - * @param[in] msg Pointer to the message data. - * - * @return - * Status of the transmit operation. - */ -nss_tx_status_t nss_wifi_mesh_tx_msg(struct nss_ctx_instance *nss_ctx, - struct nss_wifi_mesh_msg *msg); - -/** - * nss_wifi_mesh_tx_buf - * Sends a Wi-Fi mesh data packet to the NSS interface. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS core context. - * @param[in] os_buf Pointer to the OS data buffer. - * @param[in] if_num NSS interface number. - * - * @return - * Status of the transmit operation. - */ -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); - -/** - * Callback function for receiving Wi-Fi virtual device 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_mesh_msg_callback_t)(void *app_data, - struct nss_cmn_msg *msg); - -/** - * Callback function for receiving Wi-Fi virtual device 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_mesh_data_callback_t)(struct net_device *netdev, - struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback function for receiving extended data plane Wi-Fi virtual device 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. - * @param[in] netdev Pointer to the associated network device. - */ -typedef void (*nss_wifi_mesh_ext_data_callback_t)(struct net_device *netdev, - struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_wifi_mesh_msg_init - * Initializes a Wi-Fi mesh device message. - * - * @datatypes - * nss_wifi_mesh_msg \n - * nss_wifi_mesh_msg_callback_t - * - * @param[in] nim Pointer to the NSS interface message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Length of message. - * @param[in] cb Message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -void nss_wifi_mesh_msg_init(struct nss_wifi_mesh_msg *nim, nss_if_num_t if_num, uint32_t type, uint32_t len, - nss_wifi_mesh_msg_callback_t cb, void *app_data); - -/** - * nss_wifi_mesh_get_context - * Gets the NSS Wi-Fi extended virtual interface context. - * - * @return - * Pointer to the NSS core context. - */ -extern struct nss_ctx_instance *nss_wifi_mesh_get_context(void); - -/** - * nss_register_wifi_mesh_if - * Registers a Wi-Fi mesh device interface with the NSS interface. - * - * @datatypes - * nss_if_num_t \n - * nss_wifi_mesh_data_callback_t \n - * nss_wifi_mesh_ext_data_callback_t \n - * nss_wifi_mesh_msg_callback_t \n - * net_device - * @param[in] if_num NSS interface number. - * @param[in] mesh_data_callback Callback for the Wi-Fi virtual device data. - * @param[in] mesh_ext_data_callback Callback for the extended data. - * @param[in] mesh_event_callback Callback for the message. - * @param[in] dp_type Datapath type. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this - * interface. - * - * @return - * NSS_CORE_STATUS_SUCCESS in case of success. - * NSS_CORE_STATUS_FAILURE in case of failure. - */ -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); - -/** - * nss_unregister_wifi_mesh_if - * Deregisters a Wi-Fi mesh device interface from the NSS interface. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - */ -void nss_unregister_wifi_mesh_if(nss_if_num_t if_num); - -/** - * nss_wifi_mesh_tx_msg_ext - * Sends Wi-Fi mesh data packet along with metadata as a message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in,out] nss_ctx Pointer to the NSS core context. - * @param[in] os_buf Pointer to the OS data buffer. - * - * @return - * Status of the transmit operation. - */ -nss_tx_status_t nss_wifi_mesh_tx_msg_ext(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf); - -/** - * nss_wifi_mesh_verify_if_num - * Verify Wi-Fi mesh interface number. - * - * @datatypes - * interface number \n - * - * @param[in] nss_if_num_t NSS interface number. - * - * @return - * TRUE or FALSE. - */ -extern bool nss_wifi_mesh_verify_if_num(nss_if_num_t if_num); - -/** - * nss_wifi_mesh_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_wifi_mesh_stats_register_notifier(struct notifier_block *nb); - -/** - * nss_wifi_mesh_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_wifi_mesh_stats_unregister_notifier(struct notifier_block *nb); -#endif /* __NSS_WIFI_MESH_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi_vdev.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi_vdev.h deleted file mode 100644 index 1b52f66d0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifi_vdev.h +++ /dev/null @@ -1,1358 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_vdev.h - * NSS-to-HLOS Wi-Fi virtual device interface definitions. - */ - -#ifndef __NSS_WIFI_VDEV_H -#define __NSS_WIFI_VDEV_H - -/** - * @addtogroup nss_wifi_vdev_subsystem - * @{ - */ -#define NSS_WIFI_HTT_TRANSFER_HDRSIZE_WORD 6 /**< Size of the Host-To-Target (HTT) message transfer header. */ -#define NSS_WIFI_VDEV_PER_PACKET_METADATA_OFFSET 4 -/**< 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_MAX_SRCS 4 /**< Maximum number of multicast sources. */ -#define NSS_WIFI_VDEV_MAX_ME_ENTRIES 32 /**< Maximum number of multicast enhancement entries. */ - -/** - * nss_wifi_vdev_msg_types - * Wi-Fi virtual device messages. - */ -enum nss_wifi_vdev_msg_types { - NSS_WIFI_VDEV_INTERFACE_CONFIGURE_MSG = NSS_IF_MAX_MSG_TYPES + 1, - NSS_WIFI_VDEV_INTERFACE_UP_MSG, - NSS_WIFI_VDEV_INTERFACE_DOWN_MSG, - NSS_WIFI_VDEV_INTERFACE_CMD_MSG, - NSS_WIFI_VDEV_SNOOPLIST_GRP_LIST_CREATE_MSG, - NSS_WIFI_VDEV_SNOOPLIST_GRP_LIST_DELETE_MSG, - NSS_WIFI_VDEV_SNOOPLIST_GRP_MEMBER_ADD_MSG, - NSS_WIFI_VDEV_SNOOPLIST_GRP_MEMBER_REMOVE_MSG, - NSS_WIFI_VDEV_SNOOPLIST_GRP_MEMBER_UPDATE_MSG, - NSS_WIFI_VDEV_SNOOPLIST_DENY_MEMBER_ADD_MSG, - NSS_WIFI_VDEV_SNOOPLIST_DENY_LIST_DELETE_MSG, - NSS_WIFI_VDEV_SNOOPLIST_DENY_LIST_DUMP_MSG, - NSS_WIFI_VDEV_SNOOPLIST_DUMP_MSG, - NSS_WIFI_VDEV_SNOOPLIST_RESET_MSG, - NSS_WIFI_VDEV_SPECIAL_DATA_TX_MSG, - NSS_WIFI_VDEV_VOW_DBG_CFG_MSG, - NSS_WIFI_VDEV_VOW_DBG_STATS_REQ_MSG, - NSS_WIFI_VDEV_DSCP_TID_MAP_MSG, - NSS_WIFI_VDEV_SNOOPLIST_TOGGLE_MSG, - NSS_WIFI_VDEV_UPDATECHDR_MSG, - NSS_WIFI_VDEV_ME_SYNC_MSG, - NSS_WIFI_VDEV_STATS_MSG, - NSS_WIFI_VDEV_SET_NEXT_HOP, - NSS_WIFI_VDEV_DSCP_TID_MAP_ID_MSG, - NSS_WIFI_VDEV_EXTAP_ADD_ENTRY, - NSS_WIFI_VDEV_EXTAP_REMOVE_ENTRY, - NSS_WIFI_VDEV_QWRAP_PSTA_DELETE_ENTRY, - NSS_WIFI_VDEV_QWRAP_PSTA_ADD_ENTRY, - NSS_WIFI_VDEV_QWRAP_ISOLATION_ENABLE, - NSS_WIFI_VDEV_SET_PEER_NEXT_HOP, - NSS_WIFI_VDEV_CONFIG_VLAN_ID_MSG, - NSS_WIFI_VDEV_CONFIG_VLAN_MODE_MSG, - 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 -}; - -/** - * nss_wifi_vdev_err_types - * Error types for a Wi-Fi virtual device. - */ -enum nss_wifi_vdev_err_types { - NSS_WIFI_VDEV_ENONE, - NSS_WIFI_VDEV_EUNKNOWN_MSG, - NSS_WIFI_VDEV_EINV_VID_CONFIG, - NSS_WIFI_VDEV_EINV_EPID_CONFIG, - NSS_WIFI_VDEV_EINV_DL_CONFIG, - NSS_WIFI_VDEV_EINV_CMD, - NSS_WIFI_VDEV_EINV_ENCAP, - NSS_WIFI_VDEV_EINV_DECAP, - NSS_WIFI_VDEV_EINV_RX_NXTN, - NSS_WIFI_VDEV_EINV_VID_INDEX, - NSS_WIFI_VDEV_EINV_MC_CFG, - NSS_WIFI_VDEV_SNOOPTABLE_FULL, - NSS_WIFI_VDEV_SNOOPTABLE_ENOMEM, - NSS_WIFI_VDEV_SNOOPTABLE_GRP_LIST_UNAVAILABLE, - NSS_WIFI_VDEV_SNOOPTABLE_GRP_MEMBER_UNAVAILABLE, - NSS_WIFI_VDEV_SNOOPTABLE_PEER_UNAVAILABLE, - NSS_WIFI_VDEV_SNOOPTABLE_GRP_LIST_ENOMEM, - NSS_WIFI_VDEV_SNOOPTABLE_GRP_LIST_EXIST, - NSS_WIFI_VDEV_ME_ENOMEM, - NSS_WIFI_VDEV_EINV_NAWDS_CFG, - NSS_WIFI_VDEV_EINV_EXTAP_CFG, - NSS_WIFI_VDEV_EINV_VOW_DBG_CFG, - NSS_WIFI_VDEV_EINV_DSCP_TID_MAP, - NSS_WIFI_VDEV_INVALID_ETHER_TYPE, - NSS_WIFI_VDEV_SNOOPTABLE_GRP_MEMBER_EXIST, - NSS_WIFI_VDEV_ME_INVALID_NSRCS, - NSS_WIFI_VDEV_EINV_RADIO_ID, - NSS_WIFI_VDEV_RADIO_NOT_PRESENT, - NSS_WIFI_VDEV_CHDRUPD_FAIL, - NSS_WIFI_VDEV_ME_DENY_GRP_MAX_RCHD, - NSS_WIFI_VDEV_EINV_NEXT_HOP, - NSS_WIFI_VDEV_EINV_DSCP_TID_MAP_ID, - NSS_WIFI_VDEV_EINV_TID_VALUE, - NSS_WIFI_VDEV_EINV_EXTAP_TABLE, - NSS_WIFI_VDEV_EXTAP_ENTRY_UPDATE_FAIL, - NSS_WIFI_VDEV_QWRAP_PSTA_ADD_FAIL, - NSS_WIFI_VDEV_QWRAP_PSTA_DEL_FAIL, - NSS_WIFI_VDEV_QWRAP_ISOLATION_EN_FAIL, - NSS_WIFI_VDEV_QWRAP_ALLOC_FAIL, - NSS_WIFI_VDEV_PEER_NOT_FOUND_BY_MAC, - NSS_WIFI_VDEV_PEER_NEXT_HOP_NOT_FOUND, - NSS_VDEV_EUNKNOWN_NEXT_HOP, - NSS_WIFI_VDEV_VLAN_ID_CONFIG_FAIL, - 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 -}; - -/** - * nss_wifi_vdev_ext_data_pkt_type - * Types of extended data plane packets sent from the NSS to the host. - */ -enum nss_wifi_vdev_ext_data_pkt_type { - NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_NONE = 0, - NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_IGMP = 1, /**< IGMP packets. */ - NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_MESH = 2, /**< MESH packets. */ - NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_INSPECT = 3, /**< Host inspect packets. */ - NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_TXINFO = 4, /**< Tx completion information packets. */ - NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_MPSTA_TX = 5, /**< MP station Tx metadata. */ - NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_MPSTA_RX = 6, /**< MP station Rx metadata. */ - NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_RX_ERR = 7, /**< Rx error packets metadata. */ - NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_EXTAP_TX = 8, /**< ExtAP Tx metadata. */ - NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_EXTAP_RX = 9, /**< ExtAP Rx metadata. */ - NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_WNM_TFS = 10, /**< WNM TFS related metadata. */ - 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_MAX -}; - -/** - * nss_wifi_vdev_cmd - * Commands for the Wi-Fi virtual device. - */ -enum nss_wifi_vdev_cmd { - NSS_WIFI_VDEV_DROP_UNENC_CMD, /**< Configuration to drop unencrypted frames on VAP. */ - NSS_WIFI_VDEV_ENCAP_TYPE_CMD, /**< Configuration to set encapsulation type on VAP. */ - NSS_WIFI_VDEV_DECAP_TYPE_CMD, /**< Configuration to set decapsulation type on VAP. */ - NSS_WIFI_VDEV_ENABLE_ME_CMD, /**< Configuration to set multicast enhancement on VAP. */ - NSS_WIFI_VDEV_NAWDS_MODE_CMD, /**< Configuration to set NAWDS mode on VAP. */ - NSS_WIFI_VDEV_EXTAP_CONFIG_CMD, /**< Configuration to set extended AP mode on VAP. */ - NSS_WIFI_VDEV_CFG_BSTEER_CMD, /**< Configuration to set bandsteering on VAP. */ - NSS_WIFI_VDEV_VOW_DBG_MODE_CMD, /**< Configuration to set video over wireless (VOW) debug mode on VAP. */ - NSS_WIFI_VDEV_VOW_DBG_RST_STATS_CMD, - /**< Configuration to reset video over wireless (VOW) debug mode on VAP. */ - NSS_WIFI_VDEV_CFG_DSCP_OVERRIDE_CMD, - /**< Configuration to set DSCP/TID value override on VAP. */ - NSS_WIFI_VDEV_CFG_WNM_CAP_CMD, /**< Configuration to set wireless network management (WNM) capability on VAP. */ - NSS_WIFI_VDEV_CFG_WNM_TFS_CMD, /**< Configuration to set WNM traffic filtering and sleep mode (TFS) capability on VAP. */ - NSS_WIFI_VDEV_CFG_WDS_EXT_ENABLE_CMD, - /**< Configuration to set WDS extention capability on VAP. */ - NSS_WIFI_VDEV_CFG_WDS_CMD, /**< Configuration to set WDS on VAP. */ - NSS_WIFI_VDEV_CFG_AP_BRIDGE_CMD, /**< Configuration to enable/disable client isolation. */ - NSS_WIFI_VDEV_SECURITY_TYPE_CMD, /**< Configuration to set security type per VAP. */ - 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_CFG_PEER_AUTHORIZE_CMD, - /**< Configuration to enable peer authorization on VAP. */ - NSS_WIFI_VDEV_MAX_CMD -}; - -/** - * nss_wifi_vdev_dp_type - * Virtual device datapath types. - */ -enum nss_wifi_vdev_dp_type { - NSS_WIFI_VDEV_DP_ACCELERATED, /**< Wi-Fi accelerated VAP type. */ - NSS_WIFI_VDEV_DP_NON_ACCELERATED, /**< Wi-Fi non-acclerated VAP type. */ - NSS_WIFI_VDEV_DP_TYPE_MAX /**< Wi-Fi maximum VAP type. */ -}; - -/** - * nss_wifi_vdev_vlan_tagging_mode - * Supported VLAN tagging modes. - */ -enum nss_wifi_vdev_vlan_tagging_mode { - NSS_WIFI_VDEV_VLAN_NONE, /**< VLAN support disabled. */ - - /** - * Default VLAN mode to add VLAN tag in Rx path and - * remove VLAN tag only when matching with configured - * VLAN tag in Tx path. - */ - NSS_WIFI_VDEV_VLAN_INGRESS_ADD_EGRESS_STRIP_ON_ID_MATCH, - - /** - * Port-based VLAN mode to add VLAN tag in Rx path - * and remove any VLAN tag in Tx path. - */ - NSS_WIFI_VDEV_VLAN_INGRESS_ADD_EGRESS_STRIP_ALWAYS, - 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. - */ -struct nss_wifi_vdev_config_msg { - uint8_t mac_addr[ETH_ALEN]; /**< MAC address. */ - uint16_t radio_ifnum; /**< Corresponding radio interface number. */ - uint32_t vdev_id; /**< Virtual device ID. */ - uint32_t epid; /**< Endpoint ID of the copy engine. */ - uint32_t downloadlen; /**< Size of the header download length. */ - uint32_t hdrcachelen; /**< Size of the header cache. */ - uint32_t hdrcache[NSS_WIFI_HTT_TRANSFER_HDRSIZE_WORD]; - /**< Cached per descriptor metedata shared with NSS Firmware. */ - uint32_t opmode; /**< VAP operating mode: Access-Point (AP) or Station (STA). */ - uint32_t mesh_mode_en; /**< Mesh mode is enabled. */ - uint8_t is_mpsta; - /**< Specifies whether the station is a VAP Master-Proxy (MP) station. */ - uint8_t is_psta; - /**< Specifies whether the station is a proxy station. */ - uint8_t special_vap_mode; - /**< Special VAP for monitoring received management packets. */ - uint8_t smartmesh_mode_en; - /**< 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. */ -}; - -/** - * nss_wifi_vdev_enable_msg - * Enable a message for a virtual device. - */ -struct nss_wifi_vdev_enable_msg { - uint8_t mac_addr[ETH_ALEN]; /**< MAC address. */ - uint8_t reserved[2]; /**< Reserved for 4-byte alignment padding. */ -}; - -/** - * nss_wifi_vdev_disable_msg - * Disable message for a virtual device. - */ -struct nss_wifi_vdev_disable_msg { - uint32_t reserved; /**< Placeholder for future enhancement. */ -}; - -/** - * nss_wifi_vdev_recovery_msg - * Recovery message for a virtual device. - */ -struct nss_wifi_vdev_recovery_msg { - uint32_t reserved; /**< Placeholder for future enhancement. */ -}; - -/** - * nss_wifi_vdev_set_next_hop_msg - * Set next hop for Wi-Fi virtual device. - */ -struct nss_wifi_vdev_set_next_hop_msg { - uint32_t ifnumber; /**< Next hop interface number. */ -}; - -/** - * nss_wifi_vdev_extap_map - * Wi-Fi EXTAP map for IPv4/IPv6 addresses. - */ -struct nss_wifi_vdev_extap_map { - uint16_t ip_version; /**< IPv4 or IPv6 address. */ - uint8_t h_dest[ETH_ALEN]; /**< MAC address of original backend. */ - union { - uint8_t IPv4[4]; /**< IPv4 address of the backend. */ - uint8_t IPv6[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH]; /**< IPv6 group IP address. */ - } u; -}; - -/** - * nss_wifi_vdev_cmd_msg - * Virtual device commands. - */ -struct nss_wifi_vdev_cmd_msg { - uint32_t cmd; /**< Command type. */ - uint32_t value; /**< Command value. */ -}; - -/** - * nss_wifi_vdev_me_snptbl_grp_create_msg - * Information for creating the snooptable group of a virtual device. - */ -struct nss_wifi_vdev_me_snptbl_grp_create_msg { - uint32_t ether_type; /**< Ether type of the multicast group. */ - - /** - * IP address of a multicast group. - */ - union { - uint32_t grpaddr_ip4; - /**< IPv4 address. */ - 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]; - /**< MAC address of the multicast group. */ -}; - -/** - * nss_wifi_vdev_me_snptbl_grp_delete_msg - * Information for deleting a snooplist group list. - */ -struct nss_wifi_vdev_me_snptbl_grp_delete_msg { - uint32_t ether_type; /**< Ether type of the multicast group. */ - - /** - * IP address of the multicast group. - */ - union { - uint32_t grpaddr_ip4; - /**< IPv4 address. */ - 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]; /**< MAC address of the multicast group. */ -}; - -/** - * struct nss_wifi_vdev_me_mbr_ra_info - * Address details of receiver members. - */ -struct nss_wifi_vdev_me_mbr_ra_info { - bool dup; - /**< Duplicate bit to identify if next hop address is present. */ - uint8_t ramac[ETH_ALEN]; - /**< MAC address of receiver. */ -}; - -/** - * nss_wifi_vdev_me_snptbl_grp_mbr_add_msg - * Information for adding a snooplist group member. - */ -struct nss_wifi_vdev_me_snptbl_grp_mbr_add_msg { - uint32_t ether_type; /**< Ether type of the multicast group. */ - - /** - * IP address of the multicast group. - */ - union { - uint32_t grpaddr_ip4; - /**< IPv4 address. */ - uint8_t grpaddr_ip6[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH]; - /**< IPv6 address. */ - } u; /**< IP address of the multicast group. */ - - uint32_t peer_id; /**< Peer ID. */ - uint8_t grp_addr[ETH_ALEN]; - /**< MAC address of the multicast group. */ - uint8_t grp_member_addr[ETH_ALEN]; - /**< MAC address of the multicast group member. */ - uint8_t mode; /**< Multicast enhancement mode - mode 2 and mode 5. */ - uint8_t nsrcs; /**< Number of source IP addresses for selective source multicast. */ - uint8_t src_ip_addr[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH * NSS_WIFI_MAX_SRCS]; - /**< Source IP address. */ - struct nss_wifi_vdev_me_mbr_ra_info ra_entry; - /**< Receiver address entry corresponding to the member. */ -}; - -/** - * nss_wifi_vdev_me_snptbl_grp_mbr_delete_msg - * Information for removing a snooplist group member. - */ -struct nss_wifi_vdev_me_snptbl_grp_mbr_delete_msg { - uint32_t ether_type; /**< Ether type of the multicast group. */ - - /** - * IP address of the multicast group. - */ - union { - uint32_t grpaddr_ip4; - /**< IPv4 address. */ - 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]; - /**< MAC address of the multicast group. */ - uint8_t grp_member_addr[ETH_ALEN]; - /**< MAC address of the multicast group member. */ -}; - -/** - * nss_wifi_vdev_me_snptbl_grp_mbr_update_msg - * Information for updating a snooplist group member. - */ -struct nss_wifi_vdev_me_snptbl_grp_mbr_update_msg { - uint32_t ether_type; /**< Ether type of the multicast group. */ - - /** - * IP address of the multicast group. - */ - union { - uint32_t grpaddr_ip4; - /**< IPv4 address. */ - 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]; - /**< MAC address of the multicast group. */ - uint8_t grp_member_addr[ETH_ALEN]; - /**< MAC address of the multicast group member. */ - uint8_t mode; /**< Multicast enhancement mode - mode 2 and mode 5. */ - uint8_t nsrcs; /**< Number of source IP addresses for selective source multicast. */ - uint8_t src_ip_addr[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH * NSS_WIFI_MAX_SRCS]; - /**< Source IP address. */ -}; - -/** - * 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. */ - uint8_t ipv6_addr[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH]; - /**< 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. */ - uint8_t ipv6_addr[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH]; - /**< 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 deny list. - */ -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. */ - uint8_t ipv6_addr[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH]; - /**< 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 deny list. - */ -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. */ - uint8_t ipv6_addr[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH]; - /**< 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. - */ -struct nss_wifi_vdev_me_snptbl_deny_grp_add_msg { - uint32_t grpaddr; /**< IP address of the multicast group. */ -}; - -/** - * nss_wifi_vdev_txmsg - * Information for transmitting special data. - */ -struct nss_wifi_vdev_txmsg { - uint16_t peer_id; /**< Peer ID. */ - uint16_t tid; /**< Traffic ID. */ -}; - -/** - * nss_wifi_vdev_vow_dbg_stats - * Types of VoW debug statistics. - */ -struct nss_wifi_vdev_vow_dbg_stats { - uint32_t rx_vow_dbg_counters; /**< VoW Rx debug counter. */ - uint32_t tx_vow_dbg_counters[8]; /**< VoW Tx debug counter. */ -}; - -/** - * nss_wifi_vdev_vow_dbg_cfg_msg - * Information for configuring VoW debug statistics. - */ -struct nss_wifi_vdev_vow_dbg_cfg_msg { - uint8_t vow_peer_list_idx; /**< Index of the peer list. */ - uint8_t tx_dbg_vow_peer_mac4; /**< MAC address 4 for the peer. */ - uint8_t tx_dbg_vow_peer_mac5; /**< MAC address 5 for the peer. */ -}; - -/** - * nss_wifi_vdev_dscp_tid_map - * DSCP-to-TID mapping. - */ -struct nss_wifi_vdev_dscp_tid_map { - uint32_t dscp_tid_map[NSS_WIFI_VDEV_DSCP_MAP_LEN]; - /**< Array holding the DSCP-to-TID mapping. */ -}; - -/** - * nss_wifi_vdev_dscptid_map_id - * DSCP-to-TID map ID. - */ -struct nss_wifi_vdev_dscptid_map_id { - uint8_t dscp_tid_map_id; - /**< DSCP-to-TID mapping ID to be used. */ -}; - -/** - * nss_wifi_vdev_set_peer_next_hop - * Set per peer next hop. - */ -struct nss_wifi_vdev_set_peer_next_hop_msg { - uint8_t peer_mac_addr[ETH_ALEN]; /**< MAC peer address. */ - uint16_t reserved; /**< Reserved. */ - uint32_t if_num; /**< Next hop interface number. */ -}; - -/** - * nss_wifi_vdev_qwrap_psta_msg - * PSTA VAP entry map in QWRAP mode. - */ -struct nss_wifi_vdev_qwrap_psta_msg { - uint8_t oma[ETH_ALEN]; /**< Original MAC address of PSTA VAP. */ - uint8_t vma[ETH_ALEN]; /**< Virtual MAC address of PSTA VAP. */ - uint8_t vdev_id; /**< ID of PSTA VAP. */ - uint8_t is_wired; /**< Is the entry for wired PSTA VAP. */ - uint8_t reserved[2]; /**< Reserved for 4-byte alignment. */ -}; - -/** - * nss_wifi_vdev_qwrap_isolation_en_msg - * Qwrap isolation mode enable. - */ -struct nss_wifi_vdev_qwrap_isolation_en_msg { - uint8_t isolation_enable; /**< QWRAP isolation mode enable. */ - uint8_t reserved[3]; /**< Reserved for 4-byte alignment. */ -}; - -/** - * nss_wifi_vdev_igmp_per_packet_metadata - * Per-packet metadata for IGMP packets. - */ -struct nss_wifi_vdev_igmp_per_packet_metadata { - uint32_t tid; /**< TID. */ - uint32_t tsf32; /**< TSF value. */ - uint8_t peer_mac_addr[ETH_ALEN]; - /**< Peer MAC address. */ - uint8_t reserved[2]; /**< Reserved for 4-byte alignment. */ -}; - -/** - * nss_wifi_vdev_mesh_per_packet_metadata - * Per-packet metadata for Mesh packets. - */ -struct nss_wifi_vdev_mesh_per_packet_metadata { - uint32_t status; /**< Meshmode Status. */ - uint32_t rssi; /**< Received signal strength indication. */ - uint32_t tsf; /**< Tx expiry time. */ - uint16_t tx_retries; /**< Retry count. */ -}; - -/** - * nss_wifi_vdev_vlan_config_msg - * Enable special handling on this VAP where VLAN tagging is added in Rx and removed in Tx. - */ -struct nss_wifi_vdev_vlan_config_msg { - uint16_t vlan_id; /**< VLAN ID configured. */ - uint8_t reserved[2]; /**< Reserved for 4-byte alignment. */ -}; - -/** - * nss_wifi_vdev_vlan_enable_msg - * Enable VLAN tagging mode on this VAP. - */ -struct nss_wifi_vdev_vlan_enable_msg { - uint8_t vlan_tagging_mode; /**< Flag to enable default or port-based VLAN tagging mode. */ - uint8_t reserved[3]; /**< Reserved for 4-byte alignment. */ -}; - -/** - * nss_wifi_vdev_set_vlan_group_key - * Set VLAN ID for special peer. - */ -struct nss_wifi_vdev_set_vlan_group_key { - uint16_t vlan_id; /**< VLAN ID. */ - uint16_t group_key; /**< Group key. */ -}; - -/** - * nss_wifi_vdev_txinfo_per_packet_metadata - * Per-packet metadata for Tx completion information packets. - */ -struct nss_wifi_vdev_txinfo_per_packet_metadata { - uint32_t status; /**< Tx completion status. */ - uint16_t msdu_count; /**< Count of MSDUs in the MSDU list. */ - uint16_t num_msdu; /**< Sequence Number of MSDU in the MSDU list. */ - uint32_t msdu_q_time; /**< Time spent by an MSDU in the Wi-Fi firmware. */ - uint32_t ppdu_rate; /**< PPDU rate in code rate. */ - uint8_t ppdu_num_mpdus_success; - /**< Number of successful MPDUs. */ - uint8_t ppdu_num_mpdus_fail; - /**< Number of failed MPDUs. */ - uint16_t ppdu_num_msdus_success; - /**< Number of successful MSDUs. */ - uint32_t ppdu_bytes_success; - /**< Number of successful bytes. */ - uint32_t ppdu_duration; /**< Estimated air time. */ - uint8_t ppdu_retries; /**< Number of times a PPDU is retried. */ - uint8_t ppdu_is_aggregate; - /**< Flag to check whether a PPDU is aggregated. */ - uint16_t start_seq_num; /**< Starting MSDU ID for this PPDU. */ - uint16_t version; /**< PPDU statistics version. */ - uint32_t ppdu_ack_timestamp; - /**< Timestamp (in ms) when an acknowledgement was received. */ - uint32_t ppdu_bmap_enqueued_lo; - /**< Bitmap of packets enqueued to the hardware (LSB). */ - uint32_t ppdu_bmap_enqueued_hi; - /**< Bitmap of packets enqueued to the hardware (MSB). */ - uint32_t ppdu_bmap_tried_lo; - /**< Bitmap of packets sent over the air (LSB). */ - uint32_t ppdu_bmap_tried_hi; - /**< Bitmap of packets sent over the air (MSB). */ - uint32_t ppdu_bmap_failed_lo; - /**< Bitmap of packets that failed to be acknowledged (LSB). */ - uint32_t ppdu_bmap_failed_hi; - /**< Bitmap of packets that failed to be acknowledged (MSB). */ -}; - -/** - * nss_wifi_vdev_qwrap_tx_metadata_types - * Per-packet metadata types for Qwrap Tx packets. - */ -enum nss_wifi_vdev_qwrap_tx_metadata_types { - NSS_WIFI_VDEV_QWRAP_TYPE_NONE = 0, - NSS_WIFI_VDEV_QWRAP_TYPE_TX = 1, - NSS_WIFI_VDEV_QWRAP_TYPE_RX_TO_TX = 2 -}; - -/** - * nss_wifi_vdev_extap_pkt_types - * Per-packet metadata types for ExtAP Tx packets. - */ -enum nss_wifi_vdev_extap_pkt_types { - NSS_WIFI_VDEV_EXTAP_PKT_TYPE_NONE = 0, - NSS_WIFI_VDEV_EXTAP_PKT_TYPE_TX = 1, - NSS_WIFI_VDEV_EXTAP_PKT_TYPE_RX_TO_TX = 2 -}; - -/** - * nss_wifi_vdev_mpsta_per_packet_tx_metadata - * Per-packet metadata for transmitting packets to an MP station. - */ -struct nss_wifi_vdev_mpsta_per_packet_tx_metadata { - uint16_t vdev_id; /**< Virtual device ID. */ - uint16_t metadata_type; /**< Tx metadata type. */ -}; - -/** - * nss_wifi_vdev_mpsta_per_packet_rx_metadata - * Per-packet metadata for receiving packets from an MP station. - */ -struct nss_wifi_vdev_mpsta_per_packet_rx_metadata { - uint16_t vdev_id; /**< Virtual device ID. */ - uint16_t peer_id; /**< Peer ID. */ -}; - -/** - * nss_wifi_vdev_rx_err_per_packet_metadata - * Per-packet metadata for error packets received. - */ -struct nss_wifi_vdev_rx_err_per_packet_metadata { - uint8_t peer_mac_addr[ETH_ALEN]; - /**< Peer MAC address. */ - uint8_t tid; /**< TID. */ - uint8_t vdev_id; /**< Virtual device ID. */ - uint8_t err_type; /**< Error type. */ - uint8_t rsvd[3]; /**< Reserved for future enhancement. */ -}; - -/** - * nss_wifi_vdev_extap_per_packet_metadata - * Per-packet metadata for ExtAP. - */ -struct nss_wifi_vdev_extap_per_packet_metadata { - uint16_t pkt_type; /**< ExtAP packet type. */ - uint8_t res[2]; /**< Reserved for 4-byte alignment. */ -}; - -/** - * nss_wifi_vdev_tx_compl_metadata - * Per-packet metadata for Tx completion message. - */ -struct nss_wifi_vdev_tx_compl_metadata { - uint8_t ta[ETH_ALEN]; /**< Transmitter MAC address. */ - uint8_t ra[ETH_ALEN]; /**< Receiver MAC address. */ - uint16_t ppdu_id; /**< PPDU ID. */ - uint16_t peer_id; /**< Peer ID. */ -}; - -/** - * nss_wifi_vdev_wds_info_type - * Specifies the type of WDS notification information. - */ -enum wifi_vdev_ext_wds_info_type { - NSS_WIFI_VDEV_WDS_TYPE_NONE = 0, - NSS_WIFI_VDEV_WDS_TYPE_RX, /**< Rx WDS entry. */ - NSS_WIFI_VDEV_WDS_TYPE_MEC, /**< Multicast Tx WDS entry. */ - NSS_WIFI_VDEV_WDS_TYPE_DA /**< Rx WDS entry for destination address. */ -}; - -/** - * nss_wifi_vdev_per_packet_metadata - * Payload of per-packet metadata. - */ -struct nss_wifi_vdev_wds_per_packet_metadata { - uint16_t peer_id; /**< Peer ID. */ - uint8_t is_sa_valid; /**< Specifies whether source address is valid. */ - uint8_t reserved; /**< Reserve bytes for alignment. */ - enum wifi_vdev_ext_wds_info_type wds_type; - /**< WDS message type. */ - uint8_t addr4_valid; /**< 802.11 4th address valid flag. */ - uint8_t rsvd; /**< Reserve bytes for alignment. */ - uint16_t sa_idx; /**< Source address index. */ - uint16_t sa_sw_peer_id; /**< Software/Address-Search-Table peer ID. */ -}; - -/** - * nss_wifi_vdev_ppdu_mdata_dir - * Physical layer protocol data unit (PPDU) metadata direction. - */ -enum nss_wifi_vdev_ppdu_mdata_dir { - WIFI_VDEV_PPDU_MDATA_TX, /**< PPDU metadata for transmit direction. */ - WIFI_VDEV_PPDU_MDATA_RX /**< PPDU metadata for receive direction. */ -}; - -/** - * nss_wifi_vdev_ppdu_metadata - * PPDU metadata. - */ -struct nss_wifi_vdev_ppdu_metadata { - uint32_t dir; /**< Data direction for metadata. */ - uint32_t ppdu_id; /**< PPDU ID. */ - uint16_t peer_id; /**< Peer ID. */ - uint8_t first_msdu; /**< First MSDU. */ - uint8_t last_msdu; /**< Last MSDU. */ -}; - -/** - * nss_wifi_vdev_per_packet_metadata - * Wi-Fi per packet metadata content. - */ -struct nss_wifi_vdev_per_packet_metadata { - uint32_t pkt_type; /**< Type of packet. */ - - /** - * Metadata payload for special data receive messages. - */ - union { - struct nss_wifi_vdev_igmp_per_packet_metadata igmp_metadata; - /**< Per packet metadata structure for IGMP. */ - struct nss_wifi_vdev_mesh_per_packet_metadata mesh_metadata; - /**< Per packet metadata structure for mesh mode. */ - struct nss_wifi_vdev_txinfo_per_packet_metadata txinfo_metadata; - /**< Per packet metadata structure for Tx information. */ - struct nss_wifi_vdev_mpsta_per_packet_tx_metadata mpsta_tx_metadata; - /**< Per packet Tx metadata structure for master-proxy station. */ - struct nss_wifi_vdev_mpsta_per_packet_rx_metadata mpsta_rx_metadata; - /**< Per packet Rx metadata structure for master-proxy station. */ - struct nss_wifi_vdev_rx_err_per_packet_metadata rx_err_metadata; - /**< Per packet metadata structure for Rx error. */ - struct nss_wifi_vdev_tx_compl_metadata tx_compl_metadata; - /**< Per packet Tx metadata structure for Tx completion. */ - struct nss_wifi_vdev_wds_per_packet_metadata wds_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. */ - } metadata; - /**< Metadata payload for special data receive message. */ -}; - -/** - * nss_wifi_vdev_meshmode_rx_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 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). */ - uint8_t rs_flags; /**< First/last MSDU flags. */ - uint8_t rs_channel; /**< Operational channel. */ - uint8_t rs_keyix; /**< Key index. */ - uint8_t padd; /**< Padding to ensure alignment. */ -}; - -/** - * nss_wifi_vdev_rawmode_rx_metadata - * Metadata payload for Raw Mode receive. - */ -struct nss_wifi_vdev_rawmode_rx_metadata { - uint16_t vdev_id; /**< Virtual device ID. */ - uint16_t peer_id; /**< Peer ID. */ -}; - -/** - * nss_wifi_vdev_updchdr_msg - * Information for updating a cache header. - */ -struct nss_wifi_vdev_updchdr_msg { - uint32_t hdrcache[NSS_WIFI_HTT_TRANSFER_HDRSIZE_WORD]; - /**< Updated header cache. */ - uint32_t vdev_id; /**< Virtual device ID. */ -}; - -/** - * nss_wifi_vdev_me_host_sync_grp_entry - * Multicast enhancement host synchronization group table. - */ -struct nss_wifi_vdev_me_host_sync_grp_entry { - uint8_t group_addr[ETH_ALEN]; /**< Group address for this list. */ - uint8_t grp_member_addr[ETH_ALEN]; /**< MAC address of the multicast group member. */ - - /** - * Type of group addresses. - */ - union { - uint32_t grpaddr_ip4; - /**< IPv4 group address. */ - uint8_t grpaddr_ip6[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH]; - /**< IPv6 group address. */ - } u; /**< Type of group addresses. */ - - uint32_t src_ip_addr; - /**< Source IP address. */ -}; - -/** - * wifi_vdev_me_host_sync_msg - * Synchronization message for a multicast enhancement host group. - */ -struct nss_wifi_vdev_me_host_sync_msg { - uint16_t vdev_id; /**< Virtual device ID. */ - uint8_t nentries; /**< Number of group entries carried by this message. */ - uint8_t radio_ifnum; /**< Interface number of the Wi-Fi radio. */ - struct nss_wifi_vdev_me_host_sync_grp_entry grp_entry[NSS_WIFI_VDEV_MAX_ME_ENTRIES]; - /**< Array for multicast group entries. */ -}; - -/** - * nss_wifi_vdev_mcast_enhance_stats - * Multicast enhancement-related statistics. - */ -struct nss_wifi_vdev_mcast_enhance_stats { - - /** - * Number of multicast packets recieved for multicast enhancement conversion. - */ - uint32_t mcast_rcvd; - - /** - * Number of unicast packets sent as part of multicast enhancement conversion. - */ - uint32_t mcast_ucast_converted; - - /** - * Number of multicast enhancement frames dropped because of a - * buffer allocation failure. - */ - uint32_t mcast_alloc_fail; - - /** - * Number of multicast enhancement frames dropped because of a - * buffer enqueue failure. - */ - uint32_t mcast_pbuf_enq_fail; - - /** - * Number of multicast enhancement frames dropped because of a - * buffer copy failure. - */ - uint32_t mcast_pbuf_copy_fail; - - /** - * Number of multicast enhancement frames dropped because of a - * failure in sending flow control to a peer. - */ - uint32_t mcast_peer_flow_ctrl_send_fail; - - /** - * Number of multicast enhancement buffer frames dropped when - * destination MAC is the same as source MAC. - */ - uint32_t mcast_loopback_err; - - /** - * Number of multicast enhancement buffer frames dropped - * because of an empty destination MAC. - */ - uint32_t mcast_dst_address_err; - - /** - * Number of multicast enhancement buffer frames dropped - * because no member is listening on the group. - */ - uint32_t mcast_no_enhance_drop_cnt; - - /** - * 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; -}; - -/** - * nss_wifi_vdev_stats_sync_msg - * Message to get virtual device statistics from NSS Firmware to Host. - */ -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_intra_bss_enqueue_cnt; /**< Intra BSS enqueue count. */ - uint32_t tx_intra_bss_enqueue_fail_cnt; - /**< Intra BSS enqueue fail count. */ - uint32_t tx_intra_bss_mcast_send_cnt; - /**< 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 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_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; - /**< Multicast enhancement statistics. */ - uint32_t num_tx_exception; /**< Number of Tx exception to firmware. */ - uint32_t tx_dma_map_fail; /**< DMA map failure. */ - uint32_t tx_desc_alloc_fail; /**< Descriptor allocation failure. */ - uint32_t tx_hw_ring_full; /**< Hardware ring is full. */ - uint32_t tx_tso_pkt; /**< Number of TSO packets. */ - uint32_t tx_num_seg; /**< Number of segments in TSO packets. */ - uint32_t tx_rcvd; /**< Number of packets received from host. */ - uint32_t tx_rcvd_bytes; /**< Number of bytes received from host. */ - uint32_t cce_classified; - /**< Number of packets that are classified and sent to firmware as an exception. */ - uint32_t cce_classified_raw; - /**< Number of raw packets that are classified and sent to firmware as an exception. */ - 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. */ -}; - -/** - * nss_wifi_vdev_msg - * Data for sending and receiving virtual device specific messages. - */ -struct nss_wifi_vdev_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a virtual device specific message. - */ - union { - struct nss_wifi_vdev_config_msg vdev_config; - /**< Virtual device configuration. */ - struct nss_wifi_vdev_enable_msg vdev_enable; - /**< Enable a message for a virtual device. */ - struct nss_wifi_vdev_cmd_msg vdev_cmd; - /**< Command message for a virtual device. */ - struct nss_wifi_vdev_me_snptbl_grp_create_msg vdev_grp_list_create; - /**< Creates the snooptable group of a virtual device. */ - struct nss_wifi_vdev_me_snptbl_grp_delete_msg vdev_grp_list_delete; - /**< Deletes a snooplist group list. */ - struct nss_wifi_vdev_me_snptbl_grp_mbr_add_msg vdev_grp_member_add; - /**< Adds a snooplist group member. */ - struct nss_wifi_vdev_me_snptbl_grp_mbr_delete_msg vdev_grp_member_remove; - /**< Removes a snooplist group member. */ - 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 new member into the HMMC list. */ - struct nss_wifi_vdev_me_hmmc_del_msg vdev_hmmc_member_del; - /**< Delete a member from the HMMC list. */ - struct nss_wifi_vdev_me_deny_ip_add_msg vdev_deny_list_member_add; - /**< Adds a new member into the deny list. */ - struct nss_wifi_vdev_me_deny_ip_del_msg vdev_deny_list_member_del; - /**< Delete a member from the deny list. */ - struct nss_wifi_vdev_txmsg vdev_txmsgext; - /**< Transmits special data. */ - struct nss_wifi_vdev_vow_dbg_cfg_msg vdev_vow_dbg_cfg; - /**< Configures VoW debug statistics. */ - struct nss_wifi_vdev_vow_dbg_stats vdev_vow_dbg_stats; - /**< Types of VoW debug statistics. */ - struct nss_wifi_vdev_dscp_tid_map vdev_dscp_tid_map; - /**< DSCP-to-TID mapping. */ - struct nss_wifi_vdev_updchdr_msg vdev_updchdr; - /**< Updates a cache header. */ - struct nss_wifi_vdev_me_host_sync_msg vdev_me_sync; - /**< Message for a multicast enhancement host group table synchronization. */ - struct nss_wifi_vdev_stats_sync_msg vdev_stats; - /**< Message to get virtual device statistics from NSS firmware to host. */ - struct nss_wifi_vdev_set_next_hop_msg next_hop; - /**< Next hop message for virtual device. */ - struct nss_wifi_vdev_dscptid_map_id vdev_dscp_tid_map_id; - /**< Message to get DSCP-to-TID mapping id to be used on virtual device. */ - struct nss_wifi_vdev_extap_map vdev_extap_map; - /**< Message to add entry in EXTAP table on virtual device. */ - struct nss_wifi_vdev_qwrap_psta_msg vdev_qwrap_psta_map; - /**< Message to get PSTA VAP details in QWRAP mode. */ - struct nss_wifi_vdev_qwrap_isolation_en_msg vdev_qwrap_isolation_en; - /**< Message to enable QWRAP isolation mode. */ - struct nss_wifi_vdev_set_peer_next_hop_msg vdev_set_peer_next_hp; - /**< Message to set next hop per peer. */ - struct nss_wifi_vdev_vlan_config_msg vdev_vlan_config; - /**< Message to set VLAN configured on a particular virtual device. */ - struct nss_wifi_vdev_vlan_enable_msg vdev_vlan_enable; - /**< Message to enable VLAN tagging support on a particular virtual device. */ - struct nss_wifi_vdev_set_vlan_group_key vlan_group_key; - /**< Message to set group key for peer. */ - } msg; /**< Virtual device message payload. */ -}; - -/** - * nss_wifi_vdev_tx_msg - * Sends a Wi-Fi message to the NSS interface. - * - * @datatypes - * nss_ctx_instance \n - * nss_wifi_vdev_msg - * - * @param[in] nss_ctx Pointer to the NSS core context. - * @param[in] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_wifi_vdev_tx_msg(struct nss_ctx_instance *nss_ctx, - struct nss_wifi_vdev_msg *msg); - -/** - * nss_wifi_vdev_base_tx_msg - * Sends a Wi-Fi message to the NSS VAP interface. - * - * @datatypes - * nss_ctx_instance \n - * nss_wifi_vdev_msg - * - * @param[in] nss_ctx Pointer to the NSS core context. - * @param[in] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_wifi_vdev_base_tx_msg(struct nss_ctx_instance *nss_ctx, - struct nss_wifi_vdev_msg *msg); - -/** - * nss_wifi_vdev_tx_buf - * Sends a Wi-Fi data packet to the NSS interface. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in] nss_ctx Pointer to the NSS core context. - * @param[in] os_buf Pointer to the OS data buffer. - * @param[in] if_num NSS interface number. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_wifi_vdev_tx_buf(struct nss_ctx_instance *nss_ctx, - struct sk_buff *os_buf, uint32_t if_num); - -/** - * Callback function for receiving Wi-Fi virtual device 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_vdev_msg_callback_t)(void *app_data, - struct nss_cmn_msg *msg); - -/** - * Callback function for receiving Wi-Fi virtual device 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_vdev_callback_t)(struct net_device *netdev, - struct sk_buff *skb, struct napi_struct *napi); - -/** - * Callback function for receiving extended data plane Wi-Fi virtual device 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. - * @param[in] netdev Pointer to the associated network device. - */ -typedef void (*nss_wifi_vdev_ext_data_callback_t)(struct net_device *netdev, - struct sk_buff *skb, struct napi_struct *napi); - -/** - * nss_wifi_vdev_msg_init - * Initializes a Wi-Fi virtual device message. - * - * @datatypes - * nss_wifi_vdev_msg \n - * nss_wifi_vdev_msg_callback_t - * - * @param[in] nim Pointer to the NSS interface message. - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Length of message. - * @param[in] cb Message callback. - * @param[in] app_data Pointer to the application context of the message. - * - * @return - * None. - */ -void nss_wifi_vdev_msg_init(struct nss_wifi_vdev_msg *nim, uint32_t if_num, uint32_t type, uint32_t len, - nss_wifi_vdev_msg_callback_t *cb, void *app_data); - -/** - * nss_register_wifi_vdev_if - * Registers a Wi-Fi virtual device interface with the NSS interface. - * - * @datatypes - * nss_ctx_instance \n - * nss_wifi_vdev_callback_t \n - * nss_wifi_vdev_ext_data_callback_t \n - * nss_wifi_vdev_msg_callback_t \n - * net_device - * - * @param[in,out] nss_ctx Pointer to the NSS core context. - * @param[in] if_num NSS interface number. - * @param[in] wifi_data_callback Callback for the Wi-Fi virtual device data. - * @param[in] vdev_ext_data_callback Callback for the extended data. - * @param[in] wifi_event_callback Callback for the message. - * @param[in] netdev Pointer to the associated network device. - * @param[in] features Data socket buffer types supported by this - * interface. - * - * @return - * None. - */ -uint32_t nss_register_wifi_vdev_if(struct nss_ctx_instance *nss_ctx, int32_t if_num, nss_wifi_vdev_callback_t wifi_data_callback, - nss_wifi_vdev_ext_data_callback_t vdev_ext_data_callback, nss_wifi_vdev_msg_callback_t wifi_event_callback, - struct net_device *netdev, uint32_t features); - -/** - * nss_unregister_wifi_vdev_if - * Deregisters a Wi-Fi virtual device interface from the NSS interface. - * - * @param[in] if_num NSS interface number. - * - * @return - * None. - */ -void nss_unregister_wifi_vdev_if(uint32_t if_num); - -/** - * nss_wifi_vdev_tx_msg_ext - * Sends Wi-Fi data packet along with metadata as message to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * sk_buff - * - * @param[in,out] nss_ctx Pointer to the NSS core context. - * @param[in] os_buf Pointer to the OS data buffer. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_wifi_vdev_tx_msg_ext(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf); - -/** - * nss_wifi_vdev_set_next_hop - * Send next hop message to Wi-Fi virtual device. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS core context. - * @param[in] if_num NSS interface number. - * @param[in] next_hop Next hop interface number. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_wifi_vdev_set_next_hop(struct nss_ctx_instance *nss_ctx, int if_num, int next_hop); - -/** - * nss_wifi_vdev_base_set_next_hop - * Sends the next hop message to Wi-Fi virtual access point. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS core context. - * @param[in] next_hop Next hop interface number. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_wifi_vdev_base_set_next_hop(struct nss_ctx_instance *nss_ctx, int next_hop); - -/** - * nss_wifi_vdev_set_peer_next_hop - * Sends the peer next hop message to Wi-Fi virtual device. - * - * @datatypes - * nss_ctx_instance - * - * @param[in] nss_ctx Pointer to the NSS core context. - * @param[in] nss_if NSS interface number. - * @param[in] addr Peer MAC address. - * @param[in] next_hop_if Next hop interface number. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_wifi_vdev_set_peer_next_hop(struct nss_ctx_instance *nss_ctx, uint32_t nss_if, uint8_t *addr, uint32_t next_hop_if); - -/* - * nss_wifi_vdev_set_dp_type - * Sets the datapath type for virtual device. - * - * @datatypes - * nss_ctx_instance \n - * net_device \n - * uint32_t \n - * enum nss_wifi_vdev_dp_type - * - * @param[in] nss_ctx Pointer to the NSS core context. - * @param[in] netdev Pointer to the associated network device. - * @param[in] if_num Interface number of the VAP. - * @param[in] dp_type Datapath type of the VAP. - * - * @return - * True if a success, or false if a failure. - */ -bool nss_wifi_vdev_set_dp_type(struct nss_ctx_instance *nss_ctx, struct net_device *netdev, - uint32_t if_num, enum nss_wifi_vdev_dp_type dp_type); -/** - * @} - */ - -#endif /* __NSS_WIFI_VDEV_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifili_if.h b/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifili_if.h deleted file mode 100644 index 7d5954267..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/exports/nss_wifili_if.h +++ /dev/null @@ -1,2057 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2017-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. - ************************************************************************** - */ - - /** - * @file nss_wifili_if.h - * NSS TO HLOS interface definitions. - * NOTE: Here we will use wifili as a reference to - * the IPQ807x Wi-Fi object. - */ -#ifndef __NSS_WIFILI_H -#define __NSS_WIFILI_H - - /** - * @addtogroup nss_wifili_subsystem - * @{ - */ - -#define NSS_WIFILI_MAX_SRNG_REG_GROUPS_MSG 2 - /**< Maximum srng (ring) register groups. */ -#define NSS_WIFILI_MAX_NUMBER_OF_PAGE_MSG 32 - /**< Maximum number of pages allocated from host. */ -#define NSS_WIFILI_MAX_TCL_DATA_RINGS_MSG 4 - /**< Maximum number of Transmit Classifier data ring for NSS. */ -#define NSS_WIFILI_MAX_REO_DATA_RINGS_MSG 4 - /**< Maximum number of Rx reorder data ring for NSS. */ -#define NSS_WIFILI_SOC_PER_PACKET_METADATA_OFFSET 4 - /**< Metadata area for storing Rx statistics. */ -#define NSS_WIFILI_MAX_TXDESC_POOLS_MSG 4 - /**< Maximum number of Tx Descriptor software pools. */ -#define NSS_WIFILI_MAX_TX_EXT_DESC_POOLS_MSG 4 - /**< Maximum number of Tx Descriptor Extended software pools. */ -#define NSS_WIFILI_MAX_SOC_NUM 3 - /**< Maximum number of SoC devices. */ -#define NSS_WIFILI_MAX_PDEV_NUM_MSG 3 - /**< Maximum number of pdev devices. */ -#define NSS_WIFILI_MAX_MCS 12 - /**< Maximum Modulaton And Coding Scheme (MCS) count. */ -#define NSS_WIFILI_MAX_MCS_11A 8 - /**< Maximum MCS for 11a mode. */ -#define NSS_WIFILI_MAX_MCS_11B 7 - /**< Maximum MCS for 11b mode. */ -#define NSS_WIFILI_MAX_MCS_11AC 10 - /**< Maximum MCS for 11ac mode. */ -#define NSS_WIFILI_MAX_MCS_11AX 10 - /**< Maximum MCS for 11ax mode. */ -#define NSS_WIFILI_SS_COUNT 8 - /**< Maximum spatial streams count. */ -#define NSS_WIFILI_SUPPORTED_BW 4 - /**< 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 - /**< Maximum reserved type. */ -#define NSS_WIFILI_SOC_PER_PACKET_METADATA_SIZE 60 - /**< Metadata area total size. */ -#define NSS_WIFILI_MEC_PEER_ID 0xDEAD - /**< MEC (Multicast echo check) peer ID. */ -#define NSS_WIFILI_DA_PEER_ID 0xDAAD - /**< Destination address peer ID. */ -#define NSS_WIFILI_MIC_KEY_LEN 8 - /**< MIC (Message integrity code) key length. */ -#define NSS_WIFILI_TQM_RR_MAX 7 - /**< Maximum transmit queue release reasons. */ -#define NSS_WIFILI_HTT_STATUS_MAX 7 - /**< Maximum HTT completion status. */ -#define NSS_WIFILI_TQM_STATUS_MAX 9 - /**< Maximum TQM completion status. */ -#define NSS_WIFILI_REO_CODE_MAX 15 - /**< Maximum Rx reorder error codes. */ -#define NSS_WIFILI_DMA_CODE_MAX 14 - /**< Maximum DMA error codes. */ -#define NSS_WIFILI_MAX_TID 8 - /**< Maximum TID values. */ -#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. */ -#define NSS_WIFILI_SOC_ATTACHED_MAX_PDEV_NUM 1 - /**< 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. */ - -/* - * Peer Size in Bytes - */ -#define NSS_WIFILI_PEER_SIZE 1600 - -/* - * 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 - * WME stream classes. - */ -enum nss_wifili_wme_stream_classes { - NSS_WIFILI_WME_AC_BE, /**< Best effort. */ - NSS_WIFILI_WME_AC_BK, /**< Background. */ - NSS_WIFILI_WME_AC_VI, /**< Video. */ - NSS_WIFILI_WME_AC_VO, /**< Voice. */ - NSS_WIFILI_WME_AC_MAX /**< Maximum AC Value. */ -}; - -/** - * nss_wifili_packet_type - * Different Packet Types. - */ -enum nss_wifili_packet_type { - NSS_WIFILI_DOT11_A, /**< 802.11a packet type. */ - NSS_WIFILI_DOT11_B, /**< 802.11b packet type. */ - NSS_WIFILI_DOT11_N, /**< 802.11n packet type. */ - NSS_WIFILI_DOT11_AC, /**< 802.11ac packet type. */ - NSS_WIFILI_DOT11_AX , /**< 802.11ax packet type. */ - NSS_WIFILI_DOT11_MAX /**< Maximum 802.11 packet types. */ -}; - -/* - * nss_wifili_decap_pkt_type - * Different Decapsulation packet types - */ -enum wifili_decap_pkt_type { - NSS_WIFILI_DECAP_TYPE_RAW, /**< Raw packet type. */ - NSS_WIFILI_DECAP_TYPE_NATIVE_WIFI, /**< Native Wi-Fi packet type. */ - NSS_WIFILI_DECAP_TYPE_ETHERNET, /**< Ethernet packet type. */ - NSS_WIFILI_DECAP_TYPE_MAX, /**< Maximum packet type. */ -}; - -/** - * nss_wifili_msg_types - * NSS wifili messages. - */ -enum nss_wifili_msg_types { - NSS_WIFILI_INIT_MSG, - NSS_WIFILI_SOC_RESET_MSG, - NSS_WIFILI_PDEV_INIT_MSG, - NSS_WIFILI_PDEV_DEINIT_MSG, - NSS_WIFILI_START_MSG, - NSS_WIFILI_STOP_MSG, - NSS_WIFILI_PEER_CREATE_MSG, - NSS_WIFILI_PEER_DELETE_MSG, - NSS_WIFILI_SEND_PEER_MEMORY_REQUEST_MSG, - NSS_WIFILI_PEER_FREELIST_APPEND_MSG, - NSS_WIFILI_STATS_MSG, - NSS_WIFILI_WDS_VENDOR_MSG, - NSS_WIFILI_PEER_STATS_MSG, - NSS_WIFILI_WDS_PEER_ADD_MSG, - NSS_WIFILI_WDS_PEER_DEL_MSG, - NSS_WIFILI_WDS_PEER_MAP_MSG, - NSS_WIFILI_WDS_ACTIVE_INFO_MSG, - NSS_WIFILI_STATS_CFG_MSG, - NSS_WIFILI_TID_REOQ_SETUP_MSG, - NSS_WIFILI_RADIO_CMD_MSG, - NSS_WIFILI_LINK_DESC_INFO_MSG, - NSS_WIFILI_PEER_SECURITY_TYPE_MSG, - NSS_WIFILI_PEER_NAWDS_ENABLE_MSG, - NSS_WIFILI_RADIO_BUF_CFG, - NSS_WIFILI_DBDC_REPEATER_SET_MSG, - NSS_DBDC_REPEATER_AST_FLUSH_MSG, - NSS_WIFILI_SET_HMMC_DSCP_OVERRIDE_MSG, - NSS_WIFILI_SET_HMMC_DSCP_TID_MSG, - NSS_WIFILI_PDEV_STATS_V3_TXRX_SYNC_MSG, - NSS_WIFILI_PDEV_STATS_V3_DELAY_SYNC_MSG, - NSS_WIFILI_ENABLE_V3_STATS_MSG, - NSS_WIFILI_WDS_PEER_UPDATE_MSG, - NSS_WIFILI_STATS_V2_CFG_MSG, - NSS_WIFILI_SOJOURN_STATS_MSG, - NSS_WIFILI_PEER_SET_VLAN_ID, - NSS_WIFILI_UPDATE_PDEV_LMAC_ID_MSG, - 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_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_MAX_MSG -}; - -/** - * nss_wifili_error_types - * Wifili error message types for functions. - */ -enum nss_wifili_error_types { - NSS_WIFILI_EMSG_NONE, - /**< No error. */ - NSS_WIFILI_EMSG_INIT_FAIL_IMPROPER_STATE, - /**< Device initialization failure due to improper state of device. */ - NSS_WIFILI_EMSG_RINGS_INIT_FAIL, - /**< Device ring initialization failure. */ - NSS_WIFILI_EMSG_PDEV_INIT_IMPROPER_STATE_FAIL, - /**< Radio initialization failure due to improper state of device. */ - NSS_WIFILI_EMSG_PDEV_INIT_INVALID_RADIOID_FAIL, - /**< Radio initialization failed due to invalid radio ID. */ - WIFILI_EMSG_PDEV_INIT_INVALID_TARGETPDEVID_FAIL, - /**< Radio initialization failed due to invalid target physical device ID. */ - NSS_WIFILI_EMSG_PDEV_TX_IRQ_ALLOC_FAIL, - /**< IRQ line allocation for radio transmission failed. */ - NSS_WIFILI_EMSG_PDEV_RESET_INVALID_RADIOID_FAIL, - /**< Radio reset failed due to invalid radio ID. */ - NSS_WIFILI_EMSG_PDEV_RESET_PDEV_NULL_FAIL, - /**< Radio reset failed due to NULL physical device. */ - NSS_WIFILI_EMSG_PDEV_RESET_IMPROPER_STATE_FAIL, - /**< Radio reset failed due to improper state of pdev. */ - NSS_WIFILI_EMSG_START_IMPROPER_STATE_FAIL, - /**< Device start fail due to improper state */ - NSS_WIFILI_EMSG_PEER_CREATE_FAIL, - /**< Peer creation failed. */ - NSS_WIFILI_EMSG_PEER_DELETE_FAIL, - /**< Peer deletion failed. */ - NSS_WIFILI_EMSG_HASHMEM_INIT_FAIL, - /**< Peer hash memory allocation failed. */ - NSS_WIFILI_EMSG_PEER_FREELIST_APPEND_FAIL, - /**< Appending peer to freelist failed. */ - NSS_WIFILI_EMSG_PEER_CREATE_INVALID_VDEVID_FAIL, - /**< Peer creation failure due to invalid virtual device ID. */ - NSS_WIFILI_EMSG_PEER_CREATE_INVALID_PEER_ID_FAIL, - /**< Peer creation failure due to invalid peer ID. */ - NSS_WIFILI_EMSG_PEER_CREATE_VDEV_NULL_FAIL, - /**< Peer creation failure due to NULL virtual device. */ - NSS_WIFILI_EMSG_PEER_CREATE_PDEV_NULL_FAIL, - /**< Peer creation failure due to NULL physical device. */ - NSS_WIFILI_EMSG_PEER_CREATE_ALLOC_FAIL, - /**< Peer creation failure due to memory allocation failure. */ - NSS_WIFILI_EMSG_PEER_DELETE_VAPID_INVALID_FAIL, - /**< Peer deletion failure due to invalid virtual device ID. */ - NSS_WIFILI_EMSG_PEER_DELETE_INVALID_PEERID_FAIL, - /**< Peer deletion failed due to invalid peer ID. */ - NSS_WIFILI_EMSG_PEER_DELETE_VDEV_NULL_FAIL, - /**< Peer deletion failure due to NULL virtual device. */ - NSS_WIFILI_EMSG_PEER_DELETE_PDEV_NULL_FAIL, - /**< Peer deletion failure due to NULL physical device. */ - NSS_WIFILI_EMSG_PEER_DELETE_PEER_NULL_FAIL, - /**< Peer deletion failure due to NULL peer. */ - NSS_WIFILI_EMSG_PEER_DELETE_PEER_CORRUPTED_FAIL, - /**< Peer creation failure due to corrupted peer. */ - NSS_WIFILI_EMSG_PEER_DUPLICATE_AST_INDEX_PEER_ID_FAIL, - /**< AST index provided is duplicate. */ - NSS_WIFILI_EMSG_GROUP0_TIMER_ALLOC_FAIL, - /**< Timer allocation failure. */ - NSS_WIFILI_EMSG_INSUFFICIENT_WT_FAIL, - /**< Insufficient worker thread error. */ - NSS_WIFILI_EMSG_INVALID_NUM_TCL_RING_FAIL, - /**< Invalid number of Transmit Classifier rings provided in initialization message. */ - NSS_WIFILI_EMSG_INVALID_NUM_REO_DST_RING_FAIL, - /**< Invalid number of Rx reorder destination ring in initialization message. */ - NSS_WIFILI_EMSG_HAL_SRNG_SOC_ALLOC_FAIL, - /**< Srng SoC memory allocation failure. */ - NSS_WIFILI_EMSG_HAL_SRNG_INVALID_RING_INFO_FAIL, - /**< Device ring information is invalid. */ - NSS_WIFILI_EMSG_HAL_SRNG_TCL_ALLOC_FAIL, - /**< Transmit Classifier srng ring allocation failure. */ - NSS_WIFILI_EMSG_HAL_SRNG_TXCOMP_ALLOC_FAIL, - /**< Txcomp srng ring allocation failure. */ - NSS_WIFILI_EMSG_HAL_SRNG_REODST_ALLOC_FAIL, - /**< Rx reorder destination srng ring allocation failure. */ - NSS_WIFILI_EMSG_HAL_SRNG_REOREINJECT_ALLOC_FAIL, - /**< Rx reorder reinject srng ring allocation failure. */ - NSS_WIFILI_EMSG_HAL_SRNG_RXRELEASE_ALLOC_FAIL, - /**< Rx release srng ring allocation failure. */ - NSS_WIFILI_EMSG_HAL_SRNG_RXEXCP_ALLOC_FAIL, - /**< Rx exception srng ring allocation failure. */ - NSS_WIFILI_EMSG_HAL_TX_MEMALLOC_FAIL, - /**< Tx HAL (hardware abstraction layer) srng ring allocation failure. */ - NSS_WIFILI_EMSG_HAL_TX_INVLID_POOL_NUM_FAIL, - /**< Invalid pool number in initialization message. */ - NSS_WIFILI_EMSG_HAL_TX_INVALID_PAGE_NUM_FAIL, - /**< Invalid page numner in initialization message. */ - NSS_WIFILI_EMSG_HAL_TX_DESC_MEM_ALLOC_FAIL, - /**< Tx descriptor memory allocation failure. */ - NSS_WIFILI_EMSG_HAL_RX_MEMALLOC_FAIL, - /**< Rx memory allocation failure. */ - NSS_WIFILI_EMSG_PDEV_RXDMA_RING_ALLOC_FAIL, - /**< Rx DMA ring allocation failed. */ - NSS_WIFILI_EMSG_NAWDSEN_PEERID_INVALID, - /**< Peer NAWDS enable failure due to invalid peer ID. */ - NSS_WIFILI_EMSG_NAWDSEN_PEER_NULL, - /**< Peer NAWDS enable failure due to peer being NULL. */ - NSS_WIFILI_EMSG_NAWDSEN_PEER_CORRUPTED, - /**< Peer NAWDS enable failure due to corrupted peer. */ - NSS_WIFILI_EMSG_WDS_PEER_CFG_FAIL, - /**< WDS peer configuration failure. */ - NSS_WIFILI_EMSG_RESET_NO_STOP, - /**< Reset issued without stopping the device. */ - NSS_WIFILI_EMSG_HAL_SRNG_INVALID_RING_BASE_FAIL, - /**< Ring base address is invalid. */ - NSS_WIFILI_EMSG_PDEV_RX_INIT_FAIL, - /**< Pdev Rx initialization failure. */ - NSS_WIFILI_EMESG_AST_ADD_FAIL, - /**< AST entry addition failure for connected peer. */ - NSS_WIFILI_EMESG_AST_REMOVE_FAIL, - /**< AST entry removal failure for connected peer. */ - NSS_WIFILI_EMESG_WDS_ADD_FAIL, - /**< WDS peer AST entry addition failure. */ - NSS_WIFILI_EMESG_WDS_REMOVE_FAIL, - /**< WDS peer AST entry removal failure. */ - NSS_WIFILI_EMESG_WDS_MAP_FAIL, - /**< WDS peer AST entry hardware index mapping failure. */ - NSS_WIFILI_EMSG_WDS_INVALID_PEERID_FAIL, - /**< Invalid peer id passed in WDS messages. */ - NSS_WIFILI_EMSG_WDS_DUPLICATE_AST_INDEX_PEER_ID_FAIL, - /**< AST entry index is already filled. */ - NSS_WIFILI_EMSG_INVALID_RADIO_CMD, - /**< Radio command is invalid. */ - NSS_WIFILI_EMSG_INVALID_RADIO_IFNUM, - /**< Radio interface number is invalid. */ - NSS_WIFILI_EMSG_PEER_SECURITY_PEER_NULL_FAIL, - /**< Security message failed as peer is NULL for a peer ID. */ - NSS_WIFILI_EMSG_PEER_SECURITY_PEER_CORRUPTED_FAIL, - /**< Security message failed as peer is corrupted. */ - NSS_WIFILI_EMSG_RADIO_INVALID_BUF_CFG, - /**< Buffer configuration message failed as invalid range value is provided. */ - NSS_WIFILI_EMSG_INIT_FAIL_INVALID_TARGET, - /**< Invalid target SoC type from host. */ - NSS_WIFILI_EMSG_PDEV_INIT_FAIL_INVALID_LMAC_ID, - /**< Invalid lower MAC ID from host. */ - NSS_WIFILI_EMSG_STATE_PDEV_NOT_INITIALIZED, - /**< Configured message issued when radio is not initialized. */ - NSS_WIFILI_EMESG_RX_TLV_INVALID, - /**< Invalid TLV length. */ - NSS_WIFILI_EMESG_RX_BUF_LEN_INVALID, - /**< Invalid Rx buffer length. */ - NSS_WIFILI_EMSG_UNKNOWN - /**< Unknown error message. */ -}; - -/** - * nss_wifili_soc_extended_data_types - * Enumeration of extended data type to host. - */ -enum nss_wifili_soc_extended_data_types { - NSS_WIFILI_SOC_EXT_DATA_PKT_TYPE_NONE, /**< Packet type is none. */ - NSS_WIFILI_SOC_EXT_DATA_PKT_MSDU_LINK_DESC, /**< Packet type is MSDU link descriptor. */ - NSS_WIFILI_SOC_EXT_DATA_PKT_INVALID_PEER, /**< Packet type is invalid peer. */ - NSS_WIFILI_SOC_EXT_DATA_PKT_MIC_ERROR, /**< Packet received with MIC error. */ - NSS_WIFILI_SOC_EXT_DATA_PKT_2K_JUMP_ERROR, /**< Packet received with 2K jump in sequence number. */ - NSS_WIFILI_SOC_EXT_DATA_PKT_WIFI_PARSE_ERROR, /**< Packet received with Wi-Fi parse error. */ - NSS_WIFILI_SOC_EXT_DATA_PKT_TYPE_MAX /**< Maximum extended data types. */ -}; - -/** - * nss_wifili_radio_cmd - * Wi-Fi radio commands for wifili. - */ -enum nss_wifili_radio_cmd { - NSS_WIFILI_RADIO_TX_CAPTURE_CMD, /**< Enable Tx capture. */ - NSS_WIFILI_SET_PRIMARY_RADIO, /**< Set current radio as primary. */ - NSS_WIFILI_SET_ALWAYS_PRIMARY, /**< Set always primary flag. */ - 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. */ -}; - -/* - * WARNING: There is a 1:1 mapping between values of enum nss_wifili_stats_txrx and corresponding - * statistics string array in nss_stats.c. - */ - -/** - * nss_wifili_stats_txrx - * Wifili Tx or Rx statistics. - */ -enum nss_wifili_stats_txrx { - NSS_WIFILI_STATS_RX_MSDU_ERROR, - /**< Number of Rx packets received from ring with MSDU error. */ - NSS_WIFILI_STATS_RX_INV_PEER_RCV, - /**< Number of Rx packets with invalid peer ID. */ - NSS_WIFILI_STATS_RX_WDS_SRCPORT_EXCEPTION, - /**< Number of Rx packets exceptioned to host because of source port learn fail. */ - NSS_WIFILI_STATS_RX_WDS_SRCPORT_EXCEPTION_FAIL, - /**< Number of Rx source port learn fail packets failed to get enqueued to host. */ - NSS_WIFILI_STATS_RX_DELIVERD, - /**< Number of packets wifili has given to next node. */ - NSS_WIFILI_STATS_RX_DELIVER_DROPPED, - /**< Number of packets which wifili failed to enqueue to next node. */ - NSS_WIFILI_STATS_RX_INTRA_BSS_UCAST, - /**< Number of packets that wifili sent for intra-BSS unicast packet. */ - NSS_WIFILI_STATS_RX_INTRA_BSS_UCAST_FAIL, - /**< Number of packets that wifili sent for intra-BSS unicast packet failed. */ - NSS_WIFILI_STATS_RX_INTRA_BSS_MCAST, - /**< Number of packets that wifili sent for intra-BSS multicast packet. */ - NSS_WIFILI_STATS_RX_INTRA_BSS_MCAST_FAIL, - /**< Number of packets that wifili sent for intra-BSS multicast packet failed. */ - NSS_WIFILI_STATS_RX_SG_RCV_SEND, - /**< Number of packets scatter-gather sent. */ - NSS_WIFILI_STATS_RX_SG_RCV_FAIL, - /**< Number of packets scatter-gather received failure. */ - NSS_STATS_WIFILI_RX_MCAST_ECHO, - /**< Number of multicast echo packets received. */ - NSS_STATS_WIFILI_RX_INV_TID, - /**< Number of invalid TID. */ - - /* - * TODO: Move per TID based - */ - NSS_WIFILI_STATS_RX_FRAG_INV_SC, - /**< Number of fragments with invalid sequence control. */ - NSS_WIFILI_STATS_RX_FRAG_INV_FC, - /**< Number of fragments with invalid frame control. */ - NSS_WIFILI_STATS_RX_FRAG_NON_FRAG, - /**< Number of non-fragments received in fragments. */ - NSS_WIFILI_STATS_RX_FRAG_RETRY, - /**< Number of retries for fragments. */ - NSS_WIFILI_STATS_RX_FRAG_OOO, - /**< Number of out-of-order fragments. */ - NSS_WIFILI_STATS_RX_FRAG_OOO_SEQ, - /**< Number of out-of-order sequence. */ - NSS_WIFILI_STATS_RX_FRAG_ALL_FRAG_RCV, - /**< Number of times all fragments for a sequence has been received. */ - NSS_WIFILI_STATS_RX_FRAG_DELIVER, - /**< Number of fragments delivered to host. */ - NSS_WIFILI_STATS_TX_ENQUEUE, - /**< Number of packets that got enqueued to wifili. */ - NSS_WIFILI_STATS_TX_ENQUEUE_DROP, - /**< Number of packets that dropped during enqueue to wifili. */ - NSS_WIFILI_STATS_TX_DEQUEUE, - /**< Number of packets that are dequeued by wifili. */ - NSS_WIFILI_STATS_TX_HW_ENQUEUE_FAIL, - /**< Number of Rx packets that NSS Wi-Fi offload path could successfully process. */ - NSS_WIFILI_STATS_TX_SENT_COUNT, - /**< Number of Tx packets sent to hardware. */ - NSS_WIFILI_STATS_TXRX_MAX, - /**< Number of maximum Tx or Rx statistics. */ -}; - -/* - * WARNING: There is a 1:1 mapping between values of enum nss_wifili_stats_tcl and corresponding - * statistics string array in nss_stats.c. - */ - -/** - * nss_wifili_stats_tcl - * Wifili transmit classifier statistics. - */ -enum nss_wifili_stats_tcl { - NSS_WIFILI_STATS_TCL_NO_HW_DESC, /**< Number of transmit classifier hardware descriptor. */ - NSS_WIFILI_STATS_TCL_RING_FULL, /**< Number of times transmit classifier ring was full. */ - NSS_WIFILI_STATS_TCL_RING_SENT, /**< Number of times transmit classifier descriptor sent. */ - NSS_WIFILI_STATS_TCL_MAX, /**< Number of maximum transmit classifier statistics. */ -}; - -/* - * WARNING: There is a 1:1 mapping between values of enum nss_wifili_stats_tx_comp and corresponding - * statistics string array in nss_stats.c. - */ - -/** - * nss_wifili_stats_tx_comp - * Wifili Tx completion statistics. - */ -enum nss_wifili_stats_tx_comp { - NSS_WIFILI_STATS_TX_DESC_FREE_INV_BUFSRC, /**< Number of invalid buffer source packets. */ - 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_DESC_FREE_MAX, /**< Number of Tx completion statistics. */ -}; - -/* - * WARNING: There is a 1:1 mapping between values of enum nss_wifili_stats_reo and corresponding - * statistics string array in nss_stats.c. - */ - -/** - * nss_wifili_stats_reo - * Wifili Rx reorder statistics. - */ -enum nss_wifili_stats_reo { - NSS_WIFILI_STATS_REO_ERROR, /**< Number of reorder error. */ - NSS_WIFILI_STATS_REO_REAPED, /**< Number of reorder reaped. */ - NSS_WIFILI_STATS_REO_INV_COOKIE, /**< Number of invalid cookie. */ - NSS_WIFILI_STATS_REO_FRAG_RCV, /**< Number of fragmented packets received. */ - NSS_WIFILI_STATS_REO_MAX, /**< Number of reorder statistics. */ -}; - -/* - * WARNING: There is a 1:1 mapping between values of enum nss_wifili_stats_txsw_pool and corresponding - * statistics string array in nss_stats.c. - */ - -/** - * nss_wifili_stats_txsw_pool - * Wifili Tx descriptor statistics. - */ -enum nss_wifili_stats_txsw_pool { - NSS_WIFILI_STATS_TX_DESC_IN_USE, /**< Number of Tx packets that are currently in flight. */ - NSS_WIFILI_STATS_TX_DESC_ALLOC_FAIL, /**< Number of Tx software descriptor allocation failures. */ - NSS_WIFILI_STATS_TX_DESC_ALREADY_ALLOCATED, /**< Number of Tx software descriptor already allocated. */ - NSS_WIFILI_STATS_TX_DESC_INVALID_FREE, /**< Number of Tx software descriptor invalid free. */ - NSS_WIFILI_STATS_TX_DESC_FREE_SRC_FW, /**< Number of Tx descriptor for which release source is firmware. */ - NSS_WIFILI_STATS_TX_DESC_FREE_COMPLETION, /**< Number of Tx descriptor completion. */ - NSS_WIFILI_STATS_TX_DESC_NO_PB, /**< Number of Tx descriptor pbuf is NULL. */ - NSS_WIFILI_STATS_TX_QUEUELIMIT_DROP, /**< Number of Tx dropped because of queue limit. */ - NSS_WIFILI_STATS_TX_DESC_MAX, /**< Number of Tx descriptor statistics. */ -}; - -/* - * WARNING: There is a 1:1 mapping between values of enum nss_wifili_stats_ext_txsw_pool and corresponding - * statistics string array in nss_stats.c - */ - -/** - * nss_wifili_stats_ext_txsw_pool - * Wifili Rx extended descriptor statistics. - */ -enum nss_wifili_stats_ext_txsw_pool { - NSS_WIFILI_STATS_EXT_TX_DESC_IN_USE, /**< Number of extended Tx packets that are currently in flight. */ - NSS_WIFILI_STATS_EXT_TX_DESC_ALLOC_FAIL, /**< Number of extended Tx software descriptor allocation failures. */ - NSS_WIFILI_STATS_EXT_TX_DESC_ALREADY_ALLOCATED, /**< Number of extended Tx software descriptor already allocated. */ - NSS_WIFILI_STATS_EXT_TX_DESC_INVALID_FREE, /**< Number of extended Tx software descriptor invalid free. */ - NSS_WIFILI_STATS_EXT_TX_DESC_MAX, /**< Number of extended Tx descriptor statistics. */ -}; - -/* - * WARNING: There is a 1:1 mapping between values of enum nss_wifili_stats_rxdma_pool and corresponding - * statistics string array in nss_stats.c - */ - -/** - * nss_wifili_stats_rxdma_pool - * Wifili Rx descriptor statistics. - */ -enum nss_wifili_stats_rxdma_pool { - NSS_WIFILI_STATS_RX_DESC_NO_PB, /**< Number of Rx descriptors that have no pbufs. */ - NSS_WIFILI_STATS_RX_DESC_ALLOC_FAIL, /**< Number of Rx descriptor allocation failures. */ - NSS_WIFILI_STATS_RX_DESC_IN_USE, /**< Number of Rx descriptor allocations in use. */ - NSS_WIFILI_STATS_RX_DESC_MAX, /**< Maximum number of Rx descriptor statistics. */ -}; - -/* - * WARNING: There is a 1:1 mapping between values of enum nss_wifili_stats_rxdma_ring and corresponding - * statistics string array in nss_stats.c. - */ - -/** - * nss_wifili_stats_rxdma_ring - * Wifili Rx DMA(Direct Memory Access) ring statistics. - */ -enum nss_wifili_stats_rxdma_ring { - NSS_WIFILI_STATS_RXDMA_DESC_UNAVAILABLE, /**< Number of Rx DMA descriptor unavailable. */ - NSS_WIFILI_STATS_RXDMA_BUF_REPLENISHED, /**< Number of Rx DMA buffer replenished. */ - NSS_WIFILI_STATS_RXDMA_DESC_MAX, /**< Number of Rx DMA descriptor statistics. */ -}; - -/* - * WARNING: There is a 1:1 mapping between values of enum nss_wifili_stats_wbm and corresponding - * statistics string array in nss_stats.c. - */ - -/** - * nss_wifili_stats_wbm - * 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 - * NSS wifili statistics. - */ -struct nss_wifili_stats { - uint64_t stats_txrx[NSS_WIFILI_MAX_PDEV_NUM_MSG][NSS_WIFILI_STATS_TXRX_MAX]; - /**< Number of Tx or Rx statistics. */ - uint64_t stats_tcl_ring[NSS_WIFILI_MAX_TCL_DATA_RINGS_MSG][NSS_WIFILI_STATS_TCL_MAX]; - /**< TCL statistics for each ring. */ - uint64_t stats_tx_comp[NSS_WIFILI_MAX_TCL_DATA_RINGS_MSG][NSS_WIFILI_STATS_TX_DESC_FREE_MAX]; - /**< Tx completion ring statistics. */ - uint64_t stats_tx_desc[NSS_WIFILI_MAX_TXDESC_POOLS_MSG][NSS_WIFILI_STATS_TX_DESC_MAX]; - /**< Tx descriptor pool statistics. */ - uint64_t stats_ext_tx_desc[NSS_WIFILI_MAX_TX_EXT_DESC_POOLS_MSG][NSS_WIFILI_STATS_EXT_TX_DESC_MAX]; - /**< Tx extended descriptor pool statistics. */ - uint64_t stats_reo[NSS_WIFILI_MAX_REO_DATA_RINGS_MSG][NSS_WIFILI_STATS_REO_MAX]; - /**< Rx reorder ring statistics. */ - uint64_t stats_rx_desc[NSS_WIFILI_MAX_PDEV_NUM_MSG][NSS_WIFILI_STATS_RX_DESC_MAX]; - /**< Rx software pool statistics. */ - uint64_t stats_rxdma[NSS_WIFILI_MAX_PDEV_NUM_MSG][NSS_WIFILI_STATS_RXDMA_DESC_MAX]; - /**< Rx DMA ring statistics. */ - uint64_t stats_wbm[NSS_WIFILI_STATS_WBM_MAX]; - /**< Wireless Buffer Manager error ring statistics. */ -}; - -/* - * NSS wifili soc stats - */ -struct nss_wifili_soc_stats { - uint32_t soc_maxpdev; /**< Maximum number of radios per SoC. */ - struct nss_wifili_stats stats_wifili; - /**< Per-SoC statistics. */ -}; - -/** - * nss_wifili_stats_notification - * Data for sending wifili statistics. - */ -struct nss_wifili_stats_notification { - uint32_t core_id; /**< Core ID. */ - uint32_t if_num; /**< Interface number for this wifili. */ - struct nss_wifili_stats stats; /**< Wifili statistics. */ -}; - -#ifdef __KERNEL__ /* only kernel will use. */ - -/** - * nss_wifili_hal_srng_info - * Wifili HAL srng information. - */ -struct nss_wifili_hal_srng_info{ - uint8_t ring_id; - /**< Ring ID. */ - uint8_t mac_id; - /**< Pdev ID. */ - uint8_t resv[2]; - uint32_t ring_base_paddr; - /**< Physical base address of the ring. */ - uint32_t num_entries; - /**< Number of entries in ring. */ - uint32_t flags; /**< Miscellaneous flags. */ - uint32_t ring_dir; - /**< Ring direction: source or destination. */ - uint32_t entry_size; - /**< Ring entry size. */ - uint32_t low_threshold; - /**< Low threshold – in number of ring entries (valid for source rings only). */ - uint32_t hwreg_base[NSS_WIFILI_MAX_SRNG_REG_GROUPS_MSG]; - /**< Hardware ring base address. */ -}; - -/** - * nss_wifili_hal_srng_soc_msg - * Wifili hal srng message. - */ -struct nss_wifili_hal_srng_soc_msg { - uint32_t dev_base_addr; - /**< Base address of WLAN device. */ - 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. */ -}; - -/** - * struct wifili_tx_desc_addtnl_mem_msg - * Wifili additional host memory message for increeased descriptors - */ -struct nss_wifili_tx_desc_addtnl_mem_msg { - uint32_t num_addtnl_addr; - /**< Number of additional memory pages provided. */ - uint32_t addtnl_memory_addr[NSS_WIFILI_MAX_NUMBER_OF_ADDTNL_SEG]; - /**< Physical memory addresse of each additional page. */ - uint32_t addtnl_memory_size[NSS_WIFILI_MAX_NUMBER_OF_ADDTNL_SEG]; - /**< Size of each additional page. */ -}; - -/** - * nss_wifili_tx_desc_init_msg - * Wifili software descriptor pool initialization message. - */ -struct nss_wifili_tx_desc_init_msg { - uint32_t num_tx_desc; - /**< Count of the software descriptors. */ - uint32_t num_tx_desc_ext; - /**< Count of software extented descriptors. */ - uint32_t num_pool; - /**< Number of descriptor pools. */ - uint32_t memory_addr[NSS_WIFILI_MAX_NUMBER_OF_PAGE_MSG]; - /**< Memory start address of each page. */ - uint32_t memory_size[NSS_WIFILI_MAX_NUMBER_OF_PAGE_MSG]; - /**< Memory size. */ - uint32_t num_memaddr; - /**< Number of memory address. */ - uint32_t ext_desc_page_num; - /**< Extended descriptor page number. */ - uint32_t num_tx_desc_2; - /**< Count of the software descriptors for second radio. */ - uint32_t num_tx_desc_ext_2; - /**< Count of software extended descriptors for second radio. */ - uint32_t num_tx_desc_3; - /**< Count of the software descriptors for third radio. */ - uint32_t num_tx_desc_ext_3; - /**< Count of software extended descriptors for third radio. */ - uint32_t num_tx_device_limit; - /**< Count of software Tx descriptors for the device. */ -}; - -/** - * nss_wifili_rx_init_param - * Rx initialization parameters. - */ -struct nss_wifili_rx_init_param { - uint16_t tlv_size; /**< Size of Rx TLV structure. */ - uint16_t rx_buf_len; /**< Rx buffer length programmed to hardware. */ -}; - -/** - * nss_wifili_init_msg - * Wifili SoC initialization message. - */ -struct nss_wifili_init_msg { - struct nss_wifili_hal_srng_soc_msg hssm; - uint8_t num_tcl_data_rings; - /**< Number of Transmit Classifier data rings. */ - uint8_t num_reo_dest_rings; - /**< Number of Rx reorder rings. */ - uint8_t flags; - /**< Flags for SoC initialization */ - uint8_t soc_mem_profile; - /**< SoC memory profile (256M/512M/1G). */ - struct nss_wifili_hal_srng_info tcl_ring_info[NSS_WIFILI_MAX_TCL_DATA_RINGS_MSG]; - /**< Transmit Classifier data ring configuration information. */ - struct nss_wifili_hal_srng_info tx_comp_ring[NSS_WIFILI_MAX_TCL_DATA_RINGS_MSG]; - /**< Tx completion ring configuration information. */ - struct nss_wifili_hal_srng_info reo_dest_ring[NSS_WIFILI_MAX_REO_DATA_RINGS_MSG]; - /**< Rx reorder destination ring configuration information. */ - struct nss_wifili_hal_srng_info reo_exception_ring; - /**< Rx reorder exception ring configuration information. */ - struct nss_wifili_hal_srng_info rx_rel_ring; - /**< Wireless Buffer Manager release ring configuration information. */ - struct nss_wifili_hal_srng_info reo_reinject_ring; - /**< Reinject ring configuration information. */ - struct nss_wifili_tx_desc_init_msg wtdim; - /**< Tx descriptor initialization message. */ - uint32_t target_type; - /**< Target type based on SoC. */ - struct nss_wifili_rx_init_param wrip; - /**< Rx parameters to initialize Rx context. */ - struct nss_wifili_tx_desc_addtnl_mem_msg wtdam; - /**< Tx descriptor additional memory message. */ - uint32_t tx_sw_internode_queue_size; - /**< Tx software internode queue size. */ -}; - -/** - * nss_wifili_pdev_deinit_msg - * Wifili pdev deinit message. - */ -struct nss_wifili_pdev_deinit_msg { - uint32_t ifnum; /**< NSS interface number of pdev. */ -}; - -/** - * nss_wifili_pdev_init_msg - * Wifili pdev initialization message. - */ -struct nss_wifili_pdev_init_msg { - struct nss_wifili_hal_srng_info rxdma_ring; - /**< MAC (Media Access Control) ring configuration. */ - uint32_t radio_id; - /**< MAC radio ID. */ - uint32_t hwmode; - /**< MAC hardware mode. */ - uint32_t lmac_id; - /**< Lower MAC ID. */ - uint32_t num_rx_swdesc; - /**< 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. */ -}; - -/** - * nss_wifili_peer_ast_flowid_map_msg - * Wifili peer AST flow ID map message. - */ -struct nss_wifili_peer_ast_flowid_map_msg { - uint8_t peer_mac_addr[ETH_ALEN]; - /**< Peer MAC address. */ - uint16_t vdev_id; - /**< VAP ID. */ - uint16_t ast_idx[NSS_WIFILI_PEER_AST_FLOWQ_MAX]; - /**< Address search table index. */ - uint8_t tid_valid_mask[NSS_WIFILI_PEER_AST_FLOWQ_MAX]; - /**< TID valid mask for a flow. */ - uint8_t is_valid[NSS_WIFILI_PEER_AST_FLOWQ_MAX]; - /**< Valid bit. */ - uint8_t flowQ[NSS_WIFILI_PEER_AST_FLOWQ_MAX]; - /**< Flow queue. */ - uint16_t peer_id; - /**< Peer ID. */ - uint8_t reserved[2]; - /**< Padding for alignment. */ -}; - -/** - * nss_wifili_peer_ast - * Wifili peer creation message. - */ -struct nss_wifili_peer_msg { - uint8_t peer_mac_addr[6]; - /**< Peer MAC address. */ - uint16_t vdev_id; - /**< VAP ID. */ - uint16_t peer_id; - /**< Peer ID. */ - uint16_t hw_ast_idx; - /**< Hardware address search table index. */ - uint8_t is_nawds; - /**< NAWDS enabled for peer. */ - 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. */ - uint32_t flags; - /**< Peer flags. */ -}; - -/** - * nss_wifili_peer_freelist_append_msg - * Peer memory request. - */ -struct nss_wifili_peer_freelist_append_msg { - uint32_t addr; - /**< Starting address of peer_freelist pool. */ - uint32_t length; - /**< Length of peer freelist pool. */ - uint32_t num_peers; - /**< Maximum number of peer entries supported in pool. */ -}; - -/** - * nss_wifili_wds_extn_peer_cfg_msg - * Configuration information when the WDS vendor extension is enabled. - */ -struct nss_wifili_wds_extn_peer_cfg_msg { - uint8_t peer_mac_addr[ETH_ALEN]; /**< Peer MAC address. */ - uint8_t wds_flags; /**< WDS flags populated from the host. */ - uint8_t reserved; /**< Alignment padding. */ - uint16_t peer_id; /**< Peer ID. */ -}; - -/** - * nss_wifili_tx_stats - * Tx statistics. - */ -struct nss_wifili_tx_stats { - uint32_t tx_enqueue_dropped; - /**< Tx enqueue drop count. */ - uint32_t tx_enqueue_cnt; - /**< Tx enqueue succesful count. */ - uint32_t tx_dequeue_cnt; - /**< Tx dequeue count. */ - uint32_t tx_send_fail_cnt; - /**< Hardware send failure count. */ - uint32_t inv_peer; - /**< Invalid peer enqueue count. */ - uint32_t inv_peer_drop_byte_cnt; - /**< Invalid peer drop byte count. */ - uint32_t tx_input_pkt; - /**< Tx packets ready to sent. */ - uint32_t tx_processed_pkt; - /**< Tx numner of packets sent. */ - uint32_t tx_processed_bytes; - /**< Tx number of bytes processed. */ -}; - -/** - * nss_wifili_rx_stats - * Rx statistics. - */ -struct nss_wifili_rx_stats { - uint32_t rx_msdu_err; - /**< Rx msdu error count. */ - uint32_t rx_inv_peer; - /**< Rx invalid peer count. */ - uint32_t rx_scatter_inv_peer; - /**< Rx scatter invalid peer count. */ - uint32_t rx_wds_learn_send; - /**< WDS source port learn packet. */ - uint32_t rx_wds_learn_send_fail; - /**< WDS source port learn exception send failure count. */ - uint32_t rx_send_dropped; - /**< Rx send dropped count. */ - uint32_t rx_deliver_cnt; - /**< Rx deliver count to next node. */ - uint32_t rx_deliver_cnt_fail; - /**< Rx deliver count failure. */ - uint32_t rx_intra_bss_ucast_send; - /**< Intra-BSS unicast sent count. */ - uint32_t rx_intra_bss_ucast_send_fail; - /**< Intra-BSS unicast send failure count. */ - uint32_t rx_intra_bss_mcast_send; - /**< Intra-BSS multicast send count. */ - uint32_t rx_intra_bss_mcast_send_fail; - /**< Intra-BSS multicast send failure count. */ - uint32_t rx_sg_recv_send; - /**< Rx scatter-gather receive send count. */ - uint32_t rx_sg_recv_fail; - /**< Rx scatter-gather receive failure count. */ - uint32_t rx_me_pkts; /**< Rx multicast echo packets count. */ - uint32_t rx_inv_tid; /**< Rx invalid TID. */ - - /* - * TODO: Move per tid based. - */ - uint32_t rx_frag_inv_sc; /**< Rx invalid frame sequence control. */ - uint32_t rx_frag_inv_fc; /**< Rx invalid frame control count. */ - uint32_t rx_non_frag_err; /**< Rx non-fragment received in fragmention. */ - uint32_t rx_repeat_fragno; /**< Rx fragment retry counters. */ - uint32_t rx_ooo_frag; /**< Rx out-of-order fragments count. */ - uint32_t rx_ooo_frag_seq; /**< Rx out-of-order sequence count. */ - uint32_t rx_all_frag_rcv; /**< Rx all fragments received count. */ - uint32_t rx_frag_deliver; /**< Rx fragment deliver counters. */ -}; - -/** - * nss_wifili_tx_tcl_ring_stats - * Transmit Classifier ring specific statistics. - */ -struct nss_wifili_tx_tcl_ring_stats { - uint32_t tcl_no_hw_desc; /**< Number of Transmit Classifier hardware descriptors. */ - uint32_t tcl_ring_full; /**< Number of times Transmit Classifier ring full. */ - uint32_t tcl_ring_sent; /**< Total number of ring sent. */ -}; - -/** - * nss_wifili_tx_comp_ring_stats - * Tx completion ring statistics. - */ -struct nss_wifili_tx_comp_ring_stats { - 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. */ -}; - -/** - * nss_wifili_tx_sw_pool_stats - * Tx completion sw statistics. - */ -struct nss_wifili_tx_sw_pool_stats { - uint32_t desc_alloc; /**< Tx descriptor software pool descriptor in use. */ - uint32_t desc_alloc_fail; /**< Tx descriptor software pool allocation failure . */ - uint32_t desc_already_allocated; /**< Tx descriptor re-allocation for allocated descriptor. */ - uint32_t desc_invalid_free; /**< Tx descriptor freeing of allocated descriptor. */ - uint32_t tx_rel_src_fw; /**< Tx descriptor source is firmware. */ - uint32_t tx_rel_ext_desc; /**< Tx descriptor scatter-gather. */ - uint32_t tx_rel_tx_desc; /**< Tx descriptor source is hardware*/ - uint32_t tx_rel_no_pb; /**< Tx descriptor has pbuf present. */ - uint32_t tx_queue_limit_drop; /**< Tx number of packets dropped because of queueing limits. */ -}; - -/** - * wifili_tx_ext_sw_pool_stats - * Tx extended descriptor pool. - */ -struct nss_wifili_tx_ext_sw_pool_stats { - uint32_t desc_alloc; /**< Tx extend (scatter gather) descriptor in use. */ - uint32_t desc_alloc_fail; /**< Tx extend descriptor allocation failure. */ - uint32_t desc_already_allocated; /**< Tx extend descriptor already allocated. */ - uint32_t desc_invalid_free; /**< Tx descriptor invalid source. */ - -}; - -/** - * nss_wifili_rx_wbm_ring_stats - * WBM (Wireless Buffer Manager) release ring statistics. - */ -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_invalid; /**< Wireless Buffer Manager source is unknown. */ - uint32_t err_reo_codes[NSS_WIFILI_REO_CODE_MAX]; - /**< Receive 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. */ -}; - -/** - * nss_wifili_rx_reo_ring_stats - * Rx reorder error statistics. - */ -struct nss_wifili_rx_reo_ring_stats { - uint32_t ring_error; /**< Rx reorder ring error. */ - uint32_t ring_reaped; /**< Number of ring descriptor reaped. */ - uint32_t invalid_cookie; /**< Number of invalid cookie. */ - uint32_t defrag_reaped; /**< Rx defragment receive count. */ -}; - -/** - * nss_wifili_rx sw_pool_stats - * Wifili DMA sw pool statistics. - */ -struct nss_wifili_rx_sw_pool_stats { - uint32_t rx_no_pb; /**< Rx software descriptor number of buffer available. */ - uint32_t desc_alloc; /**< Number of descriptor in use. */ - uint32_t desc_alloc_fail; /**< Number of descriptor allocation failure. */ -}; - -/** - * nss_wifili_rx_dma_ring_stats - * Wifili Rx DMA ring statistics. - */ -struct nss_wifili_rx_dma_ring_stats { - uint32_t rx_hw_desc_unavailable; /**< Number of times hardware descriptor is unavailable. */ - uint32_t rx_buf_replenished; /**< Number of buffers replenished. */ -}; - -/** - * nss_wifili_dbdc_mode_stats - * Wifili DBDC mode statistics. - */ -struct nss_wifili_dbdc_mode_stats { - uint32_t dbdc_flush_ast_failed; - /**< Number of times DBDC AST flush message send has failed. */ - uint32_t dbdc_drop_rx_secmcast; - /**< Number of packets dropped in DBDC Rx for secondary multicast. */ - uint32_t dbdc_drop_tx_secmcast; - /**< Number of packets dropped in DBDC Tx for secondary multicast. */ - uint32_t dbdc_drop_rx_alwaysprimary; - /**< Number of packets dropped in DBDC Rx for always primary. */ - uint32_t dbdc_drop_tx_alwaysprimary; - /**< Number of packets dropped in DBDC Tx for always primary. */ - uint32_t dbdc_drop_loop_rx; - /**< Number of packets dropped in DBDC Rx for DBDC loop. */ - uint32_t dbdc_drop_loop_tx; - /**< Number of packets dropped in DBDC Tx for DBDC loop. */ -}; - -/** - * nss_wifili_delay_stats - * Wifili delay statistics. - */ -struct nss_wifili_delay_stats { - uint32_t delay_bucket[NSS_WIFILI_DELAY_INDEX_MAX]; - /**< Delay buckets for histogram. */ - uint32_t min_delay; - /**< Minimum delay. */ - uint32_t avg_delay; - /**< Average delay. */ - uint32_t max_delay; - /**< Maximum delay. */ -}; - -/** - * nss_wifili_v3_delay_per_tid_stats - * Wifili version 3 delay per TID statistics. - */ -struct nss_wifili_v3_delay_per_tid_stats { - struct nss_wifili_delay_stats swq_delay; - /**< Software enqueue delay. */ - struct nss_wifili_delay_stats hwtx_delay; - /**< Hardware transmit delay. */ - struct nss_wifili_delay_stats tx_intfrm_delay; - /**< Transmit interframe delay at radio entry. */ - struct nss_wifili_delay_stats rx_intfrm_delay; - /**< Receive interframe delay. */ -}; - -/** - * nss_wifili_v3_per_tid_tx_rx_stats - * Wifili version 3 Tx and Rx statistics per TID. - */ -struct nss_wifili_v3_tx_rx_per_tid_stats { - uint32_t radio_ingress_enq_drop_cnt; - /**< Ingress enqueue drop count. */ - uint32_t transmit_succes_cnt; - /**< Total successful transmit count. */ - uint32_t transmit_fwdrop_cnt; - /**< Firmware drop count. */ - uint32_t transmit_hwdrop_cnt; - /**< Hardware drop count. */ - uint32_t transmit_desc_fail_cnt; - /**< Transmit descriptor fail count. */ - uint32_t transmit_complete_cnt; - /**< Total transmit count. */ - uint32_t rx_delivered_cnt; - /**< Total Rx packets delivered to next node. */ - uint32_t rx_deliver_fail_cnt; - /**< Rx deliver fail count. */ - uint32_t rx_intrabss_cnt; - /**< Intra-BSS Rx count. */ - uint32_t rx_intrabss_fail_cnt; - /**< Intra-BSS Rx fail count. */ - uint32_t num_msdu_recived; - /**< Number of MSDU received from hardware. */ - uint32_t num_mcast_msdu_recived; - /**< Number of broadcast MSDU received. */ - uint32_t num_bcast_msdu_recived; - /**< Number of multicast MSDU received. */ - uint32_t transmit_tqm_status_cnt[NSS_WIFILI_TQM_STATUS_MAX]; - /**< Number of frames with this TQM completion status. */ - uint32_t transmit_htt_status_cnt[NSS_WIFILI_HTT_STATUS_MAX]; - /**< Number of frames with this HTT completion status. */ -}; - -/** - * nss_wifili_v3_tx_rx_per_ac_stats - * Wifili version 3 Tx and Rx statistics per AC. - */ -struct nss_wifili_v3_tx_rx_per_ac_stats { - uint32_t radio_ingress_enq_cnt; - /**< Ingress enqueue packet count. */ - uint32_t radio_ingress_deq_cnt; - /**< Ingress dequeue count. */ - uint32_t transmit_enq_cnt; - /**< Transmit enqueue count. */ -}; - -/** - * nss_wifili_radio_tx_rx_stats_v3 - * Wifili version 3 radio Tx and Rx statistics. - */ -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. */ - struct nss_wifili_v3_tx_rx_per_ac_stats ac_stats[NSS_WIFILI_WME_AC_MAX]; - /**< Per-Access Category Tx and Rx statistics. */ -}; - -/** - * nss_wifili_radio_delay_stats_v3 - * Wifili version 3 radio delay statistics. - */ -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. */ -}; - -/** - * nss_wifili_pdev_v3_tx_rx_stats_sync_msg - * Wifili message to synchronize version 3 Tx and Rx statistics to HLOS. - */ -struct nss_wifili_pdev_v3_tx_rx_stats_sync_msg { - uint32_t radio_id; - /**< Radio ID. */ - struct nss_wifili_radio_tx_rx_stats_v3 wlpv3_txrx_stats; - /**< Wifli version 3 Tx and Rx statistics. */ -}; - -/** - * nss_wifili_pdev_v3_delay_stats_sync_msg - * Wifili message to synchronize version 3 delay statistics to HLOS. - */ -struct nss_wifili_pdev_v3_delay_stats_sync_msg { - uint32_t radio_id; - /**< Radio ID. */ - struct nss_wifili_radio_delay_stats_v3 wlpv3_delay_stats; - /**< Wifli version 3 delay statistics. */ -}; - -/** - * nss_wifili_device_stats - * Wifili specific statistics. - */ -struct nss_wifili_device_stats { - struct nss_wifili_tx_tcl_ring_stats tcl_stats[NSS_WIFILI_MAX_TCL_DATA_RINGS_MSG]; - /**< Transmit Classifier ring statistics. */ - struct nss_wifili_tx_comp_ring_stats txcomp_stats[NSS_WIFILI_MAX_TCL_DATA_RINGS_MSG]; - /**< Tx completion ring statistics. */ - struct nss_wifili_tx_sw_pool_stats tx_sw_pool_stats[NSS_WIFILI_MAX_TXDESC_POOLS_MSG]; - /**< Tx software pool statistics. */ - struct nss_wifili_tx_ext_sw_pool_stats tx_ext_sw_pool_stats[NSS_WIFILI_MAX_TX_EXT_DESC_POOLS_MSG]; - /**< Tx extended software pool statistics. */ - struct nss_wifili_tx_stats tx_data_stats[NSS_WIFILI_MAX_PDEV_NUM_MSG]; - /**< Tx data statistics for each pdev. */ - struct nss_wifili_rx_reo_ring_stats rxreo_stats[NSS_WIFILI_MAX_REO_DATA_RINGS_MSG]; - /**< Rx reorder ring statistics. */ - struct nss_wifili_rx_sw_pool_stats rx_sw_pool_stats[NSS_WIFILI_MAX_PDEV_NUM_MSG]; - /**< Rx DMA software pool statistics. */ - struct nss_wifili_rx_stats rx_data_stats[NSS_WIFILI_MAX_PDEV_NUM_MSG]; - /**< Rx data statistics for each pdev. */ - struct nss_wifili_rx_dma_ring_stats rxdma_stats[NSS_WIFILI_MAX_PDEV_NUM_MSG]; - /**< Rx DMA ring statistics. */ - struct nss_wifili_rx_wbm_ring_stats rxwbm_stats; - /**< Wireless Buffer Manager ring statistics. */ - struct nss_wifili_dbdc_mode_stats dbdc_stats; - /**< DBDC mode statistics. */ -}; - -/** - * nss_wifili_stats_sync_msg - * Wifili SoC statistics synchronization message. - */ -struct nss_wifili_stats_sync_msg { - struct nss_wifili_device_stats stats; - /**< Device statistics. */ -}; - -/** - * nss_wifili_soc_linkdesc_per_packet_metadata - * Link descriptor per packet metadata. - */ -struct nss_wifili_soc_linkdesc_per_packet_metadata -{ - uint32_t desc_addr; /**< Link descriptor address. */ -}; - -/** - * nss_wifili_soc_per_packet_metadata - * Per packet special data that has to be sent to host. - */ -struct nss_wifili_soc_per_packet_metadata { - uint16_t pkt_type; /**< Packet type. */ - uint8_t pool_id; /**< Pool ID of invalid peer packets. */ - uint8_t reserved; /**< Alignment padding. */ - - /** - * Link descriptor per packet metadata. - */ - union { - struct nss_wifili_soc_linkdesc_per_packet_metadata linkdesc_metadata; - } metadata; /**< Per packet link descriptor metadata. */ -}; - -/** - * nss_wifili_tx_dropped - * Tx peer dropped packets. - */ -struct nss_wifili_tx_dropped { - uint32_t drop_stats[NSS_WIFILI_TQM_RR_MAX]; /**< Discarded by firmware. */ - uint32_t tx_nawds_mcast_drop_cnt; /**< Total number of NAWDS multicast packets dropped. */ -}; - -/** - * nss_wifili_tx_ctrl_stats - * Tx peer statistics. - */ -struct nss_wifili_tx_ctrl_stats { - uint32_t ofdma; /**< Number of orthogonal frequency-division multiple - access packets. */ - uint32_t non_amsdu_cnt; /**< Number of MSDUs with no MSDU level aggregation. */ - uint32_t amsdu_cnt; /**< Number of MSDUs part of AMSDU. */ - uint32_t tx_mcast_cnt; /**< Total number of multicast packets sent. */ - uint32_t tx_mcast_bytes; /**< Total number of multicast bytes sent. */ - uint32_t tx_ucast_cnt; /**< Total number of unicast packets sent. */ - uint32_t tx_ucast_bytes; /**< Total number of unicast bytes sent. */ - uint32_t tx_bcast_bytes; /**< Total number of broadcast bytes sent. */ - uint32_t tx_bcast_cnt; /**< Total number of broadcast packets sent. */ - struct nss_wifili_tx_dropped dropped; /**< Tx peer dropped. */ - uint32_t tx_success_cnt; /**< Total number of packets sent successfully. */ - uint32_t tx_success_bytes; /**< Total number of bytes sent successfully. */ - uint32_t tx_nawds_mcast_cnt; /**< Total number of NAWDS multicast packets sent. */ - uint32_t tx_nawds_mcast_bytes; /**< Total number of NAWDS multicast bytes sent. */ - uint32_t retries; /**< Total number of retries. */ -}; - -/** - * nss_wifili_peer_rx_err - * Rx peer errors. - */ -struct nss_wifili_rx_err { - uint32_t mic_err; /**< Rx MIC errors. */ - uint32_t decrypt_err; /**< Rx Decryption errors. */ -}; - -/** - * nss_wifili_rx_ctrl_stats - * Peer Rx statistics. - */ -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. */ - uint32_t mcast_rcv_cnt; /**< Total number of multicast packets received. */ - uint32_t mcast_rcv_bytes; /**< Total number of multicast bytes received. */ - uint32_t rx_recvd; /**< Total Rx received count. */ - uint32_t rx_recvd_bytes; /**< Total Rx received count. */ - uint32_t nawds_mcast_drop; /**< Total NAWDS drop count. */ - uint32_t nawds_mcast_drop_bytes; /**< Total NAWDS drop count. */ - uint32_t rx_intra_bss_pkts_num; /**< Total Intra-BSS packets received. */ - uint32_t rx_intra_bss_pkts_bytes; /**< Total Intra-BSS bytes received. */ - uint32_t rx_intra_bss_fail_num; /**< Total Intra-BSS packets failed. */ - 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. */ -}; - -/** - * nss_wifili_peer_ctrl_stats - * Wifili peer control statistics. - */ -struct nss_wifili_peer_ctrl_stats { - uint32_t peer_id; /**< Peer ID. */ - struct nss_wifili_tx_ctrl_stats tx; - /**< Peer Tx control statistics. */ - struct nss_wifili_rx_ctrl_stats rx; - /**< Peer Rx control statistics. */ -}; - -/** - * nss_wifili peer_stats - * Wifili peer statistics. - */ -struct nss_wifili_peer_stats { - uint32_t npeers; /**< Number of entries of peer statistics. */ - struct nss_wifili_peer_ctrl_stats wpcs[1]; - /**< Wifili peer control statistics. */ -}; - -/** - * nss_wifili_peer_stats_msg - * Wifili peer statistics message. - */ -struct nss_wifili_peer_stats_msg { - struct nss_wifili_peer_stats stats; - /**< Wifili peer statistics. */ -}; - -/** - * nss_wifili_sojourn_per_tid_stats - * 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 num_msdus; /**< MSDUs per TID. */ -}; - -/** - * nss_wifili_sojourn_peer_stats - * Wifili sojourn peer statistics. - */ -struct nss_wifili_sojourn_peer_stats { - uint32_t peer_id; /**< Peer ID. **/ - struct nss_wifili_sojourn_per_tid_stats stats[NSS_WIFILI_MAX_TID]; /**< Statistics per TID. **/ -}; - -/** - * nss_wifili_sojourn_stats_msg - * Wifili sojourn statistics message. - */ -struct nss_wifili_sojourn_stats_msg { - uint32_t npeers; /**< Number of peers. */ - struct nss_wifili_sojourn_peer_stats sj_peer_stats[1]; /**< Per-peer sojourn statistics. */ -}; - -/* - * nss_wifili_jitter_tid_stats - * Per TID jitter statistics. - */ -struct nss_wifili_jitter_tid_stats { - uint32_t avg_jitter; /**< Average jitter. */ - uint32_t avg_delay; /**< Average delay. */ - uint32_t avg_err; /**< Average count error. */ - uint32_t success; /**< Transmit success count. */ - uint32_t drop; /**< Transmit drop count. */ -}; - -/* - * nss_wifili_jitter_stats - * Wifili jitter statistics. - */ -struct nss_wifili_jitter_stats { - uint32_t peer_id; /**< Peer ID. */ - struct nss_wifili_jitter_tid_stats stats[NSS_WIFILI_MAX_TID]; /**< Per-TID jitter statistics. */ -}; - -/* - * nss_wifili_jitter_stats_msg - * Wifili jitter message. - */ -struct nss_wifili_jitter_stats_msg { - uint32_t npeers; /**< Number of peers. */ - struct nss_wifili_jitter_stats jitter_stats[1]; /**< Jitter statistics. */ -}; - -/** - * nss_wifili_wds_peer_msg - * Wi-Fi Wireless distribution system (WDS) peer-specific message. - */ -struct nss_wifili_wds_peer_msg { - uint8_t dest_mac[ETH_ALEN]; /**< MAC address of the destination. */ - uint8_t peer_mac[ETH_ALEN]; /**< MAC address of the base peer. */ - uint8_t ast_type; /**< AST (Address Search Table) type for this peer. */ - uint8_t pdev_id; /**< Radio ID for next hop peer. */ - uint16_t peer_id; /**< Peer ID of next hop peer. */ -}; - -/** - * 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. - */ -struct nss_wifili_stats_cfg_msg { - uint32_t cfg; /**< Enable or disable configuration. */ -}; - -/** - * nss_wifili_wds_peer_map_msg - * Wi-Fi Wireless distribution system(WDS) peer-specific message. - */ -struct nss_wifili_wds_peer_map_msg { - uint8_t dest_mac[ETH_ALEN]; /**< MAC address of the destination. */ - uint16_t peer_id; /**< Connected peer ID for this WDS peer. */ - uint16_t ast_idx; /**< AST (address search table) index for this peer in host. */ - uint16_t vdev_id;; /**< VAP ID. */ -}; - -/** - * nss_wifili_wds_active_info - * Wi-Fi WDS active information. - */ -struct nss_wifili_wds_active_info { - uint16_t ast_idx; /**< Hardware AST index. */ -}; - -/** - * nss_wifili_wds_active_info_msg - * Wi-Fi Wireless distribution system active information message. - */ -struct nss_wifili_wds_active_info_msg { - uint16_t nentries; /**< Number of WDS entries. */ - struct nss_wifili_wds_active_info info[1]; - /**< WDS active information. */ -}; - -/** - * nss_wifili_mec_ageout_info - * Wi-Fi multicast echo check ageout information. - */ -struct nss_wifili_mec_ageout_info { - uint8_t mac_addr[6]; /**< MAC address. */ - uint8_t radio_id; /**< Radio ID. */ - uint8_t pad; /**< Pad for word align structure. */ - -}; - -/** - * nss_wifili_mec_ageout_info_msg - * Wi-Fi multicast echo check ageout information message. - */ -struct nss_wifili_mec_ageout_info_msg { - uint16_t nentries; /**< Number of entries. */ - struct nss_wifili_mec_ageout_info info[1]; - /**< Multicast echo check active information. */ -}; - -/** - * nss_wifili_soc_linkdesc_buf_info_msg - * Link descriptor buffer addresss information. - */ -struct nss_wifili_soc_linkdesc_buf_info_msg { - uint32_t buffer_addr_low; /**< Link descriptor low address. */ - uint32_t buffer_addr_high; /**< Link descriptor high address. */ -}; - -/** - * nss_wifili_peer_security_type_msg - * Wifili security type message. - */ -struct nss_wifili_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_WIFILI_MIC_KEY_LEN]; - /**< MIC key. */ -}; - -/** - * nss_wifili_peer_nawds_enable_msg - * Wifili NAWDS enable for this peer. - */ -struct nss_wifili_peer_nawds_enable_msg { - uint16_t peer_id; /**< Peer ID. */ - uint16_t is_nawds; /**< Enable NAWDS on this peer. */ -}; - -/** - * nss_wifili_peer_vlan_id_msg - * Wifili peer VLAN ID message. - */ -struct nss_wifili_peer_vlan_id_msg { - uint16_t peer_id; /**< Peer ID. */ - uint16_t vlan_id; /**< VLAN ID. */ -}; - -/** - * 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_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. - */ -struct nss_wifili_dbdc_repeater_set_msg { - uint32_t is_dbdc_en; /**< DBDC enable flag. */ -}; - -/** - * nss_wifili_hmmc_dscp_tid_set_msg - * Wifili Hy-Fi managed multicast DSCP TID set message. - */ -struct nss_wifili_hmmc_dscp_tid_set_msg { - uint16_t radio_id; /**< Radio ID. */ - uint16_t value; /**< Hy-Fi managed multicast TID value. */ -}; - -/** - * nss_wifili_hmmc_dscp_override_set_msg - * Wifili Hy-Fi managed multicast DSCP override set message. - */ -struct nss_wifili_hmmc_dscp_override_set_msg { - uint16_t radio_id; /**< Radio ID. */ - uint16_t value; /**< Hy-Fi managed multicast DSCP override value. */ -}; - -/** - * nss_wifili_reo_tidq_msg - * Rx reorder TID queue setup message. - */ -struct nss_wifili_reo_tidq_msg { - uint32_t tid; /**< TID (traffic identification) value. */ - uint16_t peer_id; /**< Peer ID. */ -}; - -/** - * nss_wifili_enable_v3_stats_msg - * Version 3 statistics enable message. - */ -struct nss_wifili_enable_v3_stats_msg { - uint32_t radio_id; /**< Radio ID. */ - uint32_t flag; /**< Flag to enable version 3 statistics. */ -}; - -/** - * 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_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. - */ -struct nss_wifili_update_pdev_lmac_id_msg { - uint32_t pdev_id; /**< Physical device ID. */ - uint32_t lmac_id; /**< Lower MAC ID. */ - uint32_t target_pdev_id; /**< Target physical device ID. */ -}; - -/** - * nss_wifili_radio_cmd_msg - * Wi-Fi radio specific special commands. - */ -struct nss_wifili_radio_cmd_msg { - enum nss_wifili_radio_cmd cmd; - /**< Type of command message. */ - uint32_t value; /**< Value of the command. */ -}; - -/** - * nss_wifili_radio_buf_cfg_msg - * Wi-Fi Radio buffer requirement configuration. - * - * Number of payloads needed in NSS for multi-client scenarios are configured - * from Wi-Fi driver as per following ranges: - * 0-64 peers range 1. - * 64-128 peers range 2. - * 128-256 peers range 3. - * >256 peers range 4. - * Number of payloads needed in for each peer range is configured by Wi-Fi driver - * for flexibility. - */ -struct nss_wifili_radio_buf_cfg_msg { - uint32_t buf_cnt; /**< Number of buffers required. */ - uint32_t range; /**< Peer range. */ -}; - -/** - * nss_wifili_radio_cfg_msg - * Wi-Fi radio specific special configurations. - */ -struct nss_wifili_radio_cfg_msg { - uint32_t radio_if_num; /**< NSS assigned interface number for radio. */ - - /** - * Wi-Fi radio specific special command message. - */ - union { - struct nss_wifili_radio_cmd_msg radiocmdmsg; - /**< Radio specific commands. */ - struct nss_wifili_radio_buf_cfg_msg radiobufcfgmsg; - /**< Radio specific buffer configurations. */ - } radiomsg; /**< Wi-Fi radio command message. */ -}; - -/** - * 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. */ -}; - -/** - * nss_wifili_msg - * Structure that describes wifili messages. - */ -struct nss_wifili_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of wifili message. - */ - union { - struct nss_wifili_init_msg init; - /**< Wi-Fi initialization data. */ - struct nss_wifili_pdev_init_msg pdevmsg; - /**< Tx initialization data. */ - struct nss_wifili_pdev_deinit_msg pdevdeinit; - /**< Tx de-initialization data. */ - struct nss_wifili_peer_msg peermsg; - /**< Peer-specific data for the physical device. */ - struct nss_wifili_peer_freelist_append_msg peer_freelist_append; - /**< Information for creating a peer freelist. */ - struct nss_wifili_stats_sync_msg wlsoc_stats; - /**< Synchronization statistics. */ - struct nss_wifili_peer_stats_msg peer_stats; - /**< Wifili peer statistics. */ - struct nss_wifili_wds_peer_msg wdspeermsg; - /**< WDS peer-specific message. */ - struct nss_wifili_wds_peer_map_msg wdspeermapmsg; - /**< WDS peer-mapping specific message. */ - struct nss_wifili_wds_active_info_msg wdsinfomsg; - /**< WDS active information specific message. */ - struct nss_wifili_stats_cfg_msg scm; - /**< Wifili peer statistics configuration message. */ - struct nss_wifili_reo_tidq_msg reotidqmsg; - /**< Rx reorder TID queue setup message. */ - struct nss_wifili_radio_cfg_msg radiocfgmsg; - /**< Radio command message. */ - struct nss_wifili_wds_extn_peer_cfg_msg wpeercfg; - /**< WDS vendor configuration message. */ - struct nss_wifili_soc_linkdesc_buf_info_msg linkdescinfomsg; - /**< Link descriptor buffer address information. */ - struct nss_wifili_peer_security_type_msg securitymsg; - /**< Wifili peer security message. */ - struct nss_wifili_peer_nawds_enable_msg nawdsmsg; - /**< Wifili peer enable NAWDS message. */ - struct nss_wifili_dbdc_repeater_set_msg dbdcrptrmsg; - /**< Wifili DBDC repeater enable message. */ - struct nss_wifili_hmmc_dscp_override_set_msg shmmcdscpmsg; - /**< Wifili Hy-Fi managed multicast DSCP override set message. */ - struct nss_wifili_hmmc_dscp_tid_set_msg shmmcdcptidmsg; - /**< Wifili Hy-Fi managed multicast DSCP TID map set message. */ - struct nss_wifili_pdev_v3_tx_rx_stats_sync_msg v3_txrx_stats_msg; - /**< Wifili version 3 Tx and Rx statistics message. */ - struct nss_wifili_pdev_v3_delay_stats_sync_msg v3_delay_stats_msg; - /**< Wifili version 3 delay statistics message. */ - struct nss_wifili_enable_v3_stats_msg enablev3statsmsg; - /**< Wifili version 3 statistics enable message. */ - struct nss_wifili_sojourn_stats_msg sj_stats_msg; - /**< Wifili sojourn statistics message. */ - struct nss_wifili_peer_vlan_id_msg peervlan; - /**< Wifili peer VLAN ID message. */ - struct nss_wifili_update_pdev_lmac_id_msg update_pdev_lmac_id_msg; - /**< Wifili peer update lower MAC ID message. */ - struct nss_wifili_peer_ast_flowid_map_msg peer_ast_flowid_msg; - /**< Wifili peer AST index flow ID map message. */ - struct nss_wifili_mec_ageout_info_msg mecagemsg; - /**< Multicast echo check active information specific message. */ - struct nss_wifili_jitter_stats_msg jt_stats_msg; - /** HLOS messages for bridge - */ -static void nss_bridge_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *app_data) -{ - struct nss_bridge_msg *nbm = (struct nss_bridge_msg *)ncm; - nss_bridge_msg_callback_t cb; - - BUG_ON(!nss_is_dynamic_interface(ncm->interface)); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_BRIDGE_MSG_TYPE_MAX) { - 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("%px: length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Trace Messages - */ - nss_bridge_log_rx_msg(nbm); - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Update the callback and app_data for NOTIFY messages, IPv4 sends all notify messages - * to the same callback/app_data. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->bridge_callback; - ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->bridge_ctx; - } - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_bridge_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, nbm); -} - -/* - * nss_bridge_get_context() - */ -struct nss_ctx_instance *nss_bridge_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.bridge_handler_id]; -} -EXPORT_SYMBOL(nss_bridge_get_context); - -/* - * nss_bridge_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_bridge_callback(void *app_data, struct nss_bridge_msg *nbm) -{ - nss_bridge_msg_callback_t callback = (nss_bridge_msg_callback_t)bridge_pvt.cb; - void *data = bridge_pvt.app_data; - - bridge_pvt.response = NSS_TX_SUCCESS; - bridge_pvt.cb = NULL; - bridge_pvt.app_data = NULL; - - if (nbm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("bridge error response %d\n", nbm->cm.response); - bridge_pvt.response = nbm->cm.response; - } - - if (callback) { - callback(data, nbm); - } - complete(&bridge_pvt.complete); -} - -/* - * nss_bridge_verify_if_num() - * Verify if_num passed to us. - */ -bool nss_bridge_verify_if_num(uint32_t if_num) -{ - if (nss_is_dynamic_interface(if_num) == false) { - return false; - } - - if (nss_dynamic_interface_get_type(nss_bridge_get_context(), if_num) != NSS_DYNAMIC_INTERFACE_TYPE_BRIDGE) { - return false; - } - - return true; -} -EXPORT_SYMBOL(nss_bridge_verify_if_num); - -/* - * nss_bridge_tx_msg() - * Transmit a bridge message to NSSFW - */ -nss_tx_status_t nss_bridge_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_bridge_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Sanity check the message - */ - if (!nss_is_dynamic_interface(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("%px: message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - /* - * Trace Messages - */ - nss_bridge_log_tx_msg(msg); - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_bridge_tx_msg); - -/* - * nss_bridge_tx_msg_sync() - * Transmit a bridge message to NSS firmware synchronously. - */ -nss_tx_status_t nss_bridge_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_bridge_msg *nbm) -{ - nss_tx_status_t status; - int ret = 0; - - down(&bridge_pvt.sem); - bridge_pvt.cb = (void *)nbm->cm.cb; - bridge_pvt.app_data = (void *)nbm->cm.app_data; - - nbm->cm.cb = (nss_ptr_t)nss_bridge_callback; - nbm->cm.app_data = (nss_ptr_t)NULL; - - status = nss_bridge_tx_msg(nss_ctx, nbm); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: bridge_tx_msg failed\n", nss_ctx); - up(&bridge_pvt.sem); - return status; - } - - ret = wait_for_completion_timeout(&bridge_pvt.complete, msecs_to_jiffies(NSS_BRIDGE_TX_TIMEOUT)); - - if (!ret) { - nss_warning("%px: bridge msg tx failed due to timeout\n", nss_ctx); - bridge_pvt.response = NSS_TX_FAILURE; - } - - status = bridge_pvt.response; - up(&bridge_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_bridge_tx_msg_sync); - -/* - * nss_bridge_msg_init() - * Initialize nss_bridge_msg. - */ -void nss_bridge_msg_init(struct nss_bridge_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} -EXPORT_SYMBOL(nss_bridge_msg_init); - -/* - * nss_bridge_tx_vsi_assign_msg - * API to send vsi assign message to NSS FW - */ -nss_tx_status_t nss_bridge_tx_vsi_assign_msg(uint32_t if_num, uint32_t vsi) -{ - struct nss_ctx_instance *nss_ctx = nss_bridge_get_context(); - struct nss_bridge_msg nbm; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - if (nss_bridge_verify_if_num(if_num) == false) { - nss_warning("%px: invalid interface %d", nss_ctx, if_num); - return NSS_TX_FAILURE; - } - - nss_bridge_msg_init(&nbm, if_num, NSS_IF_VSI_ASSIGN, - sizeof(struct nss_if_vsi_assign), NULL, NULL); - - nbm.msg.if_msg.vsi_assign.vsi = vsi; - - return nss_bridge_tx_msg_sync(nss_ctx, &nbm); -} -EXPORT_SYMBOL(nss_bridge_tx_vsi_assign_msg); - -/* - * nss_bridge_tx_vsi_unassign_msg - * API to send vsi unassign message to NSS FW - */ -nss_tx_status_t nss_bridge_tx_vsi_unassign_msg(uint32_t if_num, uint32_t vsi) -{ - struct nss_ctx_instance *nss_ctx = nss_bridge_get_context(); - struct nss_bridge_msg nbm; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - if (nss_bridge_verify_if_num(if_num) == false) { - nss_warning("%px: invalid interface %d", nss_ctx, if_num); - return NSS_TX_FAILURE; - } - - nss_bridge_msg_init(&nbm, if_num, NSS_IF_VSI_UNASSIGN, - sizeof(struct nss_if_vsi_unassign), NULL, NULL); - - nbm.msg.if_msg.vsi_unassign.vsi = vsi; - - return nss_bridge_tx_msg_sync(nss_ctx, &nbm); -} -EXPORT_SYMBOL(nss_bridge_tx_vsi_unassign_msg); - -/* - * nss_bridge_tx_change_mtu_msg - * API to send change mtu message to NSS FW - */ -nss_tx_status_t nss_bridge_tx_set_mtu_msg(uint32_t bridge_if_num, uint32_t mtu) -{ - struct nss_ctx_instance *nss_ctx = nss_bridge_get_context(); - struct nss_bridge_msg nbm; - struct nss_if_mtu_change *nimc; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - if (nss_bridge_verify_if_num(bridge_if_num) == false) { - nss_warning("%px: received invalid interface %d", nss_ctx, bridge_if_num); - return NSS_TX_FAILURE; - } - - nss_bridge_msg_init(&nbm, bridge_if_num, NSS_IF_MTU_CHANGE, - sizeof(struct nss_if_mtu_change), NULL, NULL); - - nimc = &nbm.msg.if_msg.mtu_change; - nimc->min_buf_size = (uint16_t)mtu; - - return nss_bridge_tx_msg_sync(nss_ctx, &nbm); -} -EXPORT_SYMBOL(nss_bridge_tx_set_mtu_msg); - -/* - * nss_bridge_tx_set_mac_addr_msg - * API to send change mac addr message to NSS FW - */ -nss_tx_status_t nss_bridge_tx_set_mac_addr_msg(uint32_t bridge_if_num, uint8_t *addr) -{ - struct nss_ctx_instance *nss_ctx = nss_bridge_get_context(); - struct nss_bridge_msg nbm; - struct nss_if_mac_address_set *nmas; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - if (nss_bridge_verify_if_num(bridge_if_num) == false) { - nss_warning("%px: received invalid interface %d", nss_ctx, bridge_if_num); - return NSS_TX_FAILURE; - } - - nss_bridge_msg_init(&nbm, bridge_if_num, NSS_IF_MAC_ADDR_SET, - sizeof(struct nss_if_mac_address_set), NULL, NULL); - - nmas = &nbm.msg.if_msg.mac_address_set; - memcpy(nmas->mac_addr, addr, ETH_ALEN); - return nss_bridge_tx_msg_sync(nss_ctx, &nbm); -} -EXPORT_SYMBOL(nss_bridge_tx_set_mac_addr_msg); - -/* - * nss_bridge_tx_join_msg - * API to send slave join message to NSS FW - */ -nss_tx_status_t nss_bridge_tx_join_msg(uint32_t bridge_if_num, struct net_device *netdev) -{ - struct nss_ctx_instance *nss_ctx = nss_bridge_get_context(); - struct nss_bridge_msg nbm; - uint32_t slave_if_num; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - if (nss_bridge_verify_if_num(bridge_if_num) == false) { - 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("%px: invalid slave device %px\n", nss_ctx, netdev); - return NSS_TX_FAILURE; - } - - nbm.msg.br_join.if_num = slave_if_num; - nss_bridge_msg_init(&nbm, bridge_if_num, NSS_BRIDGE_MSG_JOIN, - sizeof(struct nss_bridge_join_msg), NULL, NULL); - - return nss_bridge_tx_msg_sync(nss_ctx, &nbm); -} -EXPORT_SYMBOL(nss_bridge_tx_join_msg); - -/* - * nss_bridge_tx_leave_msg - * API to send slave leave message to NSS FW - */ -nss_tx_status_t nss_bridge_tx_leave_msg(uint32_t bridge_if_num, struct net_device *netdev) -{ - struct nss_ctx_instance *nss_ctx = nss_bridge_get_context(); - struct nss_bridge_msg nbm; - uint32_t slave_if_num; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - if (nss_bridge_verify_if_num(bridge_if_num) == false) { - 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("%px: invalid slave device %px\n", nss_ctx, netdev); - return NSS_TX_FAILURE; - } - - nbm.msg.br_leave.if_num = slave_if_num; - nss_bridge_msg_init(&nbm, bridge_if_num, NSS_BRIDGE_MSG_LEAVE, - sizeof(struct nss_bridge_leave_msg), NULL, NULL); - - return nss_bridge_tx_msg_sync(nss_ctx, &nbm); -} -EXPORT_SYMBOL(nss_bridge_tx_leave_msg); - -/* - * nss_bridge_tx_set_fdb_learn_msg - * API to send FDB learn message to NSS FW - */ -nss_tx_status_t nss_bridge_tx_set_fdb_learn_msg(uint32_t bridge_if_num, enum nss_bridge_fdb_learn_mode fdb_learn) -{ - struct nss_ctx_instance *nss_ctx = nss_bridge_get_context(); - struct nss_bridge_msg nbm; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - if (nss_bridge_verify_if_num(bridge_if_num) == false) { - 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("%px: received invalid fdb learn mode %d\n", nss_ctx, fdb_learn); - return NSS_TX_FAILURE; - } - - nss_bridge_msg_init(&nbm, bridge_if_num, NSS_BRIDGE_MSG_SET_FDB_LEARN, - sizeof(struct nss_bridge_set_fdb_learn_msg), NULL, NULL); - - nbm.msg.fdb_learn.mode = fdb_learn; - - return nss_bridge_tx_msg_sync(nss_ctx, &nbm); -} -EXPORT_SYMBOL(nss_bridge_tx_set_fdb_learn_msg); - -/* - * nss_bridge_init() - */ -void nss_bridge_init(void) -{ - sema_init(&bridge_pvt.sem, 1); - init_completion(&bridge_pvt.complete); -} - -/* - * nss_bridge_unregister() - */ -void nss_bridge_unregister(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_bridge_get_context(); - - nss_assert(nss_bridge_verify_if_num(if_num)); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - nss_top_main.bridge_callback = NULL; - - nss_core_unregister_handler(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_bridge_unregister); - -/* - * nss_bridge_register() - */ -struct nss_ctx_instance *nss_bridge_register(uint32_t if_num, struct net_device *netdev, - nss_bridge_callback_t bridge_data_cb, - nss_bridge_msg_callback_t bridge_msg_cb, - uint32_t features, - void *app_data) -{ - struct nss_ctx_instance *nss_ctx = nss_bridge_get_context(); - - nss_assert(nss_bridge_verify_if_num(if_num)); - - nss_core_register_subsys_dp(nss_ctx, if_num, bridge_data_cb, NULL, app_data, netdev, features); - - nss_top_main.bridge_callback = bridge_msg_cb; - - nss_core_register_handler(nss_ctx, if_num, nss_bridge_handler, app_data); - return nss_ctx; -} -EXPORT_SYMBOL(nss_bridge_register); - -/* - * nss_bridge_notify_register() - * Register to receive bridge notify messages. - */ -struct nss_ctx_instance *nss_bridge_notify_register(nss_bridge_msg_callback_t cb, void *app_data) -{ - nss_top_main.bridge_callback = cb; - nss_top_main.bridge_ctx = app_data; - return nss_bridge_get_context(); -} -EXPORT_SYMBOL(nss_bridge_notify_register); - -/* - * nss_bridge_notify_unregister() - * Unregister to receive bridge notify messages. - */ -void nss_bridge_notify_unregister(void) -{ - nss_top_main.bridge_callback = NULL; -} -EXPORT_SYMBOL(nss_bridge_notify_unregister); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_bridge_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_bridge_log.c deleted file mode 100644 index 3b0cf1e39..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_bridge_log.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_bridge_log.c - * NSS Bridge logger file. - */ - -#include "nss_core.h" - -/* - * nss_bridge_log_message_types_str - * NSS Bridge message strings - */ -static int8_t *nss_bridge_log_message_types_str[NSS_BRIDGE_MSG_TYPE_MAX] __maybe_unused = { - "Bridge Join message", - "Bridge Leave message", - "Bridge Set FDB Learn message" -}; - -/* - * nss_bridge_join_msg() - * Log NSS Bridge Join message. - */ -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("%px: NSS Bridge Join message \n" - "Interface Number: %d\n", - nbm, nbjm->if_num); -} - -/* - * nss_bridge_leave_msg() - * Log NSS Bridge Leave message. - */ -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("%px: NSS Bridge Leave message: \n" - "Interface Number: %d\n", - nbm, nblm->if_num); -} - -/* - * nss_bridge_fdb_learn_msg() - * Log NSS Set Bridge FDB Learn message. - */ -static void nss_bridge_fdb_learn_msg(struct nss_bridge_msg *nbm) -{ - struct nss_bridge_set_fdb_learn_msg *nbflm __maybe_unused = - &nbm->msg.fdb_learn; - nss_trace("%px: NSS Bridge Set FDB Learn message: \n" - "Mode: %d\n", - nbm, nbflm->mode); -} - -/* - * nss_bridge_log_verbose() - * Log message contents. - */ -static void nss_bridge_log_verbose(struct nss_bridge_msg *nbm) -{ - switch (nbm->cm.type) { - case NSS_BRIDGE_MSG_JOIN: - nss_bridge_join_msg(nbm); - break; - - case NSS_BRIDGE_MSG_LEAVE: - nss_bridge_leave_msg(nbm); - break; - - case NSS_BRIDGE_MSG_SET_FDB_LEARN: - nss_bridge_fdb_learn_msg(nbm); - break; - - default: - nss_trace("%px: Invalid message type\n", nbm); - break; - } -} - -/* - * nss_bridge_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_bridge_log_tx_msg(struct nss_bridge_msg *nbm) -{ - if (nbm->cm.type >= NSS_BRIDGE_MSG_TYPE_MAX) { - nss_warning("%px: Invalid message type\n", nbm); - return; - } - - 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); -} - -/* - * nss_bridge_log_rx_msg() - * Log messages received from FW. - */ -void nss_bridge_log_rx_msg(struct nss_bridge_msg *nbm) -{ - if (nbm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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]); - -verbose: - nss_bridge_log_verbose(nbm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_bridge_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_bridge_log.h deleted file mode 100644 index af9a5f787..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_bridge_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_BRIDGE_LOG_H -#define __NSS_BRIDGE_LOG_H - -/* - * nss_bridge.h - * NSS Bridge header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_bridge_log_tx_msg - * Logs a bridge message that is sent to the NSS firmware. - */ -void nss_bridge_log_tx_msg(struct nss_bridge_msg *nbm); - -/* - * nss_bridge_log_rx_msg - * Logs a bridge message that is received from the NSS firmware. - */ -void nss_bridge_log_rx_msg(struct nss_bridge_msg *nbm); - -#endif /* __NSS_BRIDGE_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx.c b/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx.c deleted file mode 100644 index 4a1d5f8c2..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_c2c_rx.c - * NSS C2C_RX APIs - */ - -#include -#include "nss_c2c_rx_stats.h" -#include "nss_c2c_rx_strings.h" - -/* - * nss_c2c_rx_verify_if_num() - * Verify if_num passed to us. - */ -static bool nss_c2c_rx_verify_if_num(uint32_t if_num) -{ - return if_num == NSS_C2C_RX_INTERFACE; -} - -/* - * nss_c2c_rx_interface_handler() - * Handle NSS -> HLOS messages for C2C_RX Statistics - */ -static void nss_c2c_rx_interface_handler(struct nss_ctx_instance *nss_ctx, - struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_c2c_rx_msg *ncrm = (struct nss_c2c_rx_msg *)ncm; - nss_c2c_rx_msg_callback_t cb; - - if (!nss_c2c_rx_verify_if_num(ncm->interface)) { - nss_warning("%px: invalid interface %d for c2c_tx\n", nss_ctx, ncm->interface); - return; - } - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_C2C_RX_MSG_TYPE_MAX) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - switch (ncrm->cm.type) { - case NSS_C2C_RX_MSG_TYPE_STATS: - /* - * Update driver statistics and send statistics notifications to the registered modules. - */ - nss_c2c_rx_stats_sync(nss_ctx, &ncrm->msg.stats); - nss_c2c_rx_stats_notify(nss_ctx); - break; - } - - /* - * Update the callback and app_data for NOTIFY messages - * TODO: Add notify callbacks for c2c_rx - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - return; - } - - /* - * Do we have a callback? - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_c2c_rx_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, ncrm); -} - -/* - * nss_c2c_rx_register_handler() - * Register handler for messaging - */ -void nss_c2c_rx_register_handler(struct nss_ctx_instance *nss_ctx) -{ - nss_core_register_handler(nss_ctx, NSS_C2C_RX_INTERFACE, nss_c2c_rx_interface_handler, NULL); - - if (nss_ctx->id == NSS_CORE_0) { - nss_c2c_rx_stats_dentry_create(); - } - nss_c2c_rx_strings_dentry_create(); -} -EXPORT_SYMBOL(nss_c2c_rx_register_handler); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx_stats.c deleted file mode 100644 index d9ea31656..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx_stats.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - ************************************************************************** - * 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_c2c_rx_stats.h" -#include "nss_c2c_rx_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_c2c_rx_stats_notifier); - -/* - * Spinlock to protect C2C_RX statistics update/read - */ -DEFINE_SPINLOCK(nss_c2c_rx_stats_lock); - -/* - * nss_c2c_rx_stats - * c2c_rx statistics - */ -uint64_t nss_c2c_rx_stats[NSS_MAX_CORES][NSS_C2C_RX_STATS_MAX]; - -/* - * nss_c2c_rx_stats_read() - * Read C2C_RX statistics - */ -static ssize_t nss_c2c_rx_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int32_t i, core; - - /* - * 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_C2C_RX_STATS_MAX * NSS_MAX_CORES + 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 -ENOMEM; - } - - stats_shadow = kzalloc(NSS_C2C_RX_STATS_MAX * 8, GFP_KERNEL); - if (unlikely(stats_shadow == NULL)) { - nss_warning("Could not allocate memory for local shadow buffer"); - kfree(lbuf); - return -ENOMEM; - } - - /* - * C2C_RX statistics - */ - for (core = 0; core < NSS_MAX_CORES; core++) { - spin_lock_bh(&nss_c2c_rx_stats_lock); - for (i = 0; i < NSS_C2C_RX_STATS_MAX; i++) { - stats_shadow[i] = nss_c2c_rx_stats[core][i]; - } - spin_unlock_bh(&nss_c2c_rx_stats_lock); - size_wr += nss_stats_banner(lbuf, size_wr, size_al, "c2c_rx", core); - size_wr += nss_stats_print("c2c_rx", NULL, NSS_STATS_SINGLE_INSTANCE - , nss_c2c_rx_strings_stats - , stats_shadow - , NSS_C2C_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_c2c_rx_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(c2c_rx); - -/* - * nss_c2c_rx_stats_dentry_create() - * Create C2C_RX statistics debug entry. - */ -void nss_c2c_rx_stats_dentry_create(void) -{ - nss_stats_create_dentry("c2c_rx", &nss_c2c_rx_stats_ops); -} - -/* - * nss_c2c_rx_stats_sync() - * Handle the syncing of NSS C2C_RX statistics. - */ -void nss_c2c_rx_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_c2c_rx_stats *ncrs) -{ - int id = nss_ctx->id; - int j; - - spin_lock_bh(&nss_c2c_rx_stats_lock); - - /* - * Common node stats - */ - nss_c2c_rx_stats[id][NSS_STATS_NODE_RX_PKTS] += (ncrs->pbuf_simple + ncrs->pbuf_sg + ncrs->pbuf_returning); - nss_c2c_rx_stats[id][NSS_STATS_NODE_RX_BYTES] += ncrs->node_stats.rx_bytes; - nss_c2c_rx_stats[id][NSS_STATS_NODE_TX_PKTS] += ncrs->node_stats.tx_packets; - nss_c2c_rx_stats[id][NSS_STATS_NODE_TX_BYTES] += ncrs->node_stats.tx_bytes; - - for (j = 0; j < NSS_MAX_NUM_PRI; j++) { - nss_c2c_rx_stats[id][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + j] += ncrs->node_stats.rx_dropped[j]; - } - - /* - * C2C_RX statistics - */ - nss_c2c_rx_stats[id][NSS_C2C_RX_STATS_PBUF_SIMPLE] += ncrs->pbuf_simple; - nss_c2c_rx_stats[id][NSS_C2C_RX_STATS_PBUF_SG] += ncrs->pbuf_sg; - nss_c2c_rx_stats[id][NSS_C2C_RX_STATS_PBUF_RETURNING] += ncrs->pbuf_returning; - nss_c2c_rx_stats[id][NSS_C2C_RX_STATS_INVAL_DEST] += ncrs->inval_dest; - - spin_unlock_bh(&nss_c2c_rx_stats_lock); -} - -/* - * nss_c2c_rx_stats_notify() - * Sends notifications to all the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_c2c_rx_stats_notify(struct nss_ctx_instance *nss_ctx) -{ - struct nss_c2c_rx_stats_notification c2c_rx_stats; - - c2c_rx_stats.core_id = nss_ctx->id; - memcpy(c2c_rx_stats.stats, nss_c2c_rx_stats[c2c_rx_stats.core_id], sizeof(c2c_rx_stats.stats)); - atomic_notifier_call_chain(&nss_c2c_rx_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&c2c_rx_stats); -} - -/* - * nss_c2c_rx_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_c2c_rx_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_c2c_rx_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_c2c_rx_stats_register_notifier); - -/* - * nss_c2c_rx_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_c2c_rx_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_c2c_rx_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_c2c_rx_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx_stats.h deleted file mode 100644 index c53d08071..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx_stats.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - ****************************************************************************** - * 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. - * **************************************************************************** - */ - -#ifndef __NSS_C2C_RX_STATS_H -#define __NSS_C2C_RX_STATS_H - -#include - -/* - * c2c_rx_msg_type - * Message types supported - */ -enum c2c_rx_msg_type { - NSS_C2C_RX_MSG_TYPE_STATS, /* Statistics synchronization */ - NSS_C2C_RX_MSG_TYPE_MAX -}; - -/* - * nss_c2c_rx_stats - * The NSS c2c_rx node stats structure. - */ -struct nss_c2c_rx_stats { - struct nss_cmn_node_stats node_stats; - /* Common node stats for core-to-core reception. */ - uint32_t pbuf_simple; /* Number of received simple pbuf. */ - uint32_t pbuf_sg; /* Number of S/G pbuf received. */ - uint32_t pbuf_returning; /* Number of returning S/G pbuf. */ - uint32_t inval_dest; /* Number of pbuf enqueue failure because of dest is invalid. */ -}; - -/* - * nss_c2c_rx_msg - * Message structure to send/receive c2c_rx commands - */ -struct nss_c2c_rx_msg { - struct nss_cmn_msg cm; /* Message Header */ - union { - struct nss_c2c_rx_stats stats; /* c2c_rx statistics */ - } msg; -}; - -/* - * C2C_RX statistics APIs - */ -extern void nss_c2c_rx_stats_notify(struct nss_ctx_instance *nss_ctx); -typedef void (*nss_c2c_rx_msg_callback_t)(void *app_data, struct nss_c2c_rx_msg *msg); -extern void nss_c2c_rx_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_c2c_rx_stats *ncrs); -extern void nss_c2c_rx_stats_dentry_create(void); - -#endif /* __NSS_C2C_RX_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx_strings.c deleted file mode 100644 index c20754d12..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx_strings.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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" - -/* - * nss_c2c_rx_strings_stats - * Core-to-core Rx statistics strings. - */ -struct nss_stats_info nss_c2c_rx_strings_stats[NSS_C2C_RX_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}, - {"pbuf_simple" , NSS_STATS_TYPE_SPECIAL}, - {"pbuf_sg" , NSS_STATS_TYPE_SPECIAL}, - {"pbuf_returning" , NSS_STATS_TYPE_SPECIAL}, - {"inval_dest" , NSS_STATS_TYPE_DROP} -}; - -/* - * nss_c2c_rx_strings_read() - * Read C2C Rx node statistics names. - */ -static ssize_t nss_c2c_rx_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_c2c_rx_strings_stats, NSS_C2C_RX_STATS_MAX); -} - -/* - * nss_c2c_rx_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(c2c_rx); - -/* - * nss_c2c_rx_strings_dentry_create() - * Create C2C Rx statistics strings debug entry. - */ -void nss_c2c_rx_strings_dentry_create(void) -{ - nss_strings_create_dentry("c2c_rx", &nss_c2c_rx_strings_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx_strings.h deleted file mode 100644 index 3810f11fa..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_rx_strings.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_C2C_RX_STRINGS_H -#define __NSS_C2C_RX_STRINGS_H - -extern struct nss_stats_info nss_c2c_rx_strings_stats[NSS_C2C_RX_STATS_MAX]; -extern void nss_c2c_rx_strings_dentry_create(void); - -#endif /* __NSS_C2C_RX_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx.c b/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx.c deleted file mode 100644 index 244f4598a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx.c +++ /dev/null @@ -1,439 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_c2c_tx.c - * NSS C2C_TX APIs - */ - -#include -#include "nss_c2c_tx_stats.h" -#include "nss_c2c_tx_log.h" -#include "nss_c2c_tx_strings.h" - -int nss_c2c_tx_test_id = -1; - -/* - * Private data structure. - */ -struct nss_c2c_tx_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. */ -}; - -/* - * Notify data structure - */ -struct nss_c2c_tx_notify_data { - nss_c2c_tx_msg_callback_t c2c_tx_callback; - void *app_data; -}; - -static struct nss_c2c_tx_notify_data nss_c2c_tx_notify[NSS_CORE_MAX]; -static struct nss_c2c_tx_pvt nss_c2c_tx_cfg_pvt; - -/* - * nss_c2c_tx_verify_if_num() - * Verify if_num passed to us. - */ -static inline bool nss_c2c_tx_verify_if_num(uint32_t if_num) -{ - return if_num == NSS_C2C_TX_INTERFACE; -} - -/* - * nss_c2c_tx_interface_handler() - * Handle NSS -> HLOS messages for C2C_TX Statistics - */ -static void nss_c2c_tx_msg_handler(struct nss_ctx_instance *nss_ctx, - struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_c2c_tx_msg *nctm = (struct nss_c2c_tx_msg *)ncm; - nss_c2c_tx_msg_callback_t cb; - - if (!nss_c2c_tx_verify_if_num(ncm->interface)) { - nss_warning("%px: invalid interface %d for c2c_tx\n", nss_ctx, ncm->interface); - return; - } - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_C2C_TX_MSG_TYPE_MAX) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Trace messages. - */ - nss_c2c_tx_log_rx_msg(nctm); - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - switch (nctm->cm.type) { - case NSS_C2C_TX_MSG_TYPE_TX_MAP: - case NSS_C2C_TX_MSG_TYPE_PERFORMANCE_TEST: - break; - - case NSS_C2C_TX_MSG_TYPE_STATS: - /* - * Update driver statistics and send statistics notifications to the registered modules. - */ - nss_c2c_tx_stats_sync(nss_ctx, &nctm->msg.stats); - nss_c2c_tx_stats_notify(nss_ctx); - break; - } - - /* - * Update the callback and app_data for NOTIFY messages - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_c2c_tx_notify[nss_ctx->id].c2c_tx_callback; - ncm->app_data = (nss_ptr_t)nss_c2c_tx_notify[nss_ctx->id].app_data; - } - - /* - * Do we have a callback? - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_c2c_tx_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, nctm); -} - -/* - * nss_c2c_tx_register_handler() - * Register handler for messaging - */ -void nss_c2c_tx_register_handler(struct nss_ctx_instance *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) { - nss_c2c_tx_stats_dentry_create(); - } - nss_c2c_tx_strings_dentry_create(); -} -EXPORT_SYMBOL(nss_c2c_tx_register_handler); - -/* - * nss_c2c_tx_tx_msg() - * Transmit an c2c_tx message to the FW with a specified size. - */ -nss_tx_status_t nss_c2c_tx_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_c2c_tx_msg *nctm) -{ - struct nss_cmn_msg *ncm = &nctm->cm; - - /* - * Sanity check the message - */ - if (!nss_c2c_tx_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_C2C_TX_MSG_TYPE_MAX) { - nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - /* - * Trace messages. - */ - nss_c2c_tx_log_tx_msg(nctm); - - return nss_core_send_cmd(nss_ctx, nctm, sizeof(*nctm), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_c2c_tx_tx_msg); - -/* - * nss_c2c_tx_msg_cfg_map_callback() - * Callback function for tx_map configuration - */ -static void nss_c2c_tx_msg_cfg_map_callback(void *app_data, struct nss_c2c_tx_msg *nctm) -{ - struct nss_ctx_instance *nss_ctx __attribute__((unused)) = (struct nss_ctx_instance *)app_data; - if (nctm->cm.response != NSS_CMN_RESPONSE_ACK) { - 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("%px: nss c2c_tx_map configuration succeeded for NSS core %d\n", - nss_ctx, nss_ctx->id); -} - -/* - * nss_c2c_tx_msg_performance_test_start_callback() - * Callback function for c2c_tx test start configuration - */ -static void nss_c2c_tx_msg_performance_test_callback(void *app_data, struct nss_c2c_tx_msg *nctm) -{ - struct nss_ctx_instance *nss_ctx __attribute__((unused)) = (struct nss_ctx_instance *)app_data; - - /* - * Test start has been failed. Restore the value to initial state. - */ - if (nctm->cm.response != NSS_CMN_RESPONSE_ACK) { - 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("%px: nss c2c_tx test successfully initialized for NSS core %d\n", - nss_ctx, nss_ctx->id); -} - -/* - * nss_c2c_tx_msg_cfg_map() - * Send NSS to c2c_map - */ -nss_tx_status_t nss_c2c_tx_msg_cfg_map(struct nss_ctx_instance *nss_ctx, uint32_t tx_map, uint32_t c2c_intr_addr) -{ - int32_t status; - struct nss_c2c_tx_msg nctm; - struct nss_c2c_tx_map *cfg_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); - - cfg_map = &nctm.msg.map; - cfg_map->tx_map = tx_map; - cfg_map->c2c_intr_addr = c2c_intr_addr; - - status = nss_c2c_tx_tx_msg(nss_ctx, &nctm); - if (unlikely(status != NSS_TX_SUCCESS)) { - return status; - } - - return NSS_TX_SUCCESS; -} - -/* - * nss_c2c_tx_msg_performance_test() - * Send NSS c2c peformance test start message. - */ -nss_tx_status_t nss_c2c_tx_msg_performance_test(struct nss_ctx_instance *nss_ctx, uint32_t test_id) -{ - int32_t status; - struct nss_c2c_tx_msg nctm; - struct nss_c2c_tx_test *test; - - 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); - - test = &nctm.msg.test; - test->test_id = test_id; - - status = nss_c2c_tx_tx_msg(nss_ctx, &nctm); - if (unlikely(status != NSS_TX_SUCCESS)) { - return status; - } - - return NSS_TX_SUCCESS; -} - -/* - * nss_c2c_tx_msg_init() - * Initialize C2C_TX message. - */ -void nss_c2c_tx_msg_init(struct nss_c2c_tx_msg *nctm, uint16_t if_num, uint32_t type, uint32_t len, - nss_c2c_tx_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&nctm->cm, if_num, type, len, (void *)cb, app_data); -} -EXPORT_SYMBOL(nss_c2c_tx_msg_init); - -/* - * nss_c2c_tx_performance_test_handler() - * Handles the performance test. - */ -static int nss_c2c_tx_performance_test_handler(struct ctl_table *ctl, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; - int ret, ret_c2c_tx, current_state; - current_state = nss_c2c_tx_test_id; - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - - if (ret != NSS_SUCCESS) { - return ret; - } - - if (!write) { - return ret; - } - - if (current_state != -1) { - 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("%px: Invalid test ID.\n", nss_ctx); - nss_c2c_tx_test_id = current_state; - return -EINVAL; - } - - nss_info("Starting the c2c_tx performance test\n"); - ret_c2c_tx = nss_c2c_tx_msg_performance_test(nss_ctx, nss_c2c_tx_test_id); - - if (ret_c2c_tx != NSS_SUCCESS) { - nss_warning("%px: Starting the test has failed.\n", nss_ctx); - nss_c2c_tx_test_id = -1; - } - - return ret_c2c_tx; -} - -static struct ctl_table nss_c2c_tx_table[] = { - { - .procname = "test_code", - .data = &nss_c2c_tx_test_id, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_c2c_tx_performance_test_handler, - }, - { } -}; - -static struct ctl_table nss_c2c_tx_dir[] = { - { - .procname = "c2c_tx", - .mode = 0555, - .child = nss_c2c_tx_table, - }, - { } -}; - -static struct ctl_table nss_c2c_tx_root_dir[] = { - { - .procname = "nss", - .mode = 0555, - .child = nss_c2c_tx_dir, - }, - { } -}; - -static struct ctl_table nss_c2c_tx_root[] = { - { - .procname = "dev", - .mode = 0555, - .child = nss_c2c_tx_root_dir, - }, - { } -}; - -static struct ctl_table_header *nss_c2c_tx_header; - -/* - * nss_c2c_tx_register_sysctl() - */ -void nss_c2c_tx_register_sysctl(void) -{ - - /* - * c2c_tx sema init. - */ - sema_init(&nss_c2c_tx_cfg_pvt.sem, 1); - init_completion(&nss_c2c_tx_cfg_pvt.complete); - - /* - * Register sysctl table. - */ - nss_c2c_tx_header = register_sysctl_table(nss_c2c_tx_root); -} - -/* - * nss_c2c_tx_unregister_sysctl() - * Unregister sysctl specific to c2c_tx - */ -void nss_c2c_tx_unregister_sysctl(void) -{ - /* - * Unregister sysctl table. - */ - if (nss_c2c_tx_header) { - unregister_sysctl_table(nss_c2c_tx_header); - } -} - -/* - * nss_c2c_tx_notify_register() - * Register to receive c2c_tx notify messages. - */ -struct nss_ctx_instance *nss_c2c_tx_notify_register(int core, nss_c2c_tx_msg_callback_t cb, void *app_data) -{ - if (core >= NSS_CORE_MAX) { - nss_warning("Input core number %d is wrong\n", core); - return NULL; - } - - nss_c2c_tx_notify[core].c2c_tx_callback = cb; - nss_c2c_tx_notify[core].app_data = app_data; - - return (struct nss_ctx_instance *)&nss_top_main.nss[core]; -} -EXPORT_SYMBOL(nss_c2c_tx_notify_register); - -/* - * nss_c2c_tx_notify_unregister() - * Unregister to receive c2c_tx notify messages. - */ -void nss_c2c_tx_notify_unregister(int core) -{ - if (core >= NSS_CORE_MAX) { - nss_warning("Input core number %d is wrong\n", core); - return; - } - - nss_c2c_tx_notify[core].c2c_tx_callback = NULL; - nss_c2c_tx_notify[core].app_data = NULL; -} -EXPORT_SYMBOL(nss_c2c_tx_notify_unregister); - -/* - * nss_c2c_tx_init() - */ -void nss_c2c_tx_init(void) -{ - int core; - - for (core = 0; core < NSS_CORE_MAX; core++) { - nss_c2c_tx_notify_register(core, NULL, NULL); - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_log.c deleted file mode 100644 index 088cef353..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_log.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_c2c_tx_log.c - * NSS C2C TX logger file. - */ - -#include "nss_core.h" - -/* - * nss_c2c_tx_log_message_types_str - * C2C TX message strings - */ -static int8_t *nss_c2c_tx_log_message_types_str[NSS_C2C_TX_MSG_TYPE_MAX] __maybe_unused = { - "C2C TX Stats message", - "C2C TX Map Message", -}; - -/* - * nss_c2c_tx_log_error_response_types_str - * Strings for error types for c2c_tx messages - */ -static int8_t *nss_c2c_tx_log_error_response_types_str[NSS_C2C_TX_MSG_ERROR_MAX] __maybe_unused = { - "No error", - "Invalid Operation" -}; - -/* - * nss_c2c_tx_map_msg()() - * Log NSS C2C TX Map message. - */ -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("%px: NSS C2C TX Map message: \n" - "C2C Receiver Queue Start Address: %d\n" - "C2C Interrupt Register Address: %d\n", - nctm, - nctmm->tx_map, nctmm->c2c_intr_addr); -} - -/* - * nss_c2c_tx_log_verbose() - * Log message contents. - */ -static void nss_c2c_tx_log_verbose(struct nss_c2c_tx_msg *nctm) -{ - switch (nctm->cm.type) { - case NSS_C2C_TX_MSG_TYPE_TX_MAP: - nss_c2c_tx_map_msg(nctm); - break; - - default: - nss_trace("%px: Invalid message type\n", nctm); - break; - } -} - -/* - * nss_c2c_tx_log_tx_msg() - * Log messages transmitted to FW. - */ -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("%px: Invalid message type\n", nctm); - return; - } - - 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); -} - -/* - * nss_c2c_tx_log_rx_msg() - * Log messages received from FW. - */ -void nss_c2c_tx_log_rx_msg(struct nss_c2c_tx_msg *nctm) -{ - if (nctm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_c2c_tx_log_verbose(nctm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_log.h deleted file mode 100644 index e6ec47e77..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_log.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_C2C_TX_LOG_H -#define __NSS_C2C_TX_LOG_H -/* - * nss_c2c_tx_log.h - * NSS C2C TX Log Header File - */ - -/* - * nss_c2c_tx_log_tx_msg - * Logs an C2C TX message that is sent to the NSS firmware. - */ -void nss_c2c_tx_log_tx_msg(struct nss_c2c_tx_msg *nctm); - -/* - * nss_c2c_tx_log_rx_msg - * Logs an IPv4 message that is received from the NSS firmware. - */ -void nss_c2c_tx_log_rx_msg(struct nss_c2c_tx_msg *nctm); - -#endif /* __NSS_C2C_TX_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_stats.c deleted file mode 100644 index 7983f3f8c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_stats.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - ************************************************************************** - * 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_c2c_tx_stats.h" -#include "nss_c2c_tx_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_c2c_tx_stats_notifier); - -/* - * Spinlock to protect C2C_TX statistics update/read - */ -DEFINE_SPINLOCK(nss_c2c_tx_stats_lock); - -/* - * nss_c2c_tx_stats - * c2c_tx statistics - */ -uint64_t nss_c2c_tx_stats[NSS_MAX_CORES][NSS_C2C_TX_STATS_MAX]; - -/* - * nss_c2c_tx_stats_read() - * Read c2c_tx statistics - */ -static ssize_t nss_c2c_tx_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int32_t i, core; - - /* - * 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_C2C_TX_STATS_MAX * NSS_MAX_CORES + 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 -ENOMEM; - } - - stats_shadow = kzalloc(NSS_C2C_TX_STATS_MAX * 8, GFP_KERNEL); - if (unlikely(stats_shadow == NULL)) { - nss_warning("Could not allocate memory for local shadow buffer"); - kfree(lbuf); - return -ENOMEM; - } - - /* - * C2C_TX statistics - */ - for (core = 0; core < NSS_MAX_CORES; core++) { - spin_lock_bh(&nss_c2c_tx_stats_lock); - for (i = 0; i < NSS_C2C_TX_STATS_MAX; i++) { - stats_shadow[i] = nss_c2c_tx_stats[core][i]; - } - spin_unlock_bh(&nss_c2c_tx_stats_lock); - size_wr += nss_stats_banner(lbuf, size_wr, size_al, "c2c_tx", core); - size_wr += nss_stats_print("c2c_tx", NULL, NSS_STATS_SINGLE_INSTANCE, nss_c2c_tx_strings_stats, stats_shadow, NSS_C2C_TX_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_c2c_tx_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(c2c_tx); - -/* - * nss_c2c_tx_stats_dentry_create() - * Create c2c_tx statistics debug entry. - */ -void nss_c2c_tx_stats_dentry_create(void) -{ - nss_stats_create_dentry("c2c_tx", &nss_c2c_tx_stats_ops); -} - -/* - * nss_c2c_tx_stats_sync() - * Handle the syncing of NSS C2C_TX statistics. - */ -void nss_c2c_tx_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_c2c_tx_stats *nct) -{ - int id = nss_ctx->id; - int j; - - spin_lock_bh(&nss_c2c_tx_stats_lock); - - /* - * Common node stats - */ - nss_c2c_tx_stats[id][NSS_STATS_NODE_RX_PKTS] += (nct->pbuf_simple + nct->pbuf_sg + nct->pbuf_returning); - nss_c2c_tx_stats[id][NSS_STATS_NODE_RX_BYTES] += nct->node_stats.rx_bytes; - nss_c2c_tx_stats[id][NSS_STATS_NODE_TX_PKTS] += nct->node_stats.tx_packets; - nss_c2c_tx_stats[id][NSS_STATS_NODE_TX_BYTES] += nct->node_stats.tx_bytes; - - for (j = 0; j < NSS_MAX_NUM_PRI; j++) { - nss_c2c_tx_stats[id][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + j] += nct->node_stats.rx_dropped[j]; - } - - /* - * C2C_TX statistics - */ - nss_c2c_tx_stats[id][NSS_C2C_TX_STATS_PBUF_SIMPLE] += nct->pbuf_simple; - nss_c2c_tx_stats[id][NSS_C2C_TX_STATS_PBUF_SG] += nct->pbuf_sg; - nss_c2c_tx_stats[id][NSS_C2C_TX_STATS_PBUF_RETURNING] += nct->pbuf_returning; - - spin_unlock_bh(&nss_c2c_tx_stats_lock); -} - -/* - * nss_c2c_tx_stats_notify() - * Sends notifications to all the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_c2c_tx_stats_notify(struct nss_ctx_instance *nss_ctx) -{ - struct nss_c2c_tx_stats_notification c2c_tx_stats; - - c2c_tx_stats.core_id = nss_ctx->id; - memcpy(c2c_tx_stats.stats, nss_c2c_tx_stats[c2c_tx_stats.core_id], sizeof(c2c_tx_stats.stats)); - atomic_notifier_call_chain(&nss_c2c_tx_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&c2c_tx_stats); -} - -/* - * nss_c2c_tx_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_c2c_tx_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_c2c_tx_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_c2c_tx_stats_register_notifier); - -/* - * nss_c2c_tx_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_c2c_tx_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_c2c_tx_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_c2c_tx_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_stats.h deleted file mode 100644 index f77a3b4d6..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_stats.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - ****************************************************************************** - * 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. - * **************************************************************************** - */ - -#ifndef __NSS_C2C_TX_STATS_H -#define __NSS_C2C_TX_STATS_H - -#include - -/* - * C2C Tx statistics APIs - */ -extern void nss_c2c_tx_stats_notify(struct nss_ctx_instance *nss_ctx); -extern void nss_c2c_tx_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_c2c_tx_stats *nct); -extern void nss_c2c_tx_stats_dentry_create(void); - -#endif /* __NSS_C2C_TX_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_strings.c deleted file mode 100644 index 8272e8466..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_strings.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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" - -/* - * nss_c2c_tx_strings_stats - * C2C Tx statistics strings. - */ -struct nss_stats_info nss_c2c_tx_strings_stats[NSS_C2C_TX_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}, - {"pbuf_simple" , NSS_STATS_TYPE_SPECIAL}, - {"pbuf_sg" , NSS_STATS_TYPE_SPECIAL}, - {"pbuf_returning" , NSS_STATS_TYPE_SPECIAL} -}; - - -/* - * nss_c2c_tx_strings_read() - * Read c2c Tx node statistics names - */ -static ssize_t nss_c2c_tx_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_c2c_tx_strings_stats, NSS_C2C_TX_STATS_MAX); -} - -/* - * nss_c2c_tx_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(c2c_tx); - -/* - * nss_c2c_tx_strings_dentry_create() - * Create C2C Tx statistics strings debug entry. - */ -void nss_c2c_tx_strings_dentry_create(void) -{ - nss_strings_create_dentry("c2c_tx", &nss_c2c_tx_strings_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_strings.h deleted file mode 100644 index 483177de5..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_c2c_tx_strings.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_C2C_TX_STRINGS_H -#define __NSS_C2C_TX_STRINGS_H - -extern struct nss_stats_info nss_c2c_tx_strings_stats[NSS_C2C_TX_STATS_MAX]; -extern void nss_c2c_tx_strings_dentry_create(void); - -#endif /* __NSS_C2C_TX_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_capwap.c b/feeds/ipq807x/qca-nss-drv/src/nss_capwap.c deleted file mode 100644 index 597c31814..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_capwap.c +++ /dev/null @@ -1,606 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_capwap.c - * NSS CAPWAP driver interface APIs - */ -#include "nss_core.h" -#include "nss_capwap.h" -#include "nss_cmn.h" -#include "nss_tx_rx_common.h" -#include "nss_capwap_stats.h" -#include "nss_capwap_log.h" -#include "nss_capwap_strings.h" - -/* - * Spinlock for protecting tunnel operations colliding with a tunnel destroy - */ -DEFINE_SPINLOCK(nss_capwap_spinlock); - -/* - * Array of pointer for NSS CAPWAP handles. Each handle has per-tunnel - * stats based on the if_num which is an index. - * - * Per CAPWAP tunnel/interface number instance. - */ -struct nss_capwap_handle { - atomic_t refcnt; /**< Reference count on the tunnel */ - uint32_t if_num; /**< Interface number */ - uint32_t tunnel_status; /**< 0=disable, 1=enabled */ - struct nss_ctx_instance *ctx; /**< Pointer to context */ - nss_capwap_msg_callback_t msg_callback; /**< Msg callback */ - void *app_data; /**< App data (argument) */ - struct nss_capwap_tunnel_stats stats; /**< Stats per-interface number */ -}; -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) ) { - return false; - } - - return true; -} - -/* - * nss_capwap_refcnt_inc() - * Increments refcnt on the tunnel. - */ -static void nss_capwap_refcnt_inc(int32_t if_num) -{ - if_num = if_num - NSS_DYNAMIC_IF_START; - atomic_inc(&nss_capwap_hdl[if_num]->refcnt); - nss_assert(atomic_read(&nss_capwap_hdl[if_num]->refcnt) > 0); -} - -/* - * nss_capwap_refcnt_dec() - * Decrements refcnt on the tunnel. - */ -static void nss_capwap_refcnt_dec(int32_t if_num) -{ - if_num = if_num - NSS_DYNAMIC_IF_START; - nss_assert(atomic_read(&nss_capwap_hdl[if_num]->refcnt) > 0); - atomic_dec(&nss_capwap_hdl[if_num]->refcnt); -} - -/* - * nss_capwap_refcnt_get() - * Get refcnt on the tunnel. - */ -static uint32_t nss_capwap_refcnt_get(int32_t if_num) -{ - if_num = if_num - NSS_DYNAMIC_IF_START; - return atomic_read(&nss_capwap_hdl[if_num]->refcnt); -} - -/* - * nss_capwap_set_msg_callback() - * This sets the message callback handler and its associated context - */ -static void nss_capwap_set_msg_callback(int32_t if_num, nss_capwap_msg_callback_t cb, void *app_data) -{ - struct nss_capwap_handle *h; - - h = nss_capwap_hdl[if_num - NSS_DYNAMIC_IF_START]; - if (!h) { - return; - } - - h->app_data = app_data; - h->msg_callback = cb; -} - -/* - * nss_capwap_get_msg_callback() - * This gets the message callback handler and its associated context - */ -static nss_capwap_msg_callback_t nss_capwap_get_msg_callback(int32_t if_num, void **app_data) -{ - struct nss_capwap_handle *h; - - h = nss_capwap_hdl[if_num - NSS_DYNAMIC_IF_START]; - if (!h) { - *app_data = NULL; - return NULL; - } - - *app_data = h->app_data; - return h->msg_callback; -} - -/* - * nss_capwap_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) -{ - 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; - } - - /* - * Set to 1 when the tunnel is operating in fast memory. - */ - stats->fast_mem = fstats->fast_mem; -} - -/* - * nss_capwap_handler() - * Handle NSS -> HLOS messages for CAPWAP - */ -static void nss_capwap_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_capwap_msg *ntm = (struct nss_capwap_msg *)ncm; - nss_capwap_msg_callback_t cb; - - /* - * Is this a valid request/response packet? - */ - if (ncm->type > NSS_CAPWAP_MSG_TYPE_MAX) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Trace messages. - */ - nss_capwap_log_rx_msg(ntm); - - switch (ntm->cm.type) { - case NSS_CAPWAP_MSG_TYPE_SYNC_STATS: { - uint32_t if_num; - - if_num = ncm->interface - NSS_DYNAMIC_IF_START; - if (nss_capwap_hdl[if_num] != NULL) { - /* - * Update driver statistics and send statistics notifications to the registered modules. - */ - nss_capwap_update_stats(nss_capwap_hdl[if_num], &ntm->msg.stats); - nss_capwap_stats_notify(ncm->interface, nss_ctx->id); - } - } - } - - /* - * Update the callback and app_data for NOTIFY messages. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_capwap_get_msg_callback(ncm->interface, (void **)&ncm->app_data); - } - - /* - * Do we have a callback - */ - if (!ncm->cb) { - nss_trace("%px: cb is null for interface %d", nss_ctx, ncm->interface); - return; - } - - cb = (nss_capwap_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, ntm); -} - -/* - * nss_capwap_instance_alloc() - * Allocate CAPWAP tunnel instance - */ -static bool nss_capwap_instance_alloc(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - struct nss_capwap_handle *h; - - /* - * Allocate a handle - */ - h = kmalloc(sizeof(struct nss_capwap_handle), GFP_ATOMIC); - if (h == NULL) { - nss_warning("%px: no memory for allocating CAPWAP instance for interface : %d", nss_ctx, if_num); - return false; - } - - memset(h, 0, sizeof(struct nss_capwap_handle)); - h->if_num = if_num; - - spin_lock_bh(&nss_capwap_spinlock); - if (nss_capwap_hdl[if_num - NSS_DYNAMIC_IF_START] != NULL) { - spin_unlock_bh(&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); - - return true; -} - -/* - * nss_capwap_tx_msg() - * 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) -{ - struct nss_cmn_msg *ncm = &msg->cm; - int32_t status; - int32_t if_num; - - BUG_ON(in_interrupt()); - BUG_ON(in_softirq()); - BUG_ON(in_serving_softirq()); - - if (nss_capwap_verify_if_num(msg->cm.interface) == false) { - return NSS_TX_FAILURE_BAD_PARAM; - } - - if (ncm->type >= NSS_CAPWAP_MSG_TYPE_MAX) { - return NSS_TX_FAILURE_BAD_PARAM; - } - - if_num = msg->cm.interface - NSS_DYNAMIC_IF_START; - spin_lock_bh(&nss_capwap_spinlock); - if (!nss_capwap_hdl[if_num]) { - spin_unlock_bh(&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); - - /* - * Trace messages. - */ - nss_capwap_log_tx_msg(msg); - - status = nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); - nss_capwap_refcnt_dec(msg->cm.interface); - return status; -} -EXPORT_SYMBOL(nss_capwap_tx_msg); - -/* - * nss_capwap_tx_buf() - * Transmit data buffer (skb) to a NSS interface number - */ -nss_tx_status_t nss_capwap_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, uint32_t if_num) -{ - BUG_ON(!nss_capwap_verify_if_num(if_num)); - - return nss_core_send_packet(nss_ctx, os_buf, if_num, H2N_BIT_FLAG_VIRTUAL_BUFFER | H2N_BIT_FLAG_BUFFER_REUSABLE); -} -EXPORT_SYMBOL(nss_capwap_tx_buf); - -/* - *********************************** - * Register/Unregister/Miscellaneous APIs - *********************************** - */ - -/* - * nss_capwap_get_stats() - * API for getting stats from a CAPWAP tunnel interface stats - */ -bool nss_capwap_get_stats(uint32_t if_num, struct nss_capwap_tunnel_stats *stats) -{ - if (nss_capwap_verify_if_num(if_num) == false) { - return false; - } - - if_num = if_num - NSS_DYNAMIC_IF_START; - spin_lock_bh(&nss_capwap_spinlock); - if (nss_capwap_hdl[if_num] == NULL) { - spin_unlock_bh(&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); - return true; -} -EXPORT_SYMBOL(nss_capwap_get_stats); - -/* - * nss_capwap_notify_register() - * Registers a message notifier with NSS FW. It should not be called from - * softirq or interrupts. - */ -struct nss_ctx_instance *nss_capwap_notify_register(uint32_t if_num, nss_capwap_msg_callback_t cb, void *app_data) -{ - struct nss_ctx_instance *nss_ctx; - - nss_ctx = &nss_top_main.nss[nss_top_main.capwap_handler_id]; - - if (nss_capwap_verify_if_num(if_num) == false) { - nss_warning("%px: notfiy register received for invalid interface %d", nss_ctx, if_num); - return NULL; - } - - spin_lock_bh(&nss_capwap_spinlock); - if (nss_capwap_hdl[if_num - NSS_DYNAMIC_IF_START] != NULL) { - spin_unlock_bh(&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); - - return nss_ctx; -} -EXPORT_SYMBOL(nss_capwap_notify_register); - -/* - * nss_capwap_notify_unregister() - * unregister the CAPWAP notifier for the given interface number (if_num). - * It shouldn't be called from softirq or interrupts. - */ -nss_tx_status_t nss_capwap_notify_unregister(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - struct nss_top_instance *nss_top; - int index; - - if (nss_capwap_verify_if_num(if_num) == false) { - 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("%px: notify unregister received for invalid nss_top %d", nss_ctx, if_num); - return NSS_TX_FAILURE_BAD_PARAM; - } - - index = if_num - NSS_DYNAMIC_IF_START; - spin_lock_bh(&nss_capwap_spinlock); - if (nss_capwap_hdl[index] == NULL) { - spin_unlock_bh(&nss_capwap_spinlock); - nss_warning("%px: notify unregister received for unallocated if_num: %d", nss_ctx, if_num); - return NSS_TX_FAILURE_BAD_PARAM; - } - - /* - * 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); - 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); - - return NSS_TX_SUCCESS; -} -EXPORT_SYMBOL(nss_capwap_notify_unregister); - -/* - * nss_capwap_data_register() - * Registers a data packet notifier with NSS FW. - */ -struct nss_ctx_instance *nss_capwap_data_register(uint32_t if_num, nss_capwap_buf_callback_t cb, struct net_device *netdev, uint32_t features) -{ - struct nss_ctx_instance *nss_ctx; - int core_status; - - nss_ctx = nss_capwap_get_ctx(); - if (nss_capwap_verify_if_num(if_num) == false) { - nss_warning("%px: data register received for invalid interface %d", nss_ctx, if_num); - return NULL; - } - - spin_lock_bh(&nss_capwap_spinlock); - if (nss_ctx->subsys_dp_register[if_num].ndev != NULL) { - spin_unlock_bh(&nss_capwap_spinlock); - return NULL; - } - spin_unlock_bh(&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) { - 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("%px: couldn't allocate tunnel instance for if_num:%d", nss_ctx, if_num); - return NULL; - } - - nss_core_register_subsys_dp(nss_ctx, if_num, cb, NULL, NULL, netdev, features); - - return nss_ctx; -} -EXPORT_SYMBOL(nss_capwap_data_register); - -/* - * nss_capwap_data_unregister() - * Unregister a data packet notifier with NSS FW - */ -bool nss_capwap_data_unregister(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx; - struct nss_capwap_handle *h; - - nss_ctx = nss_capwap_get_ctx(); - if (nss_capwap_verify_if_num(if_num) == false) { - nss_warning("%px: data unregister received for invalid interface %d", nss_ctx, if_num); - return false; - } - - spin_lock_bh(&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); - 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); - - (void) nss_core_unregister_handler(nss_ctx, if_num); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - kfree(h); - return true; -} -EXPORT_SYMBOL(nss_capwap_data_unregister); - -/* - * nss_capwap_get_ctx() - * Return a CAPWAP NSS context. - */ -struct nss_ctx_instance *nss_capwap_get_ctx() -{ - struct nss_ctx_instance *nss_ctx; - - nss_ctx = &nss_top_main.nss[nss_top_main.capwap_handler_id]; - return nss_ctx; -} -EXPORT_SYMBOL(nss_capwap_get_ctx); - -/* - * nss_capwap_ifnum_with_core_id() - * Append core id to capwap interface num - */ -int nss_capwap_ifnum_with_core_id(int if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_capwap_get_ctx(); - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - if (nss_is_dynamic_interface(if_num) == false) { - 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); -} -EXPORT_SYMBOL(nss_capwap_ifnum_with_core_id); - -/* - * nss_capwap_get_max_buf_size() - * Return a CAPWAP NSS max_buf_size. - */ -uint32_t nss_capwap_get_max_buf_size(struct nss_ctx_instance *nss_ctx) -{ - return nss_core_get_max_buf_size(nss_ctx); -} -EXPORT_SYMBOL(nss_capwap_get_max_buf_size); - -/* - * nss_capwap_init() - * Initializes CAPWAP. Gets called from nss_init.c - */ -void nss_capwap_init() -{ - memset(&nss_capwap_hdl, 0, sizeof(nss_capwap_hdl)); - nss_capwap_stats_dentry_create(); - nss_capwap_strings_dentry_create(); -} - -/* - * nss_capwap_msg_init() - * Initialize capwap message. - */ -void nss_capwap_msg_init(struct nss_capwap_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, - nss_capwap_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, (void*)cb, app_data); -} -EXPORT_SYMBOL(nss_capwap_msg_init); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_capwap_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_capwap_log.c deleted file mode 100644 index b0b8564ac..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_capwap_log.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_capwap_log.c - * NSS CAPWAP logger file. - */ - -#include "nss_core.h" - -/* - * nss_capwap_log_message_types_str - * CAPWAP message strings - */ -static int8_t *nss_capwap_log_message_types_str[NSS_CAPWAP_MSG_TYPE_MAX] __maybe_unused = { - "No Message", - "CAPWAP config Rule", - "CAPWAP unconfig Rule", - "CAPWAP Enable Tunnel", - "CAPWAP Disable Tunnel", - "CAPWAP Update Path MTU", - "CAPWAP Sync Stats", - "CAPWAP Version", - "CAPWAP DTLS", - "CAPWAP Add Flow Rule", - "CAPWAP Delete Flow Rule" -}; - -/* - * nss_capwap_log_error_response_types_str - * Strings for error types for CAPWAP messages - */ -static int8_t *nss_capwap_log_error_response_types_str[NSS_CAPWAP_ERROR_MSG_MAX] __maybe_unused = { - "CAPWAP Invalid Reassembly Timeout", - "CAPWAP Invalid PAth MTU", - "CAPWAP Invalid Max Fragment", - "CAPWAP Invalid Buffer Size", - "CAPWAP Invalid L3 Protocool", - "CAPWAP Invalid UDP Protocol", - "CAPWAP Invalid Version", - "CAPWAP Tunnel Disabled", - "CAPWAP Tunnel Enabled", - "CAPWAP Tunnel Not Configured", - "CAPWAP Invalid IP Node", - "CAPWAP Invalid Type Flag", - "CAPWAP Inavlid DTLS Config", - "CAPWAP Flow Table Full", - "CAPWAP Flow Exists", - "CAPWAP Flow Does Not Exist" -}; - -/* - * nss_capwap_rule_msg() - * Log NSS CAPWAP stats message. - */ -static void nss_capwap_rule_msg(struct nss_capwap_msg *ncm) -{ - struct nss_capwap_rule_msg *ncrm __maybe_unused = &ncm->msg.rule; - nss_trace("%px: NSS CAPWAP Rule message \n" - "Encap Rule Src IP: %px\n" - "Encap Rule Src Port: %d\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" - "Decap Rule Max Fragments: %d\n" - "Decap Rule Max Buffer Size: %d\n" - "Stats Timer: %d\n" - "RPS: %d\n" - "Type Flags: %x\n" - "L3 Protocol: %d\n" - "UDP Protocol: %d\n" - "MTU: %d\n" - "GMAC Interface Number: %d\n" - "Enabled Features: %x\n" - "DTLS Interface Number: %d\n" - "BSSID: %px\n" - "Outer Segment Value: %x\n", - ncrm, - &ncrm->encap.src_ip.ip, - ncrm->encap.src_port, - &ncrm->encap.dest_ip.ip, - ncrm->encap.dest_port, - ncrm->encap.path_mtu, - ncrm->decap.reassembly_timeout, - ncrm->decap.max_fragments, - ncrm->decap.max_buffer_size, - ncrm->stats_timer, - ncrm->rps, ncrm->type_flags, - ncrm->l3_proto, ncrm->which_udp, - ncrm->mtu_adjust, ncrm->gmac_ifnum, - ncrm->enabled_features, - ncrm->dtls_inner_if_num, - &ncrm->bssid, ncrm->outer_sgt_value); -} - -/* - * nss_capwap_path_mtu_msg() - * Log NSS CAPWAP path MTU message. - */ -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("%px: NSS CAPWAP Path MTU message \n" - "CAPWAP Path MTU: %d\n", - ncpmm, - ncpmm->path_mtu); -} - -/* - * nss_capwap_version_msg() - * Log NSS CAPWAP version message. - */ -static void nss_capwap_version_msg(struct nss_capwap_msg *ncm) -{ - struct nss_capwap_version_msg *ncvm __maybe_unused = &ncm->msg.version; - nss_trace("%px: NSS CAPWAP Version message \n" - "CAPWAP Version: %d\n", - ncvm, - ncvm->version); -} - -/* - * nss_capwap_dtls_msg() - * Log NSS CAPWAP dtls message. - */ -static void nss_capwap_dtls_msg(struct nss_capwap_msg *ncm) -{ - struct nss_capwap_dtls_msg *ncdm __maybe_unused = &ncm->msg.dtls; - 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" - "CAPWAP Reserved: %x\n", - ncdm, - ncdm->enable, ncdm->dtls_inner_if_num, - ncdm->mtu_adjust, ncdm->reserved); -} - -/* - * nss_capwap_flow_rule_msg() - * Log NSS CAPWAP flow rule message. - */ -static void nss_capwap_flow_rule_msg(struct nss_capwap_flow_rule_msg *ncfrm) -{ - 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" - "CAPWAP Destination Port: %d\n" - "CAPWAP Source IP: %x %x %x %x\n" - "CAPWAP Destination IP: %x %x %x %x" - "CAPWAP Flow ID: %d", - ncfrm, - ncfrm->ip_version, ncfrm->protocol, - ncfrm->src_port, ncfrm->dst_port, - ncfrm->src_ip[0], ncfrm->src_ip[1], - ncfrm->src_ip[2], ncfrm->src_ip[3], - ncfrm->dst_ip[0], ncfrm->dst_ip[1], - ncfrm->dst_ip[2], ncfrm->dst_ip[3], - ncfrm->flow_id); -} - -/* - * nss_capwap_flow_rule_add_msg() - * Log NSS CAPWAP flow rule add message. - */ -static void nss_capwap_flow_rule_add_msg(struct nss_capwap_msg *ncm) -{ - struct nss_capwap_flow_rule_msg *ncfrm __maybe_unused = &ncm->msg.flow_rule_add; - nss_capwap_flow_rule_msg(ncfrm); -} - -/* - * nss_capwap_flow_rule_del_msg() - * Log NSS CAPWAP flow rule del message. - */ -static void nss_capwap_flow_rule_del_msg(struct nss_capwap_msg *ncm) -{ - struct nss_capwap_flow_rule_msg *ncfrm __maybe_unused = &ncm->msg.flow_rule_del; - nss_capwap_flow_rule_msg(ncfrm); -} - -/* - * nss_capwap_log_verbose() - * Log message contents. - */ -static void nss_capwap_log_verbose(struct nss_capwap_msg *ncm) -{ - switch (ncm->cm.type) { - case NSS_CAPWAP_MSG_TYPE_CFG_RULE: - nss_capwap_rule_msg(ncm); - break; - - case NSS_CAPWAP_MSG_TYPE_UPDATE_PATH_MTU: - nss_capwap_path_mtu_msg(ncm); - break; - - case NSS_CAPWAP_MSG_TYPE_VERSION: - nss_capwap_version_msg(ncm); - break; - - case NSS_CAPWAP_MSG_TYPE_DTLS: - nss_capwap_dtls_msg(ncm); - break; - - case NSS_CAPWAP_MSG_TYPE_FLOW_RULE_ADD: - nss_capwap_flow_rule_add_msg(ncm); - break; - - case NSS_CAPWAP_MSG_TYPE_FLOW_RULE_DEL: - nss_capwap_flow_rule_del_msg(ncm); - break; - - default: - nss_trace("%px: Invalid message type\n", ncm); - break; - } -} - -/* - * nss_capwap_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_capwap_log_tx_msg(struct nss_capwap_msg *ncm) -{ - if (ncm->cm.type >= NSS_CAPWAP_MSG_TYPE_MAX) { - nss_warning("%px: Invalid message type\n", ncm); - return; - } - - 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); -} - -/* - * nss_capwap_log_rx_msg() - * Log messages received from FW. - */ -void nss_capwap_log_rx_msg(struct nss_capwap_msg *ncm) -{ - if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_capwap_log_verbose(ncm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_capwap_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_capwap_log.h deleted file mode 100644 index f62098979..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_capwap_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_CAPWAP_LOG_H__ -#define __NSS_CAPWAP_LOG_H__ - -/* - * nss_capwap_log.h - * NSS CAPWAP Log Header File. - */ - -/* - * nss_capwap_log_tx_msg - * Logs a CAPWAP message that is sent to the NSS firmware. - */ -void nss_capwap_log_tx_msg(struct nss_capwap_msg *ncm); - -/* - * nss_capwap_log_rx_msg - * Logs a CAPWAP message that is received from the NSS firmware. - */ -void nss_capwap_log_rx_msg(struct nss_capwap_msg *ncm); - -#endif /* __NSS_CAPWAP_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_capwap_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_capwap_stats.c deleted file mode 100644 index 1d4387808..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_capwap_stats.c +++ /dev/null @@ -1,313 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -#include "nss_drv_stats.h" -#include "nss_core.h" -#include "nss_capwap.h" -#include "nss_capwap_stats.h" -#include "nss_capwap_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_capwap_stats_notifier); - -/* - * nss_capwap_stats_encap() - * Make a row for CAPWAP encap stats. - */ -static ssize_t nss_capwap_stats_encap(char *line, int len, int i, struct nss_capwap_tunnel_stats *s) -{ - uint64_t tcnt = 0; - - switch (i) { - case 0: - tcnt = s->pnode_stats.tx_packets; - break; - case 1: - tcnt = s->pnode_stats.tx_bytes; - break; - case 2: - tcnt = s->tx_segments; - break; - case 3: - tcnt = s->tx_dropped_sg_ref; - break; - case 4: - tcnt = s->tx_dropped_ver_mis; - break; - case 5: - tcnt = s->tx_dropped_inner; - break; - case 6: - tcnt = s->tx_dropped_hroom; - break; - case 7: - tcnt = s->tx_dropped_dtls; - break; - case 8: - tcnt = s->tx_dropped_nwireless; - break; - case 9: - tcnt = s->tx_queue_full_drops; - break; - case 10: - tcnt = s->tx_mem_failure_drops; - break; - case 11: - tcnt = s->fast_mem; - break; - default: - return 0; - } - - return snprintf(line, len, "%s = %llu\n", nss_capwap_strings_encap_stats[i].stats_name, tcnt); -} - -/* - * nss_capwap_stats_decap() - * Make a row for CAPWAP decap stats. - */ -static ssize_t nss_capwap_stats_decap(char *line, int len, int i, struct nss_capwap_tunnel_stats *s) -{ - uint64_t tcnt = 0; - - switch (i) { - case 0: - tcnt = s->pnode_stats.rx_packets; - break; - case 1: - tcnt = s->pnode_stats.rx_bytes; - break; - case 2: - tcnt = s->dtls_pkts; - break; - case 3: - tcnt = s->rx_segments; - break; - case 4: - tcnt = s->pnode_stats.rx_dropped; - break; - case 5: - tcnt = s->rx_oversize_drops; - break; - case 6: - tcnt = s->rx_frag_timeout_drops; - break; - case 7: - tcnt = s->rx_dup_frag; - break; - case 8: - tcnt = s->rx_frag_gap_drops; - break; - case 9: - tcnt = s->rx_n2h_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; - break; - case 11: - tcnt = s->rx_mem_failure_drops; - break; - case 12: - tcnt = s->rx_csum_drops; - break; - case 13: - tcnt = s->rx_malformed; - break; - case 14: - tcnt = s->fast_mem; - break; - default: - return 0; - } - - return snprintf(line, len, "%s = %llu\n", nss_capwap_strings_decap_stats[i].stats_name, tcnt); -} - -/* - * nss_capwap_stats_read() - * Read CAPWAP stats - */ -static ssize_t nss_capwap_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos, uint16_t type) -{ - struct nss_stats_data *data = fp->private_data; - ssize_t bytes_read = 0; - struct nss_capwap_tunnel_stats stats; - size_t bytes; - char line[80]; - int start; - uint32_t if_num = NSS_DYNAMIC_IF_START; - uint32_t max_if_num = NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES; - - if (data) { - if_num = data->if_num; - } - - /* - * If we are done accomodating all the CAPWAP tunnels. - */ - if (if_num > max_if_num) { - return 0; - } - - 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)) { - continue; - } - - /* - * If CAPWAP tunnel does not exists, then isthere will be false. - */ - isthere = nss_capwap_get_stats(if_num, &stats); - if (!isthere) { - continue; - } - - bytes = snprintf(line, sizeof(line), "----if_num : %2d----\n", if_num); - 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 = 0; - while (bytes_read < sz) { - if (type == 1) { - bytes = nss_capwap_stats_encap(line, sizeof(line), start, &stats); - } else { - bytes = nss_capwap_stats_decap(line, sizeof(line), start, &stats); - } - - /* - * If we don't have any more lines in decap/encap. - */ - if (bytes == 0) { - break; - } - - 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; - } - - if (data) { - data->if_num = if_num; - } -fail: - return bytes_read; -} - -/* - * nss_capwap_decap_stats_read() - * Read CAPWAP decap stats - */ -static ssize_t nss_capwap_decap_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_capwap_stats_read(fp, ubuf, sz, ppos, 0); -} - -/* - * nss_capwap_encap_stats_read() - * Read CAPWAP encap stats - */ -static ssize_t nss_capwap_encap_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_capwap_stats_read(fp, ubuf, sz, ppos, 1); -} - -/* - * nss_capwap_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(capwap_encap); -NSS_STATS_DECLARE_FILE_OPERATIONS(capwap_decap); - -/* - * nss_capwap_stats_dentry_create() - * Create CAPWAP statistics debug entry - */ -void nss_capwap_stats_dentry_create(void) -{ - nss_stats_create_dentry("capwap_encap", &nss_capwap_encap_stats_ops); - nss_stats_create_dentry("capwap_decap", &nss_capwap_decap_stats_ops); -} - -/* - * nss_capwap_stats_notify() - * Sends notifications to the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_capwap_stats_notify(uint32_t if_num, uint32_t core_id) -{ - struct nss_capwap_stats_notification capwap_stats; - - capwap_stats.core_id = core_id; - capwap_stats.if_num = if_num; - nss_capwap_get_stats(if_num, &capwap_stats.stats); - atomic_notifier_call_chain(&nss_capwap_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&capwap_stats); -} - -/* - * nss_capwap_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_capwap_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_capwap_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_capwap_stats_register_notifier); - -/* - * nss_capwap_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_capwap_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_capwap_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_capwap_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_capwap_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_capwap_stats.h deleted file mode 100644 index c1033ec15..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_capwap_stats.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - ****************************************************************************** - * 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. - * **************************************************************************** - */ - -#ifndef __NSS_CAPWAP_STATS_H__ -#define __NSS_CAPWAP_STATS_H__ - -/* - * CAPWAP statistics APIs - */ -extern void nss_capwap_stats_notify(uint32_t if_num, uint32_t core_id); -extern void nss_capwap_stats_dentry_create(void); - -#endif /* __NSS_CAPWAP_STATS_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_capwap_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_capwap_strings.c deleted file mode 100644 index 266cd50b8..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_capwap_strings.c +++ /dev/null @@ -1,102 +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 -#include "nss_strings.h" -#include "nss_capwap_strings.h" - -/* - * nss_capwap_strings_encap_stats - * CAPWAP encap statistics string. - */ -struct nss_stats_info nss_capwap_strings_encap_stats[NSS_CAPWAP_STATS_ENCAP_MAX] = { - {"tx_packets", NSS_STATS_TYPE_COMMON}, - {"tx_bytes", NSS_STATS_TYPE_COMMON}, - {"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_hroom", NSS_STATS_TYPE_DROP}, - {"tx_drop_DTLS", NSS_STATS_TYPE_DROP}, - {"tx_drop_nwireless", NSS_STATS_TYPE_DROP}, - {"tx_drop_qfull", NSS_STATS_TYPE_DROP}, - {"tx_drop_mem_fail", NSS_STATS_TYPE_DROP}, - {"fast_mem", NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_capwap_encap_strings_read() - * Read CAPWAP encap statistics names. - */ -static ssize_t nss_capwap_encap_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_capwap_strings_encap_stats, NSS_CAPWAP_STATS_ENCAP_MAX); -} - -/* - * nss_capwap_encap_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(capwap_encap); - -/* - * nss_capwap_strings_decap_stats - * CAPWAP decap statistics string. - */ -struct nss_stats_info nss_capwap_strings_decap_stats[NSS_CAPWAP_STATS_DECAP_MAX] = { - {"rx_packets", NSS_STATS_TYPE_COMMON}, - {"rx_bytes", NSS_STATS_TYPE_COMMON}, - {"rx_DTLS_pkts", NSS_STATS_TYPE_SPECIAL}, - {"rx_segments", NSS_STATS_TYPE_SPECIAL}, - {"rx_dropped", NSS_STATS_TYPE_DROP}, - {"rx_drop_oversize", NSS_STATS_TYPE_DROP}, - {"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_n2h_qfull", NSS_STATS_TYPE_DROP}, - {"rx_drop_mem_fail", NSS_STATS_TYPE_DROP}, - {"rx_drop_csum", NSS_STATS_TYPE_DROP}, - {"rx_drop_malformed", NSS_STATS_TYPE_DROP}, - {"fast_mem", NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_capwap_decap_strings_read() - * Read CAPWAP decap statistics names. - */ -static ssize_t nss_capwap_decap_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_capwap_strings_decap_stats, NSS_CAPWAP_STATS_DECAP_MAX); -} - -/* - * nss_capwap_decap_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(capwap_decap); - -/* - * nss_capwap_strings_dentry_create() - * Create CAPWAP statistics strings debug entry. - */ -void nss_capwap_strings_dentry_create(void) -{ - nss_strings_create_dentry("capwap_encap", &nss_capwap_encap_strings_ops); - nss_strings_create_dentry("capwap_decap", &nss_capwap_decap_strings_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_capwap_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_capwap_strings.h deleted file mode 100644 index 96f89cdce..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_capwap_strings.h +++ /dev/null @@ -1,28 +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_CAPWAP_STRINGS_H -#define __NSS_CAPWAP_STRINGS_H - -#include "nss_capwap_stats.h" - -extern struct nss_stats_info nss_capwap_strings_encap_stats[NSS_CAPWAP_STATS_ENCAP_MAX]; -extern struct nss_stats_info nss_capwap_strings_decap_stats[NSS_CAPWAP_STATS_DECAP_MAX]; -extern void nss_capwap_strings_dentry_create(void); - -#endif /* __NSS_CAPWAP_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_clmap.c b/feeds/ipq807x/qca-nss-drv/src/nss_clmap.c deleted file mode 100644 index 777b71936..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_clmap.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_clmap.c - * NSS clmap driver interface APIs - */ -#include "nss_core.h" -#include "nss_clmap.h" -#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 - -/* - * Private data structure - */ -static struct nss_clmap_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. */ -} clmap_pvt; - -/* - * nss_clmap_verify_if_num() - * Verify if_num passed to us. - */ -static bool nss_clmap_verify_if_num(uint32_t if_num) -{ - uint32_t type = nss_dynamic_interface_get_type(nss_clmap_get_ctx(), if_num); - - return ((type == NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_US) || - (type == NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_DS)); -} - -/* - * nss_clmap_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_clmap_callback(void *app_data, struct nss_clmap_msg *nclm) -{ - clmap_pvt.response = NSS_TX_SUCCESS; - clmap_pvt.cb = NULL; - clmap_pvt.app_data = NULL; - - if (nclm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("clmap Error response %d\n", nclm->cm.response); - clmap_pvt.response = nclm->cm.response; - } - - /* - * Write memory barrier. - */ - smp_wmb(); - complete(&clmap_pvt.complete); -} - -/* - * nss_clmap_handler() - * Handle NSS -> HLOS messages for clmap. - */ -static void nss_clmap_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_clmap_msg *nclm = (struct nss_clmap_msg *)ncm; - nss_clmap_msg_callback_t cb; - - BUG_ON(!nss_clmap_verify_if_num(ncm->interface)); - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_CLMAP_MSG_TYPE_MAX) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Trace messages. - */ - nss_core_log_msg_failures(nss_ctx, ncm); - nss_clmap_log_rx_msg(nclm); - - 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; - } - - /* - * 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; - } - - /* - * Do we have a callback - */ - cb = (nss_clmap_msg_callback_t)ncm->cb; - if (!cb) { - nss_trace("%px: cb is null for interface %d", nss_ctx, ncm->interface); - return; - } - - cb((void *)ncm->app_data, ncm); -} - -/* - * nss_clmap_tx_msg() - * Transmit a clmap message to NSS FW. Don't call this from softirq/interrupts. - */ -nss_tx_status_t nss_clmap_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_clmap_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - if (!nss_clmap_verify_if_num(msg->cm.interface)) { - return NSS_TX_FAILURE_BAD_PARAM; - } - - if (ncm->type >= NSS_CLMAP_MSG_TYPE_MAX) { - return NSS_TX_FAILURE_BAD_PARAM; - } - - /* - * Trace messages. - */ - nss_clmap_log_tx_msg(msg); - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_clmap_tx_msg); - -/* - * nss_clmap_tx_msg_sync() - * Transmit a clmap message to NSS firmware synchronously. - */ -nss_tx_status_t nss_clmap_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_clmap_msg *nclm) -{ - nss_tx_status_t status; - int ret; - - down(&clmap_pvt.sem); - nclm->cm.cb = (nss_ptr_t)nss_clmap_callback; - nclm->cm.app_data = (nss_ptr_t)NULL; - - status = nss_clmap_tx_msg(nss_ctx, nclm); - if (status != NSS_TX_SUCCESS) { - 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("%px: clmap tx sync failed due to timeout\n", nss_ctx); - clmap_pvt.response = NSS_TX_FAILURE; - } - - status = clmap_pvt.response; - up(&clmap_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_clmap_tx_msg_sync); - -/* - * nss_clmap_tx_buf() - * Transmit data buffer (skb) to a NSS interface number - */ -nss_tx_status_t nss_clmap_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *buf, uint32_t if_num) -{ - BUG_ON(!nss_clmap_verify_if_num(if_num)); - - return nss_core_send_packet(nss_ctx, buf, if_num, H2N_BIT_FLAG_VIRTUAL_BUFFER); -} -EXPORT_SYMBOL(nss_clmap_tx_buf); - -/* - * nss_clmap_unregister() - * Un-register a clmap interface from NSS. - */ -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("%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_core_unregister_subsys_dp(nss_ctx, if_num); - nss_core_unregister_handler(nss_ctx, if_num); - nss_clmap_stats_session_unregister(if_num); - - return true; -} -EXPORT_SYMBOL(nss_clmap_unregister); - -/* - * nss_clmap_register() - * Registers a clmap interface with the NSS. - */ -struct nss_ctx_instance *nss_clmap_register(uint32_t if_num, - uint32_t di_type, - nss_clmap_buf_callback_t data_cb, - nss_clmap_msg_callback_t notify_cb, - struct net_device *netdev, - uint32_t features) -{ - struct nss_ctx_instance *nss_ctx; - int core_status; - bool stats_status = false; - - nss_ctx = nss_clmap_get_ctx(); - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (!nss_clmap_verify_if_num(if_num)) { - 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) { - stats_status = nss_clmap_stats_session_register(if_num, NSS_CLMAP_INTERFACE_TYPE_US, netdev); - } else { - stats_status = nss_clmap_stats_session_register(if_num, NSS_CLMAP_INTERFACE_TYPE_DS, netdev); - } - - if (!stats_status) { - 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) { - 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); - - 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); - -/* - * nss_clmap_ifnum_with_core_id() - * Append core ID to clmap interface num. - */ -int nss_clmap_ifnum_with_core_id(int if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_clmap_get_ctx(); - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - if (!nss_is_dynamic_interface(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); -} -EXPORT_SYMBOL(nss_clmap_ifnum_with_core_id); - -/* - * nss_clmap_msg_init() - * Initialize clmap message. - */ -void nss_clmap_msg_init(struct nss_clmap_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, - nss_clmap_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, (void*)cb, app_data); -} -EXPORT_SYMBOL(nss_clmap_msg_init); - -/* - * nss_clmap_get_ctx() - * Return a clmap NSS context. - */ -struct nss_ctx_instance *nss_clmap_get_ctx() -{ - struct nss_ctx_instance *nss_ctx; - - nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.clmap_handler_id]; - return nss_ctx; -} -EXPORT_SYMBOL(nss_clmap_get_ctx); - -/* - * nss_clmap_init() - * Initializes clmap. Gets called from nss_init.c. - */ -void nss_clmap_init() -{ - sema_init(&clmap_pvt.sem, 1); - init_completion(&clmap_pvt.complete); - - nss_clmap_stats_dentry_create(); - nss_clmap_strings_dentry_create(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_clmap_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_clmap_log.c deleted file mode 100644 index 45cb0a734..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_clmap_log.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_clmap_log.c - * NSS clmap logger file. - */ - -#include "nss_core.h" - -/* - * nss_clmap_log_message_types_str - * clmap message strings - */ -static char *nss_clmap_log_message_types_str[NSS_CLMAP_MSG_TYPE_MAX] __maybe_unused = { - "Clmap sync stats", - "Clmap enable interface", - "Clmap disable interface", - "Clmap add MAC rule", - "Clmap delete MAC rule", - "Clmap flush MAC rule" -}; - -/* - * nss_clmap_log_error_types_str - * Strings for error types for clmap messages - */ -static char *nss_clmap_log_error_types_str[NSS_CLMAP_ERROR_MAX] __maybe_unused = { - "Clmap unknown error", - "Clmap interface disabled", - "Clmap interface enabled", - "Clmap invalid VLAN", - "Clmap invalid tunnel ID", - "Clmap MAC table full", - "Clmap MAC exists", - "Clmap MAC does not exist", - "Clmap MAC entry unhashed", - "Clmap MAC entry insert failed", - "Clmap MAC entry alloc failed", - "Clmap MAC entry delete failed" -}; - -/* - * nss_clmap_log_mac_msg() - * Log NSS clmap MAC rule message. - */ -static void nss_clmap_log_mac_msg(struct nss_clmap_mac_msg *npvcm) -{ - nss_trace("%px: NSS clmap MAC message \n" - "Clmap Mac Addr: %x : %x : %x" - "Clmap Flags: %u\n" - "Clmap VLAN ID: %u\n" - "Clmap Next-hop Interface Number: %d\n", - npvcm, - npvcm->mac_addr[0], npvcm->mac_addr[1], - npvcm->mac_addr[2], npvcm->flags, - npvcm->vlan_id, npvcm->nexthop_ifnum); -} - -/* - * nss_clmap_log_interface_enable_msg() - * Log NSS clmap rule enable message. - */ -static void nss_clmap_log_interface_enable_msg(struct nss_clmap_msg *npvm) -{ - nss_trace("%px: NSS clmap interface state message: Enable \n", npvm); -} - -/* - * nss_clmap_log_interface_disable_msg() - * Log NSS clmap rule disable message. - */ -static void nss_clmap_log_interface_disable_msg(struct nss_clmap_msg *npvm) -{ - nss_trace("%px: NSS clmap interface state message: Disable \n", npvm); -} - -/* - * nss_clmap_log_mac_add_msg() - * Log NSS clmap mac rule add message. - */ -static void nss_clmap_log_mac_add_msg(struct nss_clmap_msg *npvm) -{ - struct nss_clmap_mac_msg *npvcm __maybe_unused = &npvm->msg.mac_add; - nss_clmap_log_mac_msg(npvcm); -} - -/* - * nss_clmap_log_mac_del_msg() - * Log NSS clmap mac rule del message. - */ -static void nss_clmap_log_mac_del_msg(struct nss_clmap_msg *npvm) -{ - struct nss_clmap_mac_msg *npvcm __maybe_unused = &npvm->msg.mac_del; - nss_clmap_log_mac_msg(npvcm); -} - -/* - * nss_clmap_log_mac_flush_msg() - * Log NSS clmap mac rule flush message. - */ -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("%px: NSS clmap MAC flush message \n" - "Clmap Next-hop Interface Number: %d\n", - npvcm, npvcm->nexthop_ifnum); -} - -/* - * nss_clmap_log_verbose() - * Log message contents. - */ -static void nss_clmap_log_verbose(struct nss_clmap_msg *npvm) -{ - switch (npvm->cm.type) { - case NSS_CLMAP_MSG_TYPE_INTERFACE_ENABLE: - nss_clmap_log_interface_enable_msg(npvm); - break; - - case NSS_CLMAP_MSG_TYPE_INTERFACE_DISABLE: - nss_clmap_log_interface_disable_msg(npvm); - break; - - case NSS_CLMAP_MSG_TYPE_MAC_ADD: - nss_clmap_log_mac_add_msg(npvm); - break; - - case NSS_CLMAP_MSG_TYPE_MAC_DEL: - nss_clmap_log_mac_del_msg(npvm); - break; - - case NSS_CLMAP_MSG_TYPE_MAC_FLUSH: - nss_clmap_log_mac_flush_msg(npvm); - break; - - case NSS_CLMAP_MSG_TYPE_SYNC_STATS: - break; - - default: - nss_trace("%px: Invalid message type\n", npvm); - break; - } -} - -/* - * nss_clmap_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_clmap_log_tx_msg(struct nss_clmap_msg *npvm) -{ - if (npvm->cm.type >= NSS_CLMAP_MSG_TYPE_MAX) { - nss_warning("%px: Invalid message type\n", npvm); - return; - } - - 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); -} - -/* - * nss_clmap_log_rx_msg() - * Log messages received from FW. - */ -void nss_clmap_log_rx_msg(struct nss_clmap_msg *npvm) -{ - if (npvm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_clmap_log_verbose(npvm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_clmap_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_clmap_log.h deleted file mode 100644 index 6d193d315..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_clmap_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_LOG_H__ -#define __NSS_CLMAP_LOG_H__ - -/* - * nss_clmap_log.h - * NSS clmap Log Header File. - */ - -/* - * nss_clmap_log_tx_msg - * Logs a clmap message that is sent to the NSS firmware. - */ -void nss_clmap_log_tx_msg(struct nss_clmap_msg *ncm); - -/* - * nss_clmap_log_rx_msg - * Logs a clmap message that is received from the NSS firmware. - */ -void nss_clmap_log_rx_msg(struct nss_clmap_msg *ncm); - -#endif /* __NSS_CLMAP_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_clmap_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_clmap_stats.c deleted file mode 100644 index a75bffffe..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_clmap_stats.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_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. - */ -static char *nss_clmap_interface_type_str[NSS_CLMAP_INTERFACE_TYPE_MAX] = { - "Upstream", - "Downstream" -}; - -/* - * 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_stats_session_register - * Register debug statistic for clmap session. - */ -bool nss_clmap_stats_session_register(uint32_t if_num, uint32_t if_type, struct net_device *netdev) -{ - uint32_t i; - bool stats_status = false; - - if (!netdev) { - nss_warning("Could not allocate statistics memory as the net device is NULL!\n"); - return stats_status; - } - - spin_lock_bh(&nss_clmap_stats_lock); - for (i = 0; i < NSS_CLMAP_MAX_DEBUG_INTERFACES; i++) { - 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("%px: could not allocate memory for statistics database for interface id: %d\n", netdev, if_num); - break; - } - stats_db[i]->valid = true; - stats_db[i]->nss_if_num = if_num; - stats_db[i]->nss_if_type = if_type; - stats_db[i]->if_index = netdev->ifindex; - stats_status = true; - break; - } - } - spin_unlock_bh(&nss_clmap_stats_lock); - return stats_status; -} - -/* - * nss_clmap_get_debug_stats() - * Get clmap debug statistics. - */ -static int nss_clmap_get_debug_stats(struct nss_clmap_stats *stats) -{ - uint32_t i; - int interface_cnt = 0; - - spin_lock_bh(&nss_clmap_stats_lock); - for (i = 0; i < NSS_CLMAP_MAX_DEBUG_INTERFACES; i++) { - if (stats_db[i]) { - memcpy(stats, stats_db[i], sizeof(struct nss_clmap_stats)); - stats++; - interface_cnt++; - } - } - spin_unlock_bh(&nss_clmap_stats_lock); - - return interface_cnt; -} - -/* - * nss_clmap_stats_read() - * Read clmap statistics - */ -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; - 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; - struct nss_clmap_stats *clmap_stats = NULL; - int interface_cnt; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(!lbuf)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - /* - * Allocate statistics memory only for all interfaces. - */ - clmap_stats = kzalloc((NSS_CLMAP_MAX_DEBUG_INTERFACES * sizeof(struct nss_clmap_stats)), GFP_KERNEL); - if (unlikely(!clmap_stats)) { - nss_warning("Could not allocate memory for populating clmap statistics\n"); - kfree(lbuf); - return 0; - } - - /* - * 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); - for (id = 0; id < interface_cnt; id++) { - struct nss_clmap_stats *clmsp = clmap_stats + id; - - if (unlikely(!clmsp->valid)) { - continue; - } - - dev = dev_get_by_index(&init_net, clmsp->if_index); - if (unlikely(!dev)) { - nss_warning("No netdev available for nss interface id:%d\n", clmsp->nss_if_num); - continue; - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, interface type=%s, netdevice=%s\n", id, - 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); - } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - - kfree(clmap_stats); - kfree(lbuf); - return bytes_read; -} - -/* - * nss_clmap_stats_sync() - * Sync function for clmap statistics - */ -void nss_clmap_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_clmap_stats_msg *stats_msg, uint32_t if_num) -{ - uint32_t i; - struct nss_clmap_stats *s = NULL; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - 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)) { - s = stats_db[i]; - break; - } - } - - if (!s) { - spin_unlock_bh(&nss_clmap_stats_lock); - nss_warning("%px: Interface not found: %u", nss_ctx, if_num); - return; - } - - s->stats[NSS_CLMAP_INTERFACE_STATS_RX_PKTS] += stats_msg->node_stats.rx_packets; - s->stats[NSS_CLMAP_INTERFACE_STATS_RX_BYTES] += stats_msg->node_stats.rx_bytes; - s->stats[NSS_CLMAP_INTERFACE_STATS_TX_PKTS] += stats_msg->node_stats.tx_packets; - s->stats[NSS_CLMAP_INTERFACE_STATS_TX_BYTES] += stats_msg->node_stats.tx_bytes; - - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - s->stats[NSS_CLMAP_INTERFACE_STATS_RX_QUEUE_0_DROPPED + i] += stats_msg->node_stats.rx_dropped[i]; - } - - s->stats[NSS_CLMAP_INTERFACE_STATS_DROPPED_MACDB_LOOKUP_FAILED] += stats_msg->dropped_macdb_lookup_failed; - s->stats[NSS_CLMAP_INTERFACE_STATS_DROPPED_INVALID_PACKET_SIZE] += stats_msg->dropped_invalid_packet_size; - s->stats[NSS_CLMAP_INTERFACE_STATS_DROPPED_LOW_HEADROOM] += stats_msg->dropped_low_hroom; - s->stats[NSS_CLMAP_INTERFACE_STATS_DROPPED_NEXT_NODE_QUEUE_FULL] += stats_msg->dropped_next_node_queue_full; - s->stats[NSS_CLMAP_INTERFACE_STATS_DROPPED_PBUF_ALLOC_FAILED] += stats_msg->dropped_pbuf_alloc_failed; - s->stats[NSS_CLMAP_INTERFACE_STATS_DROPPED_LINEAR_FAILED] += stats_msg->dropped_linear_failed; - s->stats[NSS_CLMAP_INTERFACE_STATS_SHARED_PACKET_CNT] += stats_msg->shared_packet_count; - s->stats[NSS_CLMAP_INTERFACE_STATS_ETHERNET_FRAME_ERROR] += stats_msg->ethernet_frame_error; - s->stats[NSS_CLMAP_INTERFACE_STATS_MACDB_CREATE_REQUESTS_CNT] += stats_msg->macdb_create_requests; - s->stats[NSS_CLMAP_INTERFACE_STATS_MACDB_CREATE_MAC_EXISTS_CNT] += stats_msg->macdb_create_mac_exists; - s->stats[NSS_CLMAP_INTERFACE_STATS_MACDB_CREATE_MAC_TABLE_FULL_CNT] += stats_msg->macdb_create_table_full; - s->stats[NSS_CLMAP_INTERFACE_STATS_MACDB_DESTROY_REQUESTS_CNT] += stats_msg->macdb_destroy_requests; - s->stats[NSS_CLMAP_INTERFACE_STATS_MACDB_DESTROY_MAC_NOT_FOUND_CNT] += stats_msg->macdb_destroy_mac_notfound; - s->stats[NSS_CLMAP_INTERFACE_STATS_MACDB_DESTROY_MAC_UNHASHED_CNT] += stats_msg->macdb_destroy_mac_unhashed; - s->stats[NSS_CLMAP_INTERFACE_STATS_MACDB_FLUSH_REQUESTS_CNT] += stats_msg->macdb_flush_requests; - spin_unlock_bh(&nss_clmap_stats_lock); -} - -/* - * nss_clmap_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(clmap) - -/* - * nss_clmap_stats_dentry_create() - * Create client map statistics debug entry. - */ -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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_clmap_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_clmap_stats.h deleted file mode 100644 index 89f687dab..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_clmap_stats.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - ****************************************************************************** - * Copyright (c) 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. - * 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_STATS_H -#define __NSS_CLMAP_STATS_H - -#define NSS_CLMAP_MAX_DEBUG_INTERFACES 2 * NSS_CLMAP_MAX_INTERFACES - -/* - * Clmap session debug statistics. - */ -struct nss_clmap_stats { - uint64_t stats[NSS_CLMAP_INTERFACE_STATS_MAX]; /* Clmap statistics. */ - int32_t if_index; /* Interface index. */ - uint32_t nss_if_num; /* NSS interface number. */ - enum nss_clmap_interface_type nss_if_type; /* NSS interface type. */ - bool valid; -}; - -/* - * 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); -extern void nss_clmap_stats_dentry_create(void); - -#endif /* __NSS_CLMAP_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_clmap_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_clmap_strings.c deleted file mode 100644 index 4a52b489a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_clmap_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_clmap_strings.h deleted file mode 100644 index dbdffba98..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_cmn.c b/feeds/ipq807x/qca-nss-drv/src/nss_cmn.c deleted file mode 100644 index 258994f1d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_cmn.c +++ /dev/null @@ -1,345 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_cmn.c - * NSS generic APIs - */ - -#if (NSS_DT_SUPPORT == 1) -#include -#endif - -#include "nss_tx_rx_common.h" - -/* - * nss_cmn_response_str - * Common response structure string - */ -int8_t *nss_cmn_response_str[NSS_CMN_RESPONSE_LAST] = { - "Message Acknowledge without errors", - "Common message version not supported", - "Unknown Interface", - "Length Error", - "Message Error", - "FW Notification Message", -}; - -/* - * nss_cmn_msg_init() - * Initialize the common message of an ASYNC message. - */ -void nss_cmn_msg_init(struct nss_cmn_msg *ncm, uint32_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data) -{ - ncm->interface = if_num; - ncm->version = NSS_HLOS_MESSAGE_VERSION; - ncm->type = type; - ncm->len = len; - ncm->cb = (nss_ptr_t)cb; - ncm->app_data = (nss_ptr_t)app_data; -} -EXPORT_SYMBOL(nss_cmn_msg_init); - -/* - * nss_cmn_msg_sync_init() - * Initialize the common message of a SYNC message. - */ -void nss_cmn_msg_sync_init(struct nss_cmn_msg *ncm, uint32_t if_num, uint32_t type, uint32_t len) -{ - nss_cmn_msg_init(ncm, if_num, type, len, NULL, NULL); -} -EXPORT_SYMBOL(nss_cmn_msg_sync_init); - -/* - * nss_cmn_get_interface_number() - * Return the interface number of the NSS net_device. - * - * Returns -1 on failure or the interface number of dev is an NSS net_device. - */ -int32_t nss_cmn_get_interface_number(struct nss_ctx_instance *nss_ctx, struct net_device *dev) -{ - int i; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { - nss_warning("%px: Interface number could not be found as core not ready\n", nss_ctx); - return -1; - } - - nss_assert(dev != 0); - - /* - * Check physical interface table - */ - for (i = 0; i < NSS_MAX_NET_INTERFACES; i++) { - if (dev == nss_ctx->subsys_dp_register[i].ndev) { - return i; - } - } - - 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); - -/* - * nss_cmn_append_core_id() - * Return the NSS interface number with core ID. - */ -int nss_cmn_append_core_id(struct nss_ctx_instance *nss_ctx, int if_num) -{ - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - return NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_cmn_append_core_id); - -/* - * nss_cmn_get_interface_dev() - * Return the net_device for NSS interface id. - * - * Returns NULL on failure or the net_device for NSS interface id. - */ -struct net_device *nss_cmn_get_interface_dev(struct nss_ctx_instance *ctx, uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)ctx; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { - nss_warning("%px: Interface device could not be found as core not ready\n", nss_ctx); - return NULL; - } - - if (unlikely(if_num >= NSS_MAX_NET_INTERFACES)) { - return NULL; - } - - return nss_ctx->subsys_dp_register[if_num].ndev; -} -EXPORT_SYMBOL(nss_cmn_get_interface_dev); - -/* - * nss_cmn_get_interface_number_by_dev_and_type() - * Return the NSS interface id for the net_device. - * - * Returns < 0 on failure or the NSS interface id for the given device and type. - */ -int32_t nss_cmn_get_interface_number_by_dev_and_type(struct net_device *dev, uint32_t type) -{ - int i, core; - struct nss_subsystem_dataplane_register *nsdr; - - nss_assert(dev != 0); - for (core = 0; core < nss_top_main.num_nss; core++) { - for (i = 0; i < NSS_MAX_NET_INTERFACES; i++) { - nsdr = &nss_top_main.nss[core].subsys_dp_register[i]; - if (dev == nsdr->ndev && type == nsdr->type) { - return i; - } - } - } - - 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); - -/* - * nss_cmn_get_interface_number_by_dev() - * Return the NSS interface id for the net_device. - * - * Returns < 0 on failure or the NSS interface id for the given device. - */ -int32_t nss_cmn_get_interface_number_by_dev(struct net_device *dev) -{ - return nss_cmn_get_interface_number_by_dev_and_type(dev, 0); -} -EXPORT_SYMBOL(nss_cmn_get_interface_number_by_dev); - -/* - * nss_cmn_get_state() - * return the NSS initialization state - */ -nss_state_t nss_cmn_get_state(struct nss_ctx_instance *ctx) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)ctx; - nss_state_t state = NSS_STATE_UNINITIALIZED; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - spin_lock_bh(&nss_top_main.lock); - if (nss_ctx->state == NSS_CORE_STATE_INITIALIZED) { - state = NSS_STATE_INITIALIZED; - } - spin_unlock_bh(&nss_top_main.lock); - - return state; -} -EXPORT_SYMBOL(nss_cmn_get_state); - -/* - * nss_cmn_interface_is_redirect() - * Return true if the interface is a redirect interface. - */ -bool nss_cmn_interface_is_redirect(struct nss_ctx_instance *nss_ctx, int32_t interface_num) -{ - enum nss_dynamic_interface_type type = nss_dynamic_interface_get_type(nss_ctx, interface_num); - - return type == NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H - || type == NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N - || type == NSS_DYNAMIC_INTERFACE_TYPE_VIRTIF_DEPRECATED; -} -EXPORT_SYMBOL(nss_cmn_interface_is_redirect); - -/* - * nss_cmn_rx_dropped_sum() - * Sum rx_dropped count. - */ -uint32_t nss_cmn_rx_dropped_sum(struct nss_cmn_node_stats *node_stats) -{ - uint32_t sum = 0; - int i; - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - sum += node_stats->rx_dropped[i]; - } - return sum; -} -EXPORT_SYMBOL(nss_cmn_rx_dropped_sum); - -/* - * nss_cmn_register_queue_decongestion() - * Register for queue decongestion event - */ -nss_cb_register_status_t nss_cmn_register_queue_decongestion(struct nss_ctx_instance *nss_ctx, nss_cmn_queue_decongestion_callback_t event_callback, void *app_ctx) -{ - uint32_t i; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - spin_lock_bh(&nss_ctx->decongest_cb_lock); - - /* - * Find vacant location in callback table - */ - for (i = 0; i< NSS_MAX_CLIENTS; i++) { - if (nss_ctx->queue_decongestion_callback[i] == NULL) { - nss_ctx->queue_decongestion_callback[i] = event_callback; - nss_ctx->queue_decongestion_ctx[i] = app_ctx; - spin_unlock_bh(&nss_ctx->decongest_cb_lock); - return NSS_CB_REGISTER_SUCCESS; - } - } - - spin_unlock_bh(&nss_ctx->decongest_cb_lock); - return NSS_CB_REGISTER_FAILED; -} -EXPORT_SYMBOL(nss_cmn_register_queue_decongestion); - -/* - * nss_cmn_unregister_queue_decongestion() - * Unregister for queue decongestion event - */ -nss_cb_unregister_status_t nss_cmn_unregister_queue_decongestion(struct nss_ctx_instance *nss_ctx, nss_cmn_queue_decongestion_callback_t event_callback) -{ - uint32_t i; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - spin_lock_bh(&nss_ctx->decongest_cb_lock); - - /* - * Find actual location in callback table - */ - for (i = 0; i< NSS_MAX_CLIENTS; i++) { - if (nss_ctx->queue_decongestion_callback[i] == event_callback) { - nss_ctx->queue_decongestion_callback[i] = NULL; - nss_ctx->queue_decongestion_ctx[i] = NULL; - spin_unlock_bh(&nss_ctx->decongest_cb_lock); - return NSS_CB_UNREGISTER_SUCCESS; - } - } - - spin_unlock_bh(&nss_ctx->decongest_cb_lock); - return NSS_CB_UNREGISTER_FAILED; -} -EXPORT_SYMBOL(nss_cmn_unregister_queue_decongestion); - -/* - * nss_cmn_register_service_code() - * Register for service code event - */ -nss_cb_register_status_t nss_cmn_register_service_code(struct nss_ctx_instance *nss_ctx, nss_cmn_service_code_callback_t cb, uint8_t service_code, void *app_data) -{ - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (nss_ctx->service_code_callback[service_code]) { - /* - * We already have a callback registered for this 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; - } - - nss_ctx->service_code_callback[service_code] = cb; - nss_ctx->service_code_ctx[service_code] = app_data; - return NSS_CB_REGISTER_SUCCESS; -} -EXPORT_SYMBOL(nss_cmn_register_service_code); - -/* - * nss_cmn_unregister_service_code() - * Unregister for service code event - */ -nss_cb_unregister_status_t nss_cmn_unregister_service_code(struct nss_ctx_instance *nss_ctx, nss_cmn_service_code_callback_t cb, uint8_t service_code) -{ - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (!nss_ctx->service_code_callback[service_code]) { - /* - * No callback was registered for this service code. - */ - nss_warning("%px: no callback is registered for this service code %d\n", nss_ctx, service_code); - return NSS_CB_UNREGISTER_FAILED; - } - - nss_ctx->service_code_callback[service_code] = NULL; - nss_ctx->service_code_ctx[service_code] = NULL; - return NSS_CB_UNREGISTER_SUCCESS; -} -EXPORT_SYMBOL(nss_cmn_unregister_service_code); - -/* - * nss_cmn_get_nss_enabled() - * Check if NSS mode is supported on platform - * - * This API checks the device tree parameter to decide on whether - * NSS mode is enabled. On older kernels this will always return true - */ -bool nss_cmn_get_nss_enabled(void) -{ -#if (NSS_DT_SUPPORT == 1) - struct device_node *cmn = NULL; - - /* - * Get reference to NSS common device node - */ - cmn = of_find_node_by_name(NULL, "nss-common"); - if (!cmn) { - nss_info_always("nss is not enabled on this platform\n"); - return false; - } -#endif - return true; -} -EXPORT_SYMBOL(nss_cmn_get_nss_enabled); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_core.c b/feeds/ipq807x/qca-nss-drv/src/nss_core.c deleted file mode 100644 index eaea9ec15..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_core.c +++ /dev/null @@ -1,3251 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_core.c - * NSS driver core APIs source file. - */ - -#include "nss_core.h" -#include -#include -#include -#include -#include -#ifdef CONFIG_BRIDGE_NETFILTER -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 0, 0)) -#include -#else -#include -#endif -#endif -#include -#include "nss_tx_rx_common.h" -#include "nss_data_plane.h" - -#define NSS_CORE_JUMBO_LINEAR_BUF_SIZE 128 - -#if (NSS_SKB_REUSE_SUPPORT == 1) -/* - * We have validated the skb recycling code within the NSS for the - * following kernel versions. Before enabling the driver in new kernels, - * the skb recycle code must be checked against Linux skb handling. - * - * Tested on: 3.4, 3.10, 3.14, 3.18, 4.4 and 5.4 - */ -#if (!( \ -(((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0)))) || \ -(((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)))) || \ -(((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)))) || \ -(((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0)))))) -#error "Check skb recycle code in this file to match Linux version" -#endif - -static atomic_t max_reuse = ATOMIC_INIT(PAGE_SIZE); - -#endif /* NSS_SKB_REUSE_SUPPORT */ - -static int max_ipv4_conn = NSS_DEFAULT_NUM_CONN; -module_param(max_ipv4_conn, int, S_IRUGO); -MODULE_PARM_DESC(max_ipv4_conn, "Max number of IPv4 connections"); - -static int max_ipv6_conn = NSS_DEFAULT_NUM_CONN; -module_param(max_ipv6_conn, int, S_IRUGO); -MODULE_PARM_DESC(max_ipv6_conn, "Max number of IPv6 connections"); - -bool pn_mq_en = false; -module_param(pn_mq_en, bool, S_IRUGO); -MODULE_PARM_DESC(pn_mq_en, "Enable pnode ingress QoS"); - -uint16_t pn_qlimits[NSS_MAX_NUM_PRI] = {[0 ... NSS_MAX_NUM_PRI - 1] = NSS_DEFAULT_QUEUE_LIMIT}; -module_param_array(pn_qlimits, short, NULL, 0); -MODULE_PARM_DESC(pn_qlimits, "Queue limit per queue"); - -/* - * Atomic variables to control jumbo_mru & paged_mode - */ -static atomic_t jumbo_mru; -static atomic_t paged_mode; - -/* - * nss_core_update_max_ipv4_conn() - * Update the maximum number of configured IPv4 connections - */ -void nss_core_update_max_ipv4_conn(int conn) -{ - max_ipv4_conn = conn; -} - -/* - * nss_core_update_max_ipv6_conn() - * Update the maximum number of configured IPv6 connections - */ -void nss_core_update_max_ipv6_conn(int conn) -{ - max_ipv6_conn = conn; -} - -#if (NSS_SKB_REUSE_SUPPORT == 1) -/* - * nss_core_set_max_reuse() - * Set the max_reuse to the specified value - */ -void nss_core_set_max_reuse(int max) -{ - atomic_set(&max_reuse, max); -} - -/* - * nss_core_get_max_reuse() - * Does an atomic read of max_reuse - */ -int nss_core_get_max_reuse(void) -{ - return atomic_read(&max_reuse); -} - -/* - * nss_core_get_min_reuse() - * Return min reuse size - */ -uint32_t nss_core_get_min_reuse(struct nss_ctx_instance *nss_ctx) -{ - NSS_VERIFY_CTX_MAGIC(nss_ctx); - return nss_ctx->max_buf_size; -} -#endif /* NSS_SKB_REUSE_SUPPORT */ - -/* - * nss_core_set_jumbo_mru() - * Set the jumbo_mru to the specified value - */ -void nss_core_set_jumbo_mru(int jumbo) -{ - atomic_set(&jumbo_mru, jumbo); - -#if (NSS_SKB_REUSE_SUPPORT == 1) - if (jumbo > nss_core_get_max_reuse()) - nss_core_set_max_reuse(ALIGN(jumbo * 2, PAGE_SIZE)); -#endif -} - -/* - * nss_core_get_jumbo_mru() - * Does an atomic read of jumbo_mru - */ -int nss_core_get_jumbo_mru(void) -{ - return atomic_read(&jumbo_mru); -} - -/* - * nss_core_set_paged_mode() - * Set the paged_mode to the specified value - */ -void nss_core_set_paged_mode(int mode) -{ - atomic_set(&paged_mode, mode); -} - -/* - * nss_core_get_paged_mode() - * Does an atomic read of paged_mode - */ -int nss_core_get_paged_mode(void) -{ - return atomic_read(&paged_mode); -} - -/* - * nss_core_register_msg_handler() - * Register a msg callback per interface number. One per interface. - */ -uint32_t nss_core_register_msg_handler(struct nss_ctx_instance *nss_ctx, uint32_t interface, nss_if_rx_msg_callback_t msg_cb) -{ - nss_assert(msg_cb != NULL); - - /* - * Validate interface id - */ - if (interface >= NSS_MAX_NET_INTERFACES) { - nss_warning("Error - Interface %d not Supported\n", interface); - return NSS_CORE_STATUS_FAILURE; - } - - /* - * Check if already registered - */ - if (nss_ctx->nss_rx_interface_handlers[interface].msg_cb) { - nss_warning("Error - Duplicate Interface CB Registered for interface %d\n", interface); - return NSS_CORE_STATUS_FAILURE; - } - - nss_ctx->nss_rx_interface_handlers[interface].msg_cb = msg_cb; - - return NSS_CORE_STATUS_SUCCESS; -} - -/* - * nss_core_unregister_msg_handler() - * Unregister a msg callback per interface number. - */ -uint32_t nss_core_unregister_msg_handler(struct nss_ctx_instance *nss_ctx, uint32_t interface) -{ - /* - * Validate interface id - */ - if (interface >= NSS_MAX_NET_INTERFACES) { - nss_warning("Error - Interface %d not Supported\n", interface); - return NSS_CORE_STATUS_FAILURE; - } - - nss_ctx->nss_rx_interface_handlers[interface].msg_cb = NULL; - - return NSS_CORE_STATUS_SUCCESS; -} - -/* - * nss_core_register_handler() - --- Register a callback per interface code. Only one per interface. - */ -uint32_t nss_core_register_handler(struct nss_ctx_instance *nss_ctx, uint32_t interface, nss_core_rx_callback_t cb, void *app_data) -{ - nss_assert(cb != NULL); - - /* - * Validate interface id - */ - if (interface >= NSS_MAX_NET_INTERFACES) { - nss_warning("Error - Interface %d not Supported\n", interface); - return NSS_CORE_STATUS_FAILURE; - } - - /* - * Check if already registered - */ - if (nss_ctx->nss_rx_interface_handlers[interface].cb != NULL) { - nss_warning("Error - Duplicate Interface CB Registered for interface %d\n", interface); - return NSS_CORE_STATUS_FAILURE; - } - - nss_ctx->nss_rx_interface_handlers[interface].cb = cb; - nss_ctx->nss_rx_interface_handlers[interface].app_data = app_data; - - return NSS_CORE_STATUS_SUCCESS; -} - -/* - * nss_core_unregister_handler() - * Unegister a callback per interface code. - */ -uint32_t nss_core_unregister_handler(struct nss_ctx_instance *nss_ctx, uint32_t interface) -{ - /* - * Validate interface id - */ - if (interface >= NSS_MAX_NET_INTERFACES) { - nss_warning("Error - Interface %d not Supported\n", interface); - return NSS_CORE_STATUS_FAILURE; - } - - nss_ctx->nss_rx_interface_handlers[interface].cb = NULL; - nss_ctx->nss_rx_interface_handlers[interface].app_data = NULL; - - return NSS_CORE_STATUS_SUCCESS; -} - -/* - * nss_core_set_subsys_dp_type() - * Set the type for the datapath subsystem - */ -void nss_core_set_subsys_dp_type(struct nss_ctx_instance *nss_ctx, struct net_device *ndev, uint32_t if_num, uint32_t type) -{ - struct nss_subsystem_dataplane_register *reg; - - /* - * Check that interface number is in range. - */ - BUG_ON(if_num >= NSS_MAX_NET_INTERFACES); - - reg = &nss_ctx->subsys_dp_register[if_num]; - - /* - * Check if there is already a subsystem registered at this interface number. - */ - BUG_ON(reg->ndev && reg->ndev != ndev); - - reg->type = type; -} - -/* - * nss_core_register_subsys_dp() - * Registers a netdevice and associated information at a given interface. - * - * Can also be used to update an existing registry if the provided net_device - * is equal to the one already registered. Will fail if there is already - * a net_device registered to the interface not equal to the one provided, - * or if the interface number is out of range. - */ -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, - void *app_data, struct net_device *ndev, - uint32_t features) -{ - struct nss_subsystem_dataplane_register *reg; - - /* - * Check that interface number is in range. - */ - BUG_ON(if_num >= NSS_MAX_NET_INTERFACES); - - reg = &nss_ctx->subsys_dp_register[if_num]; - - /* - * Check if there is already a subsystem registered at this interface number. - */ - BUG_ON(reg->ndev && reg->ndev != ndev); - - reg->cb = cb; - reg->ext_cb = ext_cb; - reg->app_data = app_data; - reg->ndev = ndev; - reg->features = features; -} - -/* - * nss_core_unregister_subsys_dp() - * Unregisters the netdevice at the given interface. - * - * Fails if the interface number is not valid. - */ -void nss_core_unregister_subsys_dp(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - struct nss_subsystem_dataplane_register *reg; - - /* - * Check that interface number is in range. - */ - BUG_ON(if_num >= NSS_MAX_NET_INTERFACES); - - reg = &nss_ctx->subsys_dp_register[if_num]; - - reg->cb = NULL; - reg->ext_cb = NULL; - reg->app_data = NULL; - reg->ndev = NULL; - reg->features = 0; - reg->type = 0; -} - -/* - * nss_core_handle_nss_status_pkt() - * Handle the metadata/status packet. - */ -void nss_core_handle_nss_status_pkt(struct nss_ctx_instance *nss_ctx, struct sk_buff *nbuf) -{ - struct nss_cmn_msg *ncm; - uint32_t expected_version = NSS_HLOS_MESSAGE_VERSION; - nss_core_rx_callback_t cb; - void *app_data; - uint16_t nss_if; - - if (skb_shinfo(nbuf)->nr_frags > 0) { - ncm = (struct nss_cmn_msg *)skb_frag_address(&skb_shinfo(nbuf)->frags[0]); - } else { - ncm = (struct nss_cmn_msg *)nbuf->data; - } - - /* - * Save NSS interface number in local variable - */ - nss_if = ncm->interface; - - /* - * Check for version number - */ - if (ncm->version != expected_version) { - 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; - } - - /* - * Validate message size - */ - if (ncm->len > nbuf->len) { - 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; - } - - /* - * Check for validity of interface number - */ - if (nss_if >= NSS_MAX_NET_INTERFACES) { - 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; - - if (!cb) { - 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("%px: Invalid NSS I/F %d expected %d", nss_ctx, ncm->interface, nss_if); - } - - return; -} - -/* - * nss_core_handle_nss_crypto_pkt() - * Handles crypto packet. - */ -static void nss_core_handle_crypto_pkt(struct nss_ctx_instance *nss_ctx, unsigned int interface_num, - struct sk_buff *nbuf, struct napi_struct *napi) -{ - struct nss_subsystem_dataplane_register *subsys_dp_reg = &nss_ctx->subsys_dp_register[interface_num]; - nss_phys_if_rx_callback_t cb; - struct net_device *ndev; - - ndev = subsys_dp_reg->ndev; - cb = subsys_dp_reg->cb; - if (likely(cb)) { - cb(ndev, nbuf, napi); - return; - } - - dev_kfree_skb_any(nbuf); - return; -} - -/* - * nss_soc_mem_info() - * Getting DDR information for NSS SoC - */ -static uint32_t nss_soc_mem_info(void) -{ - struct device_node *node; - struct device_node *snode; - int addr_cells; - int size_cells; - int n_items; - uint32_t nss_msize = 8 << 20; /* default: 8MB */ - const __be32 *ppp; - - node = of_find_node_by_name(NULL, "reserved-memory"); - if (!node) { - nss_info_always("reserved-memory not found\n"); - return nss_msize; - } - - ppp = (__be32 *)of_get_property(node, "#address-cells", NULL); - addr_cells = ppp ? be32_to_cpup(ppp) : 2; - 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("%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("%px snode %s fn %s\n", snode, snode->name, snode->full_name); - if (strcmp(snode->name, "nss") == 0) - break; - } - of_node_put(node); - if (!snode) { - nss_info_always("nss@node not found: needed to determine NSS reserved DDR\n"); - return nss_msize; - } - - ppp = (__be32 *)of_get_property(snode, "reg", &n_items); - if (ppp) { - n_items /= sizeof(ppp[0]); - nss_msize = be32_to_cpup(ppp + addr_cells + size_cells - 1); - nss_info_always("addr/size storage words %d %d # words %d in DTS, ddr size %x\n", - addr_cells, size_cells, n_items, nss_msize); - } - of_node_put(snode); - return nss_msize; -} - -/* - * nss_get_ddr_info() - * get DDR start address and size from device tree. - */ -static void nss_get_ddr_info(struct nss_mmu_ddr_info *mmu, char *name) -{ - __be32 avail_ddr; - long cached; - struct sysinfo vals; - struct device_node *node; - - si_meminfo(&vals); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)) - cached = global_page_state(NR_FILE_PAGES); -#else - 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; - - /* - * Since "memory" has not been used by anyone, the format is not final. - * Three (3) possible formats available: one of 1 or 2 will be final. - * 1) item_size stating_address DDR_size : odd # items - * 2) stating_address DDR_size # 32-bit each; total 2 words - * 3) stating_address DDR_size # 64-bit each; total 4 words - */ - node = of_find_node_by_name(NULL, name); - if (node) { - int isize = 0; - int n_items; - const __be32 *ppp = (__be32 *)of_get_property(node, "reg", &n_items); - - n_items /= sizeof(ppp[0]); - nss_info_always("node size %d # items %d\n", - of_n_size_cells(node), n_items); - if (ppp) { - if (n_items & 1) { /* case 1 */ - isize = be32_to_cpup(ppp); - if (isize == 1) - goto case2; - if (isize == 2) - goto case3; - n_items = 0; - } else if (n_items == 2) { -case2: - mmu->start_address = be32_to_cpup(ppp + isize); - mmu->ddr_size = be32_to_cpup(&ppp[isize + 1]); - } else if (n_items == 4) { -case3: - if (!ppp[isize] && !ppp[isize * 2]) { - if (isize) - isize = 1; - mmu->start_address = be32_to_cpup(ppp + isize + 1); - mmu->ddr_size = be32_to_cpup(ppp + isize + 3); - } else - n_items = 0; - } else - n_items = 0; - if (n_items) { - of_node_put(node); - nss_info_always("%s: %x %u (avl %u) items %d active_cores %d\n", - name, mmu->start_address, mmu->ddr_size, - avail_ddr, n_items, mmu->num_active_cores); - /* - * if DTS mechanism goes wrong, use available - * DDR and round it up to 64MB for maximum DDR. - */ - if (avail_ddr > mmu->ddr_size) - mmu->ddr_size = (avail_ddr + (63 << 20)) - & (~63 << 20); - return; - } - } - of_node_put(node); - nss_info_always("incorrect memory info %px items %d\n", - ppp, n_items); - } - - /* - * boilerplate for setting customer values; - * start_address = 0 will not change default start address - * set in NSS FW (likely 0x4000_0000) - * total available RAM + 16 MB NSS FW DDR + ~31 MB kernel mem - * we round it up by 128MB to cover potential NSS DDR increase - * and a slightly large holes. - * The size can be changed to a fixed value as DTS, but simplier. - * mmu->ddr_size = 1024 << 20 - */ - mmu->start_address = 0; - mmu->ddr_size = (avail_ddr + (127 << 20)) & (~127 << 20); - nss_info_always("RAM pages fr %lu buf %lu cached %lu %lu : %lu %u\n", - vals.freeram, vals.bufferram, cached, vals.sharedram, - vals.totalram, mmu->ddr_size); -} - -/* - * nss_send_ddr_info() - * Send DDR info to NSS - */ -static void nss_send_ddr_info(struct nss_ctx_instance *nss_own) -{ - struct nss_n2h_msg nnm; - struct nss_cmn_msg *ncm = &nnm.cm; - uint32_t ret; - 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); - - nss_get_ddr_info(&nnm.msg.mmu, "memory"); - nnm.msg.mmu.nss_ddr_size = nss_soc_mem_info(); - - ret = nss_core_send_cmd(nss_own, &nnm, sizeof(nnm), NSS_NBUF_PAYLOAD_SIZE); - if (ret != NSS_TX_SUCCESS) { - nss_info_always("%px: Failed to send DDR info for core %d\n", nss_own, nss_own->id); - } -} - -/* - * nss_core_cause_to_queue() - * Map interrupt cause to queue id - */ -static inline uint16_t nss_core_cause_to_queue(uint16_t cause) -{ - if (likely(cause == NSS_N2H_INTR_DATA_QUEUE_0)) { - return NSS_IF_N2H_DATA_QUEUE_0; - } - - if (likely(cause == NSS_N2H_INTR_DATA_QUEUE_1)) { - return NSS_IF_N2H_DATA_QUEUE_1; - } - - if (likely(cause == NSS_N2H_INTR_DATA_QUEUE_2)) { - return NSS_IF_N2H_DATA_QUEUE_2; - } - - if (likely(cause == NSS_N2H_INTR_DATA_QUEUE_3)) { - return NSS_IF_N2H_DATA_QUEUE_3; - } - - if (likely(cause == NSS_N2H_INTR_EMPTY_BUFFER_QUEUE)) { - return NSS_IF_N2H_EMPTY_BUFFER_RETURN_QUEUE; - } - - /* - * There is no way we can reach here as cause was already identified to be related to valid queue - */ - nss_assert(0); - return 0; -} - -/* - * nss_dump_desc() - * Prints descriptor data - */ -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 = %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); - printk("\tbuffer_addr = %x\n", desc->buffer); - printk("\tbuffer_len = %d\n", desc->buffer_len); - printk("\tpayload_offs = %d\n", desc->payload_offs); - printk("\tpayload_len = %d\n", desc->payload_len); - printk("\tpri = %d\n", desc->pri); -} - -/* - * nss_core_skb_needs_linearize() - * Looks at if this skb needs to be linearized or not. - */ -static inline int nss_core_skb_needs_linearize(struct sk_buff *skb, uint32_t features) -{ - return ((skb_has_frag_list(skb) && - !(features & NETIF_F_FRAGLIST)) || - (skb_shinfo(skb)->nr_frags && - !(features & NETIF_F_SG))); -} - -/* - * nss_core_handle_bounced_pkt() - * Bounced packet is returned from an interface/bridge bounce operation. - * - * Return the skb to the registrant. - */ -static inline void nss_core_handle_bounced_pkt(struct nss_ctx_instance *nss_ctx, - struct nss_shaper_bounce_registrant *reg, - struct sk_buff *nbuf) -{ - void *app_data; - struct module *owner; - nss_shaper_bounced_callback_t bounced_callback; - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - spin_lock_bh(&nss_top->lock); - - /* - * Do we have a registrant? - */ - if (!reg->registered) { - spin_unlock_bh(&nss_top->lock); - dev_kfree_skb_any(nbuf); - return; - } - - /* - * Get handle to the owning registrant - */ - bounced_callback = reg->bounced_callback; - app_data = reg->app_data; - owner = reg->owner; - - /* - * Callback is active, unregistration is not permitted while this is in progress - */ - reg->callback_active = true; - spin_unlock_bh(&nss_top->lock); - if (!try_module_get(owner)) { - spin_lock_bh(&nss_top->lock); - reg->callback_active = false; - spin_unlock_bh(&nss_top->lock); - dev_kfree_skb_any(nbuf); - return; - } - - /* - * Pass bounced packet back to registrant - */ - bounced_callback(app_data, nbuf); - spin_lock_bh(&nss_top->lock); - reg->callback_active = false; - spin_unlock_bh(&nss_top->lock); - module_put(owner); -} - -/* - * nss_core_handle_virt_if_pkt() - * Handle packet destined to virtual interface. - */ -static inline void nss_core_handle_virt_if_pkt(struct nss_ctx_instance *nss_ctx, - unsigned int interface_num, - struct sk_buff *nbuf) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - struct nss_subsystem_dataplane_register *subsys_dp_reg = &nss_ctx->subsys_dp_register[interface_num]; - struct net_device *ndev = NULL; - - uint32_t xmit_ret; - uint16_t queue_offset = 0; - - NSS_PKT_STATS_INC(&nss_top->stats_drv[NSS_DRV_STATS_RX_VIRTUAL]); - - /* - * Checksum is already done by NSS for packets forwarded to virtual interfaces - */ - nbuf->ip_summed = CHECKSUM_NONE; - - /* - * Obtain net_device pointer - */ - ndev = subsys_dp_reg->ndev; - if (unlikely(!ndev)) { - nss_warning("%px: Received packet for unregistered virtual interface %d", - nss_ctx, interface_num); - - /* - * NOTE: The assumption is that gather support is not - * implemented in fast path and hence we can not receive - * fragmented packets and so we do not need to take care - * of freeing a fragmented packet - */ - dev_kfree_skb_any(nbuf); - return; - } - - /* - * TODO: Need to ensure the ndev is not removed before we take dev_hold(). - */ - dev_hold(ndev); - nbuf->dev = ndev; - - /* - * Linearize the skb if needed - * - * Mixing up non linear check with in nss_core_skb_needs_linearize causes - * unencessary performance impact because of netif_skb_features() API call unconditionally - * Hence moved skb_is_nonlinear call outside. - */ - if (unlikely(skb_is_nonlinear(nbuf))) { - if (nss_core_skb_needs_linearize(nbuf, (uint32_t)netif_skb_features(nbuf)) && - __skb_linearize(nbuf)) { - /* - * We needed to linearize, but __skb_linearize() failed. Therefore - * we free the nbuf. - */ - dev_put(ndev); - dev_kfree_skb_any(nbuf); - return; - } - } - - /* - * Check to see if there is a xmit callback is registered - * in this path. The callback will decide the queue mapping. - */ - if (unlikely((subsys_dp_reg->xmit_cb))) { - skb_set_queue_mapping(nbuf, 0); - subsys_dp_reg->xmit_cb(ndev, nbuf); - dev_put(ndev); - return; - } - - /* - * Mimic Linux behavior to allow multi-queue netdev choose which queue to use - */ - if (ndev->netdev_ops->ndo_select_queue) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)) - queue_offset = ndev->netdev_ops->ndo_select_queue(ndev, nbuf, NULL, NULL); -#else - queue_offset = ndev->netdev_ops->ndo_select_queue(ndev, nbuf, NULL); -#endif - } - - skb_set_queue_mapping(nbuf, queue_offset); - - /* - * Send the packet to virtual interface - * NOTE: Invoking this will BYPASS any assigned QDisc - this is OKAY - * as TX packets out of the NSS will have been shaped inside the NSS. - */ - xmit_ret = ndev->netdev_ops->ndo_start_xmit(nbuf, ndev); - if (unlikely(xmit_ret == NETDEV_TX_BUSY)) { - dev_kfree_skb_any(nbuf); - nss_info("%px: Congestion at virtual interface %d, %px", nss_ctx, interface_num, ndev); - } - dev_put(ndev); -} - -/* - * nss_core_handle_buffer_pkt() - * Handle data packet received on physical or virtual interface. - */ -static inline void nss_core_handle_buffer_pkt(struct nss_ctx_instance *nss_ctx, - unsigned int interface_num, - struct sk_buff *nbuf, - struct napi_struct *napi, - uint16_t flags, uint16_t qid, uint8_t service_code) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - struct nss_subsystem_dataplane_register *subsys_dp_reg = &nss_ctx->subsys_dp_register[interface_num]; - struct net_device *ndev = NULL; - nss_phys_if_rx_callback_t cb; - uint16_t queue_offset = qid - NSS_IF_N2H_DATA_QUEUE_0; - - NSS_PKT_STATS_INC(&nss_top->stats_drv[NSS_DRV_STATS_RX_PACKET]); - - /* - * Check if NSS was able to obtain checksum - */ - nbuf->ip_summed = CHECKSUM_UNNECESSARY; - if (unlikely(!(flags & N2H_BIT_FLAG_IP_TRANSPORT_CHECKSUM_VALID))) { - nbuf->ip_summed = CHECKSUM_NONE; - } - - ndev = subsys_dp_reg->ndev; - if (!ndev) { - dev_kfree_skb_any(nbuf); - return; - } - - /* - * If we have a non-zero service code, call the corresponding service code - * callback. The callback will consume the skb. - * For service code, we provide the raw packet as it was received. - */ - if (unlikely(service_code)) { - nss_cmn_service_code_callback_t cb = nss_ctx->service_code_callback[service_code]; - if (likely(cb)) { - dev_hold(ndev); - nbuf->dev = ndev; - nbuf->protocol = eth_type_trans(nbuf, ndev); - cb(nss_ctx->service_code_ctx[service_code], nbuf); - dev_put(ndev); - return; - } - } - - /* - * Deliver nbuf to the interface through callback if there is one. - */ - cb = subsys_dp_reg->cb; - if (likely(cb)) { - /* - * linearize or free if requested. - */ - if (unlikely(skb_is_nonlinear(nbuf))) { - if (nss_core_skb_needs_linearize(nbuf, ndev->features) && __skb_linearize(nbuf)) { - dev_kfree_skb_any(nbuf); - return; - } - } - - /* - * Record RX queue if the netdev has that many RX queues - */ - if (queue_offset < ndev->real_num_rx_queues) { - skb_record_rx_queue(nbuf, queue_offset); - } - - cb(ndev, (void *)nbuf, napi); - return; - } - - /* - * Deliver to the stack directly. Ex. there is no rule matched for - * redirect interface. - */ - dev_hold(ndev); - nbuf->dev = ndev; - nbuf->protocol = eth_type_trans(nbuf, ndev); - netif_receive_skb(nbuf); - dev_put(ndev); -} - -/* - * nss_core_handle_ext_buffer_pkt() - * Handle Extended data plane packet received on physical or virtual interface. - */ -static inline void nss_core_handle_ext_buffer_pkt(struct nss_ctx_instance *nss_ctx, - unsigned int interface_num, - struct sk_buff *nbuf, - struct napi_struct *napi, - uint16_t flags) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - struct nss_subsystem_dataplane_register *subsys_dp_reg = &nss_ctx->subsys_dp_register[interface_num]; - struct net_device *ndev = NULL; - nss_phys_if_rx_ext_data_callback_t ext_cb; - - NSS_PKT_STATS_INC(&nss_top->stats_drv[NSS_DRV_STATS_RX_EXT_PACKET]); - - /* - * Check if NSS was able to obtain checksum - */ - nbuf->ip_summed = CHECKSUM_UNNECESSARY; - if (unlikely(!(flags & N2H_BIT_FLAG_IP_TRANSPORT_CHECKSUM_VALID))) { - nbuf->ip_summed = CHECKSUM_NONE; - } - - ndev = subsys_dp_reg->ndev; - ext_cb = subsys_dp_reg->ext_cb; - if (likely(ext_cb) && likely(ndev)) { - - 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. - */ - dev_kfree_skb_any(nbuf); - return; - } - } - - ext_cb(ndev, (void *)nbuf, napi); - } else { - dev_kfree_skb_any(nbuf); - } -} - -/* - * nss_core_rx_pbuf() - * Receive a pbuf from the NSS into Linux. - */ -static inline void nss_core_rx_pbuf(struct nss_ctx_instance *nss_ctx, struct n2h_descriptor *desc, struct napi_struct *napi, - uint8_t buffer_type, struct sk_buff *nbuf, uint16_t qid) -{ - unsigned int interface_num = NSS_INTERFACE_NUM_GET(desc->interface_num); - unsigned int core_id = NSS_INTERFACE_NUM_GET_COREID(desc->interface_num); - struct nss_shaper_bounce_registrant *reg = NULL; - int32_t status; - - NSS_PKT_STATS_DEC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); - - if (interface_num >= NSS_MAX_NET_INTERFACES) { - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_INVALID_INTERFACE]); - nss_warning("%px: Invalid interface_num: %d", nss_ctx, interface_num); - dev_kfree_skb_any(nbuf); - return; - } - - /* - * Check if core_id value is valid. - */ - if (core_id > nss_top_main.num_nss) { - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_INVALID_CORE_ID]); - nss_warning("%px: Invalid core id: %d", nss_ctx, core_id); - dev_kfree_skb_any(nbuf); - return; - } - - /* - * Check if need to convert to local core value. - */ - if (core_id) { - nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[core_id - 1]; - } - - switch (buffer_type) { - case N2H_BUFFER_PACKET: - nss_core_handle_buffer_pkt(nss_ctx, interface_num, nbuf, napi, desc->bit_flags, qid, desc->service_code); - break; - - case N2H_BUFFER_PACKET_VIRTUAL: - nss_core_handle_virt_if_pkt(nss_ctx, interface_num, nbuf); - break; - - case N2H_BUFFER_SHAPER_BOUNCED_INTERFACE: - reg = &nss_ctx->nss_top->bounce_interface_registrants[interface_num]; - nss_core_handle_bounced_pkt(nss_ctx, reg, nbuf); - break; - - case N2H_BUFFER_SHAPER_BOUNCED_BRIDGE: - reg = &nss_ctx->nss_top->bounce_bridge_registrants[interface_num]; - nss_core_handle_bounced_pkt(nss_ctx, reg, nbuf); - break; - - case N2H_BUFFER_PACKET_EXT: - nss_core_handle_ext_buffer_pkt(nss_ctx, interface_num, nbuf, napi, desc->bit_flags); - break; - - case N2H_BUFFER_STATUS: - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_STATUS]); - nss_core_handle_nss_status_pkt(nss_ctx, nbuf); - dev_kfree_skb_any(nbuf); - break; - - case N2H_BUFFER_CRYPTO_RESP: - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_CRYPTO_RESP]); - nss_core_handle_crypto_pkt(nss_ctx, interface_num, nbuf, napi); - break; - - case N2H_BUFFER_RATE_TEST: - - /* - * This is a packet NSS sent for packet rate testing. The test measures the - * maximum PPS we can achieve between the host and NSS. After we process - * the descriptor, we directly send these test packets back to NSS without further process. - * They are again marked with H2N_BUFFER_RATE_TEST buffer type so NSS can process - * and count the test packets properly. - */ - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_STATUS]); - 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("%px: Unable to enqueue\n", nss_ctx); - } - nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); - break; - - default: - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_INVALID_BUFFER_TYPE]); - nss_warning("%px: Invalid buffer type %d received from NSS", nss_ctx, buffer_type); - dev_kfree_skb_any(nbuf); - } -} - -/* - * 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_set_tc_classify_offload(nbuf); -#endif -#endif -} - -/* - * nss_core_handle_nrfrag_skb() - * Handled the processing of fragmented skb's - */ -static inline bool nss_core_handle_nr_frag_skb(struct nss_ctx_instance *nss_ctx, struct sk_buff **nbuf_ptr, struct sk_buff **jumbo_start_ptr, struct n2h_descriptor *desc, unsigned int buffer_type) -{ - struct sk_buff *nbuf = *nbuf_ptr; - struct sk_buff *jumbo_start = *jumbo_start_ptr; - - uint16_t payload_len = desc->payload_len; - uint16_t payload_offs = desc->payload_offs; - uint16_t bit_flags = desc->bit_flags; - - nss_assert(desc->payload_offs + desc->payload_len <= PAGE_SIZE); - - dma_unmap_page(nss_ctx->dev, (desc->buffer + desc->payload_offs), desc->payload_len, DMA_FROM_DEVICE); - - /* - * The first and last bits are both set. Hence the received frame can't have - * chains (or it's not a scattered one). - */ - if (likely(bit_flags & N2H_BIT_FLAG_FIRST_SEGMENT) && likely(bit_flags & N2H_BIT_FLAG_LAST_SEGMENT)) { - - /* - * We have received another head before we saw the last segment. - * Free the old head as the frag list is corrupt. - */ - if (unlikely(jumbo_start)) { - nss_warning("%px: received a full frame before a last", jumbo_start); - dev_kfree_skb_any(jumbo_start); - *jumbo_start_ptr = NULL; - } - - /* - * NOTE: Need to use __skb_fill since we do not want to - * increment nr_frags again. We just want to adjust the offset - * and the length. - */ - __skb_fill_page_desc(nbuf, 0, skb_frag_page(&skb_shinfo(nbuf)->frags[0]), payload_offs, payload_len); - - /* - * We do not update truesize. We just keep the initial set value. - */ - nbuf->data_len = payload_len; - nbuf->len = payload_len; - nbuf->priority = desc->pri; - -#ifdef CONFIG_NET_CLS_ACT - /* - * Skip the ingress QoS for the packet if the descriptor has - * ingress shaped flag set. - */ - if (unlikely(desc->bit_flags & N2H_BIT_FLAG_INGRESS_SHAPED)) { - nss_core_set_skb_classify(nbuf); - } -#endif - - goto pull; - } - - /* - * Track Number of Fragments processed. First && Last is not true fragment - */ - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_FRAG_SEG_PROCESSED]); - - /* - * NSS sent us an SG chain. - * Build a frags[] out of segments. - */ - if (unlikely((bit_flags & N2H_BIT_FLAG_FIRST_SEGMENT))) { - - /* - * We have received another head before we saw the last segment. - * Free the old head as the frag list is corrupt. - */ - if (unlikely(jumbo_start)) { - nss_warning("%px: received the second head before a last", jumbo_start); - dev_kfree_skb_any(jumbo_start); - } - - /* - * We do not update truesize. We just keep the initial set value. - */ - __skb_fill_page_desc(nbuf, 0, skb_frag_page(&skb_shinfo(nbuf)->frags[0]), payload_offs, payload_len); - nbuf->data_len = payload_len; - nbuf->len = payload_len; - nbuf->priority = desc->pri; - -#ifdef CONFIG_NET_CLS_ACT - /* - * Skip the ingress QoS for the packet if the descriptor has - * ingress shaped flag set. - */ - if (unlikely(desc->bit_flags & N2H_BIT_FLAG_INGRESS_SHAPED)) { - nss_core_set_skb_classify(nbuf); - } -#endif - - /* - * Set jumbo pointer to nbuf - */ - *jumbo_start_ptr = nbuf; - - /* - * Skip sending until last is received. - */ - return false; - } - - NSS_PKT_STATS_DEC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); - - /* - * We've received a middle or a last segment. - * Check that we have received a head first to avoid null deferencing. - */ - if (unlikely(jumbo_start == NULL)) { - /* - * Middle before first! Free the middle. - */ - nss_warning("%px: saw a middle skb before head", nbuf); - dev_kfree_skb_any(nbuf); - return false; - } - - /* - * Free the skb after attaching the frag to the head skb. - * Our page is safe although we are freeing it because we - * just took a reference to it. - */ - skb_add_rx_frag(jumbo_start, skb_shinfo(jumbo_start)->nr_frags, skb_frag_page(&skb_shinfo(nbuf)->frags[0]), payload_offs, payload_len, PAGE_SIZE); - skb_frag_ref(jumbo_start, skb_shinfo(jumbo_start)->nr_frags - 1); - dev_kfree_skb_any(nbuf); - - if (!(bit_flags & N2H_BIT_FLAG_LAST_SEGMENT)) { - /* - * Skip sending until last is received. - */ - return false; - } - - /* - * Last is received. Set nbuf pointer to point to - * the jumbo skb so that it continues to get processed. - */ - nbuf = jumbo_start; - *nbuf_ptr = nbuf; - *jumbo_start_ptr = NULL; - prefetch((void *)(nbuf->data)); - -pull: - /* - * We need eth hdr to be in the linear part of the skb - * for data packets. Otherwise eth_type_trans fails. - */ - if (buffer_type != N2H_BUFFER_STATUS) { - if (!pskb_may_pull(nbuf, ETH_HLEN)) { - dev_kfree_skb(nbuf); - nss_warning("%px: could not pull eth header", nbuf); - return false; - } - } - - return true; -} - -/* - * nss_core_handle_linear_skb() - * Handler for processing linear skbs. - */ -static inline bool nss_core_handle_linear_skb(struct nss_ctx_instance *nss_ctx, struct sk_buff **nbuf_ptr, struct sk_buff **head_ptr, - struct sk_buff **tail_ptr, struct n2h_descriptor *desc) -{ - uint16_t bit_flags = desc->bit_flags; - struct sk_buff *nbuf = *nbuf_ptr; - struct sk_buff *head = *head_ptr; - struct sk_buff *tail = *tail_ptr; - - /* - * We are in linear SKB mode. - */ - nbuf->data = nbuf->head + desc->payload_offs; - nbuf->len = desc->payload_len; - skb_set_tail_pointer(nbuf, nbuf->len); - - dma_unmap_single(nss_ctx->dev, (desc->buffer + desc->payload_offs), desc->payload_len, - DMA_FROM_DEVICE); - - prefetch((void *)(nbuf->data)); - - if (likely(bit_flags & N2H_BIT_FLAG_FIRST_SEGMENT) && likely(bit_flags & N2H_BIT_FLAG_LAST_SEGMENT)) { - - /* - * We have received another head before we saw the last segment. - * Free the old head as the frag list is corrupt. - */ - if (unlikely(head)) { - nss_warning("%px: received a full frame before a last", head); - dev_kfree_skb_any(head); - *head_ptr = NULL; - } - - nbuf->priority = desc->pri; - -#ifdef CONFIG_NET_CLS_ACT - /* - * Skip the ingress QoS for the packet if the descriptor has - * ingress shaped flag set. - */ - if (unlikely(desc->bit_flags & N2H_BIT_FLAG_INGRESS_SHAPED)) { - nss_core_set_skb_classify(nbuf); - } -#endif - - /* - * TODO: Check if there is any issue wrt map and unmap, - * NSS should playaround with data area and should not - * touch HEADROOM area - */ - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_SIMPLE]); - return true; - } - - /* - * Track number of skb chain processed. First && Last is not true segment. - */ - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_CHAIN_SEG_PROCESSED]); - - /* - * NSS sent us an SG chain. - * Build a frag list out of segments. - */ - if (unlikely((bit_flags & N2H_BIT_FLAG_FIRST_SEGMENT))) { - - /* - * We have received another head before we saw the last segment. - * Free the old head as the frag list is corrupt. - */ - if (unlikely(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); - } - - /* - * Found head. - */ - if (unlikely(skb_has_frag_list(nbuf))) { - /* - * We don't support chain in a chain. - */ - 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; - } - - skb_frag_list_init(nbuf); - nbuf->data_len = 0; - nbuf->truesize = desc->payload_len; - nbuf->priority = desc->pri; - -#ifdef CONFIG_NET_CLS_ACT - /* - * Skip the ingress QoS for the packet if the descriptor has - * ingress shaped flag set. - */ - if (unlikely(desc->bit_flags & N2H_BIT_FLAG_INGRESS_SHAPED)) { - nss_core_set_skb_classify(nbuf); - } -#endif - - *head_ptr = nbuf; - - /* - * Skip sending until last is received. - */ - return false; - } - - NSS_PKT_STATS_DEC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); - - /* - * We've received a middle segment. - * Check that we have received a head first to avoid null deferencing. - */ - if (unlikely(head == NULL)) { - - /* - * Middle before first! Free the middle. - */ - nss_warning("%px: saw a middle skb before head", nbuf); - dev_kfree_skb_any(nbuf); - - return false; - } - - if (!skb_has_frag_list(head)) { - /* - * 2nd skb in the chain. head's frag_list should point to him. - */ - nbuf->next = skb_shinfo(head)->frag_list; - skb_shinfo(head)->frag_list = nbuf; - } else { - /* - * 3rd, 4th... skb in the chain. The chain's previous tail's - * next should point to him. - */ - tail->next = nbuf; - nbuf->next = NULL; - } - *tail_ptr = nbuf; - - /* - * Now we've added a new nbuf to the chain. - * Update the chain length. - */ - head->data_len += desc->payload_len; - head->len += desc->payload_len; - head->truesize += desc->payload_len; - - if (!(bit_flags & N2H_BIT_FLAG_LAST_SEGMENT)) { - /* - * Skip sending until last is received. - */ - return false; - } - - /* - * Last is received. Send the frag_list. - */ - *nbuf_ptr = head; - *head_ptr = NULL; - *tail_ptr = NULL; - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_SKB_FRAGLIST]); - return true; -} - -/* - * nss_core_handle_empty_buffers() - * Handle empty buffer returns. - */ -static inline void nss_core_handle_empty_buffers(struct nss_ctx_instance *nss_ctx, - struct nss_if_mem_map *if_map, - struct hlos_n2h_desc_ring *n2h_desc_ring, - struct n2h_descriptor *desc_ring, - struct n2h_descriptor *desc, - uint32_t count, uint32_t hlos_index, - uint16_t mask) -{ - while (count) { - /* - * Since we only return the primary skb, we have no way to unmap - * properly. Simple skb's are properly mapped but page data skbs - * have the payload mapped (and not the skb->data slab payload). - * - * Warning: On non-Krait HW, we need to unmap fragments. - * - * This only unmaps the first segment either slab payload or - * skb page data. Eventually, we need to unmap all of a frag_list - * or all of page_data however this is not a big concern as of now - * since on Kriats dma_map_single() does not allocate any resource - * and hence dma_unmap_single() is sort off a nop. - * - * No need to invalidate for Tx Completions, so set dma direction = DMA_TO_DEVICE; - * Similarly prefetch is not needed for an empty buffer. - */ - struct sk_buff *nbuf; - - /* - * Prefetch the next cache line of descriptors. - */ - if (((hlos_index & 1) == 0) && likely(count > 2)) { - struct n2h_descriptor *next_cache_desc = &desc_ring[(hlos_index + 2) & mask]; - prefetch(next_cache_desc); - } - - nbuf = (struct sk_buff *)desc->opaque; - - if (unlikely(nbuf < (struct sk_buff *)PAGE_OFFSET)) { - /* - * Invalid opaque pointer - */ - nss_dump_desc(nss_ctx, desc); - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_BAD_DESCRIPTOR]); - goto next; - } - - dma_unmap_single(nss_ctx->dev, (desc->buffer + desc->payload_offs), desc->payload_len, DMA_TO_DEVICE); - dev_kfree_skb_any(nbuf); - - NSS_PKT_STATS_DEC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_EMPTY]); - -next: - hlos_index = (hlos_index + 1) & (mask); - desc = &desc_ring[hlos_index]; - count--; - } - - n2h_desc_ring->hlos_index = hlos_index; - if_map->n2h_hlos_index[NSS_IF_N2H_EMPTY_BUFFER_RETURN_QUEUE] = hlos_index; - - NSS_CORE_DMA_CACHE_MAINT((void *)&if_map->n2h_hlos_index[NSS_IF_N2H_EMPTY_BUFFER_RETURN_QUEUE], sizeof(uint32_t), DMA_TO_DEVICE); - NSS_CORE_DSB(); -} - -/* - * nss_core_handle_cause_queue() - * Handle interrupt cause related to N2H/H2N queues - */ -static int32_t nss_core_handle_cause_queue(struct int_ctx_instance *int_ctx, uint16_t cause, int16_t weight) -{ - int16_t count, count_temp; - uint16_t size, mask, qid; - uint32_t nss_index, hlos_index, start, end; - struct sk_buff *nbuf; - struct hlos_n2h_desc_ring *n2h_desc_ring; - struct n2h_desc_if_instance *desc_if; - struct n2h_descriptor *desc_ring; - struct n2h_descriptor *desc; - struct n2h_descriptor *next_cache_desc; - struct nss_ctx_instance *nss_ctx = int_ctx->nss_ctx; - struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; - struct nss_if_mem_map *if_map = mem_ctx->if_map; - - qid = nss_core_cause_to_queue(cause); - - /* - * Make sure qid < num_rings - */ - nss_assert(qid < if_map->n2h_rings); - - n2h_desc_ring = &nss_ctx->n2h_desc_ring[qid]; - desc_if = &n2h_desc_ring->desc_ring; - desc_ring = desc_if->desc; - NSS_CORE_DMA_CACHE_MAINT((void *)&if_map->n2h_nss_index[qid], sizeof(uint32_t), DMA_FROM_DEVICE); - NSS_CORE_DSB(); - nss_index = if_map->n2h_nss_index[qid]; - - hlos_index = n2h_desc_ring->hlos_index; - size = desc_if->size; - mask = size - 1; - - /* - * Check if there is work to be done for this queue - */ - count = ((nss_index - hlos_index) + size) & (mask); - if (unlikely(count == 0)) { - return 0; - } - - /* - * Restrict ourselves to suggested weight - */ - if (count > weight) { - count = weight; - } - - /* - * Invalidate all the descriptors we are going to read - */ - start = hlos_index; - end = (hlos_index + count) & mask; - if (end > start) { - dmac_inv_range((void *)&desc_ring[start], (void *)&desc_ring[end] + sizeof(struct n2h_descriptor)); - } else { - /* - * We have wrapped around - */ - dmac_inv_range((void *)&desc_ring[start], (void *)&desc_ring[mask] + sizeof(struct n2h_descriptor)); - dmac_inv_range((void *)&desc_ring[0], (void *)&desc_ring[end] + sizeof(struct n2h_descriptor)); - } - - /* - * Prefetch the first descriptor - */ - desc = &desc_ring[hlos_index]; - prefetch(desc); - - /* - * Prefetch the next cache line of descriptors if we are starting with - * the second descriptor in the cache line. If it is the first in the cache line, - * this will be done inside the loop. - */ - if (((hlos_index & 1) == 1) && likely((count > 1))) { - next_cache_desc = &desc_ring[(hlos_index + 2) & mask]; - prefetch(next_cache_desc); - } - - if (qid == NSS_IF_N2H_EMPTY_BUFFER_RETURN_QUEUE) { - nss_core_handle_empty_buffers(nss_ctx, if_map, n2h_desc_ring, desc_ring, desc, count, hlos_index, mask); - return count; - } - - count_temp = count; - while (count_temp) { - unsigned int buffer_type; - nss_ptr_t opaque; - - /* - * Prefetch the next cache line of descriptors. - */ - if (((hlos_index & 1) == 0) && likely(count_temp > 2)) { - next_cache_desc = &desc_ring[(hlos_index + 2) & mask]; - prefetch(next_cache_desc); - } - - buffer_type = desc->buffer_type; - opaque = desc->opaque; - - /* - * Obtain nbuf - */ - nbuf = (struct sk_buff *)opaque; - if (unlikely(nbuf < (struct sk_buff *)PAGE_OFFSET)) { - /* - * Invalid opaque pointer - */ - nss_dump_desc(nss_ctx, desc); - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_BAD_DESCRIPTOR]); - goto next; - } - - /* - * Shaping uses the singleton approach as well. No need to unmap all the segments since only - * one of them is actually looked at. - */ - if ((unlikely(buffer_type == N2H_BUFFER_SHAPER_BOUNCED_INTERFACE)) || (unlikely(buffer_type == N2H_BUFFER_SHAPER_BOUNCED_BRIDGE))) { - dma_unmap_page(nss_ctx->dev, (desc->buffer + desc->payload_offs), desc->payload_len, DMA_TO_DEVICE); - goto consume; - } - - /* - * crypto buffer - * - */ - if (unlikely((buffer_type == N2H_BUFFER_CRYPTO_RESP))) { - dma_unmap_single(NULL, (desc->buffer + desc->payload_offs), desc->payload_len, DMA_FROM_DEVICE); - goto consume; - } - - /* - * Check if we received a paged skb. - */ - if (skb_shinfo(nbuf)->nr_frags > 0) { - /* - * Check if we received paged skb while constructing - * a linear skb chain. If so we need to free. - */ - if (unlikely(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_PKT_STATS_DEC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); - dev_kfree_skb_any(n2h_desc_ring->head); - n2h_desc_ring->head = NULL; - } - - if (!nss_core_handle_nr_frag_skb(nss_ctx, &nbuf, &n2h_desc_ring->jumbo_start, desc, buffer_type)) { - goto next; - } - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_NR_FRAGS]); - goto consume; - } - - /* - * Check if we received a linear skb while constructing - * 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("%px: we should not have an incomplete linear skb while" - " constructing a paged skb %px", nbuf, n2h_desc_ring->jumbo_start); - - 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); - n2h_desc_ring->jumbo_start = NULL; - } - - /* - * This is a simple linear skb. Use the the linear skb - * handler to process it. - */ - if (!nss_core_handle_linear_skb(nss_ctx, &nbuf, &n2h_desc_ring->head, &n2h_desc_ring->tail, desc)) { - goto next; - } - -consume: - nss_core_rx_pbuf(nss_ctx, desc, &(int_ctx->napi), buffer_type, nbuf, qid); - -next: - - hlos_index = (hlos_index + 1) & (mask); - desc = &desc_ring[hlos_index]; - count_temp--; - } - - n2h_desc_ring->hlos_index = hlos_index; - if_map->n2h_hlos_index[qid] = hlos_index; - - NSS_CORE_DMA_CACHE_MAINT((void *)&if_map->n2h_hlos_index[qid], sizeof(uint32_t), DMA_TO_DEVICE); - NSS_CORE_DSB(); - - return count; -} - -/* - * nss_core_init_nss() - * Initialize NSS core state - */ -static void nss_core_init_nss(struct nss_ctx_instance *nss_ctx, struct nss_if_mem_map *if_map) -{ - struct nss_top_instance *nss_top; - int ret; - - NSS_CORE_DMA_CACHE_MAINT((void *)if_map, sizeof(*if_map), DMA_FROM_DEVICE); - NSS_CORE_DSB(); - - /* - * NOTE: A commonly found error is that sizes and start address of per core - * virtual register map do not match in NSS and HLOS builds. This will lead - * to some hard to trace issues such as spinlock magic check failure etc. - * Following checks verify that proper virtual map has been initialized - */ - nss_assert(if_map->magic == DEV_MAGIC); - -#ifdef NSS_DRV_C2C_ENABLE - nss_ctx->c2c_start = nss_ctx->meminfo_ctx.c2c_start_dma; -#endif - - nss_top = nss_ctx->nss_top; - spin_lock_bh(&nss_top->lock); - nss_ctx->state = NSS_CORE_STATE_INITIALIZED; - spin_unlock_bh(&nss_top->lock); - - 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("Failed to send pnode queue config to core 1\n"); - } - return; - } - - /* - * If nss core0 is up, then we are ready to hook to nss-gmac - */ - if (nss_data_plane_schedule_registration()) { - - /* - * Configure the maximum number of IPv4/IPv6 - * connections supported by the accelerator. - */ - nss_ipv4_conn_cfg = max_ipv4_conn; -#ifdef NSS_DRV_IPV6_ENABLE - nss_ipv6_conn_cfg = max_ipv6_conn; - nss_ipv6_update_conn_count(max_ipv6_conn); -#endif - nss_ipv4_update_conn_count(max_ipv4_conn); - -#ifdef NSS_MEM_PROFILE_LOW - /* - * For low memory profiles, restrict the number of empty buffer pool - * size to NSS_LOW_MEM_EMPTY_POOL_BUF_SZ. Overwrite the default number - * of empty buffer pool size configured during NSS initialization. - */ - ret = nss_n2h_cfg_empty_pool_size(nss_ctx, NSS_LOW_MEM_EMPTY_POOL_BUF_SZ); - if (ret != NSS_TX_SUCCESS) { - nss_warning("%px: Failed to update empty buffer pool config\n", nss_ctx); - } -#endif - } else { - spin_lock_bh(&nss_top->lock); - nss_ctx->state = NSS_CORE_STATE_UNINITIALIZED; - spin_unlock_bh(&nss_top->lock); - } -} - -/* - * nss_core_alloc_paged_buffers() - * Allocate paged buffers for SOS. - */ -static void nss_core_alloc_paged_buffers(struct nss_ctx_instance *nss_ctx, struct nss_if_mem_map *if_map, - uint16_t count, int16_t mask, int32_t hlos_index, uint32_t alloc_fail_count, - uint32_t buffer_type, uint32_t buffer_queue, uint32_t stats_index) -{ - struct sk_buff *nbuf; - struct page *npage; - struct hlos_h2n_desc_rings *h2n_desc_ring = &nss_ctx->h2n_desc_rings[buffer_queue]; - struct h2n_desc_if_instance *desc_if = &h2n_desc_ring->desc_ring; - struct h2n_descriptor *desc_ring = desc_if->desc; - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - while (count) { - struct h2n_descriptor *desc = &desc_ring[hlos_index]; - dma_addr_t buffer; - - /* - * Alloc an skb AND a page. - */ - nbuf = dev_alloc_skb(NSS_CORE_JUMBO_LINEAR_BUF_SIZE); - if (unlikely(!nbuf)) { - /* - * ERR: - */ - NSS_PKT_STATS_INC(&nss_top->stats_drv[alloc_fail_count]); - nss_warning("%px: Could not obtain empty paged buffer", nss_ctx); - break; - } - - npage = alloc_page(GFP_ATOMIC); - if (unlikely(!npage)) { - /* - * ERR: - */ - dev_kfree_skb_any(nbuf); - NSS_PKT_STATS_INC(&nss_top->stats_drv[alloc_fail_count]); - nss_warning("%px: Could not obtain empty page", nss_ctx); - break; - } - - /* - * When we alloc an skb, initially head = data = tail and len = 0. - * So nobody will try to read the linear part of the skb. - */ - skb_fill_page_desc(nbuf, 0, npage, 0, PAGE_SIZE); - nbuf->data_len += PAGE_SIZE; - nbuf->len += PAGE_SIZE; - nbuf->truesize += PAGE_SIZE; - - /* Map the page for jumbo */ - buffer = dma_map_page(nss_ctx->dev, npage, 0, PAGE_SIZE, DMA_FROM_DEVICE); - desc->buffer_len = PAGE_SIZE; - desc->payload_offs = 0; - - if (unlikely(dma_mapping_error(nss_ctx->dev, buffer))) { - /* - * ERR: - */ - dev_kfree_skb_any(nbuf); - nss_warning("%px: DMA mapping failed for empty buffer", nss_ctx); - break; - } - /* - * We are holding this skb in NSS FW, let kmemleak know about it - */ - kmemleak_not_leak(nbuf); - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); - desc->opaque = (nss_ptr_t)nbuf; - desc->buffer = buffer; - desc->buffer_type = buffer_type; - - /* - * Flush the descriptor - */ - NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); - - hlos_index = (hlos_index + 1) & (mask); - count--; - } - - /* - * Wait for the flushes to be synced before writing the index - */ - NSS_CORE_DSB(); - - h2n_desc_ring->hlos_index = hlos_index; - if_map->h2n_hlos_index[buffer_queue] = hlos_index; - - NSS_CORE_DMA_CACHE_MAINT(&if_map->h2n_hlos_index[buffer_queue], sizeof(uint32_t), DMA_TO_DEVICE); - NSS_CORE_DSB(); - - NSS_PKT_STATS_INC(&nss_top->stats_drv[stats_index]); -} - -/* - * nss_core_alloc_jumbo_mru_buffers() - * Allocate jumbo mru buffers. - */ -static void nss_core_alloc_jumbo_mru_buffers(struct nss_ctx_instance *nss_ctx, struct nss_if_mem_map *if_map, - int jumbo_mru, uint16_t count, int16_t mask, int32_t hlos_index) -{ - - struct sk_buff *nbuf; - struct hlos_h2n_desc_rings *h2n_desc_ring = &nss_ctx->h2n_desc_rings[NSS_IF_H2N_EMPTY_BUFFER_QUEUE]; - struct h2n_desc_if_instance *desc_if = &h2n_desc_ring->desc_ring; - struct h2n_descriptor *desc_ring = desc_if->desc; - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - while (count) { - struct h2n_descriptor *desc = &desc_ring[hlos_index]; - dma_addr_t buffer; - nbuf = dev_alloc_skb(jumbo_mru); - if (unlikely(!nbuf)) { - /* - * ERR: - */ - NSS_PKT_STATS_INC(&nss_top->stats_drv[NSS_DRV_STATS_NBUF_ALLOC_FAILS]); - nss_warning("%px: Could not obtain empty jumbo mru buffer", nss_ctx); - break; - } - - /* - * Map the skb - */ - buffer = dma_map_single(nss_ctx->dev, nbuf->head, jumbo_mru, DMA_FROM_DEVICE); - desc->buffer_len = jumbo_mru; - desc->payload_offs = (uint16_t) (nbuf->data - nbuf->head); - if (unlikely(dma_mapping_error(nss_ctx->dev, buffer))) { - /* - * ERR: - */ - dev_kfree_skb_any(nbuf); - nss_warning("%px: DMA mapping failed for empty buffer", nss_ctx); - break; - } - - /* - * We are holding this skb in NSS FW, let kmemleak know about it - */ - kmemleak_not_leak(nbuf); - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); - desc->opaque = (nss_ptr_t)nbuf; - desc->buffer = buffer; - desc->buffer_type = H2N_BUFFER_EMPTY; - - /* - * Flush the descriptor - */ - NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); - - hlos_index = (hlos_index + 1) & (mask); - count--; - } - - /* - * Wait for the flushes to be synced before writing the index - */ - NSS_CORE_DSB(); - - h2n_desc_ring->hlos_index = hlos_index; - if_map->h2n_hlos_index[NSS_IF_H2N_EMPTY_BUFFER_QUEUE] = hlos_index; - - NSS_CORE_DMA_CACHE_MAINT(&if_map->h2n_hlos_index[NSS_IF_H2N_EMPTY_BUFFER_QUEUE], sizeof(uint32_t), DMA_TO_DEVICE); - NSS_CORE_DSB(); - - NSS_PKT_STATS_INC(&nss_top->stats_drv[NSS_DRV_STATS_TX_EMPTY]); -} - -/* - * nss_core_alloc_max_avail_size_buffers() - * Allocate maximum available sized buffers. - */ -static void nss_core_alloc_max_avail_size_buffers(struct nss_ctx_instance *nss_ctx, struct nss_if_mem_map *if_map, - uint16_t max_buf_size, uint16_t count, int16_t mask, int32_t hlos_index) -{ - struct hlos_h2n_desc_rings *h2n_desc_ring = &nss_ctx->h2n_desc_rings[NSS_IF_H2N_EMPTY_BUFFER_QUEUE]; - struct h2n_desc_if_instance *desc_if = &h2n_desc_ring->desc_ring; - struct h2n_descriptor *desc_ring = desc_if->desc; - struct nss_top_instance *nss_top = nss_ctx->nss_top; - uint16_t payload_len = max_buf_size + NET_SKB_PAD; - uint16_t start = hlos_index; - uint16_t prev_hlos_index; - - while (count) { - dma_addr_t buffer; - struct h2n_descriptor *desc = &desc_ring[hlos_index]; - - struct sk_buff *nbuf = dev_alloc_skb(max_buf_size); - if (unlikely(!nbuf)) { - /* - * ERR: - */ - NSS_PKT_STATS_INC(&nss_top->stats_drv[NSS_DRV_STATS_NBUF_ALLOC_FAILS]); - nss_warning("%px: Could not obtain empty buffer", nss_ctx); - break; - } - - /* - * Map the skb - */ - buffer = dma_map_single(nss_ctx->dev, nbuf->head, payload_len, DMA_FROM_DEVICE); - - if (unlikely(dma_mapping_error(nss_ctx->dev, buffer))) { - /* - * ERR: - */ - dev_kfree_skb_any(nbuf); - nss_warning("%px: DMA mapping failed for empty buffer", nss_ctx); - break; - } - - /* - * We are holding this skb in NSS FW, let kmemleak know about it - */ - kmemleak_not_leak(nbuf); - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); - - desc->opaque = (nss_ptr_t)nbuf; - desc->buffer = buffer; - desc->buffer_len = payload_len; - - hlos_index = (hlos_index + 1) & (mask); - count--; - } - - /* - * Find the last descriptor we need to flush. - */ - prev_hlos_index = (hlos_index - 1) & mask; - - /* - * Flush the descriptors, including the descriptor at prev_hlos_index. - */ - if (prev_hlos_index > start) { - dmac_clean_range((void *)&desc_ring[start], (void *)&desc_ring[prev_hlos_index] + sizeof(struct h2n_descriptor)); - } else { - /* - * We have wrapped around - */ - dmac_clean_range((void *)&desc_ring[start], (void *)&desc_ring[mask] + sizeof(struct h2n_descriptor)); - dmac_clean_range((void *)&desc_ring[0], (void *)&desc_ring[prev_hlos_index] + sizeof(struct h2n_descriptor)); - } - - /* - * Wait for the flushes to be synced before writing the index - */ - NSS_CORE_DSB(); - - h2n_desc_ring->hlos_index = hlos_index; - if_map->h2n_hlos_index[NSS_IF_H2N_EMPTY_BUFFER_QUEUE] = hlos_index; - - NSS_CORE_DMA_CACHE_MAINT(&if_map->h2n_hlos_index[NSS_IF_H2N_EMPTY_BUFFER_QUEUE], sizeof(uint32_t), DMA_TO_DEVICE); - NSS_CORE_DSB(); - - NSS_PKT_STATS_INC(&nss_top->stats_drv[NSS_DRV_STATS_TX_EMPTY]); -} - -/* - * nss_core_handle_empty_buffer_sos() - * Handle empty buffer SOS interrupt. - */ -static inline void nss_core_handle_empty_buffer_sos(struct nss_ctx_instance *nss_ctx, - struct nss_if_mem_map *if_map, uint16_t max_buf_size) -{ - uint16_t count, size, mask; - int32_t nss_index, hlos_index; - struct hlos_h2n_desc_rings *h2n_desc_ring = &nss_ctx->h2n_desc_rings[NSS_IF_H2N_EMPTY_BUFFER_QUEUE]; - - int paged_mode = nss_core_get_paged_mode(); - int jumbo_mru = nss_core_get_jumbo_mru(); - - /* - * Check how many empty buffers could be filled in queue - */ - NSS_CORE_DMA_CACHE_MAINT(&if_map->h2n_nss_index[NSS_IF_H2N_EMPTY_BUFFER_QUEUE], sizeof(uint32_t), DMA_FROM_DEVICE); - NSS_CORE_DSB(); - nss_index = if_map->h2n_nss_index[NSS_IF_H2N_EMPTY_BUFFER_QUEUE]; - - hlos_index = h2n_desc_ring->hlos_index; - size = h2n_desc_ring->desc_ring.size; - - mask = size - 1; - count = ((nss_index - hlos_index - 1) + size) & (mask); - - nss_trace("%px: Adding %d buffers to empty queue\n", nss_ctx, count); - - /* - * Fill empty buffer queue with buffers leaving one empty descriptor - * Note that total number of descriptors in queue cannot be more than (size - 1) - */ - if (!count) { - return; - } - - if (paged_mode) { - nss_core_alloc_paged_buffers(nss_ctx, if_map, count, mask, hlos_index, - NSS_DRV_STATS_NBUF_ALLOC_FAILS, H2N_BUFFER_EMPTY, - NSS_IF_H2N_EMPTY_BUFFER_QUEUE, NSS_DRV_STATS_TX_EMPTY); - } else if (jumbo_mru) { - nss_core_alloc_jumbo_mru_buffers(nss_ctx, if_map, jumbo_mru, count, - mask, hlos_index); - } else { - nss_core_alloc_max_avail_size_buffers(nss_ctx, if_map, max_buf_size, - count, mask, hlos_index); - } - - /* - * Inform NSS that new buffers are available - */ - nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_EMPTY_BUFFER_QUEUE); -} - -/* - * nss_core_handle_paged_empty_buffer_sos() - * Handle paged empty buffer SOS. - */ -static inline void nss_core_handle_paged_empty_buffer_sos(struct nss_ctx_instance *nss_ctx, - struct nss_if_mem_map *if_map, uint16_t max_buf_size) -{ - uint16_t count, size, mask; - int32_t nss_index, hlos_index; - struct hlos_h2n_desc_rings *h2n_desc_ring = &nss_ctx->h2n_desc_rings[NSS_IF_H2N_EMPTY_PAGED_BUFFER_QUEUE]; - - /* - * Check how many empty buffers could be filled in queue - */ - NSS_CORE_DMA_CACHE_MAINT((void *)&if_map->h2n_nss_index[NSS_IF_H2N_EMPTY_PAGED_BUFFER_QUEUE], sizeof(uint32_t), DMA_FROM_DEVICE); - NSS_CORE_DSB(); - nss_index = if_map->h2n_nss_index[NSS_IF_H2N_EMPTY_PAGED_BUFFER_QUEUE]; - - hlos_index = h2n_desc_ring->hlos_index; - size = h2n_desc_ring->desc_ring.size; - - mask = size - 1; - count = ((nss_index - hlos_index - 1) + size) & (mask); - nss_trace("%px: Adding %d buffers to paged buffer queue", nss_ctx, count); - - /* - * Fill empty buffer queue with buffers leaving one empty descriptor - * Note that total number of descriptors in queue cannot be more than (size - 1) - */ - if (!count) { - return; - } - - nss_core_alloc_paged_buffers(nss_ctx, if_map, count, mask, hlos_index, - NSS_DRV_STATS_PAGED_BUF_ALLOC_FAILS, H2N_PAGED_BUFFER_EMPTY, - NSS_IF_H2N_EMPTY_PAGED_BUFFER_QUEUE, NSS_DRV_STATS_PAGED_TX_EMPTY); - - /* - * Inform NSS that new buffers are available - */ - nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_EMPTY_PAGED_BUFFER_QUEUE); -} - -/* - * nss_core_handle_tx_unblocked() - * Handle TX Unblocked. - */ -static inline void nss_core_handle_tx_unblocked(struct nss_ctx_instance *nss_ctx) -{ - int32_t i; - nss_trace("%px: Data queue unblocked", nss_ctx); - - /* - * Call callback functions of drivers that have registered with us - */ - spin_lock_bh(&nss_ctx->decongest_cb_lock); - - for (i = 0; i < NSS_MAX_CLIENTS; i++) { - if (nss_ctx->queue_decongestion_callback[i]) { - nss_ctx->queue_decongestion_callback[i](nss_ctx->queue_decongestion_ctx[i]); - } - } - - spin_unlock_bh(&nss_ctx->decongest_cb_lock); - nss_ctx->h2n_desc_rings[NSS_IF_H2N_DATA_QUEUE].flags &= ~NSS_H2N_DESC_RING_FLAGS_TX_STOPPED; - - /* - * Mask Tx unblocked interrupt and unmask it again when queue full condition is reached - */ - nss_hal_disable_interrupt(nss_ctx, nss_ctx->int_ctx[0].shift_factor, NSS_N2H_INTR_TX_UNBLOCKED); -} - -/* - * nss_core_handle_cause_nonqueue() - * Handle non-queue interrupt causes (e.g. empty buffer SOS, Tx unblocked) - */ -static void nss_core_handle_cause_nonqueue(struct int_ctx_instance *int_ctx, uint32_t cause, int16_t weight) -{ - struct nss_ctx_instance *nss_ctx = int_ctx->nss_ctx; - struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; - struct nss_if_mem_map *if_map = mem_ctx->if_map; - uint16_t max_buf_size = (uint16_t) nss_ctx->max_buf_size; -#ifdef NSS_DRV_C2C_ENABLE - uint32_t c2c_intr_addr1, c2c_intr_addr2; - int32_t i; -#endif - - nss_assert((cause == NSS_N2H_INTR_EMPTY_BUFFERS_SOS) - || (cause == NSS_N2H_INTR_TX_UNBLOCKED) - || cause == NSS_N2H_INTR_PAGED_EMPTY_BUFFERS_SOS); - - /* - * If this is the first time we are receiving this interrupt then - * we need to initialize local state of NSS core. This helps us save an - * interrupt cause bit. Hopefully, unlikley and branch prediction algorithm - * of processor will prevent any excessive penalties. - */ - if (unlikely(nss_ctx->state == NSS_CORE_STATE_UNINITIALIZED)) { - struct nss_top_instance *nss_top = NULL; - nss_core_init_nss(nss_ctx, if_map); - nss_send_ddr_info(nss_ctx); - - 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 -#if (NSS_MAX_CORES > 1) - /* - * Pass C2C addresses of already brought up cores to the recently brought - * up core. No NSS core knows the state of other other cores in system so - * NSS driver needs to mediate and kick start C2C between them - */ - for (i = 0; i < nss_top_main.num_nss; i++) { - /* - * Loop through all NSS cores and send exchange C2C addresses - * TODO: Current implementation utilizes the fact that there are - * only two cores in current design. And ofcourse ignore - * the core that we are trying to initialize. - */ - if (&nss_top->nss[i] != nss_ctx) { - /* - * Block initialization routine of any other NSS cores running on other - * processors. We do not want them to mess around with their initialization - * state and C2C addresses while we check their state. - */ - spin_lock_bh(&nss_top->lock); - if (nss_top->nss[i].state == NSS_CORE_STATE_INITIALIZED) { - spin_unlock_bh(&nss_top->lock); - c2c_intr_addr1 = (uint32_t)(nss_ctx->nphys) + NSS_REGS_C2C_INTR_SET_OFFSET; - nss_c2c_tx_msg_cfg_map(&nss_top->nss[i], nss_ctx->c2c_start, c2c_intr_addr1); - c2c_intr_addr2 = (uint32_t)(nss_top->nss[i].nphys) + NSS_REGS_C2C_INTR_SET_OFFSET; - nss_c2c_tx_msg_cfg_map(nss_ctx, nss_top->nss[i].c2c_start, c2c_intr_addr2); - continue; - } - spin_unlock_bh(&nss_top->lock); - } - } -#endif -#endif - } - - /* - * TODO: find better mechanism to handle empty buffers - */ - if (likely(cause == NSS_N2H_INTR_EMPTY_BUFFERS_SOS)) { - nss_core_handle_empty_buffer_sos(nss_ctx, if_map, max_buf_size); - } else if (cause == NSS_N2H_INTR_PAGED_EMPTY_BUFFERS_SOS) { - nss_core_handle_paged_empty_buffer_sos(nss_ctx, if_map, max_buf_size); - } else if (cause == NSS_N2H_INTR_TX_UNBLOCKED) { - nss_core_handle_tx_unblocked(nss_ctx); - } -} - -/* - * nss_core_get_prioritized_cause() - * Obtain proritized cause (from multiple interrupt causes) that - * must be handled by NSS driver before other causes - */ -static uint32_t nss_core_get_prioritized_cause(uint32_t cause, uint32_t *type, int16_t *weight) -{ - *type = NSS_INTR_CAUSE_INVALID; - *weight = 0; - - /* - * NOTE: This is a very simple algorithm with fixed weight and strict priority - * - * TODO: Modify the algorithm later with proper weights and Round Robin - */ - - if (cause & NSS_N2H_INTR_EMPTY_BUFFERS_SOS) { - *type = NSS_INTR_CAUSE_NON_QUEUE; - *weight = NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT; - return NSS_N2H_INTR_EMPTY_BUFFERS_SOS; - } - - if (cause & NSS_N2H_INTR_PAGED_EMPTY_BUFFERS_SOS) { - *type = NSS_INTR_CAUSE_NON_QUEUE; - *weight = NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT; - return NSS_N2H_INTR_PAGED_EMPTY_BUFFERS_SOS; - } - - if (cause & NSS_N2H_INTR_EMPTY_BUFFER_QUEUE) { - *type = NSS_INTR_CAUSE_QUEUE; - *weight = NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT; - return NSS_N2H_INTR_EMPTY_BUFFER_QUEUE; - } - - if (cause & NSS_N2H_INTR_TX_UNBLOCKED) { - *type = NSS_INTR_CAUSE_NON_QUEUE; - *weight = NSS_TX_UNBLOCKED_PROCESSING_WEIGHT; - return NSS_N2H_INTR_TX_UNBLOCKED; - } - - if (cause & NSS_N2H_INTR_DATA_QUEUE_0) { - *type = NSS_INTR_CAUSE_QUEUE; - *weight = NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT; - return NSS_N2H_INTR_DATA_QUEUE_0; - } - - if (cause & NSS_N2H_INTR_DATA_QUEUE_1) { - *type = NSS_INTR_CAUSE_QUEUE; - *weight = NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT; - return NSS_N2H_INTR_DATA_QUEUE_1; - } - - if (cause & NSS_N2H_INTR_DATA_QUEUE_2) { - *type = NSS_INTR_CAUSE_QUEUE; - *weight = NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT; - return NSS_N2H_INTR_DATA_QUEUE_2; - } - - if (cause & NSS_N2H_INTR_DATA_QUEUE_3) { - *type = NSS_INTR_CAUSE_QUEUE; - *weight = NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT; - return NSS_N2H_INTR_DATA_QUEUE_3; - } - - if (cause & NSS_N2H_INTR_COREDUMP_COMPLETE) { - *type = NSS_INTR_CAUSE_EMERGENCY; - return NSS_N2H_INTR_COREDUMP_COMPLETE; - } - - if (cause & NSS_N2H_INTR_PROFILE_DMA) { - *type = NSS_INTR_CAUSE_SDMA; - return NSS_N2H_INTR_PROFILE_DMA; - } - - return 0; -} - -/* - * nss_core_handle_napi() - * NAPI handler for NSS - */ -int nss_core_handle_napi(struct napi_struct *napi, int budget) -{ - int16_t processed, weight, count = 0; - uint32_t prio_cause, int_cause = 0, cause_type; - struct int_ctx_instance *int_ctx = container_of(napi, struct int_ctx_instance, napi); - struct nss_ctx_instance *nss_ctx = int_ctx->nss_ctx; - - /* - * Read cause of interrupt - */ - nss_hal_read_interrupt_cause(nss_ctx, int_ctx->shift_factor, &int_cause); - nss_hal_clear_interrupt_cause(nss_ctx, int_ctx->shift_factor, int_cause); - int_ctx->cause |= int_cause; - - do { - while ((int_ctx->cause) && (budget)) { - - /* - * Obtain the cause as per priority. Also obtain the weight - * - * NOTE: The idea is that all causes are processed as per priority and weight - * so that no single cause can overwhelm the system. - */ - prio_cause = nss_core_get_prioritized_cause(int_ctx->cause, &cause_type, &weight); - if (budget < weight) { - weight = budget; - } - - processed = 0; - switch (cause_type) { - case NSS_INTR_CAUSE_QUEUE: - processed = nss_core_handle_cause_queue(int_ctx, prio_cause, weight); - - count += processed; - budget -= processed; - - /* - * If #packets processed were lesser than weight then processing for this queue/cause is - * complete and we can clear this interrupt cause from interrupt context structure - */ - if (processed < weight) { - int_ctx->cause &= ~prio_cause; - } - break; - - case NSS_INTR_CAUSE_NON_QUEUE: - nss_core_handle_cause_nonqueue(int_ctx, prio_cause, weight); - int_ctx->cause &= ~prio_cause; - break; - - case NSS_INTR_CAUSE_SDMA: - nss_core_handle_napi_sdma(napi, budget); - int_ctx->cause &= ~prio_cause; - break; - - case NSS_INTR_CAUSE_EMERGENCY: - nss_info_always("NSS core %d signal COREDUMP COMPLETE %x\n", - nss_ctx->id, int_ctx->cause); - nss_fw_coredump_notify(nss_ctx, prio_cause); - int_ctx->cause &= ~prio_cause; - break; - - default: - nss_warning("%px: Invalid cause %x received from nss", nss_ctx, int_cause); - nss_assert(0); - break; - } - } - - nss_hal_read_interrupt_cause(nss_ctx, int_ctx->shift_factor, &int_cause); - nss_hal_clear_interrupt_cause(nss_ctx, int_ctx->shift_factor, int_cause); - int_ctx->cause |= int_cause; - } while ((int_ctx->cause) && (budget)); - - if (int_ctx->cause == 0) { - napi_complete(napi); - - /* - * Re-enable any further interrupt from this IRQ - */ - nss_hal_enable_interrupt(nss_ctx, int_ctx->shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS); - } - - return count; -} - -/* - * nss_core_handle_napi_emergency() - * NAPI handler for NSS crash - */ -int nss_core_handle_napi_emergency(struct napi_struct *napi, int budget) -{ - struct int_ctx_instance *int_ctx = container_of(napi, struct int_ctx_instance, napi); - - nss_info_always("NSS core %d signal COREDUMP COMPLETE %x\n", - int_ctx->nss_ctx->id, int_ctx->cause); - nss_fw_coredump_notify(int_ctx->nss_ctx, 0); - - return 0; -} - -/* - * nss_core_handle_napi_sdma() - * NAPI handler for NSS soft DMA - */ -int nss_core_handle_napi_sdma(struct napi_struct *napi, int budget) -{ - struct int_ctx_instance *int_ctx = container_of(napi, struct int_ctx_instance, napi); - struct nss_ctx_instance *nss_ctx = int_ctx->nss_ctx; - struct nss_profile_sdma_ctrl *ctrl = (struct nss_profile_sdma_ctrl *)nss_ctx->meminfo_ctx.sdma_ctrl; - - if (ctrl->consumer[0].dispatch.fp) - ctrl->consumer[0].dispatch.fp(ctrl->consumer[0].arg.kp); - -#if !defined(NSS_HAL_IPQ806X_SUPPORT) - napi_complete(napi); - enable_irq(int_ctx->irq); -#endif - return 0; -} - -/* - * nss_core_handle_napi_queue() - * NAPI handler for NSS queue cause - */ -int nss_core_handle_napi_queue(struct napi_struct *napi, int budget) -{ - int processed; - struct int_ctx_instance *int_ctx = container_of(napi, struct int_ctx_instance, napi); - - processed = nss_core_handle_cause_queue(int_ctx, int_ctx->cause, budget); - if (processed < budget) { - napi_complete(napi); - enable_irq(int_ctx->irq); - } - - return processed; -} - -/* - * nss_core_handle_napi_non_queue() - * NAPI handler for NSS non queue cause - */ -int nss_core_handle_napi_non_queue(struct napi_struct *napi, int budget) -{ - struct int_ctx_instance *int_ctx = container_of(napi, struct int_ctx_instance, napi); - - nss_core_handle_cause_nonqueue(int_ctx, int_ctx->cause, 0); - napi_complete(napi); - enable_irq(int_ctx->irq); - return 0; -} - -/* - * nss_core_write_one_descriptor() - * Fills-up a descriptor with required fields. - */ -static inline void nss_core_write_one_descriptor(struct h2n_descriptor *desc, - uint16_t buffer_type, uint32_t buffer, uint32_t if_num, - nss_ptr_t opaque, uint16_t payload_off, uint16_t payload_len, uint16_t buffer_len, - uint32_t qos_tag, uint16_t mss, uint16_t bit_flags) -{ - desc->buffer_type = buffer_type; - desc->buffer = buffer; - desc->interface_num = if_num; - desc->opaque = opaque; - desc->payload_offs = payload_off; - desc->payload_len = payload_len; - desc->buffer_len = buffer_len; - desc->qos_tag = qos_tag; - desc->mss = mss; - desc->bit_flags = bit_flags; -} - -/* -* nss_core_send_unwind_dma() -* It unwinds (or unmap) DMA from descriptors -*/ -static inline void nss_core_send_unwind_dma(struct device *dev, struct h2n_desc_if_instance *desc_if, - uint16_t hlos_index, int16_t count, bool is_fraglist) -{ - struct h2n_descriptor *desc_ring = desc_if->desc; - struct h2n_descriptor *desc; - int16_t i, mask; - - mask = desc_if->size - 1; - for (i = 0; i < count; i++) { - desc = &desc_ring[hlos_index]; - if (is_fraglist) { - dma_unmap_single(dev, desc->buffer, desc->buffer_len, DMA_TO_DEVICE); - } else { - dma_unmap_page(dev, desc->buffer, desc->buffer_len, DMA_TO_DEVICE); - } - hlos_index = (hlos_index - 1) & mask; - } -} - -/* - * nss_core_skb_tail_offset() - */ -static inline uint32_t nss_core_skb_tail_offset(struct sk_buff *skb) -{ -#ifdef NET_SKBUFF_DATA_USES_OFFSET - return skb->tail; -#else - return skb->tail - skb->head; -#endif -} - -/* - * nss_core_dma_map_single() - */ -static inline uint32_t nss_core_dma_map_single(struct device *dev, struct sk_buff *skb) -{ - return (uint32_t)dma_map_single(dev, skb->head, nss_core_skb_tail_offset(skb), DMA_TO_DEVICE); -} - -#if (NSS_SKB_REUSE_SUPPORT == 1) -/* - * nss_core_skb_can_reuse - * check if skb can be reuse - */ -static inline bool nss_core_skb_can_reuse(struct nss_ctx_instance *nss_ctx, - uint32_t if_num, struct sk_buff *nbuf, int min_skb_size) -{ - /* - * If we have to call a destructor, we can't re-use the buffer? - */ - if (unlikely(nbuf->destructor != NULL)) { - return false; - } - - /* - * Check if skb has more than single user. - */ - if (unlikely(skb_shared(nbuf))) { - return false; - } - -#if IS_ENABLED(CONFIG_NF_CONNTRACK) - /* - * This check is added to avoid deadlock from nf_conntrack - * when ecm is trying to flush a rule. - */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)) - if (unlikely(nbuf->nfct)) { - return false; - } -#else - if (unlikely(nbuf->_nfct)) { - return false; - } -#endif -#endif - -#ifdef CONFIG_BRIDGE_NETFILTER - /* - * This check is added to avoid deadlock from nf_bridge - * when ecm is trying to flush a rule. - */ - if (unlikely(nf_bridge_info_get(nbuf))) { - return false; - } -#endif - - /* - * If skb has security parameters set do not reuse - */ - if (unlikely(skb_sec_path(nbuf))) { - return false; - } - - if (unlikely(irqs_disabled())) - return false; - - if (unlikely(skb_shinfo(nbuf)->tx_flags & SKBTX_DEV_ZEROCOPY)) - return false; - - if (unlikely(skb_is_nonlinear(nbuf))) - return false; - - if (unlikely(skb_has_frag_list(nbuf))) - return false; - - if (unlikely(skb_shinfo(nbuf)->nr_frags)) - return false; - - if (unlikely(nbuf->fclone != SKB_FCLONE_UNAVAILABLE)) - return false; - - min_skb_size = SKB_DATA_ALIGN(min_skb_size + NET_SKB_PAD); - if (unlikely(skb_end_pointer(nbuf) - nbuf->head < min_skb_size)) - return false; - - if (unlikely(skb_end_pointer(nbuf) - nbuf->head >= nss_core_get_max_reuse())) - return false; - - if (unlikely(skb_cloned(nbuf))) - return false; - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) - if (unlikely(skb_pfmemalloc(nbuf))) - return false; -#endif - - return true; -} - -/* - * nss_skb_reuse - clean up an skb - * Clears the skb to be reused as a receive buffer. - * - * NOTE: This function does any necessary reference count dropping, and - * cleans up the skbuff as if its allocated fresh. - */ -void nss_skb_reuse(struct sk_buff *nbuf) -{ - struct skb_shared_info *shinfo; - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) - u8 head_frag = nbuf->head_frag; -#endif - - /* - * Reset all the necessary head state information from skb which - * we found can be recycled for NSS. - */ - skb_dst_drop(nbuf); - - shinfo = skb_shinfo(nbuf); - memset(shinfo, 0, offsetof(struct skb_shared_info, dataref)); - atomic_set(&shinfo->dataref, 1); - - memset(nbuf, 0, offsetof(struct sk_buff, tail)); - nbuf->data = nbuf->head + NET_SKB_PAD; - skb_reset_tail_pointer(nbuf); - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) - nbuf->head_frag = head_frag; -#endif -} -#endif - -/* - * nss_core_send_buffer_simple_skb() - * Sends one skb to NSS FW - */ -static inline int32_t nss_core_send_buffer_simple_skb(struct nss_ctx_instance *nss_ctx, - struct h2n_desc_if_instance *desc_if, uint32_t if_num, - struct sk_buff *nbuf, uint16_t hlos_index, uint16_t flags, uint8_t buffer_type, uint16_t mss) -{ - struct h2n_descriptor *desc_ring = desc_if->desc; - struct h2n_descriptor *desc; - uint16_t bit_flags; - uint16_t mask; - uint32_t frag0phyaddr; - -#if (NSS_SKB_REUSE_SUPPORT == 1) - uint16_t sz; -#endif - - bit_flags = flags | H2N_BIT_FLAG_FIRST_SEGMENT | H2N_BIT_FLAG_LAST_SEGMENT; - if (likely(nbuf->ip_summed == CHECKSUM_PARTIAL)) { - bit_flags |= H2N_BIT_FLAG_GEN_IP_TRANSPORT_CHECKSUM; - bit_flags |= H2N_BIT_FLAG_GEN_IPV4_IP_CHECKSUM; - } else if (nbuf->ip_summed == CHECKSUM_UNNECESSARY) { - bit_flags |= H2N_BIT_FLAG_GEN_IP_TRANSPORT_CHECKSUM_NONE; - } - - mask = desc_if->size - 1; - desc = &desc_ring[hlos_index]; - -#if (NSS_SKB_REUSE_SUPPORT == 1) - /* - * Check if the caller indicates that the buffer is not to be re-used (kept in the accelerator). - */ - if (unlikely(!(bit_flags & H2N_BIT_FLAG_BUFFER_REUSABLE))) { - goto no_reuse; - } - - /* - * Since the caller is allowing re-use, we now check if the skb meets the criteria. - */ - if (unlikely(!nss_core_skb_can_reuse(nss_ctx, if_num, nbuf, nss_ctx->max_buf_size))) { - goto no_reuse; - } - - /* - * We are going to do both Tx and then Rx on this buffer, unmap the Tx - * and then map Rx over the entire buffer. - */ - sz = max((uint16_t)nss_core_skb_tail_offset(nbuf), (uint16_t)(nss_ctx->max_buf_size + NET_SKB_PAD)); - frag0phyaddr = (uint32_t)dma_map_single(nss_ctx->dev, nbuf->head, sz, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(nss_ctx->dev, frag0phyaddr))) { - goto no_reuse; - } - - /* - * We are allowed to re-use the packet - */ - nss_core_write_one_descriptor(desc, buffer_type, frag0phyaddr, if_num, - (nss_ptr_t)nbuf, (uint16_t)(nbuf->data - nbuf->head), nbuf->len, - sz, (uint32_t)nbuf->priority, mss, bit_flags); - - NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); - - /* - * We are done using the skb fields and can reuse it now - */ - nss_skb_reuse(nbuf); - - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_BUFFER_REUSE]); - return 1; - -no_reuse: -#endif - - 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("%px: DMA mapping failed for virtual address = %px", nss_ctx, nbuf->head); - return 0; - } - - nss_core_write_one_descriptor(desc, buffer_type, frag0phyaddr, if_num, - (nss_ptr_t)nbuf, (uint16_t)(nbuf->data - nbuf->head), nbuf->len, - (uint16_t)skb_end_offset(nbuf), (uint32_t)nbuf->priority, mss, bit_flags); - - NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); - - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_SIMPLE]); - return 1; -} - -/* - * nss_core_send_buffer_nr_frags() - * Sends frags array (NETIF_F_SG) to NSS FW - * - * Note - Opaque is set only on LAST fragment, and DISCARD is set for the rest of segments - * Used to differentiate from FRAGLIST - */ -static inline int32_t nss_core_send_buffer_nr_frags(struct nss_ctx_instance *nss_ctx, - struct h2n_desc_if_instance *desc_if, uint32_t if_num, - struct sk_buff *nbuf, uint16_t hlos_index, uint16_t flags, uint8_t buffer_type, uint16_t mss) -{ - struct h2n_descriptor *desc_ring = desc_if->desc; - struct h2n_descriptor *desc; - const skb_frag_t *frag; - dma_addr_t buffer; - uint32_t nr_frags; - uint16_t bit_flags; - int16_t i; - uint16_t mask; - - uint32_t frag0phyaddr = nss_core_dma_map_single(nss_ctx->dev, nbuf); - if (unlikely(dma_mapping_error(nss_ctx->dev, frag0phyaddr))) { - nss_warning("%px: DMA mapping failed for virtual address = %px", nss_ctx, nbuf->head); - return 0; - } - - /* - * Set the appropriate flags. - */ - bit_flags = (flags | H2N_BIT_FLAG_DISCARD); - - /* - * Reset the reuse flag for non-linear buffers. - */ - bit_flags &= ~H2N_BIT_FLAG_BUFFER_REUSABLE; - if (likely(nbuf->ip_summed == CHECKSUM_PARTIAL)) { - bit_flags |= H2N_BIT_FLAG_GEN_IP_TRANSPORT_CHECKSUM; - bit_flags |= H2N_BIT_FLAG_GEN_IPV4_IP_CHECKSUM; - } - - mask = desc_if->size - 1; - desc = &desc_ring[hlos_index]; - - /* - * First fragment/descriptor is special - */ - nss_core_write_one_descriptor(desc, buffer_type, frag0phyaddr, if_num, - (nss_ptr_t)NULL, nbuf->data - nbuf->head, nbuf->len - nbuf->data_len, - skb_end_offset(nbuf), (uint32_t)nbuf->priority, mss, bit_flags | H2N_BIT_FLAG_FIRST_SEGMENT); - - NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); - - /* - * Now handle rest of the fragments. - */ - nr_frags = skb_shinfo(nbuf)->nr_frags; - BUG_ON(nr_frags > MAX_SKB_FRAGS); - for (i = 0; i < nr_frags; i++) { - frag = &skb_shinfo(nbuf)->frags[i]; - - 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("%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); - } - - hlos_index = (hlos_index + 1) & (mask); - desc = &(desc_if->desc[hlos_index]); - - nss_core_write_one_descriptor(desc, buffer_type, buffer, if_num, - (nss_ptr_t)NULL, 0, skb_frag_size(frag), skb_frag_size(frag), - nbuf->priority, mss, bit_flags); - - NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); - } - - /* - * Update bit flag for last descriptor. - * The discard flag shall be set for all fragments except the - * the last one.The NSS returns the last fragment to HLOS - * after the packet processing is done.We do need to send the - * packet buffer address (skb) in the descriptor of last segment - * when the decriptor returns from NSS the HLOS uses the - * opaque field to free the memory allocated. - */ - desc->bit_flags |= H2N_BIT_FLAG_LAST_SEGMENT; - desc->bit_flags &= ~(H2N_BIT_FLAG_DISCARD); - desc->opaque = (nss_ptr_t)nbuf; - - NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); - - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_NR_FRAGS]); - return i+1; -} - -/* - * nss_core_send_buffer_fraglist() - * Sends fraglist (NETIF_F_FRAGLIST) to NSS FW - * - * Note - Opaque will be set on all fragments, and DISCARD is set for the rest of segments - * Used to differentiate from FRAGS - */ -static inline int32_t nss_core_send_buffer_fraglist(struct nss_ctx_instance *nss_ctx, - struct h2n_desc_if_instance *desc_if, uint32_t if_num, - struct sk_buff *nbuf, uint16_t hlos_index, uint16_t flags, uint8_t buffer_type, uint16_t mss) -{ - struct h2n_descriptor *desc_ring = desc_if->desc; - struct h2n_descriptor *desc; - dma_addr_t buffer; - uint16_t mask; - struct sk_buff *iter; - uint16_t bit_flags; - int16_t i; - - uint32_t frag0phyaddr = nss_core_dma_map_single(nss_ctx->dev, nbuf); - if (unlikely(dma_mapping_error(nss_ctx->dev, frag0phyaddr))) { - nss_warning("%px: DMA mapping failed for virtual address = %px", nss_ctx, nbuf->head); - return 0; - } - - /* - * Copy and Set bit flags - */ - bit_flags = flags; - - /* - * Reset the reuse flag for non-linear buffers. - */ - bit_flags &= ~H2N_BIT_FLAG_BUFFER_REUSABLE; - if (likely(nbuf->ip_summed == CHECKSUM_PARTIAL)) { - bit_flags |= H2N_BIT_FLAG_GEN_IP_TRANSPORT_CHECKSUM; - bit_flags |= H2N_BIT_FLAG_GEN_IPV4_IP_CHECKSUM; - } - - mask = desc_if->size - 1; - desc = &desc_ring[hlos_index]; - - /* - * First fragment/descriptor is special. Will hold the Opaque - */ - nss_core_write_one_descriptor(desc, buffer_type, frag0phyaddr, if_num, - (nss_ptr_t)nbuf, nbuf->data - nbuf->head, nbuf->len - nbuf->data_len, - skb_end_offset(nbuf), (uint32_t)nbuf->priority, mss, bit_flags | H2N_BIT_FLAG_FIRST_SEGMENT); - - NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); - - /* - * Walk the frag_list in nbuf - */ - i = 0; - skb_walk_frags(nbuf, iter) { - uint32_t nr_frags; - - buffer = nss_core_dma_map_single(nss_ctx->dev, iter); - if (unlikely(dma_mapping_error(nss_ctx->dev, buffer))) { - 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); - } - - /* - * We currently don't support frags[] array inside a - * fraglist. - */ - nr_frags = skb_shinfo(iter)->nr_frags; - if (unlikely(nr_frags > 0)) { - 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); - } - - /* - * Update index. - */ - hlos_index = (hlos_index + 1) & (mask); - desc = &(desc_if->desc[hlos_index]); - -#ifdef CONFIG_DEBUG_KMEMLEAK - /* - * We are holding this skb in NSS FW, let kmemleak know about it. - * - * If the skb is a fast clone (FCLONE), then nbuf is pointing to the - * cloned skb which is at the middle of the allocated block and kmemleak API - * would backtrace if passed such a pointer. We will need to get to the original - * skb pointer which kmemleak is aware of. - */ - if (iter->fclone == SKB_FCLONE_CLONE) { - kmemleak_not_leak(iter - 1); - } else { - kmemleak_not_leak(iter); - } -#endif - - nss_core_write_one_descriptor(desc, buffer_type, buffer, if_num, - (nss_ptr_t)iter, iter->data - iter->head, iter->len - iter->data_len, - skb_end_offset(iter), iter->priority, mss, bit_flags); - - NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); - - i++; - } - - /* - * We need to defrag the frag_list, otherwise, if this structure is - * received back we don't know how we can reconstruct the frag_list. - * Therefore, we are clearing skb_has_fraglist. This is safe because all - * information about the segments are already sent to NSS-FW. - * So, the information will be in the NSS-FW. - */ - skb_shinfo(nbuf)->frag_list = NULL; - NSS_PKT_STATS_ADD(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT], i); - - /* - * Update bit flag for last descriptor. - */ - desc->bit_flags |= H2N_BIT_FLAG_LAST_SEGMENT; - NSS_CORE_DMA_CACHE_MAINT((void *)desc, sizeof(*desc), DMA_TO_DEVICE); - - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_FRAGLIST]); - return i+1; -} - -/* - * nss_core_init_handlers() - * Initialize the handlers for all interfaces associated with core - */ -void nss_core_init_handlers(struct nss_ctx_instance *nss_ctx) -{ - struct nss_rx_cb_list *cb_list = nss_ctx->nss_rx_interface_handlers; - memset(cb_list, 0, sizeof(*cb_list) * NSS_MAX_NET_INTERFACES); -} - -/* - * nss_core_send_buffer() - * Send network buffer to NSS - */ -int32_t nss_core_send_buffer(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - struct sk_buff *nbuf, uint16_t qid, - uint8_t buffer_type, uint16_t flags) -{ - int16_t count, hlos_index, nss_index, size, mask; - uint32_t segments; - struct hlos_h2n_desc_rings *h2n_desc_ring = &nss_ctx->h2n_desc_rings[qid]; - struct h2n_desc_if_instance *desc_if = &h2n_desc_ring->desc_ring; - struct h2n_descriptor *desc_ring; - struct h2n_descriptor *desc; - struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; - struct nss_if_mem_map *if_map = mem_ctx->if_map; - uint16_t mss = 0; - bool is_bounce = ((buffer_type == H2N_BUFFER_SHAPER_BOUNCE_INTERFACE) || (buffer_type == H2N_BUFFER_SHAPER_BOUNCE_BRIDGE)); - - desc_ring = desc_if->desc; - size = desc_if->size; - mask = size - 1; - - /* - * If nbuf does not have fraglist, then update nr_frags - * from frags[] array. Otherwise walk the frag_list. - */ - if (!skb_has_frag_list(nbuf)) { - segments = skb_shinfo(nbuf)->nr_frags; - BUG_ON(segments > MAX_SKB_FRAGS); - } else { - struct sk_buff *iter; - segments = 0; - skb_walk_frags(nbuf, iter) { - segments++; - } - - /* - * Check that segments do not overflow the number of descriptors - */ - if (unlikely(segments > size)) { - nss_warning("%px: Unable to fit in skb - %d segments in our descriptors", nss_ctx, segments); - return NSS_CORE_STATUS_FAILURE; - } - } - - /* - * Take a lock for queue - */ - spin_lock_bh(&h2n_desc_ring->lock); - - /* - * 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))) { - /* - * 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); - -#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); - } -#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; - } - - desc = &desc_ring[hlos_index]; - - /* - * Check if segmentation enabled. - * Configure descriptor bit flags accordingly - */ - - /* - * When CONFIG_HIGHMEM is enabled OS is giving a single big chunk buffer without - * any scattered frames. - * - * NOTE: We dont have to perform segmentation offload for packets that are being - * bounced. These packets WILL return to the HLOS for freeing or further processing. - * They will NOT be transmitted by the NSS. - */ - if (skb_is_gso(nbuf) && !is_bounce) { - mss = skb_shinfo(nbuf)->gso_size; - flags |= H2N_BIT_FLAG_SEGMENTATION_ENABLE; - } - - /* - * WARNING! : The following "is_bounce" check has a potential to cause corruption - * if things change in the NSS. This check allows fragmented packets to be sent down - * with incomplete payload information since NSS does not care about the payload content - * when packets are bounced for shaping. If it starts caring in future, then this code - * will have to change. - * - * WHY WE ARE DOING THIS - Skipping S/G processing helps with performance. - * - */ - count = 0; - if (likely((segments == 0) || is_bounce)) { - count = nss_core_send_buffer_simple_skb(nss_ctx, desc_if, if_num, - nbuf, hlos_index, flags, buffer_type, mss); - } else if (skb_has_frag_list(nbuf)) { - count = nss_core_send_buffer_fraglist(nss_ctx, desc_if, if_num, - nbuf, hlos_index, flags, buffer_type, mss); - } else { - count = nss_core_send_buffer_nr_frags(nss_ctx, desc_if, if_num, - nbuf, hlos_index, flags, buffer_type, mss); - } - - if (unlikely(count <= 0)) { - /* - * We failed and hence we need to unmap dma regions - */ - nss_warning("%px: failed to map DMA regions:%d", nss_ctx, -count); - spin_unlock_bh(&h2n_desc_ring->lock); - return NSS_CORE_STATUS_FAILURE; - } - - /* - * Sync to ensure all flushing of the descriptors are complete - */ - NSS_CORE_DSB(); - - /* - * Update our host index so the NSS sees we've written a new descriptor. - */ - hlos_index = (hlos_index + count) & mask; - h2n_desc_ring->hlos_index = hlos_index; - if_map->h2n_hlos_index[qid] = hlos_index; - - NSS_CORE_DMA_CACHE_MAINT(&if_map->h2n_hlos_index[qid], sizeof(uint32_t), DMA_TO_DEVICE); - NSS_CORE_DSB(); - -#ifdef CONFIG_DEBUG_KMEMLEAK - /* - * We are holding this skb in NSS FW, let kmemleak know about it. - * - * If the skb is a fast clone (FCLONE), then nbuf is pointing to the - * cloned skb which is at the middle of the allocated block and kmemleak API - * would backtrace if passed such a pointer. We will need to get to the original - * skb pointer which kmemleak is aware of. - */ - if (nbuf->fclone == SKB_FCLONE_CLONE) { - kmemleak_not_leak(nbuf - 1); - } else { - kmemleak_not_leak(nbuf); - } -#endif - - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); - - spin_unlock_bh(&h2n_desc_ring->lock); - return NSS_CORE_STATUS_SUCCESS; -} - -/* - * nss_core_send_cmd() - * Send command message to NSS - */ -int32_t nss_core_send_cmd(struct nss_ctx_instance *nss_ctx, void *msg, int size, int buf_size) -{ - struct nss_cmn_msg *ncm = (struct nss_cmn_msg *)msg; - int32_t status; - struct sk_buff *nbuf; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { - 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("%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("%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; - } - - 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("%px: interface: %d type: %d msg dropped as command allocation failed", nss_ctx, ncm->interface, ncm->type); - return NSS_TX_FAILURE; - } - - memcpy(skb_put(nbuf, buf_size), (void *)ncm, size); - - status = nss_core_send_buffer(nss_ctx, 0, nbuf, NSS_IF_H2N_CMD_QUEUE, H2N_BUFFER_CTRL, H2N_BIT_FLAG_BUFFER_REUSABLE); - 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("%px: interface: %d type: %d unable to enqueue message status %d\n", nss_ctx, ncm->interface, ncm->type, status); - return status; - } - - nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_CMD_REQ]); - return status; -} - -/* - * nss_core_send_packet() - * Send data packet to NSS - */ -int32_t nss_core_send_packet(struct nss_ctx_instance *nss_ctx, struct sk_buff *nbuf, uint32_t if_num, uint32_t flag) -{ - int32_t status; - int32_t queue_id = 0; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { - nss_warning("%px: interface: %d packet dropped as core not ready\n", nss_ctx, if_num); - return NSS_TX_FAILURE_NOT_READY; - } - -#ifdef NSS_MULTI_H2N_DATA_RING_SUPPORT - queue_id = (skb_get_queue_mapping(nbuf) & (NSS_HOST_CORES - 1)) << 1; - if (nbuf->priority) { - queue_id++; - } -#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("%px: interface: %d unable to enqueue packet status %d\n", nss_ctx, if_num, status); - return status; - } - - nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); - -#ifdef NSS_MULTI_H2N_DATA_RING_SUPPORT - /* - * Count per queue and aggregate packet count - */ - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_PACKET_QUEUE_0 + queue_id]); -#endif - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_PACKET]); - return status; -} - -/* - * nss_core_ddr_info() - * Getting DDR information for NSS core - */ -uint32_t nss_core_ddr_info(struct nss_mmu_ddr_info *mmu) -{ - nss_get_ddr_info(mmu, "memory"); - return nss_soc_mem_info(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_core.h b/feeds/ipq807x/qca-nss-drv/src/nss_core.h deleted file mode 100644 index d7f62feff..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_core.h +++ /dev/null @@ -1,1038 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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. - ************************************************************************** - */ - -/* - * na_core.h - * NSS driver core header file. - */ - -#ifndef __NSS_CORE_H -#define __NSS_CORE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "nss_phys_if.h" -#include "nss_hlos_if.h" -#include "nss_oam.h" -#include "nss_data_plane.h" -#include "nss_gmac_stats.h" -#include "nss_meminfo.h" -#include "nss_stats.h" - -/* - * NSS debug macros - */ -#define nss_info_always(s, ...) pr_alert(s, ##__VA_ARGS__) - -#if (NSS_DEBUG_LEVEL < 1) -#define nss_assert(fmt, args...) -#else -#define nss_assert(c) if (!(c)) { BUG_ON(!(c)); } -#endif - -#if defined(CONFIG_DYNAMIC_DEBUG) -/* - * Compile messages for dynamic enable/disable - */ -#define nss_warning(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) -#define nss_info(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) -#define nss_trace(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) -#else - -/* - * Statically compile messages at different levels - */ -#if (NSS_DEBUG_LEVEL < 2) -#define nss_warning(s, ...) -#else -#define nss_warning(s, ...) pr_warn("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) -#endif - -#if (NSS_DEBUG_LEVEL < 3) -#define nss_info(s, ...) -#else -#define nss_info(s, ...) pr_notice("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) -#endif - -#if (NSS_DEBUG_LEVEL < 4) -#define nss_trace(s, ...) -#else -#define nss_trace(s, ...) pr_info("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) -#endif -#endif - -#if (NSS_PKT_STATS_ENABLED == 1) -#define NSS_PKT_STATS_INC(x) nss_pkt_stats_inc((x)) -#define NSS_PKT_STATS_DEC(x) nss_pkt_stats_dec((x)) -#define NSS_PKT_STATS_ADD(x, i) nss_pkt_stats_add((x), (i)) -#define NSS_PKT_STATS_SUB(x, i) nss_pkt_stats_sub((x), (i)) -#define NSS_PKT_STATS_READ(x) nss_pkt_stats_read(x) -#else -#define NSS_PKT_STATS_INC(x) -#define NSS_PKT_STATS_DEC(x) -#define NSS_PKT_STATS_ADD(x, i) -#define NSS_PKT_STATS_SUB(x, i) -#define NSS_PKT_STATS_READ(x) -#endif - -/* - * Cache operation - */ -#define NSS_CORE_DSB() dsb(sy) -#define NSS_CORE_DMA_CACHE_MAINT(start, size, dir) nss_core_dma_cache_maint(start, size, dir) - -/* - * nss_core_dma_cache_maint() - * Perform the appropriate cache op based on direction - */ -static inline void nss_core_dma_cache_maint(void *start, uint32_t size, int direction) -{ - switch (direction) { - case DMA_FROM_DEVICE:/* invalidate only */ - dmac_inv_range(start, start + size); - break; - case DMA_TO_DEVICE:/* writeback only */ - dmac_clean_range(start, start + size); - break; - case DMA_BIDIRECTIONAL:/* writeback and invalidate */ - dmac_flush_range(start, start + size); - break; - default: - BUG(); - } -} - -#define NSS_DEVICE_IF_START NSS_PHYSICAL_IF_START - -#define NSS_IS_IF_TYPE(type, if_num) ((if_num >= NSS_##type##_IF_START) && (if_num < (NSS_##type##_IF_START + NSS_MAX_##type##_INTERFACES))) - -/* - * Default payload size for NSS buffers - */ -#define NSS_NBUF_PAYLOAD_SIZE NSS_EMPTY_BUFFER_SIZE -#define NSS_NBUF_PAD_EXTRA 256 -#define NSS_NBUF_ETH_EXTRA 192 - -/* - * N2H/H2N Queue IDs - */ -#define NSS_IF_N2H_EMPTY_BUFFER_RETURN_QUEUE 0 -#define NSS_IF_N2H_DATA_QUEUE_0 1 -#define NSS_IF_N2H_DATA_QUEUE_1 2 -#define NSS_IF_N2H_DATA_QUEUE_2 3 -#define NSS_IF_N2H_DATA_QUEUE_3 4 - -#define NSS_IF_H2N_EMPTY_BUFFER_QUEUE 0 -#define NSS_IF_H2N_CMD_QUEUE 1 -#define NSS_IF_H2N_EMPTY_PAGED_BUFFER_QUEUE 2 -#define NSS_IF_H2N_DATA_QUEUE 3 - -/* - * NSS Interrupt Causes - */ -#define NSS_INTR_CAUSE_INVALID 0 -#define NSS_INTR_CAUSE_QUEUE 1 -#define NSS_INTR_CAUSE_NON_QUEUE 2 -#define NSS_INTR_CAUSE_EMERGENCY 3 -#define NSS_INTR_CAUSE_SDMA 4 - -/* - * NSS Core Status - */ -#define NSS_CORE_STATUS_SUCCESS 0 -#define NSS_CORE_STATUS_FAILURE 1 -#define NSS_CORE_STATUS_FAILURE_QUEUE 2 - -/* - * NSS context magic - */ -#define NSS_CTX_MAGIC 0xDEDEDEDE - -/* - * Number of n2h descriptor rings - */ -#define NSS_N2H_DESC_RING_NUM 15 -#define NSS_H2N_DESC_RING_NUM 16 - -/* - * NSS maximum data queue per core - */ -#define NSS_MAX_DATA_QUEUE 4 - -/* - * NSS maximum IRQ per interrupt instance/core - */ -#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) -#define NSS_MAX_IRQ_PER_CORE 8 -#else -#define NSS_MAX_IRQ_PER_INSTANCE 1 -#define NSS_MAX_IRQ_PER_CORE 2 -#endif - -/* - * NSS maximum clients - */ -#define NSS_MAX_CLIENTS 12 - -/* - * Maximum number of service code NSS supports - */ -#define NSS_MAX_SERVICE_CODE 256 - -/* - * Interrupt cause processing weights - */ -#define NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT 64 -#define NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT 64 -#define NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT 64 -#define NSS_TX_UNBLOCKED_PROCESSING_WEIGHT 1 - -/* - * Cache line size of the NSS. - */ -#define NSS_CACHE_LINE_SIZE 32 - -/* - * Statistics struct - * - * INFO: These numbers are based on previous generation chip - * These may change in future - */ - -/* - * NSS Frequency Defines and Values - * - * 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_NA 0x0 /* Instructions Per ms Min */ - -#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 */ - -#define NSS_FREQ_187 187200000 /* Frequency in hz */ -#if defined(NSS_HAL_IPQ60XX_SUPPORT) -#define NSS_FREQ_187_MIN 0x03000 /* Instructions Per ms Min */ -#define NSS_FREQ_187_MAX 0x10000 /* Instructions Per ms Max */ -#else -#define NSS_FREQ_187_MIN 0x03000 /* Instructions Per ms Min */ -#define NSS_FREQ_187_MAX 0x07000 /* Instructions Per ms Max */ -#endif - -#define NSS_FREQ_275 275000000 /* Frequency in hz */ -#define NSS_FREQ_275_MIN 0x03000 /* Instructions Per ms Min */ -#define NSS_FREQ_275_MAX 0x07000 /* Instructions Per ms Max */ - -#define NSS_FREQ_550 550000000 /* Frequency in hz */ -#define NSS_FREQ_550_MIN 0x07000 /* Instructions Per ms Min */ -#define NSS_FREQ_550_MAX 0x08000 /* Instructions Per ms Max */ - -#define NSS_FREQ_600 600000000 /* Frequency in hz */ -#define NSS_FREQ_600_MIN 0x07000 /* Instructions Per ms Min */ -#define NSS_FREQ_600_MAX 0x08000 /* Instructions Per ms Max */ - -#define NSS_FREQ_733 733000000 /* Frequency in hz */ -#define NSS_FREQ_733_MIN 0x07000 /* Instructions Per ms Min */ -#define NSS_FREQ_733_MAX 0x25000 /* Instructions Per ms Max */ - -#define NSS_FREQ_748 748800000 /* Frequency in hz */ -#if defined(NSS_HAL_IPQ60XX_SUPPORT) -#define NSS_FREQ_748_MIN 0x10000 /* Instructions Per ms Min */ -#define NSS_FREQ_748_MAX 0x18000 /* Instructions Per ms Max */ -#else -#define NSS_FREQ_748_MIN 0x07000 /* Instructions Per ms Min */ -#define NSS_FREQ_748_MAX 0x14000 /* Instructions Per ms Max */ -#endif - -#define NSS_FREQ_800 800000000 /* Frequency in hz */ -#define NSS_FREQ_800_MIN 0x07000 /* Instructions Per ms Min */ -#define NSS_FREQ_800_MAX 0x25000 /* Instructions Per ms Max */ - -#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 */ -#define NSS_FREQ_1497_MAX 0x25000 /* Instructions Per ms Max */ -#else -#define NSS_FREQ_1497_MIN 0x14000 /* Instructions Per ms Min */ -#define NSS_FREQ_1497_MAX 0x25000 /* Instructions Per ms Max */ -#endif - -#define NSS_FREQ_1689 1689600000 /* Frequency in hz */ -#define NSS_FREQ_1689_MIN 0x14000 /* Instructions Per ms Min */ -#define NSS_FREQ_1689_MAX 0x25000 /* Instructions Per ms Max */ - -#if (NSS_DT_SUPPORT == 1) -#define NSSTCM_FREQ 400000000 /* NSS TCM Frequency in Hz */ - -/* - * NSS Clock names - */ -#define NSS_CORE_CLK "nss-core-clk" -#define NSS_TCM_SRC_CLK "nss-tcm-src" -#define NSS_TCM_CLK "nss-tcm-clk" -#define NSS_FABRIC0_CLK "nss-fab0-clk" -#define NSS_FABRIC1_CLK "nss-fab1-clk" - -/* - * NSS Fabric speeds - */ -#define NSS_FABRIC0_TURBO 533000000 -#define NSS_FABRIC1_TURBO 266500000 -#define NSS_FABRIC0_NOMINAL 400000000 -#define NSS_FABRIC1_NOMINAL 200000000 -#define NSS_FABRIC0_IDLE 133333000 -#define NSS_FABRIC1_IDLE 133333000 -#endif - -/* Default NSS packet queue limit. */ -#define NSS_DEFAULT_QUEUE_LIMIT 256 - -/* - * Gives us important data from NSS platform data - */ -extern struct nss_top_instance nss_top_main; - -/* - * NSS core state - */ -enum nss_core_state { - NSS_CORE_STATE_UNINITIALIZED = 0, - NSS_CORE_STATE_INITIALIZED, - /* - * in following cases, only interrupts work - */ - NSS_CORE_STATE_FW_DEAD = 2, - NSS_CORE_STATE_FW_DUMP = 4, - NSS_CORE_STATE_PANIC = 8, -}; - -/* - * Forward declarations - */ -struct nss_top_instance; -struct nss_ctx_instance; -struct int_ctx_instance; -struct net_dev_priv_instance; - -/* - * Network device private data instance - */ -struct netdev_priv_instance { - struct int_ctx_instance *int_ctx; /* Back pointer to interrupt context */ -}; - -/* - * Interrupt context instance (one per queue per NSS core) - */ -struct int_ctx_instance { - struct nss_ctx_instance *nss_ctx; - /* Back pointer to NSS context of core that - owns this interrupt */ - uint32_t irq; /* HLOS IRQ numbers bind to this instance */ - uint32_t shift_factor; /* Shift factor for this IRQ queue */ - uint32_t cause; /* Interrupt cause carried forward to BH */ - struct napi_struct napi;/* NAPI handler */ -}; - -/* - * N2H descriptor ring information - */ -struct hlos_n2h_desc_ring { - struct n2h_desc_if_instance desc_ring; - /* Descriptor ring */ - uint32_t hlos_index; /* Current HLOS index for this ring */ - struct sk_buff *head; /* First segment of an skb fraglist */ - struct sk_buff *tail; /* Last segment received of an skb fraglist */ - struct sk_buff *jumbo_start; /* First segment of an skb with frags[] */ -}; - -/* - * H2N descriptor ring information - */ -struct hlos_h2n_desc_rings { - struct h2n_desc_if_instance desc_ring; /* Descriptor ring */ - uint32_t hlos_index; - spinlock_t lock; /* Lock to save from simultaneous access */ - uint32_t flags; /* Flags */ - uint64_t tx_q_full_cnt; /* Descriptor queue full count */ -}; - -#define NSS_H2N_DESC_RING_FLAGS_TX_STOPPED 0x1 /* Tx has been stopped for this queue */ - -/* - * struct nss_shaper_bounce_registrant - * Registrant detail for shaper bounce operations - */ -struct nss_shaper_bounce_registrant { - nss_shaper_bounced_callback_t bounced_callback; /* Invoked for each shaper bounced packet returned from the NSS */ - void *app_data; /* Argument given to the callback */ - struct module *owner; /* Owning module of the callback + arg */ - bool registered; - volatile bool callback_active; /* true when the bounce callback is being called */ -}; - -/* - * CB function declarations - */ -typedef void (*nss_core_rx_callback_t)(struct nss_ctx_instance *, struct nss_cmn_msg *, void *); - -/* - * NSS Rx per interface callback structure - */ -struct nss_rx_cb_list { - nss_if_rx_msg_callback_t msg_cb; - nss_core_rx_callback_t cb; - void *app_data; -}; - -/* - * NSS core <-> subsystem data plane registration related paramaters. - * This struct is filled with if_register/data_plane register APIs and - * retrieved when handling a data packet/skb destined to that subsystem. - */ -struct nss_subsystem_dataplane_register { - nss_phys_if_rx_callback_t cb; /* callback to be invoked */ - nss_phys_if_xmit_callback_t xmit_cb; - /* Callback to be invoked for sending the packets to the transmit path */ - nss_phys_if_rx_ext_data_callback_t ext_cb; - /* Extended data plane callback to be invoked. - This is needed if driver needs extended handling - of data packet before giving to stack */ - void *app_data; /* additional info passed during callback(for future use) */ - struct net_device *ndev; /* Netdevice associated with the interface */ - uint32_t features; /* skb types supported by this subsystem */ - uint32_t type; /* Indicates the type of this data plane */ -}; - -/* - * Holds statistics for every worker thread on a core - */ -struct nss_worker_thread_stats { - struct nss_project_irq_stats *irq_stats; -}; - -/* - * NSS context instance (one per NSS core) - */ -struct nss_ctx_instance { - struct nss_top_instance *nss_top; - /* Back pointer to NSS Top */ - struct device *dev; /* Pointer to the original device from probe */ - struct net_device napi_ndev; /* Dummy_netdev for NAPI */ - uint32_t id; /* Core ID for this instance */ - void __iomem *nmap; /* Pointer to NSS CSM registers */ - void __iomem *vmap; /* Virt mem pointer to virtual register map */ - void __iomem *qgic_map; /* Virt mem pointer to QGIC register */ - uint32_t nphys; /* Phys mem pointer to CSM register map */ - uint32_t vphys; /* Phys mem pointer to virtual register map */ - uint32_t qgic_phys; /* Phys mem pointer to QGIC register map */ - uint32_t load; /* Load address for this core */ - struct nss_meminfo_ctx meminfo_ctx; /* Meminfo context */ - enum nss_core_state state; /* State of NSS core */ - uint32_t c2c_start; /* C2C start address */ - uint32_t num_irq; /* IRQ numbers per queue */ - struct int_ctx_instance int_ctx[NSS_MAX_IRQ_PER_CORE]; - /* Interrupt context instances for each queue */ - struct hlos_h2n_desc_rings h2n_desc_rings[NSS_H2N_DESC_RING_NUM]; - /* Host to NSS descriptor rings */ - struct hlos_n2h_desc_ring n2h_desc_ring[NSS_N2H_DESC_RING_NUM]; - /* NSS to Host descriptor rings */ - uint16_t rps_en; /* N2H Enable Multiple queues for Data Packets */ - uint16_t n2h_mitigate_en; /* N2H mitigation */ - uint32_t max_buf_size; /* Maximum buffer size */ - uint32_t buf_sz_allocated; /* size of bufs allocated from host */ - nss_cmn_queue_decongestion_callback_t queue_decongestion_callback[NSS_MAX_CLIENTS]; - /* Queue decongestion callbacks */ - void *queue_decongestion_ctx[NSS_MAX_CLIENTS]; - /* Queue decongestion callback contexts */ - nss_cmn_service_code_callback_t service_code_callback[NSS_MAX_SERVICE_CODE]; - /* Service code callbacks */ - void *service_code_ctx[NSS_MAX_SERVICE_CODE]; - /* Service code callback contexts */ - 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 */ - uint32_t worker_thread_count; /* Number of NSS core worker threads for statistics */ - uint32_t irq_count; /* Number of NSS core IRQs for statistics */ - struct nss_worker_thread_stats *wt_stats; - /* 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]; - /* NSS interface callback handlers */ - struct nss_subsystem_dataplane_register subsys_dp_register[NSS_MAX_NET_INTERFACES]; - /* Subsystem registration data */ - uint32_t magic; - /* Magic protection */ -}; - -/* - * Main NSS context structure (singleton) - */ -struct nss_top_instance { - uint8_t num_nss; /* Number of NSS cores supported */ - uint8_t num_phys_ports; /* Number of physical ports supported */ - uint32_t clk_src; /* Clock source: default/alternate */ - spinlock_t lock; /* Big lock for NSS driver */ - spinlock_t stats_lock; /* Statistics lock */ - struct mutex wq_lock; /* Mutex for NSS Work queue function */ - struct dentry *top_dentry; /* Top dentry for nss */ - struct dentry *stats_dentry; /* Top dentry for nss stats */ - struct dentry *strings_dentry; /* Top dentry for nss stats strings */ - struct dentry *project_dentry; /* per-project stats dentry */ - struct nss_ctx_instance nss[NSS_MAX_CORES]; - /* NSS contexts */ - /* - * Network processing handler core ids (CORE0/CORE1) for various interfaces - */ - uint8_t phys_if_handler_id[NSS_MAX_PHYSICAL_INTERFACES]; - uint8_t virt_if_handler_id; - uint8_t gre_redir_handler_id; - uint8_t gre_redir_lag_us_handler_id; - uint8_t gre_redir_lag_ds_handler_id; - uint8_t gre_tunnel_handler_id; - uint8_t shaping_handler_id; - uint8_t ipv4_handler_id; - uint8_t ipv4_reasm_handler_id; - uint8_t ipv6_handler_id; - uint8_t ipv6_reasm_handler_id; - uint8_t crypto_handler_id; - uint8_t ipsec_handler_id; - uint8_t wlan_handler_id; - uint8_t tun6rd_handler_id; - uint8_t wifi_handler_id; - uint8_t ppe_handler_id; - uint8_t pptp_handler_id; - uint8_t pppoe_handler_id; - uint8_t l2tpv2_handler_id; - uint8_t dtls_handler_id; - uint8_t gre_handler_id; - uint8_t map_t_handler_id; - uint8_t tunipip6_handler_id; - uint8_t frequency_handler_id; - uint8_t sjack_handler_id; - uint8_t capwap_handler_id; - uint8_t tstamp_handler_id; - uint8_t portid_handler_id; - uint8_t oam_handler_id; - uint8_t edma_handler_id; - uint8_t bridge_handler_id; - uint8_t trustsec_tx_handler_id; - uint8_t vlan_handler_id; - uint8_t qvpn_handler_id; - uint8_t pvxlan_handler_id; - uint8_t igs_handler_id; - uint8_t gre_redir_mark_handler_id; - uint8_t clmap_handler_id; - uint8_t vxlan_handler_id; - uint8_t rmnet_rx_handler_id; - uint8_t match_handler_id; - uint8_t tls_handler_id; - uint8_t mirror_handler_id; - uint8_t wmdb_handler_id; - uint8_t dma_handler_id; - uint8_t udp_st_handler_id; - - /* - * Data/Message callbacks for various interfaces - */ - 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]; - /* Virtual interface messsage callback functions */ - nss_ipv4_msg_callback_t ipv4_callback; - /* IPv4 sync/establish callback function */ - nss_ipv6_msg_callback_t ipv6_callback; - /* IPv6 sync/establish callback function */ - nss_ipsec_msg_callback_t ipsec_encap_callback; - nss_ipsec_msg_callback_t ipsec_decap_callback; - /* IPsec event callback function */ - nss_crypto_msg_callback_t crypto_msg_callback; - nss_crypto_cmn_msg_callback_t crypto_cmn_msg_callback; - nss_crypto_buf_callback_t crypto_buf_callback; - nss_crypto_pm_event_callback_t crypto_pm_callback; - /* crypto interface callback functions */ - nss_profiler_callback_t profiler_callback[NSS_MAX_CORES]; - /* Profiler interface callback function */ - nss_tun6rd_msg_callback_t tun6rd_msg_callback; - /* 6rd tunnel interface event callback function */ - nss_wifi_msg_callback_t wifi_msg_callback; - /* wifi interface event callback function */ - nss_l2tpv2_msg_callback_t l2tpv2_msg_callback; - /* l2tP tunnel interface event callback function */ - nss_dtls_msg_callback_t dtls_msg_callback; /* dtls interface event callback */ - - nss_gre_tunnel_msg_callback_t gre_tunnel_msg_callback; /* gre tunnel interface event callback */ - - nss_map_t_msg_callback_t map_t_msg_callback; - /* map-t interface event callback function */ - nss_gre_msg_callback_t gre_msg_callback; - /* gre interface event callback function */ - nss_gre_data_callback_t gre_inner_data_callback; - /* gre inner data callback function */ - nss_gre_data_callback_t gre_outer_data_callback; - /* gre outer data callback function */ - nss_tunipip6_msg_callback_t tunipip6_msg_callback; - /* ipip6 tunnel interface event callback function */ - nss_pptp_msg_callback_t pptp_msg_callback; - /* PPTP tunnel interface event callback function */ - nss_pppoe_msg_callback_t pppoe_msg_callback; - /* PPPoE interface event callback function */ - struct nss_shaper_bounce_registrant bounce_interface_registrants[NSS_MAX_NET_INTERFACES]; - /* Registrants for interface shaper bounce operations */ - struct nss_shaper_bounce_registrant bounce_bridge_registrants[NSS_MAX_NET_INTERFACES]; - /* Registrants for bridge shaper bounce operations */ - nss_lag_event_callback_t lag_event_callback; - /* Registrants for lag operations */ - nss_oam_msg_callback_t oam_callback; - /* OAM call back */ - nss_edma_msg_callback_t edma_callback; - /* EDMA callback */ - nss_bridge_msg_callback_t bridge_callback; - /* Bridge callback */ - nss_vlan_msg_callback_t vlan_callback; - /* Vlan callback */ - nss_wifili_msg_callback_t wifili_msg_callback; - /* wifili interface event callback function */ - nss_ipsec_cmn_msg_callback_t ipsec_cmn_msg_callback; - /* IPSEC common interface event callback function */ - nss_qvpn_msg_callback_t qvpn_msg_callback; - /* QVPN interface event callback function */ - nss_rmnet_rx_msg_callback_t rmnet_rx_msg_callback[NSS_MAX_VIRTUAL_INTERFACES]; - /* Virtual interface messsage callback functions */ - nss_wifi_mac_db_msg_callback_t wifi_mac_db_msg_callback; - /* wifi mac database event callback function */ - - uint32_t dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_MAX]; - - /* - * Interface contexts (non network device) - */ - void *ipv4_ctx; /* IPv4 connection manager context */ - void *ipv6_ctx; /* IPv6 connection manager context */ - void *crypto_ctx; /* Crypto interface context */ - void *crypto_pm_ctx; /* Crypto PM context */ - void *profiler_ctx[NSS_MAX_CORES]; - /* Profiler interface context */ - void *ipsec_encap_ctx; /* IPsec encap context */ - void *ipsec_decap_ctx; /* IPsec decap context */ - void *oam_ctx; /* oam context */ - void *edma_ctx; /* edma context */ - void *bridge_ctx; /* Bridge context */ - void *vlan_ctx; /* Vlan context */ - - /* - * Statistics for various interfaces - */ - atomic64_t stats_drv[NSS_DRV_STATS_MAX]; - /* Hlos driver statistics */ - uint64_t stats_gmac[NSS_MAX_PHYSICAL_INTERFACES][NSS_GMAC_STATS_MAX]; - /* GMAC statistics */ - uint64_t stats_node[NSS_MAX_NET_INTERFACES][NSS_STATS_NODE_MAX]; - /* IPv4 statistics per interface */ - bool nss_hal_common_init_done; - - uint16_t prev_mtu_sz; /* mtu sz needed as of now */ - uint16_t crypto_enabled; /* check if crypto is enabled on the platform */ - - /* - * TODO: Review and update following fields - */ - 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 */ - struct nss_data_plane_ops *data_plane_ops; - /* nss_data_plane ops for this target platform */ -}; - -#if (NSS_PKT_STATS_ENABLED == 1) -/* - * nss_pkt_stats_inc() - */ -static inline void nss_pkt_stats_inc(atomic64_t *stat) -{ - atomic64_inc(stat); -} - -/* - * nss_pkt_stats_dec() - */ -static inline void nss_pkt_stats_dec(atomic64_t *stat) -{ - atomic64_dec(stat); -} - -/* - * nss_pkt_stats_add() - */ -static inline void nss_pkt_stats_add(atomic64_t *stat, uint32_t pkt) -{ - atomic64_add(pkt, stat); -} - -/* - * nss_pkt_stats_sub() - */ -static inline void nss_pkt_stats_sub(atomic64_t *stat, uint32_t pkt) -{ - atomic64_sub(pkt, stat); -} - -/* - * nss_pkt_stats_read() - */ -static inline uint64_t nss_pkt_stats_read(atomic64_t *stat) -{ - return atomic64_read(stat); -} - -#endif - -/* - * NSS Statistics and Data for User Space - */ -struct nss_cmd_buffer { - uint32_t current_freq; /* Current Running Freq of NSS */ - int32_t auto_scale; /* Enable or Disable auto_scale */ - int32_t max_freq; /* Maximum supported frequency index value */ - uint32_t register_addr; /* register addr buffer */ - uint32_t register_data; /* register data buffer */ - uint32_t average_inst; /* average of inst for nss core */ - uint32_t coredump; /* cmd coredump buffer */ -}; -extern struct nss_cmd_buffer nss_cmd_buf; - -/* - * The scales for NSS - */ -typedef enum nss_freq_scales { - NSS_FREQ_LOW_SCALE = 0, - NSS_FREQ_MID_SCALE = 1, - NSS_FREQ_HIGH_SCALE = 2, - NSS_FREQ_MAX_SCALE = 3, -} nss_freq_scales_t; - -/* - * NSS Core Statistics and Frequencies - */ -#define NSS_SAMPLE_BUFFER_SIZE 4 /* Ring Buffer should be a Size of two */ -#define NSS_SAMPLE_BUFFER_MASK (NSS_SAMPLE_BUFFER_SIZE - 1) -#define NSS_FREQUENCY_SCALE_RATE_LIMIT_UP 2 /* Adjust the Rate of Frequency Switching Up */ -#define NSS_FREQUENCY_SCALE_RATE_LIMIT_DOWN 60000 /* Adjust the Rate of Frequency Switching Down */ -#define NSS_MESSAGE_RATE_LIMIT 15000 /* Adjust the Rate of Displaying Statistic Messages */ - -/* - * NSS Frequency Scale Info - * - * INFO: Contains the Scale information per Frequency - * Per Scale information needed to Program PLL and make switching decisions - */ -struct nss_scale_info { - uint32_t frequency; /* Frequency in Mhz */ - uint32_t minimum; /* Minimum INST_CNT per Sec */ - uint32_t maximum; /* Maximum INST_CNT per Sec */ -}; - -/* - * NSS Runtime Sample Structure - * - * INFO: Contains the runtime statistic of the NSS core - * Also contains the per frequency scale array - */ -struct nss_runtime_sampling { - struct nss_scale_info freq_scale[NSS_FREQ_MAX_SCALE]; /* NSS Max Scale Per Freq */ - nss_freq_scales_t freq_scale_index; /* Current Freq Index */ - uint32_t freq_scale_ready; /* Allow Freq Scaling */ - uint32_t freq_scale_rate_limit_up; /* Scaling Change Rate Limit */ - uint32_t freq_scale_rate_limit_down; /* Scaling Change Rate Limit */ - uint32_t buffer[NSS_SAMPLE_BUFFER_SIZE]; /* Sample Ring Buffer */ - uint32_t buffer_index; /* Running Buffer Index */ - uint32_t sum; /* Total INST_CNT SUM */ - uint32_t sample_count; /* Number of Samples stored in Ring Buffer */ - uint32_t average; /* Average of INST_CNT */ - uint32_t message_rate_limit; /* Debug Message Rate Limit */ - uint32_t initialized; /* Flag to check for adequate initial samples */ -}; - -/* - * cpu_utilization - */ -struct nss_freq_cpu_usage { - uint32_t used; /* CPU utilization at a certain frequency percentage */ - uint32_t max_ins; /* Maximum instructions that can be executed in 1ms at the current frequency - This value is calculated by diving frequency by 1000. */ - uint32_t total; /* Total usage added over a time of NSS_FREQ_USG_AVG_FREQUENCY milliseconds*/ - uint32_t max; /* Maximum CPU usage since the boot (%) */ - uint32_t min; /* Minimum CPU usage since the boot (%) */ - uint32_t avg_up; /* Actual upper bound of the CPU USAGE (%)*/ - uint16_t avg_ctr; /* Averaging counter */ -}; - -#if (NSS_DT_SUPPORT == 1) -/* - * nss_feature_enabled - */ -enum nss_feature_enabled { - NSS_FEATURE_NOT_ENABLED = 0, /* Feature is not enabled on this core */ - NSS_FEATURE_ENABLED, /* Feature is enabled on this core */ -}; - -/* - * nss_platform_data - * Platform data per core - */ -struct nss_platform_data { - uint32_t id; /* NSS core ID */ - uint32_t num_queue; /* No. of queues supported per core */ - uint32_t num_irq; /* No. of irq binded per queue */ - uint32_t irq[NSS_MAX_IRQ_PER_CORE]; /* IRQ numbers per queue */ - void __iomem *nmap; /* Virtual addr of NSS CSM space */ - void __iomem *vmap; /* Virtual addr of NSS virtual register map */ - void __iomem *qgic_map; /* Virtual addr of QGIC interrupt register */ - uint32_t nphys; /* Physical addr of NSS CSM space */ - uint32_t vphys; /* Physical addr of NSS virtual register map */ - uint32_t qgic_phys; /* Physical addr of QGIC virtual register map */ - uint32_t load_addr; /* Load address of NSS firmware */ - - enum nss_feature_enabled capwap_enabled; - /* Does this core handle capwap? */ - enum nss_feature_enabled crypto_enabled; - /* Does this core handle crypto? */ - enum nss_feature_enabled dtls_enabled; - /* Does this core handle DTLS sessions ? */ - enum nss_feature_enabled gre_redir_enabled; - /* Does this core handle gre_redir Tunnel ? */ - enum nss_feature_enabled gre_tunnel_enabled; - /* Does this core handle gre_tunnel Tunnel ? */ - enum nss_feature_enabled ipsec_enabled; - /* Does this core handle IPsec? */ - enum nss_feature_enabled ipv4_enabled; - /* Does this core handle IPv4? */ - enum nss_feature_enabled ipv4_reasm_enabled; - /* Does this core handle IPv4 reassembly? */ - enum nss_feature_enabled ipv6_enabled; - /* Does this core handle IPv6? */ - enum nss_feature_enabled ipv6_reasm_enabled; - /* Does this core handle IPv6 reassembly? */ - enum nss_feature_enabled l2tpv2_enabled; - /* Does this core handle l2tpv2 Tunnel ? */ - enum nss_feature_enabled map_t_enabled; - /* Does this core handle map-t */ - enum nss_feature_enabled gre_enabled; - /* Does this core handle GRE */ - enum nss_feature_enabled oam_enabled; - /* Does this core handle oam? */ - enum nss_feature_enabled ppe_enabled; - /* Does this core handle ppe ? */ - enum nss_feature_enabled pppoe_enabled; - /* Does this core handle pppoe? */ - enum nss_feature_enabled pptp_enabled; - /* Does this core handle pptp Tunnel ? */ - enum nss_feature_enabled portid_enabled; - /* Does this core handle portid? */ - enum nss_feature_enabled shaping_enabled; - /* Does this core handle shaping ? */ - enum nss_feature_enabled tstamp_enabled; - /* Does this core handle timestamping? */ - enum nss_feature_enabled turbo_frequency; - /* Does this core support turbo frequencies */ - enum nss_feature_enabled tun6rd_enabled; - /* Does this core handle 6rd Tunnel ? */ - enum nss_feature_enabled tunipip6_enabled; - /* Does this core handle ipip6 Tunnel ? */ - enum nss_feature_enabled wlanredirect_enabled; - /* Does this core handle WLAN redirect? */ - enum nss_feature_enabled wifioffload_enabled; - /* Does this core handle WIFI OFFLOAD? */ - enum nss_feature_enabled bridge_enabled; - /* Does this core handle bridge configuration */ - enum nss_feature_enabled vlan_enabled; - /* Does this core handle vlan configuration */ - enum nss_feature_enabled qvpn_enabled; - /* Does this core handle QVPN Tunnel ? */ - enum nss_feature_enabled pvxlan_enabled; - /* Does this core handle pvxlan? */ - enum nss_feature_enabled igs_enabled; - /* Does this core handle igs? */ - enum nss_feature_enabled gre_redir_mark_enabled; - /* Does this core handle GRE redir mark? */ - enum nss_feature_enabled clmap_enabled; - /* Does this core handle clmap? */ - enum nss_feature_enabled vxlan_enabled; - /* Does this core handle vxlan tunnel? */ - enum nss_feature_enabled rmnet_rx_enabled; - /* Does this core handle rmnet rx? */ - enum nss_feature_enabled match_enabled; - /* Does this core handle match node? */ - enum nss_feature_enabled tls_enabled; - /* 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? */ -}; -#endif - -/* - * nss_core_log_msg_failures() - * Driver function for logging failed messages. - */ -static inline void nss_core_log_msg_failures(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm) -{ - if ((ncm->response == NSS_CMN_RESPONSE_ACK) || (ncm->response == NSS_CMN_RESPONSE_NOTIFY)) { - return; - } - - /* - * TODO: Is it worth doing value to name on these values? - */ - nss_warning("%px: msg failure - interface: %d, type: %d, response: %d, error: %d", - nss_ctx, ncm->interface, ncm->type, ncm->response, ncm->error); -} - -/* - * NSS workqueue to change frequencies - */ -typedef struct { - struct work_struct my_work; /* Work Structure */ - uint32_t frequency; /* Frequency To Change */ - uint32_t stats_enable; /* Auto scale on/off */ -} nss_work_t; - -/* - * APIs provided by nss_core.c - */ -extern int nss_core_handle_napi(struct napi_struct *napi, int budget); -extern int nss_core_handle_napi_queue(struct napi_struct *napi, int budget); -extern int nss_core_handle_napi_non_queue(struct napi_struct *napi, int budget); -extern int nss_core_handle_napi_emergency(struct napi_struct *napi, int budget); -extern int nss_core_handle_napi_sdma(struct napi_struct *napi, int budget); -extern int32_t nss_core_send_buffer(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - struct sk_buff *nbuf, uint16_t qid, - uint8_t buffer_type, uint16_t flags); -extern int32_t nss_core_send_cmd(struct nss_ctx_instance *nss_ctx, void *msg, int size, int buf_size); -extern int32_t nss_core_send_packet(struct nss_ctx_instance *nss_ctx, struct sk_buff *nbuf, uint32_t if_num, uint32_t flag); -extern uint32_t nss_core_ddr_info(struct nss_mmu_ddr_info *coreinfo); -extern uint32_t nss_core_register_msg_handler(struct nss_ctx_instance *nss_ctx, uint32_t interface, nss_if_rx_msg_callback_t msg_cb); -extern uint32_t nss_core_unregister_msg_handler(struct nss_ctx_instance *nss_ctx, uint32_t interface); -extern uint32_t nss_core_register_handler(struct nss_ctx_instance *nss_ctx, uint32_t interface, nss_core_rx_callback_t cb, void *app_data); -extern uint32_t nss_core_unregister_handler(struct nss_ctx_instance *nss_ctx, uint32_t interface); -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); -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, - void *app_data, struct net_device *ndev, - 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); - -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; -} - -static inline uint32_t nss_core_get_max_buf_size(struct nss_ctx_instance *nss_ctx) -{ - return nss_ctx->max_buf_size; -} - -/* - * APIs provided by nss_tx_rx.c - */ -extern void nss_rx_handle_status_pkt(struct nss_ctx_instance *nss_ctx, struct sk_buff *nbuf); - -/* - * APIs provided by nss_stats.c - */ -extern void nss_stats_init(void); -extern void nss_stats_clean(void); - -/* - * APIs provided by nss_log.c - */ -extern void nss_log_init(void); -extern bool nss_debug_log_buffer_alloc(uint8_t nss_id, uint32_t nentry); -extern int nss_logbuffer_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos); - -/* - * APIs to set jumbo_mru & paged_mode - */ -extern void nss_core_set_jumbo_mru(int jumbo_mru); -extern int nss_core_get_jumbo_mru(void); -extern void nss_core_set_paged_mode(int mode); -extern int nss_core_get_paged_mode(void); -#if (NSS_SKB_REUSE_SUPPORT == 1) -extern void nss_core_set_max_reuse(int max); -extern int nss_core_get_max_reuse(void); -extern uint32_t nss_core_get_min_reuse(struct nss_ctx_instance *nss_ctx); -#endif - -/* - * APIs for coredump - */ -extern void nss_coredump_notify_register(void); -extern void nss_fw_coredump_notify(struct nss_ctx_instance *nss_own, int intr); -extern int nss_coredump_init_delay_work(void); - -/* - * APIs provided by nss_freq.c - */ -extern bool nss_freq_sched_change(nss_freq_scales_t index, bool auto_scale); - -/* - * nss_freq_init_cpu_usage - * Initializes the cpu usage computation. - */ -extern void nss_freq_init_cpu_usage(void); - -/* - * APIs for PPE - */ -extern void nss_ppe_init(void); -extern void nss_ppe_free(void); - -/* - * APIs for N2H - */ -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); - -#endif /* __NSS_CORE_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_coredump.c b/feeds/ipq807x/qca-nss-drv/src/nss_coredump.c deleted file mode 100644 index 691a9a712..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_coredump.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - ************************************************************************** - * 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_core.c - * NSS driver core APIs source file. - */ - -#include "nss_core.h" -#include "nss_hal.h" -#include "nss_log.h" -#include -#include /* for panic_notifier_list */ -#include /* for time */ -#include "nss_tx_rx_common.h" - -#if NSS_MAX_CORES > 2 /* see comment in nss_fw_coredump_notify */ -#error too many NSS Cores: should be 1 or 2 -#endif - -static struct delayed_work coredump_queuewait; -static struct workqueue_struct *coredump_workqueue; - -/* - * nss_coredump_wait() - * reboot (panic) if all finished coredump interrupts will not come. - * N2H (C2C) interrupt may get lost during trap, as well NSS may start - * only one core; so timeout if less than desird core sends back finished - * coredump interrupt. - */ -static void nss_coredump_wait(struct work_struct *work) -{ - panic("did not get all coredump finished signals\n"); -} - -/* - * nss_coredump_init_delay_work() - * set a wait function in case coredump finish interrupt lost or - * only one NSS core is up. - */ -int nss_coredump_init_delay_work(void) -{ - coredump_workqueue = create_singlethread_workqueue("coredump_wait"); - if (!coredump_workqueue) { - nss_warning("can't set wait: hopefully all int will come\n"); - return -ENOMEM; - } - - INIT_DELAYED_WORK(&coredump_queuewait, nss_coredump_wait); - return 0; -} - -/* - * nss_panic_handler() - * notification callback register to panic chain - */ -static int nss_panic_handler(struct notifier_block *nb, - unsigned long action, void *data) -{ - int dumped, timed; - int i; - - for (i = 0; i < nss_top_main.num_nss; i++) { - struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[i]; - if (nss_ctx->state & NSS_CORE_STATE_FW_DEAD || !nss_ctx->nmap) - 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 %px to dump %x\n", - nss_ctx->nmap, nss_ctx->state); - } - - /* - * wait for FW coredump done: maximum 2 rounds for each core - * 200ms per round -- 16MB * 10 over 200MHz 32-bit memory bus - * panic will take another 3-5 seconds to reboot, so longer enough. - */ - dumped = timed = 0; - do { - mdelay(200); - for (i = 0; i < nss_top_main.num_nss; i++) { - struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[i]; - if ((nss_ctx->state & NSS_CORE_STATE_FW_DEAD || - !nss_ctx->nmap) && - !(nss_ctx->state & NSS_CORE_STATE_FW_DUMP)) { - nss_ctx->state |= NSS_CORE_STATE_FW_DUMP; - dumped++; - } - } - if (dumped >= nss_top_main.num_nss) { - nss_warning("NSS FW dump completed\n"); - break; - } - } while (timed++ < nss_top_main.num_nss * 2); - - if (timed >= nss_top_main.num_nss * 2) - nss_warning("might get %d FW dumped", dumped); - - return NOTIFY_DONE; -} - -static struct notifier_block nss_panic_nb = { - .notifier_call = nss_panic_handler, -}; - -/* - * nss_coredump_notify_register() - * API for nss_init to register coredump notifier to panic chain - */ -void nss_coredump_notify_register(void) -{ - atomic_notifier_chain_register(&panic_notifier_list, &nss_panic_nb); -} - -/* - * nss_fw_coredump_notify() - * handler for coredump notification from NSS FW - */ -void nss_fw_coredump_notify(struct nss_ctx_instance *nss_own, - int intr __attribute__ ((unused))) -{ - int i, j, curr_index, useful_entries, num_cores_wait; - struct nss_log_descriptor *nld; - struct nss_log_entry *nle_init, *nle_print; - dma_addr_t dma_addr; - uint32_t offset, index; - - 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, - msecs_to_jiffies(3456)); - - /* - * If external log buffer is not set, use the nss initial log buffer. - */ - nld = (struct nss_log_descriptor *)(nss_rbe[nss_own->id].addr); - dma_addr = nss_rbe[nss_own->id].dma_addr; - if (!nld) { - nld = nss_own->meminfo_ctx.logbuffer; - dma_addr = nss_own->meminfo_ctx.logbuffer_dma; - } - - dma_sync_single_for_cpu(NULL, 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("%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) { - curr_index = 0; - useful_entries = nld->current_entry; - } else { - curr_index = ((nld->current_entry - NSS_LOG_COREDUMP_LINE_NUM) % nld->log_nentries); - useful_entries = NSS_LOG_COREDUMP_LINE_NUM; - } - - nle_print = nle_init + curr_index; - for (j = index = curr_index; j < (curr_index + useful_entries); j++, index++) { - if (j == nld->log_nentries) { - nle_print = nle_init; - index = 0; - } - - offset = (index * sizeof(struct nss_log_entry)) - + offsetof(struct nss_log_descriptor, log_ring_buffer); - dma_sync_single_for_cpu(NULL, dma_addr + offset, - sizeof(struct nss_log_entry), DMA_FROM_DEVICE); - nss_info_always("%px: %s\n", nss_own, nle_print->message); - nle_print++; - } - - if (nss_own->state & NSS_CORE_STATE_PANIC) - return; - - /* - * We need to wait until all other cores finish their dump. - */ - num_cores_wait = (nss_top_main.num_nss - 1); - if (!num_cores_wait) { - /* - * nss_cmd_buf.coredump values: - * 0 == normal coredump and panic - * non-zero value is for debug purpose: - * 1 == force coredump and panic - * otherwise coredump but do not panic. - */ - if (!(nss_cmd_buf.coredump & 0xFFFFFFFE)) { - panic("NSS FW coredump: bringing system down\n"); - } - nss_info_always("NSS core dump completed & use mdump to collect dump to debug\n"); - return; - } - - for (i = 0; i < nss_top_main.num_nss; i++) { - struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[i]; - - /* - * Skip waiting for ourselves to coredump, we already have. - */ - if (nss_ctx == nss_own) { - continue; - } - - /* - * Notify any live core to dump. - */ - if (!(nss_ctx->state & NSS_CORE_STATE_FW_DEAD) && 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; - } - - /* - * bit 1 is used for testing coredump. Any other - * bit(s) (value other than 0/1) disable panic - * in order to use mdump utility: see mdump/src/README - * for more info. - */ - if (nss_cmd_buf.coredump & 0xFFFFFFFE) { - nss_info_always("NSS core dump completed and please use mdump to collect dump data\n"); - continue; - } - - /* - * Ideally we need to unregister ourselves from the panic - * notifier list before calling the panic to prevent infinite calling. - * However, When we tried, we couldn't make it work. Therefore, We just leave the corresponding call here - * if it will be needed in the future. - * - * atomic_notifier_chain_unregister(&panic_notifier_list, &nss_panic_nb); - */ - num_cores_wait--; - if (!num_cores_wait) { - panic("NSS FW coredump: bringing system down\n"); - return; - } - - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_crypto.c b/feeds/ipq807x/qca-nss-drv/src/nss_crypto.c deleted file mode 100644 index 96d8c5b2c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_crypto.c +++ /dev/null @@ -1,302 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_crypto.c - * NSS Crypto APIs - */ - -#include "nss_tx_rx_common.h" -#include "nss_crypto.h" -#include "nss_crypto_log.h" - -/* - ********************************** - General APIs - ********************************** - */ - -/* - * nss_crypto_set_msg_callback() - * this sets the message callback handler and its associated context - */ -static inline void nss_crypto_set_msg_callback(struct nss_ctx_instance *nss_ctx, nss_crypto_msg_callback_t cb, void *crypto_ctx) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - nss_top->crypto_ctx = crypto_ctx; - nss_top->crypto_msg_callback = cb; -} - -/* - * nss_crypto_get_msg_callback() - * this gets the message callback handler and its associated context - */ -static inline nss_crypto_msg_callback_t nss_crypto_get_msg_callback(struct nss_ctx_instance *nss_ctx, void **crypto_ctx) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - *crypto_ctx = nss_top->crypto_ctx; - return nss_top->crypto_msg_callback; -} - -/* - * nss_crypto_msg_handler() - * this handles all the IPsec events and responses - */ -static void nss_crypto_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *app_data __attribute((unused))) -{ - struct nss_crypto_msg *nim = (struct nss_crypto_msg *)ncm; - nss_crypto_msg_callback_t cb = NULL; - void *crypto_ctx = NULL; - - /* - * Sanity check the message type - */ - if (ncm->type > NSS_CRYPTO_MSG_TYPE_MAX) { - 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("%px: rx message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - if (ncm->interface != NSS_CRYPTO_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("%px: rx message response for if %d, type %d, is invalid: %d", nss_ctx, ncm->interface, - ncm->type, ncm->response); - return; - } - - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_crypto_get_msg_callback(nss_ctx, &crypto_ctx); - ncm->app_data = (nss_ptr_t)crypto_ctx; - } - - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Trace messages. - */ - nss_crypto_log_rx_msg(nim); - - /* - * Load, Test & call - */ - cb = (nss_crypto_msg_callback_t)ncm->cb; - if (unlikely(!cb)) { - nss_trace("%px: rx handler has been unregistered for i/f: %d", nss_ctx, ncm->interface); - return; - } - cb((void *)ncm->app_data, nim); -} -/* - ********************************** - Tx APIs - ********************************** - */ - -/* - * nss_crypto_tx_msg - * Send crypto config to NSS. - */ -nss_tx_status_t nss_crypto_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_crypto_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - 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("%px: tx message request for another interface: %d", nss_ctx, ncm->interface); - } - - if (ncm->type > NSS_CRYPTO_MSG_TYPE_MAX) { - 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:%px, app_data:%px, len:%d\n", - ncm->version, ncm->interface, ncm->type, (void *)ncm->cb, (void *)ncm->app_data, ncm->len); - - /* - * Trace messages. - */ - nss_crypto_log_tx_msg(msg); - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} - -/* - * nss_crypto_tx_data() - * NSS crypto TX data API. Sends a crypto buffer to NSS. - */ -nss_tx_status_t nss_crypto_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, struct sk_buff *skb) -{ - int32_t status; - - 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("%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("%px: tx_data Unable to enqueue packet", nss_ctx); - if (status == NSS_CORE_STATUS_FAILURE_QUEUE) { - return NSS_TX_FAILURE_QUEUE; - } - - return NSS_TX_FAILURE; - } - - /* - * Kick the NSS awake so it can process our new entry. - */ - nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); - - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_CRYPTO_REQ]); - - return NSS_TX_SUCCESS; -} - -/* - ********************************** - Register APIs - ********************************** - */ - -/* - * nss_crypto_notify_register() - * register message notifier for crypto interface - */ -struct nss_ctx_instance *nss_crypto_notify_register(nss_crypto_msg_callback_t cb, void *app_data) -{ - struct nss_ctx_instance *nss_ctx; - - nss_ctx = &nss_top_main.nss[nss_top_main.crypto_handler_id]; - - nss_crypto_set_msg_callback(nss_ctx, cb, app_data); - - return nss_ctx; -} - -/* - * nss_crypto_notify_unregister() - * unregister message notifier for crypto interface - */ -void nss_crypto_notify_unregister(struct nss_ctx_instance *nss_ctx) -{ - nss_crypto_set_msg_callback(nss_ctx, NULL, NULL); -} - -/* - * nss_crypto_data_register() - * register a data callback routine - */ -struct nss_ctx_instance *nss_crypto_data_register(uint32_t if_num, nss_crypto_buf_callback_t cb, - struct net_device *netdev, uint32_t features) -{ - struct nss_ctx_instance *nss_ctx; - - 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("%px: data register received for invalid interface %d", nss_ctx, if_num); - return NULL; - } - - /* - * Register subsystem, ensuring that no duplicate registrations occur. - */ - nss_core_register_subsys_dp(nss_ctx, if_num, cb, NULL, NULL, netdev, features); - - return nss_ctx; -} - -/* - * nss_crypto_data_unregister() - * unregister a data callback routine - */ -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("%px: data unregister received for invalid interface %d", nss_ctx, if_num); - return; - } - - nss_core_unregister_subsys_dp(nss_ctx, if_num); -} - -/* - * nss_crypto_pm_notify_register() - * register a PM notify callback routine - */ -void nss_crypto_pm_notify_register(nss_crypto_pm_event_callback_t cb, void *app_data) -{ - nss_top_main.crypto_pm_ctx = app_data; - nss_top_main.crypto_pm_callback = cb; -} - -/* - * nss_crypto_pm_notify_unregister() - * unregister a PM notify callback routine - */ -void nss_crypto_pm_notify_unregister(void) -{ - nss_top_main.crypto_pm_ctx = NULL; - nss_top_main.crypto_pm_callback = NULL; -} - -/* - * nss_crypto_register_handler() - */ -void nss_crypto_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[nss_top_main.crypto_handler_id]; - - nss_core_register_handler(nss_ctx, NSS_CRYPTO_INTERFACE, nss_crypto_msg_handler, NULL); -} - -/* - * nss_crypto_msg_init() - * Initialize crypto message - */ -void nss_crypto_msg_init(struct nss_crypto_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, - nss_crypto_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, (void *)cb, app_data); -} - -EXPORT_SYMBOL(nss_crypto_notify_register); -EXPORT_SYMBOL(nss_crypto_notify_unregister); -EXPORT_SYMBOL(nss_crypto_data_register); -EXPORT_SYMBOL(nss_crypto_data_unregister); -EXPORT_SYMBOL(nss_crypto_pm_notify_register); -EXPORT_SYMBOL(nss_crypto_pm_notify_unregister); -EXPORT_SYMBOL(nss_crypto_tx_msg); -EXPORT_SYMBOL(nss_crypto_tx_buf); -EXPORT_SYMBOL(nss_crypto_msg_init); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn.c b/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn.c deleted file mode 100644 index 35c4c8c86..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn.c +++ /dev/null @@ -1,388 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_crypto_cmn.c - * NSS Crypto common API implementation - */ - -#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" - -/* - * Amount time the synchronous message should wait for response from - * NSS before the timeout happens. After the timeout the message - * response even if it arrives has to be discarded. Typically, the - * time needs to be selected based on the worst case time in case of - * peak throughput between host & NSS. - */ -#define NSS_CRYPTO_CMN_TX_TIMEO_TICKS msecs_to_jiffies(3000) /* milliseconds */ - -/* - * Private data structure to hold state for - * the crypto specific NSS interaction - */ -struct nss_crypto_cmn_pvt { - struct semaphore sem; /* used for synchronizing 'tx_msg_sync' */ - struct completion complete; /* completion callback */ - atomic_t seq_no; /* used for tracking tx_msg_sync requests */ -}; - -/* - * This is a single instance applicable for all crypto synchronous - * messaging interaction with NSS. - */ -static struct nss_crypto_cmn_pvt g_nss_crypto_cmn; - -/* - * nss_crypto_cmn_msg_handler() - * this handles all the IPsec events and responses - */ -static void nss_crypto_cmn_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, - void *app_data __attribute((unused))) -{ - struct nss_crypto_cmn_msg *nim = (struct nss_crypto_cmn_msg *)ncm; - nss_crypto_cmn_msg_callback_t cb = NULL; - - /* - * Sanity check the message type - */ - if (ncm->type > NSS_CRYPTO_CMN_MSG_TYPE_MAX) { - nss_warning("%px: rx message type out of range: %d", nss_ctx, ncm->type); - return; - } - - /* - * Check if the message structure length matches that of Host side. In case - * of failure this indicates ether the structure is different or this is not - * the intended interface. - */ - if (nss_cmn_get_msg_len(ncm) > sizeof(*nim)) { - 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("%px: rx message response for if %d, type %d, is invalid: %d", nss_ctx, - ncm->interface, ncm->type, ncm->response); - return; - } - - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->crypto_cmn_msg_callback; - ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->crypto_ctx; - } - - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Trace messages. - */ - nss_crypto_cmn_log_rx_msg(nim); - - 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 - */ - cb = (nss_crypto_cmn_msg_callback_t)ncm->cb; - if (unlikely(!cb)) { - nss_warning("%px: rx handler has been unregistered for i/f: %d", nss_ctx, ncm->interface); - return; - } - - cb((void *)ncm->app_data, nim); -} - -/* - * nss_crypto_cmn_tx_msg - * Send crypto config to NSS. - */ -nss_tx_status_t nss_crypto_cmn_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_crypto_cmn_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - uint16_t msg_len = nss_cmn_get_msg_len(ncm); - - nss_info("%px: tx message %d for if %d", nss_ctx, ncm->type, ncm->interface); - - BUILD_BUG_ON(NSS_NBUF_PAYLOAD_SIZE < sizeof(*msg)); - - if (ncm->type > NSS_CRYPTO_CMN_MSG_TYPE_MAX) { - nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - /* - * Check if the message structure length matches the structure length. Otherwise - * the sender accidentally programmed a incorrect length into the message. - */ - if (msg_len != sizeof(*msg)) { - nss_warning("%px: message request len bad: %d", nss_ctx, msg_len); - return NSS_TX_FAILURE_BAD_PARAM; - } - - 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); - - /* - * Trace messages. - */ - nss_crypto_cmn_log_tx_msg(msg); - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_crypto_cmn_tx_msg); - -/* - * nss_crypto_cmn_tx_msg_cb() - * Callback to handle the synchronous completion of messages. - */ -static void nss_crypto_cmn_tx_msg_cb(void *app_data, struct nss_crypto_cmn_msg *nim) -{ - struct nss_crypto_cmn_pvt *pvt = &g_nss_crypto_cmn; - struct nss_crypto_cmn_msg *resp = (struct nss_crypto_cmn_msg *)nim->cm.app_data; - - /* - * Only update the message structure if the sequence no. matches - * Otherwise, a timeout might have happened in between and we - * are probably receiving the completion for an older message - */ - if (atomic_read(&pvt->seq_no) == nim->seq_num) { - memcpy(resp, nim, sizeof(struct nss_crypto_cmn_msg)); - complete(&pvt->complete); - } -} - -/* - * nss_crypto_cmn_tx_msg_sync() - * Transmit a crypto message to NSS firmware synchronously. - */ -nss_tx_status_t nss_crypto_cmn_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_crypto_cmn_msg *msg) -{ - struct nss_crypto_cmn_pvt *pvt = &g_nss_crypto_cmn; - nss_tx_status_t status; - int ret = 0; - - down(&pvt->sem); - atomic_inc(&pvt->seq_no); - - /* - * this is a synchronous message; overload the callback - * and app_data - */ - msg->cm.cb = (nss_ptr_t)nss_crypto_cmn_tx_msg_cb; - msg->cm.app_data = (nss_ptr_t)msg; - msg->seq_num = atomic_read(&pvt->seq_no); - - status = nss_crypto_cmn_tx_msg(nss_ctx, msg); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: tx_msg failed", nss_ctx); - up(&pvt->sem); - return status; - } - - /* - * Note: This cannot be called in atomic context - */ - ret = wait_for_completion_timeout(&pvt->complete, NSS_CRYPTO_CMN_TX_TIMEO_TICKS); - if (!ret) { - atomic_inc(&pvt->seq_no); - nss_warning("%px: tx_msg_sync timed out", nss_ctx); - up(&pvt->sem); - return NSS_TX_FAILURE; - } - - /* - * This ensures that the even if the response arrives on a different - * CPU core the data copied by the response callback will be visible - * to the caller which is sleeping for it on a different core. For - * further details read Linux/Documentation/memory-barrier.txt - */ - smp_rmb(); - up(&pvt->sem); - - return NSS_TX_SUCCESS; -} -EXPORT_SYMBOL(nss_crypto_cmn_tx_msg_sync); - -/* - * nss_crypto_cmn_tx_buf() - * NSS crypto TX data API. Sends a crypto buffer to NSS. - */ -nss_tx_status_t nss_crypto_cmn_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - struct sk_buff *skb) -{ - int32_t status; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { - nss_warning("%px: tx_data packet dropped as core not ready", nss_ctx); - return NSS_TX_FAILURE_NOT_READY; - } - - status = nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_BUFFER_REUSABLE); - switch (status) { - case NSS_CORE_STATUS_SUCCESS: - break; - - case NSS_CORE_STATUS_FAILURE_QUEUE: /* queue full condition */ - nss_warning("%px: H2N queue full for tx_buf", nss_ctx); - return NSS_TX_FAILURE_QUEUE; - - default: - nss_warning("%px: general failure for tx_buf", nss_ctx); - return NSS_TX_FAILURE; - } - - /* - * Kick the NSS awake so it can process our new entry. - */ - nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_CRYPTO_REQ]); - - return NSS_TX_SUCCESS; -} -EXPORT_SYMBOL(nss_crypto_cmn_tx_buf); - -/* - * nss_crypto_cmn_notify_register() - * register message notifier for crypto interface - */ -struct nss_ctx_instance *nss_crypto_cmn_notify_register(nss_crypto_cmn_msg_callback_t cb, void *app_data) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[nss_top->crypto_handler_id]; - - nss_top->crypto_ctx = app_data; - nss_top->crypto_cmn_msg_callback = cb; - - return nss_ctx; -} -EXPORT_SYMBOL(nss_crypto_cmn_notify_register); - -/* - * nss_crypto_cmn_notify_unregister() - * De-register the message notifier for crypto interface - */ -void nss_crypto_cmn_notify_unregister(struct nss_ctx_instance *nss_ctx) -{ - struct nss_top_instance *nss_top = &nss_top_main; - - nss_top->crypto_ctx = NULL; - nss_top->crypto_cmn_msg_callback = NULL; -} -EXPORT_SYMBOL(nss_crypto_cmn_notify_unregister); - -/* - * nss_crypto_cmn_data_register() - * Register the data callback routine - */ -struct nss_ctx_instance *nss_crypto_cmn_data_register(uint32_t if_num, nss_crypto_cmn_buf_callback_t cb, - struct net_device *netdev, uint32_t features) -{ - struct nss_ctx_instance *nss_ctx; - - nss_ctx = &nss_top_main.nss[nss_top_main.crypto_handler_id]; - - if (if_num < NSS_SPECIAL_IF_START) { - nss_warning("%px: interface number is not special interface %d", nss_ctx, if_num); - return NULL; - } - - /* - * avoid multiple registration for same interface number - */ - if (nss_ctx->subsys_dp_register[if_num].cb) - return nss_ctx; - - /* - * Note: no locking is required for updating this as - * the registration is only a module load time operation. - */ - nss_core_register_subsys_dp(nss_ctx, if_num, cb, NULL, NULL, netdev, features); - - return nss_ctx; -} -EXPORT_SYMBOL(nss_crypto_cmn_data_register); - -/* - * nss_crypto_cmn_data_unregister() - * De-register the data callback routine - */ -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("%px: interface number is not special interface %d", nss_ctx, if_num); - return; - } - - /* - * Note: no locking is required for updating this as - * the registration is only a module load time operation. - */ - nss_core_unregister_subsys_dp(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_crypto_cmn_data_unregister); - -/* - * nss_crypto_cmn_get_context() - * get NSS context instance for crypto handle - */ -struct nss_ctx_instance *nss_crypto_cmn_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.crypto_handler_id]; -} -EXPORT_SYMBOL(nss_crypto_cmn_get_context); - -/* - * nss_crypto_cmn_register_handler() - */ -void nss_crypto_cmn_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_crypto_cmn_get_context(); - - 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(); -} - -/* - * nss_crypto_cmn_msg_init() - * Initialize crypto message - */ -void nss_crypto_cmn_msg_init(struct nss_crypto_cmn_msg *ncm, uint16_t if_num, uint32_t type, - uint32_t len, nss_crypto_cmn_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, (void *)cb, app_data); -} -EXPORT_SYMBOL(nss_crypto_cmn_msg_init); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_log.c deleted file mode 100644 index 04cd66c47..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_log.c +++ /dev/null @@ -1,210 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_crypto_cmn_log.c - * NSS Crypto Common logger file. - */ - -#include "nss_core.h" - -/* - * nss_crypto_cmn_log_message_types_str - * Crypto Common message strings - */ -static int8_t *nss_crypto_cmn_log_message_types_str[NSS_CRYPTO_CMN_MSG_TYPE_MAX] __maybe_unused = { - "Crypto Common Invalid Message", - "Crypto Common CRYPTO CMN Initialize Node", - "Crypto Common Initialize Engine", - "Crypto Common Initialize DMA Pair", - "Crypto Common Update Context Information", - "Crypto Common Clear Context Information", - "Crypto Common Verify Context Active", - "Crypto Common Synchronous Node Statistics" - "Crypto Common Synchronouts Engine Statistics", - "Crypto Common Synchronous Context Statistics" -}; - -/* - * nss_crypto_cmn_log_error_response_types_str - * Strings for error types for crypto common messages - */ -static int8_t *nss_crypto_cmn_log_error_response_types_str[NSS_CRYPTO_CMN_MSG_ERROR_MAX] __maybe_unused = { - "Crypto Common No Error", - "Crypto Common Header Version Not Supported", - "Crypto Common Context Index out-of-range for node", - "Crypto Common DMA mask out-of-range", - "Crypto Common DMA count exceeds Token", - "Crypto Common Token Allocation failed", - "Crypto Common Context Index out-of-range", - "Crypto Common Context has references", - "Crypto Common Bad Context Size", - "Crypto Common Bad Algorithm", - "Crypto Common Context Allocation failed", - "Crypto Common Context has no references", - "Crypto Common Invalid Context Flags" -}; - -/* - * nss_crypto_cmn_node_msg() - * Log NSS crypto common node message. - */ -static void nss_crypto_cmn_node_msg(struct nss_crypto_cmn_msg *ncm) -{ - struct nss_crypto_cmn_node *ncnm __maybe_unused = &ncm->msg.node; - 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", - ncnm, ncnm->max_dma_rings, - ncnm->max_ctx, ncnm->max_ctx_size); -} - -/* - * nss_crypto_cmn_engine_msg() - * Log NSS crypto cmn engine message. - */ -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("%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, - ncem->dma_mask, ncem->req_count); -} - -/* - * nss_crypto_cmn_dma_msg() - * Log NSS crypto cmn dma message. - */ -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("%px: NSS crypto common dma message \n" - "Crypto Common DMA Pair ID: %d\n", - ncdm, ncdm->pair_id); -} - -/* - * nss_crypto_cmn_ctx_msg() - * Log NSS crypto cmn context message. - */ -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("%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: %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, - nccm->index, nccm->sec_offset, - &nccm->cipher_key, &nccm->auth_key, - &nccm->nonce, nccm->algo, nccm->flags); -} - -/* - * nss_crypto_cmn_log_verbose() - * Log message contents. - */ -static void nss_crypto_cmn_log_verbose(struct nss_crypto_cmn_msg *ncm) -{ - switch (ncm->cm.type) { - case NSS_CRYPTO_CMN_MSG_TYPE_SETUP_NODE: - nss_crypto_cmn_node_msg(ncm); - break; - - case NSS_CRYPTO_CMN_MSG_TYPE_SETUP_ENG: - nss_crypto_cmn_engine_msg(ncm); - break; - - case NSS_CRYPTO_CMN_MSG_TYPE_SETUP_DMA: - nss_crypto_cmn_dma_msg(ncm); - break; - - case NSS_CRYPTO_CMN_MSG_TYPE_SETUP_CTX: - case NSS_CRYPTO_CMN_MSG_TYPE_CLEAR_CTX: - case NSS_CRYPTO_CMN_MSG_TYPE_VERIFY_CTX: - nss_crypto_cmn_ctx_msg(ncm); - break; - - 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: - /* Getting logged in stats */ - break; - - default: - nss_warning("%px: Invalid message type\n", ncm); - break; - } -} - -/* - * nss_crypto_cmn_log_tx_msg() - * Log messages transmitted to FW. - */ -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("%px: Invalid message type\n", ncm); - return; - } - - 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); -} - -/* - * nss_crypto_cmn_log_rx_msg() - * Log messages received from FW. - */ -void nss_crypto_cmn_log_rx_msg(struct nss_crypto_cmn_msg *ncm) -{ - if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_crypto_cmn_log_verbose(ncm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_log.h deleted file mode 100644 index f78a8ecf7..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_LOG_H__ -#define __NSS_CRYPTO_CMN_LOG_H__ - -/* - * nss_crypto_cmn_log.h - * NSS Crypto Common Log header file. - */ - -/* - * nss_crypto_cmn_log_tx_msg - * Logs a crypto common message that is sent to the NSS firmware. - */ -void nss_crypto_cmn_log_tx_msg(struct nss_crypto_cmn_msg *ncm); - -/* - * nss_crypto_cmn_log_rx_msg - * Logs a crypto common message that is received from the NSS firmware. - */ -void nss_crypto_cmn_log_rx_msg(struct nss_crypto_cmn_msg *ncm); - -#endif /* __NSS_CRYPTO_CMN_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_stats.c deleted file mode 100644 index c30416634..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_stats.h deleted file mode 100644 index 6319c2cbb..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_strings.c deleted file mode 100644 index 42e8d8b85..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_crypto_cmn_strings.h deleted file mode 100644 index aae067764..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_crypto_log.c deleted file mode 100644 index b5569973b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_log.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_crypto_log.c - * NSS Crypto logger file. - */ - -#include "nss_core.h" - -/* - * nss_crypto_log_message_types_str - * Crypto message strings - */ -static int8_t *nss_crypto_log_message_types_str[NSS_CRYPTO_MSG_TYPE_MAX] __maybe_unused = { - "Crypto Invalid Message", - "Crypto Open Engine Message", - "Crypto Close Engine Message", - "Crypto Update Session", - "Crypto Stats Sync", -}; - -/* - * nss_crypto_log_error_response_types_str - * Strings for error types for CRYPTO messages - */ -static int8_t *nss_crypto_log_error_response_types_str[NSS_CRYPTO_MSG_ERROR_MAX] __maybe_unused = { - "Crypto No Error", - "Crypto Invalid Engine", - "Crypto Unsupported Operation", - "Crypto Invalid Operation", - "Crypto Invalid Index Range", - "Crypto Index Alloc Failure", -}; - -/* - * nss_crypto_config_eng_msg() - * Log NSS Crypto config engine message. - */ -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("%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: %px\n" - "Crypto Session Indices: %px\n", - nccem, nccem->eng_id, - nccem->bam_pbase, nccem->crypto_pbase, - &nccem->desc_paddr, &nccem->idx); -} - -/* - * nss_crypto_config_session_msg() - * Log NSS Crypto config session message. - */ -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("%px: NSS Crypto Config Session message \n" - "Crypto Session Index: %d\n" - "Crypto Session State: %d\n" - "Crypto Session Initialization Vector Length: %d\n", - nccsm, nccsm->idx, - nccsm->state, nccsm->iv_len); -} - -/* - * nss_crypto_log_verbose() - * Log message contents. - */ -static void nss_crypto_log_verbose(struct nss_crypto_msg *ncm) -{ - switch (ncm->cm.type) { - case NSS_CRYPTO_MSG_TYPE_OPEN_ENG: - nss_crypto_config_eng_msg(ncm); - break; - - case NSS_CRYPTO_MSG_TYPE_UPDATE_SESSION: - nss_crypto_config_session_msg(ncm); - break; - - default: - nss_warning("%px: Invalid message type\n", ncm); - break; - } -} - -/* - * nss_crypto_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_crypto_log_tx_msg(struct nss_crypto_msg *ncm) -{ - if (ncm->cm.type >= NSS_CRYPTO_MSG_TYPE_MAX) { - nss_warning("%px: Invalid message type\n", ncm); - return; - } - - 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_crypto_log_rx_msg() - * Log messages received from FW. - */ -void nss_crypto_log_rx_msg(struct nss_crypto_msg *ncm) -{ - if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_crypto_log_verbose(ncm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_crypto_log.h deleted file mode 100644 index c0d53ddae..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_crypto_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_LOG_H__ -#define __NSS_CRYPTO_LOG_H__ - -/* - * nss_crypto_log.h - * NSS Crypto Log Header File - */ - -/* - * nss_crypto_log_tx_msg - * Logs a crypto message that is sent to the NSS firmware. - */ -void nss_crypto_log_tx_msg(struct nss_crypto_msg *ncm); - -/* - * nss_crypto_log_rx_msg - * Logs a crypto message that is received from the NSS firmware. - */ -void nss_crypto_log_rx_msg(struct nss_crypto_msg *ncm); - -#endif /* __NSS_CRYPTO_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/hal/include/nss_data_plane_hal.h b/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/hal/include/nss_data_plane_hal.h deleted file mode 100644 index aa46eadc7..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/hal/include/nss_data_plane_hal.h +++ /dev/null @@ -1,54 +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_phys_if.h" -#include - -#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 - -/* - * 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); -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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/hal/nss_ipq50xx.c b/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/hal/nss_ipq50xx.c deleted file mode 100644 index 980a06b62..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/hal/nss_ipq50xx.c +++ /dev/null @@ -1,185 +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_data_plane_hal.h" - -static DEFINE_SPINLOCK(nss_data_plane_hal_gmac_stats_lock); - -/* - * 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) -{ - struct nss_data_plane_param *dp = (struct nss_data_plane_param *)dpc; - - spin_lock_bh(&nss_data_plane_hal_gmac_stats_lock); - memcpy(stats, &dp->gmac_stats, sizeof(*stats)); - spin_unlock_bh(&nss_data_plane_hal_gmac_stats_lock); -} - -/* - * 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->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) -{ -} - -/* - * nss_data_plane_hal_unregister() - */ -void nss_data_plane_hal_unregister(struct nss_ctx_instance *nss_ctx) -{ -} - -/* - * 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->wanted_features |= NSS_DATA_PLANE_SUPPORTED_FEATURES; - - /* - * Synopsys GMAC does not support checksum offload for QinQ VLANs. - * Hence, we do not advertise checksum offload support for VLANs. - */ - dpc->dev->vlan_features |= NSS_DATA_PLANE_SUPPORTED_FEATURES & - (~(NETIF_F_RXCSUM | NETIF_F_HW_CSUM)); -} - -/* - * 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) -{ - struct nss_dp_hal_gmac_stats *gmac_stats = &ndpp->gmac_stats.stats; - - spin_lock_bh(&nss_data_plane_hal_gmac_stats_lock); - - gmac_stats->rx_bytes += stats->if_stats.rx_bytes; - gmac_stats->rx_packets += stats->if_stats.rx_packets; - gmac_stats->rx_errors += stats->estats.rx_errors; - gmac_stats->rx_receive_errors += stats->estats.rx_receive_errors; - gmac_stats->rx_descriptor_errors += stats->estats.rx_descriptor_errors; - gmac_stats->rx_late_collision_errors += stats->estats.rx_late_collision_errors; - gmac_stats->rx_dribble_bit_errors += stats->estats.rx_dribble_bit_errors; - gmac_stats->rx_length_errors += stats->estats.rx_length_errors; - gmac_stats->rx_ip_header_errors += stats->estats.rx_ip_header_errors; - gmac_stats->rx_ip_payload_errors += stats->estats.rx_ip_payload_errors; - gmac_stats->rx_no_buffer_errors += stats->estats.rx_no_buffer_errors; - gmac_stats->rx_transport_csum_bypassed += stats->estats.rx_transport_csum_bypassed; - - gmac_stats->tx_bytes += stats->if_stats.tx_bytes; - gmac_stats->tx_packets += stats->if_stats.tx_packets; - gmac_stats->tx_collisions += stats->estats.tx_collisions; - gmac_stats->tx_errors += stats->estats.tx_errors; - gmac_stats->tx_jabber_timeout_errors += stats->estats.tx_jabber_timeout_errors; - gmac_stats->tx_frame_flushed_errors += stats->estats.tx_frame_flushed_errors; - gmac_stats->tx_loss_of_carrier_errors += stats->estats.tx_loss_of_carrier_errors; - gmac_stats->tx_no_carrier_errors += stats->estats.tx_no_carrier_errors; - gmac_stats->tx_late_collision_errors += stats->estats.tx_late_collision_errors; - gmac_stats->tx_excessive_collision_errors += stats->estats.tx_excessive_collision_errors; - gmac_stats->tx_excessive_deferral_errors += stats->estats.tx_excessive_deferral_errors; - gmac_stats->tx_underflow_errors += stats->estats.tx_underflow_errors; - gmac_stats->tx_ip_header_errors += stats->estats.tx_ip_header_errors; - gmac_stats->tx_ip_payload_errors += stats->estats.tx_ip_payload_errors; - gmac_stats->tx_dropped += stats->estats.tx_dropped; - - gmac_stats->hw_errs[0] += stats->estats.hw_errs[0]; - gmac_stats->hw_errs[1] += stats->estats.hw_errs[1]; - gmac_stats->hw_errs[2] += stats->estats.hw_errs[2]; - gmac_stats->hw_errs[3] += stats->estats.hw_errs[3]; - gmac_stats->hw_errs[4] += stats->estats.hw_errs[4]; - gmac_stats->hw_errs[5] += stats->estats.hw_errs[5]; - gmac_stats->hw_errs[6] += stats->estats.hw_errs[6]; - gmac_stats->hw_errs[7] += stats->estats.hw_errs[7]; - gmac_stats->hw_errs[8] += stats->estats.hw_errs[8]; - gmac_stats->hw_errs[9] += stats->estats.hw_errs[9]; - gmac_stats->rx_missed += stats->estats.rx_missed; - - gmac_stats->fifo_overflows += stats->estats.fifo_overflows; - gmac_stats->rx_scatter_errors += stats->estats.rx_scatter_errors; - gmac_stats->tx_ts_create_errors += stats->estats.tx_ts_create_errors; - gmac_stats->gmac_total_ticks += stats->estats.gmac_total_ticks; - gmac_stats->gmac_worst_case_ticks += stats->estats.gmac_worst_case_ticks; - gmac_stats->gmac_iterations += stats->estats.gmac_iterations; - gmac_stats->tx_pause_frames += stats->estats.tx_pause_frames; - gmac_stats->mmc_rx_overflow_errors += stats->estats.mmc_rx_overflow_errors; - gmac_stats->mmc_rx_watchdog_timeout_errors += stats->estats.mmc_rx_watchdog_timeout_errors; - gmac_stats->mmc_rx_crc_errors += stats->estats.mmc_rx_crc_errors; - gmac_stats->mmc_rx_ip_header_errors += stats->estats.mmc_rx_ip_header_errors; - gmac_stats->mmc_rx_octets_g += stats->estats.mmc_rx_octets_g; - gmac_stats->mmc_rx_ucast_frames += stats->estats.mmc_rx_ucast_frames; - gmac_stats->mmc_rx_bcast_frames += stats->estats.mmc_rx_bcast_frames; - gmac_stats->mmc_rx_mcast_frames += stats->estats.mmc_rx_mcast_frames; - gmac_stats->mmc_rx_undersize += stats->estats.mmc_rx_undersize; - gmac_stats->mmc_rx_oversize += stats->estats.mmc_rx_oversize; - gmac_stats->mmc_rx_jabber += stats->estats.mmc_rx_jabber; - gmac_stats->mmc_rx_octets_gb += stats->estats.mmc_rx_octets_gb; - gmac_stats->mmc_rx_frag_frames_g += stats->estats.mmc_rx_frag_frames_g; - gmac_stats->mmc_tx_octets_g += stats->estats.mmc_tx_octets_g; - gmac_stats->mmc_tx_ucast_frames += stats->estats.mmc_tx_ucast_frames; - gmac_stats->mmc_tx_bcast_frames += stats->estats.mmc_tx_bcast_frames; - gmac_stats->mmc_tx_mcast_frames += stats->estats.mmc_tx_mcast_frames; - gmac_stats->mmc_tx_deferred += stats->estats.mmc_tx_deferred; - gmac_stats->mmc_tx_single_col += stats->estats.mmc_tx_single_col; - gmac_stats->mmc_tx_multiple_col += stats->estats.mmc_tx_multiple_col; - gmac_stats->mmc_tx_octets_gb += stats->estats.mmc_tx_octets_gb; - - spin_unlock_bh(&nss_data_plane_hal_gmac_stats_lock); -} - -/* - * nss_data_plane_hal_get_mtu_sz() - */ -uint16_t nss_data_plane_hal_get_mtu_sz(uint16_t mtu) -{ - /* - * GMACs support 3 Modes - * Normal Mode Payloads upto 1522 Bytes ( 1500 + 14 + 4(Vlan) + 4(CRC)) - * Mini Jumbo Mode Payloads upto 2000 Bytes (1978 + 14 + 4(Vlan) + 4 (CRC)) - * Full Jumbo Mode payloads upto 9022 Bytes (9000 + 14 + 4(Vlan) + 4 (CRC)) - */ - - /* - * The configured MTU value on a GMAC interface should be one of these - * cases. Finding the Needed MTU size that is required for GMAC to - * successfully receive the frame. - */ - if (mtu <= NSS_DP_GMAC_NORMAL_FRAME_MTU) { - return NSS_DP_GMAC_NORMAL_FRAME_MTU; - } - if (mtu <= NSS_DP_GMAC_MINI_JUMBO_FRAME_MTU) { - return NSS_DP_GMAC_MINI_JUMBO_FRAME_MTU; - } - if (mtu <= NSS_DP_GMAC_FULL_JUMBO_FRAME_MTU) { - return NSS_DP_GMAC_FULL_JUMBO_FRAME_MTU; - } - return 0; -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/hal/nss_ipq60xx.c b/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/hal/nss_ipq60xx.c deleted file mode 100644 index d74df4cf8..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/hal/nss_ipq60xx.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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 - */ -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_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, - 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; -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/hal/nss_ipq807x.c b/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/hal/nss_ipq807x.c deleted file mode 100644 index 82fe2b0a1..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/hal/nss_ipq807x.c +++ /dev/null @@ -1,117 +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_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_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, - 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; -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/include/nss_data_plane.h b/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/include/nss_data_plane.h deleted file mode 100644 index 503a20a40..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/include/nss_data_plane.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_data_plane - * Data plane used for communication between qca-nss-drv & data plane host - */ - -#ifndef __NSS_DATA_PLANE_H -#define __NSS_DATA_PLANE_H - -#include -#include "nss_phys_if.h" - -/* - * nss_data_plane_schedule_registration() - * Called from nss_init to schedule a work to do data_plane register to data plane host driver - */ -bool nss_data_plane_schedule_registration(void); - -/* - * nss_data_plane_init_delay_work() - * Initialize data_plane workqueue - */ -int nss_data_plane_init_delay_work(void); - -/* - * nss_data_plane_destroy_delay_work() - * Destroy data_plane workqueue - */ -void nss_data_plane_destroy_delay_work(void); - -/* - * nss_data_plane_ops defines the API required to support multiple data plane targets - */ -struct nss_data_plane_ops { - void (*data_plane_register)(struct nss_ctx_instance *nss_ctx); - void (*data_plane_unregister)(void); - void (*data_plane_stats_sync)(struct nss_phys_if_stats *stats, uint16_t interface); - uint16_t (*data_plane_get_mtu_sz)(uint16_t max_mtu); -}; - -extern struct nss_data_plane_ops nss_data_plane_gmac_ops; -extern struct nss_data_plane_ops nss_data_plane_ops; - -extern int nss_skip_nw_process; -#endif diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/nss_data_plane.c b/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/nss_data_plane.c deleted file mode 100644 index 16b7cbbc6..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/nss_data_plane.c +++ /dev/null @@ -1,386 +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 "nss_data_plane_hal.h" - -/* - * nss_data_plane_param - */ -struct nss_data_plane_param nss_data_plane_params[NSS_DP_MAX_INTERFACES]; - -/* - * __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_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); -} - -/* - * __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) -{ - /* - * 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_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_DP_MAX_PACKET_LEN) { - nss_warning("skb->len ( %u ) > Maximum packet length ( %u ) \n", skb->len, NSS_DP_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("%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) -{ - nss_data_plane_hal_set_features(dpc); -} - -/* - * 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, -#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_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; - } - - 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; -} - -/* - * 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() - */ -static void __nss_data_plane_register(struct nss_ctx_instance *nss_ctx) -{ - 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); - } - } - - /* - * Do any SoC specific registrations. - */ - nss_data_plane_hal_register(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 = 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, -}; diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/nss_data_plane_common.c b/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/nss_data_plane_common.c deleted file mode 100644 index 4ffaa9ce4..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/nss_data_plane_common.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - ************************************************************************** - * 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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/nss_data_plane_gmac.c b/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/nss_data_plane_gmac.c deleted file mode 100644 index 42e10a91c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_data_plane/nss_data_plane_gmac.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_phys_if.h" -#include "nss_core.h" -#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_DATA_PLANE_GMAC_MAX_INTERFACES 4 - -static DEFINE_SPINLOCK(nss_data_plane_gmac_stats_lock); - -/* - * nss_data_plane_gmac_param - * Holds the information that is going to pass to data plane host as a cookie - */ -struct nss_data_plane_gmac_param { - int if_num; /* physical interface number */ - struct net_device *dev; /* net_device instance of this data plane */ - struct nss_ctx_instance *nss_ctx; /* which nss core */ - struct nss_gmac_stats gmac_stats; /* gmac stats */ - 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_gmac_params[NSS_DATA_PLANE_GMAC_MAX_INTERFACES]; - -/* - * __nss_data_plane_open() - * Called by gmac to notify open to nss-fw - */ -static int __nss_data_plane_open(void *arg, uint32_t tx_desc_ring, uint32_t rx_desc_ring, uint32_t mode) -{ - struct nss_data_plane_gmac_param *dp = (struct nss_data_plane_gmac_param *)arg; - - if (dp->notify_open) { - return NSS_GMAC_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_GMAC_SUCCESS; - } - return NSS_GMAC_FAILURE; -} - -/* - * __nss_data_plane_close() - * Called by gmac to notify close to nss-fw - */ -static int __nss_data_plane_close(void *arg) -{ - /* - * We don't actually do synopsys gmac close in fw, just return success - */ - return NSS_GMAC_SUCCESS; -} - -/* - * __nss_data_plane_link_state() - * Called by gmac to notify link state change to nss-fw - */ -static int __nss_data_plane_link_state(void *arg, uint32_t link_state) -{ - struct nss_data_plane_gmac_param *dp = (struct nss_data_plane_gmac_param *)arg; - - return nss_phys_if_link_state(dp->nss_ctx, link_state, dp->if_num); -} - -/* - * __nss_data_plane_mac_addr() - * Called by gmac to set mac address - */ -static int __nss_data_plane_mac_addr(void *arg, uint8_t *addr) -{ - struct nss_data_plane_gmac_param *dp = (struct nss_data_plane_gmac_param *)arg; - - return nss_phys_if_mac_addr(dp->nss_ctx, addr, dp->if_num); -} - -/* - * __nss_data_plane_change_mtu() - * Called by gmac to change mtu of a gmac - */ -static int __nss_data_plane_change_mtu(void *arg, uint32_t mtu) -{ - struct nss_data_plane_gmac_param *dp = (struct nss_data_plane_gmac_param *)arg; - - /* - * MTU size check is already done in nss-gmac driver, just pass to phys_if - */ - return nss_phys_if_change_mtu(dp->nss_ctx, mtu, dp->if_num); -} - -/* - * __nss_data_plane_pause_on_off() - * Called by gmac to enable/disable pause frames - */ -static int __nss_data_plane_pause_on_off(void *arg, uint32_t pause_on) -{ - struct nss_data_plane_gmac_param *dp = (struct nss_data_plane_gmac_param *)arg; - - return nss_phys_if_pause_on_off(dp->nss_ctx, pause_on, dp->if_num); -} - -/* - * __nss_data_plane_buf() - * Called by gmac to pass a sk_buff for xmit - */ -static int __nss_data_plane_buf(void *arg, struct sk_buff *os_buf) -{ - struct nss_data_plane_gmac_param *dp = (struct nss_data_plane_gmac_param *)arg; - - return nss_phys_if_buf(dp->nss_ctx, os_buf, dp->if_num); -} - -/* - * __nss_data_plane_set_features() - * Called by gmac to allow data plane to modify the set of features it supports - */ -static void __nss_data_plane_set_features(struct net_device *netdev) -{ - netdev->features |= NSS_DP_GMAC_SUPPORTED_FEATURES; - netdev->hw_features |= NSS_DP_GMAC_SUPPORTED_FEATURES; - netdev->vlan_features |= NSS_DP_GMAC_SUPPORTED_FEATURES; - netdev->wanted_features |= NSS_DP_GMAC_SUPPORTED_FEATURES; -} - -/* - * __nss_data_plane_get_stats() - */ -static void __nss_data_plane_get_stats(void *arg, struct nss_gmac_stats *stats) -{ - struct nss_data_plane_gmac_param *dp = (struct nss_data_plane_gmac_param *)arg; - - spin_lock_bh(&nss_data_plane_gmac_stats_lock); - memcpy(stats, &dp->gmac_stats, sizeof(*stats)); - spin_unlock_bh(&nss_data_plane_gmac_stats_lock); -} - -/* - * nss offload data plane ops - */ -static struct nss_gmac_data_plane_ops dp_ops = { - .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, - .get_stats = __nss_data_plane_get_stats, -}; - -/* - * nss_data_plane_register_to_nss_gmac() - */ -static bool nss_data_plane_register_to_nss_gmac(struct nss_ctx_instance *nss_ctx, int if_num) -{ - struct nss_data_plane_gmac_param *ndpp = &nss_data_plane_gmac_params[if_num]; - struct nss_top_instance *nss_top = nss_ctx->nss_top; - struct net_device *netdev; - bool is_open; - int core; - - netdev = nss_gmac_get_netdev_by_macid(if_num); - if (!netdev) { - nss_info("Platform don't have gmac%d enabled, don't bring up nss_phys_if and don't register to nss-gmac", if_num); - return false; - } - - is_open = nss_gmac_is_in_open_state(netdev); - ndpp->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 GMAC - */ - if (nss_skip_nw_process) { - ndpp->bypass_nw_process = 1; - } else { - ndpp->bypass_nw_process = 0; - } - - if (nss_gmac_override_data_plane(netdev, &dp_ops, ndpp) != NSS_GMAC_SUCCESS) { - nss_info("Override nss-gmac data plane failed\n"); - return false; - } - - /* - * Setup the receive callback so that data pkts received form NSS-FW will - * be redirected to the gmac 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_gmac_receive, NULL, NULL, netdev, ndpp->features); - } - - /* - * Now we are registered and our side is ready, if the gmac was opened, ask it to start again - */ - if (is_open) { - nss_gmac_start_data_plane(netdev, ndpp); - } - return true; -} - -/* - * nss_data_plane_unregister_from_nss_gmac() - */ -static void nss_data_plane_unregister_from_nss_gmac(int if_num) -{ - nss_gmac_restore_data_plane(nss_data_plane_gmac_params[if_num].dev); - nss_data_plane_gmac_params[if_num].dev = NULL; - nss_data_plane_gmac_params[if_num].nss_ctx = NULL; - nss_data_plane_gmac_params[if_num].if_num = 0; - nss_data_plane_gmac_params[if_num].notify_open = 0; - nss_data_plane_gmac_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 = 0; i < NSS_DATA_PLANE_GMAC_MAX_INTERFACES; i++) { - if (!nss_data_plane_register_to_nss_gmac(nss_ctx, i)) { - nss_warning("%px: Register data plane failed for gmac:%d\n", nss_ctx, i); - } else { - nss_info("%px: Register data plan to gmac:%d success\n", nss_ctx, i); - } - } -} - -/* - * __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 = 0; i < NSS_DATA_PLANE_GMAC_MAX_INTERFACES; i++) { - if (nss_top_main.nss[core].subsys_dp_register[i].ndev) { - nss_data_plane_unregister_from_nss_gmac(i); - nss_core_unregister_subsys_dp(&nss_top_main.nss[core], i); - } - } - } -} - -/* - * __nss_data_plane_stats_sync() - * Handle the syncing of gmac data plane stats. - */ -static void __nss_data_plane_stats_sync(struct nss_phys_if_stats *stats, uint16_t interface) -{ - struct nss_gmac_stats *gmac_stats = &nss_data_plane_gmac_params[interface].gmac_stats; - - spin_lock_bh(&nss_data_plane_gmac_stats_lock); - gmac_stats->rx_bytes += stats->if_stats.rx_bytes; - gmac_stats->rx_packets += stats->if_stats.rx_packets; - gmac_stats->rx_errors += stats->estats.rx_errors; - gmac_stats->rx_receive_errors += stats->estats.rx_receive_errors; - gmac_stats->rx_descriptor_errors += stats->estats.rx_descriptor_errors; - gmac_stats->rx_late_collision_errors += stats->estats.rx_late_collision_errors; - gmac_stats->rx_dribble_bit_errors += stats->estats.rx_dribble_bit_errors; - gmac_stats->rx_length_errors += stats->estats.rx_length_errors; - gmac_stats->rx_ip_header_errors += stats->estats.rx_ip_header_errors; - gmac_stats->rx_ip_payload_errors += stats->estats.rx_ip_payload_errors; - gmac_stats->rx_no_buffer_errors += stats->estats.rx_no_buffer_errors; - gmac_stats->rx_transport_csum_bypassed += stats->estats.rx_transport_csum_bypassed; - - gmac_stats->tx_bytes += stats->if_stats.tx_bytes; - gmac_stats->tx_packets += stats->if_stats.tx_packets; - gmac_stats->tx_collisions += stats->estats.tx_collisions; - gmac_stats->tx_errors += stats->estats.tx_errors; - gmac_stats->tx_jabber_timeout_errors += stats->estats.tx_jabber_timeout_errors; - gmac_stats->tx_frame_flushed_errors += stats->estats.tx_frame_flushed_errors; - gmac_stats->tx_loss_of_carrier_errors += stats->estats.tx_loss_of_carrier_errors; - gmac_stats->tx_no_carrier_errors += stats->estats.tx_no_carrier_errors; - gmac_stats->tx_late_collision_errors += stats->estats.tx_late_collision_errors; - gmac_stats->tx_excessive_collision_errors += stats->estats.tx_excessive_collision_errors; - gmac_stats->tx_excessive_deferral_errors += stats->estats.tx_excessive_deferral_errors; - gmac_stats->tx_underflow_errors += stats->estats.tx_underflow_errors; - gmac_stats->tx_ip_header_errors += stats->estats.tx_ip_header_errors; - gmac_stats->tx_ip_payload_errors += stats->estats.tx_ip_payload_errors; - gmac_stats->tx_dropped += stats->estats.tx_dropped; - - gmac_stats->hw_errs[0] += stats->estats.hw_errs[0]; - gmac_stats->hw_errs[1] += stats->estats.hw_errs[1]; - gmac_stats->hw_errs[2] += stats->estats.hw_errs[2]; - gmac_stats->hw_errs[3] += stats->estats.hw_errs[3]; - gmac_stats->hw_errs[4] += stats->estats.hw_errs[4]; - gmac_stats->hw_errs[5] += stats->estats.hw_errs[5]; - gmac_stats->hw_errs[6] += stats->estats.hw_errs[6]; - gmac_stats->hw_errs[7] += stats->estats.hw_errs[7]; - gmac_stats->hw_errs[8] += stats->estats.hw_errs[8]; - gmac_stats->hw_errs[9] += stats->estats.hw_errs[9]; - gmac_stats->rx_missed += stats->estats.rx_missed; - - gmac_stats->fifo_overflows += stats->estats.fifo_overflows; - gmac_stats->rx_scatter_errors += stats->estats.rx_scatter_errors; - gmac_stats->tx_ts_create_errors += stats->estats.tx_ts_create_errors; - gmac_stats->gmac_total_ticks += stats->estats.gmac_total_ticks; - gmac_stats->gmac_worst_case_ticks += stats->estats.gmac_worst_case_ticks; - gmac_stats->gmac_iterations += stats->estats.gmac_iterations; - gmac_stats->tx_pause_frames += stats->estats.tx_pause_frames; - gmac_stats->mmc_rx_overflow_errors += stats->estats.mmc_rx_overflow_errors; - gmac_stats->mmc_rx_watchdog_timeout_errors += stats->estats.mmc_rx_watchdog_timeout_errors; - gmac_stats->mmc_rx_crc_errors += stats->estats.mmc_rx_crc_errors; - gmac_stats->mmc_rx_ip_header_errors += stats->estats.mmc_rx_ip_header_errors; - gmac_stats->mmc_rx_octets_g += stats->estats.mmc_rx_octets_g; - gmac_stats->mmc_rx_ucast_frames += stats->estats.mmc_rx_ucast_frames; - gmac_stats->mmc_rx_bcast_frames += stats->estats.mmc_rx_bcast_frames; - gmac_stats->mmc_rx_mcast_frames += stats->estats.mmc_rx_mcast_frames; - gmac_stats->mmc_rx_undersize += stats->estats.mmc_rx_undersize; - gmac_stats->mmc_rx_oversize += stats->estats.mmc_rx_oversize; - gmac_stats->mmc_rx_jabber += stats->estats.mmc_rx_jabber; - gmac_stats->mmc_rx_octets_gb += stats->estats.mmc_rx_octets_gb; - gmac_stats->mmc_rx_frag_frames_g += stats->estats.mmc_rx_frag_frames_g; - gmac_stats->mmc_tx_octets_g += stats->estats.mmc_tx_octets_g; - gmac_stats->mmc_tx_ucast_frames += stats->estats.mmc_tx_ucast_frames; - gmac_stats->mmc_tx_bcast_frames += stats->estats.mmc_tx_bcast_frames; - gmac_stats->mmc_tx_mcast_frames += stats->estats.mmc_tx_mcast_frames; - gmac_stats->mmc_tx_deferred += stats->estats.mmc_tx_deferred; - gmac_stats->mmc_tx_single_col += stats->estats.mmc_tx_single_col; - gmac_stats->mmc_tx_multiple_col += stats->estats.mmc_tx_multiple_col; - gmac_stats->mmc_tx_octets_gb += stats->estats.mmc_tx_octets_gb; - - spin_unlock_bh(&nss_data_plane_gmac_stats_lock); -} - -/* - * __nss_data_plane_get_mtu_sz() - */ -static uint16_t __nss_data_plane_get_mtu_sz(uint16_t max_mtu) -{ - /* - * GMACs support 3 Modes - * Normal Mode Payloads upto 1522 Bytes ( 1500 + 14 + 4(Vlan) + 4(CRC)) - * Mini Jumbo Mode Payloads upto 2000 Bytes (1978 + 14 + 4(Vlan) + 4 (CRC)) - * Full Jumbo Mode payloads upto 9622 Bytes (9600 + 14 + 4(Vlan) + 4 (CRC)) - */ - - /* - * The configured MTU value on a gmac interface should be one of these - * cases. Finding the Needed MTU size that is required for GMAC to - * successfully receive the frame. - */ - if (max_mtu <= NSS_GMAC_NORMAL_FRAME_MTU) { - return NSS_GMAC_NORMAL_FRAME_MTU; - } - if (max_mtu <= NSS_GMAC_MINI_JUMBO_FRAME_MTU) { - return NSS_GMAC_MINI_JUMBO_FRAME_MTU; - } - if (max_mtu <= NSS_GMAC_FULL_JUMBO_FRAME_MTU) { - return NSS_GMAC_FULL_JUMBO_FRAME_MTU; - } - return 0; -} - -/* - * nss_data_plane_gmac_ops - */ -struct nss_data_plane_ops nss_data_plane_gmac_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, -}; diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dma.c b/feeds/ipq807x/qca-nss-drv/src/nss_dma.c deleted file mode 100755 index e88e7c668..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dma.c +++ /dev/null @@ -1,501 +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. - ************************************************************************** - */ - -/* - * 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[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(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dma_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_dma_log.c deleted file mode 100755 index 7f367c8ca..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dma_log.c +++ /dev/null @@ -1,140 +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_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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dma_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_dma_log.h deleted file mode 100755 index 4a9b9c3ad..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dma_log.h +++ /dev/null @@ -1,38 +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_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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dma_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_dma_stats.c deleted file mode 100755 index 12812e4e5..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dma_stats.c +++ /dev/null @@ -1,163 +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_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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dma_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_dma_stats.h deleted file mode 100755 index a7fc1d859..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dma_stats.h +++ /dev/null @@ -1,31 +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_DMA_STATS_H -#define __NSS_DMA_STATS_H - -#include - -/* - * 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); - -#endif /* __NSS_DMA_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dma_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_dma_strings.c deleted file mode 100755 index 402afc7be..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dma_strings.c +++ /dev/null @@ -1,88 +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_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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dma_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_dma_strings.h deleted file mode 100755 index 145021627..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dma_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_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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_drv_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_drv_stats.c deleted file mode 100644 index 30b8cb5f7..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_drv_stats.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_drv_strings.h" -#include "nss_drv_stats.h" - -/* - * nss_drv_stats_read() - * Read HLOS driver stats. - */ -static ssize_t nss_drv_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int32_t i; - - /* - * 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_DRV_STATS_MAX * NSS_MAX_CORES + 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_DRV_STATS_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, "drv", NSS_STATS_SINGLE_CORE); - for (i = 0; (i < NSS_DRV_STATS_MAX); i++) { - stats_shadow[i] = NSS_PKT_STATS_READ(&nss_top_main.stats_drv[i]); - } - - size_wr += nss_stats_print("drv", NULL, NSS_STATS_SINGLE_INSTANCE, nss_drv_strings_stats, stats_shadow, NSS_DRV_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; -} - -/* - * drv_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(drv); - -/* - * nss_drv_stats_dentry_create() - * Create DRV statistics debug entry. - */ -void nss_drv_stats_dentry_create(void) -{ - nss_stats_create_dentry("drv", &nss_drv_stats_ops); -} - -/* - * TODO: Move this (nss_wt_stats_read) function to new file (nss_wt_stats.c) - */ - -/* - * nss_wt_stats_read() - * Reads and formats worker thread statistics and outputs them to ubuf - */ -ssize_t nss_wt_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 = data->nss_ctx; - struct nss_project_irq_stats *shadow; - uint32_t thread_count = nss_ctx->worker_thread_count; - uint32_t irq_count = nss_ctx->irq_count; - - /* - * Three lines for each IRQ - */ - uint32_t max_output_lines = thread_count * 3 * irq_count; - size_t size_al = max_output_lines * NSS_STATS_MAX_STR_LENGTH; - size_t size_wr = 0; - ssize_t bytes_read = 0; - char *lbuf; - int i; - int j; - - lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(!lbuf)) { - nss_warning("Could not allocate memory for local statistics buffer\n"); - return 0; - } - - shadow = kzalloc(thread_count * irq_count * sizeof(struct nss_project_irq_stats), GFP_KERNEL); - if (unlikely(!shadow)) { - nss_warning("Could not allocate memory for stats shadow\n"); - kfree(lbuf); - return 0; - } - - spin_lock_bh(&nss_top_main.stats_lock); - if (unlikely(!nss_ctx->wt_stats)) { - spin_unlock_bh(&nss_top_main.stats_lock); - nss_warning("Worker thread statistics not allocated\n"); - kfree(lbuf); - kfree(shadow); - return 0; - } - for (i = 0; i < thread_count; ++i) { - - /* - * The statistics shadow is an array with thread_count * irq_count - * items in it. Each item is located at the index: - * (thread number) * (irq_count) + (irq number) - * thus simulating a two-dimensional array. - */ - for (j = 0; j < irq_count; ++j) { - shadow[i * irq_count + j] = nss_ctx->wt_stats[i].irq_stats[j]; - } - } - spin_unlock_bh(&nss_top_main.stats_lock); - - size_wr += nss_stats_banner(lbuf, size_wr, size_al, "worker thread", NSS_STATS_SINGLE_CORE); - for (i = 0; i < thread_count; ++i) { - for (j = 0; j < irq_count; ++j) { - struct nss_project_irq_stats *is = &(shadow[i * irq_count + j]); - if (!(is->count)) { - continue; - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, - "t-%d:irq-%d callback: 0x%x, count: %llu\n", - i, j, is->callback, is->count); - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, - "t-%d:irq-%d tick min: %10u avg: %10u max:%10u\n", - i, j, is->ticks_min, is->ticks_avg, is->ticks_max); - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, - "t-%d:irq-%d insn min: %10u avg: %10u max:%10u\n\n", - i, j, is->insn_min, is->insn_avg, is->insn_max); - } - } - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(lbuf); - kfree(shadow); - - return bytes_read; -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_drv_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_drv_stats.h deleted file mode 100644 index 543dd5c89..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_drv_stats.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_drv_stats.h - * NSS driver stats header file. - */ - -#ifndef __NSS_DRV_STATS_H -#define __NSS_DRV_STATS_H - -#include - -/* - * HLOS driver statistics - * - * WARNING: There is a 1:1 mapping between values below and corresponding - * stats string array in nss_stats.c. - */ -enum NSS_DRV_STATS { - NSS_DRV_STATS_NBUF_ALLOC_FAILS = 0, /* NBUF allocation errors */ - NSS_DRV_STATS_PAGED_BUF_ALLOC_FAILS, /* Paged buf allocation errors */ - NSS_DRV_STATS_TX_QUEUE_FULL_0, /* Tx queue full for Core 0*/ - NSS_DRV_STATS_TX_QUEUE_FULL_1, /* Tx queue full for Core 1*/ - NSS_DRV_STATS_TX_EMPTY, /* H2N Empty buffers */ - NSS_DRV_STATS_PAGED_TX_EMPTY, /* H2N Paged Empty buffers */ - NSS_DRV_STATS_TX_PACKET, /* H2N Data packets */ - NSS_DRV_STATS_TX_CMD_REQ, /* H2N Control packets */ - NSS_DRV_STATS_TX_CRYPTO_REQ, /* H2N Crypto requests */ - NSS_DRV_STATS_TX_BUFFER_REUSE, /* H2N Reuse buffer count */ - NSS_DRV_STATS_RX_EMPTY, /* N2H Empty buffers */ - NSS_DRV_STATS_RX_PACKET, /* N2H Data packets */ - NSS_DRV_STATS_RX_EXT_PACKET, /* N2H EXT type packets */ - NSS_DRV_STATS_RX_CMD_RESP, /* N2H Command responses */ - NSS_DRV_STATS_RX_STATUS, /* N2H Status packets */ - NSS_DRV_STATS_RX_CRYPTO_RESP, /* N2H Crypto responses */ - NSS_DRV_STATS_RX_VIRTUAL, /* N2H Virtual packets */ - NSS_DRV_STATS_TX_SIMPLE, /* H2N Simple SKB Packets */ - NSS_DRV_STATS_TX_NR_FRAGS, /* H2N NR Frags SKB Packets */ - NSS_DRV_STATS_TX_FRAGLIST, /* H2N Fraglist SKB Packets */ - NSS_DRV_STATS_RX_SIMPLE, /* N2H Simple SKB Packets */ - NSS_DRV_STATS_RX_NR_FRAGS, /* N2H NR Frags SKB Packets */ - NSS_DRV_STATS_RX_SKB_FRAGLIST, /* N2H Fraglist SKB Packets */ - NSS_DRV_STATS_RX_BAD_DESCRIPTOR, /* N2H Bad descriptor reads */ - NSS_DRV_STATS_RX_INVALID_INTERFACE, /* N2H Received descriptor for invalid interface */ - NSS_DRV_STATS_RX_INVALID_CORE_ID, /* N2H Received packet for invalid core_id */ - NSS_DRV_STATS_RX_INVALID_BUFFER_TYPE, /* N2H Received packet for invalid buffer type */ - NSS_DRV_STATS_NSS_SKB_COUNT, /* NSS SKB Pool Count */ - NSS_DRV_STATS_CHAIN_SEG_PROCESSED, /* N2H SKB Chain Processed Count */ - NSS_DRV_STATS_FRAG_SEG_PROCESSED, /* N2H Frag Processed Count */ - NSS_DRV_STATS_TX_CMD_QUEUE_FULL, /* Tx H2N Control packets fail due to queue full */ -#ifdef NSS_MULTI_H2N_DATA_RING_SUPPORT - NSS_DRV_STATS_TX_PACKET_QUEUE_0, /* H2N Data packets on queue0 */ - NSS_DRV_STATS_TX_PACKET_QUEUE_1, /* H2N Data packets on queue1 */ - NSS_DRV_STATS_TX_PACKET_QUEUE_2, /* H2N Data packets on queue2 */ - NSS_DRV_STATS_TX_PACKET_QUEUE_3, /* H2N Data packets on queue3 */ - NSS_DRV_STATS_TX_PACKET_QUEUE_4, /* H2N Data packets on queue4 */ - NSS_DRV_STATS_TX_PACKET_QUEUE_5, /* H2N Data packets on queue5 */ - NSS_DRV_STATS_TX_PACKET_QUEUE_6, /* H2N Data packets on queue6 */ - NSS_DRV_STATS_TX_PACKET_QUEUE_7, /* H2N Data packets on queue7 */ -#endif - NSS_DRV_STATS_MAX, -}; - -extern void nss_drv_stats_dentry_create(void); -extern ssize_t nss_wt_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos); -#endif /* __NSS_DRV_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_drv_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_drv_strings.c deleted file mode 100644 index 259561525..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_drv_strings.c +++ /dev/null @@ -1,92 +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" - -/* - * nss_drv_strings_stats - * Host driver stats names. - */ -struct nss_stats_info nss_drv_strings_stats[NSS_DRV_STATS_MAX] = { - {"nbuf_alloc_errors" , NSS_STATS_TYPE_ERROR}, - {"paged_buf_alloc_errors" , NSS_STATS_TYPE_ERROR}, - {"tx_queue_full[0]" , NSS_STATS_TYPE_ERROR}, - {"tx_queue_full[1]" , NSS_STATS_TYPE_ERROR}, - {"tx_buffers_empty" , NSS_STATS_TYPE_SPECIAL}, - {"tx_paged_buffers_empty" , NSS_STATS_TYPE_SPECIAL}, - {"tx_buffer_pkt" , NSS_STATS_TYPE_SPECIAL}, - {"tx_buffers_cmd" , NSS_STATS_TYPE_SPECIAL}, - {"tx_buffers_crypto" , NSS_STATS_TYPE_SPECIAL}, - {"tx_buffers_reuse" , NSS_STATS_TYPE_SPECIAL}, - {"rx_buffers_empty" , NSS_STATS_TYPE_SPECIAL}, - {"rx_buffers_pkt" , NSS_STATS_TYPE_SPECIAL}, - {"rx_buffers_ext_pkt" , NSS_STATS_TYPE_SPECIAL}, - {"rx_buffers_cmd_resp" , NSS_STATS_TYPE_SPECIAL}, - {"rx_buffers_status_sync" , NSS_STATS_TYPE_SPECIAL}, - {"rx_buffers_crypto" , NSS_STATS_TYPE_SPECIAL}, - {"rx_buffers_virtual" , NSS_STATS_TYPE_SPECIAL}, - {"tx_skb_simple" , NSS_STATS_TYPE_SPECIAL}, - {"tx_skb_nr_frags" , NSS_STATS_TYPE_SPECIAL}, - {"tx_skb_fraglist" , NSS_STATS_TYPE_SPECIAL}, - {"rx_skb_simple" , NSS_STATS_TYPE_SPECIAL}, - {"rx_skb_nr_frags" , NSS_STATS_TYPE_SPECIAL}, - {"rx_skb_fraglist" , NSS_STATS_TYPE_SPECIAL}, - {"rx_bad_desciptor" , NSS_STATS_TYPE_ERROR}, - {"invalid_interface" , NSS_STATS_TYPE_ERROR}, - {"invalid_core_id" , NSS_STATS_TYPE_ERROR}, - {"invalid_buffer_type" , NSS_STATS_TYPE_ERROR}, - {"nss_skb_count" , NSS_STATS_TYPE_SPECIAL}, - {"rx_chain_seg_processed" , NSS_STATS_TYPE_SPECIAL}, - {"rx_frag_seg_processed" , NSS_STATS_TYPE_SPECIAL}, - {"tx_buffers_cmd_queue_full" , NSS_STATS_TYPE_ERROR}, -#ifdef NSS_MULTI_H2N_DATA_RING_SUPPORT - {"tx_buffers_data_queue[0]" , NSS_STATS_TYPE_SPECIAL}, - {"tx_buffers_data_queue[1]" , NSS_STATS_TYPE_SPECIAL}, - {"tx_buffers_data_queue[2]" , NSS_STATS_TYPE_SPECIAL}, - {"tx_buffers_data_queue[3]" , NSS_STATS_TYPE_SPECIAL}, - {"tx_buffers_data_queue[4]" , NSS_STATS_TYPE_SPECIAL}, - {"tx_buffers_data_queue[5]" , NSS_STATS_TYPE_SPECIAL}, - {"tx_buffers_data_queue[6]" , NSS_STATS_TYPE_SPECIAL}, - {"tx_buffers_data_queue[7]" , NSS_STATS_TYPE_SPECIAL}, -#endif -}; - -/* - * nss_drv_strings_read() - * Read drv node statistics names. - */ -static ssize_t nss_drv_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_drv_strings_stats, NSS_DRV_STATS_MAX); -} - -/* - * nss_drv_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(drv); - -/* - * nss_drv_strings_dentry_create() - * Create drv statistics strings debug entry. - */ -void nss_drv_strings_dentry_create(void) -{ - nss_strings_create_dentry("drv", &nss_drv_strings_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_drv_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_drv_strings.h deleted file mode 100644 index 72a1fd7a0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_drv_strings.h +++ /dev/null @@ -1,26 +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_DRV_STRINGS_H -#define __NSS_DRV_STRINGS_H - -extern struct nss_stats_info nss_drv_strings_stats[NSS_DRV_STATS_MAX]; - -extern void nss_drv_strings_dentry_create(void); - -#endif /* __NSS_DRV_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dscp_map.h b/feeds/ipq807x/qca-nss-drv/src/nss_dscp_map.h deleted file mode 100644 index 441dc11ac..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dscp_map.h +++ /dev/null @@ -1,212 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_dscp_map.h - * NSS dscp map parse APIs - */ - -#include "nss_tx_rx_common.h" - -#define NSS_DSCP_MAP_PARAM_FIELD_COUNT 3 -#define NSS_DSCP_MAP_ARRAY_SIZE 64 -#define NSS_DSCP_MAP_PRIORITY_MAX NSS_MAX_NUM_PRI - -/* - * nss dscp map entry structure. - */ -struct nss_dscp_map_entry { - uint8_t action; /* Action associated with the DSCP value.*/ - uint8_t priority; /* Priority associated with the DSCP value. */ -}; - -/* - * nss dscp map parse output. - */ -struct nss_dscp_map_parse { - uint8_t dscp; /* Parsed dscp value */ - uint8_t action; /* Parsed action value */ - uint8_t priority; /* Parsed priority value */ -}; - -/* - * nss_dscp_map_print() - * Sysctl handler for printing dscp/pri mapping. - */ -static int nss_dscp_map_print(struct ctl_table *ctl, void __user *buffer, size_t *lenp, - loff_t *ppos, struct nss_dscp_map_entry *mapping) -{ - char *r_buf; - int i, len; - size_t cp_bytes = 0; - - /* - * (64 * 8) + 22 bytes for the buffer size is sufficient to write - * the table including the spaces and new line characters. - */ - r_buf = kzalloc(((NSS_DSCP_MAP_ARRAY_SIZE * 8) + 22) * sizeof(char), GFP_KERNEL); - if (!r_buf) { - nss_warning("Failed to alloc buffer to print dscp map table\n"); - return -EFAULT; - } - - /* - * Write the priority values to the first line of the output. - */ - len = scnprintf(r_buf + cp_bytes, 11, "%s: ", "priority"); - cp_bytes += len; - for (i = 0; i < NSS_DSCP_MAP_ARRAY_SIZE; i++) { - len = scnprintf(r_buf + cp_bytes, 4, "%d ", mapping[i].priority); - if (!len) { - nss_warning("failed to read from buffer %d\n", mapping[i].priority); - kfree(r_buf); - return -EFAULT; - } - cp_bytes += len; - } - - /* - * Add new line character at the end. - */ - len = scnprintf(r_buf + cp_bytes, 4, "\n"); - cp_bytes += len; - - /* - * Write the action values to the second line of the output. - */ - len = scnprintf(r_buf + cp_bytes, 11, "%s: ", "action"); - cp_bytes += len; - for (i = 0; i < NSS_DSCP_MAP_ARRAY_SIZE; i++) { - len = scnprintf(r_buf + cp_bytes, 4, "%d ", mapping[i].action); - if (!len) { - nss_warning("failed to read from buffer %d\n", mapping[i].action); - kfree(r_buf); - return -EFAULT; - } - cp_bytes += len; - } - - /* - * Add new line character at the end. - */ - len = scnprintf(r_buf + cp_bytes, 4, "\n"); - cp_bytes += len; - - cp_bytes = simple_read_from_buffer(buffer, *lenp, ppos, r_buf, cp_bytes); - *lenp = cp_bytes; - kfree(r_buf); - return 0; -} - -/* - * nss_dscp_map_parse() - * Sysctl handler for dscp/pri mappings. - */ -static int nss_dscp_map_parse(struct ctl_table *ctl, void __user *buffer, size_t *lenp, - loff_t *ppos, struct nss_dscp_map_parse *out) -{ - int count; - size_t cp_bytes = 0; - char w_buf[7]; - loff_t w_offset = 0; - char *str; - char *tokens[NSS_DSCP_MAP_PARAM_FIELD_COUNT]; - unsigned int dscp, priority, action; - int ret; - - /* - * Buffer length cannot be more than 7 and less than 6. - */ - if (*lenp < 6 || *lenp > 7) { - nss_warning("Buffer is not correct. Invalid lenght: %d\n", (int)*lenp); - return -EINVAL; - } - - /* - * It's a write operation - */ - cp_bytes = simple_write_to_buffer(w_buf, *lenp, &w_offset, buffer, 7); - if (cp_bytes != *lenp) { - nss_warning("failed to write to buffer\n"); - return -EFAULT; - } - - count = 0; - str = w_buf; - tokens[count] = strsep(&str, " "); - while (tokens[count] != NULL) { - count++; - if (count == NSS_DSCP_MAP_PARAM_FIELD_COUNT) { - nss_warning("maximum allowed field count is %d\n", NSS_DSCP_MAP_PARAM_FIELD_COUNT); - break; - } - tokens[count] = strsep(&str, " "); - } - - /* - * Did we read enough number of parameters from the command line. - * There must be 2 parameters. - */ - if (count != NSS_DSCP_MAP_PARAM_FIELD_COUNT) { - nss_warning("param fields are less than expected: %d\n", count); - return -EINVAL; - } - - /* - * Write the tokens to integers. - */ - ret = sscanf(tokens[0], "%u", &dscp); - if (ret != 1) { - nss_warning("failed to write the dscp token to integer\n"); - return -EFAULT; - } - - ret = sscanf(tokens[1], "%u", &action); - if (ret != 1) { - nss_warning("failed to write the action token to integer\n"); - return -EFAULT; - } - - ret = sscanf(tokens[2], "%u", &priority); - if (ret != 1) { - nss_warning("failed to write the priority token to integer\n"); - return -EFAULT; - } - - /* - * dscp value cannot be higher than 63. - */ - if (dscp >= NSS_DSCP_MAP_ARRAY_SIZE) { - nss_warning("invalid dscp value: %d\n", dscp); - return -EINVAL; - } - - /* - * Priority must be less than NSS_DSCP_MAP_PRIORITY_MAX which is 4. - */ - if (priority >= NSS_DSCP_MAP_PRIORITY_MAX) { - nss_warning("invalid priority value: %d\n", priority); - return -EINVAL; - } - - nss_info("dscp: %d action: %d priority: %d\n", dscp, action, priority); - - out->dscp = dscp; - out->action = action; - out->priority = priority; - - return 0; -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dtls.c b/feeds/ipq807x/qca-nss-drv/src/nss_dtls.c deleted file mode 100644 index 6d7c1a1ce..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dtls.c +++ /dev/null @@ -1,468 +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_tx_rx_common.h" -#include "nss_dtls_stats.h" -#include "nss_dtls_log.h" - -#define NSS_DTLS_TX_TIMEOUT 3000 /* 3 Seconds */ - -/* - * Data structures to store DTLS nss debug stats - */ -static DEFINE_SPINLOCK(nss_dtls_session_stats_lock); -static struct nss_dtls_stats_session session_stats[NSS_MAX_DTLS_SESSIONS]; - -/* - * Private data structure - */ -static struct nss_dtls_pvt { - struct semaphore sem; - struct completion complete; - int response; - void *cb; - void *app_data; -} dtls_pvt; - -/* - * nss_dtls_verify_if_num() - * Verify if_num passed to us. - */ -static bool nss_dtls_verify_if_num(uint32_t if_num) -{ - if (nss_is_dynamic_interface(if_num) == false) - return false; - - if (nss_dynamic_interface_get_type(nss_dtls_get_context(), if_num) - != NSS_DYNAMIC_INTERFACE_TYPE_DTLS) - return false; - - return true; -} - -/* - * nss_dtls_session_stats_sync - * Per DTLS session debug stats - */ -static void nss_dtls_session_stats_sync(struct nss_ctx_instance *nss_ctx, - struct nss_dtls_session_stats *stats_msg, - uint16_t if_num) -{ - int i; - struct nss_dtls_stats_session *s = NULL; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - spin_lock_bh(&nss_dtls_session_stats_lock); - for (i = 0; i < NSS_MAX_DTLS_SESSIONS; i++) { - if (session_stats[i].if_num != if_num) { - continue; - } - - s = &session_stats[i]; - break; - } - - if (!s) { - spin_unlock_bh(&nss_dtls_session_stats_lock); - return; - } - - s->stats[NSS_DTLS_STATS_SESSION_RX_PKTS] += stats_msg->node_stats.rx_packets; - s->stats[NSS_DTLS_STATS_SESSION_TX_PKTS] += stats_msg->node_stats.tx_packets; - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - s->stats[NSS_DTLS_STATS_SESSION_RX_QUEUE_0_DROPPED + i] += stats_msg->node_stats.rx_dropped[i]; - } - s->stats[NSS_DTLS_STATS_SESSION_RX_AUTH_DONE] += stats_msg->rx_auth_done; - s->stats[NSS_DTLS_STATS_SESSION_TX_AUTH_DONE] += stats_msg->tx_auth_done; - s->stats[NSS_DTLS_STATS_SESSION_RX_CIPHER_DONE] += stats_msg->rx_cipher_done; - s->stats[NSS_DTLS_STATS_SESSION_TX_CIPHER_DONE] += stats_msg->tx_cipher_done; - s->stats[NSS_DTLS_STATS_SESSION_RX_CBUF_ALLOC_FAIL] += stats_msg->rx_cbuf_alloc_fail; - s->stats[NSS_DTLS_STATS_SESSION_TX_CBUF_ALLOC_FAIL] += stats_msg->tx_cbuf_alloc_fail; - s->stats[NSS_DTLS_STATS_SESSION_TX_CENQUEUE_FAIL] += stats_msg->tx_cenqueue_fail; - s->stats[NSS_DTLS_STATS_SESSION_RX_CENQUEUE_FAIL] += stats_msg->rx_cenqueue_fail; - s->stats[NSS_DTLS_STATS_SESSION_TX_DROPPED_HROOM] += stats_msg->tx_dropped_hroom; - s->stats[NSS_DTLS_STATS_SESSION_TX_DROPPED_TROOM] += stats_msg->tx_dropped_troom; - s->stats[NSS_DTLS_STATS_SESSION_TX_FORWARD_ENQUEUE_FAIL] += stats_msg->tx_forward_enqueue_fail; - s->stats[NSS_DTLS_STATS_SESSION_RX_FORWARD_ENQUEUE_FAIL] += stats_msg->rx_forward_enqueue_fail; - s->stats[NSS_DTLS_STATS_SESSION_RX_INVALID_VERSION] += stats_msg->rx_invalid_version; - s->stats[NSS_DTLS_STATS_SESSION_RX_INVALID_EPOCH] += stats_msg->rx_invalid_epoch; - s->stats[NSS_DTLS_STATS_SESSION_RX_MALFORMED] += stats_msg->rx_malformed; - s->stats[NSS_DTLS_STATS_SESSION_RX_CIPHER_FAIL] += stats_msg->rx_cipher_fail; - s->stats[NSS_DTLS_STATS_SESSION_RX_AUTH_FAIL] += stats_msg->rx_auth_fail; - s->stats[NSS_DTLS_STATS_SESSION_RX_CAPWAP_CLASSIFY_FAIL] += stats_msg->rx_capwap_classify_fail; - s->stats[NSS_DTLS_STATS_SESSION_RX_SINGLE_REC_DGRAM] += stats_msg->rx_single_rec_dgram; - s->stats[NSS_DTLS_STATS_SESSION_RX_MULTI_REC_DGRAM] += stats_msg->rx_multi_rec_dgram; - s->stats[NSS_DTLS_STATS_SESSION_RX_REPLAY_FAIL] += stats_msg->rx_replay_fail; - s->stats[NSS_DTLS_STATS_SESSION_RX_REPLAY_DUPLICATE] += stats_msg->rx_replay_duplicate; - s->stats[NSS_DTLS_STATS_SESSION_RX_REPLAY_OUT_OF_WINDOW] += stats_msg->rx_replay_out_of_window; - s->stats[NSS_DTLS_STATS_SESSION_OUTFLOW_QUEUE_FULL] += stats_msg->outflow_queue_full; - s->stats[NSS_DTLS_STATS_SESSION_DECAP_QUEUE_FULL] += stats_msg->decap_queue_full; - s->stats[NSS_DTLS_STATS_SESSION_PBUF_ALLOC_FAIL] += stats_msg->pbuf_alloc_fail; - s->stats[NSS_DTLS_STATS_SESSION_PBUF_COPY_FAIL] += stats_msg->pbuf_copy_fail; - s->stats[NSS_DTLS_STATS_SESSION_EPOCH] = stats_msg->epoch; - s->stats[NSS_DTLS_STATS_SESSION_TX_SEQ_HIGH] = stats_msg->tx_seq_high; - s->stats[NSS_DTLS_STATS_SESSION_TX_SEQ_LOW] = stats_msg->tx_seq_low; - spin_unlock_bh(&nss_dtls_session_stats_lock); -} - -/* - * nss_dtls_session_stats_get() - * Get session DTLS statitics. - */ -void nss_dtls_session_stats_get(struct nss_dtls_stats_session *stats) -{ - int i; - - if (!stats) { - nss_warning("No memory to copy dtls session stats"); - return; - } - - spin_lock_bh(&nss_dtls_session_stats_lock); - for (i = 0; i < NSS_MAX_DTLS_SESSIONS; i++) { - if (session_stats[i].valid) { - memcpy(stats, &session_stats[i], - sizeof(struct nss_dtls_stats_session)); - stats++; - } - } - spin_unlock_bh(&nss_dtls_session_stats_lock); -} - -/* - * nss_dtls_handler() - * Handle NSS -> HLOS messages for dtls tunnel - */ -static void nss_dtls_handler(struct nss_ctx_instance *nss_ctx, - struct nss_cmn_msg *ncm, - __attribute__((unused))void *app_data) -{ - struct nss_dtls_msg *ntm = (struct nss_dtls_msg *)ncm; - void *ctx; - - nss_dtls_msg_callback_t cb; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - BUG_ON(!nss_dtls_verify_if_num(ncm->interface)); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_DTLS_MSG_MAX) { - 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("%px: dtls message length is invalid: %d", - nss_ctx, ncm->len); - return; - } - - switch (ntm->cm.type) { - case NSS_DTLS_MSG_SESSION_STATS: - nss_dtls_session_stats_sync(nss_ctx, - &ntm->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_ctx->nss_top->dtls_msg_callback; - ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].app_data; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Trace messages. - */ - nss_dtls_log_rx_msg(ntm); - - /* - * callback - */ - cb = (nss_dtls_msg_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - /* - * call dtls session callback - */ - if (!cb) { - nss_warning("%px: No callback for dtls session interface %d", - nss_ctx, ncm->interface); - return; - } - - cb(ctx, ntm); -} - -/* - * nss_dtls_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_dtls_callback(void *app_data, struct nss_dtls_msg *nim) -{ - nss_dtls_msg_callback_t callback = (nss_dtls_msg_callback_t)dtls_pvt.cb; - void *data = dtls_pvt.app_data; - - dtls_pvt.cb = NULL; - dtls_pvt.app_data = NULL; - - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("dtls Error response %d\n", nim->cm.response); - - dtls_pvt.response = NSS_TX_FAILURE; - if (callback) { - callback(data, nim); - } - - complete(&dtls_pvt.complete); - return; - } - - dtls_pvt.response = NSS_TX_SUCCESS; - if (callback) { - callback(data, nim); - } - - complete(&dtls_pvt.complete); -} - -/* - * nss_dtls_tx_buf() - * Transmit buffer over DTLS interface - */ -nss_tx_status_t nss_dtls_tx_buf(struct sk_buff *skb, uint32_t if_num, - struct nss_ctx_instance *nss_ctx) -{ - BUG_ON(!nss_dtls_verify_if_num(if_num)); - - return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_VIRTUAL_BUFFER | H2N_BIT_FLAG_BUFFER_REUSABLE); -} -EXPORT_SYMBOL(nss_dtls_tx_buf); - -/* - * nss_dtls_tx_msg() - * Transmit a DTLS message to NSS firmware - */ -nss_tx_status_t nss_dtls_tx_msg(struct nss_ctx_instance *nss_ctx, - struct nss_dtls_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Sanity check the message - */ - BUG_ON(!nss_dtls_verify_if_num(ncm->interface)); - - if (ncm->type > NSS_DTLS_MSG_MAX) { - nss_warning("%px: dtls message type out of range: %d", - nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - /* - * Trace messages. - */ - nss_dtls_log_tx_msg(msg); - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_dtls_tx_msg); - -/* - * nss_dtls_tx_msg() - * Transmit a DTLS message to NSS firmware synchronously. - */ -nss_tx_status_t nss_dtls_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_dtls_msg *msg) -{ - - nss_tx_status_t status; - int ret = 0; - - down(&dtls_pvt.sem); - dtls_pvt.cb = (void *)msg->cm.cb; - dtls_pvt.app_data = (void *)msg->cm.app_data; - - msg->cm.cb = (nss_ptr_t)nss_dtls_callback; - msg->cm.app_data = (nss_ptr_t)NULL; - - status = nss_dtls_tx_msg(nss_ctx, msg); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: dtls_tx_msg failed\n", nss_ctx); - up(&dtls_pvt.sem); - return status; - } - - ret = wait_for_completion_timeout(&dtls_pvt.complete, msecs_to_jiffies(NSS_DTLS_TX_TIMEOUT)); - - if (!ret) { - nss_warning("%px: DTLS msg tx failed due to timeout\n", nss_ctx); - dtls_pvt.response = NSS_TX_FAILURE; - } - - status = dtls_pvt.response; - up(&dtls_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_dtls_tx_msg_sync); - -/* - *********************************** - * Register/Unregister/Miscellaneous APIs - *********************************** - */ - -/* - * nss_dtls_register_if() - */ -struct nss_ctx_instance *nss_dtls_register_if(uint32_t if_num, - nss_dtls_data_callback_t cb, - nss_dtls_msg_callback_t ev_cb, - struct net_device *netdev, - uint32_t features, - void *app_ctx) -{ - int32_t i; - - struct nss_ctx_instance *nss_ctx = nss_dtls_get_context(); - - BUG_ON(!nss_dtls_verify_if_num(if_num)); - - spin_lock_bh(&nss_dtls_session_stats_lock); - for (i = 0; i < NSS_MAX_DTLS_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; - break; - } - } - spin_unlock_bh(&nss_dtls_session_stats_lock); - - if (i == NSS_MAX_DTLS_SESSIONS) { - 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("%px: Cannot find free slot for " - "DTLS NSS I/F:%u\n", nss_ctx, if_num); - - return NULL; - } - - nss_core_register_subsys_dp(nss_ctx, if_num, cb, NULL, app_ctx, netdev, features); - nss_ctx->subsys_dp_register[if_num].type = NSS_DYNAMIC_INTERFACE_TYPE_DTLS; - - nss_top_main.dtls_msg_callback = ev_cb; - nss_core_register_handler(nss_ctx, if_num, nss_dtls_handler, app_ctx); - - return nss_ctx; -} -EXPORT_SYMBOL(nss_dtls_register_if); - -/* - * nss_dtls_unregister_if() - */ -void nss_dtls_unregister_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_dtls_get_context(); - int32_t i; - - BUG_ON(!nss_dtls_verify_if_num(if_num)); - - spin_lock_bh(&nss_dtls_session_stats_lock); - for (i = 0; i < NSS_MAX_DTLS_SESSIONS; i++) { - if (session_stats[i].if_num == if_num) { - memset(&session_stats[i], 0, - sizeof(struct nss_dtls_stats_session)); - break; - } - } - spin_unlock_bh(&nss_dtls_session_stats_lock); - - if (i == NSS_MAX_DTLS_SESSIONS) { - 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("%px: Cannot find registered netdev for DTLS NSS I/F:%u\n", nss_ctx, if_num); - - return; - } - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - nss_top_main.dtls_msg_callback = NULL; - nss_core_unregister_handler(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_dtls_unregister_if); - -/* - * nss_get_dtls_context() - */ -struct nss_ctx_instance *nss_dtls_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.dtls_handler_id]; -} -EXPORT_SYMBOL(nss_dtls_get_context); - -/* - * nss_dtls_msg_init() - * Initialize nss_dtls msg. - */ -void nss_dtls_msg_init(struct nss_dtls_msg *ncm, uint16_t if_num, - uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} -EXPORT_SYMBOL(nss_dtls_msg_init); - -/* - * nss_dtls_get_ifnum_with_coreid() - */ -int32_t nss_dtls_get_ifnum_with_coreid(int32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_dtls_get_context(); - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - return NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_dtls_get_ifnum_with_coreid); - -/* - * nss_dtls_register_handler() - */ -void nss_dtls_register_handler(void) -{ - sema_init(&dtls_pvt.sem, 1); - init_completion(&dtls_pvt.complete); - - nss_dtls_stats_dentry_create(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn.c b/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn.c deleted file mode 100644 index 024d217d5..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2017-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_dtls_cmn_log.h" -#include "nss_dtls_cmn_stats.h" -#include "nss_dtls_cmn_strings.h" - -#define NSS_DTLS_CMN_TX_TIMEOUT 3000 /* 3 Seconds */ -#define NSS_DTLS_CMN_INTERFACE_MAX_LONG BITS_TO_LONGS(NSS_MAX_NET_INTERFACES) - -/* - * Private data structure. - */ -static struct nss_dtls_cmn_pvt { - struct semaphore sem; - struct completion complete; - enum nss_dtls_cmn_error resp; - unsigned long if_map[NSS_DTLS_CMN_INTERFACE_MAX_LONG]; -} dtls_cmn_pvt; - -/* - * nss_dtls_cmn_verify_ifnum() - * Verify if the interface number is a DTLS interface. - */ -static bool nss_dtls_cmn_verify_ifnum(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - enum nss_dynamic_interface_type type = nss_dynamic_interface_get_type(nss_ctx, if_num); - - if (type == NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_INNER) - return true; - - if (type == NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_OUTER) - return true; - - if (if_num == NSS_DTLS_INTERFACE) - return true; - - return false; -} - -/* - * nss_dtls_cmn_handler() - * Handle NSS -> HLOS messages for dtls tunnel. - */ -static void nss_dtls_cmn_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *data) -{ - nss_dtls_cmn_msg_callback_t cb; - void *app_data; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - nss_trace("%px: handle event for interface num :%u", nss_ctx, ncm->interface); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_DTLS_CMN_MSG_MAX) { - nss_warning("%px:Bad message type(%d) for DTLS interface %d", nss_ctx, ncm->type, ncm->interface); - return; - } - - if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_dtls_cmn_msg)) { - nss_warning("%px:Bad message length(%d)", nss_ctx, ncm->len); - return; - } - - 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); - } - - /* - * 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; - } - - /* - * Log failures. - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Trace messages. - */ - nss_dtls_cmn_log_rx_msg((struct nss_dtls_cmn_msg *)ncm); - - /* - * Callback. - */ - cb = (nss_dtls_cmn_msg_callback_t)ncm->cb; - app_data = (void *)ncm->app_data; - - /* - * Call DTLS session callback. - */ - if (!cb) { - nss_warning("%px: No callback for dtls session interface %d", nss_ctx, ncm->interface); - return; - } - - nss_trace("%px: calling dtlsmgr event handler(%u)", nss_ctx, ncm->interface); - cb(app_data, ncm); -} - -/* - * nss_dtls_cmn_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_dtls_cmn_callback(void *app_data, struct nss_cmn_msg *ncm) -{ - /* - * This callback is for synchronous operation. The caller sends its - * response pointer which needs to be loaded with the response - * data arriving from the NSS. - */ - enum nss_dtls_cmn_error *resp = (enum nss_dtls_cmn_error *)app_data; - - *resp = (ncm->response == NSS_CMN_RESPONSE_ACK) ? NSS_DTLS_CMN_ERROR_NONE : ncm->error; - complete(&dtls_cmn_pvt.complete); - - return; -} - -/* - * 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. - */ -nss_tx_status_t nss_dtls_cmn_tx_buf(struct sk_buff *skb, uint32_t if_num, struct nss_ctx_instance *nss_ctx) -{ - if (!nss_dtls_cmn_verify_ifnum(nss_ctx, if_num)) - return NSS_TX_FAILURE; - - return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_VIRTUAL_BUFFER | H2N_BIT_FLAG_BUFFER_REUSABLE); -} -EXPORT_SYMBOL(nss_dtls_cmn_tx_buf); - -/* - * nss_dtls_cmn_tx_msg() - * Transmit a DTLS message to NSS firmware. - */ -nss_tx_status_t nss_dtls_cmn_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_dtls_cmn_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - if (ncm->type >= NSS_DTLS_CMN_MSG_MAX) { - 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("%px: dtls message interface is bad: %u", nss_ctx, ncm->interface); - return NSS_TX_FAILURE; - } - - /* - * Trace messages. - */ - nss_dtls_cmn_log_tx_msg(msg); - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_dtls_cmn_tx_msg); - -/* - * nss_dtls_cmn_tx_msg_sync() - * Transmit a DTLS message to NSS firmware synchronously. - */ -nss_tx_status_t nss_dtls_cmn_tx_msg_sync(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - enum nss_dtls_cmn_msg_type type, uint16_t len, - struct nss_dtls_cmn_msg *ndcm, enum nss_dtls_cmn_error *resp) -{ - struct nss_dtls_cmn_msg ndcm_local; - nss_tx_status_t status; - int ret; - - /* - * Length of the message should be the based on type. - */ - if (len > sizeof(ndcm_local.msg)) { - nss_warning("%px: (%u)Bad message length(%u) for type (%d)", nss_ctx, if_num, len, type); - return NSS_TX_FAILURE_TOO_LARGE; - } - - /* - * Response buffer is a required for copying the response for message. - */ - if (!resp) { - nss_warning("%px: (%u)Response buffer is empty, type(%d)", nss_ctx, if_num, type); - return NSS_TX_FAILURE_BAD_PARAM; - } - - /* - * TODO: this can be removed in future as we need to ensure that the response - * memory is only updated when the current outstanding request is waiting. - * This can be solved by introducing sequence no. in messages and only completing - * the message if the sequence no. matches. For now this is solved by passing - * a known memory dtls_cmn_pvt.resp. - */ - down(&dtls_cmn_pvt.sem); - - /* - * We need to copy the message content into the actual message - * to be sent to NSS. - */ - nss_dtls_cmn_msg_init(&ndcm_local, if_num, type, len, nss_dtls_cmn_callback, &dtls_cmn_pvt.resp); - memcpy(&ndcm_local.msg, &ndcm->msg, len); - - status = nss_dtls_cmn_tx_msg(nss_ctx, &ndcm_local); - if (status != NSS_TX_SUCCESS) { - 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("%px: DTLS msg tx failed due to timeout", nss_ctx); - status = NSS_TX_FAILURE_NOT_READY; - goto done; - } - - /* - * Read memory barrier. - */ - smp_rmb(); - - /* - * Copy the response received. - */ - *resp = dtls_cmn_pvt.resp; - - /* - * Only in case of non-error response we will - * indicate success. - */ - if (dtls_cmn_pvt.resp != NSS_DTLS_CMN_ERROR_NONE) - status = NSS_TX_FAILURE; - -done: - up(&dtls_cmn_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_dtls_cmn_tx_msg_sync); - -/* - * nss_dtls_cmn_notify_register() - * Register a handler for notification from NSS firmware. - */ -struct nss_ctx_instance *nss_dtls_cmn_notify_register(uint32_t if_num, nss_dtls_cmn_msg_callback_t ev_cb, - void *app_data) -{ - struct nss_ctx_instance *nss_ctx = nss_dtls_cmn_get_context(); - uint32_t ret; - - BUG_ON(!nss_ctx); - - ret = nss_core_register_handler(nss_ctx, if_num, nss_dtls_cmn_handler, app_data); - if (ret != NSS_CORE_STATUS_SUCCESS) { - nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num); - return NULL; - } - - 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; -} -EXPORT_SYMBOL(nss_dtls_cmn_notify_register); - -/* - * nss_dtls_cmn_notify_unregister() - * Unregister notification callback handler. - */ -void nss_dtls_cmn_notify_unregister(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_dtls_cmn_get_context(); - uint32_t ret; - - BUG_ON(!nss_ctx); - - 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; - } - - 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; -} -EXPORT_SYMBOL(nss_dtls_cmn_notify_unregister); - -/* - * nss_dtls_cmn_register_if() - * Register data and event callback handlers for dynamic interface. - */ -struct nss_ctx_instance *nss_dtls_cmn_register_if(uint32_t if_num, - nss_dtls_cmn_data_callback_t data_cb, - nss_dtls_cmn_msg_callback_t ev_cb, - struct net_device *netdev, - uint32_t features, - uint32_t type, - void *app_data) -{ - struct nss_ctx_instance *nss_ctx = nss_dtls_cmn_get_context(); - uint32_t ret; - - if (!nss_dtls_cmn_verify_ifnum(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("%px: Cannot find free slot for DTLS NSS I/F:%u", nss_ctx, if_num); - return NULL; - } - - nss_core_register_subsys_dp(nss_ctx, if_num, data_cb, NULL, app_data, netdev, features); - nss_ctx->subsys_dp_register[if_num].type = type; - - ret = nss_core_register_handler(nss_ctx, if_num, nss_dtls_cmn_handler, app_data); - if (ret != NSS_CORE_STATUS_SUCCESS) { - nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num); - return NULL; - } - - 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. - */ - set_bit(if_num, dtls_cmn_pvt.if_map); - return nss_ctx; -} -EXPORT_SYMBOL(nss_dtls_cmn_register_if); - -/* - * nss_dtls_cmn_unregister_if() - * Unregister data and event callback handlers for the interface. - */ -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("%px: Cannot find registered netdev for DTLS NSS I/F:%u", nss_ctx, if_num); - return; - } - - /* - * Atomically clear the bitmap for the interface number. - */ - 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_core_unregister_subsys_dp(nss_ctx, if_num); - nss_ctx->subsys_dp_register[if_num].type = 0; -} -EXPORT_SYMBOL(nss_dtls_cmn_unregister_if); - -/* - * nss_dtls_get_context() - * Return DTLS NSS context. - */ -struct nss_ctx_instance *nss_dtls_cmn_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.dtls_handler_id]; -} -EXPORT_SYMBOL(nss_dtls_cmn_get_context); - -/* - * nss_dtls_cmn_msg_init() - * Initialize nss_dtls_cmn msg. - */ -void nss_dtls_cmn_msg_init(struct nss_dtls_cmn_msg *ncm, uint32_t if_num, - uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} -EXPORT_SYMBOL(nss_dtls_cmn_msg_init); - -/* - * nss_dtls_cmn_get_ifnum() - * Return DTLS interface number with coreid. - */ -int32_t nss_dtls_cmn_get_ifnum(int32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_dtls_cmn_get_context(); - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - return NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_dtls_cmn_get_ifnum); - -/* - * nss_dtls_cmn_register_handler() - * DTLS initialization. - */ -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(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_log.c deleted file mode 100644 index 41ad37c44..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_log.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_dtls_cmn_log.c - * NSS DTLS common logger file. - */ - -#include "nss_core.h" - -/* - * nss_dtls_cmn_log_message_types_str - * DTLS common message strings - */ -static int8_t *nss_dtls_cmn_log_message_types_str[NSS_DTLS_CMN_MSG_MAX] __maybe_unused = { - "DTLS_CMN Configure Node", - "DTLS_CMN Configure Base Context Parameter", - "DTLS_CMN Configure DTLS Parameters", - "DTLS_CMN Switch DTLS Transform", - "DTLS_CMN Deconfigure Context", - "DTLS_CMN Synchronize Stats", - "DTLS_CMN Node Statistics" -}; - -/* - * nss_dtls_cmn_log_error_response_types_str - * Strings for error types for DTLS common messages - */ -static int8_t *nss_dtls_cmn_log_error_response_types_str[NSS_DTLS_CMN_ERROR_MAX] __maybe_unused = { - "DTLS_CMN No Error", - "DTLS_CMN Unknown MEssage", - "DTLS_CMN Invalid Destination Interface", - "DTLS_CMN Invalid Source Interface", - "DTLS_CMN Invalid Crypto", - "DTLS_CMN Invalid Version", - "DTLS_CMN Invalid Context Type", - "DTLS_CMN Invalid Context Words", - "DTLS_CMN Hardware Context Alloc Fail", - "DTLS_CMN Copy Context Failure", - "DTLS_CMN Switch Hardware Context Fail", - "DTLS_CMN Already Configured", - "DTLS_CMN No Memory", - "DTLS_CMN Copy Nonce Failure" -}; - -/* - * nss_dtls_cmn_hdr_config_msg() - * Log DTLS common header configure message. - */ -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("%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: %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" - "DTLS_CMN dscp value: %x\n" - "DTLS_CMN dscp copy value: %x\n" - "DTLS_CMN DF flag: %x\n", - ndchm, ndchm->flags, - ndchm->dest_ifnum, ndchm->src_ifnum, - &ndchm->sip, &ndchm->dip, - ndchm->sport, ndchm->dport, - ndchm->hop_limit_ttl, ndchm->dscp, - ndchm->dscp_copy, ndchm->df); -}; - -/* - * nss_dtls_cmn_dtls_config_msg() - * Log DTLS common dtls configure message. - */ -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("%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" - "DTLS_CMN initial epoch: %d\n" - "DTLS_CMN IV length for encapsulation: %d\n" - "DTLS_CMN authentication hash length for encapsulation: %d\n" - "DTLS_CMN cipher block length: %d\n" - "DTLS_CMN reserved: %x\n", - ndcdm, ndcdm->ver, - ndcdm->crypto_idx, ndcdm->window_size, - ndcdm->epoch, ndcdm->iv_len, - ndcdm->hash_len, ndcdm->blk_len, - ndcdm->res1); -}; - -/* - * nss_dtls_cmn_log_verbose() - * Log message contents. - */ -static void nss_dtls_cmn_log_verbose(struct nss_dtls_cmn_msg *ndm) -{ - switch (ndm->cm.type) { - case NSS_DTLS_CMN_MSG_TYPE_CONFIGURE_HDR: - nss_dtls_cmn_hdr_config_msg(ndm); - break; - - case NSS_DTLS_CMN_MSG_TYPE_CONFIGURE_DTLS: - nss_dtls_cmn_dtls_config_msg(ndm); - break; - - default: - nss_warning("%px: Invalid message type\n", ndm); - break; - } -} - -/* - * nss_dtls_cmn_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_dtls_cmn_log_tx_msg(struct nss_dtls_cmn_msg *ndm) -{ - if (ndm->cm.type >= NSS_DTLS_CMN_MSG_MAX) { - nss_warning("%px: Invalid message type\n", ndm); - return; - } - - 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); -} - -/* - * nss_dtls_cmn_log_rx_msg() - * Log messages received from FW. - */ -void nss_dtls_cmn_log_rx_msg(struct nss_dtls_cmn_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_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("%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("%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]); - -verbose: - nss_dtls_cmn_log_verbose(ndm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_log.h deleted file mode 100644 index 3a5f75566..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_LOG_H -#define __NSS_DTLS_CMN_LOG_H - -/* - * nss_dtls_cmn_log.h - * NSS DTLS Commn Log Header File. - */ - -/* - * nss_dtls_cmn_log_tx_msg - * Logs a DTLS common message that is sent to the NSS firmware. - */ -void nss_dtls_cmn_log_tx_msg(struct nss_dtls_cmn_msg *ndm); - -/* - * nss_dtls_cmn_log_rx_msg - * Logs a DTLS common message that is received from the NSS firmware. - */ -void nss_dtls_cmn_log_rx_msg(struct nss_dtls_cmn_msg *ndm); - -#endif /* __NSS_DTLS_CMN_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_stats.c deleted file mode 100644 index 2908b28e3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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_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 - */ - 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; - 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; - } - - /* - * Common node stats for each DTLS dynamic interface. - */ - 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); - } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - vfree(lbuf); - vfree(stats_shadow); - - return bytes_read; -} - -/* - * 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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_stats.h deleted file mode 100644 index 80e6edfa4..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_strings.c deleted file mode 100644 index 8fc91976a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_dtls_cmn_strings.h deleted file mode 100644 index 0c0bc448d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_dtls_log.c deleted file mode 100644 index 5e1e33e7a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_log.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_dtls_log.c - * NSS DTLS logger file. - */ - -#include "nss_core.h" - -/* - * nss_dtls_log_message_types_str - * DTLS message strings - */ -static int8_t *nss_dtls_log_message_types_str[NSS_DTLS_MSG_MAX] __maybe_unused = { - "DTLS Session Configure", - "DTLS Session Destroy", - "DTLS Session Stats", - "DTLS Encap Cipher Update", - "DTLS Encap Cipher Switch", - "DTLS Decap Cipher Update", - "DTLS Decap Cipher Switch" -}; - -/* - * nss_dtls_log_error_response_types_str - * Strings for error types for DTLS messages - */ -static int8_t *nss_dtls_log_error_response_types_str[NSS_DTLS_ERR_MAX] __maybe_unused = { - "DTLS Unknown Message", - "DTLS Invalid APP Interface", - "DTLS Invalid Parameter", - "DTLS Invalid Version", - "DTLS No Memory" -}; - -/* - * nss_dtls_session_config_msg() - * Log DTLS session configure message. - */ -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("%px: NSS DTLS Session Configure Message:\n" - "DTLS Version: %d\n" - "DTLS Flags: %x\n" - "DTLS crypto index encap: %d\n" - "DTLS crypto index decap: %d\n" - "DTLS IV length for encapsulation: %d\n" - "DTLS IV length for decapsulation: %d\n" - "DTLS authentication hash length for encapsulation: %d\n" - "DTLS authentication hash length for decapsulation: %d\n" - "DTLS cipher algorithm for encapsulation: %x\n" - "DTLS authentication algorithm for encapsulation: %x\n" - "DTLS cipher algorithm for decapsulation: %x\n" - "DTLS authentication algorithm for decapsulation: %x\n" - "DTLS NSS interface: %x\n" - "DTLS source port: %d\n" - "DTLS destination port: %d\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" - "DTLS reserved1 padding: %x\n" - "DTLS reserved2 padding: %x\n", - ndscm, ndscm->ver, - ndscm->flags, ndscm->crypto_idx_encap, - ndscm->crypto_idx_decap, ndscm->iv_len_encap, - ndscm->iv_len_decap, ndscm->hash_len_encap, - ndscm->hash_len_decap, ndscm->cipher_algo_encap, - ndscm->auth_algo_encap, ndscm->cipher_algo_decap, - ndscm->auth_algo_decap, ndscm->nss_app_if, - ndscm->sport, ndscm->dport, - &ndscm->sip, &ndscm->dip, - ndscm->window_size, ndscm->epoch, - ndscm->oip_ttl, ndscm->reserved1, - ndscm->reserved2); -} - -/* - * nss_dtls_session_cipher_upddate_msg() - * Log DTLS Session Cipher Update message. - */ -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("%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" - "DTLS encapsulation cipher: %x\n" - "DTLS encapsulation authentication algorigthm: %x\n" - "DTLS epoch: %d\n" - "DTLS reserved: %x\n", - ndscum, ndscum->crypto_idx, - ndscum->hash_len, ndscum->iv_len, - ndscum->cipher_algo, ndscum->auth_algo, - ndscum->epoch, ndscum->reserved); -} - -/* - * nss_dtls_log_verbose() - * Log message contents. - */ -static void nss_dtls_log_verbose(struct nss_dtls_msg *ndm) -{ - switch (ndm->cm.type) { - case NSS_DTLS_MSG_REKEY_DECAP_CIPHER_UPDATE: - case NSS_DTLS_MSG_REKEY_ENCAP_CIPHER_UPDATE: - nss_dtls_session_cipher_update_msg(ndm); - break; - - case NSS_DTLS_MSG_SESSION_CONFIGURE: - nss_dtls_session_config_msg(ndm); - break; - - default: - nss_warning("%px: Invalid message type\n", ndm); - break; - } -} - -/* - * nss_dtls_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_dtls_log_tx_msg(struct nss_dtls_msg *ndm) -{ - if (ndm->cm.type >= NSS_DTLS_MSG_MAX) { - nss_warning("%px: Invalid message type\n", ndm); - return; - } - - 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); -} - -/* - * nss_dtls_log_rx_msg() - * Log messages received from FW. - */ -void nss_dtls_log_rx_msg(struct nss_dtls_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_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("%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("%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]); - -verbose: - nss_dtls_log_verbose(ndm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_dtls_log.h deleted file mode 100644 index 99fca71a8..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_LOG_H -#define __NSS_DTLS_LOG_H - -/* - * nss_dtls_log.h - * NSS DTLS Log Header File - */ - -/* - * nss_dtls_log_tx_msg - * Logs a DTLS message that is sent to the NSS firmware. - */ -void nss_dtls_log_tx_msg(struct nss_dtls_msg *ndm); - -/* - * nss_dtls_log_rx_msg - * Logs a DTLS message that is received from the NSS firmware. - */ -void nss_dtls_log_rx_msg(struct nss_dtls_msg *ndm); - -#endif /* __NSS_DTLS_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_dtls_stats.c deleted file mode 100644 index 0aeff87b0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_stats.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_stats.h" - -/* - * nss_dtls_stats_session_str - * DTLS statistics strings for nss session stats. - */ -struct nss_stats_info nss_dtls_stats_session_str[NSS_DTLS_STATS_SESSION_MAX] = { - {"rx_pkts" , NSS_STATS_TYPE_COMMON}, - {"tx_pkts" , 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}, - {"rx_auth_done" , NSS_STATS_TYPE_SPECIAL}, - {"tx_auth_done" , NSS_STATS_TYPE_SPECIAL}, - {"rx_cipher_done" , NSS_STATS_TYPE_SPECIAL}, - {"tx_cipher_done" , NSS_STATS_TYPE_SPECIAL}, - {"rx_cbuf_alloc_fail" , NSS_STATS_TYPE_DROP}, - {"tx_cbuf_alloc_fail" , NSS_STATS_TYPE_DROP}, - {"tx_cenqueue_fail" , NSS_STATS_TYPE_DROP}, - {"rx_cenqueue_fail" , NSS_STATS_TYPE_DROP}, - {"tx_drops_hroom" , NSS_STATS_TYPE_DROP}, - {"tx_drops_troom" , NSS_STATS_TYPE_DROP}, - {"tx_forward_enqueue_fail" , NSS_STATS_TYPE_DROP}, - {"rx_forward_enqueue_fail" , NSS_STATS_TYPE_DROP}, - {"rx_invalid_version" , NSS_STATS_TYPE_DROP}, - {"rx_invalid_epoch" , NSS_STATS_TYPE_DROP}, - {"rx_malformed" , NSS_STATS_TYPE_DROP}, - {"rx_cipher_fail" , NSS_STATS_TYPE_EXCEPTION}, - {"rx_auth_fail" , NSS_STATS_TYPE_EXCEPTION}, - {"rx_capwap_classify_fail" , NSS_STATS_TYPE_DROP}, - {"rx_single_rec_dgram" , NSS_STATS_TYPE_SPECIAL}, - {"rx_multi_rec_dgram" , NSS_STATS_TYPE_SPECIAL}, - {"rx_replay_fail" , NSS_STATS_TYPE_DROP}, - {"rx_replay_duplicate" , NSS_STATS_TYPE_SPECIAL}, - {"rx_replay_out_of_window" , NSS_STATS_TYPE_SPECIAL}, - {"outflow_queue_full" , NSS_STATS_TYPE_DROP}, - {"decap_queue_full" , NSS_STATS_TYPE_DROP}, - {"pbuf_alloc_fail" , NSS_STATS_TYPE_DROP}, - {"pbuf_copy_fail" , NSS_STATS_TYPE_DROP}, - {"epoch" , NSS_STATS_TYPE_DROP}, - {"tx_seq_high" , NSS_STATS_TYPE_SPECIAL}, - {"tx_seq_low" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_dtls_stats_read() - * Read DTLS session statistics. - */ -static ssize_t nss_dtls_stats_read(struct file *fp, char __user *ubuf, - size_t sz, loff_t *ppos) -{ - uint32_t max_output_lines = 2 + (NSS_MAX_DTLS_SESSIONS - * (NSS_DTLS_STATS_SESSION_MAX + 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; - int id; - struct nss_dtls_stats_session *dtls_session_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; - } - - dtls_session_stats = kzalloc((sizeof(struct nss_dtls_stats_session) - * NSS_MAX_DTLS_SESSIONS), GFP_KERNEL); - if (unlikely(dtls_session_stats == NULL)) { - nss_warning("Could not allocate memory for populating DTLS stats"); - kfree(lbuf); - return 0; - } - - /* - * Get all stats. - */ - nss_dtls_session_stats_get(dtls_session_stats); - - /* - * Session stats. - */ - size_wr += nss_stats_banner(lbuf, size_wr, size_al, "dtls", NSS_STATS_SINGLE_CORE); - - for (id = 0; id < NSS_MAX_DTLS_SESSIONS; id++) { - if (!dtls_session_stats[id].valid) - break; - - dev = dev_get_by_index(&init_net, dtls_session_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, dtls_session_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, - dtls_session_stats[id].if_num); - } - - size_wr += nss_stats_print("dtls_cmn", NULL, id, nss_dtls_stats_session_str, dtls_session_stats[id].stats, NSS_DTLS_STATS_SESSION_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(dtls_session_stats); - kfree(lbuf); - return bytes_read; -} - -/* - * nss_dtls_stats_ops. - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(dtls) - -/* - * nss_dtls_stats_dentry_create() - * Create DTLS statistics debug entry. - */ -void nss_dtls_stats_dentry_create(void) -{ - nss_stats_create_dentry("dtls", &nss_dtls_stats_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_dtls_stats.h deleted file mode 100644 index bf6a148b7..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dtls_stats.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_STATS_H -#define __NSS_DTLS_STATS_H - -/* - * DTLS session debug statistic counters - */ -enum nss_dtls_stats_session_types { - NSS_DTLS_STATS_SESSION_RX_PKTS, - /* Rx packets */ - NSS_DTLS_STATS_SESSION_TX_PKTS, - /* Tx packets */ - NSS_DTLS_STATS_SESSION_RX_QUEUE_0_DROPPED, - NSS_DTLS_STATS_SESSION_RX_QUEUE_1_DROPPED, - NSS_DTLS_STATS_SESSION_RX_QUEUE_2_DROPPED, - NSS_DTLS_STATS_SESSION_RX_QUEUE_3_DROPPED, - NSS_DTLS_STATS_SESSION_RX_AUTH_DONE, - /* Rx successful authentication */ - NSS_DTLS_STATS_SESSION_TX_AUTH_DONE, - /* Tx authentication done */ - NSS_DTLS_STATS_SESSION_RX_CIPHER_DONE, - /* Rx cipher done */ - NSS_DTLS_STATS_SESSION_TX_CIPHER_DONE, - /* Tx cipher done */ - NSS_DTLS_STATS_SESSION_RX_CBUF_ALLOC_FAIL, - /* Rx crypto buffer alloc fail */ - NSS_DTLS_STATS_SESSION_TX_CBUF_ALLOC_FAIL, - /* Tx crypto buffer alloc fail */ - NSS_DTLS_STATS_SESSION_TX_CENQUEUE_FAIL, - /* Tx enqueue to crypto fail */ - NSS_DTLS_STATS_SESSION_RX_CENQUEUE_FAIL, - /* Rx enqueue to crypto fail */ - NSS_DTLS_STATS_SESSION_TX_DROPPED_HROOM, - /* Tx drop due to insufficient headroom */ - NSS_DTLS_STATS_SESSION_TX_DROPPED_TROOM, - /* Tx drop due to insufficient tailroom */ - NSS_DTLS_STATS_SESSION_TX_FORWARD_ENQUEUE_FAIL, - /* Enqueue failed to Tx node after encap */ - NSS_DTLS_STATS_SESSION_RX_FORWARD_ENQUEUE_FAIL, - /* Enqueue failed to Rx node after decap */ - NSS_DTLS_STATS_SESSION_RX_INVALID_VERSION, - /* Rx invalid DTLS version */ - NSS_DTLS_STATS_SESSION_RX_INVALID_EPOCH, - /* Rx invalid DTLS epoch */ - NSS_DTLS_STATS_SESSION_RX_MALFORMED, - /* Rx malformed DTLS record */ - NSS_DTLS_STATS_SESSION_RX_CIPHER_FAIL, - /* Rx cipher fail */ - NSS_DTLS_STATS_SESSION_RX_AUTH_FAIL, - /* Rx authentication fail */ - NSS_DTLS_STATS_SESSION_RX_CAPWAP_CLASSIFY_FAIL, - /* Rx CAPWAP classification fail */ - NSS_DTLS_STATS_SESSION_RX_SINGLE_REC_DGRAM, - /* Rx single record datagrams processed */ - NSS_DTLS_STATS_SESSION_RX_MULTI_REC_DGRAM, - /* Rx multi record datagrams processed */ - NSS_DTLS_STATS_SESSION_RX_REPLAY_FAIL, - /* Rx anti-replay failures */ - NSS_DTLS_STATS_SESSION_RX_REPLAY_DUPLICATE, - /* Rx anti-replay fail due to duplicate record */ - NSS_DTLS_STATS_SESSION_RX_REPLAY_OUT_OF_WINDOW, - /* Rx anti-replay fail due to out of window record */ - NSS_DTLS_STATS_SESSION_OUTFLOW_QUEUE_FULL, - /* Tx drop due to encap queue full */ - NSS_DTLS_STATS_SESSION_DECAP_QUEUE_FULL, - /* Rx drop due to decap queue full */ - NSS_DTLS_STATS_SESSION_PBUF_ALLOC_FAIL, - /* Drops due to buffer allocation failure */ - NSS_DTLS_STATS_SESSION_PBUF_COPY_FAIL, - /* Drops due to buffer copy failure */ - NSS_DTLS_STATS_SESSION_EPOCH, - /* Current Epoch */ - NSS_DTLS_STATS_SESSION_TX_SEQ_HIGH, - /* Upper 16-bits of current sequence number */ - NSS_DTLS_STATS_SESSION_TX_SEQ_LOW, - /* Lower 32-bits of current sequence number */ - NSS_DTLS_STATS_SESSION_MAX, -}; - -/* - * DTLS session statistics - */ -struct nss_dtls_stats_session { - uint64_t stats[NSS_DTLS_STATS_SESSION_MAX]; - int32_t if_index; - uint32_t if_num; /* nss interface number */ - bool valid; -}; - -/* - * Stats APIs provided by nss_dtls.c - */ -extern void nss_dtls_session_stats_get(struct nss_dtls_stats_session *s); - -/* - * DTLS statistics APIs - */ -extern void nss_dtls_stats_dentry_create(void); - -#endif /* __NSS_DTLS_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface.c b/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface.c deleted file mode 100644 index a7286bfd0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface.c +++ /dev/null @@ -1,420 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_dynamic_interface_log.h" -#include "nss_dynamic_interface_stats.h" - -#define NSS_DYNAMIC_INTERFACE_COMP_TIMEOUT 60000 /* 60 Sec */ - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_dynamic_interface_stats_notifier); - -void nss_dynamic_interface_stats_notify(uint32_t if_num, uint32_t core_id); - -/* - * Message data structure to store the message result - */ -struct nss_dynamic_interface_msg_data { - struct completion complete; /* completion structure */ - int if_num; /* Interface number */ - enum nss_cmn_response response; /* Message response */ -}; - -static nss_dynamic_interface_assigned nss_dynamic_interface_assigned_types[NSS_CORE_MAX][NSS_MAX_DYNAMIC_INTERFACES]; /* Array of assigned interface types */ - -/* - * nss_dynamic_interface_handler() - * Handle NSS -> HLOS messages for dynamic interfaces - */ -static void nss_dynamic_interface_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - nss_dynamic_interface_msg_callback_t cb; - struct nss_dynamic_interface_msg *ndim = (struct nss_dynamic_interface_msg *)ncm; - int32_t if_num; - - BUG_ON(ncm->interface != NSS_DYNAMIC_INTERFACE); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_DYNAMIC_INTERFACE_MAX) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Trace messages. - */ - nss_dynamic_interface_log_rx_msg(ndim); - - /* - * Handling dynamic interface messages coming from NSS fw. - */ - switch (ndim->cm.type) { - case NSS_DYNAMIC_INTERFACE_ALLOC_NODE: - if (ncm->response == NSS_CMN_RESPONSE_ACK) { - 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("%px: if_num < 0\n", nss_ctx); - } - } - - break; - - case NSS_DYNAMIC_INTERFACE_DEALLOC_NODE: - if (ncm->response == NSS_CMN_RESPONSE_ACK) { - 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; - /* - * Send dynamic interface dealloc notifications to the registered modules. - */ - nss_dynamic_interface_stats_notify(ndim->msg.dealloc_node.if_num, nss_ctx->id); - } - - break; - - default: - nss_warning("%px: Received response %d for type %d, interface %d", - nss_ctx, ncm->response, ncm->type, ncm->interface); - return; - } - - /* - * Do we have a callback? - */ - if (!ncm->cb) { - nss_warning("%px: nss_dynamic_interface_handler cb is NULL\n", nss_ctx); - return; - } - - /* - * Callback - */ - cb = (nss_dynamic_interface_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, ncm); -} - -/* - * nss_dynamic_interface_callback - * Callback to handle the message response from NSS FW. - */ -static void nss_dynamic_interface_callback(void *app_data, struct nss_cmn_msg *ncm) -{ - struct nss_dynamic_interface_msg_data *di_data = (struct nss_dynamic_interface_msg_data *)app_data; - struct nss_dynamic_interface_msg *ndim = (struct nss_dynamic_interface_msg *)ncm; - - di_data->response = ncm->response; - di_data->if_num = ndim->msg.alloc_node.if_num; - - /* - * Unblock the sleeping function. - */ - complete(&di_data->complete); -} - -/* - * nss_dynamic_interface_tx() - * Transmit a dynamic interface message to NSSFW, asynchronously. - */ -nss_tx_status_t nss_dynamic_interface_tx(struct nss_ctx_instance *nss_ctx, struct nss_dynamic_interface_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Sanity check the message - */ - if (ncm->interface != NSS_DYNAMIC_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("%px: message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - /* - * Trace messages. - */ - nss_dynamic_interface_log_tx_msg(msg); - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} - -/* - * nss_dynamic_interface_tx_sync() - * Send the message to NSS and wait till we get an ACK or NACK for this msg. - */ -static nss_tx_status_t nss_dynamic_interface_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_dynamic_interface_msg_data *di_data, - struct nss_dynamic_interface_msg *ndim) -{ - nss_tx_status_t status; - int ret; - - status = nss_dynamic_interface_tx(nss_ctx, ndim); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: not able to transmit msg successfully\n", nss_ctx); - return status; - } - - /* - * Blocking call, wait till we get ACK for this msg. - */ - ret = wait_for_completion_timeout(&di_data->complete, msecs_to_jiffies(NSS_DYNAMIC_INTERFACE_COMP_TIMEOUT)); - if (ret == 0) { - nss_warning("%px: Waiting for ack timed out\n", nss_ctx); - return NSS_TX_FAILURE; - } - - return status; -} - -/* - * nss_dynamic_interface_alloc_node() - * Allocates node of perticular type on NSS and returns interface_num for this node or -1 in case of failure. - * - * Note: This function should not be called from soft_irq or interrupt context because it blocks till ACK/NACK is - * received for the message sent to NSS. - */ -int nss_dynamic_interface_alloc_node(enum nss_dynamic_interface_type type) -{ - struct nss_ctx_instance *nss_ctx = NULL; - struct nss_dynamic_interface_msg ndim; - struct nss_dynamic_interface_alloc_node_msg *ndia; - struct nss_dynamic_interface_msg_data di_data; - uint32_t core_id; - nss_tx_status_t status; - - if (type >= NSS_DYNAMIC_INTERFACE_TYPE_MAX) { - nss_warning("Dynamic if msg drooped as type is wrong %d\n", type); - return -1; - } - - 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; - di_data.response = false; - init_completion(&di_data.complete); - - nss_dynamic_interface_msg_init(&ndim, NSS_DYNAMIC_INTERFACE, NSS_DYNAMIC_INTERFACE_ALLOC_NODE, - sizeof(struct nss_dynamic_interface_alloc_node_msg), nss_dynamic_interface_callback, (void *)&di_data); - - ndia = &ndim.msg.alloc_node; - ndia->type = type; - - /* - * Initialize if_num to -1. The allocated if_num is returned by the firmware - * in the response message. - */ - ndia->if_num = -1; - - /* - * Calling synchronous transmit function. - */ - status = nss_dynamic_interface_tx_sync(nss_ctx, &di_data, &ndim); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px not able to transmit alloc node msg\n", nss_ctx); - return -1; - } - - /* - * Check response and return -1 if its a NACK else proceed. - */ - if (di_data.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("%px Received NACK from NSS - Response:%d\n", nss_ctx, di_data.response); - return -1; - } - - return di_data.if_num; -} - -/* - * nss_dynamic_interface_dealloc_node() - * Deallocate node of particular type and if_num in NSS. - * - * Note: This will just mark the state of node as not active, actual memory will be freed when reference count of that node becomes 0. - * This function should not be called from soft_irq or interrupt context because it blocks till ACK/NACK is received for the message - * sent to NSS. - */ -nss_tx_status_t nss_dynamic_interface_dealloc_node(int if_num, enum nss_dynamic_interface_type type) -{ - struct nss_ctx_instance *nss_ctx = NULL; - struct nss_dynamic_interface_msg ndim; - struct nss_dynamic_interface_dealloc_node_msg *ndid; - struct nss_dynamic_interface_msg_data di_data; - uint32_t core_id; - nss_tx_status_t status; - - if (type >= NSS_DYNAMIC_INTERFACE_TYPE_MAX) { - nss_warning("Dynamic if msg dropped as type is wrong type %d if_num %d\n", type, if_num); - return NSS_TX_FAILURE_BAD_PARAM; - } - - core_id = nss_top_main.dynamic_interface_table[type]; - nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[core_id]; - di_data.response = false; - init_completion(&di_data.complete); - - if (nss_is_dynamic_interface(if_num) == false) { - nss_warning("%px: nss_dynamic_interface if_num is not in range %d\n", nss_ctx, if_num); - return NSS_TX_FAILURE_BAD_PARAM; - } - - nss_dynamic_interface_msg_init(&ndim, NSS_DYNAMIC_INTERFACE, NSS_DYNAMIC_INTERFACE_DEALLOC_NODE, - sizeof(struct nss_dynamic_interface_dealloc_node_msg), nss_dynamic_interface_callback, (void *)&di_data); - - ndid = &ndim.msg.dealloc_node; - ndid->type = type; - ndid->if_num = if_num; - - /* - * Calling synchronous transmit function. - */ - status = nss_dynamic_interface_tx_sync(nss_ctx, &di_data, &ndim); - if (status != NSS_TX_SUCCESS) { - 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("%px Received NACK from NSS\n", nss_ctx); - return -1; - } - - return status; -} - -/* - * nss_dynamic_interface_register_handler() - */ -void nss_dynamic_interface_register_handler(struct nss_ctx_instance *nss_ctx) -{ - nss_core_register_handler(nss_ctx, NSS_DYNAMIC_INTERFACE, nss_dynamic_interface_handler, NULL); - nss_dynamic_interface_stats_dentry_create(); -} - -/* - * nss_is_dynamic_interface() - * Judge it is a valid dynamic interface - */ -bool nss_is_dynamic_interface(int if_num) -{ - return (if_num >= NSS_DYNAMIC_IF_START && if_num < NSS_SPECIAL_IF_START); -} - -/* - * nss_dynamic_interface_get_nss_ctx_by_type() - * Gets the NSS context using NSS dynamic interface type. - */ -struct nss_ctx_instance *nss_dynamic_interface_get_nss_ctx_by_type(enum nss_dynamic_interface_type type) -{ - struct nss_ctx_instance *nss_ctx = NULL; - uint32_t core_id; - - if (type >= NSS_DYNAMIC_INTERFACE_TYPE_MAX) { - nss_warning("Invalid param: Type is wrong %d\n", type); - return NULL; - } - - core_id = nss_top_main.dynamic_interface_table[type]; - nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[core_id]; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - return nss_ctx; -} - -/* - * nss_dynamic_interface_get_type() - * Gets the type of dynamic interface - */ -enum nss_dynamic_interface_type nss_dynamic_interface_get_type(struct nss_ctx_instance *nss_ctx, int if_num) -{ - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (nss_is_dynamic_interface(if_num) == false) { - return NSS_DYNAMIC_INTERFACE_TYPE_NONE; - } - - return nss_dynamic_interface_assigned_types[nss_ctx->id][if_num - NSS_DYNAMIC_IF_START]; -} - -/* - * nss_dynamic_interface_msg_init() - * Initialize dynamic interface message. - */ -void nss_dynamic_interface_msg_init(struct nss_dynamic_interface_msg *ndm, uint16_t if_num, uint32_t type, uint32_t len, - void *cb, void *app_data) -{ - nss_cmn_msg_init(&ndm->cm, if_num, type, len, cb, app_data); -} - -/* - * nss_dynamic_interface_stats_notify() - * Sends notifications to all the registered modules. - */ -void nss_dynamic_interface_stats_notify(uint32_t if_num, uint32_t core_id) -{ - struct nss_dynamic_interface_notification stats; - - stats.core_id = core_id; - stats.if_num = if_num; - atomic_notifier_call_chain(&nss_dynamic_interface_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&stats); -} -EXPORT_SYMBOL(nss_dynamic_interface_stats_notify); - -/* - * nss_dynamic_interface_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_dynamic_interface_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_dynamic_interface_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_dynamic_interface_stats_register_notifier); - -/* - * nss_dynamic_interface_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_dynamic_interface_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_dynamic_interface_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_dynamic_interface_stats_unregister_notifier); - -EXPORT_SYMBOL(nss_dynamic_interface_alloc_node); -EXPORT_SYMBOL(nss_dynamic_interface_dealloc_node); -EXPORT_SYMBOL(nss_is_dynamic_interface); -EXPORT_SYMBOL(nss_dynamic_interface_get_type); -EXPORT_SYMBOL(nss_dynamic_interface_get_nss_ctx_by_type); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface_log.c deleted file mode 100644 index 0c49aeb7e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface_log.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_dynamic_interface_log.c - * NSS Dynamic Interface logger file. - */ - -#include "nss_core.h" - -/* - * nss_dynamic_interface_log_message_types_str - * Dynamic Interface message strings - */ -static int8_t *nss_dynamic_interface_log_message_types_str[NSS_DYNAMIC_INTERFACE_MAX] __maybe_unused = { - "Dynamic Interface Alloc Node", - "Dynamic Interface Dealloc Node" -}; - -/* - * nss_dynamic_interface_log_error_response_types_str - * Strings for error types for dynamic interface messages - */ -static int8_t *nss_dynamic_interface_log_error_response_types_str[NSS_DYNAMIC_INTERFACE_ERR_MAX] __maybe_unused = { - "Dynamic Interface Error Unknown Interface", - "Dynamic Interface Error Unavailable Interface", - "Dynamic Interface Error Invalid Interface Type", - "Dynamic Interface Error Invalid Interface Number", - "Dynamic Interface Error Alloc Function Unavailable", - "Dynamic Interface Error Dealloc Funciton Unavailable", - "Dynamic Interface Error Allocation Error", - "Dynamic Interface Error Interface Number Mismatch" -}; - -/* - * nss_dynamic_interface_alloc_node_msg() - * Log Dynamic Interface alloc node message. - */ -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("%px: NSS Dynamic Interface Alloc Node Message:\n" - "Dynamic Interface Type: %d\n" - "Dynamic Interface Number: %d\n", - ndanm, ndanm->type, - ndanm->if_num); -} - -/* - * nss_dynamic_interface_dealloc_node_msg() - * Log Dynamic Interface dealloc node message. - */ -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("%px: NSS Dynamic Interface Alloc Node Message:\n" - "Dynamic Interface Type: %d\n" - "Dynamic Interface Number: %d\n", - nddnm, nddnm->type, - nddnm->if_num); -} - -/* - * nss_dynamic_interface_log_verbose() - * Log message contents. - */ -static void nss_dynamic_interface_log_verbose(struct nss_dynamic_interface_msg *ndm) -{ - switch (ndm->cm.type) { - case NSS_DYNAMIC_INTERFACE_ALLOC_NODE: - nss_dynamic_interface_alloc_node_log_msg(ndm); - break; - - case NSS_DYNAMIC_INTERFACE_DEALLOC_NODE: - nss_dynamic_interface_dealloc_node_log_msg(ndm); - break; - - default: - nss_warning("%px: Invalid message type\n", ndm); - break; - } -} - -/* - * nss_dynamic_interface_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_dynamic_interface_log_tx_msg(struct nss_dynamic_interface_msg *ndm) -{ - if (ndm->cm.type >= NSS_DYNAMIC_INTERFACE_MAX) { - nss_warning("%px: Invalid message type\n", ndm); - return; - } - - 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); -} - -/* - * nss_dynamic_interface_log_rx_msg() - * Log messages received from FW. - */ -void nss_dynamic_interface_log_rx_msg(struct nss_dynamic_interface_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_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("%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("%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]); - -verbose: - nss_dynamic_interface_log_verbose(ndm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface_log.h deleted file mode 100644 index 266b909c9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_DYNAMIC_INTERFACE_LOG_H -#define __NSS_DYNAMIC_INTERFACE_LOG_H - -/* - * nss_dynamic_interface.h - * NSS Dynamic Interface private header file. - */ - -/* - * nss_dynamic_interface_log_tx_msg - * Logs a dynamic interface message that is sent to the NSS firmware. - */ -void nss_dynamic_interface_log_tx_msg(struct nss_dynamic_interface_msg *ndm); - -/* - * nss_dynamic_interface_log_rx_msg - * Logs a dynamic interface message that is received from the NSS firmware. - */ -void nss_dynamic_interface_log_rx_msg(struct nss_dynamic_interface_msg *ndm); - -#endif /* __NSS_DYNAMIC_INTERFACE_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface_stats.c deleted file mode 100644 index 1f190b645..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface_stats.c +++ /dev/null @@ -1,160 +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_dynamic_interface.h" - -/* - * nss_dynamic_interface_type_names - * Name strings for dynamic interface types - */ -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_TUNIPIP6_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_RESERVED", - "NSS_DYNAMIC_INTERFACE_TYPE_VAP", - "NSS_DYNAMIC_INTERFACE_TYPE_RESERVED_0", - "NSS_DYNAMIC_INTERFACE_TYPE_PPPOE", - "NSS_DYNAMIC_INTERFACE_TYPE_VIRTIF_DEPRECATED", - "NSS_DYNAMIC_INTERFACE_TYPE_L2TPV2", - "NSS_DYNAMIC_INTERFACE_TYPE_RESERVED_4", - "NSS_DYNAMIC_INTERFACE_TYPE_PORTID", - "NSS_DYNAMIC_INTERFACE_TYPE_DTLS", - "NSS_DYNAMIC_INTERFACE_TYPE_QVPN_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_QVPN_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_BRIDGE", - "NSS_DYNAMIC_INTERFACE_TYPE_VLAN", - "NSS_DYNAMIC_INTERFACE_TYPE_RESERVED_3", - "NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_INTERNAL", - "NSS_DYNAMIC_INTERFACE_TYPE_MAP_T_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_MAP_T_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_HOST_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_OFFL_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_SJACK_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INLINE_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INLINE_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H", - "NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N", - "NSS_DYNAMIC_INTERFACE_TYPE_TUN6RD_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_TUN6RD_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INNER_EXCEPTION", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_US", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_DS", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_PPTP_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_PPTP_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_PPTP_HOST_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_MDATA_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_MDATA_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_REDIRECT", - "NSS_DYNAMIC_INTERFACE_TYPE_PVXLAN_HOST_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_PVXLAN_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_IGS", - "NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_US", - "NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_DS", - "NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_OUTER", - "NSS_DYNAMIC_INTERFACE_TYPE_MATCH", - "NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_N2H", - "NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_H2N", - "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", -}; - -/* - * nss_dynamic_interface_type_names_stats_read() - * Read and display dynamic interface types names - */ -static ssize_t nss_dynamic_interface_type_names_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int i; - char *lbuf = NULL; - size_t size_wr = 0; - ssize_t bytes_read = 0; - uint32_t max_output_lines = 2 /* header & footer for stats */ - + NSS_DYNAMIC_INTERFACE_TYPE_MAX /* maximum number of dynamic interface types */ - + 2; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - - lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(lbuf == NULL)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - /* - * name strings - */ - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n dynamic interface type names start:\n\n"); - - for (i = 0; i < NSS_DYNAMIC_INTERFACE_TYPE_MAX; i++) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, - "\t%u : %s\n", i, nss_dynamic_interface_type_names[i]); - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n dynamic interface type names end\n"); - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - - kfree(lbuf); - return bytes_read; -} - -/* - * nss_dynamic_interface_type_names_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(dynamic_interface_type_names) - -/* - * nss_dynamic_interface_stats_dentry_create() - * Create dynamic-interface statistics debug entry. - */ -void nss_dynamic_interface_stats_dentry_create(void) -{ - struct dentry *di_dentry = NULL; - struct dentry *di_type_name_d = NULL; - - di_dentry = debugfs_create_dir("dynamic_if", nss_top_main.stats_dentry); - if (unlikely(di_dentry == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/dynamic_if directory"); - return; - } - - di_type_name_d = debugfs_create_file("type_names", 0400, di_dentry, - &nss_top_main, &nss_dynamic_interface_type_names_stats_ops); - if (unlikely(di_type_name_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/dynamic_if/type_names file"); - return; - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface_stats.h deleted file mode 100644 index ef16162bc..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_dynamic_interface_stats.h +++ /dev/null @@ -1,33 +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_DYNAMIC_INTERFACE_STATS_H -#define __NSS_DYNAMIC_INTERFACE_STATS_H - -/* - * nss_dynamic_interface.h - * NSS Dynamic Interface private header file. - */ - -/* - * nss_dynamic_interface_stats_dentry_create - * Create dynamic interface debugfs entry. - */ -void nss_dynamic_interface_stats_dentry_create(void); - -#endif /* __NSS_DYNAMIC_INTERFACE_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_edma.c b/feeds/ipq807x/qca-nss-drv/src/nss_edma.c deleted file mode 100644 index f03772689..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_edma.c +++ /dev/null @@ -1,139 +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. - ************************************************************************** - */ - -/* - * nss_edma.c - * NSS EDMA APIs - */ -#include "nss_edma_stats.h" -#include "nss_edma_strings.h" - -/* - ********************************** - Rx APIs - ********************************** - */ - -/* - * nss_edma_interface_handler() - * Handle NSS -> HLOS messages for EDMA node - */ -static void nss_edma_interface_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_edma_msg *nem = (struct nss_edma_msg *)ncm; - nss_edma_msg_callback_t cb; - - /* - * Is this a valid request/response packet? - */ - if (nem->cm.type >= NSS_METADATA_TYPE_EDMA_MAX) { - nss_warning("%px: received invalid message %d for edma interface", nss_ctx, nem->cm.type); - return; - } - - /* - * Handle different types of messages - */ - switch (nem->cm.type) { - case NSS_METADATA_TYPE_EDMA_PORT_STATS_SYNC: - /* - * Update driver statistics and send statistics notifications to the registered modules. - */ - nss_edma_metadata_port_stats_sync(nss_ctx, &nem->msg.port_stats); - nss_edma_stats_notify(nss_ctx); - - break; - case NSS_METADATA_TYPE_EDMA_RING_STATS_SYNC: - nss_edma_metadata_ring_stats_sync(nss_ctx, &nem->msg.ring_stats); - break; - case NSS_METADATA_TYPE_EDMA_ERR_STATS_SYNC: - nss_edma_metadata_err_stats_sync(nss_ctx, &nem->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 sends all notify messages - * to the same callback/app_data. - */ - if (nem->cm.response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->edma_callback; - ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->edma_ctx; - } - - /* - * Do we have a callback? - */ - if (!ncm->cb) { - return; - } - - /* - * Callback - */ - cb = (nss_edma_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, nem); -} - -/* - * nss_edma_notify_register() - * Register to received EDMA events. - */ -struct nss_ctx_instance *nss_edma_notify_register(nss_edma_msg_callback_t cb, void *app_data) -{ - nss_top_main.edma_callback = cb; - nss_top_main.edma_ctx = app_data; - return &nss_top_main.nss[nss_top_main.edma_handler_id]; -} -EXPORT_SYMBOL(nss_edma_notify_register); - -/* - * nss_edma_notify_unregister() - * Unregister to received EDMA events. - */ -void nss_edma_notify_unregister(void) -{ - nss_top_main.edma_callback = NULL; -} -EXPORT_SYMBOL(nss_edma_notify_unregister); - -/* - * nss_get_edma_context() - */ -struct nss_ctx_instance *nss_edma_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.edma_handler_id]; -} -EXPORT_SYMBOL(nss_edma_get_context); - -/* - * nss_edma_register_handler() - */ -void nss_edma_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_edma_get_context(); - - nss_core_register_handler(nss_ctx, NSS_EDMA_INTERFACE, nss_edma_interface_handler, NULL); - - nss_edma_stats_dentry_create(); - nss_edma_strings_dentry_create(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_edma_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_edma_stats.c deleted file mode 100644 index abb338e2a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_edma_stats.c +++ /dev/null @@ -1,822 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2017-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_edma_stats.c - * NSS EDMA statistics APIs - */ - -#include "nss_edma_stats.h" -#include "nss_edma_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_edma_stats_notifier); - -struct nss_edma_stats edma_stats; - -/* - ********************************** - EDMA statistics APIs - ********************************** - */ - -/* - * nss_edma_port_stats_read() - * Read EDMA port statistics - */ -static ssize_t nss_edma_port_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int32_t i; - - /* - * 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_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; - struct nss_stats_data *data = fp->private_data; - - 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, "edma port %d stats:\n\n", data->edma_id); - - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; (i < NSS_STATS_NODE_MAX); i++) { - stats_shadow[i] = edma_stats.port[data->edma_id].port_stats[i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("edma_port", NULL, data->edma_id - , nss_edma_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_port_type_stats_read() - * Read EDMA port type - */ -static ssize_t nss_edma_port_type_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - /* - * max output lines = #stats + start tag line + end tag line + three blank lines - */ - uint32_t max_output_lines = (1 + 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 port_type; - struct nss_stats_data *data = fp->private_data; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(lbuf == NULL)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - size_wr = scnprintf(lbuf, size_al, "edma port type start:\n\n"); - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma port %d type:\n\n", data->edma_id); - - /* - * Port type - */ - spin_lock_bh(&nss_top_main.stats_lock); - port_type = edma_stats.port[data->edma_id].port_type; - spin_unlock_bh(&nss_top_main.stats_lock); - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, - "port_type = %s\n", nss_edma_strings_stats_port_type[port_type].stats_name); - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma stats end\n"); - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(lbuf); - - return bytes_read; -} - -/* - * nss_edma_port_ring_map_stats_read() - * Read EDMA port ring map - */ -static ssize_t nss_edma_port_ring_map_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 = (4 + 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; - struct nss_stats_data *data = fp->private_data; - - 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_PORT_RING_MAP_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 port ring map start:\n\n"); - - /* - * Port ring map - */ - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "edma port %d ring map:\n\n", data->edma_id); - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; i < NSS_EDMA_PORT_RING_MAP_MAX; i++) { - stats_shadow[i] = edma_stats.port[data->edma_id].port_ring_map[i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - - size_wr += nss_stats_print("edma_port_ring", NULL, data->edma_id - , nss_edma_strings_stats_port_ring_map - , stats_shadow - , NSS_EDMA_PORT_RING_MAP_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_txring_stats_read() - * Read EDMA Tx ring stats - */ -static ssize_t nss_edma_txring_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_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; - struct nss_stats_data *data = fp->private_data; - - 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_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 %d stats:\n\n", data->edma_id); - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; i < NSS_EDMA_STATS_TX_MAX; i++) { - stats_shadow[i] = edma_stats.tx_stats[data->edma_id][i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - - size_wr += nss_stats_print("edma_tx_ring", NULL, data->edma_id - , nss_edma_strings_stats_tx - , stats_shadow - , NSS_EDMA_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_rxring_stats_read() - * Read EDMA rxring stats - */ -static ssize_t nss_edma_rxring_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_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; - struct nss_stats_data *data = fp->private_data; - - 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_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_STATS_RX_MAX; i++) { - stats_shadow[i] = edma_stats.rx_stats[data->edma_id][i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("edma_rx_ring", NULL, data->edma_id - , nss_edma_strings_stats_rx - , stats_shadow - , NSS_EDMA_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_txcmplring_stats_read() - * Read EDMA txcmplring stats - */ -static ssize_t nss_edma_txcmplring_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_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; - struct nss_stats_data *data = fp->private_data; - - 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_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 %d stats:\n\n", data->edma_id); - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; i < NSS_EDMA_STATS_TXCMPL_MAX; i++) { - stats_shadow[i] = edma_stats.txcmpl_stats[data->edma_id][i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("edma_tx_cmpl_ring", NULL, data->edma_id - , nss_edma_strings_stats_txcmpl - , stats_shadow - , NSS_EDMA_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_rxfillring_stats_read() - * Read EDMA rxfillring stats - */ -static ssize_t nss_edma_rxfillring_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_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; - struct nss_stats_data *data = fp->private_data; - - 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_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 %d stats:\n\n", data->edma_id); - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; i < NSS_EDMA_STATS_RXFILL_MAX; i++) { - stats_shadow[i] = edma_stats.rxfill_stats[data->edma_id][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_strings_stats_rxfill - , stats_shadow - , NSS_EDMA_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_err_stats_read() - * Read EDMA err stats - */ -static ssize_t nss_edma_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_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_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_ERR_STATS_MAX); i++) - stats_shadow[i] = edma_stats.misc_err[i]; - - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("edma_err", NULL, NSS_STATS_SINGLE_INSTANCE - , nss_edma_strings_stats_err_map - , stats_shadow - , NSS_EDMA_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_port_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(edma_port); - -/* - * edma_port_type_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(edma_port_type); - -/* - * edma_port_ring_map_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(edma_port_ring_map); - -/* - * edma_txring_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(edma_txring); - -/* - * edma_rxring_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(edma_rxring); - -/* - * edma_txcmplring_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(edma_txcmplring); - -/* - * edma_rxfillring_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(edma_rxfillring); - -/* - * edma_err_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(edma_err); - -/* - * nss_edma_stats_dentry_create() - * Create edma statistics debug entry. - */ -void nss_edma_stats_dentry_create(void) -{ - int i; - struct dentry *edma_d = NULL; - struct dentry *edma_port_dir_d = NULL; - struct dentry *edma_port_d = NULL; - struct dentry *edma_port_type_d = NULL; - struct dentry *edma_port_stats_d = NULL; - struct dentry *edma_port_ring_map_d = NULL; - struct dentry *edma_rings_dir_d = NULL; - struct dentry *edma_tx_dir_d = NULL; - struct dentry *edma_tx_d = NULL; - struct dentry *edma_rx_dir_d = NULL; - struct dentry *edma_rx_d = NULL; - struct dentry *edma_txcmpl_dir_d = NULL; - struct dentry *edma_txcmpl_d = NULL; - struct dentry *edma_rxfill_dir_d = NULL; - struct dentry *edma_rxfill_d = NULL; - struct dentry *edma_err_stats_d = NULL; - char file_name[10]; - - edma_d = debugfs_create_dir("edma", nss_top_main.stats_dentry); - if (unlikely(edma_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma directory"); - return; - } - - /* - * edma port stats - */ - edma_port_dir_d = debugfs_create_dir("ports", edma_d); - if (unlikely(edma_port_dir_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/ports directory"); - return; - } - - for (i = 0; i < NSS_EDMA_NUM_PORTS_MAX; i++) { - memset(file_name, 0, sizeof(file_name)); - snprintf(file_name, sizeof(file_name), "%d", i); - - edma_port_d = debugfs_create_dir(file_name, edma_port_dir_d); - if (unlikely(edma_port_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d directory", i); - return; - } - - edma_port_stats_d = debugfs_create_file("stats", 0400, edma_port_d, (void *)(nss_ptr_t)i, &nss_edma_port_stats_ops); - if (unlikely(edma_port_stats_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/stats file", i); - return; - } - - edma_port_type_d = debugfs_create_file("type", 0400, edma_port_d, (void *)(nss_ptr_t)i, &nss_edma_port_type_stats_ops); - if (unlikely(edma_port_type_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/type file", i); - return; - } - - edma_port_ring_map_d = debugfs_create_file("ring_map", 0400, edma_port_d, (void *)(nss_ptr_t)i, &nss_edma_port_ring_map_stats_ops); - if (unlikely(edma_port_ring_map_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/ring_map file", i); - return; - } - } - - /* - * edma error stats - */ - edma_err_stats_d = NULL; - edma_err_stats_d = debugfs_create_file("err_stats", 0400, edma_d, &nss_top_main, &nss_edma_err_stats_ops); - if (unlikely(edma_port_stats_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/%d/err_stats file", 0); - 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_dir_d = debugfs_create_dir("tx", edma_rings_dir_d); - if (unlikely(edma_tx_dir_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/rings/tx directory"); - return; - } - - for (i = 0; i < NSS_EDMA_NUM_TX_RING_MAX; i++) { - memset(file_name, 0, sizeof(file_name)); - scnprintf(file_name, sizeof(file_name), "%d", i); - edma_tx_d = debugfs_create_file(file_name, 0400, edma_tx_dir_d, (void *)(nss_ptr_t)i, &nss_edma_txring_stats_ops); - if (unlikely(edma_tx_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/rings/tx/%d file", i); - return; - } - } - - /* - * edma rx ring stats - */ - edma_rx_dir_d = debugfs_create_dir("rx", edma_rings_dir_d); - if (unlikely(edma_rx_dir_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rx directory"); - return; - } - - for (i = 0; i < NSS_EDMA_NUM_RX_RING_MAX; i++) { - memset(file_name, 0, sizeof(file_name)); - scnprintf(file_name, sizeof(file_name), "%d", i); - edma_rx_d = debugfs_create_file(file_name, 0400, edma_rx_dir_d, (void *)(nss_ptr_t)i, &nss_edma_rxring_stats_ops); - if (unlikely(edma_rx_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rx/%d file", i); - return; - } - } - - /* - * edma tx cmpl ring stats - */ - edma_txcmpl_dir_d = debugfs_create_dir("txcmpl", edma_rings_dir_d); - if (unlikely(edma_txcmpl_dir_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/rings/txcmpl directory"); - return; - } - - for (i = 0; i < NSS_EDMA_NUM_TXCMPL_RING_MAX; i++) { - memset(file_name, 0, sizeof(file_name)); - scnprintf(file_name, sizeof(file_name), "%d", i); - edma_txcmpl_d = debugfs_create_file(file_name, 0400, edma_txcmpl_dir_d, (void *)(nss_ptr_t)i, &nss_edma_txcmplring_stats_ops); - if (unlikely(edma_txcmpl_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/rings/txcmpl/%d file", i); - return; - } - } - - /* - * edma rx fill ring stats - */ - edma_rxfill_dir_d = debugfs_create_dir("rxfill", edma_rings_dir_d); - if (unlikely(edma_rxfill_dir_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rxfill directory"); - return; - } - - for (i = 0; i < NSS_EDMA_NUM_RXFILL_RING_MAX; i++) { - memset(file_name, 0, sizeof(file_name)); - scnprintf(file_name, sizeof(file_name), "%d", i); - edma_rxfill_d = debugfs_create_file(file_name, 0400, edma_rxfill_dir_d, (void *)(nss_ptr_t)i, &nss_edma_rxfillring_stats_ops); - if (unlikely(edma_rxfill_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rxfill/%d file", i); - return; - } - } -} - -/* - * nss_edma_metadata_port_stats_sync() - * Handle the syncing of EDMA port statistics. - */ -void nss_edma_metadata_port_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_edma_port_stats_sync *nepss) -{ - uint16_t i, j = 0; - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - spin_lock_bh(&nss_top->stats_lock); - - /* - * edma port stats - * We process a subset of port stats since msg payload is not enough to hold all ports at once. - */ - for (i = nepss->start_port; i < nepss->end_port; i++) { - int k; - - edma_stats.port[i].port_stats[NSS_STATS_NODE_RX_PKTS] += nepss->port_stats[j].node_stats.rx_packets; - edma_stats.port[i].port_stats[NSS_STATS_NODE_RX_BYTES] += nepss->port_stats[j].node_stats.rx_bytes; - edma_stats.port[i].port_stats[NSS_STATS_NODE_TX_PKTS] += nepss->port_stats[j].node_stats.tx_packets; - edma_stats.port[i].port_stats[NSS_STATS_NODE_TX_BYTES] += nepss->port_stats[j].node_stats.tx_bytes; - - for (k = 0; k < NSS_MAX_NUM_PRI; k++) { - edma_stats.port[i].port_stats[NSS_STATS_NODE_RX_QUEUE_0_DROPPED + k] += nepss->port_stats[j].node_stats.rx_dropped[k]; - } - - edma_stats.port[i].port_type = nepss->port_stats[j].port_type; - edma_stats.port[i].port_ring_map[NSS_EDMA_PORT_RX_RING] = nepss->port_stats[j].edma_rx_ring; - edma_stats.port[i].port_ring_map[NSS_EDMA_PORT_TX_RING] = nepss->port_stats[j].edma_tx_ring; - j++; - } - - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_edma_metadata_ring_stats_sync() - * Handle the syncing of EDMA ring statistics. - */ -void nss_edma_metadata_ring_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_edma_ring_stats_sync *nerss) -{ - int32_t i; - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - spin_lock_bh(&nss_top->stats_lock); - - /* - * edma tx ring stats - */ - for (i = 0; i < NSS_EDMA_NUM_TX_RING_MAX; i++) { - edma_stats.tx_stats[i][NSS_EDMA_STATS_TX_ERR] += nerss->tx_ring[i].tx_err; - edma_stats.tx_stats[i][NSS_EDMA_STATS_TX_DROPPED] += nerss->tx_ring[i].tx_dropped; - edma_stats.tx_stats[i][NSS_EDMA_STATS_TX_DESC] += nerss->tx_ring[i].desc_cnt; - } - - /* - * edma rx ring stats - */ - for (i = 0; i < NSS_EDMA_NUM_RX_RING_MAX; i++) { - edma_stats.rx_stats[i][NSS_EDMA_STATS_RX_CSUM_ERR] += nerss->rx_ring[i].rx_csum_err; - 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; - } - - /* - * edma tx cmpl ring stats - */ - for (i = 0; i < NSS_EDMA_NUM_TXCMPL_RING_MAX; i++) { - edma_stats.txcmpl_stats[i][NSS_EDMA_STATS_TXCMPL_DESC] += nerss->txcmpl_ring[i].desc_cnt; - } - - /* - * edma rx fill ring stats - */ - for (i = 0; i < NSS_EDMA_NUM_RXFILL_RING_MAX; i++) { - edma_stats.rxfill_stats[i][NSS_EDMA_STATS_RXFILL_DESC] += nerss->rxfill_ring[i].desc_cnt; - } - - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_edma_metadata_err_stats_sync() - * Handle the syncing of EDMA error statistics. - */ -void nss_edma_metadata_err_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_edma_err_stats_sync *nerss) -{ - - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - spin_lock_bh(&nss_top->stats_lock); - - edma_stats.misc_err[NSS_EDMA_AXI_RD_ERR] += nerss->msg_err_stats.axi_rd_err; - edma_stats.misc_err[NSS_EDMA_AXI_WR_ERR] += nerss->msg_err_stats.axi_wr_err; - edma_stats.misc_err[NSS_EDMA_RX_DESC_FIFO_FULL_ERR] += nerss->msg_err_stats.rx_desc_fifo_full_err; - edma_stats.misc_err[NSS_EDMA_RX_BUF_SIZE_ERR] += nerss->msg_err_stats.rx_buf_size_err; - edma_stats.misc_err[NSS_EDMA_TX_SRAM_FULL_ERR] += nerss->msg_err_stats.tx_sram_full_err; - edma_stats.misc_err[NSS_EDMA_TX_CMPL_BUF_FULL_ERR] += nerss->msg_err_stats.tx_cmpl_buf_full_err; - edma_stats.misc_err[NSS_EDMA_PKT_LEN_LA64K_ERR] += nerss->msg_err_stats.pkt_len_la64k_err; - edma_stats.misc_err[NSS_EDMA_PKT_LEN_LE33_ERR] += nerss->msg_err_stats.pkt_len_le33_err; - edma_stats.misc_err[NSS_EDMA_DATA_LEN_ERR] += nerss->msg_err_stats.data_len_err; - edma_stats.misc_err[NSS_EDMA_ALLOC_FAIL_CNT] += nerss->msg_err_stats.alloc_fail_cnt; - edma_stats.misc_err[NSS_EDMA_QOS_INVAL_DST_DROPS] += nerss->msg_err_stats.qos_inval_dst_drops; - - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_edma_stats_notify() - * Calls statistics notifier. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_edma_stats_notify(struct nss_ctx_instance *nss_ctx) -{ - uint32_t core_id = nss_ctx->id; - - atomic_notifier_call_chain(&nss_edma_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&core_id); -} - -/* - * nss_edma_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_edma_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_edma_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_edma_stats_register_notifier); - -/* - * nss_edma_stats_unregister_notifier() - * Deregisters stats notifier. - */ -int nss_edma_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_edma_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_edma_stats_unregister_notifier); - -/* - * nss_edma_get_stats - * Sends EDMA statistics to NSS clients. - */ -void nss_edma_get_stats(uint64_t *stats, int port_id) -{ - memcpy(stats, edma_stats.port[port_id].port_stats, sizeof(uint64_t) * NSS_STATS_NODE_MAX); -} -EXPORT_SYMBOL(nss_edma_get_stats); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_edma_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_edma_stats.h deleted file mode 100644 index 305582b84..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_edma_stats.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - ****************************************************************************** - * 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. - * **************************************************************************** - */ - -/* - * nss_edma_stats.h - * NSS EDMA statistics header file. - */ - -#ifndef __NSS_EDMA_STATS_H -#define __NSS_EDMA_STATS_H - -#include "nss_core.h" - -/* - * NSS EDMA statistics APIs - */ -extern void nss_edma_stats_notify(struct nss_ctx_instance *nss_ctx); -extern void nss_edma_metadata_port_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_edma_port_stats_sync *nepss); -extern void nss_edma_metadata_ring_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_edma_ring_stats_sync *nerss); -extern void nss_edma_metadata_err_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_edma_err_stats_sync *nerss); -extern void nss_edma_stats_dentry_create(void); - -#endif /* __NSS_EDMA_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_edma_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_edma_strings.c deleted file mode 100644 index 3d9c23352..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_edma_strings.c +++ /dev/null @@ -1,350 +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 -#include "nss_strings.h" - -/* - * nss_edma_strings_stats_node - * EDMA statistics strings. - */ -struct nss_stats_info nss_edma_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_common_stats_strings_read() - * Read EDMA common node statistics names. - */ -static ssize_t nss_edma_common_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_edma_strings_stats_node, NSS_STATS_NODE_MAX); -} - -/* - * nss_edma_common_stats_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_common_stats); - -/* - * nss_edma_strings_stats_tx - */ -struct nss_stats_info nss_edma_strings_stats_tx[NSS_EDMA_STATS_TX_MAX] = { - {"tx_err" , NSS_STATS_TYPE_ERROR}, - {"tx_drops" , NSS_STATS_TYPE_DROP}, - {"desc_cnt" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_edma_txring_strings_read() - * Read EDMA txring names. - */ -static ssize_t nss_edma_txring_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_edma_strings_stats_tx, NSS_EDMA_STATS_TX_MAX); -} - -/* - * edma_txring_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_txring); - -/* - * nss_edma_strings_stats_rx - */ -struct nss_stats_info nss_edma_strings_stats_rx[NSS_EDMA_STATS_RX_MAX] = { - {"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} -}; - -/* - * nss_edma_rxring_strings_read() - * Read EDMA rxring names. - */ -static ssize_t nss_edma_rxring_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_edma_strings_stats_rx, NSS_EDMA_STATS_RX_MAX); -} - -/* - * edma_rxring_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_rxring); - -/* - * nss_edma_strings_stats_txcmpl - */ -struct nss_stats_info nss_edma_strings_stats_txcmpl[NSS_EDMA_STATS_TXCMPL_MAX] = { - {"desc_cnt" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_edma_txcmplring_strings_read() - * Read EDMA txcmplring names. - */ -static ssize_t nss_edma_txcmplring_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_edma_strings_stats_txcmpl, NSS_EDMA_STATS_TXCMPL_MAX); -} - -/* - * edma_txcmplring_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_txcmplring); - -/* - * nss_edma_strings_stats_rxfill - */ -struct nss_stats_info nss_edma_strings_stats_rxfill[NSS_EDMA_STATS_RXFILL_MAX] = { - {"desc_cnt" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_edma_rxfillring_strings_read() - * Read EDMA rxfillring names. - */ -static ssize_t nss_edma_rxfillring_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_edma_strings_stats_rxfill, NSS_EDMA_STATS_RXFILL_MAX); -} - -/* - * edma_rxfillring_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_rxfillring); - -/* - * nss_edma_strings_stats_port_type - */ -struct nss_stats_info nss_edma_strings_stats_port_type[NSS_EDMA_PORT_TYPE_MAX] = { - {"physical_port", NSS_STATS_TYPE_SPECIAL}, - {"virtual_port" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_edma_port_type_strings_read() - * Read EDMA port type names. - */ -static ssize_t nss_edma_port_type_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_edma_strings_stats_port_type, NSS_EDMA_PORT_TYPE_MAX); -} - -/* - * edma_port_type_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_port_type); - -/* - * nss_edma_strings_stats_port_ring_map - */ -struct nss_stats_info nss_edma_strings_stats_port_ring_map[NSS_EDMA_PORT_RING_MAP_MAX] = { - {"rx_ring" , NSS_STATS_TYPE_SPECIAL}, - {"tx_ring" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_edma_port_ring_map_strings_read() - * Read EDMA port ring map names. - */ -static ssize_t nss_edma_port_ring_map_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_edma_strings_stats_port_ring_map, NSS_EDMA_PORT_RING_MAP_MAX); -} - -/* - * edma_port_ring_map_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_port_ring_map); - -/* - * nss_edma_strings_stats_err_map - */ -struct nss_stats_info nss_edma_strings_stats_err_map[NSS_EDMA_ERR_STATS_MAX] = { - {"axi_rd_err" , NSS_STATS_TYPE_ERROR}, - {"axi_wr_err" , NSS_STATS_TYPE_ERROR}, - {"rx_desc_fifo_full_err", NSS_STATS_TYPE_ERROR}, - {"rx_buf_size_err" , NSS_STATS_TYPE_ERROR}, - {"tx_sram_full_err" , NSS_STATS_TYPE_ERROR}, - {"tx_cmpl_buf_full_err" , NSS_STATS_TYPE_ERROR}, - {"pkt_len_la64k_err" , NSS_STATS_TYPE_ERROR}, - {"pkt_len_le33_err" , NSS_STATS_TYPE_ERROR}, - {"data_len_err" , NSS_STATS_TYPE_ERROR}, - {"alloc_fail_cnt" , NSS_STATS_TYPE_ERROR}, - {"qos_inval_dst_drops" , NSS_STATS_TYPE_DROP} -}; - -/* - * nss_edma_err_strings_read() - * Read EDMA error names. - */ -static ssize_t nss_edma_err_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_edma_strings_stats_err_map, NSS_EDMA_ERR_STATS_MAX); -} - -/* - * edma_err_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_err); - -/* - * nss_edma_strings_dentry_create() - * Create EDMA statistics strings debug entry. - */ -void nss_edma_strings_dentry_create(void) -{ - struct dentry *edma_d; - struct dentry *edma_port_dir_d; - struct dentry *edma_rings_dir_d; - struct dentry *edma_rx_dir_d; - struct dentry *edma_tx_dir_d; - struct dentry *edma_rxfill_dir_d; - struct dentry *edma_txcmpl_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 port stats. - */ - edma_port_dir_d = debugfs_create_dir("ports", edma_d); - if (!edma_port_dir_d) { - nss_warning("Failed to create qca-nss-drv/strings/edma/ports directory"); - goto fail; - } - - file_d = debugfs_create_file("common_stats_str", 0400, edma_port_dir_d, &nss_top_main, &nss_edma_common_stats_strings_ops); - if (!file_d) { - nss_warning("Failed to create qca-nss-drv/strings/edma/ports/common_stats_str file"); - goto fail; - } - - file_d = debugfs_create_file("type", 0400, edma_port_dir_d, &nss_top_main, &nss_edma_port_type_strings_ops); - if (!file_d) { - nss_warning("Failed to create qca-nss-drv/strings/edma/ports/type file"); - goto fail; - } - - file_d = debugfs_create_file("ring_map", 0400, edma_port_dir_d, &nss_top_main, &nss_edma_port_ring_map_strings_ops); - if (!file_d) { - nss_warning("Failed to create qca-nss-drv/strings/edma/ports/ring_map file"); - goto fail; - } - - /* - * edma error stats - */ - file_d = debugfs_create_file("err_stats", 0400, edma_d, &nss_top_main, &nss_edma_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 - */ - edma_tx_dir_d = debugfs_create_dir("tx", edma_rings_dir_d); - if (!edma_tx_dir_d) { - nss_warning("Failed to create qca-nss-drv/strings/edma/rings/tx directory"); - goto fail; - } - - file_d = debugfs_create_file("tx_str", 0400, edma_tx_dir_d, &nss_top_main, &nss_edma_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 - */ - edma_rx_dir_d = debugfs_create_dir("rx", edma_rings_dir_d); - if (!edma_rx_dir_d) { - nss_warning("Failed to create qca-nss-drv/strings/edma/rings/rx directory"); - goto fail; - } - - file_d = debugfs_create_file("rx_str", 0400, edma_rx_dir_d, &nss_top_main, &nss_edma_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 - */ - edma_txcmpl_dir_d = debugfs_create_dir("txcmpl", edma_rings_dir_d); - if (!edma_txcmpl_dir_d) { - nss_warning("Failed to create qca-nss-drv/strings/edma/rings/txcmpl directory"); - goto fail; - } - - file_d = debugfs_create_file("txcmpl_str", 0400, edma_txcmpl_dir_d, &nss_top_main, &nss_edma_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 - */ - edma_rxfill_dir_d = debugfs_create_dir("rxfill", edma_rings_dir_d); - if (!edma_rxfill_dir_d) { - nss_warning("Failed to create qca-nss-drv/strings/edma/rings/rxfill directory"); - goto fail; - } - - file_d = debugfs_create_file("rxfill_str", 0400, edma_rxfill_dir_d, &nss_top_main, &nss_edma_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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_edma_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_edma_strings.h deleted file mode 100644 index b211975ff..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_edma_strings.h +++ /dev/null @@ -1,30 +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_EDMA_STRINGS_H -#define __NSS_EDMA_STRINGS_H - -extern struct nss_stats_info nss_edma_strings_stats_node[NSS_STATS_NODE_MAX]; -extern struct nss_stats_info nss_edma_strings_stats_tx[NSS_EDMA_STATS_TX_MAX]; -extern struct nss_stats_info nss_edma_strings_stats_rx[NSS_EDMA_STATS_RX_MAX]; -extern struct nss_stats_info nss_edma_strings_stats_txcmpl[NSS_EDMA_STATS_TXCMPL_MAX]; -extern struct nss_stats_info nss_edma_strings_stats_rxfill[NSS_EDMA_STATS_RXFILL_MAX]; -extern struct nss_stats_info nss_edma_strings_stats_port_type[NSS_EDMA_PORT_TYPE_MAX]; -extern struct nss_stats_info nss_edma_strings_stats_port_ring_map[NSS_EDMA_PORT_RING_MAP_MAX]; -extern struct nss_stats_info nss_edma_strings_stats_err_map[NSS_EDMA_ERR_STATS_MAX]; -extern void nss_edma_strings_dentry_create(void); - -#endif /* __NSS_EDMA_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx.c b/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx.c deleted file mode 100644 index eba62afae..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_eth_rx.c - * NSS ETH_RX APIs - */ - -#include -#include "nss_eth_rx_stats.h" -#include "nss_eth_rx_strings.h" - -/* - ********************************** - Rx APIs - ********************************** - */ - -/* - * nss_eth_rx_interface_handler() - * Handle NSS -> HLOS messages for ETH_RX node - */ -static void nss_eth_rx_interface_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_eth_rx_msg *nem = (struct nss_eth_rx_msg *)ncm; - - /* - * Is this a valid request/response packet? - */ - if (nem->cm.type >= NSS_METADATA_TYPE_ETH_RX_MAX) { - nss_warning("%px: received invalid message %d for eth_rx interface", nss_ctx, nem->cm.type); - return; - } - - switch (nem->cm.type) { - case NSS_RX_METADATA_TYPE_ETH_RX_STATS_SYNC: - /* - * Update driver statistics and send stats notifications to the registered modules. - */ - nss_eth_rx_metadata_stats_sync(nss_ctx, &nem->msg.node_sync); - nss_eth_rx_stats_notify(nss_ctx); - 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); - } - } -} - -/* - * nss_eth_rx_register_handler() - */ -void nss_eth_rx_register_handler(struct nss_ctx_instance *nss_ctx) -{ - nss_core_register_handler(nss_ctx, NSS_ETH_RX_INTERFACE, nss_eth_rx_interface_handler, NULL); - - nss_eth_rx_stats_dentry_create(); - nss_eth_rx_strings_dentry_create(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx_stats.c deleted file mode 100644 index cfc705773..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx_stats.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_eth_rx_stats.h" -#include "nss_eth_rx_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_eth_rx_stats_notifier); - -uint64_t nss_eth_rx_stats[NSS_ETH_RX_STATS_MAX]; /* ETH_RX statistics */ -uint64_t nss_eth_rx_exception_stats[NSS_ETH_RX_EXCEPTION_EVENT_MAX]; /* Unknown protocol exception events per interface */ - -/* - * nss_eth_rx_stats_read() - * Read ETH_RX stats. - */ -static ssize_t nss_eth_rx_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int32_t i; - - /* - * 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_ETH_RX_STATS_MAX + NSS_ETH_RX_EXCEPTION_EVENT_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; - } - - /* - * 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, "eth_rx", NSS_STATS_SINGLE_CORE); - - size_wr += nss_stats_fill_common_stats(NSS_ETH_RX_INTERFACE, NSS_STATS_SINGLE_INSTANCE, lbuf, size_wr, size_al, "eth_rx"); - - /* - * eth_rx node stats. - */ - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; (i < NSS_ETH_RX_STATS_MAX); i++) { - stats_shadow[i] = nss_eth_rx_stats[i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - - size_wr += nss_stats_print("eth_rx", "eth_rx node stats" - , NSS_STATS_SINGLE_INSTANCE - , nss_eth_rx_strings_stats - , stats_shadow - , NSS_ETH_RX_STATS_MAX - , lbuf, size_wr, size_al); - - /* - * Exception stats. - */ - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; (i < NSS_ETH_RX_EXCEPTION_EVENT_MAX); i++) { - stats_shadow[i] = nss_eth_rx_exception_stats[i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - - size_wr += nss_stats_print("eth_rx", "eth_rx exception stats" - , NSS_STATS_SINGLE_INSTANCE - , nss_eth_rx_strings_exception_stats - , stats_shadow - , NSS_ETH_RX_EXCEPTION_EVENT_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_eth_rx_stats_ops. - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(eth_rx); - -/* - * nss_eth_rx_stats_dentry_create() - * Create eth_rx statistics debug entry. - */ -void nss_eth_rx_stats_dentry_create(void) -{ - nss_stats_create_dentry("eth_rx", &nss_eth_rx_stats_ops); -} - -/* - * nss_eth_rx_metadata_stats_sync() - * Handle the syncing of ETH_RX node statistics. - */ -void nss_eth_rx_metadata_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_eth_rx_node_sync *nens) -{ - int32_t i; - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - spin_lock_bh(&nss_top->stats_lock); - - nss_top->stats_node[NSS_ETH_RX_INTERFACE][NSS_STATS_NODE_RX_PKTS] += nens->node_stats.rx_packets; - nss_top->stats_node[NSS_ETH_RX_INTERFACE][NSS_STATS_NODE_RX_BYTES] += nens->node_stats.rx_bytes; - nss_top->stats_node[NSS_ETH_RX_INTERFACE][NSS_STATS_NODE_TX_PKTS] += nens->node_stats.tx_packets; - nss_top->stats_node[NSS_ETH_RX_INTERFACE][NSS_STATS_NODE_TX_BYTES] += nens->node_stats.tx_bytes; - - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - nss_top->stats_node[NSS_ETH_RX_INTERFACE][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + i] += nens->node_stats.rx_dropped[i]; - } - - nss_eth_rx_stats[NSS_ETH_RX_STATS_TOTAL_TICKS] += nens->total_ticks; - nss_eth_rx_stats[NSS_ETH_RX_STATS_WORST_CASE_TICKS] += nens->worst_case_ticks; - nss_eth_rx_stats[NSS_ETH_RX_STATS_ITERATIONS] += nens->iterations; - - for (i = 0; i < NSS_ETH_RX_EXCEPTION_EVENT_MAX; i++) { - nss_eth_rx_exception_stats[i] += nens->exception_events[i]; - } - - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_eth_rx_stats_notify() - * Sends notifications to the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_eth_rx_stats_notify(struct nss_ctx_instance *nss_ctx) -{ - struct nss_eth_rx_stats_notification eth_rx_stats; - - eth_rx_stats.core_id = nss_ctx->id; - memcpy(eth_rx_stats.cmn_node_stats, nss_top_main.stats_node[NSS_ETH_RX_INTERFACE], sizeof(eth_rx_stats.cmn_node_stats)); - memcpy(eth_rx_stats.special_stats, nss_eth_rx_stats, sizeof(eth_rx_stats.special_stats)); - memcpy(eth_rx_stats.exception_stats, nss_eth_rx_exception_stats, sizeof(eth_rx_stats.exception_stats)); - atomic_notifier_call_chain(&nss_eth_rx_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)ð_rx_stats); -} - -/* - * nss_eth_rx_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_eth_rx_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_eth_rx_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_eth_rx_stats_register_notifier); - -/* - * nss_eth_rx_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_eth_rx_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_eth_rx_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_eth_rx_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx_stats.h deleted file mode 100644 index c5470ba9c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx_stats.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -#ifndef __NSS_ETH_RX_STATS_H -#define __NSS_ETH_RX_STATS_H - -#include - -/* - * nss_eth_rx_stats.h - * NSS driver ETH_RX statistics header file. - */ - -/* - * Request/Response types - */ -enum nss_eth_rx_metadata_types { - NSS_RX_METADATA_TYPE_ETH_RX_STATS_SYNC, - NSS_METADATA_TYPE_ETH_RX_MAX, -}; - -/* - * The NSS eth_rx node stats structure. - */ -struct nss_eth_rx_node_sync { - struct nss_cmn_node_stats node_stats; - /* Common node stats for ETH_RX */ - uint32_t total_ticks; /* Total clock ticks spend inside the eth_rx */ - uint32_t worst_case_ticks; /* Worst case iteration of the eth_rx in ticks */ - uint32_t iterations; /* Number of iterations around the eth_rx */ - uint32_t exception_events[NSS_ETH_RX_EXCEPTION_EVENT_MAX]; - /* Number of ETH_RX exception events */ -}; - -/* - * Message structure to send/receive eth_rx commands - */ -struct nss_eth_rx_msg { - struct nss_cmn_msg cm; /* Message Header */ - union { - struct nss_eth_rx_node_sync node_sync; /* Message: node statistics sync */ - } msg; -}; - -/* - * eth_rx statistics APIs - */ -extern void nss_eth_rx_stats_notify(struct nss_ctx_instance *nss_ctx); -extern void nss_eth_rx_metadata_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_eth_rx_node_sync *nens); -extern void nss_eth_rx_stats_dentry_create(void); - -#endif /* __NSS_ETH_RX_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx_strings.c deleted file mode 100644 index 8412b444d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx_strings.c +++ /dev/null @@ -1,106 +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" - -/* - * nss_eth_rx_strings_stats - * Ethernet Rx statistics strings. - */ -struct nss_stats_info nss_eth_rx_strings_stats[NSS_ETH_RX_STATS_MAX] = { - {"ticks" , NSS_STATS_TYPE_SPECIAL}, - {"worst_ticks" , NSS_STATS_TYPE_SPECIAL}, - {"iterations" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_eth_rx_strings_exception_stats - * Interface statistics strings for unknown exceptions. - */ -struct nss_stats_info nss_eth_rx_strings_exception_stats[NSS_ETH_RX_EXCEPTION_EVENT_MAX] = { - {"unknown_l3_protocol" , NSS_STATS_TYPE_EXCEPTION}, - {"eth_hdr_missing" , NSS_STATS_TYPE_EXCEPTION}, - {"vlan_missing" , NSS_STATS_TYPE_EXCEPTION}, - {"trustsec_hdr_missing" , NSS_STATS_TYPE_EXCEPTION} -}; - -/* - * nss_eth_rx_special_stats_strings_read() - * Read Ethernet Rx special node statistics names. - */ -static ssize_t nss_eth_rx_special_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_eth_rx_strings_stats, NSS_ETH_RX_STATS_MAX); -} - -/* - * nss_eth_rx_exception_stats_strings_read() - * Read Ethernet Rx exception statistics names. - */ -static ssize_t nss_eth_rx_exception_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_eth_rx_strings_exception_stats, NSS_ETH_RX_EXCEPTION_EVENT_MAX); -} - -/* - * nss_eth_rx_special_stats_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(eth_rx_special_stats); - -/* - * nss_eth_rx_exception_stats_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(eth_rx_exception_stats); - -/* - * nss_eth_rx_strings_dentry_create() - * Create Ethernet Rx statistics strings debug entry. - */ -void nss_eth_rx_strings_dentry_create(void) -{ - struct dentry *eth_rx_d = NULL; - struct dentry *eth_rx_spcl_stats_d = NULL; - struct dentry *eth_rx_excp_stats_d = NULL; - - if (!nss_top_main.strings_dentry) { - nss_warning("qca-nss-drv/strings is not present"); - return; - } - - eth_rx_d = debugfs_create_dir("eth_rx", nss_top_main.strings_dentry); - if (!eth_rx_d) { - nss_warning("Failed to create qca-nss-drv/strings/eth_rx directory"); - return; - } - - eth_rx_spcl_stats_d = debugfs_create_file("special_stats_str", 0400, eth_rx_d, &nss_top_main, &nss_eth_rx_special_stats_strings_ops); - if (!eth_rx_spcl_stats_d) { - nss_warning("Failed to create qca-nss-drv/stats/eth_rx/special_stats_str file"); - debugfs_remove_recursive(eth_rx_d); - return; - } - - eth_rx_excp_stats_d = debugfs_create_file("exception_stats_str", 0400, eth_rx_d, &nss_top_main, &nss_eth_rx_exception_stats_strings_ops); - if (!eth_rx_excp_stats_d) { - nss_warning("Failed to create qca-nss-drv/stats/eth_rx/exception_stats_str file"); - debugfs_remove_recursive(eth_rx_d); - return; - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx_strings.h deleted file mode 100644 index 2f40440f3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_eth_rx_strings.h +++ /dev/null @@ -1,26 +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_ETH_RX_STRINGS_H -#define __NSS_ETH_RX_STRINGS_H - -extern struct nss_stats_info nss_eth_rx_strings_stats[NSS_ETH_RX_STATS_MAX]; -extern struct nss_stats_info nss_eth_rx_strings_exception_stats[NSS_ETH_RX_EXCEPTION_EVENT_MAX]; -extern void nss_eth_rx_strings_dentry_create(void); - -#endif /* __NSS_ETH_RX_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_freq.c b/feeds/ipq807x/qca-nss-drv/src/nss_freq.c deleted file mode 100644 index d55bd63b6..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_freq.c +++ /dev/null @@ -1,467 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_freq.c - * NSS frequency change APIs - */ - -#include "nss_stats.h" -#include "nss_tx_rx_common.h" -#include "nss_freq_log.h" -#include "nss_freq_stats.h" - -#define NSS_ACK_STARTED 0 -#define NSS_ACK_FINISHED 1 - -#define NSS_FREQ_USG_AVG_FREQUENCY 1000 /* Time in ms over which CPU Usage is averaged */ -#define NSS_FREQ_CPU_USAGE_MAX_BOUND 75 /* MAX CPU usage equivalent to running max instructions excluding all the hazards */ -#define NSS_FREQ_CPU_USAGE_MAX 100 /* MAX CPU usage equivalent to running max instructions including all the hazards. - This is also the ideal maximum usage value. */ - -/* - * Spinlock to protect the global data structure nss_freq_cpu_status - */ -DEFINE_SPINLOCK(nss_freq_cpu_usage_lock); - -/* - * At any point, this object has the latest data about CPU utilization. - */ -struct nss_freq_cpu_usage nss_freq_cpu_status; - -extern struct nss_runtime_sampling nss_runtime_samples; -extern struct workqueue_struct *nss_wq; -extern nss_work_t *nss_work; - -/* - * nss_freq_msg_init() - * Initialize the freq message - */ -static void nss_freq_msg_init(struct nss_corefreq_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, - void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} - -/* - * nss_freq_handle_ack() - * Handle the nss ack of frequency change. - */ -static void nss_freq_handle_ack(struct nss_ctx_instance *nss_ctx, struct nss_freq_msg *nfa) -{ - if (nfa->ack == NSS_ACK_STARTED) { - /* - * NSS finished start noficiation - HW change clocks and send end notification - */ - nss_info("%px: NSS ACK Received: %d - Change HW CLK/Send Finish to NSS\n", nss_ctx, nfa->ack); - - return; - } - - if (nfa->ack == NSS_ACK_FINISHED) { - /* - * NSS finished end notification - Done - */ - 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("%px: NSS had an error - Running: %dmhz\n", nss_ctx, nfa->freq_current); -} - -/* - * nss_freq_queue_work() - * Queue Work to the NSS Workqueue based on Current index. - */ -static bool nss_freq_queue_work(void) -{ - nss_freq_scales_t index = nss_runtime_samples.freq_scale_index; - - BUG_ON(!nss_wq); - - nss_info("frequency:%d index:%d sample count:%x\n", nss_runtime_samples.freq_scale[index].frequency, - index, nss_runtime_samples.average); - - /* - * schedule freq change with autoscale ON - */ - return nss_freq_sched_change(index, true); -} - -/* - * nss_freq_get_cpu_usage() - * Returns the CPU usage value in percentage at any instance for a required core. Returns -1 in case of an error. - * - * Calculation frequency is 1 second. Range of usage is 0-100. This API returns -1 if CPU usage is requested for core 1. - * TODO: Extend this API to get CPU usage for core 1. - */ -int8_t nss_freq_get_cpu_usage(uint32_t core_id) -{ - int8_t usage; - - if (core_id == 0) { - spin_lock_bh(&nss_freq_cpu_usage_lock); - usage = nss_freq_cpu_status.used; - spin_unlock_bh(&nss_freq_cpu_usage_lock); - - return usage; - } - - nss_warning("CPU usage functionality is not supported for core %u\n", core_id); - return -1; -} - -/* - * nss_freq_compute_cpu_usage() - * Computes the CPU utilization and maximum-minumun cpu utilization since boot. - */ -static void nss_freq_compute_cpu_usage(struct nss_ctx_instance *nss_ctx, uint32_t inst_cnt) -{ - uint32_t estimated_ins_capacity; - uint8_t actual_usage; - uint8_t usage; - - spin_lock_bh(&nss_freq_cpu_usage_lock); - - /* - * If actual CPU usage turns up higher than 100, there is something wrong with the received data. - * Upper bound average varies between 80% usage to 100% usage. - * - * TODO: To improve estimation algorithm for calculating how many actual instructions are executed. - */ - actual_usage = (inst_cnt * 100) / nss_freq_cpu_status.max_ins; - if ((actual_usage > NSS_FREQ_CPU_USAGE_MAX) || (actual_usage == 0)) { - spin_unlock_bh(&nss_freq_cpu_usage_lock); - return; - } - - /* - * Simpler version of below math: This is calculating the reduced number of maximum instructions - * estimated_ins_capacity = nss_freq_cpu_status.avg_up% of nss_freq_cpu_status.max_ins - * Calculating usage percentage: usage = (inst_cnt/estimated_ins_capacity) * 100 - */ - estimated_ins_capacity = ((NSS_FREQ_CPU_USAGE_MAX_BOUND * nss_freq_cpu_status.max_ins) / 100); - if (estimated_ins_capacity == 0) { - spin_unlock_bh(&nss_freq_cpu_usage_lock); - return; - } - usage = (inst_cnt * 100) / estimated_ins_capacity; - - /* - * Average the instructions over NSS_FREQ_USG_AVG_FREQUENCY ms - */ - if (nss_freq_cpu_status.avg_ctr == NSS_FREQ_USG_AVG_FREQUENCY) { - nss_freq_cpu_status.used = nss_freq_cpu_status.total / NSS_FREQ_USG_AVG_FREQUENCY; - - /* - * Due to our estimation, this could go beyond the end limit of 100% - */ - if (nss_freq_cpu_status.used > NSS_FREQ_CPU_USAGE_MAX) { - nss_freq_cpu_status.used = NSS_FREQ_CPU_USAGE_MAX; - } - - /* - * Getting the all time max and min usage - */ - if (nss_freq_cpu_status.used > nss_freq_cpu_status.max) { - nss_freq_cpu_status.max = nss_freq_cpu_status.used; - } - - if (nss_freq_cpu_status.used < nss_freq_cpu_status.min) { - nss_freq_cpu_status.min = nss_freq_cpu_status.used; - } - - 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; - nss_freq_cpu_status.avg_ctr = 0; - } - - nss_freq_cpu_status.total += usage; - nss_freq_cpu_status.avg_ctr++; - - spin_unlock_bh(&nss_freq_cpu_usage_lock); -} - -/* - * nss_freq_scale_frequency() - * Frequency scaling algorithm to scale frequency. - */ -void nss_freq_scale_frequency(struct nss_ctx_instance *nss_ctx, uint32_t inst_cnt) -{ - uint32_t b_index; - uint32_t minimum; - uint32_t maximum; - uint32_t index = nss_runtime_samples.freq_scale_index; - - /* - * We do not accept any statistics if auto scaling is off, - * we start with a fresh sample set when scaling is - * eventually turned on. - */ - if (!nss_cmd_buf.auto_scale && nss_runtime_samples.initialized) { - return; - } - - /* - * Delete Current Index Value, Add New Value, Recalculate new Sum, Shift Index - */ - b_index = nss_runtime_samples.buffer_index; - - nss_runtime_samples.sum = nss_runtime_samples.sum - nss_runtime_samples.buffer[b_index]; - nss_runtime_samples.buffer[b_index] = inst_cnt; - nss_runtime_samples.sum = nss_runtime_samples.sum + nss_runtime_samples.buffer[b_index]; - nss_runtime_samples.buffer_index = (b_index + 1) & NSS_SAMPLE_BUFFER_MASK; - - if (nss_runtime_samples.sample_count < NSS_SAMPLE_BUFFER_SIZE) { - nss_runtime_samples.sample_count++; - - /* - * Samples Are All Ready, Start Auto Scale - */ - if (nss_runtime_samples.sample_count == NSS_SAMPLE_BUFFER_SIZE ) { - nss_cmd_buf.auto_scale = 1; - nss_runtime_samples.freq_scale_ready = 1; - nss_runtime_samples.initialized = 1; - } - - return; - } - - nss_runtime_samples.average = nss_runtime_samples.sum / nss_runtime_samples.sample_count; - - /* - * Print out statistics every 10 samples - */ - if (nss_runtime_samples.message_rate_limit++ >= NSS_MESSAGE_RATE_LIMIT) { - 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; - } - - /* - * Don't scale if we are not ready or auto scale is disabled. - */ - if ((nss_runtime_samples.freq_scale_ready != 1) || (nss_cmd_buf.auto_scale != 1)) { - return; - } - - /* - * Scale Algorithmn - * Algorithmn will limit how fast it will transition each scale, by the number of samples seen. - * If any sample is out of scale during the idle count, the rate_limit will reset to 0. - * Scales are limited to the max number of cpu scales we support. - */ - if (nss_runtime_samples.freq_scale_rate_limit_up++ >= NSS_FREQUENCY_SCALE_RATE_LIMIT_UP) { - maximum = nss_runtime_samples.freq_scale[index].maximum; - if ((nss_runtime_samples.average > maximum) && (index < (NSS_FREQ_MAX_SCALE - 1))) { - nss_runtime_samples.freq_scale_index++; - nss_runtime_samples.freq_scale_ready = 0; - - /* - * If fail to increase frequency, decrease index - */ - nss_trace("frequency increase to %d inst:%x > maximum:%x\n", nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency, inst_cnt, maximum); - if (!nss_freq_queue_work()) { - nss_runtime_samples.freq_scale_index--; - } - } - - /* - * Reset the down scale counter based on running average, so can idle properly - */ - if (nss_runtime_samples.average > maximum) { - nss_trace("down scale timeout reset running average:%x\n", nss_runtime_samples.average); - nss_runtime_samples.freq_scale_rate_limit_down = 0; - } - - nss_runtime_samples.freq_scale_rate_limit_up = 0; - return; - } - - 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) { - nss_runtime_samples.freq_scale_index--; - nss_runtime_samples.freq_scale_ready = 0; - - /* - * If fail to decrease frequency, increase index - */ - nss_trace("frequency decrease to %d inst:%x < minumum:%x\n", nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency, nss_runtime_samples.average, minimum); - if (!nss_freq_queue_work()) { - nss_runtime_samples.freq_scale_index++; - } - } - nss_runtime_samples.freq_scale_rate_limit_down = 0; - return; - } -} - -/* - * nss_freq_handle_core_stats() - * Handle the core stats. - */ -static void nss_freq_handle_core_stats(struct nss_ctx_instance *nss_ctx, struct nss_core_stats *core_stats) -{ - uint32_t inst_cnt = core_stats->inst_cnt_total; - - /* - * compute CPU utilization by using the instruction count - */ - nss_freq_compute_cpu_usage(nss_ctx, inst_cnt); - - /* - * Perform frequency scaling - */ - nss_freq_scale_frequency(nss_ctx, inst_cnt); -} - -/* - * nss_freq_interface_handler() - * Handle NSS -> HLOS messages for Frequency Changes and Statistics. - */ -static void nss_freq_interface_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) { - - struct nss_corefreq_msg *ncfm = (struct nss_corefreq_msg *)ncm; - - /* - * Trace Messages - */ - nss_freq_log_rx_msg(ncfm); - - switch (ncfm->cm.type) { - case COREFREQ_METADATA_TYPE_TX_FREQ_ACK: - nss_freq_handle_ack(nss_ctx, &ncfm->msg.nfc); - break; - case COREFREQ_METADATA_TYPE_TX_CORE_STATS: - nss_freq_handle_core_stats(nss_ctx, &ncfm->msg.ncs); - 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); - } - } -} - -/* - * nss_freq_change() - * NSS frequency change API. - */ -nss_tx_status_t nss_freq_change(struct nss_ctx_instance *nss_ctx, uint32_t eng, uint32_t stats_enable, uint32_t start_or_end) -{ - struct nss_corefreq_msg ncm; - struct nss_freq_msg *nfc; - - nss_info("%px: frequency changing to: %d\n", nss_ctx, eng); - - /* - * Update the max instruction count for a frequency during down scaling. - * Better to update this as late as possible in the frequency update call. - */ - spin_lock_bh(&nss_freq_cpu_usage_lock); - nss_freq_cpu_status.max_ins = eng / 1000; - spin_unlock_bh(&nss_freq_cpu_usage_lock); - - nss_freq_msg_init(&ncm, NSS_COREFREQ_INTERFACE, NSS_TX_METADATA_TYPE_NSS_FREQ_CHANGE, - sizeof(struct nss_freq_msg), NULL, NULL); - nfc = &ncm.msg.nfc; - nfc->frequency = eng; - nfc->start_or_end = start_or_end; - nfc->stats_enable = stats_enable; - - return nss_core_send_cmd(nss_ctx, &ncm, sizeof(ncm), NSS_NBUF_PAYLOAD_SIZE); -} - -/* - * nss_freq_sched_change() - * Schedule a frequency work. - */ -bool nss_freq_sched_change(nss_freq_scales_t index, bool auto_scale) -{ - if (index >= NSS_FREQ_MAX_SCALE) { - nss_info("NSS freq scale beyond limit\n"); - return false; - } - - nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC); - if (!nss_work) { - nss_info("NSS Freq WQ kmalloc fail"); - return false; - } - - INIT_WORK((struct work_struct *)nss_work, nss_hal_wq_function); - - nss_work->frequency = nss_runtime_samples.freq_scale[index].frequency; - - nss_work->stats_enable = auto_scale; - nss_cmd_buf.current_freq = nss_work->frequency; - queue_work(nss_wq, (struct work_struct *)nss_work); - - return true; -} - -/* - * nss_freq_get_context() - * Get NSS context instance for frequency. - */ -struct nss_ctx_instance *nss_freq_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.frequency_handler_id]; -} -EXPORT_SYMBOL(nss_freq_get_context); - -/* - * nss_freq_register_handler() - */ -void nss_freq_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_freq_get_context(); - nss_core_register_handler(nss_ctx, NSS_COREFREQ_INTERFACE, nss_freq_interface_handler, NULL); -} - -/* - * nss_freq_cpu_usage_init() - * Initialize cpu usage computing. - * - * TODO: Add support to retrieve CPU usage even if frequency scaling is disabled. - */ -void nss_freq_init_cpu_usage(void) -{ - nss_freq_cpu_status.used = 0; - nss_freq_cpu_status.max_ins = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency / 1000; - nss_freq_cpu_status.total = 0; - nss_freq_cpu_status.max = 0; /* Initial value is 0 to capture the highest most value during the run */ - nss_freq_cpu_status.min = NSS_FREQ_CPU_USAGE_MAX; /* Initial value is 100 to capture the lowest most value during the run */ - nss_freq_cpu_status.avg_up = NSS_FREQ_CPU_USAGE_MAX_BOUND; - nss_freq_cpu_status.avg_ctr = 0; - - nss_freq_stats_dentry_create(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_freq_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_freq_log.c deleted file mode 100644 index 9b96184cd..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_freq_log.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_freq_log.c - * NSS Freq logger file. - */ - -#include "nss_core.h" - -/* - * nss_freq_log_message_types_str - * Freq message strings - */ -static int8_t *nss_freq_log_message_types_str[COREFREQ_METADATA_TYPE_MAX] __maybe_unused = { - "Freq Error Message", - "Freq Change", - "Freq ACK", - "TX Core Stats", -}; - -/* - * nss_freq_log_msg() - * Log NSS Freq message. - */ -static void nss_freq_log_msg(struct nss_corefreq_msg *ncm) -{ - struct nss_freq_msg *nfm __maybe_unused = &ncm->msg.nfc; - nss_trace("%px: NSS Freq Message:\n" - "Frequency request: %d\n" - "Frequency start/end: %d\n" - "Frequency stats enable: %d\n" - "Current Frequency: %d\n" - "Frequency ACK: %d\n", - nfm, nfm->frequency, nfm->start_or_end, - nfm->stats_enable, nfm->freq_current, - nfm->ack); -} - -/* - * nss_freq_log_verbose() - * Log message contents. - */ -static void nss_freq_log_verbose(struct nss_corefreq_msg *ncm) -{ - switch (ncm->cm.type) { - case COREFREQ_METADATA_TYPE_RX_FREQ_CHANGE: - case COREFREQ_METADATA_TYPE_TX_FREQ_ACK: - nss_freq_log_msg(ncm); - break; - - case COREFREQ_METADATA_TYPE_TX_CORE_STATS: - /* - * No log for a valid stats message. - */ - break; - - default: - nss_warning("%px: Invalid message type\n", ncm); - break; - } -} - -/* - * nss_freq_log_rx_msg() - * Log messages received from FW. - */ -void nss_freq_log_rx_msg(struct nss_corefreq_msg *ncm) -{ - if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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]); - -verbose: - nss_freq_log_verbose(ncm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_freq_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_freq_log.h deleted file mode 100644 index ab7d7d4f6..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_freq_log.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_FREQ_LOG_H -#define __NSS_FREQ_LOG_H - -/* - * nss_freq_log.h - * NSS frequency log header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_freq_log_rx_msg - * Logs a frequency message that is received from the NSS firmware. - */ -void nss_freq_log_rx_msg(struct nss_corefreq_msg *nbm); - -#endif /* __NSS_FREQ_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_freq_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_freq_stats.c deleted file mode 100644 index 32e62c3c6..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_freq_stats.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_freq_stats.c - * NSS Frequency statistics APIs. - */ - -#include "nss_stats.h" -#include "nss_tx_rx_common.h" - -/* - * At any point, this object has the latest data about CPU utilization. - */ -extern struct nss_freq_cpu_usage nss_freq_cpu_status; - -/* - * Spinlock to protect the global data structure nss_freq_cpu_status - */ -extern spinlock_t nss_freq_cpu_usage_lock; - -/* - * nss_freq_stats_read() - * Read frequency stats and display CPU information. - */ -static ssize_t nss_freq_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - /* - * max output lines = Should change in case of number of lines below. - */ - uint32_t max_output_lines = (2 + 3) + 5; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - size_t size_wr = 0; - ssize_t bytes_read = 0; - uint32_t avg, max, min; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(!lbuf)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - size_wr = scnprintf(lbuf, size_al, "CPU Utilization:\n"); - - spin_lock_bh(&nss_freq_cpu_usage_lock); - avg = nss_freq_cpu_status.used; - max = nss_freq_cpu_status.max; - min = nss_freq_cpu_status.min; - spin_unlock_bh(&nss_freq_cpu_usage_lock); - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Note: Averaged over 1 second\n\n"); - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Core 0:\n"); - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Min\tAvg\tMax\n"); - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, " %u%%\t %u%%\t %u%%\n\n", min, avg, max); - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(lbuf); - - return bytes_read; -} - -/* - * nss_freq_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(freq) - -/* - * nss_freq_dentry_create() - */ -void nss_freq_stats_dentry_create(void) -{ - nss_stats_create_dentry("cpu_load_ubi", &nss_freq_stats_ops); -} \ No newline at end of file diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_freq_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_freq_stats.h deleted file mode 100644 index 72e00cc86..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_freq_stats.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_freq_stats.h - * NSS Frequency statistics header file. - */ - -#ifndef __NSS_FREQ_STATS_H -#define __NSS_FREQ_STATS_H - -#include "nss_core.h" - -extern void nss_freq_stats_dentry_create(void); - -#endif /* __NSS_FREQ_STATS_H */ \ No newline at end of file diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gmac_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_gmac_stats.c deleted file mode 100644 index 23f5924e2..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gmac_stats.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - ************************************************************************** - * 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_gmac_stats.h" - -/* - * nss_gmac_stats_str - * GMAC stats strings. - */ -struct nss_stats_info nss_gmac_stats_str[NSS_GMAC_STATS_MAX] = { - {"ticks" , NSS_STATS_TYPE_SPECIAL}, - {"worst_ticks" , NSS_STATS_TYPE_SPECIAL}, - {"iterations" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_gmac_stats_read() - * Read GMAC stats. - */ -ssize_t nss_gmac_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - uint32_t i, id; - - /* - * max output lines = ((#stats + start tag + one blank) * #GMACs) Number of Extra outputlines for future - * reference to add new stats + start/end tag + 3 blank - */ - uint32_t max_output_lines = NSS_GMAC_STATS_MAX * NSS_MAX_PHYSICAL_INTERFACES + 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_GMAC_STATS_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, "gmac", NSS_STATS_SINGLE_CORE); - - for (id = 0; id < NSS_MAX_PHYSICAL_INTERFACES; id++) { - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; (i < NSS_GMAC_STATS_MAX); i++) { - stats_shadow[i] = nss_top_main.stats_gmac[id][i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("gmac", "gmac stats", id - , nss_gmac_stats_str - , stats_shadow - , NSS_GMAC_STATS_MAX - , lbuf, size_wr, size_al); - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ngmac stats end\n\n"); - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(lbuf); - kfree(stats_shadow); - - return bytes_read; -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gmac_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_gmac_stats.h deleted file mode 100644 index 646143ed0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gmac_stats.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -#ifndef __NSS_GMAC_STATS_H -#define __NSS_GMAC_STATS_H - -#include - -/* - * GMAC node statistics - */ -enum nss_stats_gmac { - NSS_GMAC_STATS_TOTAL_TICKS, /* Total clock ticks spend inside the GMAC */ - NSS_GMAC_STATS_WORST_CASE_TICKS, /* Worst case iteration of the GMAC in ticks */ - NSS_GMAC_STATS_ITERATIONS, /* Number of iterations around the GMAC */ - NSS_GMAC_STATS_MAX, -}; - -extern ssize_t nss_gmac_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos); -#endif /* __NSS_GMAC_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre.c deleted file mode 100644 index 46cd72c71..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre.c +++ /dev/null @@ -1,411 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2017-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_gre_stats.h" -#include "nss_gre_log.h" -#include "nss_gre_strings.h" - -#define NSS_GRE_TX_TIMEOUT 3000 /* 3 Seconds */ - -/* - * Private data structure - */ -static struct { - struct semaphore sem; - struct completion complete; - int response; - void *cb; - void *app_data; -} nss_gre_pvt; - -/* - * TODO: Register separate callbacks for inner and outer GRE nodes. - */ -static atomic64_t pkt_cb_addr = ATOMIC64_INIT(0); - -/* - * nss_gre_inner_rx_handler() - * GRE inner rx handler. - */ -static void nss_gre_inner_rx_handler(struct net_device *dev, struct sk_buff *skb, - __attribute__((unused)) struct napi_struct *napi) -{ - nss_gre_data_callback_t cb; - - nss_gre_pkt_callback_t scb = (nss_gre_pkt_callback_t)(unsigned long)atomic64_read(&pkt_cb_addr); - if (unlikely(scb)) { - struct nss_gre_info *info = (struct nss_gre_info *)netdev_priv(dev); - if (likely(info->next_dev_inner)) { - scb(info->next_dev_inner, skb); - } - } - - cb = nss_top_main.gre_inner_data_callback; - cb(dev, skb, 0); -} - -/* - * nss_gre_outer_rx_handler() - * GRE outer rx handler. - */ -static void nss_gre_outer_rx_handler(struct net_device *dev, struct sk_buff *skb, - __attribute__((unused)) struct napi_struct *napi) -{ - nss_gre_data_callback_t cb; - - nss_gre_pkt_callback_t scb = (nss_gre_pkt_callback_t)(unsigned long)atomic64_read(&pkt_cb_addr); - if (unlikely(scb)) { - struct nss_gre_info *info = (struct nss_gre_info *)netdev_priv(dev); - if (likely(info->next_dev_outer)) { - scb(info->next_dev_outer, skb); - } - } - - cb = nss_top_main.gre_outer_data_callback; - cb(dev, skb, 0); -} - -/* - * nss_gre_msg_handler() - * Handle NSS -> HLOS messages for GRE - */ -static void nss_gre_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_gre_msg *ntm = (struct nss_gre_msg *)ncm; - void *ctx; - - nss_gre_msg_callback_t cb; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - BUG_ON(!(nss_is_dynamic_interface(ncm->interface) || ncm->interface == NSS_GRE_INTERFACE)); - - /* - * Trace Messages - */ - nss_gre_log_rx_msg(ntm); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_GRE_MSG_MAX) { - 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("%px: tx request for another interface: %d", nss_ctx, ncm->interface); - return; - } - - switch (ntm->cm.type) { - case NSS_GRE_MSG_SESSION_STATS: - /* - * 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); - break; - - case NSS_GRE_MSG_BASE_STATS: - nss_gre_stats_base_sync(nss_ctx, &ntm->msg.bstats); - nss_gre_stats_base_notify(nss_ctx); - break; - - default: - break; - - } - - /* - * Update the callback and app_data for NOTIFY messages, gre sends all notify messages - * to the same callback/app_data. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->gre_msg_callback; - ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].app_data; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * callback - */ - cb = (nss_gre_msg_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - /* - * call gre-std callback - */ - if (!cb) { - nss_warning("%px: No callback for gre-std interface %d", - nss_ctx, ncm->interface); - return; - } - - cb(ctx, ntm); -} - -/* - * nss_gre_callback() - * Callback to handle the completion of HLOS-->NSS messages. - */ -static void nss_gre_callback(void *app_data, struct nss_gre_msg *nim) -{ - nss_gre_msg_callback_t callback = (nss_gre_msg_callback_t)nss_gre_pvt.cb; - void *data = nss_gre_pvt.app_data; - - nss_gre_pvt.cb = NULL; - nss_gre_pvt.app_data = NULL; - - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("gre Error response %d\n", nim->cm.response); - nss_gre_pvt.response = NSS_TX_FAILURE; - } else { - nss_gre_pvt.response = NSS_TX_SUCCESS; - } - - if (callback) { - callback(data, nim); - } - - complete(&nss_gre_pvt.complete); -} - -/* - * nss_gre_register_pkt_callback() - * Register for data callback. - */ -void nss_gre_register_pkt_callback(nss_gre_pkt_callback_t cb) -{ - atomic64_set(&pkt_cb_addr, (unsigned long)cb); -} -EXPORT_SYMBOL(nss_gre_register_pkt_callback); - -/* - * nss_gre_unregister_pkt_callback() - * Unregister for data callback. - */ -void nss_gre_unregister_pkt_callback() -{ - atomic64_set(&pkt_cb_addr, 0); -} -EXPORT_SYMBOL(nss_gre_unregister_pkt_callback); - -/* - * nss_gre_tx_msg() - * Transmit a GRE message to NSS firmware - */ -nss_tx_status_t nss_gre_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_gre_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Sanity check the message - */ - if (!nss_is_dynamic_interface(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("%px: message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - /* - * Trace Messages - */ - nss_gre_log_tx_msg(msg); - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_gre_tx_msg); - -/* - * nss_gre_tx_msg_sync() - * Transmit a GRE message to NSS firmware synchronously. - */ -nss_tx_status_t nss_gre_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_msg *msg) -{ - nss_tx_status_t status; - int ret = 0; - - down(&nss_gre_pvt.sem); - nss_gre_pvt.cb = (void *)msg->cm.cb; - nss_gre_pvt.app_data = (void *)msg->cm.app_data; - - msg->cm.cb = (nss_ptr_t)nss_gre_callback; - msg->cm.app_data = (nss_ptr_t)NULL; - - status = nss_gre_tx_msg(nss_ctx, msg); - if (status != NSS_TX_SUCCESS) { - 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("%px: GRE STD tx sync failed due to timeout\n", nss_ctx); - nss_gre_pvt.response = NSS_TX_FAILURE; - } - - status = nss_gre_pvt.response; - up(&nss_gre_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_gre_tx_msg_sync); - -/* - * nss_gre_tx_buf() - * Send packet to GRE interface owned by NSS - */ -nss_tx_status_t nss_gre_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, struct sk_buff *skb) -{ - return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_VIRTUAL_BUFFER | H2N_BIT_FLAG_BUFFER_REUSABLE); -} -EXPORT_SYMBOL(nss_gre_tx_buf); - -/* - *********************************** - * Register/Unregister/Miscellaneous APIs - *********************************** - */ - -/* - * nss_gre_register_if() - * Register data and message handlers for GRE. - */ -struct nss_ctx_instance *nss_gre_register_if(uint32_t if_num, uint32_t type, nss_gre_data_callback_t data_callback, - nss_gre_msg_callback_t event_callback, struct net_device *netdev, uint32_t features) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.gre_handler_id]; - - nss_assert(nss_ctx); - nss_assert(nss_is_dynamic_interface(if_num)); - - switch (type) { - case NSS_DYNAMIC_INTERFACE_TYPE_GRE_INNER: - nss_core_register_subsys_dp(nss_ctx, if_num, nss_gre_inner_rx_handler, NULL, netdev, netdev, features); - nss_top_main.gre_inner_data_callback = data_callback; - break; - - case NSS_DYNAMIC_INTERFACE_TYPE_GRE_OUTER: - nss_core_register_subsys_dp(nss_ctx, if_num, nss_gre_outer_rx_handler, NULL, netdev, netdev, features); - nss_top_main.gre_outer_data_callback = data_callback; - break; - - default: - nss_warning("%px: Unable to register. Wrong interface type %d\n", nss_ctx, type); - return NULL; - } - - nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, type); - - nss_top_main.gre_msg_callback = event_callback; - - nss_core_register_handler(nss_ctx, if_num, nss_gre_msg_handler, NULL); - - nss_gre_stats_session_register(if_num, netdev); - - return nss_ctx; -} -EXPORT_SYMBOL(nss_gre_register_if); - -/* - * nss_gre_unregister_if() - * Unregister data and message handler. - */ -void nss_gre_unregister_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.gre_handler_id]; - struct net_device *dev; - - nss_assert(nss_ctx); - nss_assert(nss_is_dynamic_interface(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; - } - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - nss_core_set_subsys_dp_type(nss_ctx, dev, if_num, NSS_DYNAMIC_INTERFACE_TYPE_NONE); - nss_top_main.gre_msg_callback = NULL; - - nss_core_unregister_handler(nss_ctx, if_num); - - nss_gre_stats_session_unregister(if_num); -} -EXPORT_SYMBOL(nss_gre_unregister_if); - -/* - * nss_get_gre_context() - */ -struct nss_ctx_instance *nss_gre_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.gre_handler_id]; -} -EXPORT_SYMBOL(nss_gre_get_context); - -/* - * nss_gre_ifnum_with_core_id() - * Append core id to GRE interface num. - */ -int nss_gre_ifnum_with_core_id(int if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_gre_get_context(); - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - if (!nss_is_dynamic_interface(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); -} -EXPORT_SYMBOL(nss_gre_ifnum_with_core_id); - -/* - * nss_gre_msg_init() - * Initialize nss_gre msg. - */ -void nss_gre_msg_init(struct nss_gre_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} -EXPORT_SYMBOL(nss_gre_msg_init); - -/* - * nss_gre_register_handler() - * debugfs stats msg handler received on static gre interface - */ -void nss_gre_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_gre_get_context(); - - nss_info("nss_gre_register_handler"); - sema_init(&nss_gre_pvt.sem, 1); - 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(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_log.c deleted file mode 100644 index c2f752ba5..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_log.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_gre_log.c - * NSS GRE logger file. - */ - -#include "nss_core.h" - -#define NSS_GRE_LOG_MESSAGE_TYPE_INDEX(type) ((type) - NSS_IF_MAX_MSG_TYPES - 1) - -/* - * nss_gre_log_message_types_str - * NSS GRE message strings - */ -static int8_t *nss_gre_log_message_types_str[NSS_GRE_MSG_MAX] __maybe_unused = { - "GRE Message Configure", - "GRE Message Deconfigure", - "GRE Session Stats", - "GRE Base Stats" -}; - -/* - * nss_gre_log_config_msg() - * Log NSS GRE Config message. - */ -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("%px: NSS GRE Config message\n" - "GRE flags: %d\n" - "GRE ikey: %d\n" - "GRE okey: %d\n" - "GRE mode: %d\n" - "GRE ip type: %d\n" - "GRE interface number: %d\n" - "GRE Src MAC: %pM\n" - "GRE Dst MAC: %pM\n" - "GRE ttl: %d\n" - "GRE tos: %d\n" - "GRE metadata size: %d\n", - ngcm, ngcm->flags, ngcm->ikey, ngcm->okey, - ngcm->mode, ngcm->ip_type, ngcm->next_node_if_num, - ngcm->src_mac, ngcm->dest_mac, ngcm->ttl, ngcm->tos, - ngcm->metadata_size); - /* - * Continuation of the log message. Different identifiers based on IP type. - */ - if (ngcm->ip_type == NSS_GRE_IP_IPV6) { - nss_trace("GRE Source IP: %pI6\n" - "GRE Dest IP: %pI6\n", - ngcm->src_ip, ngcm->dest_ip); - } else { - nss_trace("GRE Source IP: %pI4\n" - "GRE Dest IP: %pI4\n", - ngcm->src_ip, ngcm->dest_ip); - } -} - -/* - * nss_gre_log_deconfig_msg() - * Log NSS GRE deconfig message. - */ -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("%px: NSS GRE deconfig message\n" - "GRE interface number: %d\n", - ngdm, ngdm->if_number); -} - -/* - * nss_gre_log_linkup_msg() - * Log NSS GRE linkup message. - */ -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("%px: NSS GRE linkup message\n" - "GRE interface number: %d\n", - nglm, nglm->if_number); -} - -/* - * nss_gre_log_linkdown_msg() - * Log NSS GRE linkdown message. - */ -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("%px: NSS GRE linkdown message\n" - "GRE interface number: %d\n", - ngdm, ngdm->if_number); -} - -/* - * nss_gre_log_verbose() - * Log message contents. - */ -static void nss_gre_log_verbose(struct nss_gre_msg *ngm) -{ - switch (ngm->cm.type) { - case NSS_GRE_MSG_ENCAP_CONFIGURE: - case NSS_GRE_MSG_DECAP_CONFIGURE: - nss_gre_log_config_msg(ngm); - break; - - case NSS_GRE_MSG_ENCAP_DECONFIGURE: - case NSS_GRE_MSG_DECAP_DECONFIGURE: - nss_gre_log_deconfig_msg(ngm); - break; - - case NSS_IF_OPEN: - nss_gre_log_linkup_msg(ngm); - break; - - case NSS_IF_CLOSE: - nss_gre_log_linkdown_msg(ngm); - break; - - case NSS_GRE_MSG_SESSION_STATS: - case NSS_GRE_MSG_BASE_STATS: - /* - * No log for valid stats messages. - */ - break; - - default: - nss_trace("%px: Invalid message type\n", ngm); - break; - } -} - -/* - * nss_gre_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_gre_log_tx_msg(struct nss_gre_msg *ngm) -{ - if (ngm->cm.type >= NSS_GRE_MSG_MAX) { - nss_warning("%px: Invalid message type\n", ngm); - return; - } - - 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); -} - -/* - * nss_gre_log_rx_msg() - * Log messages received from FW. - */ -void nss_gre_log_rx_msg(struct nss_gre_msg *ngm) -{ - if (ngm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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]); - -verbose: - nss_gre_log_verbose(ngm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_log.h deleted file mode 100644 index 2a2111785..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_LOG_H -#define __NSS_GRE_LOG_H - -/* - * nss_gre_log.h - * NSS GRE header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_gre_log_tx_msg - * Logs a gre message that is sent to the NSS firmware. - */ -void nss_gre_log_tx_msg(struct nss_gre_msg *ngm); - -/* - * nss_gre_log_rx_msg - * Logs a gre message that is received from the NSS firmware. - */ -void nss_gre_log_rx_msg(struct nss_gre_msg *ngm); - -#endif /* __NSS_GRE_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir.c deleted file mode 100644 index 73e7c9fc3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir.c +++ /dev/null @@ -1,673 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_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 */ - -static struct dentry *gre_redir_dentry; - -/* - * Private data structure for handling synchronous messaging. - */ -static struct { - struct semaphore sem; - struct completion complete; - int response; -} nss_gre_redir_pvt; - -/* - * Array to hold tunnel stats along with if_num - */ -struct nss_gre_redir_tunnel_stats tun_stats[NSS_GRE_REDIR_MAX_INTERFACES]; - -/* - * nss_gre_callback() - * Callback to handle the completion of HLOS-->NSS messages. - */ -static void nss_gre_redir_msg_sync_callback(void *app_data, struct nss_gre_redir_msg *nim) -{ - nss_gre_redir_pvt.response = NSS_TX_SUCCESS; - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("gre Error response %d\n", nim->cm.response); - nss_gre_redir_pvt.response = NSS_TX_FAILURE; - } - - complete(&nss_gre_redir_pvt.complete); -} - -/* - * nss_gre_redir_verify_ifnum() - * Verify interface type. - */ -bool nss_gre_redir_verify_ifnum(uint32_t if_num) -{ - uint32_t type; - - type = nss_dynamic_interface_get_type(nss_gre_redir_get_context(), if_num); - return type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_HOST_INNER || - type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_OFFL_INNER || - type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_SJACK_INNER || - type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_OUTER || - type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_US || - type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_DS; -} - -/* - * nss_gre_redir_handler() - * Handle NSS -> HLOS messages for GRE tunnel. - */ -static void nss_gre_redir_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_gre_redir_msg *ngrm = (struct nss_gre_redir_msg *)ncm; - void *ctx; - nss_gre_redir_msg_callback_t cb; - - /* - * interface should either be dynamic interface for receiving tunnel msg or GRE_REDIR interface for - * receiving base node messages. - */ - BUG_ON(((ncm->interface < NSS_DYNAMIC_IF_START) || (ncm->interface >= (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES))) && - ncm->interface != NSS_GRE_REDIR_INTERFACE); - - /* - * Trace Messages - */ - nss_gre_redir_log_rx_msg(ngrm); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_GRE_REDIR_MAX_MSG_TYPES) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Update the callback and app_data for NOTIFY messages, gre 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->nss_rx_interface_handlers[ncm->interface].app_data; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - 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); - break; - } - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_gre_redir_msg_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - /* - * call gre tunnel callback - */ - cb(ctx, ncm); -} - -/* - * nss_gre_redir_register_if() - * Register dynamic node for GRE redir. - */ -static struct nss_ctx_instance *nss_gre_redir_register_if(uint32_t if_num, struct net_device *netdev, - nss_gre_redir_data_callback_t cb_func_data, nss_gre_redir_msg_callback_t cb_func_msg, uint32_t features, - uint32_t type, void *app_ctx) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.gre_redir_handler_id]; - uint32_t status; - int i, idx = -1; - - nss_assert(nss_ctx); - nss_assert((if_num >= NSS_DYNAMIC_IF_START) && (if_num < (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES))); - - spin_lock_bh(&nss_gre_redir_stats_lock); - for (i = 0; i < NSS_GRE_REDIR_MAX_INTERFACES; i++) { - if (tun_stats[i].dev == netdev) { - idx = i; - break; - } - - if ((idx == -1) && (tun_stats[i].ref_count == 0)) { - idx = i; - } - } - - if (idx == -1) { - spin_unlock_bh(&nss_gre_redir_stats_lock); - nss_warning("%px: Maximum number of gre_redir tunnel_stats instances are already allocated\n", nss_ctx); - return NULL; - } - - if (!tun_stats[idx].ref_count) { - tun_stats[idx].dev = netdev; - } - tun_stats[idx].ref_count++; - - spin_unlock_bh(&nss_gre_redir_stats_lock); - - /* - * Registering handler for sending tunnel interface msgs to NSS. - */ - status = nss_core_register_handler(nss_ctx, if_num, nss_gre_redir_msg_handler, app_ctx); - if (status != NSS_CORE_STATUS_SUCCESS) { - 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; - } - - /* - * 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); - return nss_ctx; -} - -/* - * nss_gre_redir_get_context() - * Retrieve context for GRE redir. - */ -struct nss_ctx_instance *nss_gre_redir_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.gre_redir_handler_id]; -} -EXPORT_SYMBOL(nss_gre_redir_get_context); - -/* - * nss_gre_redir_alloc_and_register_node() - * Allocates and registers GRE Inner/Outer type dynamic nodes with NSS. - */ -int nss_gre_redir_alloc_and_register_node(struct net_device *dev, - nss_gre_redir_data_callback_t data_cb, - nss_gre_redir_msg_callback_t msg_cb, - uint32_t type, void *app_ctx) -{ - int ifnum; - nss_tx_status_t status; - struct nss_ctx_instance *nss_ctx; - - if ((type != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_HOST_INNER) && - (type != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_OFFL_INNER) && - (type != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_SJACK_INNER) && - (type != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_OUTER) && - (type != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_US) && - (type != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_DS)) { - - nss_warning("%px: Unknown type %u\n", dev, type); - return -1; - } - - ifnum = nss_dynamic_interface_alloc_node(type); - if (ifnum == -1) { - nss_warning("%px: Unable to allocate GRE_REDIR node of type = %u\n", dev, type); - return -1; - } - - nss_ctx = nss_gre_redir_register_if(ifnum, dev, data_cb, - msg_cb, 0, type, app_ctx); - if (!nss_ctx) { - nss_warning("Unable to register GRE_REDIR node of type = %u\n", type); - status = nss_dynamic_interface_dealloc_node(ifnum, type); - if (status != NSS_TX_SUCCESS) { - nss_warning("Unable to deallocate node.\n"); - } - - return -1; - } - - return ifnum; -} -EXPORT_SYMBOL(nss_gre_redir_alloc_and_register_node); - -/* - * nss_gre_redir_configure_inner_node() - * Configure an inner type gre_redir dynamic node. - */ -nss_tx_status_t nss_gre_redir_configure_inner_node(int ifnum, - struct nss_gre_redir_inner_configure_msg *ngrcm) -{ - struct nss_gre_redir_msg config; - uint32_t len, iftype, outerif_type; - nss_tx_status_t status; - - struct nss_ctx_instance *nss_ctx __maybe_unused = nss_gre_redir_get_context(); - if (!nss_ctx) { - nss_warning("Unable to retrieve NSS context.\n"); - return NSS_TX_FAILURE_BAD_PARAM; - } - - 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("%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("%px: Incorrect header version %u\n", nss_ctx, ngrcm->gre_version); - return NSS_TX_FAILURE_BAD_PARAM; - } - - iftype = nss_dynamic_interface_get_type(nss_ctx, ifnum); - if (!((iftype == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_HOST_INNER) || - (iftype == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_OFFL_INNER) || - (iftype == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_SJACK_INNER))) { - - 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("%px: Incorrect type for exception interface %u\n", nss_ctx, outerif_type); - return NSS_TX_FAILURE_BAD_PARAM; - } - - len = sizeof(struct nss_gre_redir_inner_configure_msg); - - /* - * Configure the node - */ - nss_cmn_msg_init(&config.cm, ifnum, NSS_GRE_REDIR_TX_TUNNEL_INNER_CONFIGURE_MSG, len, NULL, NULL); - config.msg.inner_configure.ip_hdr_type = ngrcm->ip_hdr_type; - config.msg.inner_configure.ip_df_policy = ngrcm->ip_df_policy; - config.msg.inner_configure.gre_version = ngrcm->gre_version; - config.msg.inner_configure.ip_ttl = ngrcm->ip_ttl; - config.msg.inner_configure.except_outerif = ngrcm->except_outerif; - memcpy((void *)config.msg.inner_configure.ip_src_addr, (void *)(ngrcm->ip_src_addr), sizeof(ngrcm->ip_src_addr)); - memcpy((void *)config.msg.inner_configure.ip_dest_addr, (void *)(ngrcm->ip_dest_addr), sizeof(ngrcm->ip_dest_addr)); - - status = nss_gre_redir_tx_msg_sync(nss_ctx, &config); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: Unable to configure inner node %d.\n", nss_ctx, ifnum); - } - - return status; -} -EXPORT_SYMBOL(nss_gre_redir_configure_inner_node); - -/* - * nss_gre_redir_exception_ds_reg_cb() - * Configure a callback on VAP for downstream exception tunnel flows. - */ -nss_tx_status_t nss_gre_redir_exception_ds_reg_cb(int ifnum, - struct nss_gre_redir_exception_ds_reg_cb_msg *ngrcm) -{ - struct nss_gre_redir_msg config; - struct nss_ctx_instance *nss_ctx __maybe_unused = nss_gre_redir_get_context(); - nss_tx_status_t status; - uint32_t vap_type, iftype; - uint32_t len = sizeof(struct nss_gre_redir_exception_ds_reg_cb_msg); - - if (!nss_ctx) { - nss_warning("Unable to retrieve NSS context.\n"); - return NSS_TX_FAILURE_BAD_PARAM; - } - - iftype = nss_dynamic_interface_get_type(nss_ctx, ifnum); - if (iftype != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_DS) { - 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("%px: Incorrect type for vap interface type = %u", nss_ctx, vap_type); - return NSS_TX_FAILURE_BAD_PARAM; - } - - /* - * Configure the node - */ - nss_cmn_msg_init(&config.cm, ifnum, NSS_GRE_REDIR_EXCEPTION_DS_REG_CB_MSG, len, NULL, NULL); - config.msg.exception_ds_configure.dst_vap_nssif = ngrcm->dst_vap_nssif; - - status = nss_gre_redir_tx_msg_sync(nss_ctx, &config); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: Unable to register callback from gre redir exception ds %d\n", nss_ctx, ifnum); - } - - return status; -} -EXPORT_SYMBOL(nss_gre_redir_exception_ds_reg_cb); - -/* - * nss_gre_redir_configure_outer_node() - * Configure an outer type gre_redir dynamic node. - */ -nss_tx_status_t nss_gre_redir_configure_outer_node(int ifnum, - struct nss_gre_redir_outer_configure_msg *ngrcm) -{ - struct nss_gre_redir_msg config; - struct nss_ctx_instance *nss_ctx __maybe_unused = nss_gre_redir_get_context(); - nss_tx_status_t status; - uint32_t hostif_type, offlif_type, sjackif_type, iftype; - uint32_t len = sizeof(struct nss_gre_redir_outer_configure_msg); - - if (!nss_ctx) { - nss_warning("Unable to retrieve NSS context.\n"); - return NSS_TX_FAILURE_BAD_PARAM; - } - - 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("%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("%px: Incorrect interface type %u\n", nss_ctx, iftype); - return NSS_TX_FAILURE_BAD_PARAM; - } - - hostif_type = nss_dynamic_interface_get_type(nss_ctx, ngrcm->except_hostif); - offlif_type = nss_dynamic_interface_get_type(nss_ctx, ngrcm->except_offlif); - sjackif_type = nss_dynamic_interface_get_type(nss_ctx, ngrcm->except_sjackif); - if ((hostif_type != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_HOST_INNER) || - (offlif_type != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_OFFL_INNER) || - (ngrcm->except_sjackif - && sjackif_type != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_SJACK_INNER)) { - - 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; - } - - /* - * Configure the node - */ - nss_cmn_msg_init(&config.cm, ifnum, NSS_GRE_REDIR_TX_TUNNEL_OUTER_CONFIGURE_MSG, len, NULL, NULL); - config.msg.outer_configure.ip_hdr_type = ngrcm->ip_hdr_type; - config.msg.outer_configure.rps_hint = ngrcm->rps_hint; - config.msg.outer_configure.except_hostif = ngrcm->except_hostif; - config.msg.outer_configure.except_offlif = ngrcm->except_offlif; - config.msg.outer_configure.except_sjackif = ngrcm->except_sjackif; - - status = nss_gre_redir_tx_msg_sync(nss_ctx, &config); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: Unable to configure outer node %d\n", nss_ctx, ifnum); - } - - return status; -} -EXPORT_SYMBOL(nss_gre_redir_configure_outer_node); - -/* - * nss_gre_redir_tx_msg() - * Transmit a GRE message to NSS FW. - */ -nss_tx_status_t nss_gre_redir_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace Messages - */ - nss_gre_redir_log_tx_msg(msg); - - /* - * Sanity check the message - */ - - /* - * interface should either be dynamic interface to transmit tunnel msg or GRE_REDIR interface to transmit - * base node messages. - */ - 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("%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("%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); -} -EXPORT_SYMBOL(nss_gre_redir_tx_msg); - -/* - * nss_gre_redir_tx_msg_sync() - * Transmit a GRE redir message to NSS firmware synchronously. - */ -nss_tx_status_t nss_gre_redir_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_msg *ngrm) -{ - nss_tx_status_t status; - int ret = 0; - - down(&nss_gre_redir_pvt.sem); - ngrm->cm.cb = (nss_ptr_t)nss_gre_redir_msg_sync_callback; - ngrm->cm.app_data = (nss_ptr_t)NULL; - status = nss_gre_redir_tx_msg(nss_ctx, ngrm); - if (status != NSS_TX_SUCCESS) { - 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("%px: GRE tx sync failed due to timeout\n", nss_ctx); - nss_gre_redir_pvt.response = NSS_TX_FAILURE; - } - - status = nss_gre_redir_pvt.response; - up(&nss_gre_redir_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_gre_redir_tx_msg_sync); - -/* - * nss_gre_redir_tx_buf() - * Send packet to gre_redir interface owned by NSS. - */ -nss_tx_status_t nss_gre_redir_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, uint32_t if_num) -{ - uint32_t type; - - 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 - * type GRE_REDIR_WIFI_HOST_INNER. - */ - 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("%px: Unknown type for interface %u\n", nss_ctx, type); - return NSS_TX_FAILURE_BAD_PARAM; - } - - return nss_core_send_packet(nss_ctx, os_buf, if_num, H2N_BIT_FLAG_BUFFER_REUSABLE); -} -EXPORT_SYMBOL(nss_gre_redir_tx_buf); - -/* - * nss_gre_redir_tx_buf_noreuse() - * Send packet to gre_redir interface owned by NSS. - */ -nss_tx_status_t nss_gre_redir_tx_buf_noreuse(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, uint32_t if_num) -{ - uint32_t type; - - 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 - * type GRE_REDIR_WIFI_HOST_INNER. - */ - 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("%px: Unknown type for interface %u\n", nss_ctx, type); - return NSS_TX_FAILURE_BAD_PARAM; - } - - return nss_core_send_packet(nss_ctx, os_buf, if_num, 0); -} -EXPORT_SYMBOL(nss_gre_redir_tx_buf_noreuse); - -/* - * nss_gre_redir_unregister_if() - * Unregister dynamic node for GRE redir. - */ -bool nss_gre_redir_unregister_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx __maybe_unused = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.gre_redir_handler_id]; - uint32_t status; - struct net_device *dev; - int i; - - nss_assert(nss_ctx); - nss_assert((if_num >= NSS_DYNAMIC_IF_START) && (if_num < (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES))); - - 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 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("%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); - spin_lock_bh(&nss_gre_redir_stats_lock); - - /* - * Update/Clear the tunnel stats entry for this tunnel. - */ - for (i = 0; i < NSS_GRE_REDIR_MAX_INTERFACES; i++) { - if (tun_stats[i].dev == dev) { - tun_stats[i].ref_count--; - if (!tun_stats[i].ref_count) { - tun_stats[i].dev = NULL; - } - - break; - } - } - - spin_unlock_bh(&nss_gre_redir_stats_lock); - return true; -} -EXPORT_SYMBOL(nss_gre_redir_unregister_if); - -/* - * nss_gre_redir_get_device() - * Gets the original device from probe. - */ -struct device *nss_gre_redir_get_device(void) -{ - struct nss_ctx_instance *nss_ctx = nss_gre_redir_get_context(); - return nss_ctx->dev; -} -EXPORT_SYMBOL(nss_gre_redir_get_device); - -/* - * nss_gre_redir_get_dentry() - * Returns directory entry created in debugfs for statistics. - */ -struct dentry *nss_gre_redir_get_dentry(void) -{ - return gre_redir_dentry; -} - -/* - * nss_gre_redir_register_handler() - * Registering handler for sending msg to base gre_redir node on NSS. - */ -void nss_gre_redir_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx __maybe_unused = nss_gre_redir_get_context(); - uint32_t status; - - gre_redir_dentry = nss_gre_redir_stats_dentry_create(); - if (!gre_redir_dentry) { - nss_warning("%px: Not able to create debugfs entry\n", nss_ctx); - return; - } - - sema_init(&nss_gre_redir_pvt.sem, 1); - init_completion(&nss_gre_redir_pvt.complete); - memset(tun_stats, 0, sizeof(struct nss_gre_redir_tunnel_stats) * NSS_GRE_REDIR_MAX_INTERFACES); - status = nss_core_register_handler(nss_ctx, NSS_GRE_REDIR_INTERFACE, nss_gre_redir_msg_handler, NULL); - if (status != NSS_CORE_STATUS_SUCCESS) { - debugfs_remove_recursive(gre_redir_dentry); - gre_redir_dentry = NULL; - 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(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds.c deleted file mode 100644 index ea4132013..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds.c +++ /dev/null @@ -1,404 +0,0 @@ -/* - **************************************************************************** - * Copyright (c) 2018, 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_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]; - -/* - * Private data structure - */ -static struct { - struct semaphore sem; - struct completion complete; - int response; - nss_gre_redir_lag_ds_msg_callback_t *cb; - void *app_data; -} nss_gre_redir_lag_ds_pvt; - -/* - * nss_gre_redir_lag_ds_callback() - * Callback to handle the completion of HLOS-->NSS messages. - */ -static void nss_gre_redir_lag_ds_callback(void *app_data, struct nss_gre_redir_lag_ds_msg *nim) -{ - nss_gre_redir_lag_ds_msg_callback_t callback = (nss_gre_redir_lag_ds_msg_callback_t)nss_gre_redir_lag_ds_pvt.cb; - void *data = nss_gre_redir_lag_ds_pvt.app_data; - - nss_gre_redir_lag_ds_pvt.cb = NULL; - nss_gre_redir_lag_ds_pvt.app_data = NULL; - - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("GRE LAG DS: error response %d\n", nim->cm.response); - nss_gre_redir_lag_ds_pvt.response = NSS_TX_FAILURE; - } else { - nss_gre_redir_lag_ds_pvt.response = NSS_TX_SUCCESS; - } - - if (callback) { - callback(data, &nim->cm); - } - - complete(&nss_gre_redir_lag_ds_pvt.complete); -} - -/* - * 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) -{ - 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)) { - *idx = node_idx; - return true; - } - } - - return false; -} - -/* - * nss_gre_redir_lag_ds_verify_ifnum() - * Verify interface type. - */ -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; -} - -/* - * nss_gre_redir_lag_ds_handler() - * Handle NSS -> HLOS messages for gre tunnel - */ -static void nss_gre_redir_lag_ds_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - void *ctx; - struct nss_gre_redir_lag_ds_msg *ngrm = (struct nss_gre_redir_lag_ds_msg *)ncm; - nss_gre_redir_lag_ds_msg_callback_t cb; - - /* - * Interface should be a dynamic interface of type NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS. - */ - BUG_ON(!nss_gre_redir_lag_ds_verify_ifnum(ncm->interface)); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_GRE_REDIR_LAG_DS_MAX_MSG_TYPES) { - 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("%px: Length of message is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Update the callback and app_data for NOTIFY messages, gre 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->nss_rx_interface_handlers[ncm->interface].app_data; - } - - /* - * Trace messages. - */ - nss_gre_redir_lag_ds_log_rx_msg(ngrm); - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - 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); - break; - } - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_gre_redir_lag_ds_msg_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - /* - * call gre tunnel callback - */ - cb(ctx, ncm); -} - -/* - * nss_gre_redir_lag_ds_unregister_if() - * Unregister GRE redirect LAG downstream node. - */ -static enum nss_gre_redir_lag_err_types nss_gre_redir_lag_ds_unregister_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx __maybe_unused = nss_gre_redir_lag_ds_get_context(); - uint32_t idx, status; - - 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("%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); - 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: Stats context not found.\n", nss_ctx); - return NSS_GRE_REDIR_LAG_ERR_STATS_INDEX_NOT_FOUND; - } - - tun_ds_stats[idx].valid = false; - spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); - return NSS_GRE_REDIR_LAG_SUCCESS; -} - -/* - * nss_gre_redir_lag_ds_register_if() - * Register GRE redirect LAG downstream node. - */ -static struct nss_ctx_instance *nss_gre_redir_lag_ds_register_if(uint32_t if_num, struct net_device *netdev, - nss_gre_redir_lag_ds_data_callback_t cb_func_data, - nss_gre_redir_lag_ds_msg_callback_t cb_func_msg, uint32_t features, uint32_t type, void *app_ctx) -{ - struct nss_ctx_instance *nss_ctx = nss_gre_redir_lag_ds_get_context(); - uint32_t status, i; - nss_assert(nss_ctx); - nss_assert(!nss_gre_redir_lag_ds_verify_ifnum(if_num)); - - /* - * Registering handler for sending tunnel interface msgs to NSS. - */ - 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("%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); - 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; - break; - } - } - - spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); - - return nss_ctx; -} - -/* - * nss_gre_redir_lag_ds_get_context() - * Retrieves context GRE redirect LAG downstream node. - */ -struct nss_ctx_instance *nss_gre_redir_lag_ds_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.gre_redir_lag_ds_handler_id]; -} -EXPORT_SYMBOL(nss_gre_redir_lag_ds_get_context); - -/* - * nss_gre_redir_lag_ds_tx_msg() - * Transmit a gre message to NSS. - */ -nss_tx_status_t nss_gre_redir_lag_ds_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_lag_ds_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace messages. - */ - nss_gre_redir_lag_ds_log_tx_msg(msg); - - /* - * Sanity check the message. Interface should be a dynamic interface - * of type NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS. - */ - if (!nss_gre_redir_lag_ds_verify_ifnum(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("%px: message type out of range: %d\n", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_gre_redir_lag_ds_tx_msg); - -/* - * nss_gre_redir_lag_ds_tx_msg_sync() - * Transmit a GRE lag message to NSS firmware synchronously. - */ -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_tx_status_t status; - int ret = 0; - - down(&nss_gre_redir_lag_ds_pvt.sem); - nss_gre_redir_lag_ds_pvt.cb = (void *)ngrm->cm.cb; - nss_gre_redir_lag_ds_pvt.app_data = (void *)ngrm->cm.app_data; - ngrm->cm.cb = (nss_ptr_t)nss_gre_redir_lag_ds_callback; - ngrm->cm.app_data = (nss_ptr_t)NULL; - - status = nss_gre_redir_lag_ds_tx_msg(nss_ctx, ngrm); - if (status != NSS_TX_SUCCESS) { - 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("%px: GRE LAG DS tx sync failed due to timeout\n", nss_ctx); - nss_gre_redir_lag_ds_pvt.response = NSS_TX_FAILURE; - } - - status = nss_gre_redir_lag_ds_pvt.response; - up(&nss_gre_redir_lag_ds_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_gre_redir_lag_ds_tx_msg_sync); - -/* - * nss_gre_redir_lag_ds_unregister_and_dealloc() - * Unregister and deallocate nss gre redirect LAG DS node. - */ -enum nss_gre_redir_lag_err_types nss_gre_redir_lag_ds_unregister_and_dealloc(uint32_t ifnum) -{ - uint32_t ret; - struct nss_ctx_instance *nss_ctx __maybe_unused = nss_gre_redir_lag_ds_get_context(); - nss_tx_status_t status; - - if (!nss_gre_redir_lag_ds_verify_ifnum(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("%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("%px: Unable to deallocate node %u\n", nss_ctx, ifnum); - return NSS_GRE_REDIR_LAG_ERR_DEALLOC_FAILED; - } - - return NSS_GRE_REDIR_LAG_SUCCESS; -} -EXPORT_SYMBOL(nss_gre_redir_lag_ds_unregister_and_dealloc); - -/* - * nss_gre_redir_lag_ds_alloc_and_register_node() - * Allocates and registers GRE downstream type dynamic nodes with NSS. - */ -int nss_gre_redir_lag_ds_alloc_and_register_node(struct net_device *dev, - nss_gre_redir_lag_ds_data_callback_t cb_func_data, - nss_gre_redir_lag_ds_msg_callback_t cb_func_msg, void *app_ctx) -{ - int ifnum; - nss_tx_status_t status; - struct nss_ctx_instance *nss_ctx; - - ifnum = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS); - if (ifnum == -1) { - 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("%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("%px: Unable to deallocate node of type = %u.\n", dev, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS); - } - - return -1; - } - - return ifnum; -} -EXPORT_SYMBOL(nss_gre_redir_lag_ds_alloc_and_register_node); - -/* - * nss_gre_redir_lag_ds_register_handler() - * Registering handler for sending msg to base gre_lag node on NSS. - */ -void nss_gre_redir_lag_ds_register_handler(void) -{ - if (!nss_gre_redir_lag_ds_stats_dentry_create()) { - nss_warning(" Unable to create debugfs entry for LAG DS node.\n"); - 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); - init_completion(&nss_gre_redir_lag_ds_pvt.complete); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_log.c deleted file mode 100644 index 158cb9d44..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_log.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_gre_redir_lag_ds_log.c - * NSS GRE REDIR LAG DS logger file. - */ - -#include "nss_core.h" - -/* - * nss_gre_redir_lag_ds_log_message_types_str - * GRE REDIR LAG DS message strings - */ -static int8_t *nss_gre_redir_lag_ds_log_message_types_str[NSS_GRE_REDIR_LAG_DS_MAX_MSG_TYPES] __maybe_unused = { - "GRE REDIR LAG DS add station Message", - "GRE REDIR LAG DS delete station message", - "GRE REDIR LAG DS update station message", - "GRE REDIR LAG DS stats sync message", -}; - -/* - * nss_gre_redir_lag_ds_log_error_response_types_str - * Strings for error types for GRE REDIR LAG DS messages - */ -static int8_t *nss_gre_redir_lag_ds_log_error_response_types_str[NSS_GRE_REDIR_LAG_ERR_MAX] __maybe_unused = { - "GRE REDIR LAG Success", - "GRE REDIR LAG Incorrect Interface", - "GRE REDIR LAG DS Core Unregister Failed", - "GRE REDIR LAG DS STats Index Not Found", - "GRE REDIR LAG Dealloc Failed", -}; - -/* - * nss_gre_redir_lag_ds_log_add_sta_msg() - * Log NSS GRE REDIR LAG DS add STA message. - */ -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("%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); -} - -/* - * nss_gre_redir_lag_ds_log_del_sta_msg() - * Log NSS GRE REDIR LAG DS del STA message. - */ -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("%px: NSS GRE REDIR LAG DS Del STA Message:\n" - "GRE REDIR LAG DS Station MAC Address: %px\n", - ngdsm, ngdsm->mac); -} - -/* - * nss_gre_redir_lag_ds_log_add_sta_msg() - * Log NSS GRE REDIR LAG DS add STA message. - */ -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("%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); -} - -/* - * nss_gre_redir_lag_ds_log_verbose() - * Log message contents. - */ -static void nss_gre_redir_lag_ds_log_verbose(struct nss_gre_redir_lag_ds_msg *ngm) -{ - switch (ngm->cm.type) { - case NSS_GRE_REDIR_LAG_DS_ADD_STA_MSG: - nss_gre_redir_lag_ds_log_add_sta_msg(ngm); - break; - - case NSS_GRE_REDIR_LAG_DS_DEL_STA_MSG: - nss_gre_redir_lag_ds_log_del_sta_msg(ngm); - break; - - case NSS_GRE_REDIR_LAG_DS_UPDATE_STA_MSG: - nss_gre_redir_lag_ds_log_update_sta_msg(ngm); - break; - - case NSS_GRE_REDIR_LAG_DS_STATS_SYNC_MSG: - /* - * No log for valid stats message. - */ - break; - - default: - nss_warning("%px: Invalid message type\n", ngm); - break; - } -} - -/* - * nss_gre_redir_lag_ds_log_tx_msg() - * Log messages transmitted to FW. - */ -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("%px: Invalid message type\n", ngm); - return; - } - - 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); -} - -/* - * nss_gre_redir_lag_ds_log_rx_msg() - * Log messages received from FW. - */ -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("%px: Invalid response\n", ngm); - return; - } - - if (ngm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ngm->cm.response == NSS_CMN_RESPONSE_ACK)) { - 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("%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("%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]); - -verbose: - nss_gre_redir_lag_ds_log_verbose(ngm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_log.h deleted file mode 100644 index b0918760e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_LOG_H__ -#define __NSS_GRE_REDIR_LAG_DS_LOG_H__ - -/* - * nss_gre_redir_lag_ds_log.h - * NSS GRE REDIR LAG DS Log Header File - */ - -/* - * nss_gre_redir_lag_ds_log_tx_msg - * Logs a gre redir lag ds message that is sent to the NSS firmware. - */ -void nss_gre_redir_lag_ds_log_tx_msg(struct nss_gre_redir_lag_ds_msg *ngm); - -/* - * nss_gre_redir_lag_ds_log_rx_msg - * Logs a gre redir lag ds message that is received from the NSS firmware. - */ -void nss_gre_redir_lag_ds_log_rx_msg(struct nss_gre_redir_lag_ds_msg *ngm); - -#endif /* __NSS_GRE_REDIR_LAG_DS_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_stats.c deleted file mode 100644 index 76b3d7f83..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_stats.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_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. - */ -ATOMIC_NOTIFIER_HEAD(nss_gre_redir_lag_ds_stats_notifier); - -/* - * 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; - } - - memcpy((void *)cmn_stats, (void *)&tun_ds_stats[index], sizeof(*cmn_stats)); - spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); - return true; -} - -/* - * nss_gre_redir_lag_ds_stats_read() - * Read gre_redir_lag_ds tunnel stats. - */ -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; - 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; - } - - while (data->index < NSS_GRE_REDIR_LAG_MAX_NODE) { - if (nss_gre_redir_lag_ds_stats_get(&stats, data->index)) { - break; - } - - data->index++; - } - - 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_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_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - data->index++; - kfree(lbuf); - return bytes_read; -} - -/* - * nss_gre_redir_lag_ds_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(gre_redir_lag_ds_cmn) - -/* - * nss_gre_redir_lag_ds_stats_dentry_create() - * Create debugfs directory entry. - */ -struct dentry *nss_gre_redir_lag_ds_stats_dentry_create(void) -{ - struct dentry *gre_redir; - struct dentry *cmn_stats; - - gre_redir = nss_gre_redir_get_dentry(); - if (unlikely(!gre_redir)) { - nss_warning("Failed to retrieve directory entry qca-nss-drv/stats/gre_redir/\n"); - return NULL; - } - - cmn_stats = debugfs_create_file("lag_ds_cmn_stats", 0400, gre_redir, - &nss_top_main, &nss_gre_redir_lag_ds_cmn_stats_ops); - if (unlikely(!cmn_stats)) { - nss_warning("Failed to create qca-nss-drv/stats/gre_redir/lag_ds_cmn_stats file\n"); - return NULL; - } - - 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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_stats.h deleted file mode 100644 index 127f0082a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_stats.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - ************************************************************************** - * 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 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_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); - -#endif diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_strings.c deleted file mode 100644 index 185189996..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_ds_strings.h deleted file mode 100644 index c85bc7721..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us.c deleted file mode 100644 index 8e1b7588e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us.c +++ /dev/null @@ -1,665 +0,0 @@ -/* - **************************************************************************** - * Copyright (c) 2018, 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_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; - -/* - * Sync response context. - */ -static struct { - struct semaphore sem; - struct completion complete; - int response; - nss_gre_redir_lag_us_msg_callback_t *cb; - void *app_data; -} nss_gre_redir_lag_us_sync_ctx; - -/* - * nss_gre_redir_lag_us_callback() - * Callback to handle the completion of HLOS-->NSS messages. - */ -static void nss_gre_redir_lag_us_callback(void *app_data, struct nss_gre_redir_lag_us_msg *nim) -{ - nss_gre_redir_lag_us_msg_callback_t callback = (nss_gre_redir_lag_us_msg_callback_t)nss_gre_redir_lag_us_sync_ctx.cb; - void *data = nss_gre_redir_lag_us_sync_ctx.app_data; - - nss_gre_redir_lag_us_sync_ctx.cb = NULL; - nss_gre_redir_lag_us_sync_ctx.app_data = NULL; - - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("GRE redir LAG US Error response %d\n", nim->cm.response); - nss_gre_redir_lag_us_sync_ctx.response = NSS_TX_FAILURE; - } else { - nss_gre_redir_lag_us_sync_ctx.response = NSS_TX_SUCCESS; - } - - if (callback) { - callback(data, &nim->cm); - } - - complete(&nss_gre_redir_lag_us_sync_ctx.complete); -} - -/* - * nss_gre_redir_lag_us_hash_update_stats_req() - * Update query hash message's index for next request. - */ -static void nss_gre_redir_lag_us_hash_update_stats_req(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_lag_us_msg *ngrm) -{ - uint32_t ifnum = ngrm->cm.interface; - uint32_t idx, sync_delay = NSS_GRE_REDIR_LAG_US_STATS_SYNC_PERIOD; - struct nss_gre_redir_lag_us_hash_stats_query_msg *nim = &ngrm->msg.hash_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; - } - - /* - * Update start index for next iteration of the query. - */ - if (ngrm->cm.response == NSS_CMN_RESPONSE_ACK) { - cmn_ctx.stats_ctx[idx].db_sync_msg.msg.hash_stats.db_entry_idx = nim->db_entry_next; - } else { - cmn_ctx.stats_ctx[idx].db_sync_msg.msg.hash_stats.db_entry_idx = 0; - } - - /* - * 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) - 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); - spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -} - -/* - * nss_gre_redir_lag_us_handler() - * Handle NSS -> HLOS messages for gre tunnel - */ -static void nss_gre_redir_lag_us_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - void *ctx; - struct nss_gre_redir_lag_us_msg *ngrm = (struct nss_gre_redir_lag_us_msg *)ncm; - nss_gre_redir_lag_us_msg_callback_t cb; - - /* - * Interface should be a dynamic interface of type NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US. - */ - BUG_ON(!nss_gre_redir_lag_us_verify_ifnum(ncm->interface)); - - /* - * Trace messages. - */ - nss_gre_redir_lag_us_log_rx_msg(ngrm); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_GRE_REDIR_LAG_US_MAX_MSG_TYPES) { - 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("%px: Length of message is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Update the callback and app_data for NOTIFY messages, GRE 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->nss_rx_interface_handlers[ncm->interface].app_data; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - 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); - break; - - case NSS_GRE_REDIR_LAG_US_DB_HASH_NODE_MSG: - nss_gre_redir_lag_us_hash_update_stats_req(nss_ctx, ngrm); - break; - } - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_gre_redir_lag_us_msg_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - /* - * call gre tunnel callback - */ - cb(ctx, ncm); -} - -/* - * nss_gre_redir_lag_us_tx_msg_with_size() - * Transmit a GRE message to NSSFW with size. - */ -static nss_tx_status_t nss_gre_redir_lag_us_tx_msg_with_size(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_lag_us_msg *msg, uint32_t size) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Sanity check the message. Interface should be a dynamic - * interface of type NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US. - */ - if (!nss_gre_redir_lag_us_verify_ifnum(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("%px: message type out of range: %d\n", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), size); -} - -/* - * nss_gre_redir_lag_us_tx_msg_sync_with_size() - * Transmit a GRE LAG message to NSS firmware synchronously with size. - */ -static nss_tx_status_t nss_gre_redir_lag_us_tx_msg_sync_with_size(struct nss_ctx_instance *nss_ctx, - struct nss_gre_redir_lag_us_msg *ngrm, uint32_t size) -{ - nss_tx_status_t status; - int ret = 0; - - down(&nss_gre_redir_lag_us_sync_ctx.sem); - - /* - * Save the client's callback, and initialize the message - * with the callback which releases the semaphore after message - * response is received, This callback will inturn call the client's - * callback. - */ - nss_gre_redir_lag_us_sync_ctx.cb = (void *)ngrm->cm.cb; - nss_gre_redir_lag_us_sync_ctx.app_data = (void *)ngrm->cm.app_data; - ngrm->cm.cb = (nss_ptr_t)nss_gre_redir_lag_us_callback; - ngrm->cm.app_data = (nss_ptr_t)NULL; - - status = nss_gre_redir_lag_us_tx_msg_with_size(nss_ctx, ngrm, size); - if (status != NSS_TX_SUCCESS) { - 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("%px: GRE LAG US tx sync failed due to timeout\n", nss_ctx); - nss_gre_redir_lag_us_sync_ctx.response = NSS_TX_FAILURE; - } - - status = nss_gre_redir_lag_us_sync_ctx.response; - up(&nss_gre_redir_lag_us_sync_ctx.sem); - return status; -} - -/* - * nss_gre_redir_lag_us_stats_sync_req_work() - * Work function for hash statistics synchronization. - */ -static void nss_gre_redir_lag_us_stats_sync_req_work(struct work_struct *work) -{ - struct delayed_work *d_work = container_of(work, struct delayed_work, work); - struct nss_gre_redir_lag_us_pvt_sync_stats *sync_ctx = container_of(d_work, struct nss_gre_redir_lag_us_pvt_sync_stats, - nss_gre_redir_lag_us_work); - struct nss_gre_redir_lag_us_hash_stats_query_msg *nicsm_req = &(sync_ctx->db_sync_msg.msg.hash_stats); - nss_tx_status_t nss_tx_status; - nss_gre_redir_lag_us_msg_callback_t cb; - void *app_data; - struct nss_ctx_instance *nss_ctx __maybe_unused = nss_gre_redir_lag_us_get_context(); - int retry = NSS_GRE_REDIR_LAG_US_STATS_SYNC_RETRY; - - spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); - cb = sync_ctx->cb; - app_data = sync_ctx->app_data; - spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); - - nss_cmn_msg_init(&(sync_ctx->db_sync_msg.cm), sync_ctx->ifnum, - NSS_GRE_REDIR_LAG_US_DB_HASH_NODE_MSG, sizeof(struct nss_gre_redir_lag_us_hash_stats_query_msg), - cb, app_data); - while (retry) { - nss_tx_status = nss_gre_redir_lag_us_tx_msg_sync_with_size(nss_ctx, &(sync_ctx->db_sync_msg), PAGE_SIZE); - if (nss_tx_status == NSS_TX_SUCCESS) { - return; - } - - retry--; - nss_warning("%px: TX_NOT_OKAY, try again later\n", nss_ctx); - usleep_range(100, 200); - } - - /* - * TX failed after retries, take fresh start. - */ - nicsm_req->count = 0; - nicsm_req->db_entry_idx = 0; - queue_delayed_work(cmn_ctx.nss_gre_redir_lag_us_wq, &(sync_ctx->nss_gre_redir_lag_us_work), NSS_GRE_REDIR_LAG_US_STATS_SYNC_PERIOD); -} - -/* - * nss_gre_redir_lag_us_sync_work_init() - * Initialize work. - */ -static bool nss_gre_redir_lag_us_sync_work_init(uint32_t ifnum) -{ - struct nss_gre_redir_lag_us_hash_stats_query_msg *hash_stats_msg; - struct nss_ctx_instance __maybe_unused *nss_ctx = nss_gre_redir_lag_us_get_context(); - int ret, idx; - - 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 init work. Stats context not found.\n", nss_ctx); - return false; - } - - hash_stats_msg = &(cmn_ctx.stats_ctx[idx].db_sync_msg.msg.hash_stats); - hash_stats_msg->db_entry_idx = 0; - INIT_DELAYED_WORK(&(cmn_ctx.stats_ctx[idx].nss_gre_redir_lag_us_work), nss_gre_redir_lag_us_stats_sync_req_work); - ret = queue_delayed_work(cmn_ctx.nss_gre_redir_lag_us_wq, - &(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("%px: Unable to queue work function to work queue\n", nss_ctx); - return false; - } - - spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); - return true; -} - -/* - * nss_gre_redir_lag_us_unregister_if() - * Unregister GRE redirect LAG upstream node. - */ -static enum nss_gre_redir_lag_err_types nss_gre_redir_lag_us_unregister_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx __maybe_unused = nss_gre_redir_lag_us_get_context(); - uint32_t status; - int idx; - - 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("%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); - - 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("Stats context not found.\n"); - return NSS_GRE_REDIR_LAG_ERR_STATS_INDEX_NOT_FOUND; - } - - cmn_ctx.stats_ctx[idx].cb = NULL; - cmn_ctx.stats_ctx[idx].app_data = NULL; - cmn_ctx.stats_ctx[idx].valid = false; - spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); - - /* - * Work is per LAG US node. Cancel works for this node. - */ - cancel_delayed_work_sync(&(cmn_ctx.stats_ctx[idx].nss_gre_redir_lag_us_work)); - return NSS_GRE_REDIR_LAG_SUCCESS; -} - -/* - * nss_gre_redir_lag_us_register_if() - * Register GRE redirect LAG upstream node. - */ -static struct nss_ctx_instance *nss_gre_redir_lag_us_register_if(uint32_t if_num, struct net_device *netdev, - nss_gre_redir_lag_us_data_callback_t cb_func_data, - nss_gre_redir_lag_us_msg_callback_t cb_func_msg, uint32_t features, uint32_t type, void *app_ctx) -{ - struct nss_ctx_instance *nss_ctx = nss_gre_redir_lag_us_get_context(); - uint32_t status; - int i; - nss_assert(nss_ctx); - nss_assert(!nss_gre_redir_lag_us_verify_ifnum(if_num)); - - spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); - for (i = 0; i < NSS_GRE_REDIR_LAG_MAX_NODE; i++) { - if (!cmn_ctx.stats_ctx[i].valid) { - cmn_ctx.stats_ctx[i].ifnum = if_num; - cmn_ctx.stats_ctx[i].valid = true; - cmn_ctx.stats_ctx[i].cb = cb_func_msg; - cmn_ctx.stats_ctx[i].app_data = app_ctx; - break; - } - } - - spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); - if (i == NSS_GRE_REDIR_LAG_MAX_NODE) { - nss_warning("Maximum number of LAG nodes are already present.\n"); - return NULL; - } - - /* - * Registering handler for sending tunnel interface msgs to NSS. - */ - 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("%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; - cmn_ctx.stats_ctx[i].app_data = NULL; - spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); - 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); - return nss_ctx; -} - -/* - * 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. - */ -struct nss_ctx_instance *nss_gre_redir_lag_us_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.gre_redir_lag_us_handler_id]; -} -EXPORT_SYMBOL(nss_gre_redir_lag_us_get_context); - -/* - * nss_gre_redir_lag_us_configure_node() - * Configure upstream lag node. - */ -bool nss_gre_redir_lag_us_configure_node(uint32_t ifnum, - struct nss_gre_redir_lag_us_config_msg *ngluc) -{ - struct nss_gre_redir_lag_us_msg *config; - uint32_t len, iftype, idx = 0, i; - bool ret; - nss_tx_status_t status; - struct nss_ctx_instance *nss_ctx __maybe_unused = nss_ctx = nss_gre_redir_lag_us_get_context(); - - if (!nss_ctx) { - nss_warning("Unable to retrieve NSS context.\n"); - return false; - } - - config = (struct nss_gre_redir_lag_us_msg *) kzalloc(sizeof(struct nss_gre_redir_lag_us_msg), GFP_KERNEL); - if (!config) { - 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("%px: Incorrect interface type %u\n", nss_ctx, iftype); - kfree(config); - return false; - } - - if (!ngluc) { - 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("%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("%px: Unable to initialize work queue\n", nss_ctx); - kfree(config); - return false; - } - - len = sizeof(struct nss_gre_redir_lag_us_msg) - sizeof(struct nss_cmn_msg); - nss_cmn_msg_init(&config->cm, ifnum, NSS_GRE_REDIR_LAG_US_CONFIG_MSG, len, NULL, NULL); - config->msg.config_us.hash_mode = ngluc->hash_mode; - config->msg.config_us.num_slaves = ngluc->num_slaves; - for (i = 0; i < ngluc->num_slaves; i++) { - config->msg.config_us.if_num[i] = ngluc->if_num[i]; - } - - status = nss_gre_redir_lag_us_tx_msg_sync(nss_ctx, config); - kfree(config); - if (status == NSS_TX_SUCCESS) { - return true; - } - - 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: Stats context not found.\n", nss_ctx); - return false; - } - - spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); - - /* - * 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("%px: Unable to configure upstream lag node %d.\n", nss_ctx, ifnum); - return false; -} -EXPORT_SYMBOL(nss_gre_redir_lag_us_configure_node); - -/* - * nss_gre_redir_lag_us_tx_msg() - * Transmit a GRE LAG message to NSS firmware asynchronously. - */ -nss_tx_status_t nss_gre_redir_lag_us_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_lag_us_msg *ngrm) -{ - /* - * Trace messages. - */ - nss_gre_redir_lag_us_log_tx_msg(ngrm); - - return nss_gre_redir_lag_us_tx_msg_with_size(nss_ctx, ngrm, NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_gre_redir_lag_us_tx_msg); - -/* - * nss_gre_redir_lag_us_tx_msg_sync() - * Transmit a GRE lag message to NSS firmware synchronously. - */ -nss_tx_status_t nss_gre_redir_lag_us_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_lag_us_msg *ngrm) -{ - return nss_gre_redir_lag_us_tx_msg_sync_with_size(nss_ctx, ngrm, NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_gre_redir_lag_us_tx_msg_sync); - -/* - * nss_gre_redir_lag_us_unregister_and_dealloc() - * Unregister and deallocate nss gre redirect LAG US node. - */ -enum nss_gre_redir_lag_err_types nss_gre_redir_lag_us_unregister_and_dealloc(uint32_t ifnum) -{ - uint32_t ret; - struct nss_ctx_instance *nss_ctx __maybe_unused = nss_gre_redir_lag_us_get_context(); - nss_tx_status_t status; - - if (!nss_gre_redir_lag_us_verify_ifnum(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("%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("%px: Unable to deallocate node %u\n", nss_ctx, ifnum); - return NSS_GRE_REDIR_LAG_ERR_DEALLOC_FAILED; - } - - return NSS_GRE_REDIR_LAG_SUCCESS; -} -EXPORT_SYMBOL(nss_gre_redir_lag_us_unregister_and_dealloc); - -/* - * nss_gre_redir_lag_us_alloc_and_register_node() - * Allocates and registers GRE upstream type dynamic nodes with NSS. - */ -int nss_gre_redir_lag_us_alloc_and_register_node(struct net_device *dev, - nss_gre_redir_lag_us_data_callback_t cb_func_data, - nss_gre_redir_lag_us_msg_callback_t cb_func_msg, void *app_ctx) -{ - int ifnum; - nss_tx_status_t status; - struct nss_ctx_instance *nss_ctx; - - ifnum = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US); - if (ifnum == -1) { - 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("%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("%px: Unable to deallocate node.\n", dev); - } - - return -1; - } - - return ifnum; -} -EXPORT_SYMBOL(nss_gre_redir_lag_us_alloc_and_register_node); - -/* - * nss_gre_redir_lag_us_register_handler() - * Registering handler for sending msg to base gre_lag node on NSS. - */ -void nss_gre_redir_lag_us_register_handler(void) -{ - struct dentry *d_entry = nss_gre_redir_lag_us_stats_dentry_create(); - - if (!d_entry) { - nss_warning(" Unable to create debugfs entry for LAG US node.\n"); - return; - } - - cmn_ctx.nss_gre_redir_lag_us_wq = create_singlethread_workqueue("nss_gre_redir_lag_us_workqueue"); - if (!cmn_ctx.nss_gre_redir_lag_us_wq) { - debugfs_remove_recursive(d_entry); - nss_warning("Unable to create workqueue for LAG US node.\n"); - 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); - init_completion(&nss_gre_redir_lag_us_sync_ctx.complete); - spin_lock_init(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_log.c deleted file mode 100644 index 8601979d4..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_log.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_gre_redir_lag_us_log.c - * NSS GRE REDIR LAG US logger file. - */ - -#include "nss_core.h" - -/* - * nss_gre_redir_lag_us_log_message_types_str - * GRE REDIR LAG US message strings - */ -static int8_t *nss_gre_redir_lag_us_log_message_types_str[NSS_GRE_REDIR_LAG_US_MAX_MSG_TYPES] __maybe_unused = { - "GRE REDIR LAG US config Message", - "GRE REDIR LAG US add hash node message", - "GRE REDIR LAG US delete hash node message", - "GRE REDIR LAG US query hash node message", - "GRE REDIR LAG US stats sync message", - "GRE REDIR LAG US DB hash node message", -}; - -/* - * nss_gre_redir_lag_us_log_error_response_types_str - * Strings for error types for GRE REDIR LAG US messages - */ -static int8_t *nss_gre_redir_lag_us_log_error_response_types_str[NSS_GRE_REDIR_LAG_ERR_MAX] __maybe_unused = { - "GRE REDIR LAG Success", - "GRE REDIR LAG Incorrect Interface", - "GRE REDIR LAG US Core Unregister Failed", - "GRE REDIR LAG US STats Index Not Found", - "GRE REDIR LAG Dealloc Failed", -}; - -/* - * nss_gre_redir_lag_us_log_config_msg() - * Log NSS GRE REDIR LAG US config message. - */ -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("%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: %px\n", - ngcm, ngcm->hash_mode, ngcm->num_slaves, - ngcm->if_num); -} - -/* - * nss_gre_redir_lag_us_log_add_hash_node_msg() - * Log NSS GRE REDIR LAG US add hash node message. - */ -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("%px: NSS GRE REDIR LAG Add Hash Node Message:\n" - "GRE REDIR LAG US Interface Number: %d\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); -} - -/* - * nss_gre_redir_lag_us_log_del_hash_node_msg() - * Log NSS GRE REDIR LAG US del hash node message. - */ -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("%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); -} - -/* - * nss_gre_redir_lag_us_log_query_hash_node_msg() - * Log NSS GRE REDIR LAG US query hash node message. - */ -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("%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); -} - -/* - * nss_gre_redir_lag_us_log_verbose() - * Log message contents. - */ -static void nss_gre_redir_lag_us_log_verbose(struct nss_gre_redir_lag_us_msg *ngm) -{ - switch (ngm->cm.type) { - case NSS_GRE_REDIR_LAG_US_CONFIG_MSG: - nss_gre_redir_lag_us_log_config_msg(ngm); - break; - - case NSS_GRE_REDIR_LAG_US_ADD_HASH_NODE_MSG: - nss_gre_redir_lag_us_log_add_hash_node_msg(ngm); - break; - - case NSS_GRE_REDIR_LAG_US_DEL_HASH_NODE_MSG: - nss_gre_redir_lag_us_log_del_hash_node_msg(ngm); - break; - - case NSS_GRE_REDIR_LAG_US_QUERY_HASH_NODE_MSG: - nss_gre_redir_lag_us_log_query_hash_node_msg(ngm); - break; - - case NSS_GRE_REDIR_LAG_US_CMN_STATS_SYNC_MSG: - case NSS_GRE_REDIR_LAG_US_DB_HASH_NODE_MSG: - /* - * No log for valid stats message. - */ - break; - - default: - nss_warning("%px: Invalid message type\n", ngm); - break; - } -} - -/* - * nss_gre_redir_lag_us_log_tx_msg() - * Log messages transmitted to FW. - */ -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("%px: Invalid message type\n", ngm); - return; - } - - 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); -} - -/* - * nss_gre_redir_lag_us_log_rx_msg() - * Log messages received from FW. - */ -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("%px: Invalid response\n", ngm); - return; - } - - if (ngm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ngm->cm.response == NSS_CMN_RESPONSE_ACK)) { - 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("%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("%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]); - -verbose: - nss_gre_redir_lag_us_log_verbose(ngm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_log.h deleted file mode 100644 index cbda8d93a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_LOG_H__ -#define __NSS_GRE_REDIR_LAG_US_LOG_H__ - -/* - * nss_gre_redir_lag_us_log.h - * NSS GRE REDIR LAG US Log Header File - */ - -/* - * nss_gre_redir_lag_us_log_tx_msg - * Logs a gre redir lag us message that is sent to the NSS firmware. - */ -void nss_gre_redir_lag_us_log_tx_msg(struct nss_gre_redir_lag_us_msg *ngm); - -/* - * nss_gre_redir_lag_us_log_rx_msg - * Logs a gre redir lag us message that is received from the NSS firmware. - */ -void nss_gre_redir_lag_us_log_rx_msg(struct nss_gre_redir_lag_us_msg *ngm); - -#endif /* __NSS_GRE_REDIR_LAG_US_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_stats.c deleted file mode 100644 index 2b291bfd3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_stats.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_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. - */ -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; - } - - 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_cmn_stats_read() - * Read and copy stats to user buffer. - */ -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; - 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; - } - - while (data->index < NSS_GRE_REDIR_LAG_MAX_NODE) { - if (nss_gre_redir_lag_us_stats_get(&stats, data->index)) { - break; - } - - data->index++; - } - - 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_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - data->index++; - kfree(lbuf); - return bytes_read; -} - -/* - * nss_gre_redir_lag_us_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(gre_redir_lag_us_cmn) - -/* - * nss_gre_redir_lag_us_stats_dentry_create() - * Create debugfs directory for stats. - */ -struct dentry *nss_gre_redir_lag_us_stats_dentry_create(void) -{ - struct dentry *gre_redir; - struct dentry *cmn_stats; - - gre_redir = nss_gre_redir_get_dentry(); - if (unlikely(!gre_redir)) { - nss_warning("Failed to retrieve directory entry qca-nss-drv/stats/gre_redir/\n"); - return NULL; - } - - cmn_stats = debugfs_create_file("lag_us_cmn_stats", 0400, gre_redir, - &nss_top_main, &nss_gre_redir_lag_us_cmn_stats_ops); - if (unlikely(!cmn_stats)) { - nss_warning("Failed to create qca-nss-drv/stats/gre_redir/lag_us_cmn_stats file\n"); - return NULL; - } - - 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); - diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_stats.h deleted file mode 100644 index 9f223122d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_stats.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - ****************************************************************************** - * 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 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_STATS_H__ -#define __NSS_GRE_REDIR_LAG_US_STATS_H__ - -/* - * 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. - */ -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 diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_strings.c deleted file mode 100644 index c1dca2bad..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} - diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_lag_us_strings.h deleted file mode 100644 index 74c1054de..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_log.c deleted file mode 100644 index 1ac6afbd2..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_log.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_gre_redir_log.c - * NSS GRE REDIR logger file. - */ - -#include "nss_core.h" - -/* - * nss_gre_redir_log_message_types_str - * NSS GRE REDIR message strings - */ -static int8_t *nss_gre_redir_log_message_types_str[NSS_GRE_REDIR_MAX_MSG_TYPES] __maybe_unused = { - "GRE REDIR Tunnel Inner Configure", - "GRE REDIR Tunnel Outer Configure", - "GRE REDIR Interface Map", - "GRE REDIR Interface Unmap", - "GRE REDIR SJACK Map", - "GRE REDIR SJACK Unmap", - "GRE REDIR Stats Sync", - "GRE REDIR Exception DS register cb" -}; - -/* - * nss_gre_redir_log_inner_configure_msg() - * Log NSS GRE Redir inner configure 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("%px: NSS GRE Redir Inner Configure message" - "GRE REDIR IP Header Type: %d\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" - "GRE REDIR Version: %d\n", - ngicm, ngicm->ip_hdr_type, - ngicm->ip_src_addr, ngicm->ip_dest_addr, - ngicm->except_outerif, ngicm->ip_df_policy, - ngicm->ip_ttl, ngicm->gre_version); -} - -/* - * nss_gre_redir_log_interface_map_msg() - * Log NSS GRE Redir interface map message. - */ -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("%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" - "GRE REDIR VAP ID: %d\n" - "GRE REDIR LAG Flags: %x\n" - "GRE REDIR Tunnel Type: %d\n" - "GRE REDIR IPsec pattern: %d\n", - ngicm, ngicm->vap_nssif, - ngicm->nexthop_nssif, ngicm->radio_id, - ngicm->vap_id, ngicm->lag_en, - ngicm->tunnel_type, ngicm->ipsec_pattern); -} - -/* - * nss_gre_redir_log_interface_unmap_msg() - * Log NSS GRE Redir interface unmap message. - */ -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("%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", - ngicm, ngicm->vap_nssif, - ngicm->radio_id, ngicm->vap_id); -} - -/* - * nss_gre_redir_log_sjack_map_msg() - * Log NSS GRE Redir interface map message. - */ -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("%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", - ngscm, ngscm->eth_nssif, - ngscm->eth_id, ngscm->ipsec_pattern); -} - -/* - * nss_gre_redir_log_sjack_unmap_msg() - * Log NSS GRE Redir interface unmap message. - */ -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("%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, - ngscm->eth_id); -} - -/* - * nss_gre_redir_log_outer_configure_msg() - * Log NSS GRE Redir outer configure message. - */ -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("%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" - "GRE REDIR SJACK Inner Interface: %d\n" - "GRE REDIR RPS: %d\n" - "GRE REDIR RPS Valid: %d\n", - ngocm, ngocm->ip_hdr_type, - ngocm->except_hostif, ngocm->except_offlif, - ngocm->except_sjackif, ngocm->rps_hint, - ngocm->rps_hint_valid); -} - -/* - * nss_gre_redir_log_exception_ds_reg_cb_msg() - * Log GRE exception downstream callback registration message. - */ -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("%px: NSS GRE redir exception completion callback registration message\n" - "vap_if_num: %d\n", ngm, exception_ds_configure->dst_vap_nssif); -} - -/* - * nss_gre_redir_log_verbose() - * Log message contents. - */ -static void nss_gre_redir_log_verbose(struct nss_gre_redir_msg *ngm) -{ - switch (ngm->cm.type) { - case NSS_GRE_REDIR_TX_TUNNEL_INNER_CONFIGURE_MSG: - nss_gre_redir_log_inner_configure_msg(ngm); - break; - - case NSS_GRE_REDIR_TX_TUNNEL_OUTER_CONFIGURE_MSG: - nss_gre_redir_log_outer_configure_msg(ngm); - break; - - case NSS_GRE_REDIR_TX_INTERFACE_MAP_MSG: - nss_gre_redir_log_interface_map_msg(ngm); - break; - - case NSS_GRE_REDIR_TX_INTERFACE_UNMAP_MSG: - nss_gre_redir_log_interface_unmap_msg(ngm); - break; - - case NSS_GRE_REDIR_TX_SJACK_MAP_MSG: - nss_gre_redir_log_sjack_map_msg(ngm); - break; - - case NSS_GRE_REDIR_TX_SJACK_UNMAP_MSG: - nss_gre_redir_log_sjack_unmap_msg(ngm); - break; - - case NSS_GRE_REDIR_RX_STATS_SYNC_MSG: - /* - * No log for valid stats message. - */ - break; - - case NSS_GRE_REDIR_EXCEPTION_DS_REG_CB_MSG: - nss_gre_redir_log_exception_ds_reg_cb_msg(ngm); - break; - - default: - nss_warning("%px: Invalid message type\n", ngm); - break; - } -} - -/* - * nss_gre_redir_log_tx_msg() - * Log messages transmitted to FW. - */ -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("%px: Invalid message type\n", ngm); - return; - } - - 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); -} - -/* - * nss_gre_redir_log_rx_msg() - * Log messages received from FW. - */ -void nss_gre_redir_log_rx_msg(struct nss_gre_redir_msg *ngm) -{ - if (ngm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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]); - -verbose: - nss_gre_redir_log_verbose(ngm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_log.h deleted file mode 100644 index 7e1fb793e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_LOG_H -#define __NSS_GRE_REDIR_LOG_H - -/* - * nss_gre_redir_log.h - * NSS GRE REDIR Log header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_gre_redir_log_tx_msg - * Logs a gre_redir message that is sent to the NSS firmware. - */ -void nss_gre_redir_log_tx_msg(struct nss_gre_redir_msg *ngm); - -/* - * nss_gre_redir_log_rx_msg - * Logs a gre_redir message that is received from the NSS firmware. - */ -void nss_gre_redir_log_rx_msg(struct nss_gre_redir_msg *ngm); - -#endif /* __NSS_GRE_REDIR_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark.c deleted file mode 100644 index 0b8524f7c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark.c +++ /dev/null @@ -1,341 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_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 */ - -/* - * Private data structure for handling synchronous messaging. - */ -static struct { - struct semaphore sem; - struct completion complete; - int response; -} nss_gre_redir_mark_pvt; - -/* - * nss_gre_redir_mark_msg_sync_callback() - * Callback to handle the completion of HLOS-->NSS messages. - */ -static void nss_gre_redir_mark_msg_sync_callback(void *app_data, struct nss_gre_redir_mark_msg *nim) -{ - nss_gre_redir_mark_pvt.response = NSS_TX_SUCCESS; - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("GRE mark Error response %d\n", nim->cm.response); - nss_gre_redir_mark_pvt.response = NSS_TX_FAILURE; - } - - complete(&nss_gre_redir_mark_pvt.complete); -} - -/* - * nss_gre_redir_mark_handler() - * Handle NSS to HLOS messages for GRE redir mark - */ -static void nss_gre_redir_mark_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *app_data) -{ - struct nss_gre_redir_mark_msg *ngrm = (struct nss_gre_redir_mark_msg *)ncm; - nss_gre_redir_mark_msg_callback_t cb; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_GRE_REDIR_MARK_MSG_MAX) { - 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("%px: length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Trace messages. - */ - nss_gre_redir_mark_log_rx_msg((struct nss_gre_redir_mark_msg *)ncm); - - 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); - } - - /* - * Update the callback and app_data for NOTIFY messages, GRE redir mark sends all notify messages - * to the same callback/app_data. The app data here represent the netdevice of the GRE redir mark - * interface. - */ - 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; - } - - /* - * load and call the registered synchronous message callback. - */ - cb = (nss_gre_redir_mark_msg_callback_t)ncm->cb; - if (unlikely(!cb)) { - return; - } - - cb((void *)ncm->app_data, ncm); -} - -/* - * nss_gre_redir_mark_reg_cb() - * Configure a callback on VAP. - */ -nss_tx_status_t nss_gre_redir_mark_reg_cb(int ifnum, - struct nss_gre_redir_mark_register_cb_msg *ngrcm) -{ - struct nss_gre_redir_mark_msg config; - struct nss_ctx_instance *nss_ctx __maybe_unused = nss_gre_redir_mark_get_context(); - nss_tx_status_t status; - uint32_t vap_type; - uint32_t len = sizeof(struct nss_gre_redir_mark_register_cb_msg); - - if (!nss_ctx) { - nss_warning("Unable to retrieve NSS context.\n"); - return NSS_TX_FAILURE_BAD_PARAM; - } - - vap_type = nss_dynamic_interface_get_type(nss_ctx, ngrcm->nss_if_num); - if ((vap_type != NSS_DYNAMIC_INTERFACE_TYPE_VAP)) { - nss_warning("%px: Incorrect type for vap interface type = %u", nss_ctx, vap_type); - return NSS_TX_FAILURE_BAD_PARAM; - } - - /* - * Configure the node - */ - nss_cmn_msg_init(&config.cm, NSS_GRE_REDIR_MARK_INTERFACE, NSS_GRE_REDIR_MARK_REG_CB_MSG, len, NULL, NULL); - config.msg.reg_cb_msg.nss_if_num = ngrcm->nss_if_num; - - status = nss_gre_redir_mark_tx_msg_sync(nss_ctx, &config); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: Unable to register callback from GRE redir mark interface %d\n", nss_ctx, ifnum); - } - - return status; -} -EXPORT_SYMBOL(nss_gre_redir_mark_reg_cb); - -/* - * nss_gre_redir_mark_tx_msg() - * Transmit a GRE MARK configuration message to NSS FW. - */ -nss_tx_status_t nss_gre_redir_mark_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_mark_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace Messages - */ - nss_gre_redir_mark_log_tx_msg(msg); - - /* - * interface should be of type of redir mark - */ - if (ncm->interface != NSS_GRE_REDIR_MARK_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("%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); -} -EXPORT_SYMBOL(nss_gre_redir_mark_tx_msg); - -/* - * nss_gre_redir_mark_tx_msg_sync() - * Transmit a GRE redir mark message to NSS firmware synchronously. - */ -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_tx_status_t status; - int ret = 0; - - /* - * Decrease the semaphore count to send the message exclusively. - */ - down(&nss_gre_redir_mark_pvt.sem); - ngrm->cm.cb = (nss_ptr_t)nss_gre_redir_mark_msg_sync_callback; - 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("%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("%px: GRE redir mark message tx sync failed due to timeout\n", nss_ctx); - nss_gre_redir_mark_pvt.response = NSS_TX_FAILURE; - } - - status = nss_gre_redir_mark_pvt.response; - up(&nss_gre_redir_mark_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_gre_redir_mark_tx_msg_sync); - -/* - * nss_gre_redir_mark_tx_buf() - * Send packet to GRE redir mark interface owned by NSS. - */ -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("%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("%px: Invalid interface:%d for GRE redir mark packets\n", nss_ctx, if_num); - return NSS_TX_FAILURE_BAD_PARAM; - } - - return nss_core_send_packet(nss_ctx, os_buf, if_num, 0); -} -EXPORT_SYMBOL(nss_gre_redir_mark_tx_buf); - -/* - * nss_gre_redir_mark_get_context() - * Return NSS GRE redir mark context. - */ -struct nss_ctx_instance *nss_gre_redir_mark_get_context(void) -{ - return &nss_top_main.nss[nss_top_main.gre_redir_mark_handler_id]; -} -EXPORT_SYMBOL(nss_gre_redir_mark_get_context); - -/* - * nss_gre_redir_mark_unregister_if() - * Unregister dynamic node for GRE_REDIR_MARK redir. - */ -bool nss_gre_redir_mark_unregister_if(uint32_t if_num) -{ - 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); - - dev = nss_cmn_get_interface_dev(nss_ctx, if_num); - - BUG_ON(!dev); - - nss_core_unregister_subsys_dp(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 gre_redir_mark interface %d with NSS core\n", - nss_ctx, if_num); - return false; - } - - nss_ctx->nss_rx_interface_handlers[if_num].msg_cb = NULL; - return true; -} -EXPORT_SYMBOL(nss_gre_redir_mark_unregister_if); - -/* - * nss_gre_redir_mark_register_if() - * Register staticr GRE redir mark interface with data-plane. - */ -struct nss_ctx_instance *nss_gre_redir_mark_register_if(struct net_device *netdev, uint32_t if_num, - nss_gre_redir_mark_data_callback_t cb_func_data, nss_gre_redir_mark_msg_callback_t cb_func_msg, - 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); - - /* - * Registering the interface with network data path. - */ - nss_core_register_subsys_dp(nss_ctx, if_num, cb_func_data, NULL, NULL, netdev, features); - 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); - -/* - * nss_gre_redir_mark_get_device() - * Gets the original device from probe. - */ -struct device *nss_gre_redir_mark_get_device(void) -{ - struct nss_ctx_instance *nss_ctx = nss_gre_redir_mark_get_context(); - return nss_ctx->dev; -} -EXPORT_SYMBOL(nss_gre_redir_mark_get_device); - -/* - * nss_gre_redir_mark_register_handler() - * Register GRE redir mark and register handler - */ -void nss_gre_redir_mark_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_gre_redir_mark_get_context(); - struct dentry *gre_redir_mark_dentry = NULL; - uint32_t status = NSS_CORE_STATUS_FAILURE; - - /* - * Create the debug fs entry for the stats. - */ - gre_redir_mark_dentry = nss_gre_redir_mark_stats_dentry_create(); - if (!gre_redir_mark_dentry) { - nss_warning("%px: Not able to create debugfs entry\n", nss_ctx); - 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); - - nss_info("nss_gre_redir_mark_register_handler\n"); - status = nss_core_register_handler(nss_ctx, NSS_GRE_REDIR_MARK_INTERFACE, nss_gre_redir_mark_handler, NULL); - if (status != NSS_CORE_STATUS_SUCCESS) { - debugfs_remove_recursive(gre_redir_mark_dentry); - gre_redir_mark_dentry = NULL; - nss_warning("%px: Not able to register handler for GRE redir mark with NSS core\n", nss_ctx); - return; - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_log.c deleted file mode 100644 index 580c5a851..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_log.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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" - -/* - * nss_gre_redir_mark_log_message_types_str - * GRE redir mark message strings - */ -static int8_t *nss_gre_redir_mark_log_message_types_str[NSS_GRE_REDIR_MARK_MSG_MAX] __maybe_unused = { - "GRE redir mark register callback message", - "GRE redir mark statistics synchronization" -}; - -/* - * nss_gre_redir_mark_log_error_response_types_str - * Strings for error types for GRE redir mark messages - */ -static int8_t *nss_gre_redir_mark_log_error_response_types_str[NSS_GRE_REDIR_MARK_ERROR_TYPE_MAX] __maybe_unused = { - "GRE redir mark No error", - "GRE redir mark Invalid interface for callback registration", - "GRE redir mark Invalid ethertype for Tx interface" -}; - -/* - * nss_gre_redir_mark_log_reg_cb_msg() - * Log NSS GRE redir mark configuration message - */ -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("%px: NSS GRE redir mark callback registration message \n" - "nss_if_num: %d\n", ncm, reg_cb_msg->nss_if_num); -} - -/* - * nss_gre_redir_mark_log_verbose() - * Log message contents. - */ -static void nss_gre_redir_mark_log_verbose(struct nss_gre_redir_mark_msg *ncm) -{ - switch (ncm->cm.type) { - case NSS_GRE_REDIR_MARK_REG_CB_MSG: - nss_gre_redir_mark_log_reg_cb_msg(ncm); - break; - - case NSS_GRE_REDIR_MARK_STATS_SYNC_MSG: - /* - * No log for valid stats message. - */ - break; - - default: - nss_trace("%px: Invalid message type\n", ncm); - break; - } -} - -/* - * nss_gre_redir_mark_log_tx_msg() - * Log messages transmitted to FW. - */ -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("%px: Invalid message type\n", ngm); - return; - } - - 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); -} -/* - * nss_gre_redir_mark_log_rx_msg() - * Log messages received from FW. - */ -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("%px: Invalid response\n", ncm); - return; - } - - if (ncm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ncm->cm.response == NSS_CMN_RESPONSE_ACK)) { - 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("%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("%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]); - -verbose: - nss_gre_redir_mark_log_verbose(ncm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_log.h deleted file mode 100644 index 27e2ffb16..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_LOG_H__ -#define __NSS_GRE_REDIR_MARK_LOG_H__ - -/* - * nss_gre_redir_mark_log.h - * NSS GRE_REDIR_MARK Log Header File. - */ - -/* - * nss_gre_redir_mark_log_tx_msg - * Logs GRE_REDIR_MARK message that is sent to the NSS firmware. - */ -void nss_gre_redir_mark_log_tx_msg(struct nss_gre_redir_mark_msg *ncm); - -/* - * nss_gre_redir_mark_log_rx_msg - * Logs GRE_REDIR_MARK message that is received from the NSS firmware. - */ -void nss_gre_redir_mark_log_rx_msg(struct nss_gre_redir_mark_msg *ncm); - -#endif /* __NSS_GRE_REDIR_MARK_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_stats.c deleted file mode 100644 index da0f64621..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_stats.c +++ /dev/null @@ -1,230 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_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 - */ -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; - } - - /* - * 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; - ssize_t bytes_read = 0; - bool isthere; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(!lbuf)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - /* - * If GRE redir mark does not exists, then (isthere) will be false. - */ - isthere = nss_gre_redir_mark_stats_get(&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); - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - - kfree(lbuf); - return bytes_read; -} - -/* - * nss_gre_redir_mark_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(gre_redir_mark) - -/* - * nss_gre_redir_mark_stats_dentry_create() - * Create debugfs directory entry for stats. - */ -struct dentry *nss_gre_redir_mark_stats_dentry_create(void) -{ - struct dentry *gre_redir_mark; - - gre_redir_mark = debugfs_create_file("gre_redir_mark", 0400, nss_top_main.stats_dentry, - &nss_top_main, &nss_gre_redir_mark_stats_ops); - if (unlikely(!gre_redir_mark)) { - nss_warning("Failed to create file entry qca-nss-drv/stats/gre_redir_mark/\n"); - return NULL; - } - - 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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_stats.h deleted file mode 100644 index cacb3d218..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_stats.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - ****************************************************************************** - * Copyright (c) 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. - * 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_STATS_H__ -#define __NSS_GRE_REDIR_MARK_STATS_H__ - -/* - * NSS core stats -- for H2N/N2H gre_redir_mark debug stats - */ -struct nss_gre_redir_mark_stats { - uint64_t stats[NSS_GRE_REDIR_MARK_STATS_MAX]; -}; - -/* - * 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__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_strings.c deleted file mode 100644 index a8d5a9859..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_mark_strings.h deleted file mode 100644 index 98ed33204..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_stats.c deleted file mode 100644 index 6adb3534c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_stats.c +++ /dev/null @@ -1,312 +0,0 @@ -/* - **************************************************************************** - * Copyright (c) 2017-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. - * 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_gre_redir.h" -#include "nss_gre_redir_stats.h" -#include "nss_gre_redir_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_gre_redir_stats_notifier); - -/* - * Spinlock to protect GRE redirect statistics update/read - */ -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) -{ - 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_stats_get); - -/* - * nss_gre_redir_stats_read() - * READ gre_redir tunnel stats. - */ -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; - 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; - } - - /* - * If we are done accomodating all the GRE_REDIR tunnels. - */ - if (index >= NSS_GRE_REDIR_MAX_INTERFACES) { - kfree(lbuf); - return 0; - } - - for (; index < NSS_GRE_REDIR_MAX_INTERFACES; index++) { - bool isthere; - - /* - * If gre_redir tunnel does not exists, then isthere will be false. - */ - isthere = nss_gre_redir_stats_get(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_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - if (data) { - data->index = index; - } - - kfree(lbuf); - return bytes_read; -} - -/* - * nss_gre_redir_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(gre_redir) - -/* - * nss_gre_redir_stats_dentry_create() - * Create debugfs directory entry for stats. - */ -struct dentry *nss_gre_redir_stats_dentry_create(void) -{ - struct dentry *gre_redir; - struct dentry *tun_stats; - - gre_redir = debugfs_create_dir("gre_redir", nss_top_main.stats_dentry); - if (unlikely(!gre_redir)) { - nss_warning("Failed to create directory entry qca-nss-drv/stats/gre_redir/\n"); - return NULL; - } - - tun_stats = debugfs_create_file("tun_stats", 0400, gre_redir, - &nss_top_main, &nss_gre_redir_stats_ops); - if (unlikely(!tun_stats)) { - debugfs_remove_recursive(gre_redir); - nss_warning("Failed to create file entry qca-nss-drv/stats/gre_redir/tun_stats\n"); - return NULL; - } - - 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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_stats.h deleted file mode 100644 index 28f8fae3e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_stats.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - ****************************************************************************** - * Copyright (c) 2017-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. - * 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_STATS_H__ -#define __NSS_GRE_REDIR_STATS_H__ - -/* - * 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__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_strings.c deleted file mode 100644 index 319be274e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_redir_strings.h deleted file mode 100644 index b0f0ba340..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_stats.c deleted file mode 100644 index 3808e5e93..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_stats.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2017-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_gre_stats.c - * NSS GRE statistics APIs - * - */ - -#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. - */ -ATOMIC_NOTIFIER_HEAD(nss_gre_stats_notifier); - -/* - * Data structures to store GRE nss debug stats - */ -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; - -/* - * GRE statistics APIs - */ - -/* - * nss_gre_stats_session_unregister() - * Unregister debug statistic for GRE session. - */ -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].if_num == if_num) { - memset(&session_stats[i], 0, sizeof(struct nss_gre_stats_session)); - break; - } - } - spin_unlock_bh(&nss_gre_stats_lock); -} - -/* - * nss_gre_stats_session_register() - * Register debug statistic for GRE session. - */ -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].valid) { - session_stats[i].valid = true; - session_stats[i].if_num = if_num; - session_stats[i].if_index = netdev->ifindex; - break; - } - } - spin_unlock_bh(&nss_gre_stats_lock); -} - -/* - * nss_gre_stats_session_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) -{ - 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 (interface_type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_INNER) { - session_stats[i].stats[NSS_GRE_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; - } - break; - } - } - spin_unlock_bh(&nss_gre_stats_lock); -} - -/* - * nss_gre_stats_base_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) -{ - 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]; - } - spin_unlock_bh(&nss_gre_stats_lock); -} - -/* - * nss_gre_stats_session_get() - * Get GRE session debug statistics. - */ -static void nss_gre_stats_session_get(void *stats_mem, int size) -{ - struct nss_gre_stats_session *stats = (struct nss_gre_stats_session *)stats_mem; - int i; - - if (!stats || (size < (sizeof(struct nss_gre_stats_session) * 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)); - stats++; - } - } - spin_unlock_bh(&nss_gre_stats_lock); -} - -/* - * nss_gre_stats_base_get() - * Get GRE debug base statistics. - */ -static void nss_gre_stats_base_get(void *stats_mem, int size) -{ - struct nss_gre_stats_base *stats = (struct nss_gre_stats_base *)stats_mem; - - if (!stats) { - nss_warning("No memory to copy GRE base stats\n"); - return; - } - - if (size < sizeof(struct nss_gre_stats_base)) { - 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)); - spin_unlock_bh(&nss_gre_stats_lock); -} - -/* - * nss_gre_stats_read() - * Read GRE statistics - */ -static ssize_t nss_gre_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - 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 */ - + 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; - int id; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(!lbuf)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - bstats = kzalloc(sizeof(struct nss_gre_stats_base), 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); - if (unlikely(!sstats)) { - nss_warning("Could not allocate memory for base debug statistics buffer"); - kfree(lbuf); - kfree(bstats); - return 0; - } - - size_wr += nss_stats_banner(lbuf, size_wr, size_al, "gre", NSS_STATS_SINGLE_CORE); - - /* - * Get all base stats - */ - nss_gre_stats_base_get((void *)bstats, sizeof(struct nss_gre_stats_base)); - - size_wr += nss_stats_print("gre", NULL, NSS_STATS_SINGLE_INSTANCE - , nss_gre_strings_base_stats - , bstats->stats - , NSS_GRE_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); - - for (id = 0; id < NSS_GRE_MAX_DEBUG_SESSION_STATS; id++) { - - if (!((sstats + id)->valid)) { - continue; - } - - dev = dev_get_by_index(&init_net, (sstats + 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, - (sstats + 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, - (sstats + id)->if_num); - } - size_wr += nss_stats_print("gre_session", NULL, id - , nss_gre_strings_session_stats - , (sstats + id)->stats - , NSS_GRE_SESSION_DEBUG_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(sstats); - kfree(bstats); - kfree(lbuf); - return bytes_read; -} - -/* - * nss_gre_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(gre) - -/* - * nss_gre_stats_dentry_create() - * Create gre statistics debug entry. - */ -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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_stats.h deleted file mode 100644 index 7feb1d679..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_stats.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2017, 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_gre_stats.h - * NSS GRE statistics header file. - */ - -#ifndef __NSS_GRE_STATS_H -#define __NSS_GRE_STATS_H - -#include - -/* - * GRE base debug statistics - */ -struct nss_gre_stats_base { - uint64_t stats[NSS_GRE_BASE_DEBUG_MAX]; /**< GRE debug statistics. */ -}; - -/* - * 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 ? */ -}; - -/* - * 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_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); - -#endif /* __NSS_GRE_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_strings.c deleted file mode 100644 index 26c652d75..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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; - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_strings.h deleted file mode 100644 index e8a421fce..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel.c deleted file mode 100644 index 1e9a22a72..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_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 */ - -/* - * Private data structure - */ -static struct nss_gre_tunnel_pvt { - struct semaphore sem; - struct completion complete; - int response; - void *cb; - void *app_data; -} gre_tunnel_pvt; - -/* - * nss_gre_tunnel_verify_if_num() - * Verify if_num passed to us. - */ -static bool nss_gre_tunnel_verify_if_num(uint32_t if_num) -{ - uint32_t type = nss_dynamic_interface_get_type(nss_gre_tunnel_get_ctx(), if_num); - - switch (type) { - case NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INNER: - case NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INLINE_INNER: - case NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_OUTER: - case NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INLINE_OUTER: - case NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INNER_EXCEPTION: - return true; - default: - return false; - } -} - -/* - * nss_gre_tunnel_handler() - * Handle NSS to HLOS messages for gre_tunnel - */ -static void nss_gre_tunnel_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_gre_tunnel_msg *ngtm = (struct nss_gre_tunnel_msg *)ncm; - void *ctx; - - nss_gre_tunnel_msg_callback_t cb; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - BUG_ON(!nss_gre_tunnel_verify_if_num(ncm->interface)); - - /* - * Trace Messages - */ - nss_gre_tunnel_log_rx_msg(ngtm); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_GRE_TUNNEL_MSG_MAX) { - 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("%px: gre_tunnel message length is invalid: %d", nss_ctx, ncm->len); - return; - } - - /* - * Check messages - */ - 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; - } - - /* - * Update the callback and app_data for NOTIFY messages - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->gre_tunnel_msg_callback; - 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_gre_tunnel_msg_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - /* - * call GRE Tunnel session callback - */ - if (!cb) { - return; - } - - cb(ctx, ngtm); -} - -/* - * nss_gre_tunnel_inquiry() - * Inquiry if a GRE tunnel has been established in NSS FW. - * - * Input parameters: - * inquiry_info->ip_type - * inquiry_info->src_ip - * inquiry_info->dest_ip - * inquiry_info->gre_mode - * if (gre_mode == NSS_GRE_TUNNEL_MODE_GRE_UDP) - * inquiry_info->src_port - * inquiry_info->dest_port - * inquiry_info->encrypt_type -- currently not checked in FW, - */ -nss_tx_status_t nss_gre_tunnel_inquiry( - struct nss_gre_tunnel_configure *inquiry_info, - nss_gre_tunnel_msg_callback_t cb, void *app_data) -{ - nss_tx_status_t nss_tx_status; - struct nss_gre_tunnel_msg nim; - struct nss_ctx_instance *nss_ctx = nss_gre_tunnel_get_ctx(); - - /* - * Initialize inquiry message structure. - * This is async message and the result will be returned - * to the caller by the msg_callback passed in. - */ - memset(&nim, 0, sizeof(nim)); - nss_gre_tunnel_msg_init(&nim, NSS_GRE_TUNNEL_INTERFACE, - NSS_GRE_TUNNEL_MSG_INQUIRY, - sizeof(struct nss_gre_tunnel_configure), - cb, app_data); - 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("%px: Send GT inquiry message failed\n", inquiry_info); - } - - return nss_tx_status; -} -EXPORT_SYMBOL(nss_gre_tunnel_inquiry); - -/* - * nss_get_gre_tunnel_context() - * Return the core ctx which the feature is on - */ -struct nss_ctx_instance *nss_gre_tunnel_get_ctx(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.gre_tunnel_handler_id]; -} -EXPORT_SYMBOL(nss_gre_tunnel_get_ctx); - -/* - * nss_gre_tunnel_ifnum_with_core_id() - * Append core id to GRE tunnel interface num - */ -int nss_gre_tunnel_ifnum_with_core_id(int if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_gre_tunnel_get_ctx(); - BUG_ON(!nss_gre_tunnel_verify_if_num(if_num)); - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (nss_is_dynamic_interface(if_num) == false) { - 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); -} -EXPORT_SYMBOL(nss_gre_tunnel_ifnum_with_core_id); - -/* - * nss_gre_tunnel_tx_buf() - * Transmit buffer over GRE Tunnel interface - */ -nss_tx_status_t nss_gre_tunnel_tx_buf(struct sk_buff *skb, uint32_t if_num, - struct nss_ctx_instance *nss_ctx) -{ - BUG_ON(!nss_gre_tunnel_verify_if_num(if_num)); - - return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_VIRTUAL_BUFFER | H2N_BIT_FLAG_BUFFER_REUSABLE); -} -EXPORT_SYMBOL(nss_gre_tunnel_tx_buf); - -/* - * nss_gre_tunnel_tx_msg() - * Transmit a gre_tunnel message to NSS firmware - */ -nss_tx_status_t nss_gre_tunnel_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_gre_tunnel_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace Messages - */ - nss_gre_tunnel_log_tx_msg(msg); - - /* - * Sanity check message - */ - if (ncm->type >= NSS_GRE_TUNNEL_MSG_MAX) { - nss_warning("%px: gre_tunnel message type out of range: %d", - nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - BUG_ON(!nss_gre_tunnel_verify_if_num(ncm->interface)); - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_gre_tunnel_tx_msg); - -/* - * nss_gre_tunnel_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_gre_tunnel_callback(void *app_data, struct nss_gre_tunnel_msg *ngtm) -{ - nss_gre_tunnel_msg_callback_t callback = (nss_gre_tunnel_msg_callback_t)gre_tunnel_pvt.cb; - void *data = gre_tunnel_pvt.app_data; - - gre_tunnel_pvt.response = NSS_TX_SUCCESS; - gre_tunnel_pvt.cb = NULL; - gre_tunnel_pvt.app_data = NULL; - - if (ngtm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("gre tunnel Error response %d\n", ngtm->cm.response); - gre_tunnel_pvt.response = ngtm->cm.response; - } - - if (callback) { - callback(data, ngtm); - } - complete(&gre_tunnel_pvt.complete); -} - -/* - * nss_gre_tunnel_tx_msg() - * Transmit a GRE Tunnel message to NSS firmware synchronously. - */ -nss_tx_status_t nss_gre_tunnel_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_tunnel_msg *ngtm) -{ - nss_tx_status_t status; - int ret = 0; - - down(&gre_tunnel_pvt.sem); - gre_tunnel_pvt.cb = (void *)ngtm->cm.cb; - gre_tunnel_pvt.app_data = (void *)ngtm->cm.app_data; - - ngtm->cm.cb = (nss_ptr_t)nss_gre_tunnel_callback; - ngtm->cm.app_data = (nss_ptr_t)NULL; - - status = nss_gre_tunnel_tx_msg(nss_ctx, ngtm); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: gre_tunnel_tx_msg failed\n", nss_ctx); - up(&gre_tunnel_pvt.sem); - return status; - } - - ret = wait_for_completion_timeout(&gre_tunnel_pvt.complete, msecs_to_jiffies(NSS_GRE_TUNNEL_TX_TIMEOUT)); - - if (!ret) { - nss_warning("%px: GRE Tunnel msg tx failed due to timeout\n", nss_ctx); - gre_tunnel_pvt.response = NSS_TX_FAILURE; - } - - status = gre_tunnel_pvt.response; - up(&gre_tunnel_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_gre_tunnel_tx_msg_sync); - -/* - * nss_gre_tunnel_msg_init() - * Initialize gre_tunnel msg. - */ -void nss_gre_tunnel_msg_init(struct nss_gre_tunnel_msg *ngtm, uint16_t if_num, - uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ngtm->cm, if_num, type, len, cb, app_data); -} -EXPORT_SYMBOL(nss_gre_tunnel_msg_init); - -/* - * nss_gre_tunnel_register_if() - * Register netdev - */ -struct nss_ctx_instance *nss_gre_tunnel_register_if(uint32_t if_num, - nss_gre_tunnel_data_callback_t cb, - nss_gre_tunnel_msg_callback_t ev_cb, - struct net_device *netdev, - uint32_t features, - void *app_ctx) -{ - int32_t i; - - struct nss_ctx_instance *nss_ctx = nss_gre_tunnel_get_ctx(); - - BUG_ON(!nss_gre_tunnel_verify_if_num(if_num)); - - spin_lock_bh(&nss_gre_tunnel_stats_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; - break; - } - } - spin_unlock_bh(&nss_gre_tunnel_stats_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); - return NULL; - } - - 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; - return NULL; - } - - nss_core_register_subsys_dp(nss_ctx, if_num, cb, NULL, app_ctx, netdev, features); - - 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; -} -EXPORT_SYMBOL(nss_gre_tunnel_register_if); - -/* - * nss_gre_tunnel_unregister_if() - * Unregister netdev - */ -void nss_gre_tunnel_unregister_if(uint32_t if_num) -{ - int32_t i; - struct nss_ctx_instance *nss_ctx = nss_gre_tunnel_get_ctx(); - - BUG_ON(!nss_gre_tunnel_verify_if_num(if_num)); - - 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) { - memset(&session_stats[i], 0, - sizeof(struct nss_gre_tunnel_stats_session)); - break; - } - } - spin_unlock_bh(&nss_gre_tunnel_stats_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); - return; - } - - if (!nss_ctx->subsys_dp_register[if_num].ndev) { - nss_warning("%px: Cannot find registered netdev for GRE Tunnel NSS I/F: %d\n", nss_ctx, if_num); - - return; - } - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - nss_top_main.gre_tunnel_msg_callback = NULL; - nss_core_unregister_handler(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_gre_tunnel_unregister_if); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_log.c deleted file mode 100644 index 6af7b56b9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_log.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_gre_tunnel_log.c - * NSS GRE Tunnel logger file. - */ - -#include "nss_core.h" - -/* - * nss_gre_tunnel_log_message_types_str - * NSS GRE Tunnel message strings - */ -static int8_t *nss_gre_tunnel_log_message_types_str[NSS_GRE_TUNNEL_MSG_MAX] __maybe_unused = { - "GRE Tunnel configure", - "GRE Tunnel session destroy", - "GRE Tunnel stats", - "GRE Tunnel configure DI to WLAN ID", - "GRE Tunnel message inquiry" -}; - -/* - * nss_gre_tunnel_log_configure_msg() - * Log NSS GRE Tunnel configure message. - */ -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("%px: NSS GRE Tunnel configure message \n" - "Meta Header Version: %d\n" - "GRE Mode: %x\n" - "IP Type: %x\n" - "Encryption Type: %d\n" - "Source Port: %d\n" - "Destination Port: %d\n" - "Crypto Node Identifier: %d\n" - "Encryption Crypto Index: %d\n" - "Decryption Crypto Index: %d\n" - "Word0 header: %d\n" - "Initialization Vector: %px\n" - "Sibling Interface Number: %d\n" - "TTL: %d\n" - "RPS: %d\n" - "Reserved: %x\n" - "Word1 Header: %x\n" - "Word2 Header: %x\n" - "Word3 Header: %x\n", - ngcm, ngcm->mh_version, ngcm->gre_mode, - ngcm->ip_type, ngcm->encrypt_type, - ngcm->src_port, ngcm->dest_port, - ngcm->crypto_node_id, ngcm->crypto_idx_encrypt, - ngcm->crypto_idx_decrypt, ngcm->word0, - ngcm->iv_val, ngcm->sibling_if, - ngcm->ttl, ngcm->rps, - ngcm->reserved, ngcm->word1, - ngcm->word2, ngcm->word3); - - /* - * Continuation of log message. Different identifiers based on ip_type - */ - if (ngcm->ip_type == NSS_GRE_TUNNEL_IP_IPV6) { - nss_trace("Source IP: %pI6\n" - "Destination IP: %pI6\n", - ngcm->src_ip, ngcm->dest_ip); - } else if (ngcm->ip_type == NSS_GRE_TUNNEL_IP_IPV4) { - nss_trace("Source IP: %pI4\n" - "Destination IP: %pI4\n", - ngcm->src_ip, ngcm->dest_ip); - } -} - -/* - * nss_gre_tunnel_log_di_to_wlan_id_msg() - * Log NSS GRE Tunnel Dynamic Interface to WLAN ID message. - */ -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("%px: NSS GRE Dynamic Interface to WLAN ID message: \n" - "Dynamic Interface Number: %d\n" - "WLAN ID: %x\n", - ngdm, ngdm->dynamic_interface_num, - ngdm->wlan_id); -} - -/* - * nss_gre_tunnel_log_verbose() - * Log message contents. - */ -static void nss_gre_tunnel_log_verbose(struct nss_gre_tunnel_msg *ngm) -{ - switch (ngm->cm.type) { - case NSS_GRE_TUNNEL_MSG_CONFIGURE: - case NSS_GRE_TUNNEL_MSG_INQUIRY: - nss_gre_tunnel_log_configure_msg(ngm); - break; - - case NSS_GRE_TUNNEL_MSG_CONFIGURE_DI_TO_WLAN_ID: - nss_gre_tunnel_log_di_to_wlan_id_msg(ngm); - break; - - case NSS_GRE_TUNNEL_MSG_SESSION_DESTROY: - case NSS_GRE_TUNNEL_MSG_STATS: - /* - * No log for these valid messages. - */ - break; - - default: - nss_trace("%px: Invalid message type\n", ngm); - break; - } -} - -/* - * nss_gre_tunnel_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_gre_tunnel_log_tx_msg(struct nss_gre_tunnel_msg *ngm) -{ - if (ngm->cm.type >= NSS_GRE_TUNNEL_MSG_MAX) { - nss_warning("%px: Invalid message type\n", ngm); - return; - } - - 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); -} - -/* - * nss_gre_tunnel_log_rx_msg() - * Log messages received from FW. - */ -void nss_gre_tunnel_log_rx_msg(struct nss_gre_tunnel_msg *ngm) -{ - if (ngm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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]); - -verbose: - nss_gre_tunnel_log_verbose(ngm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_log.h deleted file mode 100644 index be0751301..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_LOG_H -#define __NSS_GRE_TUNNEL_LOG_H - -/* - * nss_gre_tunnel.h - * NSS GRE Tunnel header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_gre_tunnel_log_tx_msg - * Logs a gre_tunnel message that is sent to the NSS firmware. - */ -void nss_gre_tunnel_log_tx_msg(struct nss_gre_tunnel_msg *ngm); - -/* - * nss_gre_tunnel_log_rx_msg - * Logs a gre_tunnel message that is received from the NSS firmware. - */ -void nss_gre_tunnel_log_rx_msg(struct nss_gre_tunnel_msg *ngm); - -#endif /* __NSS_GRE_TUNNEL_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_stats.c deleted file mode 100644 index c3e53bf85..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_stats.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - **************************************************************************** - * Copyright (c) 2017, 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_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); - -/* - * Spinlock to protect gre tunnel statistics update/read - */ -DEFINE_SPINLOCK(nss_gre_tunnel_stats_lock); - -struct nss_gre_tunnel_stats_session session_stats[NSS_MAX_GRE_TUNNEL_SESSIONS]; - -/* - * nss_gre_tunnel_stats_session_sync() - * Sync function for GRE Tunnel statistics - */ -void nss_gre_tunnel_stats_session_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_tunnel_stats *stats_msg, - uint16_t if_num) -{ - int i; - struct nss_gre_tunnel_stats_session *s = NULL; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - 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) { - s = &session_stats[i]; - break; - } - } - - if (!s) { - spin_unlock_bh(&nss_gre_tunnel_stats_lock); - nss_warning("%px: Session not found: %u", nss_ctx, if_num); - return; - } - - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_PKTS] += stats_msg->node_stats.rx_packets; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_TX_PKTS] += stats_msg->node_stats.tx_packets; - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_QUEUE_0_DROPPED + i] += stats_msg->node_stats.rx_dropped[i]; - } - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_MALFORMED] += stats_msg->rx_malformed; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_INVALID_PROT] += stats_msg->rx_invalid_prot; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_DECAP_QUEUE_FULL] += stats_msg->decap_queue_full; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_SINGLE_REC_DGRAM] += stats_msg->rx_single_rec_dgram; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_INVALID_REC_DGRAM] += stats_msg->rx_invalid_rec_dgram; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_BUFFER_ALLOC_FAIL] += stats_msg->buffer_alloc_fail; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_BUFFER_COPY_FAIL] += stats_msg->buffer_copy_fail; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_OUTFLOW_QUEUE_FULL] += stats_msg->outflow_queue_full; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_DROPPED_HROOM] += stats_msg->rx_dropped_hroom; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_CBUFFER_ALLOC_FAIL] += stats_msg->rx_cbuf_alloc_fail; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_CENQUEUE_FAIL] += stats_msg->rx_cenqueue_fail; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_DECRYPT_DONE] += stats_msg->rx_decrypt_done; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_FORWARD_ENQUEUE_FAIL] += stats_msg->rx_forward_enqueue_fail; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_TX_CBUFFER_ALLOC_FAIL] += stats_msg->tx_cbuf_alloc_fail; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_TX_CENQUEUE_FAIL] += stats_msg->tx_cenqueue_fail; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_DROPPED_TROOM] += stats_msg->rx_dropped_troom; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_TX_FORWARD_ENQUEUE_FAIL] += stats_msg->tx_forward_enqueue_fail; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_TX_CIPHER_DONE] += stats_msg->tx_cipher_done; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_CRYPTO_NOSUPP] += stats_msg->crypto_nosupp; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_DROPPED_MH_VERSION] += stats_msg->rx_dropped_mh_ver; - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_RX_UNALIGNED_PKT] += stats_msg->rx_unaligned_pkt; - - /* - * Copy crypto resp err stats. - */ - for (i = 0; i < NSS_CRYPTO_CMN_RESP_ERROR_MAX; i++) { -#if defined(NSS_HAL_IPQ807x_SUPPORT) - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_MAX + i] += stats_msg->crypto_resp_error[i]; -#else - s->stats[NSS_GRE_TUNNEL_STATS_SESSION_MAX + i] = 0; -#endif - } - - spin_unlock_bh(&nss_gre_tunnel_stats_lock); -} - -/* - * nss_gre_tunnel_stats_session_get() - * Get session GRE Tunnel statitics. - */ -static void nss_gre_tunnel_stats_session_get(struct nss_gre_tunnel_stats_session *stats) -{ - int i; - - if (!stats) { - nss_warning("No memory to copy gre_tunnel session stats"); - return; - } - - spin_lock_bh(&nss_gre_tunnel_stats_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)); - stats++; - } - } - spin_unlock_bh(&nss_gre_tunnel_stats_lock); -} - -/* - * nss_gre_tunnel_stats_read() - * Read GRE Tunnel session statistics - */ -static ssize_t nss_gre_tunnel_stats_read(struct file *fp, char __user *ubuf, - size_t sz, loff_t *ppos) -{ - uint32_t max_output_lines = 2 + (NSS_MAX_GRE_TUNNEL_SESSIONS - * (NSS_GRE_TUNNEL_STATS_SESSION_MAX + 2)) + 2; - 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; - - 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_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) - * 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); - - /* - * Session stats - */ - size_wr += nss_stats_banner(lbuf, size_wr, size_al, "GRE tunnel stats", NSS_STATS_SINGLE_CORE); - - for (id = 0; id < NSS_MAX_GRE_TUNNEL_SESSIONS; id++) { - if (!gre_tunnel_session_stats[id].valid) - break; - - dev = dev_get_by_index(&init_net, gre_tunnel_session_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, gre_tunnel_session_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, - 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); - - /* - * 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]; - } - - 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"); - } - - 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; -} - -/* - * nss_gre_tunnel_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(gre_tunnel) - -/* - * nss_gre_tunnel_stats_dentry_create() - * Create gre tunnel statistics debug entry. - */ -void nss_gre_tunnel_stats_dentry_create(void) -{ - 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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_stats.h deleted file mode 100644 index cdee4788d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_stats.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - ****************************************************************************** - * Copyright (c) 2016-2017, 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_STATS_H -#define __NSS_GRE_TUNNEL_STATS_H - -/* - * GRE Tunnel session debug statistics - */ -struct nss_gre_tunnel_stats_session { - 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 */ - 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]; - -/* - * 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); - -#endif /* __NSS_GRE_TUNNEL_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_strings.c deleted file mode 100644 index 402182e61..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_gre_tunnel_strings.h deleted file mode 100644 index 829469492..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_hal/fsm9010/nss_hal_pvt.c b/feeds/ipq807x/qca-nss-drv/src/nss_hal/fsm9010/nss_hal_pvt.c deleted file mode 100644 index 4a72d3d82..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_hal/fsm9010/nss_hal_pvt.c +++ /dev/null @@ -1,342 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_hal_pvt.c - * NSS HAL private APIs. - */ - -#include -#include -#include -#include -#include -#include "nss_hal.h" -#include "nss_core.h" - -#define NSS_H2N_INTR_EMPTY_BUFFER_QUEUE_BIT 0 -#define NSS_H2N_INTR_DATA_COMMAND_QUEUE_BIT 1 -#define NSS_H2N_INTR_TX_UNBLOCKED_BIT 11 -#define NSS_H2N_INTR_TRIGGER_COREDUMP_BIT 15 - -/* - * Interrupt type to cause vector. - */ -static uint32_t intr_cause[] = {(1 << NSS_H2N_INTR_EMPTY_BUFFER_QUEUE_BIT), - (1 << NSS_H2N_INTR_DATA_COMMAND_QUEUE_BIT), - (1 << NSS_H2N_INTR_TX_UNBLOCKED_BIT), - (1 << NSS_H2N_INTR_TRIGGER_COREDUMP_BIT)}; - -/* - * nss_hal_wq_function() - * Added to Handle BH requests to kernel - */ -void nss_hal_wq_function(struct work_struct *work) -{ - /* - * Not supported in FSM9010 - */ - kfree((void *)work); -} - -/* - * nss_hal_get_num_irqs() - * get number of irqs from interrupt resource of device tree - */ -static inline int nss_hal_get_num_irqs(struct device_node *np) -{ - int num_irqs = 0; - - while (of_irq_to_resource(np, num_irqs, NULL)) { - num_irqs++; - } - - return num_irqs; -} - -/* - * nss_hal_handle_irq() - * HLOS interrupt handler for nss interrupts - */ -static irqreturn_t nss_hal_handle_irq(int irq, void *ctx) -{ - struct int_ctx_instance *int_ctx = (struct int_ctx_instance *) ctx; - struct nss_ctx_instance *nss_ctx = int_ctx->nss_ctx; - - /* - * Mask interrupt until our bottom half re-enables it - */ - nss_hal_disable_interrupt(nss_ctx, int_ctx->shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS); - - /* - * Schedule tasklet to process interrupt cause - */ - napi_schedule(&int_ctx->napi); - return IRQ_HANDLED; -} - -/* - * nss_hal_of_get_pdata() - * Retrieve platform data from device node. - */ -static struct nss_platform_data *__nss_hal_of_get_pdata(struct platform_device *pdev) -{ - struct device_node *np = of_node_get(pdev->dev.of_node); - struct nss_platform_data *npd = NULL; - struct nss_ctx_instance *nss_ctx = NULL; - struct nss_top_instance *nss_top = &nss_top_main; - struct resource res_nphys, res_vphys; - int32_t i; - - npd = devm_kzalloc(&pdev->dev, sizeof(struct nss_platform_data), GFP_KERNEL); - if (!npd) { - return NULL; - } - - if (of_property_read_u32(np, "qcom,id", &npd->id) - || of_property_read_u32(np, "qcom,num-queue", &npd->num_queue)) { - pr_err("%s: error reading critical device node properties\n", np->name); - goto out; - } - - if (of_property_read_u32(np, "qcom,num-irq", &npd->num_irq)) { - npd->num_irq = nss_hal_get_num_irqs(np); - } - - if (npd->num_irq < npd->num_queue) { - pr_err("%s: not enough interrupts configured for all the queues\n", np->name); - goto out; - } - - if (npd->num_irq > NSS_MAX_IRQ_PER_CORE) { - pr_err("%s: exceeds maximum interrupt numbers per core\n", np->name); - goto out; - } - - nss_ctx = &nss_top->nss[npd->id]; - nss_ctx->id = npd->id; - - if (of_address_to_resource(np, 0, &res_nphys) != 0) { - 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("%px: nss%d: of_address_to_resource() fail for vphys\n", nss_ctx, nss_ctx->id); - goto out; - } - - /* - * Save physical addresses - */ - npd->nphys = res_nphys.start; - npd->vphys = res_vphys.start; - - npd->nmap = ioremap_nocache(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; - } - - /* - * Get IRQ numbers - */ - 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("%px: nss%d: irq_of_parse_and_map() fail for irq %d\n", nss_ctx, nss_ctx->id, i); - goto out; - } - } - - nss_hal_dt_parse_features(np, npd); - - of_node_put(np); - return npd; - -out: - if (npd->nmap) { - iounmap((void *)npd->nmap); - } - - if (npd->vmap) { - iounmap((void *)npd->vmap); - } - - devm_kfree(&pdev->dev, npd); - of_node_put(np); - return NULL; -} - -/* - * __nss_hal_debug_enable() - * Enable NSS debug - */ -static void __nss_hal_debug_enable(void) -{ - return; -} - -/* - * __nss_hal_common_reset() - */ -static int __nss_hal_common_reset(struct platform_device *nss_dev) -{ - return 0; -} - -/* - * __nss_hal_core_reset() - */ -static int __nss_hal_core_reset(struct platform_device *nss_dev, void __iomem *map, uint32_t addr, uint32_t clk_src) -{ - return 0; -} - -/* - * __nss_hal_firmware_load() - */ -static int __nss_hal_firmware_load(struct nss_ctx_instance *nss_ctx, struct platform_device *nss_dev, struct nss_platform_data *npd) -{ - return 0; -} - -/* - * __nss_hal_clock_configure() - */ -static int __nss_hal_clock_configure(struct nss_ctx_instance *nss_ctx, struct platform_device *nss_dev, struct nss_platform_data *npd) -{ - return 0; -} - -/* - * __nss_hal_read_interrupt_cause() - */ -static void __nss_hal_read_interrupt_cause(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t *cause) -{ - uint32_t value = nss_read_32(nss_ctx->nmap, NSS_REGS_N2H_INTR_STATUS_OFFSET); - *cause = (((value) >> shift_factor) & 0x7FFF); -} - -/* - * __nss_hal_clear_interrupt_cause() - */ -static void __nss_hal_clear_interrupt_cause(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ - nss_write_32(nss_ctx->nmap, NSS_REGS_N2H_INTR_CLR_OFFSET, (cause << shift_factor)); -} - -/* - * __nss_hal_disable_interrupt() - */ -static void __nss_hal_disable_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ - nss_write_32(nss_ctx->nmap, NSS_REGS_N2H_INTR_MASK_CLR_OFFSET, (cause << shift_factor)); -} - -/* - * __nss_hal_enable_interrupt() - */ -static void __nss_hal_enable_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ - nss_write_32(nss_ctx->nmap, NSS_REGS_N2H_INTR_MASK_SET_OFFSET, (cause << shift_factor)); -} - -/* - * __nss_hal_send_interrupt() - */ -static void __nss_hal_send_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t type) -{ - nss_write_32(nss_ctx->nmap, NSS_REGS_C2C_INTR_SET_OFFSET, intr_cause[type]); -} - -/* - * __nss_hal_request_irq() - */ -static int __nss_hal_request_irq(struct nss_ctx_instance *nss_ctx, struct nss_platform_data *npd, int irq_num) -{ - struct int_ctx_instance *int_ctx = &nss_ctx->int_ctx[irq_num]; - int err; - - if (irq_num == 1) { - int_ctx->shift_factor = 15; - err = request_irq(npd->irq[irq_num], nss_hal_handle_irq, 0, "nss_queue1", int_ctx); - } else { - int_ctx->shift_factor = 0; - err = request_irq(npd->irq[irq_num], nss_hal_handle_irq, 0, "nss", int_ctx); - } - if (err) { - nss_warning("%px: IRQ%d request failed", nss_ctx, npd->irq[irq_num]); - return err; - } - - int_ctx->irq = npd->irq[irq_num]; - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi, 64); - return 0; -} - -/* - * __nss_hal_init_imem - */ -void __nss_hal_init_imem(struct nss_ctx_instance *nss_ctx) -{ - struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; - - mem_ctx->imem_head = NSS_IMEM_START + NSS_IMEM_SIZE * nss_ctx->id; - mem_ctx->imem_end = mem_ctx->imem_head + NSS_IMEM_SIZE; - mem_ctx->imem_tail = mem_ctx->imem_head; - - 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); -} - -/* - * __nss_hal_init_utcm_shared - */ -bool __nss_hal_init_utcm_shared(struct nss_ctx_instance *nss_ctx, uint32_t *meminfo_start) -{ - /* - * Nothing to be done as there are no UTCM_SHARED defined for fsm9010 - */ - return true; -} - -/* - * nss_hal_fsm9010_ops - */ -struct nss_hal_ops nss_hal_fsm9010_ops = { - .common_reset = __nss_hal_common_reset, - .core_reset = __nss_hal_core_reset, - .clock_configure = __nss_hal_clock_configure, - .firmware_load = __nss_hal_firmware_load, - .debug_enable = __nss_hal_debug_enable, - .of_get_pdata = __nss_hal_of_get_pdata, - .request_irq = __nss_hal_request_irq, - .send_interrupt = __nss_hal_send_interrupt, - .enable_interrupt = __nss_hal_enable_interrupt, - .disable_interrupt = __nss_hal_disable_interrupt, - .clear_interrupt_cause = __nss_hal_clear_interrupt_cause, - .read_interrupt_cause = __nss_hal_read_interrupt_cause, - .init_imem = __nss_hal_init_imem, - .init_utcm_shared = __nss_hal_init_utcm_shared, -}; diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_hal/include/nss_hal.h b/feeds/ipq807x/qca-nss-drv/src/nss_hal/include/nss_hal.h deleted file mode 100644 index d9591a781..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_hal/include/nss_hal.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2013, 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. - ************************************************************************** - */ - -/** - * nss_hal.h - * NSS HAL public declarations. - */ - -#ifndef __NSS_HAL_H -#define __NSS_HAL_H - -#include -#include -#include -#include - -extern struct clk *nss_core0_clk; -extern struct clk *nss_core1_clk; -extern struct nss_runtime_sampling nss_runtime_samples; -extern struct clk *nss_fab0_clk; -extern struct clk *nss_fab1_clk; -extern void nss_hal_wq_function(struct work_struct *work); - -#if defined(NSS_HAL_IPQ806X_SUPPORT) -extern struct nss_hal_ops nss_hal_ipq806x_ops; -#endif -#if defined(NSS_HAL_IPQ807x_SUPPORT) -extern struct nss_hal_ops nss_hal_ipq807x_ops; -#endif -#if defined(NSS_HAL_IPQ60XX_SUPPORT) -extern struct nss_hal_ops nss_hal_ipq60xx_ops; -#endif -#if defined(NSS_HAL_IPQ50XX_SUPPORT) -extern struct nss_hal_ops nss_hal_ipq50xx_ops; -#endif -#if defined(NSS_HAL_FSM9010_SUPPORT) -extern struct nss_hal_ops nss_hal_fsm9010_ops; -#endif - -#define NSS_HAL_SUPPORTED_INTERRUPTS (NSS_N2H_INTR_EMPTY_BUFFER_QUEUE | \ - NSS_N2H_INTR_DATA_QUEUE_0 | \ - NSS_N2H_INTR_DATA_QUEUE_1 | \ - NSS_N2H_INTR_EMPTY_BUFFERS_SOS | \ - NSS_N2H_INTR_TX_UNBLOCKED | \ - NSS_N2H_INTR_COREDUMP_COMPLETE | \ - NSS_N2H_INTR_PROFILE_DMA | \ - NSS_N2H_INTR_PAGED_EMPTY_BUFFERS_SOS) - -/* - * nss_hal_read_interrupt_cause() - */ -static inline void nss_hal_read_interrupt_cause(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t *cause) -{ - nss_top_main.hal_ops->read_interrupt_cause(nss_ctx, shift_factor, cause); -} - -/* - * nss_hal_clear_interrupt_cause() - */ -static inline void nss_hal_clear_interrupt_cause(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ - nss_top_main.hal_ops->clear_interrupt_cause(nss_ctx, shift_factor, cause); -} - -/* - * nss_hal_disable_interrupt() - */ -static inline void nss_hal_disable_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ - nss_top_main.hal_ops->disable_interrupt(nss_ctx, shift_factor, cause); -} - -/* - * nss_hal_enable_interrupt() - */ -static inline void nss_hal_enable_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ - nss_top_main.hal_ops->enable_interrupt(nss_ctx, shift_factor, cause); -} - -/* - * nss_hal_send_interrupt() - */ -static inline void nss_hal_send_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t cause) -{ - nss_top_main.hal_ops->send_interrupt(nss_ctx, cause); -} - -/* - * nss_hal_debug_enable() - */ -static inline void nss_hal_debug_enable(void) -{ - nss_top_main.hal_ops->debug_enable(); -} - -/* - * nss_hal_probe() - */ -int nss_hal_probe(struct platform_device *nss_dev); - -/* - * nss_hal_remove() - */ -int nss_hal_remove(struct platform_device *nss_dev); - -/* - * nss_hal_firmware_load() - */ -int nss_hal_firmware_load(struct nss_ctx_instance *nss_ctx, struct platform_device *nss_dev, struct nss_platform_data *npd); - -/* - * nss_hal_dt_parse_features() - */ -void nss_hal_dt_parse_features(struct device_node *np, struct nss_platform_data *npd); -#endif /* __NSS_HAL_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_hal/include/nss_hal_ops.h b/feeds/ipq807x/qca-nss-drv/src/nss_hal/include/nss_hal_ops.h deleted file mode 100644 index 736d37e6c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_hal/include/nss_hal_ops.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_hal_ops.h - * NSS HAL ops structure declaration. - */ - -#ifndef __NSS_HAL_OPS_H -#define __NSS_HAL_OPS_H - -#if (NSS_DT_SUPPORT != 1) -#include -#include -#endif - -/* - * nss_hal_ops defines the HAL layer API required to support multiple targets - */ -struct nss_hal_ops { - int (*common_reset)(struct platform_device *pdev); - int (*core_reset)(struct platform_device *nss_dev, void __iomem *map, uint32_t addr, uint32_t clk_src); - int (*clock_configure)(struct nss_ctx_instance *nss_ctx, struct platform_device *nss_dev, struct nss_platform_data *npd); - void (*debug_enable)(void); - struct nss_platform_data * (*of_get_pdata)(struct platform_device *pdev); - int (*firmware_load)(struct nss_ctx_instance *nss_ctx, struct platform_device *nss_dev, struct nss_platform_data *npd); - void (*read_interrupt_cause)(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t *cause); - int (*request_irq)(struct nss_ctx_instance *nss_ctx, struct nss_platform_data *npd, int irq_num); - void (*clear_interrupt_cause)(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause); - void (*send_interrupt)(struct nss_ctx_instance *nss_ctx, uint32_t type); - void (*enable_interrupt)(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause); - void (*disable_interrupt)(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause); - void (*init_imem)(struct nss_ctx_instance *nss_ctx); - bool (*init_utcm_shared)(struct nss_ctx_instance *nss_ctx, uint32_t *meminfo_start); -}; -#endif /* __NSS_HAL_OPS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_hal/include/nss_regs.h b/feeds/ipq807x/qca-nss-drv/src/nss_hal/include/nss_regs.h deleted file mode 100644 index 765e8a197..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_hal/include/nss_regs.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2013, 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. - * 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_regs.h - * NSS register definitions. - */ - -#ifndef __NSS_REGS_H -#define __NSS_REGS_H - -#include -#include - -/* - * CSM register offsets - */ -#define NSS_REGS_CORE_ID_OFFSET 0x0000 -#define NSS_REGS_RESET_CTRL_OFFSET 0x0004 -#define NSS_REGS_CORE_BAR_OFFSET 0x0008 -#define NSS_REGS_CORE_AMC_OFFSET 0x000c -#define NSS_REGS_CORE_BOOT_ADDR_OFFSET 0x0010 -#define NSS_REGS_C2C_INTR_STATUS_OFFSET 0x0014 -#define NSS_REGS_C2C_INTR_SET_OFFSET 0x0018 -#define NSS_REGS_C2C_INTR_CLR_OFFSET 0x001c -#define NSS_REGS_N2H_INTR_STATUS_OFFSET 0x0020 -#define NSS_REGS_N2H_INTR_SET_OFFSET 0x0024 -#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 -#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 - */ -#define NSS_REGS_FPB_CSR_CFG_OFFSET 0x0004 - -/* - * Defines for N2H interrupts - */ -#define NSS_N2H_INTR_EMPTY_BUFFER_QUEUE (1 << 0) -#define NSS_N2H_INTR_DATA_QUEUE_0 (1 << 1) -#define NSS_N2H_INTR_DATA_QUEUE_1 (1 << 2) -#define NSS_N2H_INTR_DATA_QUEUE_2 (1 << 3) -#define NSS_N2H_INTR_DATA_QUEUE_3 (1 << 4) -#define NSS_N2H_INTR_EMPTY_BUFFERS_SOS (1 << 10) -#define NSS_N2H_INTR_TX_UNBLOCKED (1 << 11) -#define NSS_N2H_INTR_PAGED_EMPTY_BUFFERS_SOS (1 << 12) -#define NSS_N2H_INTR_PROFILE_DMA (1 << 13) -#define NSS_N2H_INTR_COREDUMP_COMPLETE (1 << 14) - -/* - * Types of H2N interrupts - */ -enum nss_h2n_intr_type { - NSS_H2N_INTR_EMPTY_BUFFER_QUEUE = 0, - NSS_H2N_INTR_DATA_COMMAND_QUEUE = 1, - NSS_H2N_INTR_TX_UNBLOCKED = 2, - NSS_H2N_INTR_TRIGGER_COREDUMP = 3, - NSS_H2N_INTR_EMPTY_PAGED_BUFFER_QUEUE = 4, - NSS_H2N_INTR_TYPE_MAX = 5, -}; - -/* - * clock source for NSS cores - */ -enum nss_regs_clk_src_select { - NSS_REGS_CLK_SRC_DEFAULT, - NSS_REGS_CLK_SRC_ALTERNATE -}; - -/* - * nss_read_32() - * Read NSS register - */ -static inline uint32_t nss_read_32(void __iomem *addr, uint32_t offs) -{ - return readl(addr + offs); -} - -/* - * nss_write_32() - * Write NSS register - */ -static inline void nss_write_32(void __iomem *addr, uint32_t offs, uint32_t val) -{ - writel(val, addr + offs); -} - -#endif /* __NSS_REGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq50xx/nss_hal_pvt.c b/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq50xx/nss_hal_pvt.c deleted file mode 100644 index 3d6dfd02d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq50xx/nss_hal_pvt.c +++ /dev/null @@ -1,667 +0,0 @@ -/* - * 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 - * 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_hal_pvt.c - * NSS HAL private APIs. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "nss_hal.h" -#include "nss_core.h" - -#define NSS_QGIC_IPC_REG_OFFSET 0x8 - -#define NSS0_H2N_INTR_BASE 13 - -/* - * N2H interrupts - */ -#define NSS_IRQ_NAME_EMPTY_BUF_SOS "nss_empty_buf_sos" -#define NSS_IRQ_NAME_EMPTY_BUF_QUEUE "nss_empty_buf_queue" -#define NSS_IRQ_NAME_TX_UNBLOCK "nss-tx-unblock" -#define NSS_IRQ_NAME_QUEUE0 "nss_queue0" -#define NSS_IRQ_NAME_QUEUE1 "nss_queue1" -#define NSS_IRQ_NAME_COREDUMP_COMPLETE "nss_coredump_complete" -#define NSS_IRQ_NAME_PAGED_EMPTY_BUF_SOS "nss_paged_empty_buf_sos" -#define NSS_IRQ_NAME_PROFILE_DMA "nss_profile_dma" - -/* - * CLKs - */ -#define NSS_CFG_CLK "nss-cfg-clk" -#define NSS_DBG_CLK "nss-dbg-clk" -#define NSS_CORE_CLK "nss-core-clk" -#define NSS_AXI_CLK "nss-axi-clk" -#define NSS_SNOC_AXI_CLK "nss-snoc-axi-clk" -#define NSS_NC_AXI_CLK "nss-nc-axi-clk" -#define NSS_UTCM_CLK "nss-utcm-clk" - -/* - * Core GCC reset - */ -#define NSS_CORE_GCC_RESET 0x00000007 - -/* - * GCC reset - */ -void __iomem *nss_misc_reset; -void __iomem *nss_misc_reset_flag; - -/* - * Purpose of each interrupt index: This should match the order defined in the NSS firmware - */ -enum nss_hal_n2h_intr_purpose { - NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_SOS = 0, - NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_QUEUE = 1, - NSS_HAL_N2H_INTR_PURPOSE_TX_UNBLOCKED = 2, - NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_0 = 3, - NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_1 = 4, - NSS_HAL_N2H_INTR_PURPOSE_COREDUMP_COMPLETE = 5, - NSS_HAL_N2H_INTR_PURPOSE_PAGED_EMPTY_BUFFER_SOS = 6, - NSS_HAL_N2H_INTR_PURPOSE_PROFILE_DMA = 7, - NSS_HAL_N2H_INTR_PURPOSE_MAX -}; - -/* - * Interrupt type to cause vector. - */ -static uint32_t intr_cause[NSS_MAX_CORES][NSS_H2N_INTR_TYPE_MAX] = { - /* core0 */ - {(1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_EMPTY_BUFFER_QUEUE)), - (1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_DATA_COMMAND_QUEUE)), - (1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_TX_UNBLOCKED)), - (1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_TRIGGER_COREDUMP)), - (1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_EMPTY_PAGED_BUFFER_QUEUE))} -}; - -/* - * nss_hal_wq_function() - * Added to Handle BH requests to kernel - */ -void nss_hal_wq_function(struct work_struct *work) -{ - nss_work_t *my_work = (nss_work_t *)work; - - mutex_lock(&nss_top_main.wq_lock); - - nss_freq_change(&nss_top_main.nss[NSS_CORE_0], my_work->frequency, my_work->stats_enable, 0); - clk_set_rate(nss_core0_clk, my_work->frequency); - - nss_freq_change(&nss_top_main.nss[NSS_CORE_0], my_work->frequency, my_work->stats_enable, 1); - - mutex_unlock(&nss_top_main.wq_lock); - kfree((void *)work); -} - -/* - * nss_hal_handle_irq() - */ -static irqreturn_t nss_hal_handle_irq(int irq, void *ctx) -{ - struct int_ctx_instance *int_ctx = (struct int_ctx_instance *) ctx; - - disable_irq_nosync(irq); - napi_schedule(&int_ctx->napi); - - return IRQ_HANDLED; -} - -/* - * __nss_hal_of_get_pdata() - * Retrieve platform data from device node. - */ -static struct nss_platform_data *__nss_hal_of_get_pdata(struct platform_device *pdev) -{ - struct device_node *np = of_node_get(pdev->dev.of_node); - struct nss_platform_data *npd; - struct nss_ctx_instance *nss_ctx = NULL; - struct nss_top_instance *nss_top = &nss_top_main; - struct resource res_nphys, res_qgic_phys; - int32_t i; - - npd = devm_kzalloc(&pdev->dev, sizeof(struct nss_platform_data), GFP_KERNEL); - if (!npd) { - return NULL; - } - - if (of_property_read_u32(np, "qcom,id", &npd->id) - || of_property_read_u32(np, "qcom,load-addr", &npd->load_addr) - || of_property_read_u32(np, "qcom,num-queue", &npd->num_queue) - || of_property_read_u32(np, "qcom,num-irq", &npd->num_irq)) { - pr_err("%s: error reading critical device node properties\n", np->name); - goto out; - } - - /* - * Read frequencies. If failure, load default values. - */ - of_property_read_u32(np, "qcom,mid-frequency", &nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency); - of_property_read_u32(np, "qcom,max-frequency", &nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency); - - if (npd->num_irq > NSS_MAX_IRQ_PER_CORE) { - pr_err("%s: exceeds maximum interrupt numbers per core\n", np->name); - goto out; - } - - nss_ctx = &nss_top->nss[npd->id]; - nss_ctx->id = npd->id; - - if (of_address_to_resource(np, 0, &res_nphys) != 0) { - 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("%px: nss%d: of_address_to_resource() fail for qgic_phys\n", nss_ctx, nss_ctx->id); - goto out; - } - - /* - * Save physical addresses - */ - npd->nphys = res_nphys.start; - npd->qgic_phys = res_qgic_phys.start; - - npd->nmap = ioremap_nocache(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)); - if (!npd->qgic_map) { - nss_info_always("%px: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id); - goto out; - } - - NSS_CORE_DSB(); - - /* - * Get IRQ numbers - */ - 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("%px: nss%d: irq_of_parse_and_map() fail for irq %d\n", nss_ctx, nss_ctx->id, i); - goto out; - } - } - - nss_hal_dt_parse_features(np, npd); - - of_node_put(np); - return npd; - -out: - if (npd->nmap) { - iounmap(npd->nmap); - } - - if (npd->vmap) { - iounmap(npd->vmap); - } - - devm_kfree(&pdev->dev, npd); - of_node_put(np); - return NULL; -} - -/* - * nss_hal_clock_set_and_enable() - */ -static int nss_hal_clock_set_and_enable(struct device *dev, const char *id, unsigned long rate) -{ - struct clk *nss_clk = NULL; - int err; - - nss_clk = devm_clk_get(dev, id); - if (IS_ERR(nss_clk)) { - 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("%px: cannot set %s freq\n", dev, id); - return -EFAULT; - } - } - - err = clk_prepare_enable(nss_clk); - if (err) { - pr_err("%px: cannot enable clock: %s\n", dev, id); - return -EFAULT; - } - - return 0; -} - -/* - * __nss_hal_core_reset() - */ -static int __nss_hal_core_reset(struct platform_device *nss_dev, void __iomem *map, uint32_t addr, uint32_t clk_src) -{ - uint32_t value; - - /* - * Apply ubi32 core reset - */ - nss_write_32(map, NSS_REGS_RESET_CTRL_OFFSET, 0x1); - - /* - * De-assert reset - */ - value = nss_read_32(nss_misc_reset, 0x0); - value &= ~NSS_CORE_GCC_RESET; - nss_write_32(nss_misc_reset, 0x0, value); - - /* - * Program address configuration - */ - nss_write_32(map, NSS_REGS_CORE_AMC_OFFSET, 0x1); - nss_write_32(map, NSS_REGS_CORE_BAR_OFFSET, 0x3C000000); - nss_write_32(map, NSS_REGS_CORE_BOOT_ADDR_OFFSET, addr); - - /* - * Set crypto interrupt as level sensitive - */ - nss_write_32(map, NSS_REGS_CORE_INT_STAT2_TYPE_OFFSET, 0x80000000); - nss_write_32(map, NSS_REGS_CORE_INT_STAT3_TYPE_OFFSET, 0x00200000); - - /* - * Enable Instruction Fetch range checking between 0x4000 0000 to 0xBFFF FFFF. - */ - nss_write_32(map, NSS_REGS_CORE_IFETCH_RANGE_OFFSET, 0xBF004001); - - /* - * De-assert ubi32 core reset - */ - nss_write_32(map, NSS_REGS_RESET_CTRL_OFFSET, 0x0); - - /* - * Set values only once for core0. Grab the proper clock. - */ - nss_core0_clk = clk_get(&nss_dev->dev, NSS_CORE_CLK); - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency)) { - return -EFAULT; - } - - return 0; -} - -/* - * __nss_hal_debug_enable() - * Enable NSS debug - */ -static void __nss_hal_debug_enable(void) -{ - -} - -/* - * __nss_hal_common_reset - * Do reset/clock configuration common to all cores - */ -static int __nss_hal_common_reset(struct platform_device *nss_dev) -{ - struct device_node *cmn = NULL; - struct resource res_nss_misc_reset; - - /* - * Get reference to NSS common device node - */ - cmn = of_find_node_by_name(NULL, "nss-common"); - if (!cmn) { - 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("%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)); - if (!nss_misc_reset) { - pr_err("%px: ioremap fail for nss_misc_reset\n", nss_dev); - return -EFAULT; - } - - nss_top_main.nss_hal_common_init_done = true; - nss_info("nss_hal_common_reset Done\n"); - - return 0; -} - -/* - * __nss_hal_clock_configure() - */ -static int __nss_hal_clock_configure(struct nss_ctx_instance *nss_ctx, struct platform_device *nss_dev, struct nss_platform_data *npd) -{ - int32_t i; - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_DBG_CLK, 150000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CFG_CLK, 100000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_AXI_CLK, 400000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_SNOC_AXI_CLK, 400000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NC_AXI_CLK, 266670000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_UTCM_CLK, 266670000)) { - return -EFAULT; - } - - /* - * No entries, then just load default - */ - if ((nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency == 0) || - (nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency == 0)) { - nss_runtime_samples.freq_scale[NSS_FREQ_LOW_SCALE].frequency = NSS_FREQ_SCALE_NA; - nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency = NSS_FREQ_850; - nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency = NSS_FREQ_1000; - nss_info_always("%px: Running default frequencies\n", nss_ctx); - } - - /* - * Maple low frequency not applicable, set it accordingly - */ - nss_runtime_samples.freq_scale[NSS_FREQ_LOW_SCALE].frequency = NSS_FREQ_SCALE_NA; - - /* - * Test frequency from dtsi, if fail, try to set default frequency. - */ - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency)) { - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, NSS_FREQ_1000)) { - return -EFAULT; - } - } - - /* - * Setup ranges, test frequency, and display. - */ - for (i = 0; i < NSS_FREQ_MAX_SCALE; i++) { - switch (nss_runtime_samples.freq_scale[i].frequency) { - case NSS_FREQ_850: - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_850_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_850_MAX; - break; - - case NSS_FREQ_1000: - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_1000_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_1000_MAX; - break; - - case NSS_FREQ_SCALE_NA: - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_NA; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_NA; - continue; - - default: - nss_info_always("%px: Frequency not found %d\n", nss_ctx, nss_runtime_samples.freq_scale[i].frequency); - return -EFAULT; - } - - /* - * Test the frequency, if fail, then default to safe frequency and abort - */ - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, nss_runtime_samples.freq_scale[i].frequency)) { - return -EFAULT; - } - } - - nss_info_always("Supported Frequencies - "); - for (i = 0; i < NSS_FREQ_MAX_SCALE; i++) { - switch (nss_runtime_samples.freq_scale[i].frequency) { - case NSS_FREQ_850: - nss_info_always("850 MHz "); - break; - - case NSS_FREQ_1000: - nss_info_always("1 GHz "); - break; - - case NSS_FREQ_SCALE_NA: - continue; - - default: - nss_info_always("%px: Error\nNo Table/Invalid Frequency Found\n", nss_ctx); - return -EFAULT; - } - } - nss_info_always("\n"); - - /* - * Set values only once for core0. Grab the proper clock. - */ - nss_core0_clk = clk_get(&nss_dev->dev, NSS_CORE_CLK); - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency)) { - return -EFAULT; - } - return 0; -} - -/* - * __nss_hal_read_interrupt_cause() - */ -static void __nss_hal_read_interrupt_cause(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t *cause) -{ -} - -/* - * __nss_hal_clear_interrupt_cause() - */ -static void __nss_hal_clear_interrupt_cause(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ -} - -/* - * __nss_hal_disable_interrupt() - */ -static void __nss_hal_disable_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ -} - -/* - * __nss_hal_enable_interrupt() - */ -static void __nss_hal_enable_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ -} - -/* - * __nss_hal_send_interrupt() - */ -static void __nss_hal_send_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t type) -{ - /* - * Check if core and type is Valid - */ - nss_assert(nss_ctx->id < nss_top_main.num_nss); - nss_assert(type < NSS_H2N_INTR_TYPE_MAX); - - nss_write_32(nss_ctx->qgic_map, NSS_QGIC_IPC_REG_OFFSET, intr_cause[nss_ctx->id][type]); -} - -/* - * __nss_hal_request_irq() - */ -static int __nss_hal_request_irq(struct nss_ctx_instance *nss_ctx, struct nss_platform_data *npd, int irq_num) -{ - struct int_ctx_instance *int_ctx = &nss_ctx->int_ctx[irq_num]; - uint32_t cause, napi_wgt; - int err = -1, irq = npd->irq[irq_num]; - int (*napi_poll_cb)(struct napi_struct *, int) = NULL; - const char *irq_name; - - irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY); - - switch (irq_num) { - case NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_SOS: - napi_poll_cb = nss_core_handle_napi_non_queue; - napi_wgt = NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT; - cause = NSS_N2H_INTR_EMPTY_BUFFERS_SOS; - irq_name = NSS_IRQ_NAME_EMPTY_BUF_SOS; - break; - - case NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_QUEUE: - napi_poll_cb = nss_core_handle_napi_queue; - napi_wgt = NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT; - cause = NSS_N2H_INTR_EMPTY_BUFFER_QUEUE; - irq_name = NSS_IRQ_NAME_EMPTY_BUF_QUEUE; - break; - - case NSS_HAL_N2H_INTR_PURPOSE_TX_UNBLOCKED: - napi_poll_cb = nss_core_handle_napi_non_queue; - napi_wgt = NSS_TX_UNBLOCKED_PROCESSING_WEIGHT; - cause = NSS_N2H_INTR_TX_UNBLOCKED; - irq_name = NSS_IRQ_NAME_TX_UNBLOCK; - break; - - case NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_0: - napi_poll_cb = nss_core_handle_napi_queue; - napi_wgt = NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT; - cause = NSS_N2H_INTR_DATA_QUEUE_0; - irq_name = NSS_IRQ_NAME_QUEUE0; - break; - - case NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_1: - napi_poll_cb = nss_core_handle_napi_queue; - napi_wgt = NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT; - cause = NSS_N2H_INTR_DATA_QUEUE_1; - irq_name = NSS_IRQ_NAME_QUEUE1; - break; - - case NSS_HAL_N2H_INTR_PURPOSE_COREDUMP_COMPLETE: - napi_poll_cb = nss_core_handle_napi_emergency; - napi_wgt = NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT; - cause = NSS_N2H_INTR_COREDUMP_COMPLETE; - irq_name = NSS_IRQ_NAME_COREDUMP_COMPLETE; - break; - - case NSS_HAL_N2H_INTR_PURPOSE_PAGED_EMPTY_BUFFER_SOS: - napi_poll_cb = nss_core_handle_napi_non_queue; - napi_wgt = NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT; - cause = NSS_N2H_INTR_PAGED_EMPTY_BUFFERS_SOS; - irq_name = NSS_IRQ_NAME_PAGED_EMPTY_BUF_SOS; - break; - - case NSS_HAL_N2H_INTR_PURPOSE_PROFILE_DMA: - napi_poll_cb = nss_core_handle_napi_sdma; - napi_wgt = NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT; - cause = NSS_N2H_INTR_PROFILE_DMA; - irq_name = NSS_IRQ_NAME_PROFILE_DMA; - break; - - default: - nss_warning("%px: nss%d: unsupported irq# %d\n", nss_ctx, nss_ctx->id, irq_num); - return err; - } - - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, napi_poll_cb, napi_wgt); - int_ctx->cause = cause; - err = request_irq(irq, nss_hal_handle_irq, 0, irq_name, int_ctx); - if (err) { - nss_warning("%px: nss%d: request_irq failed for irq# %d\n", nss_ctx, nss_ctx->id, irq_num); - return err; - } - int_ctx->irq = irq; - return 0; -} - -/* - * __nss_hal_init_imem - */ -void __nss_hal_init_imem(struct nss_ctx_instance *nss_ctx) -{ - /* - * Nothing to be done as there are no TCM in ipq50xx - */ -} - -/* - * __nss_hal_init_utcm_shared - */ -bool __nss_hal_init_utcm_shared(struct nss_ctx_instance *nss_ctx, uint32_t *meminfo_start) -{ - struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; - uint32_t utcm_shared_map_magic = meminfo_start[2]; - uint32_t utcm_shared_start = meminfo_start[3]; - uint32_t utcm_shared_size = meminfo_start[4]; - - /* - * Check meminfo utcm_shared map magic - */ - if ((uint16_t)utcm_shared_map_magic != NSS_MEMINFO_RESERVE_AREA_UTCM_SHARED_MAP_MAGIC) { - nss_info_always("%px: failed to verify UTCM_SHARED map magic\n", nss_ctx); - return false; - } - - mem_ctx->utcm_shared_head = utcm_shared_start; - 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("%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; -} - -/* - * nss_hal_ipq50xx_ops - */ -struct nss_hal_ops nss_hal_ipq50xx_ops = { - .common_reset = __nss_hal_common_reset, - .core_reset = __nss_hal_core_reset, - .clock_configure = __nss_hal_clock_configure, - .firmware_load = nss_hal_firmware_load, - .debug_enable = __nss_hal_debug_enable, - .of_get_pdata = __nss_hal_of_get_pdata, - .request_irq = __nss_hal_request_irq, - .send_interrupt = __nss_hal_send_interrupt, - .enable_interrupt = __nss_hal_enable_interrupt, - .disable_interrupt = __nss_hal_disable_interrupt, - .clear_interrupt_cause = __nss_hal_clear_interrupt_cause, - .read_interrupt_cause = __nss_hal_read_interrupt_cause, - .init_imem = __nss_hal_init_imem, - .init_utcm_shared = __nss_hal_init_utcm_shared, -}; diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq60xx/nss_hal_pvt.c b/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq60xx/nss_hal_pvt.c deleted file mode 100644 index 4c84cb958..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq60xx/nss_hal_pvt.c +++ /dev/null @@ -1,739 +0,0 @@ -/* - * 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. - */ - -/** - * nss_hal_pvt.c - * NSS HAL private APIs. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "nss_hal.h" -#include "nss_core.h" - -#define NSS_QGIC_IPC_REG_OFFSET 0x8 - -#define NSS0_H2N_INTR_BASE 13 - -/* - * Common CLKs - */ -#define NSS_NOC_CLK "nss-noc-clk" -#define NSS_PTP_REF_CLK "nss-ptp-ref-clk" -#define NSS_CSR_CLK "nss-csr-clk" -#define NSS_CFG_CLK "nss-cfg-clk" -#define NSS_NSSNOC_QOSGEN_REF_CLK "nss-nssnoc-qosgen-ref-clk" -#define NSS_NSSNOC_SNOC_CLK "nss-nssnoc-snoc-clk" -#define NSS_NSSNOC_TIMEOUT_REF_CLK "nss-nssnoc-timeout-ref-clk" -#define NSS_CE_AXI_CLK "nss-ce-axi-clk" -#define NSS_CE_APB_CLK "nss-ce-apb-clk" -#define NSS_NSSNOC_CE_AXI_CLK "nss-nssnoc-ce-axi-clk" -#define NSS_NSSNOC_CE_APB_CLK "nss-nssnoc-ce-apb-clk" -#define NSS_MEM_NOC_UBI32_CLK "nss-mem-noc-ubi32-clk" -#define NSS_SNOC_NSSNOC_CLK "nss-snoc-nssnoc-clk" - -/* - * Per-core CLKS - */ -#define NSS_NSSNOC_AHB_CLK "nss-nssnoc-ahb-clk" -#define NSS_CORE_CLK "nss-core-clk" -#define NSS_AHB_CLK "nss-ahb-clk" -#define NSS_AXI_CLK "nss-axi-clk" -#define NSS_NC_AXI_CLK "nss-nc-axi-clk" -#define NSS_UTCM_CLK "nss-utcm-clk" - -/* - * Voltage values - */ -#define NOMINAL_VOLTAGE 1 -#define TURBO_VOLTAGE 2 - -/* - * Core reset part 1 - */ -#define NSS_CORE_GCC_RESET_1 0x00000020 - -/* - * Core reset part 2 - */ -#define NSS_CORE_GCC_RESET_2 0x00000017 - -/* - * Voltage regulator - */ -struct regulator *npu_reg; - -/* - * GCC reset - */ -void __iomem *nss_misc_reset; -void __iomem *nss_misc_reset_flag; - -/* - * Purpose of each interrupt index: This should match the order defined in the NSS firmware - */ -enum nss_hal_n2h_intr_purpose { - NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_SOS = 0, - NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_QUEUE = 1, - NSS_HAL_N2H_INTR_PURPOSE_TX_UNBLOCKED = 2, - NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_0 = 3, - NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_1 = 4, - NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_2 = 5, - NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_3 = 6, - NSS_HAL_N2H_INTR_PURPOSE_COREDUMP_COMPLETE = 7, - NSS_HAL_N2H_INTR_PURPOSE_PAGED_EMPTY_BUFFER_SOS = 8, - NSS_HAL_N2H_INTR_PURPOSE_PROFILE_DMA = 9, - NSS_HAL_N2H_INTR_PURPOSE_MAX -}; - -/* - * Interrupt type to cause vector. - */ -static uint32_t intr_cause[NSS_MAX_CORES][NSS_H2N_INTR_TYPE_MAX] = { - /* core0 */ - {(1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_EMPTY_BUFFER_QUEUE)), - (1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_DATA_COMMAND_QUEUE)), - (1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_TX_UNBLOCKED)), - (1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_TRIGGER_COREDUMP)), - (1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_EMPTY_PAGED_BUFFER_QUEUE))} -}; - -/* - * nss_hal_wq_function() - * Added to Handle BH requests to kernel - */ -void nss_hal_wq_function(struct work_struct *work) -{ - nss_work_t *my_work = (nss_work_t *)work; - - mutex_lock(&nss_top_main.wq_lock); - - nss_freq_change(&nss_top_main.nss[NSS_CORE_0], my_work->frequency, my_work->stats_enable, 0); - clk_set_rate(nss_core0_clk, my_work->frequency); - - nss_freq_change(&nss_top_main.nss[NSS_CORE_0], my_work->frequency, my_work->stats_enable, 1); - - mutex_unlock(&nss_top_main.wq_lock); - kfree((void *)work); -} - -/* - * nss_hal_handle_irq() - */ -static irqreturn_t nss_hal_handle_irq(int irq, void *ctx) -{ - struct int_ctx_instance *int_ctx = (struct int_ctx_instance *) ctx; - - disable_irq_nosync(irq); - napi_schedule(&int_ctx->napi); - - return IRQ_HANDLED; -} - -/* - * __nss_hal_of_get_pdata() - * Retrieve platform data from device node. - */ -static struct nss_platform_data *__nss_hal_of_get_pdata(struct platform_device *pdev) -{ - struct device_node *np = of_node_get(pdev->dev.of_node); - struct nss_platform_data *npd; - struct nss_ctx_instance *nss_ctx = NULL; - struct nss_top_instance *nss_top = &nss_top_main; - struct resource res_nphys, res_qgic_phys; - int32_t i; - - npd = devm_kzalloc(&pdev->dev, sizeof(struct nss_platform_data), GFP_KERNEL); - if (!npd) { - return NULL; - } - - if (of_property_read_u32(np, "qcom,id", &npd->id) - || of_property_read_u32(np, "qcom,load-addr", &npd->load_addr) - || of_property_read_u32(np, "qcom,num-queue", &npd->num_queue) - || of_property_read_u32(np, "qcom,num-irq", &npd->num_irq)) { - pr_err("%s: error reading critical device node properties\n", np->name); - goto out; - } - - /* - * Read frequencies. If failure, load default values. - */ - of_property_read_u32(np, "qcom,low-frequency", &nss_runtime_samples.freq_scale[NSS_FREQ_LOW_SCALE].frequency); - of_property_read_u32(np, "qcom,mid-frequency", &nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency); - of_property_read_u32(np, "qcom,max-frequency", &nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency); - - if (npd->num_irq > NSS_MAX_IRQ_PER_CORE) { - pr_err("%s: exceeds maximum interrupt numbers per core\n", np->name); - goto out; - } - - nss_ctx = &nss_top->nss[npd->id]; - nss_ctx->id = npd->id; - - if (of_address_to_resource(np, 0, &res_nphys) != 0) { - 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("%px: nss%d: of_address_to_resource() fail for qgic_phys\n", nss_ctx, nss_ctx->id); - goto out; - } - - /* - * Save physical addresses - */ - npd->nphys = res_nphys.start; - npd->qgic_phys = res_qgic_phys.start; - - npd->nmap = ioremap_nocache(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)); - if (!npd->qgic_map) { - nss_info_always("%px: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id); - goto out; - } - - NSS_CORE_DSB(); - - /* - * Get IRQ numbers - */ - 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("%px: nss%d: irq_of_parse_and_map() fail for irq %d\n", nss_ctx, nss_ctx->id, i); - goto out; - } - } - - nss_hal_dt_parse_features(np, npd); - - of_node_put(np); - return npd; - -out: - if (npd->nmap) { - iounmap(npd->nmap); - } - - if (npd->vmap) { - iounmap(npd->vmap); - } - - devm_kfree(&pdev->dev, npd); - of_node_put(np); - return NULL; -} - -/* - * nss_hal_clock_set_and_enable() - */ -static int nss_hal_clock_set_and_enable(struct device *dev, const char *id, unsigned long rate) -{ - struct clk *nss_clk = NULL; - int err; - - nss_clk = devm_clk_get(dev, id); - if (IS_ERR(nss_clk)) { - 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("%px: cannot set %s freq\n", dev, id); - return -EFAULT; - } - } - - err = clk_prepare_enable(nss_clk); - if (err) { - pr_err("%px: cannot enable clock: %s\n", dev, id); - return -EFAULT; - } - - return 0; -} - -/* - * __nss_hal_core_reset() - */ -static int __nss_hal_core_reset(struct platform_device *nss_dev, void __iomem *map, uint32_t addr, uint32_t clk_src) -{ - uint32_t value; - - /* - * Apply ubi32 core reset - */ - nss_write_32(map, NSS_REGS_RESET_CTRL_OFFSET, 0x1); - - /* - * De-assert reset for first set - */ - value = nss_read_32(nss_misc_reset, 0x0); - value &= ~NSS_CORE_GCC_RESET_1; - nss_write_32(nss_misc_reset, 0x0, value); - - /* - * Minimum 10 - 20 cycles delay is required after - * de-asserting NSS reset clamp - */ - usleep_range(10, 20); - - /* - * De-assert reset for second set - */ - value &= ~NSS_CORE_GCC_RESET_2; - nss_write_32(nss_misc_reset, 0x0, value); - - /* - * Program address configuration - */ - nss_write_32(map, NSS_REGS_CORE_AMC_OFFSET, 0x1); - nss_write_32(map, NSS_REGS_CORE_BAR_OFFSET, 0x3C000000); - nss_write_32(map, NSS_REGS_CORE_BOOT_ADDR_OFFSET, addr); - - /* - * Enable Instruction Fetch range checking between 0x4000 0000 to 0xBFFF FFFF. - */ - nss_write_32(map, NSS_REGS_CORE_IFETCH_RANGE_OFFSET, 0xBF004001); - - /* - * De-assert ubi32 core reset - */ - nss_write_32(map, NSS_REGS_RESET_CTRL_OFFSET, 0x0); - - /* - * Set values only once for core0. Grab the proper clock. - */ - nss_core0_clk = clk_get(&nss_dev->dev, NSS_CORE_CLK); - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency)) { - return -EFAULT; - } - - return 0; -} - -/* - * __nss_hal_debug_enable() - * Enable NSS debug - */ -static void __nss_hal_debug_enable(void) -{ - -} - -/* - * __nss_hal_common_reset - * Do reset/clock configuration common to all cores - */ -static int __nss_hal_common_reset(struct platform_device *nss_dev) -{ - - struct device_node *cmn = NULL; - struct resource res_nss_misc_reset; - struct resource res_nss_misc_reset_flag; - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NOC_CLK, 266670000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_PTP_REF_CLK, 150000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CSR_CLK, 200000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CFG_CLK, 100000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NSSNOC_QOSGEN_REF_CLK, 24000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NSSNOC_SNOC_CLK, 266600000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_SNOC_NSSNOC_CLK, 266670000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NSSNOC_TIMEOUT_REF_CLK, 6000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CE_AXI_CLK, 200000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CE_APB_CLK, 200000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NSSNOC_CE_AXI_CLK, 200000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NSSNOC_CE_APB_CLK, 200000000)) { - return -EFAULT; - } - - /* - * Get reference to NSS common device node - */ - cmn = of_find_node_by_name(NULL, "nss-common"); - if (!cmn) { - 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("%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("%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)); - 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)); - if (!nss_misc_reset_flag) { - pr_err("%px: ioremap fail for nss_misc_reset_flag\n", nss_dev); - return -EFAULT; - } - - nss_top_main.nss_hal_common_init_done = true; - nss_info("nss_hal_common_reset Done\n"); - - return 0; -} - -/* - * __nss_hal_clock_configure() - */ -static int __nss_hal_clock_configure(struct nss_ctx_instance *nss_ctx, struct platform_device *nss_dev, struct nss_platform_data *npd) -{ - uint32_t i; - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NSSNOC_AHB_CLK, 200000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_AHB_CLK, 200000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_AXI_CLK, 533330000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NC_AXI_CLK, 266670000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_UTCM_CLK, 266670000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_MEM_NOC_UBI32_CLK, 533330000)) { - return -EFAULT; - } - - /* - * No entries, then just load default - */ - if ((nss_runtime_samples.freq_scale[NSS_FREQ_LOW_SCALE].frequency == 0) || - (nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency == 0) || - (nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency == 0)) { - nss_runtime_samples.freq_scale[NSS_FREQ_LOW_SCALE].frequency = NSS_FREQ_187; - nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency = NSS_FREQ_748; - nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency = NSS_FREQ_1497; - nss_info_always("Running default frequencies\n"); - } - - /* - * Test frequency from dtsi, if fail, try to set default frequency. - */ - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency)) { - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, NSS_FREQ_1497)) { - return -EFAULT; - } - } - - /* - * Setup ranges, test frequency, and display. - */ - for (i = 0; i < NSS_FREQ_MAX_SCALE; i++) { - if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_187) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_187_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_187_MAX; - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_748) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_748_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_748_MAX; - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_1497) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_1497_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_1497_MAX; - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_1689) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_1689_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_1689_MAX; - } else { - nss_info_always("Frequency not found %d\n", nss_runtime_samples.freq_scale[i].frequency); - return -EFAULT; - } - - /* - * Test the frequency, if fail, then default to safe frequency and abort - */ - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, nss_runtime_samples.freq_scale[i].frequency)) { - return -EFAULT; - } - } - - nss_info_always("Supported Frequencies - "); - for (i = 0; i < NSS_FREQ_MAX_SCALE; i++) { - if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_187) { - nss_info_always("187.2 MHz "); - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_748) { - nss_info_always("748.8 MHz "); - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_1497) { - nss_info_always("1.4976 GHz "); - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_1689) { - nss_info_always("1.6896 GHz "); - } else { - nss_info_always("Error\nNo Table/Invalid Frequency Found\n"); - return -EFAULT; - } - } - nss_info_always("\n"); - - /* - * Set values only once for core0. Grab the proper clock. - */ - nss_core0_clk = clk_get(&nss_dev->dev, NSS_CORE_CLK); - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency)) { - return -EFAULT; - } - - return 0; -} - -/* - * __nss_hal_read_interrupt_cause() - */ -static void __nss_hal_read_interrupt_cause(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t *cause) -{ -} - -/* - * __nss_hal_clear_interrupt_cause() - */ -static void __nss_hal_clear_interrupt_cause(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ -} - -/* - * __nss_hal_disable_interrupt() - */ -static void __nss_hal_disable_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ -} - -/* - * __nss_hal_enable_interrupt() - */ -static void __nss_hal_enable_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ -} - -/* - * __nss_hal_send_interrupt() - */ -static void __nss_hal_send_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t type) -{ - /* - * Check if core and type is Valid - */ - nss_assert(nss_ctx->id < nss_top_main.num_nss); - nss_assert(type < NSS_H2N_INTR_TYPE_MAX); - - nss_write_32(nss_ctx->qgic_map, NSS_QGIC_IPC_REG_OFFSET, intr_cause[nss_ctx->id][type]); -} - -/* - * __nss_hal_request_irq() - */ -static int __nss_hal_request_irq(struct nss_ctx_instance *nss_ctx, struct nss_platform_data *npd, int irq_num) -{ - struct int_ctx_instance *int_ctx = &nss_ctx->int_ctx[irq_num]; - int err = -1, irq = npd->irq[irq_num]; - - irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY); - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_SOS) { - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); - int_ctx->cause = NSS_N2H_INTR_EMPTY_BUFFERS_SOS; - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_empty_buf_sos", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_QUEUE) { - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT); - int_ctx->cause = NSS_N2H_INTR_EMPTY_BUFFER_QUEUE; - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_empty_buf_queue", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_TX_UNBLOCKED) { - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_TX_UNBLOCKED_PROCESSING_WEIGHT); - int_ctx->cause = NSS_N2H_INTR_TX_UNBLOCKED; - err = request_irq(irq, nss_hal_handle_irq, 0, "nss-tx-unblock", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_0) { - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); - int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_0; - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue0", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_1) { - int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_1; - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue1", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_2) { - int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_2; - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue2", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_3) { - int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_3; - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue3", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_COREDUMP_COMPLETE) { - int_ctx->cause = NSS_N2H_INTR_COREDUMP_COMPLETE; - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_emergency, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_coredump_complete", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_PAGED_EMPTY_BUFFER_SOS) { - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); - int_ctx->cause = NSS_N2H_INTR_PAGED_EMPTY_BUFFERS_SOS; - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_paged_empty_buf_sos", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_PROFILE_DMA) { - int_ctx->cause = NSS_N2H_INTR_PROFILE_DMA; - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_sdma, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_profile_dma", int_ctx); - } - - if (err) { - return err; - } - - int_ctx->irq = irq; - return 0; -} - -/* - * __nss_hal_init_imem - */ -void __nss_hal_init_imem(struct nss_ctx_instance *nss_ctx) -{ - /* - * Nothing to be done as there are no TCM in ipq60xx - */ -} - -/* - * __nss_hal_init_utcm_shared - */ -bool __nss_hal_init_utcm_shared(struct nss_ctx_instance *nss_ctx, uint32_t *meminfo_start) -{ - struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; - uint32_t utcm_shared_map_magic = meminfo_start[2]; - uint32_t utcm_shared_start = meminfo_start[3]; - uint32_t utcm_shared_size = meminfo_start[4]; - - /* - * Check meminfo utcm_shared map magic - */ - if ((uint16_t)utcm_shared_map_magic != NSS_MEMINFO_RESERVE_AREA_UTCM_SHARED_MAP_MAGIC) { - nss_info_always("%px: failed to verify UTCM_SHARED map magic\n", nss_ctx); - return false; - } - - mem_ctx->utcm_shared_head = utcm_shared_start; - 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("%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; -} - -/* - * nss_hal_ipq60xx_ops - */ -struct nss_hal_ops nss_hal_ipq60xx_ops = { - .common_reset = __nss_hal_common_reset, - .core_reset = __nss_hal_core_reset, - .clock_configure = __nss_hal_clock_configure, - .firmware_load = nss_hal_firmware_load, - .debug_enable = __nss_hal_debug_enable, - .of_get_pdata = __nss_hal_of_get_pdata, - .request_irq = __nss_hal_request_irq, - .send_interrupt = __nss_hal_send_interrupt, - .enable_interrupt = __nss_hal_enable_interrupt, - .disable_interrupt = __nss_hal_disable_interrupt, - .clear_interrupt_cause = __nss_hal_clear_interrupt_cause, - .read_interrupt_cause = __nss_hal_read_interrupt_cause, - .init_imem = __nss_hal_init_imem, - .init_utcm_shared = __nss_hal_init_utcm_shared, -}; diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq806x/nss_clocks.h b/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq806x/nss_clocks.h deleted file mode 100644 index 1e7af1a4d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq806x/nss_clocks.h +++ /dev/null @@ -1,131 +0,0 @@ -/* * Copyright (c) 2013 The Linux Foundation. All rights reserved.* */ -/* - * Copyright (c) 2013 The Linux Foundation. - * - * Permission to use, copy, modify, and/or distribute this software 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_CLOCKS_H -#define __NSS_CLOCKS_H - -#if (NSS_DT_SUPPORT != 1) -#include -#include - -#define REG(off) (MSM_CLK_CTL_BASE + (off)) -#define REG_GCC(off) (MSM_APCS_GCC_BASE + (off)) - -/* Peripheral clock registers. */ -#define PLL18_ACR REG(0x1234) -#define PLL18_MODE REG(0x31A0) -#define PLL18_L_VAL REG(0x31A4) -#define PLL18_M_VAL REG(0x31A8) -#define PLL18_N_VAL REG(0x31AC) -#define PLL18_TEST_CTL REG(0x31B0) -#define PLL18_CONFIG REG(0x31B4) -#define PLL18_STATUS REG(0x31B8) -#define PLL_LOCK_DET_STATUS REG(0x3420) -#define PLL_LOCK_DET_MASK REG(0x3424) -#define CE5_CORE_CLK_SRC_CTL REG(0x36C0) -#define CE5_CORE_CLK_SRC0_NS REG(0x36C4) -#define NSS_ACC_REG REG(0x28EC) -#define NSS_RESET_SPARE REG(0x3B60) -#define NSSFB0_CLK_SRC_CTL REG(0x3B80) -#define NSSFB0_CLK_SRC0_NS REG(0x3B84) -#define NSSFB0_CLK_SRC1_NS REG(0x3B88) -#define NSSFB0_CLK_CTL REG(0x3BA0) -#define NSSFAB_GLOBAL_BUS_NS REG(0x3BC0) -#define NSSFB1_CLK_SRC_CTL REG(0x3BE0) -#define NSSFB1_CLK_SRC0_NS REG(0x3BE4) -#define NSSFB1_CLK_SRC1_NS REG(0x3BE8) -#define NSSFB1_CLK_CTL REG(0x3C00) -#define CLK_HALT_NSSFAB0_NSSFAB1_STATEA REG(0x3C20) -#define UBI32_MPT0_CLK_CTL REG(0x3C40) -#define UBI32_MPT1_CLK_CTL REG(0x3C44) -#define CE5_HCLK_SRC_CTL REG(0x3C60) -#define CE5_HCLK_SRC0_NS REG(0x3C64) -#define CE5_HCLK_SRC1_NS REG(0x3C68) -#define CE5_HCLK_CTL REG(0x3C6C) -#define NSSFPB_CLK_CTL REG(0x3C80) -#define NSSFPB_CLK_SRC_CTL REG(0x3C84) -#define NSSFPB_CLK_SRC0_NS REG(0x3C88) -#define NSSFPB_CLK_SRC1_NS REG(0x3C8C) -#define GMAC_COREn_CLK_SRC_CTL(n) REG(0x3CA0+32*(n)) -#define GMAC_CORE1_CLK_SRC_CTL REG(0x3CA0) -#define GMAC_COREn_CLK_SRC0_MD(n) REG(0x3CA4+32*(n)) -#define GMAC_CORE1_CLK_SRC0_MD REG(0x3CA4) -#define GMAC_COREn_CLK_SRC1_MD(n) REG(0x3CA8+32*(n)) -#define GMAC_CORE1_CLK_SRC1_MD REG(0x3CA8) -#define GMAC_COREn_CLK_SRC0_NS(n) REG(0x3CAC+32*(n)) -#define GMAC_CORE1_CLK_SRC0_NS REG(0x3CAC) -#define GMAC_COREn_CLK_SRC1_NS(n) REG(0x3CB0+32*(n)) -#define GMAC_CORE1_CLK_SRC1_NS REG(0x3CB0) -#define GMAC_COREn_CLK_CTL(n) REG(0x3CB4+32*(n)) -#define GMAC_CORE1_CLK_CTL REG(0x3CB4) -#define GMAC_COREn_CLK_FS(n) REG(0x3CB8+32*(n)) -#define GMAC_CORE1_CLK_FS REG(0x3CB8) -#define GMAC_COREn_RESET(n) REG(0x3CBC+32*(n)) -#define GMAC_CORE1_RESET REG(0x3CBC) -#define UBI32_COREn_CLK_SRC_CTL(n) REG(0x3D20+32*(n)) -#define UBI32_CORE1_CLK_SRC_CTL REG(0x3D20) -#define UBI32_COREn_CLK_SRC0_MD(n) REG(0x3D24+32*(n)) -#define UBI32_CORE1_CLK_SRC0_MD REG(0x3D24) -#define UBI32_COREn_CLK_SRC1_MD(n) REG(0x3D28+32*(n)) -#define UBI32_CORE1_CLK_SRC1_MD REG(0x3D28) -#define UBI32_COREn_CLK_SRC0_NS(n) REG(0x3D2C+32*(n)) -#define UBI32_CORE1_CLK_SRC0_NS REG(0x3D2C) -#define UBI32_COREn_CLK_SRC1_NS(n) REG(0x3D30+32*(n)) -#define UBI32_CORE1_CLK_SRC1_NS REG(0x3D30) -#define UBI32_COREn_CLK_CTL(n) REG(0x3D34+32*(n)) -#define UBI32_CORE1_CLK_CTL REG(0x3D34) -#define UBI32_COREn_CLK_FS(n) REG(0x3D38+32*(n)) -#define UBI32_CORE1_CLK_FS REG(0x3D38) -#define UBI32_COREn_RESET_CLAMP(n) REG(0x3D3C+32*(n)) -#define UBI32_CORE1_RESET_CLAMP REG(0x3D3C) -#define NSS_250MHZ_CLK_SRC_CTL REG(0x3D60) -#define NSS_250MHZ_CLK_SRC0_NS REG(0x3D64) -#define NSS_250MHZ_CLK_SRC1_NS REG(0x3D68) -#define NSS_250MHZ_CLK_SRC0_MD REG(0x3D6C) -#define NSS_250MHZ_CLK_SRC1_MD REG(0x3D70) -#define NSS_250MHZ_CLK_CTL REG(0x3D74) -#define CE5_ACLK_SRC_CTL REG(0x3D80) -#define CE5_ACLK_SRC0_NS REG(0x3D84) -#define CE5_ACLK_SRC1_NS REG(0x3D88) -#define CE5_ACLK_CTL REG(0x3D8C) -#define PLL_ENA_NSS REG(0x3DA0) -#define NSSTCM_CLK_SRC_CTL REG(0x3DC0) -#define NSSTCM_CLK_SRC0_NS REG(0x3DC4) -#define NSSTCM_CLK_SRC1_NS REG(0x3DC8) -#define NSSTCM_CLK_FS REG(0x3DCC) -#define NSSTCM_CLK_CTL REG(0x3DD0) -#define CE5_CORE_0_RESET REG(0x3E00) -#define CE5_CORE_1_RESET REG(0x3E04) -#define CE5_CORE_2_RESET REG(0x3E08) -#define CE5_CORE_3_RESET REG(0x3E0C) -#define CE5_AHB_RESET REG(0x3E10) -#define NSS_RESET REG(0x3E20) -#define GMAC_AHB_RESET REG(0x3E24) -#define MACSEC_CORE1_RESET REG(0x3E28) -#define MACSEC_CORE2_RESET REG(0x3E2C) -#define MACSEC_CORE3_RESET REG(0x3E30) -#define NSS_TCM_RESET REG(0x3E40) - -enum nss_hal_pvt_pll_status { - PLL_NOT_LOCKED, - PLL_LOCKED -}; - -#endif -#endif /* __NSS_CLOCKS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq806x/nss_hal_pvt.c b/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq806x/nss_hal_pvt.c deleted file mode 100644 index b8733e04b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq806x/nss_hal_pvt.c +++ /dev/null @@ -1,1237 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_hal_pvt.c - * NSS HAL private APIs. - */ - -#include -#include -#include -#include -#include -#if (NSS_DT_SUPPORT != 1) -#include -#include -#else -#include -#include -#include -#include -#include -#endif -#include "nss_hal.h" -#include "nss_clocks.h" -#include "nss_core.h" -#if (NSS_PM_SUPPORT == 1) -#include "nss_pm.h" -#endif -#if (NSS_FABRIC_SCALING_SUPPORT == 1) -#include -#endif - -#define NSS_H2N_INTR_EMPTY_BUFFER_QUEUE_BIT 0 -#define NSS_H2N_INTR_DATA_COMMAND_QUEUE_BIT 1 -#define NSS_H2N_INTR_TX_UNBLOCKED_BIT 11 -#define NSS_H2N_INTR_EMPTY_PAGED_BUFFER_QUEUE_BIT 12 -#define NSS_H2N_INTR_TRIGGER_COREDUMP_BIT 15 - -/* - * Interrupt type to cause vector. - */ -static uint32_t intr_cause[] = {(1 << NSS_H2N_INTR_EMPTY_BUFFER_QUEUE_BIT), - (1 << NSS_H2N_INTR_DATA_COMMAND_QUEUE_BIT), - (1 << NSS_H2N_INTR_TX_UNBLOCKED_BIT), - (1 << NSS_H2N_INTR_TRIGGER_COREDUMP_BIT), - (1 << NSS_H2N_INTR_EMPTY_PAGED_BUFFER_QUEUE_BIT)}; - -#if (NSS_DT_SUPPORT == 1) -bool nss_crypto_is_scaled = false; -#endif - -#if (NSS_FW_DBG_SUPPORT == 1) -/* - * NSS debug pins configuration - */ - -/* - * Core 0, Data - * No pull up, Function 2 - */ -static struct gpiomux_setting nss_spi_data_0 = { - .func = GPIOMUX_FUNC_2, - .drv = GPIOMUX_DRV_8MA, - .pull = GPIOMUX_PULL_NONE, - .dir = GPIOMUX_IN, -}; - -/* - * Core 0, CLK, CS - * Pull up high, Function 2 - */ -static struct gpiomux_setting nss_spi_cs_clk_0 = { - .func = GPIOMUX_FUNC_2, - .drv = GPIOMUX_DRV_8MA, - .pull = GPIOMUX_PULL_UP, - .dir = GPIOMUX_IN, -}; - -/* - * Core 1, CS - * Pull up high, Function 4 - */ -static struct gpiomux_setting nss_spi_cs_1 = { - .func = GPIOMUX_FUNC_4, - .drv = GPIOMUX_DRV_8MA, - .pull = GPIOMUX_PULL_UP, - .dir = GPIOMUX_IN, -}; - -/* - * Core 1, CLK - * Pull up high, Function 5 - */ -static struct gpiomux_setting nss_spi_clk_1 = { - .func = GPIOMUX_FUNC_5, - .drv = GPIOMUX_DRV_8MA, - .pull = GPIOMUX_PULL_UP, - .dir = GPIOMUX_IN, -}; - -/* - * Core 1, Data - * Pull up none, Function 5 - */ -static struct gpiomux_setting nss_spi_data_1 = { - .func = GPIOMUX_FUNC_5, - .drv = GPIOMUX_DRV_8MA, - .pull = GPIOMUX_PULL_NONE, - .dir = GPIOMUX_IN, -}; - -static struct msm_gpiomux_config nss_spi_gpiomux[] = { - { - .gpio = 14, - .settings = { - [GPIOMUX_ACTIVE] = &nss_spi_data_0, - [GPIOMUX_SUSPENDED] = &nss_spi_data_0, - }, - }, - { - .gpio = 15, - .settings = { - [GPIOMUX_ACTIVE] = &nss_spi_data_0, - [GPIOMUX_SUSPENDED] = &nss_spi_data_0, - }, - }, - { - .gpio = 16, - .settings = { - [GPIOMUX_ACTIVE] = &nss_spi_cs_clk_0, - [GPIOMUX_SUSPENDED] = &nss_spi_cs_clk_0, - }, - }, - { - .gpio = 17, - .settings = { - [GPIOMUX_ACTIVE] = &nss_spi_cs_clk_0, - [GPIOMUX_SUSPENDED] = &nss_spi_cs_clk_0, - }, - }, - { - .gpio = 55, - .settings = { - [GPIOMUX_ACTIVE] = &nss_spi_data_1, - [GPIOMUX_SUSPENDED] = &nss_spi_data_1, - }, - }, - { - .gpio = 56, - .settings = { - [GPIOMUX_ACTIVE] = &nss_spi_data_1, - [GPIOMUX_SUSPENDED] = &nss_spi_data_1, - }, - }, - { - .gpio = 57, - .settings = { - [GPIOMUX_ACTIVE] = &nss_spi_cs_1, - [GPIOMUX_SUSPENDED] = &nss_spi_cs_1, - }, - }, - { - .gpio = 58, - .settings = { - [GPIOMUX_ACTIVE] = &nss_spi_clk_1, - [GPIOMUX_SUSPENDED] = &nss_spi_clk_1, - }, - }, -}; -#endif /* NSS_FW_DBG_SUPPORT */ - -/* - * nss_hal_scale_fabric() - * DT supported fabric scaling - */ -void nss_hal_scale_fabric(uint32_t work_frequency) -{ -#if (NSS_DT_SUPPORT == 1) - nss_crypto_pm_event_callback_t crypto_pm_cb; - bool auto_scale; - bool turbo; - -#if (NSS_FABRIC_SCALING_SUPPORT == 1) - /* - * PM framework - */ - scale_fabrics(); -#endif - if ((nss_fab0_clk != NULL) && (nss_fab1_clk != NULL)) { - if (work_frequency >= NSS_FREQ_733) { - clk_set_rate(nss_fab0_clk, NSS_FABRIC0_TURBO); - clk_set_rate(nss_fab1_clk, NSS_FABRIC1_TURBO); - } else if (work_frequency > NSS_FREQ_110) { - clk_set_rate(nss_fab0_clk, NSS_FABRIC0_NOMINAL); - clk_set_rate(nss_fab1_clk, NSS_FABRIC1_NOMINAL); - } else { - clk_set_rate(nss_fab0_clk, NSS_FABRIC0_IDLE); - clk_set_rate(nss_fab1_clk, NSS_FABRIC1_IDLE); - } - - /* - * notify crypto about the clock change - */ - crypto_pm_cb = nss_top_main.crypto_pm_callback; - if (crypto_pm_cb) { - turbo = (work_frequency >= NSS_FREQ_733); - auto_scale = nss_cmd_buf.auto_scale; - nss_crypto_is_scaled = crypto_pm_cb(nss_top_main.crypto_pm_ctx, turbo, auto_scale); - } - } -#endif -} - -/* - * nss_hal_pm_support() - * Supported in 3.4 - */ -void nss_hal_pm_support(uint32_t work_frequency) -{ -#if (NSS_PM_SUPPORT == 1) - if (!pm_client) { - return; - } - - if (work_frequency >= NSS_FREQ_733) { - nss_pm_set_perf_level(pm_client, NSS_PM_PERF_LEVEL_TURBO); - } else if (work_frequency > NSS_FREQ_110) { - nss_pm_set_perf_level(pm_client, NSS_PM_PERF_LEVEL_NOMINAL); - } else { - nss_pm_set_perf_level(pm_client, NSS_PM_PERF_LEVEL_IDLE); - } -#endif -} - -/* - * nss_hal_freq_change() - * Send frequency change message, and clock adjustment - */ -void nss_hal_freq_change(nss_work_t *my_work) -{ - nss_freq_change(&nss_top_main.nss[NSS_CORE_0], my_work->frequency, my_work->stats_enable, 0); - if (nss_top_main.nss[NSS_CORE_1].state == NSS_CORE_STATE_INITIALIZED) { - nss_freq_change(&nss_top_main.nss[NSS_CORE_1], my_work->frequency, my_work->stats_enable, 0); - } - clk_set_rate(nss_core0_clk, my_work->frequency); - - nss_freq_change(&nss_top_main.nss[NSS_CORE_0], my_work->frequency, my_work->stats_enable, 1); - if (nss_top_main.nss[NSS_CORE_1].state == NSS_CORE_STATE_INITIALIZED) { - nss_freq_change(&nss_top_main.nss[NSS_CORE_1], my_work->frequency, my_work->stats_enable, 1); - } -} - -/* - * nss_hal_wq_function() - * Added to Handle BH requests to kernel - */ -void nss_hal_wq_function(struct work_struct *work) -{ - nss_work_t *my_work = (nss_work_t *)work; - - mutex_lock(&nss_top_main.wq_lock); -#if (NSS_DT_SUPPORT == 1) - /* - * If crypto clock is in Turbo, disable scaling for other - * NSS subsystem components and retain them at turbo - */ - if (nss_crypto_is_scaled) { - nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency; - mutex_unlock(&nss_top_main.wq_lock); - return; - } -#endif - - nss_hal_freq_change(my_work); - - /* - * Supported in 3.4 - */ - nss_hal_pm_support(my_work->frequency); - - nss_hal_scale_fabric(my_work->frequency); - - mutex_unlock(&nss_top_main.wq_lock); - kfree((void *)work); -} - -/* - * nss_hal_handle_irq() - * HLOS interrupt handler for nss interrupts - */ -static irqreturn_t nss_hal_handle_irq(int irq, void *ctx) -{ - struct int_ctx_instance *int_ctx = (struct int_ctx_instance *) ctx; - struct nss_ctx_instance *nss_ctx = int_ctx->nss_ctx; - - /* - * Mask interrupt until our bottom half re-enables it - */ - nss_hal_disable_interrupt(nss_ctx, int_ctx->shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS); - - /* - * Schedule tasklet to process interrupt cause - */ - napi_schedule(&int_ctx->napi); - return IRQ_HANDLED; -} - -#if (NSS_DT_SUPPORT != 1) -#if defined(NSS_ENABLE_CLK) -/* - * nss_hal_pvt_enable_pll18() - * Enable PLL18 - */ -static uint32_t nss_hal_pvt_enable_pll18(uint32_t speed) -{ - uint32_t retries = 100; - - /* - * Prevent Compiler from commenting out the loop. - */ - uint32_t value; - uint32_t mask = (1 << 2); - - /* - * Start with clean slate - */ - writel(0, PLL18_MODE); - - /* - * Effective VCO Frequency = 1100 MHz Post Divide 2 - */ - if (speed == 1100) { - writel(0x4000042C, PLL18_L_VAL); - writel(0x0, PLL18_M_VAL); - writel(0x1, PLL18_N_VAL); - - /* - * PLL configuration (as provided by HW team) - */ - writel(0x01495625, PLL18_CONFIG); - writel(0x00003080, PLL18_TEST_CTL); - } else if (speed == 1466) { - /* - * Effective VCO Frequency = 1466 MHz Post Divide 2 - */ - - writel(0x4000043A, PLL18_L_VAL); - writel(0x10, PLL18_M_VAL); - writel(0x19, PLL18_N_VAL); - - /* - * PLL configuration (as provided by HW team) - */ - writel(0x014B5625, PLL18_CONFIG); - writel(0x00003080, PLL18_TEST_CTL); - } else { - BUG_ON(1); - } - - /* - * Enable PLL18 output (sequence provided by HW team) - */ - writel(0x2, PLL18_MODE); - mdelay(1); - writel(0x6, PLL18_MODE); - writel(0x7, PLL18_MODE); - - /* - * Enable NSS Vote for PLL18. - */ - writel(mask, PLL_ENA_NSS); - do { - value = readl(PLL_LOCK_DET_STATUS); - if (value & mask) { - return PLL_LOCKED; - } - - mdelay(1); - } while (retries-- > 0); - - return PLL_NOT_LOCKED; -} -#endif -#else -/* - * __nss_hal_of_get_pdata() - * Retrieve platform data from device node. - */ -static struct nss_platform_data *__nss_hal_of_get_pdata(struct platform_device *pdev) -{ - struct device_node *np = of_node_get(pdev->dev.of_node); - struct nss_platform_data *npd; - struct nss_ctx_instance *nss_ctx = NULL; - struct nss_top_instance *nss_top = &nss_top_main; - struct resource res_nphys, res_vphys; - int32_t i; - - npd = devm_kzalloc(&pdev->dev, sizeof(struct nss_platform_data), GFP_KERNEL); - if (!npd) { - return NULL; - } - - if (of_property_read_u32(np, "qcom,id", &npd->id) - || of_property_read_u32(np, "qcom,load-addr", &npd->load_addr) - || of_property_read_u32(np, "qcom,num-queue", &npd->num_queue) - || of_property_read_u32(np, "qcom,num-irq", &npd->num_irq)) { - pr_err("%s: error reading critical device node properties\n", np->name); - goto out; - } - - /* - * Read frequencies. If failure, load default values. - */ - of_property_read_u32(np, "qcom,low-frequency", &nss_runtime_samples.freq_scale[NSS_FREQ_LOW_SCALE].frequency); - of_property_read_u32(np, "qcom,mid-frequency", &nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency); - of_property_read_u32(np, "qcom,max-frequency", &nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency); - - if (npd->num_irq < npd->num_queue) { - pr_err("%s: not enough interrupts configured for all the queues\n", np->name); - goto out; - } - - if (npd->num_irq > NSS_MAX_IRQ_PER_CORE) { - pr_err("%s: exceeds maximum interrupt numbers per core\n", np->name); - goto out; - } - - nss_ctx = &nss_top->nss[npd->id]; - nss_ctx->id = npd->id; - - if (of_address_to_resource(np, 0, &res_nphys) != 0) { - 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("%px: nss%d: of_address_to_resource() fail for vphys\n", nss_ctx, nss_ctx->id); - goto out; - } - - /* - * Save physical addresses - */ - npd->nphys = res_nphys.start; - npd->vphys = res_vphys.start; - - npd->nmap = ioremap_nocache(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; - } - - /* - * Clear TCM memory used by this core - */ - for (i = 0; i < resource_size(&res_vphys) ; i += 4) { - nss_write_32(npd->vmap, i, 0); - NSS_CORE_DMA_CACHE_MAINT((npd->vmap + i), 4, DMA_TO_DEVICE); - } - NSS_CORE_DSB(); - - /* - * Get IRQ numbers - */ - 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("%px: nss%d: irq_of_parse_and_map() fail for irq %d\n", nss_ctx, nss_ctx->id, i); - goto out; - } - } - - nss_hal_dt_parse_features(np, npd); - - of_node_put(np); - return npd; - -out: - if (npd->nmap) { - iounmap(npd->nmap); - } - - if (npd->vmap) { - iounmap(npd->vmap); - } - - devm_kfree(&pdev->dev, npd); - of_node_put(np); - return NULL; -} -#endif - -/* - * __nss_hal_core_reset() - */ -static int __nss_hal_core_reset(struct platform_device *nss_dev, void __iomem *map, uint32_t addr, uint32_t clk_src) -{ -#if (NSS_DT_SUPPORT == 1) - struct reset_control *rstctl = NULL; - - /* - * Remove UBI32 reset clamp - */ - rstctl = devm_reset_control_get(&nss_dev->dev, "clkrst-clamp"); - if (IS_ERR(rstctl)) { - nss_info_always("%px: Deassert UBI32 core%d reset clamp failed", nss_dev, nss_dev->id); - return -EFAULT; - } - reset_control_deassert(rstctl); - - /* - * Remove UBI32 core clamp - */ - rstctl = devm_reset_control_get(&nss_dev->dev, "clamp"); - if (IS_ERR(rstctl)) { - nss_info_always("%px: Deassert UBI32 core%d clamp failed", nss_dev, nss_dev->id); - return -EFAULT; - } - reset_control_deassert(rstctl); - - /* - * Remove UBI32 AHB reset - */ - rstctl = devm_reset_control_get(&nss_dev->dev, "ahb"); - if (IS_ERR(rstctl)) { - nss_info_always("%px: Deassert AHB core%d reset failed", nss_dev, nss_dev->id); - return -EFAULT; - } - reset_control_deassert(rstctl); - - /* - * Remove UBI32 AXI reset - */ - rstctl = devm_reset_control_get(&nss_dev->dev, "axi"); - if (IS_ERR(rstctl)) { - nss_info_always("%px: Deassert core%d AXI reset failed", nss_dev, nss_dev->id); - return -EFAULT; - } - reset_control_deassert(rstctl); -#else -#if defined(NSS_ENABLE_CLOCK) - /* - * Enable mpt clock - */ - writel(0x10, UBI32_MPT0_CLK_CTL); - - /* - * UBI coren clock root enable - */ - if (clk_src == NSS_REGS_CLK_SRC_DEFAULT) { - /* select Src0 */ - writel(0x02, UBI32_COREn_CLK_SRC_CTL(nss_dev->id)); - } else { - /* select Src1 */ - writel(0x03, UBI32_COREn_CLK_SRC_CTL(nss_dev->id)); - } - - /* - * Src0: Bypass M value configuration. - */ - - /* - * Src1: M val is 0x01 and NOT_2D value is 0xfd, 400 MHz with PLL0. - */ - writel(0x100fd, UBI32_COREn_CLK_SRC1_MD(nss_dev->id)); - - /* - * Bypass, pll18 - * Effective frequency = 550 MHz - */ - writel(0x00000001, UBI32_COREn_CLK_SRC0_NS(nss_dev->id)); - - /* - * Dual edge, pll0, NOT(N_M) = 0xfe. - * Effective frequency = 400 MHz - */ - writel(0x00fe0142, UBI32_COREn_CLK_SRC1_NS(nss_dev->id)); - - /* - * UBI32 coren clock control branch. - */ - writel(0x4f, UBI32_COREn_CLK_FS(nss_dev->id)); - - /* - * UBI32 coren clock control branch. - */ - writel(0x10, UBI32_COREn_CLK_CTL(nss_dev->id)); -#endif - /* - * Remove UBI32 reset clamp - */ - writel(0xB, UBI32_COREn_RESET_CLAMP(nss_dev->id)); - - /* - * Busy wait for few cycles - */ - mdelay(1); - - /* - * Remove UBI32 core clamp - */ - writel(0x3, UBI32_COREn_RESET_CLAMP(nss_dev->id)); - - mdelay(1); - - /* - * Remove UBI32 AHB reset - */ - writel(0x1, UBI32_COREn_RESET_CLAMP(nss_dev->id)); - - mdelay(1); - - /* - * Remove UBI32 AXI reset - */ - writel(0x0, UBI32_COREn_RESET_CLAMP(nss_dev->id)); - - mdelay(1); -#endif /* NSS_DT_SUPPORT */ - - /* - * Apply ubi32 core reset - */ - nss_write_32(map, NSS_REGS_RESET_CTRL_OFFSET, 1); - - /* - * Program address configuration - */ - nss_write_32(map, NSS_REGS_CORE_AMC_OFFSET, 1); - nss_write_32(map, NSS_REGS_CORE_BAR_OFFSET, 0x3c000000); - nss_write_32(map, NSS_REGS_CORE_BOOT_ADDR_OFFSET, addr); - - /* - * C2C interrupts are level sensitive - */ - nss_write_32(map, NSS_REGS_CORE_INT_STAT2_TYPE_OFFSET, 0xFFFF); - - /* - * Enable Instruction Fetch range checking between 0x4000 0000 to 0xBFFF FFFF. - */ - nss_write_32(map, NSS_REGS_CORE_IFETCH_RANGE_OFFSET, 0xBF004001); - - /* - * De-assert ubi32 core reset - */ - nss_write_32(map, NSS_REGS_RESET_CTRL_OFFSET, 0); - - return 0; -} - -/* - * __nss_hal_debug_enable() - * Enable NSS debug - */ -static void __nss_hal_debug_enable(void) -{ -#if (NSS_FW_DBG_SUPPORT == 1) - msm_gpiomux_install(nss_spi_gpiomux, - ARRAY_SIZE(nss_spi_gpiomux)); -#endif -} - -/* - * __nss_hal_common_reset - * Do reset/clock configuration common to all cores - */ -static int __nss_hal_common_reset(struct platform_device *nss_dev) -{ -#if (NSS_DT_SUPPORT == 1) - struct device_node *cmn = NULL; - struct resource res_nss_fpb_base; - struct clk *nss_tcm_src = NULL; - struct clk *nss_tcm_clk = NULL; - void __iomem *fpb_base; - int err; - - /* - * Get reference to NSS common device node - */ - cmn = of_find_node_by_name(NULL, "nss-common"); - if (!cmn) { - 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("%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)); - if (!fpb_base) { - pr_err("%px: ioremap fail for nss_fpb_base\n", nss_dev); - return -EFAULT; - } - - /* - * Attach debug interface to TLMM - */ - nss_write_32(fpb_base, NSS_REGS_FPB_CSR_CFG_OFFSET, 0x360); - - /* - * NSS TCM CLOCK - */ - nss_tcm_src = clk_get(&nss_dev->dev, NSS_TCM_SRC_CLK); - if (IS_ERR(nss_tcm_src)) { - 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("%px: cannot set NSSTCM freq\n", nss_dev); - return -EFAULT; - } - - err = clk_prepare_enable(nss_tcm_src); - if (err) { - 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("%px: cannot get clock: %s\n", nss_dev, NSS_TCM_CLK); - return -EFAULT; - } - - err = clk_prepare_enable(nss_tcm_clk); - if (err) { - pr_err("%px: cannot enable NSSTCM clock\n", nss_dev); - return -EFAULT; - } - - /* - * NSS Fabric Clocks. - */ - nss_fab0_clk = clk_get(&nss_dev->dev, NSS_FABRIC0_CLK); - if (IS_ERR(nss_fab0_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("%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("%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("%px: cannot enable clock: %s\n", nss_dev, NSS_FABRIC1_CLK); - return -EFAULT; - } - } - - nss_top_main.nss_hal_common_init_done = true; - nss_info("nss_hal_common_reset Done\n"); - return 0; -} -#else - uint32_t i; - uint32_t value; - uint32_t status_mask = 0x1; - uint32_t wait_cycles = 100; - -#if defined(NSS_ENABLE_CLK) - /* - * NSS FPB CLOCK - */ - - /* - * Enable clock root and Divider 0 - * NOTE: Default value is good so no work here - */ - - /* - * PLL0 (800 MHZ). SRC_SEL is 2 (3'b010) - * src_div selected is Div-6 (4'b0101). - * - * Effective frequency (Divider 0) = 133 MHz - */ - writel(0x2a, NSSFPB_CLK_SRC0_NS); - - /* - * Enable clock branch - */ - writel(0x50, NSSFPB_CLK_CTL); - - /* - * NSS FABRIC0 CLOCK - */ - - /* - * Enable clock root and Divider 0 - * NOTE: Default value is good so no work here - */ - - /* - * PLL0 (800 MHZ) and div is set to 2. - * Effective frequency = 400 MHZ. - */ - writel(0x0a, NSSFB0_CLK_SRC0_NS); - - /* - * NSS Fabric0 Branch and dynamic clock gating enabled. - */ - writel(0x50, NSSFB0_CLK_CTL); - - /* - * Enable clock root and Divider 0 - * NOTE: Default value is good so no work here - */ - - /* - * PLL0 (800 MHZ) and div is set to 4. - * Effective frequency = 200 MHZ. - */ - writel(0x1a, NSSFB1_CLK_SRC0_NS); - - /* - * NSS Fabric1 Branch enable and fabric clock gating enabled. - */ - writel(0x50, NSSFB1_CLK_CTL); - - /* - * NSS TCM CLOCK - */ - - /* - * Enable NSS TCM clock root source and select divider 0. - * - * NOTE: Default value is not good here - */ - writel(0x2, NSSTCM_CLK_SRC_CTL); - - /* - * PLL0 (800 MHZ) and div is set to 2. - * Effective frequency = 400 MHZ - */ - writel(0xa, NSSTCM_CLK_SRC0_NS); - - /* - * NSS TCM Branch enable and fabric clock gating enabled. - */ - writel(0x50, NSSTCM_CLK_CTL); - - /* - * Enable global NSS clock branches. - * NSS global Fab Branch enable and fabric clock gating enabled. - */ - writel(0xf, NSSFAB_GLOBAL_BUS_NS); - - /* - * Send reset interrupt to NSS - */ - writel(0x0, NSS_RESET); - - /* - * Enable PLL18 - */ - pll18_status = nss_hal_pvt_enable_pll18(); - if (!pll18_status) { - /* - * Select alternate good source (Src1/pll0) - */ - nss_top->clk_src = NSS_REGS_CLK_SRC_ALTERNATE; - return; - } - - /* - * Select default source (Src0/pll18) - */ - nss_top->clk_src = NSS_REGS_CLK_SRC_DEFAULT; -#endif - - /* - * Attach debug interface to TLMM - */ - nss_write_32((uint32_t)MSM_NSS_FPB_BASE, NSS_REGS_FPB_CSR_CFG_OFFSET, 0x360); - - /* - * NSS TCM CLOCK - */ - - /* - * Enable NSS TCM clock root source - SRC1. - * - */ - writel(0x3, NSSTCM_CLK_SRC_CTL); - - /* Enable PLL Voting for 0 */ - writel((readl(PLL_ENA_NSS) | 0x1), PLL_ENA_NSS); - do { - value = readl(PLL_LOCK_DET_STATUS); - if (value & status_mask) { - break; - } - mdelay(1); - } while (wait_cycles-- > 0); - - /* - * PLL0 (800 MHZ) and div is set to 3/4. - * Effective frequency = 266/400 Mhz for SRC0/1 - */ - writel(0x12, NSSTCM_CLK_SRC0_NS); - writel(0xa, NSSTCM_CLK_SRC1_NS); - - /* - * NSS TCM Branch enable and fabric clock gating enabled. - */ - writel(0x50, NSSTCM_CLK_CTL); - - /* - * Clear TCM memory - */ - for (i = 0; i < IPQ806X_NSS_TCM_SIZE; i += 4) { - nss_write_32((uint32_t)MSM_NSS_TCM_BASE, i, 0); - } - - return 0; -} -#endif /* NSS_DT_SUPPORT */ - -/* - * __nss_hal_clock_configure() - */ -static int __nss_hal_clock_configure(struct nss_ctx_instance *nss_ctx, struct platform_device *nss_dev, struct nss_platform_data *npd) -{ -#if (NSS_FABRIC_SCALING_SUPPORT == 1) - struct fab_scaling_info fab_data; -#endif - int i, err; - - /* - * Both ubi core on ipq806x attach to the same clock, configure just the core0 - */ - if (nss_ctx->id) { - return 0; - } - - 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("%px: Regulator %s get failed, err=%d\n", nss_ctx, dev_name(&nss_dev->dev), err); - return err; - } - - /* - * Check if turbo is supported - */ - if (npd->turbo_frequency) { - nss_info_always("nss_driver - Turbo Support %d\n", npd->turbo_frequency); -#if (NSS_PM_SUPPORT == 1) - nss_pm_set_turbo(); -#endif - } else { - nss_info_always("nss_driver - Turbo No Support %d\n", npd->turbo_frequency); - } - - /* - * If valid entries - from dtsi - then just init clks. - * Otherwise query for clocks. - */ - if ((nss_runtime_samples.freq_scale[NSS_FREQ_LOW_SCALE].frequency != 0) && - (nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency != 0) && - (nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency != 0)) { - goto clk_complete; - } - - /* - * Load default scales, then query for higher. - * If basic set cannot be set, then go to error, and abort - * Two set of defaults, 110, 550, 733 or 110, 275 and 550 - */ - if (clk_set_rate(nss_core0_clk, NSS_FREQ_110) != 0) { - return -EFAULT; - } - nss_runtime_samples.freq_scale[NSS_FREQ_LOW_SCALE].frequency = NSS_FREQ_110; - - if (npd->turbo_frequency) { - /* - * Figure out the middle scale - */ - if (clk_set_rate(nss_core0_clk, NSS_FREQ_600) == 0) { - nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency = NSS_FREQ_600; - } else if (clk_set_rate(nss_core0_clk, NSS_FREQ_550) == 0) { - nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency = NSS_FREQ_550; - } else { - return -EFAULT; - } - - /* - * Figure out the max scale - */ - if (clk_set_rate(nss_core0_clk, NSS_FREQ_800) == 0) { - nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency = NSS_FREQ_800; - } else if (clk_set_rate(nss_core0_clk, NSS_FREQ_733) == 0) { - nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency = NSS_FREQ_733; - } else { - return -EFAULT; - } - - } else { - if (clk_set_rate(nss_core0_clk, NSS_FREQ_275) != 0) { - return -EFAULT; - } - nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency = NSS_FREQ_275; - - if (clk_set_rate(nss_core0_clk, NSS_FREQ_550) != 0) { - return -EFAULT; - } - nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency = NSS_FREQ_550; - } - -clk_complete: -#if (NSS_FABRIC_SCALING_SUPPORT == 1) - if (npd->turbo_frequency) { - fab_data.idle_freq = nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency; - } else { - fab_data.idle_freq = nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency; - } - fab_data.clk = nss_core0_clk; - fab_scaling_register(&fab_data); -#endif - - /* - * Setup Ranges - */ - for (i = 0; i < NSS_FREQ_MAX_SCALE; i++) { - if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_110) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_110_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_110_MAX; - } - if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_275) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_275_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_275_MAX; - } - if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_550) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_550_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_550_MAX; - } - if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_600) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_600_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_600_MAX; - } - if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_733) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_733_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_733_MAX; - } - if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_800) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_800_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_800_MAX; - } - } - - nss_info_always("Supported Frequencies - "); - for (i = 0; i < NSS_FREQ_MAX_SCALE; i++) { - if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_110) { - nss_info_always("110Mhz "); - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_275) { - nss_info_always("275Mhz "); - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_550) { - nss_info_always("550Mhz "); - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_600) { - nss_info_always("600Mhz "); - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_733) { - nss_info_always("733Mhz "); - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_800) { - nss_info_always("800Mhz "); - } else { - nss_info_always("Error\nNo Table/Invalid Frequency Found - Loading Old Tables -"); - return -EFAULT; - } - } - nss_info_always("\n"); - - /* - * Set default frequency - */ - err = clk_set_rate(nss_core0_clk, nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency); - if (err) { - 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("%px: cannot enable nss core0 clock\n", nss_ctx); - return -EFAULT; - } - - return 0; -} - -/* - * __nss_hal_read_interrupt_cause() - */ -static void __nss_hal_read_interrupt_cause(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t *cause) -{ - uint32_t value = nss_read_32(nss_ctx->nmap, NSS_REGS_N2H_INTR_STATUS_OFFSET); - *cause = (((value) >> shift_factor) & 0x7FFF); -} - -/* - * __nss_hal_clear_interrupt_cause() - */ -static void __nss_hal_clear_interrupt_cause(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ - nss_write_32(nss_ctx->nmap, NSS_REGS_N2H_INTR_CLR_OFFSET, (cause << shift_factor)); -} - -/* - * __nss_hal_disable_interrupt() - */ -static void __nss_hal_disable_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ - nss_write_32(nss_ctx->nmap, NSS_REGS_N2H_INTR_MASK_CLR_OFFSET, (cause << shift_factor)); -} - -/* - * __nss_hal_enable_interrupt() - */ -static void __nss_hal_enable_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ - nss_write_32(nss_ctx->nmap, NSS_REGS_N2H_INTR_MASK_SET_OFFSET, (cause << shift_factor)); -} - -/* - * __nss_hal_send_interrupt() - */ -static void __nss_hal_send_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t type) -{ - nss_write_32(nss_ctx->nmap, NSS_REGS_C2C_INTR_SET_OFFSET, intr_cause[type]); -} - -/* - * __nss_hal_request_irq() - */ -static int __nss_hal_request_irq(struct nss_ctx_instance *nss_ctx, struct nss_platform_data *npd, int irq_num) -{ - struct int_ctx_instance *int_ctx = &nss_ctx->int_ctx[irq_num]; - int err; - - if (irq_num == 1) { - int_ctx->shift_factor = 15; - err = request_irq(npd->irq[irq_num], nss_hal_handle_irq, 0, "nss_queue1", int_ctx); - } else { - int_ctx->shift_factor = 0; - err = request_irq(npd->irq[irq_num], nss_hal_handle_irq, 0, "nss", int_ctx); - } - if (err) { - nss_info_always("%px: IRQ%d request failed", nss_ctx, npd->irq[irq_num]); - return err; - } - - int_ctx->irq = npd->irq[irq_num]; - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi, 64); - - return 0; -} - -/* - * __nss_hal_init_imem - */ -void __nss_hal_init_imem(struct nss_ctx_instance *nss_ctx) -{ - struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; - - mem_ctx->imem_head = NSS_IMEM_START + NSS_IMEM_SIZE * nss_ctx->id; - mem_ctx->imem_end = mem_ctx->imem_head + NSS_IMEM_SIZE; - mem_ctx->imem_tail = mem_ctx->imem_head; - - 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); -} - -/* - * __nss_hal_init_utcm_shared - */ -bool __nss_hal_init_utcm_shared(struct nss_ctx_instance *nss_ctx, uint32_t *meminfo_start) -{ - /* - * Nothing to be done as there are no UTCM_SHARED defined for ipq806x - */ - return true; -} - -/* - * nss_hal_ipq806x_ops - */ -struct nss_hal_ops nss_hal_ipq806x_ops = { - .common_reset = __nss_hal_common_reset, - .core_reset = __nss_hal_core_reset, - .clock_configure = __nss_hal_clock_configure, - .firmware_load = nss_hal_firmware_load, - .debug_enable = __nss_hal_debug_enable, -#if (NSS_DT_SUPPORT == 1) - .of_get_pdata = __nss_hal_of_get_pdata, -#endif - .request_irq = __nss_hal_request_irq, - .send_interrupt = __nss_hal_send_interrupt, - .enable_interrupt = __nss_hal_enable_interrupt, - .disable_interrupt = __nss_hal_disable_interrupt, - .clear_interrupt_cause = __nss_hal_clear_interrupt_cause, - .read_interrupt_cause = __nss_hal_read_interrupt_cause, - .init_imem = __nss_hal_init_imem, - .init_utcm_shared = __nss_hal_init_utcm_shared, -}; diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq807x/nss_hal_pvt.c b/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq807x/nss_hal_pvt.c deleted file mode 100644 index b95a23c4b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_hal/ipq807x/nss_hal_pvt.c +++ /dev/null @@ -1,771 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_hal_pvt.c - * NSS HAL private APIs. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "nss_hal.h" -#include "nss_core.h" - -#define NSS_QGIC_IPC_REG_OFFSET 0x8 - -#define NSS0_H2N_INTR_BASE 13 -#define NSS1_H2N_INTR_BASE 19 - -/* - * Common CLKs - */ -#define NSS_NOC_CLK "nss-noc-clk" -#define NSS_PTP_REF_CLK "nss-ptp-ref-clk" -#define NSS_CSR_CLK "nss-csr-clk" -#define NSS_CFG_CLK "nss-cfg-clk" -#define NSS_IMEM_CLK "nss-imem-clk" -#define NSS_NSSNOC_QOSGEN_REF_CLK "nss-nssnoc-qosgen-ref-clk" -#define NSS_MEM_NOC_NSS_AXI_CLK "nss-mem-noc-nss-axi-clk" -#define NSS_NSSNOC_SNOC_CLK "nss-nssnoc-snoc-clk" -#define NSS_NSSNOC_TIMEOUT_REF_CLK "nss-nssnoc-timeout-ref-clk" -#define NSS_CE_AXI_CLK "nss-ce-axi-clk" -#define NSS_CE_APB_CLK "nss-ce-apb-clk" -#define NSS_NSSNOC_CE_AXI_CLK "nss-nssnoc-ce-axi-clk" -#define NSS_NSSNOC_CE_APB_CLK "nss-nssnoc-ce-apb-clk" - -/* - * Per-core CLKS - */ -#define NSS_NSSNOC_AHB_CLK "nss-nssnoc-ahb-clk" -#define NSS_CORE_CLK "nss-core-clk" -#define NSS_AHB_CLK "nss-ahb-clk" -#define NSS_AXI_CLK "nss-axi-clk" -#define NSS_MPT_CLK "nss-mpt-clk" -#define NSS_NC_AXI_CLK "nss-nc-axi-clk" - -/* - * Voltage values - */ -#define NOMINAL_VOLTAGE 1 -#define TURBO_VOLTAGE 2 - -/* - * Core reset part 1 - */ -#define NSS_CORE_GCC_RESET_1 0x00000020 - -/* - * Core reset part 2 - */ -#define NSS_CORE_GCC_RESET_2 0x00000017 - -/* - * Voltage regulator - */ -struct regulator *npu_reg; - -/* - * GCC reset - */ -void __iomem *nss_misc_reset; - -/* - * Purpose of each interrupt index: This should match the order defined in the NSS firmware - */ -enum nss_hal_n2h_intr_purpose { - NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_SOS = 0, - NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_QUEUE = 1, - NSS_HAL_N2H_INTR_PURPOSE_TX_UNBLOCKED = 2, - NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_0 = 3, - NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_1 = 4, - NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_2 = 5, - NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_3 = 6, - NSS_HAL_N2H_INTR_PURPOSE_COREDUMP_COMPLETE = 7, - NSS_HAL_N2H_INTR_PURPOSE_PAGED_EMPTY_BUFFER_SOS = 8, - NSS_HAL_N2H_INTR_PURPOSE_PROFILE_DMA = 9, - NSS_HAL_N2H_INTR_PURPOSE_MAX -}; - -/* - * Interrupt type to cause vector. - */ -static uint32_t intr_cause[NSS_MAX_CORES][NSS_H2N_INTR_TYPE_MAX] = { - /* core0 */ - {(1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_EMPTY_BUFFER_QUEUE)), - (1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_DATA_COMMAND_QUEUE)), - (1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_TX_UNBLOCKED)), - (1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_TRIGGER_COREDUMP)), - (1 << (NSS0_H2N_INTR_BASE + NSS_H2N_INTR_EMPTY_PAGED_BUFFER_QUEUE))}, - /* core 1 */ - {(1 << (NSS1_H2N_INTR_BASE + NSS_H2N_INTR_EMPTY_BUFFER_QUEUE)), - (1 << (NSS1_H2N_INTR_BASE + NSS_H2N_INTR_DATA_COMMAND_QUEUE)), - (1 << (NSS1_H2N_INTR_BASE + NSS_H2N_INTR_TX_UNBLOCKED)), - (1 << (NSS1_H2N_INTR_BASE + NSS_H2N_INTR_TRIGGER_COREDUMP)), - (1 << (NSS1_H2N_INTR_BASE + NSS_H2N_INTR_EMPTY_PAGED_BUFFER_QUEUE))} -}; - -/* - * nss_hal_wq_function() - * Added to Handle BH requests to kernel - */ -void nss_hal_wq_function(struct work_struct *work) -{ - nss_work_t *my_work = (nss_work_t *)work; - - mutex_lock(&nss_top_main.wq_lock); - - if (my_work->frequency > NSS_FREQ_1497) { - regulator_set_voltage(npu_reg, TURBO_VOLTAGE, TURBO_VOLTAGE); - } - - nss_freq_change(&nss_top_main.nss[NSS_CORE_0], my_work->frequency, my_work->stats_enable, 0); - if (nss_top_main.nss[NSS_CORE_1].state == NSS_CORE_STATE_INITIALIZED) { - nss_freq_change(&nss_top_main.nss[NSS_CORE_1], my_work->frequency, my_work->stats_enable, 0); - } - clk_set_rate(nss_core0_clk, my_work->frequency); - - nss_freq_change(&nss_top_main.nss[NSS_CORE_0], my_work->frequency, my_work->stats_enable, 1); - if (nss_top_main.nss[NSS_CORE_1].state == NSS_CORE_STATE_INITIALIZED) { - nss_freq_change(&nss_top_main.nss[NSS_CORE_1], my_work->frequency, my_work->stats_enable, 1); - } - - clk_set_rate(nss_core1_clk, my_work->frequency); - if (my_work->frequency <= NSS_FREQ_1497) { - regulator_set_voltage(npu_reg, NOMINAL_VOLTAGE, NOMINAL_VOLTAGE); - } - - mutex_unlock(&nss_top_main.wq_lock); - kfree((void *)work); -} - -/* - * nss_hal_handle_irq() - */ -static irqreturn_t nss_hal_handle_irq(int irq, void *ctx) -{ - struct int_ctx_instance *int_ctx = (struct int_ctx_instance *) ctx; - - disable_irq_nosync(irq); - napi_schedule(&int_ctx->napi); - - return IRQ_HANDLED; -} - -/* - * __nss_hal_of_get_pdata() - * Retrieve platform data from device node. - */ -static struct nss_platform_data *__nss_hal_of_get_pdata(struct platform_device *pdev) -{ - struct device_node *np = of_node_get(pdev->dev.of_node); - struct nss_platform_data *npd; - struct nss_ctx_instance *nss_ctx = NULL; - struct nss_top_instance *nss_top = &nss_top_main; - struct resource res_nphys, res_vphys, res_qgic_phys; - int32_t i; - - npd = devm_kzalloc(&pdev->dev, sizeof(struct nss_platform_data), GFP_KERNEL); - if (!npd) { - return NULL; - } - - if (of_property_read_u32(np, "qcom,id", &npd->id) - || of_property_read_u32(np, "qcom,load-addr", &npd->load_addr) - || of_property_read_u32(np, "qcom,num-queue", &npd->num_queue) - || of_property_read_u32(np, "qcom,num-irq", &npd->num_irq)) { - pr_err("%s: error reading critical device node properties\n", np->name); - goto out; - } - - /* - * Read frequencies. If failure, load default values. - */ - of_property_read_u32(np, "qcom,low-frequency", &nss_runtime_samples.freq_scale[NSS_FREQ_LOW_SCALE].frequency); - of_property_read_u32(np, "qcom,mid-frequency", &nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency); - of_property_read_u32(np, "qcom,max-frequency", &nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency); - - if (npd->num_irq > NSS_MAX_IRQ_PER_CORE) { - pr_err("%s: exceeds maximum interrupt numbers per core\n", np->name); - goto out; - } - - nss_ctx = &nss_top->nss[npd->id]; - nss_ctx->id = npd->id; - - if (of_address_to_resource(np, 0, &res_nphys) != 0) { - 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("%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("%px: nss%d: of_address_to_resource() fail for qgic_phys\n", nss_ctx, nss_ctx->id); - goto out; - } - - /* - * Save physical addresses - */ - npd->nphys = res_nphys.start; - npd->vphys = res_vphys.start; - npd->qgic_phys = res_qgic_phys.start; - - npd->nmap = ioremap_nocache(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)); - if (!npd->qgic_map) { - nss_info_always("%px: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id); - goto out; - } - - /* - * Clear TCM memory used by this core - */ - for (i = 0; i < resource_size(&res_vphys) ; i += 4) { - nss_write_32(npd->vmap, i, 0); - NSS_CORE_DMA_CACHE_MAINT((npd->vmap + i), 4, DMA_TO_DEVICE); - } - NSS_CORE_DSB(); - - /* - * Get IRQ numbers - */ - 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("%px: nss%d: irq_of_parse_and_map() fail for irq %d\n", nss_ctx, nss_ctx->id, i); - goto out; - } - } - - nss_hal_dt_parse_features(np, npd); - - of_node_put(np); - return npd; - -out: - if (npd->nmap) { - iounmap(npd->nmap); - } - - if (npd->vmap) { - iounmap(npd->vmap); - } - - devm_kfree(&pdev->dev, npd); - of_node_put(np); - return NULL; -} - -/* - * __nss_hal_core_reset() - */ -static int __nss_hal_core_reset(struct platform_device *nss_dev, void __iomem *map, uint32_t addr, uint32_t clk_src) -{ - uint32_t value; - - /* - * De-assert reset for first set - */ - value = nss_read_32(nss_misc_reset, 0x0); - value &= ~(NSS_CORE_GCC_RESET_1 << (nss_dev->id << 3)); - nss_write_32(nss_misc_reset, 0x0, value); - - /* - * Minimum 10 - 20 cycles delay is required after - * de-asserting UBI reset clamp - */ - usleep_range(10, 20); - - /* - * De-assert reset for second set - */ - value &= ~(NSS_CORE_GCC_RESET_2 << (nss_dev->id << 3)); - nss_write_32(nss_misc_reset, 0x0, value); - - /* - * Apply ubi32 core reset - */ - nss_write_32(map, NSS_REGS_RESET_CTRL_OFFSET, 1); - - /* - * Program address configuration - */ - nss_write_32(map, NSS_REGS_CORE_AMC_OFFSET, 1); - nss_write_32(map, NSS_REGS_CORE_BAR_OFFSET, 0x3c000000); - nss_write_32(map, NSS_REGS_CORE_BOOT_ADDR_OFFSET, addr); - - /* - * C2C interrupts are level sensitive - * Copy engine interrupts are level sensitive - */ - nss_write_32(map, NSS_REGS_CORE_INT_STAT2_TYPE_OFFSET, 0xFFFF); - nss_write_32(map, NSS_REGS_CORE_INT_STAT3_TYPE_OFFSET, 0xFF); - - /* - * Enable Instruction Fetch range checking between 0x4000 0000 to 0xBFFF FFFF. - */ - nss_write_32(map, NSS_REGS_CORE_IFETCH_RANGE_OFFSET, 0xBF004001); - - /* - * De-assert ubi32 core reset - */ - nss_write_32(map, NSS_REGS_RESET_CTRL_OFFSET, 0); - - return 0; -} - -/* - * __nss_hal_debug_enable() - * Enable NSS debug - */ -static void __nss_hal_debug_enable(void) -{ - -} - -/* - * nss_hal_clock_set_and_enable() - */ -static int nss_hal_clock_set_and_enable(struct device *dev, const char *id, unsigned long rate) -{ - struct clk *nss_clk = NULL; - int err; - - nss_clk = devm_clk_get(dev, id); - if (IS_ERR(nss_clk)) { - 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("%px: cannot set %s freq\n", dev, id); - return -EFAULT; - } - } - - err = clk_prepare_enable(nss_clk); - if (err) { - pr_err("%px: cannot enable clock: %s\n", dev, id); - return -EFAULT; - } - - return 0; -} - -/* - * __nss_hal_common_reset - * Do reset/clock configuration common to all cores - */ -static int __nss_hal_common_reset(struct platform_device *nss_dev) -{ - struct device_node *cmn = NULL; - struct resource res_nss_misc_reset; - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NOC_CLK, 461500000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_PTP_REF_CLK, 150000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CSR_CLK, 200000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CFG_CLK, 100000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_IMEM_CLK, 400000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NSSNOC_QOSGEN_REF_CLK, 19200000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_MEM_NOC_NSS_AXI_CLK, 461500000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NSSNOC_SNOC_CLK, 266600000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NSSNOC_TIMEOUT_REF_CLK, 4800000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CE_AXI_CLK, 200000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CE_APB_CLK, 200000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NSSNOC_CE_AXI_CLK, 200000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NSSNOC_CE_APB_CLK, 200000000)) { - return -EFAULT; - } - - /* - * Get reference to NSS common device node - */ - cmn = of_find_node_by_name(NULL, "nss-common"); - if (!cmn) { - 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("%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)); - if (!nss_misc_reset) { - pr_err("%px: ioremap fail for nss_misc_reset\n", nss_dev); - return -EFAULT; - } - - nss_top_main.nss_hal_common_init_done = true; - nss_info("nss_hal_common_reset Done\n"); - return 0; -} - -/* - * __nss_hal_clock_configure() - */ -static int __nss_hal_clock_configure(struct nss_ctx_instance *nss_ctx, struct platform_device *nss_dev, struct nss_platform_data *npd) -{ - uint32_t i; - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NSSNOC_AHB_CLK, 200000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_AHB_CLK, 200000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_AXI_CLK, 461500000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_MPT_CLK, 25000000)) { - return -EFAULT; - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NC_AXI_CLK, 461500000)) { - return -EFAULT; - } - - /* - * For IPQ807x, any rate above 1497 is Turbo Voltage - * Temporary set the voltage to turbo till we start scaling frequenices. - * This is to ensure probing is safe and autoscaling will correct the voltage. - */ - if (!nss_ctx->id) { - npu_reg = devm_regulator_get(&nss_dev->dev, "npu"); - if (IS_ERR(npu_reg)) { - return PTR_ERR(npu_reg); - } - if (regulator_enable(npu_reg)) { - return -EFAULT; - } - regulator_set_voltage(npu_reg, TURBO_VOLTAGE, TURBO_VOLTAGE); - } - - /* - * No entries, then just load default - */ - if ((nss_runtime_samples.freq_scale[NSS_FREQ_LOW_SCALE].frequency == 0) || - (nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency == 0) || - (nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency == 0)) { - nss_runtime_samples.freq_scale[NSS_FREQ_LOW_SCALE].frequency = NSS_FREQ_187; - nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency = NSS_FREQ_748; - nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency = NSS_FREQ_1497; - nss_info_always("Running default frequencies\n"); - } - - /* - * Test frequency from dtsi, if fail, try to set default frequency. - */ - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, nss_runtime_samples.freq_scale[NSS_FREQ_HIGH_SCALE].frequency)) { - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, NSS_FREQ_1497)) { - return -EFAULT; - } - } - - /* - * Setup ranges, test frequency, and display. - */ - for (i = 0; i < NSS_FREQ_MAX_SCALE; i++) { - if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_187) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_187_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_187_MAX; - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_748) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_748_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_748_MAX; - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_1497) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_1497_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_1497_MAX; - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_1689) { - nss_runtime_samples.freq_scale[i].minimum = NSS_FREQ_1689_MIN; - nss_runtime_samples.freq_scale[i].maximum = NSS_FREQ_1689_MAX; - } else { - nss_info_always("Frequency not found %d\n", nss_runtime_samples.freq_scale[i].frequency); - return -EFAULT; - } - - /* - * Test the frequency, if fail, then default to safe frequency and abort - */ - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, nss_runtime_samples.freq_scale[i].frequency)) { - return -EFAULT; - } - } - - nss_info_always("Supported Frequencies - "); - for (i = 0; i < NSS_FREQ_MAX_SCALE; i++) { - if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_187) { - nss_info_always("187.2 MHz "); - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_748) { - nss_info_always("748.8 MHz "); - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_1497) { - nss_info_always("1.4976 GHz "); - } else if (nss_runtime_samples.freq_scale[i].frequency == NSS_FREQ_1689) { - nss_info_always("1.6896 GHz "); - } else { - nss_info_always("Error\nNo Table/Invalid Frequency Found\n"); - return -EFAULT; - } - } - nss_info_always("\n"); - - /* - * Set values only once for core0. Grab the proper clock. - */ - if (nss_ctx->id) { - nss_core1_clk = clk_get(&nss_dev->dev, NSS_CORE_CLK); - } else { - nss_core0_clk = clk_get(&nss_dev->dev, NSS_CORE_CLK); - } - - if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_CORE_CLK, nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency)) { - return -EFAULT; - } - - return 0; -} - -/* - * __nss_hal_read_interrupt_cause() - */ -static void __nss_hal_read_interrupt_cause(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t *cause) -{ -} - -/* - * __nss_hal_clear_interrupt_cause() - */ -static void __nss_hal_clear_interrupt_cause(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ -} - -/* - * __nss_hal_disable_interrupt() - */ -static void __nss_hal_disable_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ -} - -/* - * __nss_hal_enable_interrupt() - */ -static void __nss_hal_enable_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t shift_factor, uint32_t cause) -{ -} - -/* - * __nss_hal_send_interrupt() - */ -static void __nss_hal_send_interrupt(struct nss_ctx_instance *nss_ctx, uint32_t type) -{ - /* - * Check if core and type is Valid - */ - nss_assert(nss_ctx->id < nss_top_main.num_nss); - nss_assert(type < NSS_H2N_INTR_TYPE_MAX); - - nss_write_32(nss_ctx->qgic_map, NSS_QGIC_IPC_REG_OFFSET, intr_cause[nss_ctx->id][type]); -} - -/* - * __nss_hal_request_irq() - */ -static int __nss_hal_request_irq(struct nss_ctx_instance *nss_ctx, struct nss_platform_data *npd, int irq_num) -{ - struct int_ctx_instance *int_ctx = &nss_ctx->int_ctx[irq_num]; - int err = -1, irq = npd->irq[irq_num]; - - irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY); - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_SOS) { - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); - int_ctx->cause = NSS_N2H_INTR_EMPTY_BUFFERS_SOS; - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_empty_buf_sos", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_QUEUE) { - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT); - int_ctx->cause = NSS_N2H_INTR_EMPTY_BUFFER_QUEUE; - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_empty_buf_queue", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_TX_UNBLOCKED) { - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_TX_UNBLOCKED_PROCESSING_WEIGHT); - int_ctx->cause = NSS_N2H_INTR_TX_UNBLOCKED; - err = request_irq(irq, nss_hal_handle_irq, 0, "nss-tx-unblock", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_0) { - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); - int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_0; - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue0", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_1) { - int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_1; - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue1", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_2) { - int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_2; - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue2", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_3) { - int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_3; - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue3", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_COREDUMP_COMPLETE) { - int_ctx->cause = NSS_N2H_INTR_COREDUMP_COMPLETE; - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_emergency, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_coredump_complete", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_PAGED_EMPTY_BUFFER_SOS) { - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT); - int_ctx->cause = NSS_N2H_INTR_PAGED_EMPTY_BUFFERS_SOS; - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_paged_empty_buf_sos", int_ctx); - } - - if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_PROFILE_DMA) { - int_ctx->cause = NSS_N2H_INTR_PROFILE_DMA; - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_sdma, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT); - err = request_irq(irq, nss_hal_handle_irq, 0, "nss_profile_dma", int_ctx); - } - - if (err) { - return err; - } - - int_ctx->irq = irq; - return 0; -} - -/* - * __nss_hal_init_imem - */ -void __nss_hal_init_imem(struct nss_ctx_instance *nss_ctx) -{ - struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; - - mem_ctx->imem_head = NSS_IMEM_START + NSS_IMEM_SIZE * nss_ctx->id; - mem_ctx->imem_end = mem_ctx->imem_head + NSS_IMEM_SIZE; - mem_ctx->imem_tail = mem_ctx->imem_head; - - 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); -} - -/* - * __nss_hal_init_utcm_shared - */ -bool __nss_hal_init_utcm_shared(struct nss_ctx_instance *nss_ctx, uint32_t *meminfo_start) -{ - /* - * Nothing to be done as there are no TCM in ipq807x - */ - return true; -} - -/* - * nss_hal_ipq807x_ops - */ -struct nss_hal_ops nss_hal_ipq807x_ops = { - .common_reset = __nss_hal_common_reset, - .core_reset = __nss_hal_core_reset, - .clock_configure = __nss_hal_clock_configure, - .firmware_load = nss_hal_firmware_load, - .debug_enable = __nss_hal_debug_enable, - .of_get_pdata = __nss_hal_of_get_pdata, - .request_irq = __nss_hal_request_irq, - .send_interrupt = __nss_hal_send_interrupt, - .enable_interrupt = __nss_hal_enable_interrupt, - .disable_interrupt = __nss_hal_disable_interrupt, - .clear_interrupt_cause = __nss_hal_clear_interrupt_cause, - .read_interrupt_cause = __nss_hal_read_interrupt_cause, - .init_imem = __nss_hal_init_imem, - .init_utcm_shared = __nss_hal_init_utcm_shared, -}; diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_hal/nss_hal.c b/feeds/ipq807x/qca-nss-drv/src/nss_hal/nss_hal.c deleted file mode 100644 index 30085e010..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_hal/nss_hal.c +++ /dev/null @@ -1,834 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_hal.c - * NSS HAL general APIs. - */ - -#include -#include -#include -#include -#include - -#include "nss_hal.h" -#include "nss_arch.h" -#include "nss_core.h" -#include "nss_tx_rx_common.h" -#include "nss_data_plane.h" -#if (NSS_PM_SUPPORT == 1) -#include "nss_pm.h" -#endif -#if (NSS_FABRIC_SCALING_SUPPORT == 1) -#include -#endif - -/* - * Macros - */ -#define MIN_IMG_SIZE (64*1024) -#define NSS_AP0_IMAGE "qca-nss0.bin" -#define NSS_AP1_IMAGE "qca-nss1.bin" - -/* - * File local/Static variables/functions - */ -static const struct net_device_ops nss_netdev_ops; -static const struct ethtool_ops nss_ethtool_ops; - -int nss_hal_firmware_load(struct nss_ctx_instance *nss_ctx, struct platform_device *nss_dev, struct nss_platform_data *npd) -{ - const struct firmware *nss_fw; - void __iomem *load_mem; - int rc; - - if (nss_ctx->id == 0) { - rc = request_firmware(&nss_fw, NSS_AP0_IMAGE, &(nss_dev->dev)); - } else if (nss_ctx->id == 1) { - rc = request_firmware(&nss_fw, NSS_AP1_IMAGE, &(nss_dev->dev)); - } else { - nss_warning("%px: Invalid nss dev: %d\n", nss_ctx, nss_ctx->id); - return -EINVAL; - } - - /* - * Check if the file read is successful - */ - if (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("%px: nss firmware is truncated, size:%d", nss_ctx, (int)nss_fw->size); - return rc; - } - - load_mem = ioremap_nocache(npd->load_addr, nss_fw->size); - if (!load_mem) { - nss_info_always("%px: ioremap_nocache failed: %x", nss_ctx, npd->load_addr); - release_firmware(nss_fw); - return rc; - } - - nss_info_always("nss_driver - fw of size %d bytes copied to load addr: %x, nss_id : %d\n", (int)nss_fw->size, npd->load_addr, nss_dev->id); - memcpy_toio(load_mem, nss_fw->data, nss_fw->size); - release_firmware(nss_fw); - iounmap(load_mem); - return 0; -} - -/* - * nss_hal_dt_parse_features() - */ -void nss_hal_dt_parse_features(struct device_node *np, struct nss_platform_data *npd) -{ - /* - * Read the features in - */ - 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"); - npd->ipv6_enabled = of_property_read_bool(np, "qcom,ipv6-enabled"); - npd->ipv6_reasm_enabled = of_property_read_bool(np, "qcom,ipv6-reasm-enabled"); - npd->l2tpv2_enabled = of_property_read_bool(np, "qcom,l2tpv2-enabled"); - npd->map_t_enabled = of_property_read_bool(np, "qcom,map-t-enabled"); - npd->oam_enabled = of_property_read_bool(np, "qcom,oam-enabled"); - npd->ppe_enabled = of_property_read_bool(np, "qcom,ppe-enabled"); - npd->pppoe_enabled = of_property_read_bool(np, "qcom,pppoe-enabled"); - 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->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"); -} -/* - * nss_hal_clean_up_irq() - */ -static void nss_hal_clean_up_irq(struct int_ctx_instance *int_ctx) -{ - if (!int_ctx->irq) { - return; - } - - /* - * Wait here till the poll is complete. - */ - napi_disable(&int_ctx->napi); - - /* - * Interrupt can be raised here before free_irq() but as napi is - * already disabled, it will be never sheduled from hard_irq - * context. - */ - irq_clear_status_flags(int_ctx->irq, IRQ_DISABLE_UNLAZY); - free_irq(int_ctx->irq, int_ctx); - int_ctx->irq = 0; - - netif_napi_del(&int_ctx->napi); -} - -/* - * nss_hal_register_irq() - */ -static int nss_hal_register_irq(struct nss_ctx_instance *nss_ctx, struct nss_platform_data *npd, - struct net_device *netdev, int irq_num) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct int_ctx_instance *int_ctx = &nss_ctx->int_ctx[irq_num]; - int err = 0; - - /* - * request for IRQs - */ - int_ctx->nss_ctx = nss_ctx; - err = nss_top->hal_ops->request_irq(nss_ctx, npd, irq_num); - if (err) { - nss_warning("%px: IRQ request for queue %d failed", nss_ctx, irq_num); - return err; - } - - /* - * Register NAPI for NSS core interrupt - */ - napi_enable(&int_ctx->napi); - return 0; -} - -/* - * nss_hal_probe() - * HLOS device probe callback - */ -int nss_hal_probe(struct platform_device *nss_dev) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = NULL; - struct nss_platform_data *npd = NULL; - int i, err = 0; -#ifdef NSS_DRV_TSTAMP_ENABLE - struct net_device *tstamp_ndev = NULL; -#endif - - if (nss_top_main.nss_hal_common_init_done == false) { - err = nss_top->hal_ops->common_reset(nss_dev); - if (err) { - nss_info_always("NSS HAL common init failed\n"); - return -EFAULT; - } - } - -#if (NSS_DT_SUPPORT == 1) - if (!nss_dev->dev.of_node) { - pr_err("nss-driver: Device tree not available\n"); - return -ENODEV; - } - - npd = nss_top->hal_ops->of_get_pdata(nss_dev); - if (!npd) { - return -EFAULT; - } - - nss_ctx = &nss_top->nss[npd->id]; - nss_ctx->id = npd->id; - nss_dev->id = nss_ctx->id; -#else - npd = (struct nss_platform_data *) nss_dev->dev.platform_data; - nss_ctx = &nss_top->nss[nss_dev->id]; - nss_ctx->id = nss_dev->id; -#endif - nss_ctx->num_irq = npd->num_irq; - nss_ctx->nss_top = nss_top; - - /* - * dev is required for dma map/unmap - */ - nss_ctx->dev = &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("%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("%px: clock configure failed\n", nss_ctx); - goto err_init; - } - - /* - * Get load address of NSS firmware - */ - 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; - - /* - * Get virtual and physical memory addresses for nss logical/hardware address maps - */ - - /* - * Virtual address of CSM space - */ - nss_ctx->nmap = npd->nmap; - - /* - * Physical address of CSM space - */ - nss_ctx->nphys = npd->nphys; - nss_assert(nss_ctx->nphys); - - /* - * Virtual address of logical registers space - */ - nss_ctx->vmap = npd->vmap; - - /* - * Virtual address of QGIC interrupt space - */ - nss_ctx->qgic_map = npd->qgic_map; - - /* - * Physical address of logical registers space - */ - nss_ctx->vphys = npd->vphys; - 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("%px: meminfo init failed\n", nss_ctx); - err = -EFAULT; - goto err_init; - } - - /* - * Initialize the dummy netdevice. - */ - init_dummy_netdev(&nss_ctx->napi_ndev); - - for (i = 0; i < npd->num_irq; i++) { - err = nss_hal_register_irq(nss_ctx, npd, &nss_ctx->napi_ndev, i); - if (err) { - goto err_register_irq; - } - } - -#ifdef NSS_DRV_TSTAMP_ENABLE - /* - * Allocate tstamp net_device and register the net_device - */ - if (npd->tstamp_enabled == NSS_FEATURE_ENABLED) { - tstamp_ndev = nss_tstamp_register_netdev(); - if (!tstamp_ndev) { - 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; - nss_tstamp_register_handler(tstamp_ndev); - } -#endif - /* - * Initialize the handlers for all interfaces associated with core - */ - nss_core_init_handlers(nss_ctx); - - /* - * Features that will always be enabled on both cores - */ - nss_dynamic_interface_register_handler(nss_ctx); - nss_n2h_register_handler(nss_ctx); - nss_project_register_handler(nss_ctx); -#ifdef NSS_DRV_QRFS_ENABLE - nss_qrfs_register_handler(nss_ctx); -#endif - -#ifdef NSS_DRV_C2C_ENABLE - nss_c2c_tx_register_handler(nss_ctx); - nss_c2c_rx_register_handler(nss_ctx); -#endif - nss_unaligned_register_handler(nss_ctx); - - /* - * Check functionalities are supported by this NSS core - */ -#ifdef NSS_DRV_SHAPER_ENABLE - if (npd->shaping_enabled == NSS_FEATURE_ENABLED) { - nss_top->shaping_handler_id = nss_dev->id; - nss_info("%d: NSS shaping is enabled", nss_dev->id); - } -#endif - - if (npd->ipv4_enabled == NSS_FEATURE_ENABLED) { - 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(); -#endif -#ifdef NSS_DRV_TRUSTSEC_ENABLE - nss_top->trustsec_tx_handler_id = nss_dev->id; - nss_trustsec_tx_register_handler(); -#endif - - nss_top->virt_if_handler_id = nss_dev->id; - - 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; - } - -#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; - } -#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 - /* - * TODO: when Crypto is moved to Core-1 it needs to - * flush based on nss_top->crypto_enabled - */ - 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) - nss_crypto_cmn_register_handler(); -#else - 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 - -#ifdef NSS_DRV_IPSEC_ENABLE - if (npd->ipsec_enabled == NSS_FEATURE_ENABLED) { - nss_top->ipsec_handler_id = nss_dev->id; -#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_IPSEC_CMN_INNER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_OUTER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_MDATA_INNER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_MDATA_OUTER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_REDIRECT] = nss_dev->id; - nss_ipsec_cmn_register_handler(); -#else - nss_ipsec_register_handler(); -#endif - } -#endif - - if (npd->wlanredirect_enabled == NSS_FEATURE_ENABLED) { - nss_top->wlan_handler_id = nss_dev->id; - } - -#ifdef NSS_DRV_TUN6RD_ENABLE - if (npd->tun6rd_enabled == NSS_FEATURE_ENABLED) { - nss_top->tun6rd_handler_id = nss_dev->id; - } -#endif - -#ifdef NSS_DRV_PPTP_ENABLE - if (npd->pptp_enabled == NSS_FEATURE_ENABLED) { - nss_top->pptp_handler_id = nss_dev->id; - nss_pptp_register_handler(); - } -#endif - - if (npd->pppoe_enabled == NSS_FEATURE_ENABLED) { - nss_top->pppoe_handler_id = nss_dev->id; - nss_pppoe_register_handler(); - } - -#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) { - nss_top->l2tpv2_handler_id = nss_dev->id; - nss_l2tpv2_register_handler(); - } -#endif - -#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) - 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(); -#else - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_DTLS] = nss_dev->id; - nss_dtls_register_handler(); -#endif - } -#endif - -#ifdef NSS_DRV_MAPT_ENABLE - if (npd->map_t_enabled == NSS_FEATURE_ENABLED) { - nss_top->map_t_handler_id = nss_dev->id; - nss_map_t_register_handler(); - } -#endif - -#ifdef NSS_DRV_TUNIPIP6_ENABLE - if (npd->tunipip6_enabled == NSS_FEATURE_ENABLED) { - nss_top->tunipip6_handler_id = nss_dev->id; - nss_tunipip6_register_handler(); - } -#endif - -#ifdef NSS_DRV_GRE_ENABLE - if (npd->gre_enabled == NSS_FEATURE_ENABLED) { - nss_top->gre_handler_id = nss_dev->id; - nss_gre_register_handler(); - } -#endif - -#ifdef NSS_DRV_GRE_REDIR_ENABLE - if (npd->gre_redir_enabled == NSS_FEATURE_ENABLED) { - nss_top->gre_redir_handler_id = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_HOST_INNER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_OFFL_INNER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_SJACK_INNER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_OUTER] = nss_dev->id; - nss_gre_redir_register_handler(); - nss_gre_redir_lag_us_register_handler(); - nss_gre_redir_lag_ds_register_handler(); -#ifdef NSS_DRV_SJACK_ENABLE - nss_top->sjack_handler_id = nss_dev->id; - nss_sjack_register_handler(); -#endif - - } - - if (npd->gre_redir_mark_enabled == NSS_FEATURE_ENABLED) { - nss_top->gre_redir_mark_handler_id = nss_dev->id; - nss_gre_redir_mark_register_handler(); - } -#endif - -#ifdef NSS_DRV_GRE_TUNNEL_ENABLE - if (npd->gre_tunnel_enabled == NSS_FEATURE_ENABLED) { - nss_top->gre_tunnel_handler_id = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INNER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_OUTER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INLINE_INNER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INLINE_OUTER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INNER_EXCEPTION] = nss_dev->id; - } -#endif - -#ifdef NSS_DRV_PORTID_ENABLE - if (npd->portid_enabled == NSS_FEATURE_ENABLED) { - nss_top->portid_handler_id = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_PORTID] = nss_dev->id; - nss_portid_register_handler(); - } -#endif - - 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 - 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); - } - -#ifdef NSS_DRV_OAM_ENABLE - if (npd->oam_enabled == NSS_FEATURE_ENABLED) { - nss_top->oam_handler_id = nss_dev->id; - nss_oam_register_handler(); - } -#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 - - 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(); - } - -#ifdef NSS_DRV_QVPN_ENABLE -#if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) - if (npd->qvpn_enabled == NSS_FEATURE_ENABLED) { - nss_top->qvpn_handler_id = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_QVPN_OUTER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_QVPN_INNER] = nss_dev->id; - nss_qvpn_register_handler(); - } -#endif -#endif - -#ifdef NSS_DRV_PVXLAN_ENABLE - if (npd->pvxlan_enabled == NSS_FEATURE_ENABLED) { - nss_top->pvxlan_handler_id = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_PVXLAN_HOST_INNER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_PVXLAN_OUTER] = nss_dev->id; - } -#endif - -#ifdef NSS_DRV_RMNET_ENABLE - if (npd->rmnet_rx_enabled == NSS_FEATURE_ENABLED) { - nss_top->rmnet_rx_handler_id = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_N2H] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_H2N] = nss_dev->id; - } -#endif - -#ifdef NSS_DRV_IGS_ENABLE - if (npd->igs_enabled == NSS_FEATURE_ENABLED) { - nss_top->igs_handler_id = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_IGS] = nss_dev->id; - nss_info("%d: NSS IGS is enabled", nss_dev->id); - } -#endif - -#ifdef NSS_DRV_CLMAP_ENABLE - if (npd->clmap_enabled == NSS_FEATURE_ENABLED) { - nss_top->clmap_handler_id = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_US] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_DS] = nss_dev->id; - } -#endif - -#ifdef NSS_DRV_VXLAN_ENABLE - if (npd->vxlan_enabled == NSS_FEATURE_ENABLED) { - nss_top->vxlan_handler_id = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_INNER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_OUTER] = nss_dev->id; - nss_vxlan_init(); - } -#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 - -#ifdef NSS_DRV_TLS_ENABLE -#if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) - if (npd->tls_enabled == NSS_FEATURE_ENABLED) { - nss_top->tls_handler_id = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_TLS_INNER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_TLS_OUTER] = nss_dev->id; - nss_tls_register_handler(); - } -#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 - -#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) { -#if (NSS_FREQ_SCALE_SUPPORT == 1) - nss_freq_register_handler(); - - /* - * Init CPU usage detail - * Note: As of now, ubi cpu usage is supported only for core0 - */ - nss_freq_init_cpu_usage(); -#endif - - nss_lso_rx_register_handler(nss_ctx); - } - - nss_top->frequency_handler_id = nss_dev->id; - - /* - * Initialize decongestion callbacks to NULL - */ - for (i = 0; i < NSS_MAX_CLIENTS; i++) { - nss_ctx->queue_decongestion_callback[i] = 0; - nss_ctx->queue_decongestion_ctx[i] = 0; - } - - spin_lock_init(&(nss_ctx->decongest_cb_lock)); - nss_ctx->magic = NSS_CTX_MAGIC; - - nss_info("%px: Reseting NSS core %d now", nss_ctx, nss_ctx->id); - - /* - * Enable clocks and bring NSS core out of reset - */ - err = nss_top->hal_ops->core_reset(nss_dev, nss_ctx->nmap, nss_ctx->load, nss_top->clk_src); - if (err) { - goto err_register_irq; - } - - /* - * Initialize max buffer size for NSS core - */ - nss_ctx->max_buf_size = NSS_NBUF_PAYLOAD_SIZE; - - /* - * Initialize S/G status pointers to NULL - */ - for (i = 0; i < NSS_N2H_DESC_RING_NUM; i++) { - nss_ctx->n2h_desc_ring[i].head = NULL; - nss_ctx->n2h_desc_ring[i].tail = NULL; - nss_ctx->n2h_desc_ring[i].jumbo_start = NULL; - } - - /* - * Enable interrupts for NSS core. - */ - for (i = 0; i < npd->num_irq; i++) { - nss_hal_enable_interrupt(nss_ctx, nss_ctx->int_ctx[i].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS); - } - - 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: - for (i = 0; i < npd->num_irq; i++) { - nss_hal_clean_up_irq(&nss_ctx->int_ctx[i]); - } - -err_init: - if (nss_dev->dev.of_node) { - if (npd->nmap) { - iounmap(npd->nmap); - } - - if (npd->vmap) { - iounmap(npd->vmap); - } - } - -out: - if (nss_dev->dev.of_node) { - devm_kfree(&nss_dev->dev, npd); - } - return err; -} - -/* - * nss_hal_remove() - * HLOS device remove callback - */ -int nss_hal_remove(struct platform_device *nss_dev) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[nss_dev->id]; - int i; - - /* - * Clean up debugfs - */ - nss_stats_clean(); - - /* - * Clear up the resources associated with the interrupt - */ - for (i = 0; i < nss_ctx->num_irq; i++) { - nss_hal_disable_interrupt(nss_ctx, nss_ctx->int_ctx[i].shift_factor, - NSS_HAL_SUPPORTED_INTERRUPTS); - nss_hal_clean_up_irq(&nss_ctx->int_ctx[i]); - } - - /* - * nss-drv is exiting, unregister and restore host data plane - */ - nss_top->data_plane_ops->data_plane_unregister(); - -#if (NSS_FABRIC_SCALING_SUPPORT == 1) - fab_scaling_unregister(nss_core0_clk); -#endif - - if (nss_dev->dev.of_node) { - if (nss_ctx->nmap) { - iounmap(nss_ctx->nmap); - nss_ctx->nmap = 0; - } - - if (nss_ctx->vmap) { - iounmap(nss_ctx->vmap); - nss_ctx->vmap = 0; - } - } - - nss_info("%px: All resources freed for nss core%d", nss_ctx, nss_dev->id); - return 0; -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_hlos_if.h b/feeds/ipq807x/qca-nss-drv/src/nss_hlos_if.h deleted file mode 100644 index fdcf21b8c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_hlos_if.h +++ /dev/null @@ -1,381 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_hlos_if.h - * NSS to HLOS interface definitions. - */ - -#ifndef __NSS_HLOS_IF_H -#define __NSS_HLOS_IF_H - -#define NSS_MIN_NUM_CONN 256 /* MIN Connection shared between IPv4 and IPv6 */ -#define NSS_FW_DEFAULT_NUM_CONN 1024 /* Firmware default number of connections for IPv4 and IPv6 */ -#define NSS_NUM_CONN_QUANTA_MASK (1024 - 1) /* Quanta of number of connections 1024 */ -#define NSS_CONN_CFG_TIMEOUT 6000 /* 6 sec timeout for connection cfg message */ - -/* - * The following definitions sets the maximum number of connections - * based on the type of memory profile that the system is operating with - */ -#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 */ -#define NSS_MAX_TOTAL_NUM_CONN_IPV4_IPV6 4096 /* MAX Connection shared between IPv4 and IPv6 for medium memory profile */ -#else -#define NSS_DEFAULT_NUM_CONN 4096 /* Default number of connections for each IPv4 and IPv6 */ -#define NSS_MAX_TOTAL_NUM_CONN_IPV4_IPV6 8192 /* MAX Connection shared between IPv4 and IPv6 */ -#endif - -#if defined(NSS_SKB_FIXED_SIZE_2K) && !defined(__LP64__) -#define NSS_EMPTY_BUFFER_SIZE 1792 /* Default buffer size for reduced memory profiles. */ -#define NSS_FIXED_BUFFER_SIZE /* For low memory profiles, maximum buffer size/MTU is fixed */ -#else -#define NSS_EMPTY_BUFFER_SIZE 1984 /* Default buffer size for regular memory profiles. */ -#undef NSS_FIXED_BUFFER_SIZE -#endif - -enum { - NSS_SUCCESS = 0, - NSS_FAILURE = 1, -}; - -/* - * Request/Response types - */ -enum nss_if_metadata_types { - NSS_TX_METADATA_TYPE_INTERFACE_OPEN, - NSS_TX_METADATA_TYPE_INTERFACE_CLOSE, - NSS_TX_METADATA_TYPE_INTERFACE_LINK_STATE_NOTIFY, - NSS_TX_METADATA_TYPE_INTERFACE_MTU_CHANGE, - NSS_TX_METADATA_TYPE_INTERFACE_MAC_ADDR_SET, - NSS_TX_METADATA_TYPE_INTERFACE_MSS_SET, - NSS_RX_METADATA_TYPE_INTERFACE_STATS_SYNC, - NSS_METADATA_TYPE_INTERFACE_MAX, -}; - -/* - * General statistics messages - */ - -/* - * IPv4 reasm node stats - */ -struct nss_ipv4_reasm_stats_sync { - struct nss_cmn_node_stats node_stats; - /* Common node stats for ipv4_reasm */ - uint32_t ipv4_reasm_evictions; - uint32_t ipv4_reasm_alloc_fails; - uint32_t ipv4_reasm_timeouts; -}; - -/* - * IPv4 reasm message types - */ -enum nss_ipv4_reasm_message_types { - NSS_IPV4_REASM_STATS_SYNC_MSG, -}; - -/* - * IPv4 reassembly message structure - */ -struct nss_ipv4_reasm_msg { - struct nss_cmn_msg cm; - union { - struct nss_ipv4_reasm_stats_sync stats_sync; - } msg; -}; - -/* - * IPv6 reasm node stats - */ -struct nss_ipv6_reasm_stats_sync { - struct nss_cmn_node_stats node_stats; - /* Common node stats for ipv6_reasm */ - uint32_t ipv6_reasm_alloc_fails; - uint32_t ipv6_reasm_timeouts; - uint32_t ipv6_reasm_discards; -}; - -/* - * IPv6 reasm message types - */ -enum nss_ipv6_reasm_message_types { - NSS_IPV6_REASM_STATS_SYNC_MSG, -}; - -/* - * IPv6 reassembly message structure - */ -struct nss_ipv6_reasm_msg { - struct nss_cmn_msg cm; - union { - struct nss_ipv6_reasm_stats_sync stats_sync; - } msg; -}; - -/* - * Generic interface messages - */ -enum nss_generic_metadata_types { - NSS_TX_METADATA_TYPE_GENERIC_IF_PARAMS, - NSS_METADATA_TYPE_GENERIC_IF_MAX -}; - -/* - * Interface params command - */ -struct nss_generic_if_params { - uint8_t buf[1]; /* Buffer */ -}; - -/* - * Message structure to send/receive ipsec messages - */ -struct nss_generic_msg { - struct nss_cmn_msg cm; /* Message Header */ - union { - struct nss_generic_if_params rule; /* Message: generic rule */ - } msg; -}; - -/* - * NSS frequency scaling messages - */ -enum nss_freq_stats_metadata_types { - COREFREQ_METADATA_TYPE_ERROR, - COREFREQ_METADATA_TYPE_RX_FREQ_CHANGE, - COREFREQ_METADATA_TYPE_TX_FREQ_ACK, - COREFREQ_METADATA_TYPE_TX_CORE_STATS, - COREFREQ_METADATA_TYPE_MAX, -}; - - /* - * Types of TX metadata -- legacy code needs to be removed - */ -enum nss_tx_metadata_types { - NSS_TX_METADATA_TYPE_LEGACY_0, - NSS_TX_METADATA_TYPE_NSS_FREQ_CHANGE, - NSS_TX_METADATA_TYPE_SHAPER_CONFIGURE, -}; - -/* - * The NSS freq start or stop strcture - */ -struct nss_freq_msg { - /* Request */ - uint32_t frequency; - uint32_t start_or_end; - uint32_t stats_enable; - - /* Response */ - uint32_t freq_current; - int32_t ack; -}; - -/* - * NSS core stats - */ -struct nss_core_stats { - uint32_t inst_cnt_total; -}; - -/* - * Message structure to send/receive NSS Freq commands - */ -struct nss_corefreq_msg { - struct nss_cmn_msg cm; /* Message Header */ - union { - struct nss_freq_msg nfc; /* Message: freq stats */ - struct nss_core_stats ncs; /* Message: NSS stats sync */ - } msg; -}; - -/* - * H2N Buffer Types - */ -#define H2N_BUFFER_EMPTY 0 -#define H2N_PAGED_BUFFER_EMPTY 1 -#define H2N_BUFFER_PACKET 2 -#define H2N_BUFFER_CTRL 4 -#define H2N_BUFFER_NATIVE_WIFI 8 -#define H2N_BUFFER_SHAPER_BOUNCE_INTERFACE 9 -#define H2N_BUFFER_SHAPER_BOUNCE_BRIDGE 10 -#define H2N_BUFFER_RATE_TEST 14 -#define H2N_BUFFER_MAX 16 - -/* - * H2N Bit Flag Definitions - */ -#define H2N_BIT_FLAG_GEN_IPV4_IP_CHECKSUM 0x0001 -#define H2N_BIT_FLAG_GEN_IP_TRANSPORT_CHECKSUM 0x0002 -#define H2N_BIT_FLAG_FIRST_SEGMENT 0x0004 -#define H2N_BIT_FLAG_LAST_SEGMENT 0x0008 - -#define H2N_BIT_FLAG_GEN_IP_TRANSPORT_CHECKSUM_NONE 0x0010 -#define H2N_BIT_FLAG_TX_TS_REQUIRED 0x0040 -#define H2N_BIT_FLAG_DISCARD 0x0080 -#define H2N_BIT_FLAG_SEGMENTATION_ENABLE 0x0100 - -#define H2N_BIT_FLAG_VIRTUAL_BUFFER 0x2000 -#define H2N_BIT_FLAG_BUFFER_REUSABLE 0x8000 - -/* - * HLOS to NSS descriptor structure. - */ -struct h2n_descriptor { - uint32_t interface_num; /* Interface number to which the buffer is to be sent (where appropriate) */ - uint32_t buffer; /* Physical buffer address. This is the address of the start of the usable buffer being provided by the HLOS */ - uint32_t qos_tag; /* QoS tag information of the buffer (where appropriate) */ - uint16_t buffer_len; /* Length of the buffer (in bytes) */ - uint16_t payload_len; /* Length of the active payload of the buffer (in bytes) */ - uint16_t mss; /* MSS to be used with TSO/UFO */ - uint16_t payload_offs; /* Offset from the start of the buffer to the start of the payload (in bytes) */ - uint16_t bit_flags; /* Bit flags associated with the buffer */ - uint8_t buffer_type; /* Type of buffer */ - uint8_t reserved; /* Reserved for future use */ - nss_ptr_t opaque; /* 32 or 64-bit value provided by the HLOS to associate with the buffer. The cookie has no meaning to the NSS */ -#ifndef __LP64__ - uint32_t padding; /* Pad to fit 64bits, do not reuse */ -#endif -}; - -/* - * N2H Buffer Types - */ -#define N2H_BUFFER_EMPTY 1 -#define N2H_BUFFER_PACKET 3 -#define N2H_BUFFER_COMMAND_RESP 5 -#define N2H_BUFFER_STATUS 6 -#define N2H_BUFFER_CRYPTO_RESP 8 -#define N2H_BUFFER_PACKET_VIRTUAL 10 -#define N2H_BUFFER_SHAPER_BOUNCED_INTERFACE 11 -#define N2H_BUFFER_SHAPER_BOUNCED_BRIDGE 12 -#define N2H_BUFFER_PACKET_EXT 13 -#define N2H_BUFFER_RATE_TEST 14 -#define N2H_BUFFER_MAX 16 - -/* - * Command Response Types - */ -#define N2H_COMMAND_RESP_OK 0 -#define N2H_COMMAND_RESP_BUFFER_TOO_SMALL 1 -#define N2H_COMMAND_RESP_BUFFER_NOT_WRITEABLE 2 -#define N2H_COMMAND_RESP_UNSUPPORTED_COMMAND 3 -#define N2H_COMMAND_RESP_INVALID_PARAMETERS 4 -#define N2H_COMMAND_RESP_INACTIVE_SUBSYSTEM 5 - -/* - * N2H Bit Flag Definitions - */ -#define N2H_BIT_FLAG_IPV4_IP_CHECKSUM_VALID 0x0001 -#define N2H_BIT_FLAG_IP_TRANSPORT_CHECKSUM_VALID 0x0002 -#define N2H_BIT_FLAG_FIRST_SEGMENT 0x0004 -#define N2H_BIT_FLAG_LAST_SEGMENT 0x0008 -#define N2H_BIT_FLAG_INGRESS_SHAPED 0x0010 - -/* - * NSS to HLOS descriptor structure - */ -struct n2h_descriptor { - uint32_t interface_num; /* Interface number to which the buffer is to be sent (where appropriate) */ - uint32_t buffer; /* Physical buffer address. This is the address of the start of the usable buffer being provided by the HLOS */ - uint16_t buffer_len; /* Length of the buffer (in bytes) */ - uint16_t payload_len; /* Length of the active payload of the buffer (in bytes) */ - uint16_t payload_offs; /* Offset from the start of the buffer to the start of the payload (in bytes) */ - uint16_t bit_flags; /* Bit flags associated with the buffer */ - uint8_t buffer_type; /* Type of buffer */ - uint8_t response_type; /* Response type if the buffer is a command response */ - uint8_t pri; /* Packet priority */ - uint8_t service_code; /* Service code */ - uint32_t reserved; /* Reserved for future use */ - nss_ptr_t opaque; /* 32 or 64-bit value provided by the HLOS to associate with the buffer. The cookie has no meaning to the NSS */ -#ifndef __LP64__ - uint32_t padding; /* Pad to fit 64 bits, do not reuse */ -#endif -}; - -/* - * Device Memory Map Definitions - */ -#define DEV_MAGIC 0x4e52522e -#define DEV_INTERFACE_VERSION 1 -#define DEV_DESCRIPTORS 256 /* Do we need it here? */ - -/** - * H2N descriptor METADATA - */ -struct h2n_desc_if_meta { - uint32_t desc_addr; - uint16_t size; - uint16_t padding; -}; - -/** - * H2N descriptor ring - */ -struct h2n_desc_if_instance { - struct h2n_descriptor *desc; - uint16_t size; /* Size in entries of the H2N0 descriptor ring */ -}; - -/** - * N2H descriptor METADATA - */ -struct n2h_desc_if_meta { - uint32_t desc_addr; - uint16_t size; - uint16_t padding; -}; - -/** - * N2H descriptor ring - */ -struct n2h_desc_if_instance { - struct n2h_descriptor *desc; - uint16_t size; /* Size in entries of the H2N0 descriptor ring */ -}; - -/** - * NSS virtual interface map - */ -struct nss_if_mem_map { - struct h2n_desc_if_meta h2n_desc_if[16];/* Base address of H2N0 descriptor ring */ - struct n2h_desc_if_meta n2h_desc_if[15];/* Base address of N2H0 descriptor ring */ - uint32_t magic; /* Magic value used to identify NSS implementations (must be 0x4e52522e) */ - uint16_t if_version; /* Interface version number (must be 1 for this version) */ - uint8_t h2n_rings; /* Number of descriptor rings in the H2N direction */ - uint8_t n2h_rings; /* Number of descriptor rings in the N2H direction */ - uint32_t h2n_nss_index[16]; - /* Index number for the next descriptor that will be read by the NSS in the H2N0 descriptor ring (NSS owned) */ - volatile uint32_t n2h_nss_index[15]; - /* Index number for the next descriptor that will be written by the NSS in the N2H0 descriptor ring (NSS owned) */ - uint8_t num_phys_ports; - uint8_t reserved1[3]; /* Reserved for future use */ - uint32_t h2n_hlos_index[16]; - /* Index number for the next descriptor that will be written by the HLOS in the H2N0 descriptor ring (HLOS owned) */ - volatile uint32_t n2h_hlos_index[15]; - /* Index number for the next descriptor that will be read by the HLOS in the N2H0 descriptor ring (HLOS owned) */ - uint32_t reserved; /* Reserved for future use */ -}; -#endif /* __NSS_HLOS_IF_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_if.c b/feeds/ipq807x/qca-nss-drv/src/nss_if.c deleted file mode 100644 index 0c370b119..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_if.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2014-2016, 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 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.c - * NSS base interfaces - */ - -#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() - * Handle NSS -> HLOS messages for base class interfaces - */ -void nss_if_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, - __attribute__((unused))void *app_data) -{ - struct nss_if_msg *nim = (struct nss_if_msg *)ncm; - nss_if_msg_callback_t cb; - - /* - * We only support base class messages with this interface - */ - if (ncm->type > NSS_IF_MAX_MSG_TYPES) { - 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("%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("%px: message length too big: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Trace messages. - */ - nss_if_log_rx_msg(nim); - - /* - * Do we have a callback? - */ - if (!ncm->cb) { - return; - } - - /* - * Callback - */ - cb = (nss_if_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, nim); -} - -/* - * nss_if_tx_buf() - * Send packet to interface owned by NSS - */ -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("%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("%px: interface %d not in physical or dynamic if range\n", nss_ctx, if_num); - return NSS_TX_FAILURE_BAD_PARAM; - } - - return nss_core_send_packet(nss_ctx, os_buf, if_num, H2N_BIT_FLAG_BUFFER_REUSABLE); -} - -/* - * 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) -{ - struct nss_cmn_msg *ncm = &nim->cm; - struct net_device *dev; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - /* - * Sanity check the message - */ - 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("%px: Unregister interface %d: no context", nss_ctx, ncm->interface); - return NSS_TX_FAILURE_BAD_PARAM; - } - - return nss_core_send_cmd(nss_ctx, nim, sizeof(*nim), NSS_NBUF_PAYLOAD_SIZE); -} - -/* - * nss_if_register() - * Primary registration for receiving data and msgs from an interface. - */ -struct nss_ctx_instance *nss_if_register(uint32_t if_num, - nss_if_rx_callback_t rx_callback, - nss_if_msg_callback_t msg_callback, - struct net_device *if_ctx) -{ - return NULL; -} - -/* - * nss_if_unregister() - * Unregisteer the callback for this interface - */ -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); - -/* - * 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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_if_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_if_log.c deleted file mode 100644 index a551a4205..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_if_log.c +++ /dev/null @@ -1,429 +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_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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_if_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_if_log.h deleted file mode 100644 index 0f2a7d27b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_if_log.h +++ /dev/null @@ -1,40 +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_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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_igs.c b/feeds/ipq807x/qca-nss-drv/src/nss_igs.c deleted file mode 100644 index 8153a4653..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_igs.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_igs_stats.h" - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) -#ifdef CONFIG_NET_CLS_ACT -#include -#endif -#endif - -static struct module *nss_igs_module; - -/* - * nss_igs_verify_if_num() - * Verify interface number passed to us. - */ -bool nss_igs_verify_if_num(uint32_t if_num) -{ - enum nss_dynamic_interface_type if_type; - - if_type = nss_dynamic_interface_get_type(nss_igs_get_context(), if_num); - - if (if_type == NSS_DYNAMIC_INTERFACE_TYPE_IGS) { - return true; - } - return false; -} -EXPORT_SYMBOL(nss_igs_verify_if_num); - -/* - * nss_igs_handler() - * Handle NSS -> HLOS messages for igs device - */ -static void nss_igs_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, - void *app_data) -{ - void *ctx; - nss_igs_msg_callback_t cb; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - BUG_ON(!nss_igs_verify_if_num(ncm->interface)); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_IGS_MSG_MAX) { - 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("%px: tx request for another interface: %d", nss_ctx, ncm->interface); - return; - } - - switch (ncm->type) { - case NSS_IGS_MSG_SYNC_STATS: - /* - * Debug stats embedded in stats msg. - */ - nss_igs_stats_sync(nss_ctx, ncm, 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)app_data; - } - - /* - * callback - */ - cb = (nss_igs_msg_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - /* - * call igs callback - */ - if (!cb) { - nss_warning("%px: No callback for igs interface %d", - nss_ctx, ncm->interface); - return; - } - - cb(ctx, ncm); -} - -/* - * nss_igs_unregister_if() - * Un-registers IGS interface from the NSS firmware. - */ -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_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); -} -EXPORT_SYMBOL(nss_igs_unregister_if); - -/* - * nss_igs_register_if() - * Registers the IGS interface with NSS FW. - */ -struct nss_ctx_instance *nss_igs_register_if(uint32_t if_num, uint32_t type, - nss_igs_msg_callback_t event_callback, struct net_device *netdev, - 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_igs_stats_dentry_create(); - nss_igs_stats_init(if_num, netdev); - - return nss_ctx; -} -EXPORT_SYMBOL(nss_igs_register_if); - -/* - * nss_igs_get_context() - * Get the IGS context. - */ -struct nss_ctx_instance *nss_igs_get_context() -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.igs_handler_id]; -} -EXPORT_SYMBOL(nss_igs_get_context); - -#ifdef CONFIG_NET_CLS_ACT -/* - * nss_igs_module_save() - * Save the ingress shaping module reference. - */ -void nss_igs_module_save(struct tc_action_ops *act, struct module *module) -{ - nss_assert(act); - nss_assert(act->type == TCA_ACT_MIRRED_NSS); - - nss_igs_module = module; -} -EXPORT_SYMBOL(nss_igs_module_save); -#endif - -/* - * nss_igs_module_get() - * Get the ingress shaping module reference. - */ -bool nss_igs_module_get() -{ - nss_assert(nss_igs_module); - return try_module_get(nss_igs_module); -} -EXPORT_SYMBOL(nss_igs_module_get); - -/* - * nss_igs_module_put() - * Release the ingress shaping module reference. - */ -void nss_igs_module_put() -{ - nss_assert(nss_igs_module); - module_put(nss_igs_module); -} -EXPORT_SYMBOL(nss_igs_module_put); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_igs_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_igs_stats.c deleted file mode 100644 index a6b511a28..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_igs_stats.c +++ /dev/null @@ -1,307 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_igs_stats.h" - -/* - * nss_igs_stats - * IGS debug statistics. - */ -enum nss_igs_stats { - NSS_IGS_STATS_TX_DROP, - NSS_IGS_STATS_SHAPER_DROP, - NSS_IGS_STATS_IPV4_PARSE_FAIL, - NSS_IGS_STATS_IPV4_UNKNOWN_GRE_TYPE, - NSS_IGS_STATS_IPV4_UNKNOWN_L4, - NSS_IGS_STATS_IPV4_NO_CME, - NSS_IGS_STATS_IPV4_FRAG_INITIAL, - NSS_IGS_STATS_IPV4_FRAG_NON_INITIAL, - NSS_IGS_STATS_IPV4_MALFORMED_UDP, - NSS_IGS_STATS_IPV4_MALFORMED_TCP, - NSS_IGS_STATS_IPV4_MALFORMED_UDPL, - NSS_IGS_STATS_IPV4_MALFORMED_GRE, - NSS_IGS_STATS_IPV6_PARSE_FAIL, - NSS_IGS_STATS_IPV6_UNKNOWN_L4, - NSS_IGS_STATS_IPV6_NO_CME, - NSS_IGS_STATS_IPV6_FRAG_INITIAL, - NSS_IGS_STATS_IPV6_FRAG_NON_INITIAL, - NSS_IGS_STATS_IPV6_MALFORMED_UDP, - NSS_IGS_STATS_IPV6_MALFORMED_TCP, - NSS_IGS_STATS_IPV6_MALFORMED_UDPL, - NSS_IGS_STATS_IPV6_MALFORMED_FRAG, - NSS_IGS_STATS_EVENT_NO_SI, - NSS_IGS_STATS_ETH_PARSE_FAIL, - NSS_IGS_STATS_ETH_UNKNOWN_TYPE, - NSS_IGS_STATS_PPPOE_NON_IP, - NSS_IGS_STATS_PPPOE_MALFORMED, - NSS_IGS_STATS_MAX -}; - -/* - * nss_igs_stats_debug_instance - * Stucture for H2N/N2H IGS debug stats - */ -static struct nss_igs_stats_debug_instance { - uint64_t stats[NSS_IGS_STATS_MAX]; /* IGS statistics for each instance. */ - int32_t if_index; /* IFB instance netdev index. */ - uint32_t if_num; /* IFB instance NSS interface number */ - bool valid; /* IFB statistics valid bit. */ -} nss_igs_stats_debug[NSS_MAX_IGS_DYNAMIC_INTERFACES]; - -/* - * Data structures to store IGS interface stats. - */ -static DEFINE_SPINLOCK(nss_igs_stats_debug_lock); - -/* - * nss_igs_stats_str - * IGS statistics strings for nss session stats - */ -struct nss_stats_info nss_igs_stats_str[NSS_IGS_STATS_MAX] = { - {"IGS_SHAPER_TX_DROP" , NSS_STATS_TYPE_DROP}, - {"IGS_SHAPER_DROP" , NSS_STATS_TYPE_DROP}, - {"IGS_EXCEPTION_IPV4_PARSE_FAIL" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV4_UNKNOWN_GRE_TYPE" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV4_UNKNOWN_L4" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV4_NO_CME" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV4_FRAG_INITIAL" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV4_FRAG_NON_INITIAL" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV4_MALFORMED_UDP" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV4_MALFORMED_TCP" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV4_MALFORMED_UDPL" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV4_MALFORMED_GRE" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV6_PARSE_FAIL" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV6_UNKNOWN_L4" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV6_NO_CME" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV6_FRAG_INITIAL" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV6_FRAG_NON_INITIAL" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV6_MALFORMED_UDP" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV6_MALFORMED_TCP" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV6_MALFORMED_UDPL" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_IPV6_MALFORMED_FRAG" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_EVENT_NO_SI" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_ETH_PARSE_FAIL" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_ETH_UNKNOWN_TYPE" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_PPPOE_NON_IP" , NSS_STATS_TYPE_EXCEPTION}, - {"IGS_EXCEPTION_PPPOE_MALFORMED" , NSS_STATS_TYPE_EXCEPTION} -}; - -/* - * nss_igs_stats_get() - * Get IGS statistics. - */ -static void nss_igs_stats_get(void *stats_mem) -{ - struct nss_igs_stats_debug_instance *stats = (struct nss_igs_stats_debug_instance *)stats_mem; - int i; - - if (!stats) { - nss_warning("No memory to copy IGS stats"); - return; - } - - spin_lock_bh(&nss_igs_stats_debug_lock); - for (i = 0; i < NSS_MAX_IGS_DYNAMIC_INTERFACES; i++) { - if (nss_igs_stats_debug[i].valid) { - memcpy(stats, &nss_igs_stats_debug[i], sizeof(struct nss_igs_stats_debug_instance)); - stats++; - } - } - spin_unlock_bh(&nss_igs_stats_debug_lock); -} - -/* - * nss_igs_stats_read() - * Read IGS statistics - */ -static ssize_t nss_igs_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - - uint32_t max_output_lines = 2 /* header & footer for instance stats */ - + NSS_MAX_IGS_DYNAMIC_INTERFACES * - ((NSS_STATS_NODE_MAX + 3 ) + (NSS_IGS_STATS_MAX + 3)) /*instance 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_igs_stats_debug_instance *igs_shadow_stats; - int id; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(!lbuf)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - igs_shadow_stats = kzalloc(sizeof(struct nss_igs_stats_debug_instance) * - NSS_MAX_IGS_DYNAMIC_INTERFACES, GFP_KERNEL); - if (unlikely(!igs_shadow_stats)) { - nss_warning("Could not allocate memory for base debug statistics buffer"); - kfree(lbuf); - return 0; - } - - /* - * Get all stats - */ - nss_igs_stats_get((void *)igs_shadow_stats); - size_wr += nss_stats_banner(lbuf, size_wr, size_al, "igs", NSS_STATS_SINGLE_CORE); - - /* - * Session stats - */ - for (id = 0; id < NSS_MAX_IGS_DYNAMIC_INTERFACES; id++) { - - if (!igs_shadow_stats[id].valid) { - continue; - } - - dev = dev_get_by_index(&init_net, igs_shadow_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, - igs_shadow_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, - igs_shadow_stats[id].if_num); - } - size_wr += nss_stats_fill_common_stats(igs_shadow_stats[id].if_num, id, lbuf, size_wr, size_al, "igs"); - - /* - * IGS exception stats. - */ - size_wr += nss_stats_print("igs", "igs exception stats start" - , id - , nss_igs_stats_str - , igs_shadow_stats[id].stats - , NSS_IGS_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(igs_shadow_stats); - kfree(lbuf); - return bytes_read; -} - -/* - * nss_igs_stats_sync - * API to sync statistics for IGS - */ -void nss_igs_stats_sync(struct nss_ctx_instance *nss_ctx, - struct nss_cmn_msg *ncm, uint16_t if_num) -{ - uint8_t i, j; - struct nss_top_instance *nss_top = nss_ctx->nss_top; - struct nss_igs_msg *nim = (struct nss_igs_msg *)ncm; - struct nss_igs_stats_sync_msg *stats_msg = &nim->msg.stats; - struct nss_cmn_node_stats *node_stats_ptr = &stats_msg->node_stats; - uint32_t *igs_stats_ptr = (uint32_t *)&stats_msg->igs_stats; - - spin_lock_bh(&nss_igs_stats_debug_lock); - for (i = 0; i < NSS_MAX_IGS_DYNAMIC_INTERFACES; i++) { - if (nss_igs_stats_debug[i].if_num != if_num) { - continue; - } - - for (j = 0; j < NSS_IGS_STATS_MAX; j++) { - /* - * sync stats. - */ - nss_igs_stats_debug[i].stats[j] += igs_stats_ptr[j]; - } - spin_unlock_bh(&nss_igs_stats_debug_lock); - goto sync_cmn_stats; - } - - spin_unlock_bh(&nss_igs_stats_debug_lock); - return; - -sync_cmn_stats: - spin_lock_bh(&nss_top->stats_lock); - - /* - * sync common stats. - */ - nss_top->stats_node[if_num][NSS_STATS_NODE_RX_PKTS] += node_stats_ptr->rx_packets; - nss_top->stats_node[if_num][NSS_STATS_NODE_RX_BYTES] += node_stats_ptr->rx_bytes; - nss_top->stats_node[if_num][NSS_STATS_NODE_TX_PKTS] += node_stats_ptr->tx_packets; - nss_top->stats_node[if_num][NSS_STATS_NODE_TX_BYTES] += node_stats_ptr->tx_bytes; - - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - nss_top->stats_node[if_num][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + i] += - node_stats_ptr->rx_dropped[i]; - } - - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_igs_stats_reset() - * API to reset the IGS stats. - */ -void nss_igs_stats_reset(uint32_t if_num) -{ - uint8_t i; - - spin_lock_bh(&nss_igs_stats_debug_lock); - for (i = 0; i < NSS_MAX_IGS_DYNAMIC_INTERFACES; i++) { - if (nss_igs_stats_debug[i].if_num == if_num) { - memset(&nss_igs_stats_debug[i], 0, sizeof(struct nss_igs_stats_debug_instance)); - break; - } - } - spin_unlock_bh(&nss_igs_stats_debug_lock); -} - -/* - * nss_igs_stats_init() - * API to initialize IGS debug instance statistics. - */ -void nss_igs_stats_init(uint32_t if_num, struct net_device *netdev) -{ - uint8_t i; - - spin_lock_bh(&nss_igs_stats_debug_lock); - for (i = 0; i < NSS_MAX_IGS_DYNAMIC_INTERFACES; i++) { - if (!nss_igs_stats_debug[i].valid) { - nss_igs_stats_debug[i].valid = true; - nss_igs_stats_debug[i].if_num = if_num; - nss_igs_stats_debug[i].if_index = netdev->ifindex; - break; - } - } - spin_unlock_bh(&nss_igs_stats_debug_lock); -} - -/* - * nss_igs_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(igs) - -/* - * nss_igs_stats_dentry_create() - * Create igs statistics debug entry. - */ -void nss_igs_stats_dentry_create(void) -{ - nss_stats_create_dentry("igs", &nss_igs_stats_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_igs_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_igs_stats.h deleted file mode 100644 index 08f9c79f7..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_igs_stats.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_IGS_STATS_H -#define __NSS_IGS_STATS_H - -/* - * nss_igs_stats_sync - * API to sync statistics for IGS - */ -extern void nss_igs_stats_sync(struct nss_ctx_instance *nss_ctx, - struct nss_cmn_msg *ncm, uint16_t if_num); - -/* - * nss_igs_stats_reset() - * API to reset the IGS stats. - */ -extern void nss_igs_stats_reset(uint32_t if_num); - -/* - * nss_igs_stats_init() - * API to initialize IGS debug instance statistics. - */ -extern void nss_igs_stats_init(uint32_t if_num, struct net_device *netdev); - - -/* - * IGS statistics APIs - */ -extern void nss_igs_stats_dentry_create(void); - -#endif /* __NSS_IGS_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_init.c b/feeds/ipq807x/qca-nss-drv/src/nss_init.c deleted file mode 100644 index ebd2a12fb..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_init.c +++ /dev/null @@ -1,950 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_init.c - * NSS init APIs - * - */ -#include "nss_core.h" -#if (NSS_PM_SUPPORT == 1) -#include "nss_pm.h" -#endif -#include "nss_tx_rx_common.h" -#include "nss_data_plane.h" -#include "nss_capwap.h" -#include "nss_strings.h" - -#include - -#include -#include -#include -#include - -#if (NSS_DT_SUPPORT == 1) -#if (NSS_FABRIC_SCALING_SUPPORT == 1) -#include -#endif -#include -#include -#include -#include -#include -#else -#include -#endif - -#include -#include -#include - -/* - * Global declarations - */ -int nss_ctl_redirect __read_mostly = 0; -int nss_ctl_debug __read_mostly = 0; -int nss_ctl_logbuf __read_mostly = 0; -int nss_jumbo_mru __read_mostly = 0; -int nss_paged_mode __read_mostly = 0; -#if (NSS_SKB_REUSE_SUPPORT == 1) -int nss_max_reuse __read_mostly = PAGE_SIZE; -#endif -int nss_skip_nw_process = 0x0; -module_param(nss_skip_nw_process, int, S_IRUGO); - -/* - * PM client handle - */ -#if (NSS_PM_SUPPORT == 1) -static void *pm_client; -#endif - -/* - * Handler to send NSS messages - */ -struct clk *nss_core0_clk; -struct clk *nss_core1_clk; - -/* - * Handle fabric requests - only on new kernel - */ -#if (NSS_DT_SUPPORT == 1) -struct clk *nss_fab0_clk; -struct clk *nss_fab1_clk; -#endif - -/* - * Top level nss context structure - */ -struct nss_top_instance nss_top_main; -struct nss_cmd_buffer nss_cmd_buf; -struct nss_runtime_sampling nss_runtime_samples; -struct workqueue_struct *nss_wq; - -/* - * Work Queue to handle messages to Kernel - */ -nss_work_t *nss_work; - -extern struct of_device_id nss_dt_ids[]; - -/* - * nss_probe() - * HLOS device probe callback - */ -static inline int nss_probe(struct platform_device *nss_dev) -{ - return nss_hal_probe(nss_dev); -} - -/* - * nss_remove() - * HLOS device remove callback - */ -static inline int nss_remove(struct platform_device *nss_dev) -{ - return nss_hal_remove(nss_dev); -} - -#if (NSS_DT_SUPPORT == 1) -/* - * Platform Device ID for NSS core. - */ -struct of_device_id nss_dt_ids[] = { - { .compatible = "qcom,nss" }, - { .compatible = "qcom,nss0" }, - { .compatible = "qcom,nss1" }, - {}, -}; -MODULE_DEVICE_TABLE(of, nss_dt_ids); -#endif - -/* - * nss_driver - * Platform driver structure for NSS - */ -struct platform_driver nss_driver = { - .probe = nss_probe, - .remove = nss_remove, - .driver = { - .name = "qca-nss", - .owner = THIS_MODULE, -#if (NSS_DT_SUPPORT == 1) - .of_match_table = of_match_ptr(nss_dt_ids), -#endif - }, -}; - -#if (NSS_FREQ_SCALE_SUPPORT == 1) -/* - * nss_reset_frequency_stats_samples() - * Reset all frequency sampling state when auto scaling is turned off. - */ -static void nss_reset_frequency_stats_samples(void) -{ - nss_runtime_samples.buffer_index = 0; - nss_runtime_samples.sum = 0; - nss_runtime_samples.average = 0; - nss_runtime_samples.sample_count = 0; - nss_runtime_samples.message_rate_limit = 0; - nss_runtime_samples.freq_scale_rate_limit_down = 0; -} - -/* - * nss_current_freq_handler() - * Handle Userspace Frequency Change Requests - */ -static int nss_current_freq_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - int ret, i; - - BUG_ON(!nss_wq); - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - - if (!*lenp || (*ppos && !write)) { - printk("Frequency Set to %d\n", nss_cmd_buf.current_freq); - *lenp = 0; - return ret; - } - - /* - * Check if frequency exists in frequency Table - */ - i = 0; - while (i < NSS_FREQ_MAX_SCALE) { - if (nss_runtime_samples.freq_scale[i].frequency == nss_cmd_buf.current_freq) { - break; - } - i++; - } - if (i == NSS_FREQ_MAX_SCALE) { - printk("Frequency not found. Please check Frequency Table\n"); - nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency; - return ret; - } - - /* - * Turn off Auto Scale - */ - nss_cmd_buf.auto_scale = 0; - nss_runtime_samples.freq_scale_ready = 0; - nss_runtime_samples.freq_scale_index = i; - - nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC); - if (!nss_work) { - nss_info("NSS Freq WQ kmalloc fail"); - return ret; - } - INIT_WORK((struct work_struct *)nss_work, nss_hal_wq_function); - nss_work->frequency = nss_cmd_buf.current_freq; - nss_work->stats_enable = 0; - - /* - * Ensure we start with a fresh set of samples later - */ - nss_reset_frequency_stats_samples(); - - queue_work(nss_wq, (struct work_struct *)nss_work); - - return ret; -} - -/* - * nss_auto_scale_handler() - * Enables or Disable Auto Scaling - */ -static int nss_auto_scale_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - int ret; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - - if (!*lenp || (*ppos && !write)) { - return ret; - } - - if (nss_cmd_buf.auto_scale != 1) { - /* - * Is auto scaling currently enabled? If so, send the command to - * disable stats reporting to NSS - */ - if (nss_runtime_samples.freq_scale_ready != 0) { - nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency; - nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC); - if (!nss_work) { - nss_info("NSS Freq WQ kmalloc fail"); - return ret; - } - INIT_WORK((struct work_struct *)nss_work, nss_hal_wq_function); - nss_work->frequency = nss_cmd_buf.current_freq; - nss_work->stats_enable = 0; - queue_work(nss_wq, (struct work_struct *)nss_work); - nss_runtime_samples.freq_scale_ready = 0; - - /* - * The current samples would be stale later when scaling is - * enabled again, hence reset them - */ - nss_reset_frequency_stats_samples(); - } - return ret; - } - - /* - * Setup default values - Middle of Freq Scale Band - */ - nss_runtime_samples.freq_scale_index = 1; - nss_runtime_samples.sample_count = 0; - nss_runtime_samples.initialized = 0; - nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency; - - nss_work = (nss_work_t *)kmalloc(sizeof(nss_work_t), GFP_ATOMIC); - if (!nss_work) { - nss_info("NSS Freq WQ kmalloc fail"); - return ret; - } - INIT_WORK((struct work_struct *)nss_work, nss_hal_wq_function); - nss_work->frequency = nss_cmd_buf.current_freq; - nss_work->stats_enable = 1; - queue_work(nss_wq, (struct work_struct *)nss_work); - - nss_cmd_buf.auto_scale = 0; - nss_runtime_samples.freq_scale_ready = 1; - - return ret; -} - -/* - * nss_get_freq_table_handler() - * Display Support Freq and Ex how to Change. - */ -static int nss_get_freq_table_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - int ret, i; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - - if (write) { - return ret; - } - - printk("Frequency Supported - "); - - i = 0; - while (i < NSS_FREQ_MAX_SCALE) { - 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"); - - *lenp = 0; - return ret; -} - -/* - * nss_get_average_inst_handler() - * Display AVG Inst Per Ms. - */ -static int nss_get_average_inst_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - int ret; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - - if (write) { - return ret; - } - - printk("Current Inst Per Ms %x\n", nss_runtime_samples.average); - - *lenp = 0; - return ret; -} -#endif - -#if (NSS_FW_DBG_SUPPORT == 1) -/* - * nss_debug_handler() - * Enable NSS debug output - */ -static int nss_debug_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - int ret; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (!ret) { - if ((write) && (nss_ctl_debug != 0)) { - printk("Enabling NSS SPI Debug\n"); - nss_hal_debug_enable(); - } - } - - return ret; -} -#endif - -/* - * nss_coredump_handler() - * Send Signal To Coredump NSS Cores - */ -static int nss_coredump_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[NSS_CORE_0]; - int ret; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (!ret) { - /* - * if nss_cmd_buf.coredump is not 0 or 1, panic will be disabled - * when NSS FW crashes, so OEM/ODM have a chance to use mdump - * to dump crash dump (coredump) and send dump to us for analysis. - */ - if ((write) && (nss_ctl_debug != 0) && nss_cmd_buf.coredump == 1) { - printk("Coredumping to DDR\n"); - nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_TRIGGER_COREDUMP); - } - } - - return ret; -} - -/* - * nss_jumbo_mru_handler() - * Sysctl to modify nss_jumbo_mru - */ -static int nss_jumbo_mru_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - int ret; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret) { - return ret; - } - - if (write) { - nss_core_set_jumbo_mru(nss_jumbo_mru); - nss_info("jumbo_mru set to %d\n", nss_jumbo_mru); - } - - return ret; -} - -/* nss_paged_mode_handler() - * Sysctl to modify nss_paged_mode. - */ - -static int nss_paged_mode_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - int ret; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret) { - return ret; - } - - if (write) { - nss_core_set_paged_mode(nss_paged_mode); - nss_info("paged_mode set to %d\n", nss_paged_mode); - } - - return ret; -} - -#if (NSS_SKB_REUSE_SUPPORT == 1) -/* - * nss_get_min_reuse_handler() - * Sysctl to get min reuse sizes - */ -static int nss_get_min_reuse_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - int ret; - struct nss_ctx_instance *nss_ctx = NULL; - uint32_t core_id; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret) { - return ret; - } - - printk("Min SKB reuse sizes - "); - - for (core_id = 0; core_id < NSS_CORE_MAX; core_id++) { - nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[core_id]; - printk("core %d: %d ", core_id, nss_core_get_min_reuse(nss_ctx)); - } - - printk("\n"); - *lenp = 0; - return ret; -} - -/* - * nss_max_reuse_handler() - * Sysctl to modify nss_max_reuse - */ -static int nss_max_reuse_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - int ret; - - nss_max_reuse = nss_core_get_max_reuse(); - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret) { - return ret; - } - - if (write) { - nss_core_set_max_reuse(nss_max_reuse); - nss_info("max_reuse set to %d\n", nss_max_reuse); - } - - return ret; -} - -/* - * sysctl-tuning for NSS driver SKB reuse - */ -static struct ctl_table nss_skb_reuse_table[] = { - { - .procname = "min_sizes", - .data = NULL, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_get_min_reuse_handler, - }, - { - .procname = "max_size", - .data = &nss_max_reuse, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_max_reuse_handler, - }, - { } -}; -#endif - -#if (NSS_FREQ_SCALE_SUPPORT == 1) -/* - * sysctl-tuning infrastructure. - */ -static struct ctl_table nss_freq_table[] = { - { - .procname = "current_freq", - .data = &nss_cmd_buf.current_freq, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_current_freq_handler, - }, - { - .procname = "freq_table", - .data = &nss_cmd_buf.max_freq, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_get_freq_table_handler, - }, - { - .procname = "auto_scale", - .data = &nss_cmd_buf.auto_scale, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_auto_scale_handler, - }, - { - .procname = "inst_per_sec", - .data = &nss_cmd_buf.average_inst, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_get_average_inst_handler, - }, - { } -}; -#endif - -static struct ctl_table nss_general_table[] = { - { - .procname = "redirect", - .data = &nss_ctl_redirect, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec, - }, -#if (NSS_FW_DBG_SUPPORT == 1) - { - .procname = "debug", - .data = &nss_ctl_debug, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_debug_handler, - }, -#endif - { - .procname = "coredump", - .data = &nss_cmd_buf.coredump, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_coredump_handler, - }, - { - .procname = "logbuf", - .data = &nss_ctl_logbuf, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_logbuffer_handler, - }, - { - .procname = "jumbo_mru", - .data = &nss_jumbo_mru, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_jumbo_mru_handler, - }, - { - .procname = "paged_mode", - .data = &nss_paged_mode, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_paged_mode_handler, - }, - { } -}; - -static struct ctl_table nss_init_dir[] = { -#if (NSS_FREQ_SCALE_SUPPORT == 1) - { - .procname = "clock", - .mode = 0555, - .child = nss_freq_table, - }, -#endif - { - .procname = "general", - .mode = 0555, - .child = nss_general_table, - }, -#if (NSS_SKB_REUSE_SUPPORT == 1) - { - .procname = "skb_reuse", - .mode = 0555, - .child = nss_skb_reuse_table, - }, -#endif - { } -}; - -static struct ctl_table nss_root_dir[] = { - { - .procname = "nss", - .mode = 0555, - .child = nss_init_dir, - }, - { } -}; - -static struct ctl_table nss_root[] = { - { - .procname = "dev", - .mode = 0555, - .child = nss_root_dir, - }, - { } -}; - -static struct ctl_table_header *nss_dev_header; - -/* - * nss_init() - * Registers nss driver - */ -static int __init nss_init(void) -{ -#if (NSS_DT_SUPPORT == 1) - struct device_node *cmn = NULL; -#endif - nss_info("Init NSS driver"); - -#if (NSS_DT_SUPPORT == 1) - /* - * Get reference to NSS common device node - */ - cmn = of_find_node_by_name(NULL, "nss-common"); - if (!cmn) { - nss_info_always("qca-nss-drv.ko is loaded for symbol link\n"); - return 0; - } - of_node_put(cmn); - - /* - * Pick up HAL by target information - */ -#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; - nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops; - 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; - nss_top_main.data_plane_ops = &nss_data_plane_ops; -#if defined(NSS_MEM_PROFILE_LOW) - nss_top_main.num_nss = 1; -#else - nss_top_main.num_nss = 2; -#endif - } -#endif -#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_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_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; - nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops; - nss_top_main.num_nss = 1; - } -#endif - if (!nss_top_main.hal_ops) { - nss_info_always("No supported HAL compiled on this platform\n"); - return -EFAULT; - } -#else - /* - * For banana, only ipq806x is supported - */ - nss_top_main.hal_ops = &nss_hal_ipq806x_ops; - nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops; - nss_top_main.num_nss = 2; - -#endif /* NSS_DT_SUPPORT */ - nss_top_main.nss_hal_common_init_done = false; - - /* - * Initialize data_plane workqueue - */ - if (nss_data_plane_init_delay_work()) { - nss_warning("Error initializing nss_data_plane_workqueue\n"); - return -EFAULT; - } - - /* - * Enable spin locks - */ - spin_lock_init(&(nss_top_main.lock)); - spin_lock_init(&(nss_top_main.stats_lock)); - mutex_init(&(nss_top_main.wq_lock)); - - /* - * Enable NSS statistics - */ - nss_stats_init(); - - /* - * Enable NSS statistics names. - */ - nss_strings_init(); - - /* - * Register sysctl table. - */ - nss_dev_header = register_sysctl_table(nss_root); - - /* - * 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. - */ - if (nss_top_main.num_nss == 1) { - nss_n2h_single_core_register_sysctl(); - } else { - nss_n2h_multi_core_register_sysctl(); - } - - /* - * Registering sysctl for rps specific config. - */ - nss_rps_register_sysctl(); - -#ifdef NSS_DRV_C2C_ENABLE - /* - * Registering sysctl for c2c_tx specific config. - */ - nss_c2c_tx_register_sysctl(); -#endif - - /* - * Registering sysctl for for printing non zero stats. - */ - nss_stats_register_sysctl(); - - /* - * Register sysctl for project config - */ - nss_project_register_sysctl(); - - /* - * Registering sysctl for pppoe specific config. - */ - nss_pppoe_register_sysctl(); - - /* - * Setup Runtime Sample values - */ - nss_runtime_samples.freq_scale_index = 1; - nss_runtime_samples.freq_scale_ready = 0; - nss_runtime_samples.freq_scale_rate_limit_down = 0; - nss_runtime_samples.buffer_index = 0; - nss_runtime_samples.sum = 0; - nss_runtime_samples.sample_count = 0; - nss_runtime_samples.average = 0; - nss_runtime_samples.message_rate_limit = 0; - nss_runtime_samples.initialized = 0; - - nss_cmd_buf.current_freq = nss_runtime_samples.freq_scale[nss_runtime_samples.freq_scale_index].frequency; - - /* - * Initial Workqueue - */ - nss_wq = create_workqueue("nss_freq_queue"); - -#if (NSS_PM_SUPPORT == 1) - /* - * Initialize NSS Bus PM module - */ - nss_pm_init(); - - /* - * Register with Bus driver - */ - pm_client = nss_pm_client_register(NSS_PM_CLIENT_NETAP); - if (!pm_client) { - nss_warning("Error registering with PM driver"); - } -#endif - - /* - * Initialize mtu size needed as start - */ - nss_top_main.prev_mtu_sz = ETH_DATA_LEN; - - /* - * register panic handler and timeout control - */ - nss_coredump_notify_register(); - nss_coredump_init_delay_work(); - -#ifdef NSS_DRV_CAPWAP_ENABLE - /* - * Init capwap - */ - nss_capwap_init(); -#endif - -#ifdef NSS_DRV_QRFS_ENABLE - /* - * Init QRFS - */ - nss_qrfs_init(); -#endif - -#ifdef NSS_DRV_C2C_ENABLE - /* - * Init c2c_tx - */ - nss_c2c_tx_init(); -#endif - -#ifdef NSS_DRV_PVXLAN_ENABLE - /* - * Init pvxlan - */ - nss_pvxlan_init(); -#endif - -#ifdef NSS_DRV_CLMAP_ENABLE - /* - * Init clmap - */ - nss_clmap_init(); -#endif - - /* - * INIT ppe on supported platform - */ -#ifdef NSS_DRV_PPE_ENABLE - nss_ppe_init(); -#endif - -#ifdef NSS_DRV_DMA_ENABLE - nss_dma_init(); -#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); -} - -/* - * nss_cleanup() - * Unregisters nss driver - */ -static void __exit nss_cleanup(void) -{ - nss_info("Exit NSS driver"); - - if (nss_dev_header) - unregister_sysctl_table(nss_dev_header); - - /* - * Unregister n2h specific sysctl - */ - nss_n2h_unregister_sysctl(); - - /* - * Unregister rps specific sysctl - */ - nss_rps_unregister_sysctl(); - -#ifdef NSS_DRV_C2C_ENABLE - /* - * Unregister c2c_tx specific sysctl - */ - nss_c2c_tx_unregister_sysctl(); -#endif - - /* - * Unregister pppoe specific sysctl - */ - nss_pppoe_unregister_sysctl(); - - /* - * Unregister ipv4/6 specific sysctl and free allocated to connection tables - */ - nss_ipv4_unregister_sysctl(); - 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(); - - /* - * cleanup ppe on supported platform - */ -#ifdef NSS_DRV_PPE_ENABLE - nss_ppe_free(); -#endif - - platform_driver_unregister(&nss_driver); -} - -module_init(nss_init); -module_exit(nss_cleanup); - -MODULE_DESCRIPTION("QCA NSS Driver"); -MODULE_AUTHOR("Qualcomm Atheros Inc"); -MODULE_LICENSE("Dual BSD/GPL"); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipsec.c deleted file mode 100644 index 49c7805f3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec.c +++ /dev/null @@ -1,597 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_ipsec.c - * NSS IPsec APIs - */ - -#include "nss_tx_rx_common.h" -#include "nss_ipsec.h" -#include "nss_ppe.h" -#include "nss_ipsec_log.h" - -#if defined(NSS_HAL_IPQ806X_SUPPORT) -#define NSS_IPSEC_ENCAP_INTERFACE_NUM NSS_IPSEC_ENCAP_IF_NUMBER -#define NSS_IPSEC_DECAP_INTERFACE_NUM NSS_IPSEC_DECAP_IF_NUMBER -#define NSS_IPSEC_DATA_INTERFACE_NUM NSS_C2C_TX_INTERFACE - -#elif defined(NSS_HAL_FSM9010_SUPPORT) -#define NSS_IPSEC_ENCAP_INTERFACE_NUM NSS_IPSEC_ENCAP_IF_NUMBER -#define NSS_IPSEC_DECAP_INTERFACE_NUM NSS_IPSEC_DECAP_IF_NUMBER -#define NSS_IPSEC_DATA_INTERFACE_NUM NSS_IPSEC_CMN_INTERFACE - -#elif defined(NSS_HAL_IPQ807x_SUPPORT) -#define NSS_IPSEC_ENCAP_INTERFACE_NUM NSS_IPSEC_CMN_INTERFACE -#define NSS_IPSEC_DECAP_INTERFACE_NUM NSS_IPSEC_CMN_INTERFACE -#define NSS_IPSEC_DATA_INTERFACE_NUM NSS_IPSEC_CMN_INTERFACE - -#elif defined(NSS_HAL_IPQ60XX_SUPPORT) -#define NSS_IPSEC_ENCAP_INTERFACE_NUM NSS_IPSEC_CMN_INTERFACE -#define NSS_IPSEC_DECAP_INTERFACE_NUM NSS_IPSEC_CMN_INTERFACE -#define NSS_IPSEC_DATA_INTERFACE_NUM NSS_IPSEC_CMN_INTERFACE - -#elif defined(NSS_HAL_IPQ50XX_SUPPORT) -#define NSS_IPSEC_ENCAP_INTERFACE_NUM NSS_IPSEC_CMN_INTERFACE -#define NSS_IPSEC_DECAP_INTERFACE_NUM NSS_IPSEC_CMN_INTERFACE -#define NSS_IPSEC_DATA_INTERFACE_NUM NSS_IPSEC_CMN_INTERFACE - -#else -#define NSS_IPSEC_ENCAP_INTERFACE_NUM -1 -#define NSS_IPSEC_DECAP_INTERFACE_NUM -1 -#define NSS_IPSEC_DATA_INTERFACE_NUM -1 - -#endif - -/* - * Amount time the synchronous message should wait for response from - * NSS before the timeout happens. After the timeout the message - * response even if it arrives has to be discarded. Typically, the - * time needs to be selected based on the worst case time in case of - * peak throughput between host & NSS. - */ -#define NSS_IPSEC_TX_TIMEO_TICKS msecs_to_jiffies(3000) /* 3 Seconds */ - -/* - * Private data structure to hold state for - * the ipsec specific NSS interaction - */ -struct nss_ipsec_pvt { - struct semaphore sem; /* used for synchronizing 'tx_msg_sync' */ - struct completion complete; /* completion callback */ - atomic_t resp; /* Response error type */ -} nss_ipsec; - -/* - * nss_ipsec_get_msg_ctx() - * return ipsec message context assoicated with the callback - * - * Note: certain SOC the decap interface specially programmed - */ -static inline nss_ptr_t nss_ipsec_get_msg_ctx(struct nss_ctx_instance *nss_ctx, uint32_t interface_num) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - /* - * the encap is primary interface - */ - if (interface_num == NSS_IPSEC_ENCAP_INTERFACE_NUM) - return (nss_ptr_t)nss_top->ipsec_encap_ctx; - - return (nss_ptr_t)nss_top->ipsec_decap_ctx; -} - -/* - * nss_ipsec_get_msg_callback() - * this gets the message callback handler - */ -static inline nss_ptr_t nss_ipsec_get_msg_callback(struct nss_ctx_instance *nss_ctx, uint32_t interface_num) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - /* - * the encap is primary interface - */ - if (interface_num == NSS_IPSEC_ENCAP_INTERFACE_NUM) - return (nss_ptr_t)nss_top->ipsec_encap_callback; - - return (nss_ptr_t)nss_top->ipsec_decap_callback; -} - -/* - ********************************** - Rx APIs - ********************************** - */ - -/* - * nss_ipsec_msg_handler() - * this handles all the IPsec events and responses - */ -static void nss_ipsec_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *app_data __attribute((unused))) -{ - struct nss_ipsec_msg *nim = (struct nss_ipsec_msg *)ncm; - nss_ipsec_msg_callback_t cb = NULL; - uint32_t if_num = ncm->interface; - - /* - * Trace messages. - */ - nss_ipsec_log_rx_msg(nim); - - /* - * Sanity check the message type - */ - if (ncm->type > NSS_IPSEC_MSG_TYPE_MAX) { - 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("%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("%px: rx message response for if %d, type %d, is invalid: %d", nss_ctx, ncm->interface, - ncm->type, ncm->response); - return; - } - - /* - * Is this a notification? if, yes then fill up the callback and app_data from - * locally stored state - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = nss_ipsec_get_msg_callback(nss_ctx, if_num); - ncm->app_data = nss_ipsec_get_msg_ctx(nss_ctx, if_num); - } - - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * load, test & call - */ - cb = (nss_ipsec_msg_callback_t)ncm->cb; - if (unlikely(!cb)) { - nss_trace("%px: rx handler has been unregistered for i/f: %d", nss_ctx, ncm->interface); - return; - } - - cb((void *)ncm->app_data, nim); -} - -/* - ********************************** - Tx APIs - ********************************** - */ - -/* - * nss_ipsec_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_ipsec_callback(void *app_data, struct nss_ipsec_msg *nim) -{ - struct nss_cmn_msg *ncm = &nim->cm; - - /* - * This callback is for synchronous operation. The caller sends its - * response pointer which needs to be loaded with the response - * data arriving from the NSS - */ - atomic_t *resp = (atomic_t *)app_data; - - if (ncm->response == NSS_CMN_RESPONSE_ACK) { - atomic_set(resp, NSS_IPSEC_ERROR_TYPE_NONE); - complete(&nss_ipsec.complete); - return; - } - - atomic_set(resp, ncm->error); - complete(&nss_ipsec.complete); -} - -/* - * nss_ipsec_tx_msg - * Send ipsec rule to NSS. - */ -nss_tx_status_t nss_ipsec_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_ipsec_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - 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)); - - /* - * Trace messages. - */ - nss_ipsec_log_tx_msg(msg); - - if ((ncm->interface != NSS_IPSEC_ENCAP_INTERFACE_NUM) && (ncm->interface != NSS_IPSEC_DECAP_INTERFACE_NUM)) { - 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("%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:%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); -} -EXPORT_SYMBOL(nss_ipsec_tx_msg); - -/* - * nss_ipsec_tx_msg_sync() - * Transmit a ipsec message to NSS firmware synchronously. - */ -nss_tx_status_t nss_ipsec_tx_msg_sync(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - enum nss_ipsec_msg_type type, uint16_t len, - struct nss_ipsec_msg *nim, enum nss_ipsec_error_type *resp) -{ - struct nss_ipsec_msg nim_local = { {0} }; - nss_tx_status_t status; - int ret; - - /* - * Length of the message should be the based on type - */ - if (len > sizeof(nim_local.msg)) { - nss_warning("%px: (%u)Bad message length(%u) for type (%d)", nss_ctx, if_num, len, type); - return NSS_TX_FAILURE_TOO_LARGE; - } - - /* - * Response buffer is a required for copying the response for message - */ - if (!resp) { - nss_warning("%px: (%u)Response buffer is empty, type(%d)", nss_ctx, if_num, type); - return NSS_TX_FAILURE_BAD_PARAM; - } - - /* - * TODO: this can be removed in future as we need to ensure that the response - * memory is only updated when the current outstanding request is waiting. - * This can be solved by introducing sequence no. in messages and only completing - * the message if the sequence no. matches. For now this is solved by passing - * a known memory nss_ipsec.resp - */ - down(&nss_ipsec.sem); - - /* - * Initializing it to a fail error type - */ - atomic_set(&nss_ipsec.resp, NSS_IPSEC_ERROR_TYPE_UNHANDLED_MSG); - - /* - * We need to copy the message content into the actual message - * to be sent to NSS - * - * Note: Here pass the nss_ipsec.resp as the pointer. Since, the caller - * provided pointer is not allocated by us and may go away when this function - * returns with failure. The callback is not aware of this and may try to - * access the pointer incorrectly potentially resulting in a crash. - */ - nss_ipsec_msg_init(&nim_local, if_num, type, len, nss_ipsec_callback, &nss_ipsec.resp); - memcpy(&nim_local.msg, &nim->msg, len); - - status = nss_ipsec_tx_msg(nss_ctx, &nim_local); - if (status != NSS_TX_SUCCESS) { - 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("%px: IPsec msg tx failed due to timeout", nss_ctx); - status = NSS_TX_FAILURE_NOT_ENABLED; - goto done; - } - - /* - * Read memory barrier - */ - smp_rmb(); - - /* - * Copy the response received - */ - *resp = atomic_read(&nss_ipsec.resp); - - /* - * Only in case of non-error response we will - * indicate success - */ - if (*resp != NSS_IPSEC_ERROR_TYPE_NONE) - status = NSS_TX_FAILURE; - -done: - up(&nss_ipsec.sem); - return status; -} -EXPORT_SYMBOL(nss_ipsec_tx_msg_sync); - -/* - * nss_ipsec_tx_buf - * Send data packet for ipsec processing - */ -nss_tx_status_t nss_ipsec_tx_buf(struct sk_buff *skb, uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[nss_top_main.ipsec_handler_id]; - - 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); -} -EXPORT_SYMBOL(nss_ipsec_tx_buf); - -/* - ********************************** - Register APIs - ********************************** - */ - -/* - * nss_ipsec_notify_register() - * register message notifier for the given interface (if_num) - */ -struct nss_ctx_instance *nss_ipsec_notify_register(uint32_t if_num, nss_ipsec_msg_callback_t cb, void *app_data) -{ - struct nss_top_instance *nss_top = &nss_top_main; - uint8_t core_id = nss_top->ipsec_handler_id; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_id]; - - if (if_num >= NSS_MAX_NET_INTERFACES) { - nss_warning("%px: notfiy register received for invalid interface %d", nss_ctx, if_num); - return NULL; - } - - /* - * the encap is primary interface - */ - if (if_num == NSS_IPSEC_ENCAP_INTERFACE_NUM) { - nss_top->ipsec_encap_callback = cb; - nss_top->ipsec_encap_ctx = app_data; - return nss_ctx; - } - - nss_top->ipsec_decap_callback = cb; - nss_top->ipsec_decap_ctx = app_data; - return nss_ctx; -} -EXPORT_SYMBOL(nss_ipsec_notify_register); - -/* - * nss_ipsec_notify_unregister() - * unregister the IPsec notifier for the given interface number (if_num) - */ -void nss_ipsec_notify_unregister(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - if (if_num >= NSS_MAX_NET_INTERFACES) { - nss_warning("%px: notify unregister received for invalid interface %d", nss_ctx, if_num); - return; - } - - /* - * the encap is primary interface - */ - if (if_num == NSS_IPSEC_ENCAP_INTERFACE_NUM) { - nss_top->ipsec_encap_callback = NULL; - nss_top->ipsec_encap_ctx = NULL; - return; - } - - nss_top->ipsec_decap_callback = NULL; - nss_top->ipsec_decap_ctx = NULL; -} -EXPORT_SYMBOL(nss_ipsec_notify_unregister); - -/* - * nss_ipsec_data_register() - * register a data callback routine - */ -struct nss_ctx_instance *nss_ipsec_data_register(uint32_t if_num, nss_ipsec_buf_callback_t cb, struct net_device *netdev, uint32_t features) -{ - struct nss_ctx_instance *nss_ctx, *nss_ctx0; - - 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("%px: data register received for invalid interface %d", nss_ctx, if_num); - return NULL; - } - - /* - * avoid multiple registeration for multiple tunnels - */ - if (nss_ctx->subsys_dp_register[if_num].cb) { - return nss_ctx; - } - - nss_core_register_subsys_dp(nss_ctx, if_num, cb, NULL, NULL, netdev, features); - - if (nss_top_main.ipsec_handler_id == 1) { - nss_ctx0 = &nss_top_main.nss[0]; - - nss_core_register_subsys_dp(nss_ctx0, if_num, cb, NULL, NULL, netdev, features); - } - - return nss_ctx; -} -EXPORT_SYMBOL(nss_ipsec_data_register); - -/* - * nss_ipsec_data_unregister() - * unregister a data callback routine - */ -void nss_ipsec_data_unregister(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx0; - - if ((if_num >= NSS_MAX_NET_INTERFACES) && (if_num < NSS_MAX_PHYSICAL_INTERFACES)){ - nss_warning("%px: data unregister received for invalid interface %d", nss_ctx, if_num); - return; - } - - if (nss_top_main.ipsec_handler_id == 1) { - nss_ctx0 = &nss_top_main.nss[0]; - - nss_core_unregister_subsys_dp(nss_ctx0, if_num); - } - - nss_core_unregister_subsys_dp(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_ipsec_data_unregister); - -/* - * nss_ipsec_get_encap_interface() - * Get the NSS interface number for encap message - */ -int32_t nss_ipsec_get_encap_interface(void) -{ - return NSS_IPSEC_ENCAP_INTERFACE_NUM; -} -EXPORT_SYMBOL(nss_ipsec_get_encap_interface); - -/* - * nss_ipsec_get_decap_interface() - * Get the NSS interface number for decap message - */ -int32_t nss_ipsec_get_decap_interface(void) -{ - return NSS_IPSEC_DECAP_INTERFACE_NUM; -} -EXPORT_SYMBOL(nss_ipsec_get_decap_interface); - -/* - * nss_ipsec_get_data_interface() - * Get the NSS interface number used for data path - */ -int32_t nss_ipsec_get_data_interface(void) -{ - return NSS_IPSEC_DATA_INTERFACE_NUM; -} -EXPORT_SYMBOL(nss_ipsec_get_data_interface); - -/* - * nss_ipsec_get_context() - * Get NSS context instance for IPsec handle - */ -struct nss_ctx_instance *nss_ipsec_get_context(void) -{ - return &nss_top_main.nss[nss_top_main.ipsec_handler_id]; -} -EXPORT_SYMBOL(nss_ipsec_get_context); - -/* - * nss_ipsec_get_ifnum() - * Return IPsec interface number with coreid. - */ -int32_t nss_ipsec_get_ifnum(int32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_ipsec_get_context(); - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - return NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_ipsec_get_ifnum); - -/* - * nss_ipsec_ppe_port_config() - * Configure PPE port for IPsec inline - */ -bool nss_ipsec_ppe_port_config(struct nss_ctx_instance *nss_ctx, struct net_device *netdev, - uint32_t if_num, uint32_t vsi_num) -{ -#ifdef NSS_PPE_SUPPORTED - 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("%px: Failed to configure PPE IPsec port", nss_ctx); - return false; - } - - return true; -#else - return false; -#endif -} -EXPORT_SYMBOL(nss_ipsec_ppe_port_config); - -/* - * nss_ipsec_ppe_mtu_update() - * Update PPE MTU for IPsec inline - */ -bool nss_ipsec_ppe_mtu_update(struct nss_ctx_instance *nss_ctx, uint32_t if_num, uint16_t mtu, uint16_t mru) -{ -#ifdef NSS_PPE_SUPPORTED - 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("%px: Failed to update PPE MTU for IPsec port", nss_ctx); - return false; - } - - return true; -#else - return false; -#endif -} -EXPORT_SYMBOL(nss_ipsec_ppe_mtu_update); - -/* - * nss_ipsec_register_handler() - */ -void nss_ipsec_register_handler() -{ - struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[nss_top_main.ipsec_handler_id]; - - BUILD_BUG_ON(NSS_IPSEC_ENCAP_INTERFACE_NUM < 0); - BUILD_BUG_ON(NSS_IPSEC_DECAP_INTERFACE_NUM < 0); - - sema_init(&nss_ipsec.sem, 1); - init_completion(&nss_ipsec.complete); - atomic_set(&nss_ipsec.resp, NSS_IPSEC_ERROR_TYPE_NONE); - - nss_ctx->nss_top->ipsec_encap_callback = NULL; - nss_ctx->nss_top->ipsec_decap_callback = NULL; - - nss_ctx->nss_top->ipsec_encap_ctx = NULL; - nss_ctx->nss_top->ipsec_decap_ctx = NULL; - - nss_core_register_handler(nss_ctx, NSS_IPSEC_ENCAP_INTERFACE_NUM, nss_ipsec_msg_handler, NULL); - nss_core_register_handler(nss_ctx, NSS_IPSEC_DECAP_INTERFACE_NUM, nss_ipsec_msg_handler, NULL); -} - -/* - * nss_ipsec_msg_init() - * Initialize ipsec message. - */ -void nss_ipsec_msg_init(struct nss_ipsec_msg *nim, uint16_t if_num, uint32_t type, uint32_t len, - nss_ipsec_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&nim->cm, if_num, type, len, (void *)cb, app_data); -} -EXPORT_SYMBOL(nss_ipsec_msg_init); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn.c deleted file mode 100644 index c5f520da1..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn.c +++ /dev/null @@ -1,525 +0,0 @@ -/* - ************************************************************************** - * 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 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_dynamic_interface.h" -#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) - -/* - * Private data structure for handling synchronous messaging. - */ -static struct nss_ipsec_cmn_pvt { - struct semaphore sem; - struct completion complete; - struct nss_ipsec_cmn_msg nicm; - unsigned long if_map[NSS_IPSEC_CMN_INTERFACE_MAX_LONG]; -} ipsec_cmn_pvt; - -/* - * nss_ipsec_cmn_verify_ifnum() - * Verify if the interface number is a IPsec interface. - */ -static bool nss_ipsec_cmn_verify_ifnum(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - enum nss_dynamic_interface_type type = nss_dynamic_interface_get_type(nss_ctx, if_num); - - if (if_num == NSS_IPSEC_CMN_INTERFACE) - return true; - - switch (type) { - case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_INNER: - case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_OUTER: - case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_MDATA_INNER: - case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_MDATA_OUTER: - case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_REDIRECT: - return true; - - default: - return false; - } - - return false; -} - -/* - * nss_ipsec_cmn_msg_handler() - * Handle NSS -> HLOS messages for IPSEC tunnel. - */ -static void nss_ipsec_cmn_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *app_data) -{ - nss_ipsec_cmn_msg_callback_t cb; - struct nss_ipsec_cmn_msg *nim; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - /* - * Trace messages. - */ - nim = (struct nss_ipsec_cmn_msg *)ncm; - nss_ipsec_cmn_log_rx_msg(nim); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_IPSEC_CMN_MSG_TYPE_MAX) { - 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("%px: Invalid message length(%d)\n", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - 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 - * 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->nss_rx_interface_handlers[ncm->interface].app_data; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Callback - */ - cb = (nss_ipsec_cmn_msg_callback_t)ncm->cb; - app_data = (void *)ncm->app_data; - - /* - * Call IPsec message callback - */ - if (!cb) { - nss_warning("%px: No callback for IPsec interface %d\n", nss_ctx, ncm->interface); - return; - } - - nss_trace("%px: calling ipsecsmgr message handler(%u)\n", nss_ctx, ncm->interface); - cb(app_data, ncm); -} - -/* - * nss_ipsec_cmn_sync_resp() - * Callback to handle the completion of HLOS-->NSS messages. - */ -static void nss_ipsec_cmn_sync_resp(void *app_data, struct nss_cmn_msg *ncm) -{ - struct nss_ipsec_cmn_msg *pvt_msg = app_data; - struct nss_ipsec_cmn_msg *resp_msg = container_of(ncm, struct nss_ipsec_cmn_msg, cm); - - /* - * Copy response message to pvt message - */ - memcpy(pvt_msg, resp_msg, sizeof(*resp_msg)); - - /* - * Write memory barrier - */ - smp_wmb(); - - complete(&ipsec_cmn_pvt.complete); -} - -/* - * 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. - */ -struct nss_ctx_instance *nss_ipsec_cmn_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.ipsec_handler_id]; -} -EXPORT_SYMBOL(nss_ipsec_cmn_get_context); - -/* - * nss_ipsec_cmn_get_ifnum_with_coreid() - * Return IPsec interface number with coreid. - */ -uint32_t nss_ipsec_cmn_get_ifnum_with_coreid(int32_t ifnum) -{ - struct nss_ctx_instance *nss_ctx = nss_ipsec_cmn_get_context(); - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - return NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, ifnum); -} -EXPORT_SYMBOL(nss_ipsec_cmn_get_ifnum_with_coreid); - -/* - * nss_ipsec_cmn_msg_init() - * Initialize message - */ -void nss_ipsec_cmn_msg_init(struct nss_ipsec_cmn_msg *nim, uint16_t if_num, enum nss_ipsec_cmn_msg_type type, - uint16_t len, nss_ipsec_cmn_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&nim->cm, if_num, type, len, cb, app_data); -} -EXPORT_SYMBOL(nss_ipsec_cmn_msg_init); - -/* - * nss_ipsec_cmn_tx_msg() - * Transmit a IPSEC message to NSS FW. - */ -nss_tx_status_t nss_ipsec_cmn_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_ipsec_cmn_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace messages. - */ - nss_ipsec_cmn_log_tx_msg(msg); - - /* - * Sanity check the message - */ - if (ncm->type >= NSS_IPSEC_CMN_MSG_TYPE_MAX) { - 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("%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("%px: Invalid message length(%u)\n", nss_ctx, nss_cmn_get_msg_len(ncm)); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_ipsec_cmn_tx_msg); - -/* - * nss_ipsec_cmn_tx_msg_sync() - * Transmit a IPSEC redir message to NSS firmware synchronously. - */ -nss_tx_status_t nss_ipsec_cmn_tx_msg_sync(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - enum nss_ipsec_cmn_msg_type type, uint16_t len, - struct nss_ipsec_cmn_msg *nicm) -{ - struct nss_ipsec_cmn_msg *local_nicm = &ipsec_cmn_pvt.nicm; - nss_tx_status_t status; - int ret = 0; - - /* - * Length of the message should be the based on type - */ - if (len > sizeof(struct nss_ipsec_cmn_msg)) { - nss_warning("%px: Invalid message length(%u), type (%d), I/F(%u)\n", nss_ctx, len, type, if_num); - return NSS_TX_FAILURE; - } - - down(&ipsec_cmn_pvt.sem); - - /* - * We need to copy the message content into the actual message - * to be sent to NSS - */ - memset(local_nicm, 0, sizeof(*local_nicm)); - - nss_ipsec_cmn_msg_init(local_nicm, if_num, type, len, nss_ipsec_cmn_sync_resp, local_nicm); - memcpy(&local_nicm->msg, &nicm->msg, len); - - status = nss_ipsec_cmn_tx_msg(nss_ctx, local_nicm); - if (status != NSS_TX_SUCCESS) { - 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("%px: Failed to receive response, timeout(%d)\n", nss_ctx, ret); - status = NSS_TX_FAILURE_NOT_READY; - goto done; - } - - /* - * Read memory barrier - */ - smp_rmb(); - - if (local_nicm->cm.response != NSS_CMN_RESPONSE_ACK) { - status = NSS_TX_FAILURE; - nicm->cm.response = local_nicm->cm.response; - nicm->cm.error = local_nicm->cm.error; - goto done; - } - - /* - * Copy the message received - */ - memcpy(&nicm->msg, &local_nicm->msg, len); - -done: - up(&ipsec_cmn_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_ipsec_cmn_tx_msg_sync); - -/* - * nss_ipsec_cmn_tx_buf() - * Send packet to IPsec interface in NSS. - */ -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("%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("%px: Interface number(%d) is not IPSec type\n", nss_ctx, if_num); - return NSS_TX_FAILURE; - } - - return nss_core_send_packet(nss_ctx, os_buf, if_num, H2N_BIT_FLAG_BUFFER_REUSABLE); -} -EXPORT_SYMBOL(nss_ipsec_cmn_tx_buf); - -/* - * nss_ipsec_cmn_register_if() - * Register dynamic node for IPSEC redir. - */ -struct nss_ctx_instance *nss_ipsec_cmn_register_if(uint32_t if_num, struct net_device *netdev, - nss_ipsec_cmn_data_callback_t cb_data, - nss_ipsec_cmn_msg_callback_t cb_msg, - uint32_t features, enum nss_dynamic_interface_type type, void *app_ctx) -{ - struct nss_ctx_instance *nss_ctx = nss_ipsec_cmn_get_context(); - uint32_t status; - - if (!nss_ipsec_cmn_verify_ifnum(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("%px: Failed find free slot for IPsec NSS I/F:%u\n", nss_ctx, if_num); - 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. - */ - status = nss_core_register_handler(nss_ctx, if_num, nss_ipsec_cmn_msg_handler, app_ctx); - if (status != NSS_CORE_STATUS_SUCCESS){ - 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("%px: Failed to register message handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); - return NULL; - } - - nss_core_register_subsys_dp(nss_ctx, if_num, cb_data, NULL, app_ctx, netdev, features); - nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, type); - - /* - * Atomically set the bitmap for the interface number - */ - set_bit(if_num, ipsec_cmn_pvt.if_map); - - return nss_ctx; -} -EXPORT_SYMBOL(nss_ipsec_cmn_register_if); - -/* - * nss_ipsec_cmn_unregister_if() - * Unregister dynamic node for IPSEC redir. - */ -bool nss_ipsec_cmn_unregister_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_ipsec_cmn_get_context(); - struct net_device *dev; - uint32_t status; - - nss_assert(nss_ctx); - - if (!nss_ipsec_cmn_verify_ifnum(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("%px: Failed to find registered netdev for IPsec NSS I/F:%u\n", nss_ctx, if_num); - return false; - } - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - /* - * Atomically clear the bitmap for the interface number - */ - clear_bit(if_num, ipsec_cmn_pvt.if_map); - - 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 false; - } - - 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 false; - } - - return true; -} -EXPORT_SYMBOL(nss_ipsec_cmn_unregister_if); - -/* - * nss_ipsec_cmn_notify_register() - * Register a handler for notification from NSS firmware. - */ -struct nss_ctx_instance *nss_ipsec_cmn_notify_register(uint32_t if_num, nss_ipsec_cmn_msg_callback_t cb, void *app_data) -{ - struct nss_ctx_instance *nss_ctx = nss_ipsec_cmn_get_context(); - uint32_t ret; - - BUG_ON(!nss_ctx); - - ret = nss_core_register_handler(nss_ctx, if_num, nss_ipsec_cmn_msg_handler, app_data); - if (ret != NSS_CORE_STATUS_SUCCESS) { - 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("%px: Failed to register message handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); - return NULL; - } - - return nss_ctx; -} -EXPORT_SYMBOL(nss_ipsec_cmn_notify_register); - -/* - * nss_ipsec_cmn_notify_unregister() - * unregister the IPsec notifier for the given interface number (if_num) - */ -void nss_ipsec_cmn_notify_unregister(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - uint32_t ret; - - if (if_num >= NSS_MAX_NET_INTERFACES) { - 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("%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("%px: unable to unregister event handler for interface(%u)\n", nss_ctx, if_num); - return; - } -} -EXPORT_SYMBOL(nss_ipsec_cmn_notify_unregister); - -/* - * nss_ipsec_cmn_ppe_port_config() - * Configure PPE port for IPsec inline - */ -bool nss_ipsec_cmn_ppe_port_config(struct nss_ctx_instance *nss_ctx, struct net_device *netdev, - uint32_t if_num, uint32_t vsi_num) -{ -#ifdef NSS_PPE_SUPPORTED - 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("%px: Failed to configure PPE IPsec port\n", nss_ctx); - return false; - } - - return true; -#else - return false; -#endif -} -EXPORT_SYMBOL(nss_ipsec_cmn_ppe_port_config); - -/* - * nss_ipsec_cmn_ppe_mtu_update() - * Update PPE MTU for IPsec inline - */ -bool nss_ipsec_cmn_ppe_mtu_update(struct nss_ctx_instance *nss_ctx, uint32_t if_num, uint16_t mtu, uint16_t mru) -{ -#ifdef NSS_PPE_SUPPORTED - 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("%px: Failed to update PPE MTU for IPsec port\n", nss_ctx); - return false; - } - - return true; -#else - return false; -#endif -} -EXPORT_SYMBOL(nss_ipsec_cmn_ppe_mtu_update); - -/* - * nss_ipsec_cmn_register_handler() - * Registering handler for sending msg to base ipsec_cmn node on NSS. - */ -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(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_log.c deleted file mode 100644 index 8ae7928f9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_log.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_ipsec_cmn_log.c - * NSS IPSEC logger file. - */ - -#include "nss_core.h" - -#define NSS_IPSEC_LOG_IPV4 4 -#define NSS_IPSEC_LOG_IPV6 6 - -/* - * nss_ipsec_cmn_log_msg_types_str - * IPSEC message strings - */ -static int8_t *nss_ipsec_cmn_log_msg_types_str[NSS_IPSEC_CMN_MSG_TYPE_MAX] __maybe_unused = { - "IPSEC CMN Msg None", - "IPSEC CMN Node Config", - "IPSEC CMN CTX Config", - "IPSEC CMN CTX Sync", - "IPSEC CMN SA Create", - "IPSEC CMN SA Destroy", - "IPSEC CMN SA Sync", - "IPSEC CMN Flow Create", - "IPSEC CMN Flow Destroy", -}; - -/* - * nss_ipsec_cmn_log_node_msg_types_str - * IPSEC cmn node message strings - */ -static int8_t *nss_ipsec_cmn_log_node_str[] __maybe_unused = { - "IPSEC CMN Node DMA Redirect", - "IPSEC CMN Node DMA Lookaside", - "IPSEC CMN Node Maximum SA", -}; - -/* - * nss_ipsec_cmn_log_ctx_msg_types_str - * IPSEC cmn ctx message strings - */ -static int8_t *nss_ipsec_cmn_log_ctx_str[] __maybe_unused = { - "IPSEC CMN CTX Type", - "IPSEC CMN CTX Exception Interface", -}; - -/* - * nss_ipsec_cmn_log_ctx_types_str - * IPSEC cmn context strings - */ -static int8_t *nss_ipsec_cmn_ctx_types_str[] __maybe_unused = { - "IPSEC CMN CTX NONE", - "IPSEC CMN CTX INNER", - "IPSEC CMN CTX INNER BOUNCE", - "IPSEC CMN CTX OUTER", - "IPSEC CMN CTX OUTER BOUNCE", - "IPSEC CMN CTX REDIRECT", -}; - -/* - * nss_ipsec_cmn_log_flow_tuple_str - * IPSEC cmn flow tuple strings - */ -static int8_t *nss_ipsec_cmn_log_flow_tuple_str[] __maybe_unused = { - "Dest IP", - "Src IP", - "Spi Index", - "Dest Port", - "Src Port", - "User Pattern", - "User Protocol", - "IP Version", -}; - -/* - * nss_ipsec_cmn_log_sa_tuple_str - * IPSEC cmn SA tuple strings - */ -static int8_t *nss_ipsec_cmn_log_sa_tuple_str[] __maybe_unused = { - "Dest IP", - "Src IP", - "Spi Index", - "Dest Port", - "Src Port", - "Crypto Index", - "Protocol", - "IP Version", - "Hop Limit", -}; - -/* - * nss_ipsec_cmn_log_sa_data_str - * IPSEC cmn SA tuple strings - */ -static int8_t *nss_ipsec_cmn_log_sa_data_str[] __maybe_unused = { - "Sequence Start", - "Flags", - "Window Size", - "DSCP", - "DF", - "Block Length", - "IV length", - "ICV length", -}; - -/* - * nss_ipsec_cmn_log_error_str - * Strings for error types for IPSEC messages - */ -static int8_t *nss_ipsec_cmn_log_error_str[NSS_IPSEC_CMN_MSG_ERROR_MAX] __maybe_unused = { - "IPSEC No Error", - "IPSEC Invalid Context", - "IPSEC SA allocation Error", - "IPSEC Invalid SA", - "IPSEC Duplicate SA", - "IPSEC SA is in Use", - "IPSEC Error in Flow Allocation", - "IPSEC Invalid Flow", - "IPSEC Duplicate Flow", - "IPSEC Failure to find SA for Flow", - "IPSEC Failed to Register Dynamic Interface", - "IPSEC Unhandled Message", -}; - -/* - * nss_ipsec_cmn_log_node_msg() - * Log NSS IPSEC node message. - */ -static void nss_ipsec_cmn_log_node_msg(struct nss_ipsec_cmn_msg *nim) -{ - struct nss_ipsec_cmn_node *node_msg __maybe_unused = &nim->msg.node; - - nss_trace("%px: NSS IPSEC Node Message:\n" - "%s: %d\n" - "%s: %d\n" - "%s: %d\n", nim, - nss_ipsec_cmn_log_node_str[0], node_msg->dma_redirect, - nss_ipsec_cmn_log_node_str[1], node_msg->dma_lookaside, - nss_ipsec_cmn_log_node_str[2], node_msg->max_sa); -} - -/* - * nss_ipsec_cmn_log_ctx_msg() - * Log NSS IPSEC ctx message. - */ -static void nss_ipsec_cmn_log_ctx_msg(struct nss_ipsec_cmn_msg *nim) -{ - struct nss_ipsec_cmn_ctx *ctx_msg __maybe_unused = &nim->msg.ctx; - - 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], - nss_ipsec_cmn_log_ctx_str[1], ctx_msg->except_ifnum); -} - -/* - * nss_ipsec_cmn_log_sa_msg() - * Log NSS IPSEC SA message. - */ -static void nss_ipsec_cmn_log_sa_msg(struct nss_ipsec_cmn_msg *nim) -{ - struct nss_ipsec_cmn_sa *sa_msg __maybe_unused = &nim->msg.sa; - 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("%px: NSS IPSEC SA Message:\n", nim); - - if (tuple->ip_ver == 4) { - nss_trace("%s: %pI4\n%s: %pI4\n", - nss_ipsec_cmn_log_sa_tuple_str[0], tuple->dest_ip, - nss_ipsec_cmn_log_sa_tuple_str[1], tuple->src_ip); - } else { - nss_trace("%s: %pI6\n%s: %pI6\n", - nss_ipsec_cmn_log_sa_tuple_str[0], tuple->dest_ip, - nss_ipsec_cmn_log_sa_tuple_str[1], tuple->src_ip); - } - - nss_trace( "%s: %x\n%s: %d\n%s: %d\n%s: %d\n" - "%s: %d\n%s: %d\n%s: %d\n" - "%s: %d\n%s: %x\n%s: %d\n%s: %d\n" - "%s: %d\n%s: %d\n%s: %d\n%s: %d\n", - nss_ipsec_cmn_log_sa_tuple_str[2], tuple->spi_index, - nss_ipsec_cmn_log_sa_tuple_str[3], tuple->dest_port, - nss_ipsec_cmn_log_sa_tuple_str[4], tuple->src_port, - nss_ipsec_cmn_log_sa_tuple_str[5], tuple->crypto_index, - nss_ipsec_cmn_log_sa_tuple_str[6], tuple->protocol, - nss_ipsec_cmn_log_sa_tuple_str[7], tuple->ip_ver, - nss_ipsec_cmn_log_sa_tuple_str[8], tuple->hop_limit, - - nss_ipsec_cmn_log_sa_data_str[0], data->seq_start, - nss_ipsec_cmn_log_sa_data_str[1], data->flags, - nss_ipsec_cmn_log_sa_data_str[2], data->window_size, - nss_ipsec_cmn_log_sa_data_str[3], data->dscp, - nss_ipsec_cmn_log_sa_data_str[4], data->df, - nss_ipsec_cmn_log_sa_data_str[5], data->blk_len, - nss_ipsec_cmn_log_sa_data_str[6], data->iv_len, - nss_ipsec_cmn_log_sa_data_str[7], data->icv_len); - -} - -/* - * nss_ipsec_cmn_log_flow_msg() - * Log NSS IPSEC Flow message. - */ -static void nss_ipsec_cmn_log_flow_msg(struct nss_ipsec_cmn_msg *nim) -{ - struct nss_ipsec_cmn_flow *flow_msg __maybe_unused = &nim->msg.flow; - struct nss_ipsec_cmn_flow_tuple *flow = &flow_msg->flow_tuple; - struct nss_ipsec_cmn_sa_tuple *sa = &flow_msg->sa_tuple; - - nss_trace("%px: NSS IPSEC Flow Message:\n", nim); - - if (sa->ip_ver == 4) { - nss_trace("%s: %pI4\n%s: %pI4\n", - nss_ipsec_cmn_log_sa_tuple_str[0], sa->dest_ip, - nss_ipsec_cmn_log_sa_tuple_str[1], sa->src_ip); - } else { - nss_trace("%s: %pI6\n%s: %pI6\n", - nss_ipsec_cmn_log_sa_tuple_str[0], sa->dest_ip, - nss_ipsec_cmn_log_sa_tuple_str[1], sa->src_ip); - } - - if (flow->ip_ver == 4) { - nss_trace("%s: %pI4\n%s: %pI4\n", - nss_ipsec_cmn_log_sa_tuple_str[0], flow->dest_ip, - nss_ipsec_cmn_log_sa_tuple_str[1], flow->src_ip); - } else { - nss_trace("%s: %pI6\n%s: %pI6\n", - nss_ipsec_cmn_log_sa_tuple_str[0], flow->dest_ip, - nss_ipsec_cmn_log_sa_tuple_str[1], flow->src_ip); - } - - nss_trace( "%s: %x\n%s: %d\n%s: %d\n%s: %d\n" - "%s: %d\n", - nss_ipsec_cmn_log_flow_tuple_str[2], flow->spi_index, - nss_ipsec_cmn_log_flow_tuple_str[3], flow->dst_port, - nss_ipsec_cmn_log_flow_tuple_str[4], flow->src_port, - nss_ipsec_cmn_log_flow_tuple_str[5], flow->user_pattern, - nss_ipsec_cmn_log_flow_tuple_str[6], flow->protocol); - - nss_trace( "%s: %x\n%s: %d\n%s: %d\n%s: %d\n" - "%s: %d\n%s: %d\n%s: %d\n", - nss_ipsec_cmn_log_sa_tuple_str[2], sa->spi_index, - nss_ipsec_cmn_log_sa_tuple_str[3], sa->dest_port, - nss_ipsec_cmn_log_sa_tuple_str[4], sa->src_port, - nss_ipsec_cmn_log_sa_tuple_str[5], sa->crypto_index, - nss_ipsec_cmn_log_sa_tuple_str[6], sa->protocol, - nss_ipsec_cmn_log_sa_tuple_str[7], sa->ip_ver, - nss_ipsec_cmn_log_sa_tuple_str[8], sa->hop_limit); -} - -/* - * nss_ipsec_cmn_log_verbose() - * Log message contents. - */ -static void nss_ipsec_cmn_log_verbose(struct nss_ipsec_cmn_msg *nim) -{ - switch (nim->cm.type) { - case NSS_IPSEC_CMN_MSG_TYPE_NODE_CONFIG: - nss_ipsec_cmn_log_node_msg(nim); - break; - - case NSS_IPSEC_CMN_MSG_TYPE_CTX_CONFIG: - nss_ipsec_cmn_log_ctx_msg(nim); - break; - - case NSS_IPSEC_CMN_MSG_TYPE_SA_CREATE: - case NSS_IPSEC_CMN_MSG_TYPE_SA_DESTROY: - nss_ipsec_cmn_log_sa_msg(nim); - break; - - case NSS_IPSEC_CMN_MSG_TYPE_FLOW_CREATE: - case NSS_IPSEC_CMN_MSG_TYPE_FLOW_DESTROY: - nss_ipsec_cmn_log_flow_msg(nim); - break; - - case NSS_IPSEC_CMN_MSG_TYPE_CTX_SYNC: - case NSS_IPSEC_CMN_MSG_TYPE_SA_SYNC: - /* - * No log for these valid messages. - */ - break; - - default: - nss_warning("%px: Invalid message type\n", nim); - break; - } -} - -/* - * nss_ipsec_cmn_log_tx_msg() - * Log messages transmitted to FW. - */ -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("%px: Invalid message type\n", nim); - return; - } - - 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); -} - -/* - * nss_ipsec_cmn_log_rx_msg() - * Log messages received from FW. - */ -void nss_ipsec_cmn_log_rx_msg(struct nss_ipsec_cmn_msg *nim) -{ - if (nim->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_ipsec_cmn_log_verbose(nim); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_log.h deleted file mode 100644 index d99c8be4c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * Copyright (c) 2018-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. - * **************************************************************************** - */ - -#ifndef __NSS_IPSEC_CMN_LOG_H__ -#define __NSS_IPSEC_CMN_LOG_H__ - -/* - * nss_ipsec_cmn_log.h - * NSS Crypto Log Header File - */ - -/* - * nss_ipsec_cmn_log_tx_msg - * Logs a ipsec message that is sent to the NSS firmware. - */ -void nss_ipsec_cmn_log_tx_msg(struct nss_ipsec_cmn_msg *nim); - -/* - * nss_ipsec_cmn_log_rx_msg - * Logs a ipsec message that is received from the NSS firmware. - */ -void nss_ipsec_cmn_log_rx_msg(struct nss_ipsec_cmn_msg *nim); - -#endif /* __NSS_IPSEC_CMN_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_stats.c deleted file mode 100644 index 192f2291a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_stats.h deleted file mode 100644 index 511056802..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_strings.c deleted file mode 100644 index bf2cff6c5..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_cmn_strings.h deleted file mode 100644 index c22f4c0f1..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_log.c deleted file mode 100644 index 2f1570efb..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_log.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_ipsec_log.c - * NSS IPSEC logger file. - */ - -#include "nss_core.h" - -#define NSS_IPSEC_LOG_IPV4 4 -#define NSS_IPSEC_LOG_IPV6 6 - -/* - * nss_ipsec_log_message_types_str - * IPSEC message strings - */ -static int8_t *nss_ipsec_log_message_types_str[NSS_IPSEC_MSG_TYPE_MAX] __maybe_unused = { - "IPSEC Msg None", - "IPSEC ADD Rule", - "IPSEC DEL Rule", - "IPSEC Flush Tunnel", - "IPSEC SA Stats", - "IPSEC Flow Stats", - "IPSEC Node Stats", - "IPSEC Configure Node", -}; - -/* - * nss_ipsec_log_error_response_types_str - * Strings for error types for IPSEC messages - */ -static int8_t *nss_ipsec_log_error_response_types_str[NSS_IPSEC_ERROR_TYPE_MAX] __maybe_unused = { - "IPSEC No Error", - "IPSEC Hash Duplicate", - "IPSEC Hash Collision", - "IPSEC Unhandled Message", - "IPSEC Invalid Rule", - "IPSEC MAX SA", - "IPSEC MAX Flow", - "IPSEC Invalid CINDEX", - "IPSEC Invalid IP Version", -}; - -/* - * nss_ipsec_log_rule_msg() - * Log NSS IPSEC rule message. - */ -static void nss_ipsec_log_rule_msg(struct nss_ipsec_msg *nim) -{ - struct nss_ipsec_rule *nir __maybe_unused = &nim->msg.rule; - - nss_trace("%px: NSS IPSEC Rule Message:\n" - "IPSEC ESP SPI Index: %dn" - "IPSEC TTL Hop Limit: %dn" - "IPSEC IP Version: %x\n" - "IPSEC Crypto Index: %d\n" - "IPSEC Window Size: %d\n" - "IPSEC Cipher Block Len: %d\n" - "IPSEC Initialization Vector Length: %d\n" - "IPSEC NAT-T Required: %d\n" - "IPSEC ICV Length: %d\n" - "IPSEC Skip Seq Number: %d\n" - "IPSEC Skip ESP Trailer: %d\n" - "IPSEC Use Pattern: %d\n" - "IPSEC Enable Extended Sequence Number: %d\n" - "IPSEC DSCP Value: %d\n" - "IPSEC Don't Fragment Flag: %d\n" - "IPSEC DSCP Copy %d\n" - "IPSEC DF Copy: %d\n" - "IPSEC NSS Index: %d\n" - "IPSEC SA Index: %d\n", - nir, nir->oip.esp_spi, - nir->oip.ttl_hop_limit, nir->oip.ip_ver, - nir->data.crypto_index, nir->data.window_size, - nir->data.cipher_blk_len, nir->data.iv_len, - nir->data.nat_t_req, nir->data.esp_icv_len, - nir->data.esp_seq_skip, nir->data.esp_tail_skip, - nir->data.use_pattern, nir->data.enable_esn, - nir->data.dscp, nir->data.df, - nir->data.copy_dscp, nir->data.copy_df, - nir->index, nir->sa_idx); - - /* - * Continuation of previous log. Different identifiers based on ip_ver - */ - if (nir->oip.ip_ver == NSS_IPSEC_LOG_IPV6) { - nss_trace("IPSEC Destination Address: %pI6\n" - "IPSEC Source Address: %pI6\n", - nir->oip.dst_addr, nir->oip.src_addr); - } else if (nir->oip.ip_ver == NSS_IPSEC_LOG_IPV4) { - nss_trace("IPSEC Destination Address: %pI4\n" - "IPSEC Source Address: %pI4\n", - nir->oip.dst_addr, nir->oip.src_addr); - } -} - -/* - * nss_ipsec_log_configure_node_msg() - * Log NSS IPSEC configure node message. - */ -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("%px: NSS IPSEC Configure Node\n" - "IPSEC DMA Redirect: %d\n" - "IPSEC DMA Lookaside: %d\n", - nicn, nicn->dma_redirect, - nicn->dma_lookaside); -} - -/* - * nss_ipsec_log_verbose() - * Log message contents. - */ -static void nss_ipsec_log_verbose(struct nss_ipsec_msg *nim) -{ - switch (nim->cm.type) { - case NSS_IPSEC_MSG_TYPE_ADD_RULE: - case NSS_IPSEC_MSG_TYPE_DEL_RULE: - nss_ipsec_log_rule_msg(nim); - break; - - case NSS_IPSEC_MSG_TYPE_CONFIGURE_NODE: - nss_ipsec_log_configure_node_msg(nim); - break; - - case NSS_IPSEC_MSG_TYPE_NONE: - case NSS_IPSEC_MSG_TYPE_FLUSH_TUN: - case NSS_IPSEC_MSG_TYPE_SYNC_SA_STATS: - case NSS_IPSEC_MSG_TYPE_SYNC_FLOW_STATS: - case NSS_IPSEC_MSG_TYPE_SYNC_NODE_STATS: - /* - * No log for these valid messages. - */ - break; - - default: - nss_warning("%px: Invalid message type\n", nim); - break; - } -} - -/* - * nss_ipsec_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_ipsec_log_tx_msg(struct nss_ipsec_msg *nim) -{ - if (nim->cm.type >= NSS_IPSEC_MSG_TYPE_MAX) { - nss_warning("%px: Invalid message type\n", nim); - return; - } - - 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); -} - -/* - * nss_ipsec_log_rx_msg() - * Log messages received from FW. - */ -void nss_ipsec_log_rx_msg(struct nss_ipsec_msg *nim) -{ - if (nim->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_ipsec_log_verbose(nim); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_log.h deleted file mode 100644 index 5342c208f..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipsec_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_LOG_H__ -#define __NSS_IPSEC_LOG_H__ - -/* - * nss_ipsec_log.h - * NSS Crypto Log Header File - */ - -/* - * nss_ipsec_log_tx_msg - * Logs a ipsec message that is sent to the NSS firmware. - */ -void nss_ipsec_log_tx_msg(struct nss_ipsec_msg *nim); - -/* - * nss_ipsec_log_rx_msg - * Logs a ipsec message that is received from the NSS firmware. - */ -void nss_ipsec_log_rx_msg(struct nss_ipsec_msg *nim); - -#endif /* __NSS_IPSEC_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv4.c deleted file mode 100644 index e1e045206..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4.c +++ /dev/null @@ -1,782 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipv4.c - * NSS IPv4 APIs - */ -#include -#include "nss_dscp_map.h" -#include "nss_ipv4_stats.h" -#include "nss_ipv4_strings.h" - -#define NSS_IPV4_TX_MSG_TIMEOUT 1000 /* 1 sec timeout for IPv4 messages */ - -/* - * Private data structure for ipv4 configuration - */ -struct nss_ipv4_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_ipv4_pvt; - -/* - * Private data structure for ipv4 connection information. - */ -struct nss_ipv4_conn_table_info { - uint32_t ce_table_size; /* Size of connection table entry in NSS FW */ - uint32_t cme_table_size; /* Size of connection match table entry in NSS FW */ - unsigned long ce_mem; /* Start address for connection entry table */ - unsigned long cme_mem; /* Start address for connection match entry table */ -} nss_ipv4_ct_info; - -int nss_ipv4_conn_cfg = NSS_DEFAULT_NUM_CONN; -int nss_ipv4_accel_mode_cfg __read_mostly = 1; - -static struct nss_dscp_map_entry mapping[NSS_DSCP_MAP_ARRAY_SIZE]; - -/* - * Callback for conn_sync_many request message. - */ -nss_ipv4_msg_callback_t nss_ipv4_conn_sync_many_msg_cb = NULL; - -/* - * nss_ipv4_dscp_map_usage() - * Help function shows the usage of the command. - */ -static inline void nss_ipv4_dscp_map_usage(void) -{ - nss_info_always("\nUsage:\n"); - nss_info_always("echo > /proc/sys/dev/nss/ipv4cfg/ipv4_dscp_map\n\n"); - nss_info_always("dscp[0-63] action[0-%u] prio[0-%u]:\n\n", - NSS_IPV4_DSCP_MAP_ACTION_MAX - 1, - NSS_DSCP_MAP_PRIORITY_MAX - 1); -} - -/* - * 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 - */ -static void nss_ipv4_rx_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_ipv4_msg *nim = (struct nss_ipv4_msg *)ncm; - nss_ipv4_msg_callback_t cb; - - BUG_ON(ncm->interface != NSS_IPV4_RX_INTERFACE); - - /* - * Sanity check the message type - */ - if (ncm->type >= NSS_IPV4_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_ipv4_msg)) { - nss_warning("%px: message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Trace messages. - */ - nss_ipv4_log_rx_msg(nim); - - switch (nim->cm.type) { - case NSS_IPV4_RX_NODE_STATS_SYNC_MSG: - /* - * Update driver statistics on node sync and send statistics notifications to the registered modules. - */ - nss_ipv4_stats_node_sync(nss_ctx, &nim->msg.node_stats); - nss_ipv4_stats_notify(nss_ctx); - break; - - case NSS_IPV4_RX_CONN_STATS_SYNC_MSG: - /* - * Update driver statistics on connection sync. - */ - nss_ipv4_stats_conn_sync(nss_ctx, &nim->msg.conn_stats); - break; - - case NSS_IPV4_TX_CONN_STATS_SYNC_MANY_MSG: - /* - * Update driver statistics on connection sync many. - */ - nss_ipv4_stats_conn_sync_many(nss_ctx, &nim->msg.conn_stats_many); - ncm->cb = (nss_ptr_t)nss_ipv4_conn_sync_many_msg_cb; - break; - } - - /* - * Update the callback and app_data for NOTIFY messages, IPv4 sends all notify messages - * to the same callback/app_data. - */ - if (nim->cm.response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->ipv4_callback; - ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->ipv4_ctx; - } - - /* - * Do we have a callback? - */ - if (!ncm->cb) { - return; - } - - /* - * Callback - */ - cb = (nss_ipv4_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, nim); -} - -/* - * nss_ipv4_tx_sync_callback() - * Callback to handle the completion of synchronous tx messages. - */ -static void nss_ipv4_tx_sync_callback(void *app_data, struct nss_ipv4_msg *nim) -{ - nss_ipv4_msg_callback_t callback = (nss_ipv4_msg_callback_t)nss_ipv4_pvt.cb; - void *data = nss_ipv4_pvt.app_data; - - nss_ipv4_pvt.cb = NULL; - nss_ipv4_pvt.app_data = NULL; - - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("ipv4 error response %d\n", nim->cm.response); - nss_ipv4_pvt.response = NSS_TX_FAILURE; - } else { - nss_ipv4_pvt.response = NSS_TX_SUCCESS; - } - - if (callback) { - callback(data, nim); - } - - complete(&nss_ipv4_pvt.complete); -} - -/* - * nss_ipv4_dscp_action_get() - * Gets the action mapped to dscp. - */ -enum nss_ipv4_dscp_map_actions nss_ipv4_dscp_action_get(uint8_t dscp) -{ - if (dscp >= NSS_DSCP_MAP_ARRAY_SIZE) { - nss_warning("dscp:%u invalid\n", dscp); - return NSS_IPV4_DSCP_MAP_ACTION_MAX; - } - - return mapping[dscp].action; -} -EXPORT_SYMBOL(nss_ipv4_dscp_action_get); - -/* - * nss_ipv4_max_conn_count() - * Return the maximum number of IPv4 connections that the NSS acceleration engine supports. - */ -int nss_ipv4_max_conn_count(void) -{ - return nss_ipv4_conn_cfg; -} -EXPORT_SYMBOL(nss_ipv4_max_conn_count); - -/* - * nss_ipv4_conn_inquiry() - * Inquiry if a connection has been established in NSS FW - */ -nss_tx_status_t nss_ipv4_conn_inquiry(struct nss_ipv4_5tuple *ipv4_5t_p, - nss_ipv4_msg_callback_t cb) -{ - nss_tx_status_t nss_tx_status; - struct nss_ipv4_msg nim; - struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[0]; - - /* - * Initialize inquiry message structure. - * This is async message and the result will be returned - * to the caller by the msg_callback passed in. - */ - memset(&nim, 0, sizeof(nim)); - nss_ipv4_msg_init(&nim, NSS_IPV4_RX_INTERFACE, - NSS_IPV4_TX_CONN_CFG_INQUIRY_MSG, - sizeof(struct nss_ipv4_inquiry_msg), - cb, NULL); - 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("%px: Send inquiry message failed\n", ipv4_5t_p); - } - - return nss_tx_status; -} -EXPORT_SYMBOL(nss_ipv4_conn_inquiry); - -/* - * nss_ipv4_tx_with_size() - * Transmit an ipv4 message to the FW with a specified size. - */ -nss_tx_status_t nss_ipv4_tx_with_size(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_msg *nim, uint32_t size) -{ - struct nss_cmn_msg *ncm = &nim->cm; - - /* - * Sanity check the message - */ - if (ncm->interface != NSS_IPV4_RX_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("%px: message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - /* - * Trace messages. - */ - nss_ipv4_log_tx_msg(nim); - - return nss_core_send_cmd(nss_ctx, nim, sizeof(*nim), size); -} -EXPORT_SYMBOL(nss_ipv4_tx_with_size); - -/* - * nss_ipv4_tx() - * Transmit an ipv4 message to the FW. - */ -nss_tx_status_t nss_ipv4_tx(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_msg *nim) -{ - return nss_ipv4_tx_with_size(nss_ctx, nim, NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_ipv4_tx); - -/* - * nss_ipv4_tx_sync() - * Transmit a synchronous ipv4 message to the FW. - */ -nss_tx_status_t nss_ipv4_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_msg *nim) -{ - nss_tx_status_t status; - int ret = 0; - - down(&nss_ipv4_pvt.sem); - nss_ipv4_pvt.cb = (void *)nim->cm.cb; - nss_ipv4_pvt.app_data = (void *)nim->cm.app_data; - - nim->cm.cb = (nss_ptr_t)nss_ipv4_tx_sync_callback; - nim->cm.app_data = (nss_ptr_t)NULL; - - status = nss_ipv4_tx(nss_ctx, nim); - if (status != NSS_TX_SUCCESS) { - 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("%px: IPv4 tx sync failed due to timeout\n", nss_ctx); - nss_ipv4_pvt.response = NSS_TX_FAILURE; - } - - status = nss_ipv4_pvt.response; - up(&nss_ipv4_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_ipv4_tx_sync); - -/* - ********************************** - Register/Unregister/Miscellaneous APIs - ********************************** - */ - -/* - * nss_ipv4_notify_register() - * Register to received IPv4 events. - * - * NOTE: Do we want to pass an nss_ctx here so that we can register for ipv4 on any core? - */ -struct nss_ctx_instance *nss_ipv4_notify_register(nss_ipv4_msg_callback_t cb, void *app_data) -{ - /* - * TODO: We need to have a new array in support of the new API - * TODO: If we use a per-context array, we would move the array into nss_ctx based. - */ - nss_top_main.ipv4_callback = cb; - nss_top_main.ipv4_ctx = app_data; - return &nss_top_main.nss[nss_top_main.ipv4_handler_id]; -} -EXPORT_SYMBOL(nss_ipv4_notify_register); - -/* - * nss_ipv4_notify_unregister() - * Unregister to received IPv4 events. - * - * NOTE: Do we want to pass an nss_ctx here so that we can register for ipv4 on any core? - */ -void nss_ipv4_notify_unregister(void) -{ - nss_top_main.ipv4_callback = NULL; -} -EXPORT_SYMBOL(nss_ipv4_notify_unregister); - -/* - * nss_ipv4_conn_sync_many_notify_register() - * Register to receive IPv4 conn_sync_many message response. - */ -void nss_ipv4_conn_sync_many_notify_register(nss_ipv4_msg_callback_t cb) -{ - nss_ipv4_conn_sync_many_msg_cb = cb; -} -EXPORT_SYMBOL(nss_ipv4_conn_sync_many_notify_register); - -/* - * nss_ipv4_conn_sync_many_notify_unregister() - * Unregister to receive IPv4 conn_sync_many message response. - */ -void nss_ipv4_conn_sync_many_notify_unregister(void) -{ - nss_ipv4_conn_sync_many_msg_cb = NULL; -} -EXPORT_SYMBOL(nss_ipv4_conn_sync_many_notify_unregister); - -/* - * nss_ipv4_get_mgr() - * - * TODO: This only suppports a single ipv4, do we ever want to support more? - */ -struct nss_ctx_instance *nss_ipv4_get_mgr(void) -{ - return (void *)&nss_top_main.nss[nss_top_main.ipv4_handler_id]; -} -EXPORT_SYMBOL(nss_ipv4_get_mgr); - -/* - * nss_ipv4_register_handler() - * Register our handler to receive messages for this interface - */ -void nss_ipv4_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_ipv4_get_mgr(); - - if (nss_core_register_handler(nss_ctx, NSS_IPV4_RX_INTERFACE, nss_ipv4_rx_msg_handler, NULL) != NSS_CORE_STATUS_SUCCESS) { - nss_warning("IPv4 handler failed to register"); - } - - nss_ipv4_stats_dentry_create(); - nss_ipv4_strings_dentry_create(); -} - -/* - * nss_ipv4_conn_cfg_process_callback() - * Call back function for the ipv4 connection configure process - */ -static void nss_ipv4_conn_cfg_process_callback(void *app_data, struct nss_ipv4_msg *nim) -{ - struct nss_ipv4_rule_conn_cfg_msg *nirccm = &nim->msg.rule_conn_cfg; - struct nss_ctx_instance *nss_ctx __maybe_unused = nss_ipv4_get_mgr(); - - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - 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("%px: IPv4 connection configuration success: %d\n", nss_ctx, nim->cm.error); -} - -/* - * nss_ipv4_conn_cfg_process() - * Process request to configure number of ipv4 connections - */ -static int nss_ipv4_conn_cfg_process(struct nss_ctx_instance *nss_ctx, int conn) -{ - struct nss_ipv4_msg nim; - struct nss_ipv4_rule_conn_cfg_msg *nirccm; - nss_tx_status_t nss_tx_status; - - if ((!nss_ipv4_ct_info.ce_table_size) || (!nss_ipv4_ct_info.cme_table_size)) { - nss_warning("%px: connection entry or connection match entry table size not available\n", - nss_ctx); - return -EINVAL; - } - - 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, - 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", - nss_ctx, - conn); - goto fail; - } - - nss_ipv4_ct_info.cme_mem = __get_free_pages(GFP_ATOMIC | __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", - nss_ctx, - conn); - goto fail; - } - - memset(&nim, 0, sizeof(struct nss_ipv4_msg)); - nss_ipv4_msg_init(&nim, NSS_IPV4_RX_INTERFACE, NSS_IPV4_TX_CONN_CFG_RULE_MSG, - sizeof(struct nss_ipv4_rule_conn_cfg_msg), nss_ipv4_conn_cfg_process_callback, NULL); - - nirccm = &nim.msg.rule_conn_cfg; - 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("%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("%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("%px: nss_tx error setting IPv4 Connections: %d\n", - nss_ctx, - conn); - goto fail; - } - - return 0; - -fail: - nss_ipv4_free_conn_tables(); - return -EINVAL;; -} - -/* - * nss_ipv4_update_conn_count_callback() - * Callback function for the ipv4 get connection info message. - */ -static void nss_ipv4_update_conn_count_callback(void *app_data, struct nss_ipv4_msg *nim) -{ - struct nss_ipv4_rule_conn_get_table_size_msg *nircgts = &nim->msg.size; - struct nss_ctx_instance *nss_ctx = nss_ipv4_get_mgr(); - - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - 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; - } - - nss_info("IPv4 get connection info success\n"); - - nss_ipv4_ct_info.ce_table_size = ntohl(nircgts->ce_table_size); - 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("%px: IPv4 connection entry or connection match entry table size\ - not available\n", nss_ctx); - } - - return; -} - -/* - * nss_ipv4_update_conn_count() - * Sets the maximum number of IPv4 connections. - * - * It first gets the connection tables size information from NSS FW - * and then configures the connections in NSS FW. - */ -int nss_ipv4_update_conn_count(int ipv4_num_conn) -{ - struct nss_ctx_instance *nss_ctx = nss_ipv4_get_mgr(); - struct nss_ipv4_msg nim; - struct nss_ipv4_rule_conn_get_table_size_msg *nircgts; - nss_tx_status_t nss_tx_status; - uint32_t sum_of_conn; - - /* - * By default, NSS FW is configured with default number of connections. - */ - if (ipv4_num_conn == NSS_FW_DEFAULT_NUM_CONN) { - nss_info("%px: Default number of connections (%d) already configured\n", nss_ctx, ipv4_num_conn); - return 0; - } - - /* - * The input should be multiple of 1024. - * Input for ipv4 and ipv6 sum together should not exceed 8k - * 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); - - 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("%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, - ipv4_num_conn, - NSS_MIN_NUM_CONN, - NSS_MAX_TOTAL_NUM_CONN_IPV4_IPV6); - return -EINVAL; - } - - memset(&nim, 0, sizeof(struct nss_ipv4_msg)); - nss_ipv4_msg_init(&nim, NSS_IPV4_RX_INTERFACE, NSS_IPV4_TX_CONN_TABLE_SIZE_MSG, - sizeof(struct nss_ipv4_rule_conn_get_table_size_msg), nss_ipv4_update_conn_count_callback, NULL); - - nircgts = &nim.msg.size; - nircgts->num_conn = htonl(ipv4_num_conn); - nss_tx_status = nss_ipv4_tx(nss_ctx, &nim); - - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: Send fetch connection info message failed\n", nss_ctx); - return -EINVAL; - } - - return 0; -} - -/* - * nss_ipv4_free_conn_tables() - * Frees memory allocated for connection tables - */ -void nss_ipv4_free_conn_tables(void) -{ - if (nss_ipv4_ct_info.ce_mem) { - free_pages(nss_ipv4_ct_info.ce_mem, get_order(nss_ipv4_ct_info.ce_table_size)); - } - - if (nss_ipv4_ct_info.cme_mem) { - free_pages(nss_ipv4_ct_info.cme_mem, get_order(nss_ipv4_ct_info.cme_table_size)); - } - - memset(&nss_ipv4_ct_info, 0, sizeof(struct nss_ipv4_conn_table_info)); - return; -} - -/* - * nss_ipv4_accel_mode_cfg_handler() - * Configure acceleration mode for IPv4 - */ -static int nss_ipv4_accel_mode_cfg_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; - struct nss_ipv4_msg nim; - struct nss_ipv4_accel_mode_cfg_msg *nipcm; - nss_tx_status_t nss_tx_status; - int ret = NSS_FAILURE; - int current_value; - - /* - * Take snap shot of current value - */ - current_value = nss_ipv4_accel_mode_cfg; - - /* - * Write the variable with user input - */ - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret || (!write)) { - return ret; - } - - memset(&nim, 0, sizeof(struct nss_ipv4_msg)); - nss_ipv4_msg_init(&nim, NSS_IPV4_RX_INTERFACE, NSS_IPV4_TX_ACCEL_MODE_CFG_MSG, - sizeof(struct nss_ipv4_accel_mode_cfg_msg), NULL, NULL); - - nipcm = &nim.msg.accel_mode_cfg; - nipcm->mode = htonl(nss_ipv4_accel_mode_cfg); - - nss_tx_status = nss_ipv4_tx_sync(nss_ctx, &nim); - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: Send acceleration mode message failed\n", nss_ctx); - nss_ipv4_accel_mode_cfg = current_value; - return -EIO; - } - - return 0; -} - -/* - * nss_ipv4_dscp_map_cfg_handler() - * Sysctl handler for dscp/pri mappings. - */ -static int nss_ipv4_dscp_map_cfg_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; - struct nss_dscp_map_parse out; - struct nss_ipv4_msg nim; - struct nss_ipv4_dscp2pri_cfg_msg *nipd2p; - nss_tx_status_t status; - int ret; - - if (!write) { - return nss_dscp_map_print(ctl, buffer, lenp, ppos, mapping); - } - - ret = nss_dscp_map_parse(ctl, buffer, lenp, ppos, &out); - if (ret) { - nss_warning("failed to parse dscp mapping:%d\n", ret); - nss_ipv4_dscp_map_usage(); - return ret; - } - - if (out.action >= NSS_IPV4_DSCP_MAP_ACTION_MAX) { - nss_warning("invalid action value: %d\n", out.action); - nss_ipv4_dscp_map_usage(); - return -EINVAL; - } - - memset(&nim, 0, sizeof(struct nss_ipv4_msg)); - nss_ipv4_msg_init(&nim, NSS_IPV4_RX_INTERFACE, NSS_IPV4_TX_DSCP2PRI_CFG_MSG, - sizeof(struct nss_ipv4_dscp2pri_cfg_msg), NULL, NULL); - - nipd2p = &nim.msg.dscp2pri_cfg; - nipd2p->dscp = out.dscp; - nipd2p->priority = out.priority; - - status = nss_ipv4_tx_sync(nss_ctx, &nim); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: ipv4 dscp2pri config message failed\n", nss_ctx); - return -EFAULT; - } - - /* - * NSS firmware acknowleged the configuration, so update the mapping - * table on HOST side as well. - */ - mapping[out.dscp].action = out.action; - mapping[out.dscp].priority = out.priority; - - return 0; -} - -static struct ctl_table nss_ipv4_table[] = { - { - .procname = "ipv4_accel_mode", - .data = &nss_ipv4_accel_mode_cfg, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_ipv4_accel_mode_cfg_handler, - }, - { - .procname = "ipv4_dscp_map", - .data = &mapping[NSS_DSCP_MAP_ARRAY_SIZE], - .maxlen = sizeof(struct nss_dscp_map_entry), - .mode = 0644, - .proc_handler = &nss_ipv4_dscp_map_cfg_handler, - }, - { } -}; - -static struct ctl_table nss_ipv4_dir[] = { - { - .procname = "ipv4cfg", - .mode = 0555, - .child = nss_ipv4_table, - }, - { } -}; - -static struct ctl_table nss_ipv4_root_dir[] = { - { - .procname = "nss", - .mode = 0555, - .child = nss_ipv4_dir, - }, - { } -}; - -static struct ctl_table nss_ipv4_root[] = { - { - .procname = "dev", - .mode = 0555, - .child = nss_ipv4_root_dir, - }, - { } -}; - -static struct ctl_table_header *nss_ipv4_header; - -/* - * nss_ipv4_register_sysctl() - * Register sysctl specific to ipv4 - */ -void nss_ipv4_register_sysctl(void) -{ - sema_init(&nss_ipv4_pvt.sem, 1); - init_completion(&nss_ipv4_pvt.complete); - - /* - * Register sysctl table. - */ - nss_ipv4_header = register_sysctl_table(nss_ipv4_root); -} - -/* - * nss_ipv4_unregister_sysctl() - * Unregister sysctl specific to ipv4 - */ -void nss_ipv4_unregister_sysctl(void) -{ - /* - * Unregister sysctl table. - */ - if (nss_ipv4_header) { - unregister_sysctl_table(nss_ipv4_header); - } -} - -/* - * nss_ipv4_msg_init() - * Initialize IPv4 message. - */ -void nss_ipv4_msg_init(struct nss_ipv4_msg *nim, uint16_t if_num, uint32_t type, uint32_t len, - nss_ipv4_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&nim->cm, if_num, type, len, (void *)cb, app_data); -} -EXPORT_SYMBOL(nss_ipv4_msg_init); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_log.c deleted file mode 100644 index 08414051d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_log.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2016, 2018, 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_ipv4_log.c - * NSS IPv4 logger file. - */ - -#include "nss_core.h" - -/* - * nss_ipv4_log_message_types_str - * IPv4 bridge/route rule message strings - */ -static int8_t *nss_ipv4_log_message_types_str[NSS_IPV4_MAX_MSG_TYPES] __maybe_unused = { - "IPv4 create rule message", - "IPv4 destroy rule message", - "Deprecated: NSS_IPV4_RX_ESTABLISH_RULE_MSG", - "IPv4 connection stats sync message", - "IPv4 generic statistics sync message", - "IPv4 number of connections supported rule message", - "IPv4 multicast create rule message", - "IPv4 request FW to send many conn sync message", -}; - -/* - * nss_ipv4_log_error_response_types_str - * Strings for error types for ipv4 messages - */ -static int8_t *nss_ipv4_log_error_response_types_str[NSS_IPV4_LAST] __maybe_unused = { - "No error", - "Unknown error", - "Invalid interface number", - "Missing connection rule", - "Buffer allocation failure", - "No connection found to delete", - "Conn cfg already done once", - "Conn cfg input is not multiple of quanta", - "Conn cfg input exceeds max supported connections", - "Conn cfg mem alloc fail at NSS FW", - "Invalid L4 protocol for multicast rule create", - "Invalid multicast flags for multicast update", - "Invalid interface for multicast update", -}; - -/* - * nss_ipv4_log_rule_create_msg() - * Log IPv4 create rule message. - */ -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("%px: IPv4 create rule message \n" - "Protocol: %d\n" - "from_mtu: %u\n" - "to_mtu: %u\n" - "from_ip: %pI4h:%d\n" - "to_ip: %pI4h:%d\n" - "from_ip_xlate: %pI4h:%d\n" - "to_ip_xlate: %pI4h:%d\n" - "from_mac: %pM\n" - "to_mac: %pM\n" - "src_iface_num: %u\n" - "dest_iface_num: %u\n" - "ingress_inner_vlan_tag: %u\n" - "egress_inner_vlan_tag: %u\n" - "ingress_outer_vlan_tag: %u\n" - "egress_outer_vlan_tag: %u\n" - "rule_flags: %x\n" - "valid_flags: %x\n" - "return_pppoe_if_exist: %u\n" - "return_pppoe_if_num: %u\n" - "flow_pppoe_if_exist: %u\n" - "flow_pppoe_if_num: %u\n" - "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", - nim, - nircm->tuple.protocol, - nircm->conn_rule.flow_mtu, - nircm->conn_rule.return_mtu, - &nircm->tuple.flow_ip, nircm->tuple.flow_ident, - &nircm->tuple.return_ip, nircm->tuple.return_ident, - &nircm->conn_rule.flow_ip_xlate, nircm->conn_rule.flow_ident_xlate, - &nircm->conn_rule.return_ip_xlate, nircm->conn_rule.return_ident_xlate, - nircm->conn_rule.flow_mac, - nircm->conn_rule.return_mac, - nircm->conn_rule.flow_interface_num, - nircm->conn_rule.return_interface_num, - nircm->vlan_primary_rule.ingress_vlan_tag, - nircm->vlan_primary_rule.egress_vlan_tag, - nircm->vlan_secondary_rule.ingress_vlan_tag, - nircm->vlan_secondary_rule.egress_vlan_tag, - nircm->rule_flags, - nircm->valid_flags, - nircm->pppoe_rule.return_if_exist, - nircm->pppoe_rule.return_if_num, - nircm->pppoe_rule.flow_if_exist, - nircm->pppoe_rule.flow_if_num, - 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); -} - -/* - * nss_ipv4_log_destroy_rule_msg() - * Log IPv4 destroy rule message. - */ -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("%px: IPv4 destroy rule message: \n" - "flow_ip: %pI4h:%d\n" - "return_ip: %pI4h:%d\n" - "protocol: %d\n", - nim, - &nirdm->tuple.flow_ip, nirdm->tuple.flow_ident, - &nirdm->tuple.return_ip, nirdm->tuple.return_ident, - nirdm->tuple.protocol); -} - -/* - * nss_ipv4_log_conn_sync() - * Log IPv4 connection stats sync message. - */ -static void nss_ipv4_log_conn_sync(struct nss_ipv4_msg *nim) -{ - struct nss_ipv4_conn_sync *sync = &nim->msg.conn_stats; - if (sync->flow_tx_packet_count || sync->return_tx_packet_count) { - nss_trace("%px: IPv4 connection stats sync message: \n" - "Protocol: %d\n" - "src_addr: %pI4h:%d\n" - "dest_addr: %pI4h:%d\n" - "flow_rx_packet_count: %u\n" - "flow_rx_byte_count: %u\n" - "return_rx_packet_count: %u\n" - "return_rx_byte_count: %u\n" - "flow_tx_packet_count: %u\n" - "flow_tx_byte_count: %u\n" - "return_tx_packet_count: %u\n" - "return_tx_byte_count: %u\n", - nim, - (int)sync->protocol, - &sync->flow_ip, (int)sync->flow_ident, - &sync->return_ip_xlate, (int)sync->return_ident_xlate, - sync->flow_rx_packet_count, - sync->flow_rx_byte_count, - sync->return_rx_packet_count, - sync->return_rx_byte_count, - sync->flow_tx_packet_count, - sync->flow_tx_byte_count, - sync->return_tx_packet_count, - sync->return_tx_byte_count); - } -} - -/* - * nss_ipv4_log_conn_cfg_msg() - * Log IPv4 number of connections supported rule message. - */ -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("%px: IPv4 number of connections supported rule message: \n" - "num_conn: %d\n", - nim, - nirccm->num_conn); -} - -/* - * nss_ipv4_log_mc_rule_create_msg() - * Log IPv4 multicast create rule message. - */ -static void nss_ipv4_log_mc_rule_create_msg(struct nss_ipv4_msg *nim) -{ - 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("%px: IPv4 multicast create rule message \n" - "Rule flag: %x\n" - "Vif: %d\n" - "Protocol: %d\n" - "to_mtu: %u\n" - "from_ip: %pI4h:%d\n" - "to_ip: %pI4h:%d\n" - "to_mac: %pM\n" - "dest_iface_num: %u\n" - "out_vlan[0] %x\n" - "out_vlan[1] %x\n", - nim, - nimrcm->if_rule[vif].rule_flags, - vif, - nimrcm->tuple.protocol, - nimrcm->if_rule[vif].if_mtu, - &nimrcm->tuple.flow_ip, nimrcm->tuple.flow_ident, - &nimrcm->tuple.return_ip, nimrcm->tuple.return_ident, - nimrcm->if_rule[vif].if_mac, - nimrcm->if_rule[vif].if_num, - nimrcm->if_rule[vif].egress_vlan_tag[0], - nimrcm->if_rule[vif].egress_vlan_tag[1]); - } -} - -/* - * nss_ipv4_log_conn_sync_many_msg() - * Log IPv4 many conn sync message. - */ -static void nss_ipv4_log_conn_sync_many_msg(struct nss_ipv4_msg *nim) -{ - uint16_t i; - struct nss_ipv4_conn_sync_many_msg *nicsm = &nim->msg.conn_stats_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("%px: IPv4 many conn sync message \n" - "count: %d\n" - "i: %d\n" - "Protocol: %d\n" - "src_addr: %pI4h:%d\n" - "dest_addr: %pI4h:%d\n" - "flow_rx_packet_count: %u\n" - "flow_rx_byte_count: %u\n" - "return_rx_packet_count: %u\n" - "return_rx_byte_count: %u\n" - "flow_tx_packet_count: %u\n" - "flow_tx_byte_count: %u\n" - "return_tx_packet_count: %u\n" - "return_tx_byte_count: %u\n", - nim, - nicsm->count, - i, - (int)sync->protocol, - &sync->flow_ip, (int)sync->flow_ident, - &sync->return_ip_xlate, (int)sync->return_ident_xlate, - sync->flow_rx_packet_count, - sync->flow_rx_byte_count, - sync->return_rx_packet_count, - sync->return_rx_byte_count, - sync->flow_tx_packet_count, - sync->flow_tx_byte_count, - sync->return_tx_packet_count, - sync->return_tx_byte_count); - } - } -} - -/* - * nss_ipv4_log_verbose() - * Log message contents. - */ -static void nss_ipv4_log_verbose(struct nss_ipv4_msg *nim) -{ - switch (nim->cm.type) { - case NSS_IPV4_TX_CREATE_RULE_MSG: - nss_ipv4_log_rule_create_msg(nim); - break; - - case NSS_IPV4_TX_DESTROY_RULE_MSG: - nss_ipv4_log_destroy_rule_msg(nim); - break; - - case NSS_IPV4_RX_CONN_STATS_SYNC_MSG: - nss_ipv4_log_conn_sync(nim); - break; - - case NSS_IPV4_RX_NODE_STATS_SYNC_MSG: - /* Getting logged in stats */ - break; - - case NSS_IPV4_TX_CONN_CFG_RULE_MSG: - nss_ipv4_log_conn_cfg_msg(nim); - break; - - case NSS_IPV4_TX_CREATE_MC_RULE_MSG: - nss_ipv4_log_mc_rule_create_msg(nim); - break; - - case NSS_IPV4_TX_CONN_STATS_SYNC_MANY_MSG: - nss_ipv4_log_conn_sync_many_msg(nim); - break; - - default: - nss_trace("%px: Invalid message type\n", nim); - break; - } -} - -/* - * nss_ipv4_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_ipv4_log_tx_msg(struct nss_ipv4_msg *nim) -{ - if (nim->cm.type >= NSS_IPV4_MAX_MSG_TYPES) { - nss_info("%px: Invalid message type\n", nim); - return; - } - - 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); -} - -/* - * nss_ipv4_log_rx_msg() - * Log messages received from FW. - */ -void nss_ipv4_log_rx_msg(struct nss_ipv4_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_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("%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("%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]); - -verbose: - nss_ipv4_log_verbose(nim); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm.c deleted file mode 100644 index 402a46c4a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_ipv4_reasm.c - * NSS IPv4 Reassembly APIs - */ -#include -#include "nss_ipv4_reasm_stats.h" -#include "nss_ipv4_reasm_strings.h" - -/* - * nss_ipv4_reasm_msg_handler() - * Handle NSS -> HLOS messages for IPv4 reasm - */ -static void nss_ipv4_reasm_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_ipv4_reasm_msg *nim = (struct nss_ipv4_reasm_msg *)ncm; - - BUG_ON(ncm->interface != NSS_IPV4_REASM_INTERFACE); - - /* - * Handle deprecated messages. Eventually these messages should be removed. - */ - switch (nim->cm.type) { - case NSS_IPV4_REASM_STATS_SYNC_MSG: - /* - * Update Ipv4 reasm driver statistics and send statistics notifications to the registered modules. - */ - nss_ipv4_reasm_stats_sync(nss_ctx, &nim->msg.stats_sync); - nss_ipv4_reasm_stats_notify(nss_ctx); - - break; - default: - nss_warning("IPv4 reasm received an unknown message type"); - } -} - -/* - * nss_ipv4_reasm_get_context() - * get NSS context instance for ipv4 reassembly - */ -struct nss_ctx_instance *nss_ipv4_reasm_get_context(void) -{ - return &nss_top_main.nss[nss_top_main.ipv4_reasm_handler_id]; -} -EXPORT_SYMBOL(nss_ipv4_reasm_get_context); - -/* - * nss_ipv4_reasm_register_handler() - * Register our handler to receive messages for this interface - */ -void nss_ipv4_reasm_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_ipv4_reasm_get_context(); - - if (nss_core_register_handler(nss_ctx, NSS_IPV4_REASM_INTERFACE, nss_ipv4_reasm_msg_handler, NULL) != NSS_CORE_STATUS_SUCCESS) { - nss_warning("IPv4 reasm handler failed to register"); - } - - nss_ipv4_reasm_stats_dentry_create(); - nss_ipv4_reasm_strings_dentry_create(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm_stats.c deleted file mode 100644 index 350e61962..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm_stats.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipv4_reasm_stats.h" -#include "nss_ipv4_reasm.h" -#include "nss_ipv4_reasm_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_ipv4_reasm_stats_notifier); - -uint64_t nss_ipv4_reasm_stats[NSS_IPV4_REASM_STATS_MAX]; /* IPv4 reasm statistics */ - -/* - * nss_ipv4_reasm_stats_read() - * Read IPV4 reassembly stats - */ -static ssize_t nss_ipv4_reasm_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_IPV4_REASM_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_IPV4_REASM_STATS_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, "ipv4_reasm", NSS_STATS_SINGLE_CORE); - - size_wr += nss_stats_fill_common_stats(NSS_IPV4_REASM_INTERFACE, NSS_STATS_SINGLE_INSTANCE, lbuf, size_wr, size_al, "ipv4_reasm"); - - /* - * IPv4 reasm node stats - */ - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; (i < NSS_IPV4_REASM_STATS_MAX); i++) { - stats_shadow[i] = nss_ipv4_reasm_stats[i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("ipv4_reasm", NULL, NSS_STATS_SINGLE_INSTANCE - , nss_ipv4_reasm_strings_stats - , stats_shadow - , NSS_IPV4_REASM_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_ipv4_reasm_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(ipv4_reasm); - -/* - * nss_ipv4_reasm_stats_dentry_create() - * Create the IPv4 reasm statistics debug entry - */ -void nss_ipv4_reasm_stats_dentry_create(void) -{ - nss_stats_create_dentry("ipv4_reasm", &nss_ipv4_reasm_stats_ops); -} - -/* - * nss_ipv4_reasm_stats_sync() - * Update driver specific information from the messsage. - */ -void nss_ipv4_reasm_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_reasm_stats_sync *nirs) -{ - int i; - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - spin_lock_bh(&nss_top->stats_lock); - - /* - * Common node stats - */ - nss_top->stats_node[NSS_IPV4_REASM_INTERFACE][NSS_STATS_NODE_RX_PKTS] += nirs->node_stats.rx_packets; - nss_top->stats_node[NSS_IPV4_REASM_INTERFACE][NSS_STATS_NODE_RX_BYTES] += nirs->node_stats.rx_bytes; - nss_top->stats_node[NSS_IPV4_REASM_INTERFACE][NSS_STATS_NODE_TX_PKTS] += nirs->node_stats.tx_packets; - nss_top->stats_node[NSS_IPV4_REASM_INTERFACE][NSS_STATS_NODE_TX_BYTES] += nirs->node_stats.tx_bytes; - - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - nss_top->stats_node[NSS_IPV4_REASM_INTERFACE][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + i] += nirs->node_stats.rx_dropped[i]; - } - - /* - * IPv4 reasm node stats - */ - nss_ipv4_reasm_stats[NSS_IPV4_REASM_STATS_EVICTIONS] += nirs->ipv4_reasm_evictions; - nss_ipv4_reasm_stats[NSS_IPV4_REASM_STATS_ALLOC_FAILS] += nirs->ipv4_reasm_alloc_fails; - nss_ipv4_reasm_stats[NSS_IPV4_REASM_STATS_TIMEOUTS] += nirs->ipv4_reasm_timeouts; - - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_ipv4_reasm_stats_notify() - * Sends notifications to all the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_ipv4_reasm_stats_notify(struct nss_ctx_instance *nss_ctx) -{ - struct nss_ipv4_reasm_stats_notification ipv4_reasm_stats; - - ipv4_reasm_stats.core_id = nss_ctx->id; - memcpy(ipv4_reasm_stats.cmn_node_stats, nss_top_main.stats_node[NSS_IPV4_REASM_INTERFACE], sizeof(ipv4_reasm_stats.cmn_node_stats)); - memcpy(ipv4_reasm_stats.ipv4_reasm_stats, nss_ipv4_reasm_stats, sizeof(ipv4_reasm_stats.ipv4_reasm_stats)); - atomic_notifier_call_chain(&nss_ipv4_reasm_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&ipv4_reasm_stats); -} - -/* - * nss_ipv4_reasm_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_ipv4_reasm_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_ipv4_reasm_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_ipv4_reasm_stats_register_notifier); - -/* - * nss_ipv4_reasm_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_ipv4_reasm_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_ipv4_reasm_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_ipv4_reasm_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm_stats.h deleted file mode 100644 index f8c5f39f3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm_stats.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_IPV4_REASM_STATS_H -#define __NSS_IPV4_REASM_STATS_H - -/* - * IPV4 reasm statistics APIs - */ -extern void nss_ipv4_reasm_stats_notify(struct nss_ctx_instance *nss_ctx); -extern void nss_ipv4_reasm_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_reasm_stats_sync *nirs); -extern void nss_ipv4_reasm_stats_dentry_create(void); - -#endif /* __NSS_IPV4_REASM_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm_strings.c deleted file mode 100644 index 445d1349d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm_strings.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_ipv4_reasm_strings_stats - * IPv4 reassembly statistics strings. - */ -struct nss_stats_info nss_ipv4_reasm_strings_stats[NSS_IPV4_REASM_STATS_MAX] = { - {"evictions" , NSS_STATS_TYPE_DROP}, - {"alloc_fails" , NSS_STATS_TYPE_DROP}, - {"timeouts" , NSS_STATS_TYPE_DROP} -}; - -/* - * nss_ipv4_reasm_strings_read() - * Read IPv4 reassembly node statistics names. - */ -static ssize_t nss_ipv4_reasm_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_ipv4_reasm_strings_stats, NSS_IPV4_REASM_STATS_MAX); -} - -/* - * nss_ipv4_reasm_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(ipv4_reasm); - -/* - * nss_ipv4_reasm_strings_dentry_create() - * Create IPv4 reassembly statistics strings debug entry. - */ -void nss_ipv4_reasm_strings_dentry_create(void) -{ - nss_strings_create_dentry("ipv4_reasm", &nss_ipv4_reasm_strings_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm_strings.h deleted file mode 100644 index 9a0b362c2..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_reasm_strings.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_IPV4_REASM_STRINGS_H -#define __NSS_IPV4_REASM_STRINGS_H - -extern struct nss_stats_info nss_ipv4_reasm_strings_stats[NSS_IPV4_REASM_STATS_MAX]; -extern void nss_ipv4_reasm_strings_dentry_create(void); - -#endif /* __NSS_IPV4_REASM_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_stats.c deleted file mode 100644 index 39b162c7e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_stats.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2016-2017, 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. - * 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 -#include "nss_ipv4_stats.h" -#include "nss_ipv4_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_ipv4_stats_notifier); - -uint64_t nss_ipv4_stats[NSS_IPV4_STATS_MAX]; -uint64_t nss_ipv4_exception_stats[NSS_IPV4_EXCEPTION_EVENT_MAX]; - -/* - * nss_ipv4_stats_read() - * Read IPV4 stats - */ -static ssize_t nss_ipv4_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int32_t i; - - /* - * max output lines = #stats + Number of Extra outputlines for future reference to add new stats + - * start tag line + end tag line + three blank lines - */ - uint32_t max_output_lines = NSS_STATS_NODE_MAX + NSS_IPV4_STATS_MAX + NSS_IPV4_EXCEPTION_EVENT_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; - } - - /* - * Note: The assumption here is that exception event count is larger than other statistics count for IPv4 - */ - stats_shadow = kzalloc(NSS_IPV4_EXCEPTION_EVENT_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, "ipv4", NSS_STATS_SINGLE_CORE); - size_wr += nss_stats_fill_common_stats(NSS_IPV4_RX_INTERFACE, NSS_STATS_SINGLE_INSTANCE, lbuf, size_wr, size_al, "ipv4"); - - /* - * IPv4 node stats - */ - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; i < NSS_IPV4_STATS_MAX; i++) { - stats_shadow[i] = nss_ipv4_stats[i]; - } - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("ipv4", "ipv4 special stats" - , NSS_STATS_SINGLE_INSTANCE - , nss_ipv4_strings_stats - , stats_shadow - , NSS_IPV4_STATS_MAX - , lbuf, size_wr, size_al); - - /* - * Exception stats - */ - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; (i < NSS_IPV4_EXCEPTION_EVENT_MAX); i++) { - stats_shadow[i] = nss_ipv4_exception_stats[i]; - } - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("ipv4", "ipv4 exception stats" - , NSS_STATS_SINGLE_INSTANCE - , nss_ipv4_strings_exception_stats - , stats_shadow - , NSS_IPV4_EXCEPTION_EVENT_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_ipv4_stats_conn_sync() - * Update driver specific information from the messsage. - */ -void nss_ipv4_stats_conn_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_conn_sync *nirs) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - /* - * Update statistics maintained by NSS driver - */ - spin_lock_bh(&nss_top->stats_lock); - nss_ipv4_stats[NSS_IPV4_STATS_ACCELERATED_RX_PKTS] += nirs->flow_rx_packet_count + nirs->return_rx_packet_count; - nss_ipv4_stats[NSS_IPV4_STATS_ACCELERATED_RX_BYTES] += nirs->flow_rx_byte_count + nirs->return_rx_byte_count; - nss_ipv4_stats[NSS_IPV4_STATS_ACCELERATED_TX_PKTS] += nirs->flow_tx_packet_count + nirs->return_tx_packet_count; - nss_ipv4_stats[NSS_IPV4_STATS_ACCELERATED_TX_BYTES] += nirs->flow_tx_byte_count + nirs->return_tx_byte_count; - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_ipv4_stats_conn_sync_many() - * Update driver specific information from the conn_sync_many messsage. - */ -void nss_ipv4_stats_conn_sync_many(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_conn_sync_many_msg *nicsm) -{ - int i; - - /* - * Sanity check for the stats count - */ - if (nicsm->count * sizeof(struct nss_ipv4_conn_sync) >= nicsm->size) { - nss_warning("%px: stats sync count %u exceeds the size of this msg %u", nss_ctx, nicsm->count, nicsm->size); - return; - } - - for (i = 0; i < nicsm->count; i++) { - nss_ipv4_stats_conn_sync(nss_ctx, &nicsm->conn_sync[i]); - } -} - -/* - * nss_ipv4_stats_node_sync() - * Update driver specific information from the messsage. - */ -void nss_ipv4_stats_node_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_node_sync *nins) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - uint32_t i; - - /* - * Update statistics maintained by NSS driver - */ - spin_lock_bh(&nss_top->stats_lock); - nss_top->stats_node[NSS_IPV4_RX_INTERFACE][NSS_STATS_NODE_RX_PKTS] += nins->node_stats.rx_packets; - nss_top->stats_node[NSS_IPV4_RX_INTERFACE][NSS_STATS_NODE_RX_BYTES] += nins->node_stats.rx_bytes; - nss_top->stats_node[NSS_IPV4_RX_INTERFACE][NSS_STATS_NODE_TX_PKTS] += nins->node_stats.tx_packets; - nss_top->stats_node[NSS_IPV4_RX_INTERFACE][NSS_STATS_NODE_TX_BYTES] += nins->node_stats.tx_bytes; - - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - nss_top->stats_node[NSS_IPV4_RX_INTERFACE][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + i] += nins->node_stats.rx_dropped[i]; - } - - nss_ipv4_stats[NSS_IPV4_STATS_CONNECTION_CREATE_REQUESTS] += nins->ipv4_connection_create_requests; - nss_ipv4_stats[NSS_IPV4_STATS_CONNECTION_CREATE_COLLISIONS] += nins->ipv4_connection_create_collisions; - nss_ipv4_stats[NSS_IPV4_STATS_CONNECTION_CREATE_INVALID_INTERFACE] += nins->ipv4_connection_create_invalid_interface; - nss_ipv4_stats[NSS_IPV4_STATS_CONNECTION_DESTROY_REQUESTS] += nins->ipv4_connection_destroy_requests; - nss_ipv4_stats[NSS_IPV4_STATS_CONNECTION_DESTROY_MISSES] += nins->ipv4_connection_destroy_misses; - nss_ipv4_stats[NSS_IPV4_STATS_CONNECTION_HASH_HITS] += nins->ipv4_connection_hash_hits; - nss_ipv4_stats[NSS_IPV4_STATS_CONNECTION_HASH_REORDERS] += nins->ipv4_connection_hash_reorders; - nss_ipv4_stats[NSS_IPV4_STATS_CONNECTION_FLUSHES] += nins->ipv4_connection_flushes; - nss_ipv4_stats[NSS_IPV4_STATS_CONNECTION_EVICTIONS] += nins->ipv4_connection_evictions; - nss_ipv4_stats[NSS_IPV4_STATS_FRAGMENTATIONS] += nins->ipv4_fragmentations; - nss_ipv4_stats[NSS_IPV4_STATS_MC_CONNECTION_CREATE_REQUESTS] += nins->ipv4_mc_connection_create_requests; - nss_ipv4_stats[NSS_IPV4_STATS_MC_CONNECTION_UPDATE_REQUESTS] += nins->ipv4_mc_connection_update_requests; - nss_ipv4_stats[NSS_IPV4_STATS_MC_CONNECTION_CREATE_INVALID_INTERFACE] += nins->ipv4_mc_connection_create_invalid_interface; - 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]; - } - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_ipv4_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(ipv4); - -/* - * nss_ipv4_stats_dentry_create() - * Create IPv4 statistics debug entry. - */ -void nss_ipv4_stats_dentry_create(void) -{ - nss_stats_create_dentry("ipv4", &nss_ipv4_stats_ops); -} - -/* - * nss_ipv4_stats_notify() - * Sends notifications to the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_ipv4_stats_notify(struct nss_ctx_instance *nss_ctx) -{ - struct nss_ipv4_stats_notification ipv4_stats; - - ipv4_stats.core_id = nss_ctx->id; - memcpy(ipv4_stats.cmn_node_stats, nss_top_main.stats_node[NSS_IPV4_RX_INTERFACE], sizeof(ipv4_stats.cmn_node_stats)); - memcpy(ipv4_stats.special_stats, nss_ipv4_stats, sizeof(ipv4_stats.special_stats)); - memcpy(ipv4_stats.exception_stats, nss_ipv4_exception_stats, sizeof(ipv4_stats.exception_stats)); - atomic_notifier_call_chain(&nss_ipv4_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&ipv4_stats); -} - -/* - * nss_ipv4_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_ipv4_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_ipv4_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_ipv4_stats_register_notifier); - -/* - * nss_ipv4_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_ipv4_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_ipv4_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_ipv4_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_stats.h deleted file mode 100644 index ad85c35a2..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_stats.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_IPV4_STATS_H -#define __NSS_IPV4_STATS_H - -/* - * NSS IPV4 statistics APIs - */ -extern void nss_ipv4_stats_notify(struct nss_ctx_instance *nss_ctx); -extern void nss_ipv4_stats_node_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_node_sync *nins); -extern void nss_ipv4_stats_conn_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_conn_sync *nirs); -extern void nss_ipv4_stats_conn_sync_many(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_conn_sync_many_msg *nicsm); -extern void nss_ipv4_stats_dentry_create(void); - -#endif /* __NSS_IPV4_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_strings.c deleted file mode 100644 index 77ff3520b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_strings.c +++ /dev/null @@ -1,208 +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 -#include "nss_strings.h" - -/* - * nss_ipv4_strings_exception_stats - * Interface statistics strings for ipv4 exceptions. - */ -struct nss_stats_info nss_ipv4_strings_exception_stats[NSS_IPV4_EXCEPTION_EVENT_MAX] = { - {"icmp_hdr_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_unhandled_type" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_ipv4_hdr_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_ipv4_udp_hdr_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_ipv4_tcp_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_sipv4_unknown_protocol" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_flush_to_host" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_ip_option" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_ip_fragment" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_small_ttl" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_flags" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_seq_exceeds_right_edge" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_small_data_offs" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_bad_sack" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_big_data_offs" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_seq_before_left_edge" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_ack_exceeds_right_edge" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_ack_before_left_edge" , NSS_STATS_TYPE_EXCEPTION}, - {"udp_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"udp_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"udp_ip_option" , NSS_STATS_TYPE_EXCEPTION}, - {"udp_ip_fragment" , NSS_STATS_TYPE_EXCEPTION}, - {"udp_small_ttl" , NSS_STATS_TYPE_EXCEPTION}, - {"udp_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"wrong_target_mac" , NSS_STATS_TYPE_EXCEPTION}, - {"header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"bad_total_length" , NSS_STATS_TYPE_EXCEPTION}, - {"bad_checksum" , NSS_STATS_TYPE_EXCEPTION}, - {"non_initial_fragment" , NSS_STATS_TYPE_EXCEPTION}, - {"datagram_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"options_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"unknown_protocol" , NSS_STATS_TYPE_EXCEPTION}, - {"esp_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"esp_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"esp_ip_option" , NSS_STATS_TYPE_EXCEPTION}, - {"esp_ip_fragment" , NSS_STATS_TYPE_EXCEPTION}, - {"esp_small_ttl" , NSS_STATS_TYPE_EXCEPTION}, - {"esp_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"ingress_vid_mismatch" , NSS_STATS_TYPE_EXCEPTION}, - {"ingress_vid_missing" , NSS_STATS_TYPE_EXCEPTION}, - {"6rd_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"6rd_ip_option" , NSS_STATS_TYPE_EXCEPTION}, - {"6rd_ip_fragment" , NSS_STATS_TYPE_EXCEPTION}, - {"6rd_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"dscp_marking_mismatch" , NSS_STATS_TYPE_EXCEPTION}, - {"vlan_marking_mismatch" , NSS_STATS_TYPE_EXCEPTION}, - {"interface_mismatch" , NSS_STATS_TYPE_EXCEPTION}, - {"gre_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"gre_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"gre_ip_option" , NSS_STATS_TYPE_EXCEPTION}, - {"gre_ip_fragment" , NSS_STATS_TYPE_EXCEPTION}, - {"gre_small_ttl" , NSS_STATS_TYPE_EXCEPTION}, - {"gre_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"pptp_gre_session_match_fail" , NSS_STATS_TYPE_EXCEPTION}, - {"pptp_gre_invalid_proto" , NSS_STATS_TYPE_EXCEPTION}, - {"pptp_gre_no_cme" , NSS_STATS_TYPE_EXCEPTION}, - {"pptp_gre_ip_option" , NSS_STATS_TYPE_EXCEPTION}, - {"pptp_gre_ip_fragment" , NSS_STATS_TYPE_EXCEPTION}, - {"pptp_gre_small_ttl" , NSS_STATS_TYPE_EXCEPTION}, - {"pptp_gre_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"destroy" , NSS_STATS_TYPE_EXCEPTION}, - {"frag_df_set" , NSS_STATS_TYPE_EXCEPTION}, - {"frag_fail" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_ipv4_udplite_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"udplite_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"udplite_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"udplite_ip_option" , NSS_STATS_TYPE_EXCEPTION}, - {"udplite_ip_fragment" , NSS_STATS_TYPE_EXCEPTION}, - {"udplite_small_ttl" , NSS_STATS_TYPE_EXCEPTION}, - {"udplite_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"mc_udp_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"mc_mem_alloc_failure" , NSS_STATS_TYPE_EXCEPTION}, - {"mc_update_failure" , NSS_STATS_TYPE_EXCEPTION}, - {"mc_pbuf_alloc_failure" , NSS_STATS_TYPE_EXCEPTION}, - {"pppoe_bridge_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"pppoe_no_session" , NSS_STATS_TYPE_DROP}, - {"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}, -}; - -/* - * nss_ipv4_strings_stats - * IPv4 statistics strings. - */ -struct nss_stats_info nss_ipv4_strings_stats[NSS_IPV4_STATS_MAX] = { - {"rx_pkts" , NSS_STATS_TYPE_SPECIAL}, - {"rx_bytes" , NSS_STATS_TYPE_SPECIAL}, - {"tx_pkts" , NSS_STATS_TYPE_SPECIAL}, - {"tx_bytes" , NSS_STATS_TYPE_SPECIAL}, - {"create_requests" , NSS_STATS_TYPE_SPECIAL}, - {"create_collisions" , NSS_STATS_TYPE_SPECIAL}, - {"create_invalid_interface" , NSS_STATS_TYPE_SPECIAL}, - {"destroy_requests" , NSS_STATS_TYPE_SPECIAL}, - {"destroy_misses" , NSS_STATS_TYPE_SPECIAL}, - {"hash_hits" , NSS_STATS_TYPE_SPECIAL}, - {"hash_reorders" , NSS_STATS_TYPE_SPECIAL}, - {"flushes" , NSS_STATS_TYPE_SPECIAL}, - {"evictions" , NSS_STATS_TYPE_SPECIAL}, - {"fragmentations" , NSS_STATS_TYPE_SPECIAL}, - {"by_rule_drops" , NSS_STATS_TYPE_DROP}, - {"mc_create_requests" , NSS_STATS_TYPE_SPECIAL}, - {"mc_update_requests" , NSS_STATS_TYPE_SPECIAL}, - {"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}, -}; - -/* - * nss_ipv4_special_stats_strings_read() - * Read IPV4 special node statistics names. - */ -static ssize_t nss_ipv4_special_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_ipv4_strings_stats, NSS_IPV4_STATS_MAX); -} - -/* - * nss_ipv4_exception_stats_strings_read() - * Read IPV4 exception statistics names. - */ -static ssize_t nss_ipv4_exception_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_ipv4_strings_exception_stats, NSS_IPV4_EXCEPTION_EVENT_MAX); -} - -/* - * nss_ipv4_special_stats_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(ipv4_special_stats); - -/* - * nss_ipv4_exception_stats_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(ipv4_exception_stats); - -/* - * nss_ipv4_strings_dentry_create() - * Create IPv4 statistics strings debug entry. - */ -void nss_ipv4_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("ipv4", nss_top_main.strings_dentry); - if (!dir_d) { - nss_warning("Failed to create qca-nss-drv/strings/ipv4 directory"); - return; - } - - file_d = debugfs_create_file("special_stats_str", 0400, dir_d, &nss_top_main, &nss_ipv4_special_stats_strings_ops); - if (!file_d) { - nss_warning("Failed to create qca-nss-drv/stats/ipv4/special_stats_str file"); - goto fail; - } - - file_d = debugfs_create_file("exception_stats_str", 0400, dir_d, &nss_top_main, &nss_ipv4_exception_stats_strings_ops); - if (!file_d) { - nss_warning("Failed to create qca-nss-drv/stats/ipv4/exception_stats_str file"); - goto fail; - } - - return; -fail: - debugfs_remove_recursive(dir_d); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_strings.h deleted file mode 100644 index fd819c769..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv4_strings.h +++ /dev/null @@ -1,26 +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_IPV4_STRINGS_H -#define __NSS_IPV4_STRINGS_H - -extern struct nss_stats_info nss_ipv4_strings_stats[NSS_IPV4_STATS_MAX]; -extern struct nss_stats_info nss_ipv4_strings_exception_stats[NSS_IPV4_EXCEPTION_EVENT_MAX]; -extern void nss_ipv4_strings_dentry_create(void); - -#endif /* __NSS_IPV4_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv6.c deleted file mode 100644 index 2f9f14b9a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6.c +++ /dev/null @@ -1,776 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipv6.c - * NSS IPv6 APIs - */ -#include -#include "nss_dscp_map.h" -#include "nss_ipv6_stats.h" -#include "nss_ipv6_strings.h" - -#define NSS_IPV6_TX_MSG_TIMEOUT 1000 /* 1 sec timeout for IPv6 messages */ - -/* - * Private data structure for ipv6 configure messages - */ -struct nss_ipv6_cfg_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_ipv6_pvt; - -/* - * Private data structure for ipv6 connection information. - */ -struct nss_ipv6_conn_table_info { - uint32_t ce_table_size; /* Size of connection entry table in NSS FW */ - uint32_t cme_table_size; /* Size of connection match entry table in NSS FW */ - unsigned long ce_mem; /* Start address for connection entry table */ - unsigned long cme_mem; /* Start address for connection match entry table */ -} nss_ipv6_ct_info; - -int nss_ipv6_conn_cfg = NSS_DEFAULT_NUM_CONN; -int nss_ipv6_accel_mode_cfg __read_mostly = 1; - -static struct nss_dscp_map_entry mapping[NSS_DSCP_MAP_ARRAY_SIZE]; - -/* - * Callback for conn_sync_many request message. - */ -nss_ipv6_msg_callback_t nss_ipv6_conn_sync_many_msg_cb = NULL; - -/* - * nss_ipv6_dscp_map_usage() - * Help function shows the usage of the command. - */ -static inline void nss_ipv6_dscp_map_usage(void) -{ - nss_info_always("\nUsage:\n"); - nss_info_always("echo > /proc/sys/dev/nss/ipv6cfg/ipv6_dscp_map\n\n"); - nss_info_always("dscp[0-63] action[0-%u] prio[0-%u]:\n\n", - NSS_IPV6_DSCP_MAP_ACTION_MAX - 1, - NSS_DSCP_MAP_PRIORITY_MAX - 1); -} - -/* - * nss_ipv6_rx_msg_handler() - * Handle NSS -> HLOS messages for IPv6 bridge/route - */ -static void nss_ipv6_rx_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_ipv6_msg *nim = (struct nss_ipv6_msg *)ncm; - nss_ipv6_msg_callback_t cb; - - BUG_ON(ncm->interface != NSS_IPV6_RX_INTERFACE); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_IPV6_MAX_MSG_TYPES) { - 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("%px: message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Trace messages. - */ - nss_ipv6_log_rx_msg(nim); - - /* - * Handle deprecated messages. Eventually these messages should be removed. - */ - switch (nim->cm.type) { - case NSS_IPV6_RX_NODE_STATS_SYNC_MSG: - /* - * Update driver statistics on node sync and send statistics notifications to the registered modules. - */ - nss_ipv6_stats_node_sync(nss_ctx, &nim->msg.node_stats); - nss_ipv6_stats_notify(nss_ctx); - break; - - case NSS_IPV6_RX_CONN_STATS_SYNC_MSG: - /* - * Update driver statistics on connection sync. - */ - nss_ipv6_stats_conn_sync(nss_ctx, &nim->msg.conn_stats); - break; - - case NSS_IPV6_TX_CONN_STATS_SYNC_MANY_MSG: - /* - * Update driver statistics on connection sync many. - */ - nss_ipv6_stats_conn_sync_many(nss_ctx, &nim->msg.conn_stats_many); - ncm->cb = (nss_ptr_t)nss_ipv6_conn_sync_many_msg_cb; - break; - } - - /* - * Update the callback and app_data for NOTIFY messages, IPv6 sends all notify messages - * to the same callback/app_data. - */ - if (nim->cm.response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->ipv6_callback; - ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->ipv6_ctx; - } - - /* - * Do we have a callback? - */ - if (!ncm->cb) { - return; - } - - /* - * Callback - */ - cb = (nss_ipv6_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, nim); -} - -/* - * nss_ipv6_tx_sync_callback() - * Callback to handle the completion of synchronous tx messages. - */ -static void nss_ipv6_tx_sync_callback(void *app_data, struct nss_ipv6_msg *nim) -{ - nss_ipv6_msg_callback_t callback = (nss_ipv6_msg_callback_t)nss_ipv6_pvt.cb; - void *data = nss_ipv6_pvt.app_data; - - nss_ipv6_pvt.cb = NULL; - nss_ipv6_pvt.app_data = NULL; - - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("ipv6 error response %d\n", nim->cm.response); - nss_ipv6_pvt.response = NSS_TX_FAILURE; - } else { - nss_ipv6_pvt.response = NSS_TX_SUCCESS; - } - - if (callback) { - callback(data, nim); - } - - complete(&nss_ipv6_pvt.complete); -} - -/* - * nss_ipv6_dscp_action_get() - * Gets the action mapped to dscp. - */ -enum nss_ipv6_dscp_map_actions nss_ipv6_dscp_action_get(uint8_t dscp) -{ - if (dscp >= NSS_DSCP_MAP_ARRAY_SIZE) { - nss_warning("dscp:%u invalid\n", dscp); - return NSS_IPV6_DSCP_MAP_ACTION_MAX; - } - - return mapping[dscp].action; -} -EXPORT_SYMBOL(nss_ipv6_dscp_action_get); - -/* - * nss_ipv6_max_conn_count() - * Return the maximum number of IPv6 connections that the NSS acceleration engine supports. - */ -int nss_ipv6_max_conn_count(void) -{ - return nss_ipv6_conn_cfg; -} -EXPORT_SYMBOL(nss_ipv6_max_conn_count); - -/* - * nss_ipv6_conn_inquiry() - * Inquiry if a connection has been established in NSS FW - */ -nss_tx_status_t nss_ipv6_conn_inquiry(struct nss_ipv6_5tuple *ipv6_5t_p, - nss_ipv6_msg_callback_t cb) -{ - nss_tx_status_t nss_tx_status; - struct nss_ipv6_msg nim; - struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[0]; - - /* - * Initialize inquiry message structure. - * This is async message and the result will be returned - * to the caller by the msg_callback passed in. - */ - memset(&nim, 0, sizeof(nim)); - nss_ipv6_msg_init(&nim, NSS_IPV6_RX_INTERFACE, - NSS_IPV6_TX_CONN_CFG_INQUIRY_MSG, - sizeof(struct nss_ipv6_inquiry_msg), - cb, NULL); - 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("%px: Send inquiry message failed\n", ipv6_5t_p); - } - - return nss_tx_status; -} -EXPORT_SYMBOL(nss_ipv6_conn_inquiry); - -/* - * nss_ipv6_tx_with_size() - * Transmit an ipv6 message to the FW with a specified size. - */ -nss_tx_status_t nss_ipv6_tx_with_size(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *nim, uint32_t size) -{ - struct nss_cmn_msg *ncm = &nim->cm; - - /* - * Sanity check the message - */ - if (ncm->interface != NSS_IPV6_RX_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("%px: message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - /* - * Trace messages. - */ - nss_ipv6_log_tx_msg(nim); - - return nss_core_send_cmd(nss_ctx, nim, sizeof(*nim), size); -} -EXPORT_SYMBOL(nss_ipv6_tx_with_size); - -/* - * nss_ipv6_tx() - * Transmit an ipv6 message to the FW. - */ -nss_tx_status_t nss_ipv6_tx(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *nim) -{ - return nss_ipv6_tx_with_size(nss_ctx, nim, NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_ipv6_tx); - -/* - * nss_ipv6_tx_sync() - * Transmit a synchronous ipv6 message to the FW. - */ -nss_tx_status_t nss_ipv6_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *nim) -{ - nss_tx_status_t status; - int ret = 0; - - down(&nss_ipv6_pvt.sem); - nss_ipv6_pvt.cb = (void *)nim->cm.cb; - nss_ipv6_pvt.app_data = (void *)nim->cm.app_data; - - nim->cm.cb = (nss_ptr_t)nss_ipv6_tx_sync_callback; - nim->cm.app_data = (nss_ptr_t)NULL; - - status = nss_ipv6_tx(nss_ctx, nim); - if (status != NSS_TX_SUCCESS) { - 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("%px: IPv6 tx sync failed due to timeout\n", nss_ctx); - nss_ipv6_pvt.response = NSS_TX_FAILURE; - } - - status = nss_ipv6_pvt.response; - up(&nss_ipv6_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_ipv6_tx_sync); - -/* - ********************************** - Register/Unregister/Miscellaneous APIs - ********************************** - */ - -/* - * nss_ipv6_notify_register() - * Register to received IPv6 events. - * - * NOTE: Do we want to pass an nss_ctx here so that we can register for ipv6 on any core? - */ -struct nss_ctx_instance *nss_ipv6_notify_register(nss_ipv6_msg_callback_t cb, void *app_data) -{ - /* - * TODO: We need to have a new array in support of the new API - * TODO: If we use a per-context array, we would move the array into nss_ctx based. - */ - nss_top_main.ipv6_callback = cb; - nss_top_main.ipv6_ctx = app_data; - return &nss_top_main.nss[nss_top_main.ipv6_handler_id]; -} -EXPORT_SYMBOL(nss_ipv6_notify_register); - -/* - * nss_ipv6_notify_unregister() - * Unregister to received IPv6 events. - * - * NOTE: Do we want to pass an nss_ctx here so that we can register for ipv6 on any core? - */ -void nss_ipv6_notify_unregister(void) -{ - nss_top_main.ipv6_callback = NULL; -} -EXPORT_SYMBOL(nss_ipv6_notify_unregister); - -/* - * nss_ipv6_conn_sync_many_notify_register() - * Register to receive IPv6 conn_sync_many message response. - */ -void nss_ipv6_conn_sync_many_notify_register(nss_ipv6_msg_callback_t cb) -{ - nss_ipv6_conn_sync_many_msg_cb = cb; -} -EXPORT_SYMBOL(nss_ipv6_conn_sync_many_notify_register); - -/* - * nss_ipv6_conn_sync_many_notify_unregister() - * Unregister to receive IPv6 conn_sync_many message response. - */ -void nss_ipv6_conn_sync_many_notify_unregister(void) -{ - nss_ipv6_conn_sync_many_msg_cb = NULL; -} -EXPORT_SYMBOL(nss_ipv6_conn_sync_many_notify_unregister); - -/* - * nss_ipv6_get_mgr() - * - * TODO: This only suppports a single ipv6, do we ever want to support more? - */ -struct nss_ctx_instance *nss_ipv6_get_mgr(void) -{ - return (void *)&nss_top_main.nss[nss_top_main.ipv6_handler_id]; -} -EXPORT_SYMBOL(nss_ipv6_get_mgr); - -/* - * nss_ipv6_register_handler() - * Register our handler to receive messages for this interface - */ -void nss_ipv6_register_handler() -{ - struct nss_ctx_instance *nss_ctx = nss_ipv6_get_mgr(); - - if (nss_core_register_handler(nss_ctx, NSS_IPV6_RX_INTERFACE, nss_ipv6_rx_msg_handler, NULL) != NSS_CORE_STATUS_SUCCESS) { - nss_warning("IPv6 handler failed to register"); - } - - nss_ipv6_stats_dentry_create(); - nss_ipv6_strings_dentry_create(); -} - -/* - * nss_ipv6_conn_cfg_process_callback() - * Call back function for the ipv6 connection configuration process. - */ -static void nss_ipv6_conn_cfg_process_callback(void *app_data, struct nss_ipv6_msg *nim) -{ - struct nss_ipv6_rule_conn_cfg_msg *nirccm = &nim->msg.rule_conn_cfg; - struct nss_ctx_instance *nss_ctx __maybe_unused = nss_ipv6_get_mgr(); - - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - 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; - } - - nss_ipv6_conn_cfg = ntohl(nirccm->num_conn); - - nss_info("%px: IPv6 connection configuration success: %d\n", nss_ctx, nim->cm.error); -} - -/* - * nss_ipv6_conn_cfg_process() - * Process request to configure number of ipv6 connections - */ -static int nss_ipv6_conn_cfg_process(struct nss_ctx_instance *nss_ctx, int conn) -{ - struct nss_ipv6_msg nim; - struct nss_ipv6_rule_conn_cfg_msg *nirccm; - nss_tx_status_t nss_tx_status; - - if ((!nss_ipv6_ct_info.ce_table_size) || (!nss_ipv6_ct_info.cme_table_size)) { - nss_warning("%px: connection entry or connection match entry table size not available\n", - nss_ctx); - return -EINVAL; - } - - 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, - 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", - nss_ctx, - conn); - goto fail; - } - nss_info("%px: CE Memory allocated for IPv6 Connections: %d\n", - nss_ctx, - conn); - - nss_ipv6_ct_info.cme_mem = __get_free_pages(GFP_ATOMIC | __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", - nss_ctx, - conn); - goto fail; - } - nss_info("%px: CME Memory allocated for IPv6 Connections: %d\n", - nss_ctx, - conn); - - memset(&nim, 0, sizeof(struct nss_ipv6_msg)); - nss_ipv6_msg_init(&nim, NSS_IPV6_RX_INTERFACE, NSS_IPV6_TX_CONN_CFG_RULE_MSG, - sizeof(struct nss_ipv6_rule_conn_cfg_msg), nss_ipv6_conn_cfg_process_callback, NULL); - - nirccm = &nim.msg.rule_conn_cfg; - 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("%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("%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("%px: nss_tx error setting IPv6 Connections: %d\n", - nss_ctx, - conn); - goto fail; - } - - return 0; - -fail: - nss_ipv6_free_conn_tables(); - return -EINVAL; -} - -/* - * nss_ipv6_update_conn_count_callback() - * Call back function for the ipv6 get connection info message. - */ -static void nss_ipv6_update_conn_count_callback(void *app_data, struct nss_ipv6_msg *nim) -{ - struct nss_ipv6_rule_conn_get_table_size_msg *nircgts = &nim->msg.size; - struct nss_ctx_instance *nss_ctx = nss_ipv6_get_mgr(); - - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - 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; - } - - nss_info("IPv6 get connection info success\n"); - - nss_ipv6_ct_info.ce_table_size = ntohl(nircgts->ce_table_size); - 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("%px: IPv6 connection entry or connection match entry table size\ - not available\n", nss_ctx); - } - - return; -} - -/* - * nss_ipv6_update_conn_count() - * Sets the maximum number of IPv6 connections. - * - * It first gets the connection tables size information from NSS FW - * and then configures the connections in NSS FW. - */ -int nss_ipv6_update_conn_count(int ipv6_num_conn) -{ - struct nss_ctx_instance *nss_ctx = nss_ipv6_get_mgr(); - struct nss_ipv6_msg nim; - struct nss_ipv6_rule_conn_get_table_size_msg *nircgts; - nss_tx_status_t nss_tx_status; - uint32_t sum_of_conn; - - /* - * By default, NSS FW is configured with default number of connections. - */ - if (ipv6_num_conn == NSS_FW_DEFAULT_NUM_CONN) { - nss_info("%px: Default number of connections (%d) already configured\n", nss_ctx, ipv6_num_conn); - return 0; - } - - /* - * Specifications for input - * 1) The input should be power of 2. - * 2) Input for ipv4 and ipv6 sum togther should not exceed 8k - * 3) Min. value should be at leat 256 connections. This is the - * minimum connections we will support for each of them. - */ - sum_of_conn = nss_ipv4_conn_cfg + ipv6_num_conn; - 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("%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, - ipv6_num_conn, - NSS_MIN_NUM_CONN, - NSS_MAX_TOTAL_NUM_CONN_IPV4_IPV6); - return -EINVAL; - } - - memset(&nim, 0, sizeof(struct nss_ipv6_msg)); - nss_ipv6_msg_init(&nim, NSS_IPV6_RX_INTERFACE, NSS_IPV6_TX_CONN_TABLE_SIZE_MSG, - sizeof(struct nss_ipv6_rule_conn_get_table_size_msg), nss_ipv6_update_conn_count_callback, NULL); - - nircgts = &nim.msg.size; - 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("%px: Send acceleration mode message failed\n", nss_ctx); - return -EINVAL; - } - - return 0; -} - -/* - * nss_ipv6_free_conn_tables() - * Frees memory allocated for connection tables - */ -void nss_ipv6_free_conn_tables(void) -{ - if (nss_ipv6_ct_info.ce_mem) { - free_pages(nss_ipv6_ct_info.ce_mem, get_order(nss_ipv6_ct_info.ce_table_size)); - } - - if (nss_ipv6_ct_info.cme_mem) { - free_pages(nss_ipv6_ct_info.cme_mem, get_order(nss_ipv6_ct_info.cme_table_size)); - } - - memset(&nss_ipv6_ct_info, 0, sizeof(struct nss_ipv6_conn_table_info)); - return; -} - -/* - * nss_ipv6_accel_mode_cfg_handler() - * Configure acceleration mode for IPv6 - */ -static int nss_ipv6_accel_mode_cfg_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; - struct nss_ipv6_msg nim; - struct nss_ipv6_accel_mode_cfg_msg *nipcm; - nss_tx_status_t nss_tx_status; - int ret = NSS_FAILURE; - int current_value; - - /* - * Take snap shot of current value - */ - current_value = nss_ipv6_accel_mode_cfg; - - /* - * Write the variable with user input - */ - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret || (!write)) { - return ret; - } - - memset(&nim, 0, sizeof(struct nss_ipv6_msg)); - nss_ipv6_msg_init(&nim, NSS_IPV6_RX_INTERFACE, NSS_IPV6_TX_ACCEL_MODE_CFG_MSG, - sizeof(struct nss_ipv6_accel_mode_cfg_msg), NULL, NULL); - - nipcm = &nim.msg.accel_mode_cfg; - nipcm->mode = htonl(nss_ipv6_accel_mode_cfg); - - nss_tx_status = nss_ipv6_tx_sync(nss_ctx, &nim); - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: Send acceleration mode message failed\n", nss_ctx); - nss_ipv6_accel_mode_cfg = current_value; - return -EIO; - } - - return 0; -} - -/* - * nss_ipv6_dscp_map_cfg_handler() - * Sysctl handler for dscp/pri mappings. - */ -static int nss_ipv6_dscp_map_cfg_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; - struct nss_dscp_map_parse out; - struct nss_ipv6_msg nim; - struct nss_ipv6_dscp2pri_cfg_msg *nipd2p; - nss_tx_status_t status; - int ret; - - if (!write) { - return nss_dscp_map_print(ctl, buffer, lenp, ppos, mapping); - } - - ret = nss_dscp_map_parse(ctl, buffer, lenp, ppos, &out); - if (ret) { - nss_warning("failed to parse dscp mapping:%d\n", ret); - return ret; - } - - if (out.action >= NSS_IPV6_DSCP_MAP_ACTION_MAX) { - nss_warning("invalid action value: %d\n", out.action); - nss_ipv6_dscp_map_usage(); - return -EINVAL; - } - - memset(&nim, 0, sizeof(struct nss_ipv6_msg)); - nss_ipv6_msg_init(&nim, NSS_IPV6_RX_INTERFACE, NSS_IPV6_TX_DSCP2PRI_CFG_MSG, - sizeof(struct nss_ipv6_dscp2pri_cfg_msg), NULL, NULL); - - nipd2p = &nim.msg.dscp2pri_cfg; - nipd2p->dscp = out.dscp; - nipd2p->priority = out.priority; - - status = nss_ipv6_tx_sync(nss_ctx, &nim); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: ipv6 dscp2pri config message failed\n", nss_ctx); - return -EFAULT; - } - - /* - * NSS firmware acknowleged the configuration, so update the mapping - * table on HOST side as well. - */ - mapping[out.dscp].action = out.action; - mapping[out.dscp].priority = out.priority; - - return 0; -} - -static struct ctl_table nss_ipv6_table[] = { - { - .procname = "ipv6_accel_mode", - .data = &nss_ipv6_accel_mode_cfg, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_ipv6_accel_mode_cfg_handler, - }, - { - .procname = "ipv6_dscp_map", - .data = &mapping[NSS_DSCP_MAP_ARRAY_SIZE], - .maxlen = sizeof(struct nss_dscp_map_entry), - .mode = 0644, - .proc_handler = &nss_ipv6_dscp_map_cfg_handler, - }, - { } -}; - -static struct ctl_table nss_ipv6_dir[] = { - { - .procname = "ipv6cfg", - .mode = 0555, - .child = nss_ipv6_table, - }, - { } -}; - -static struct ctl_table nss_ipv6_root_dir[] = { - { - .procname = "nss", - .mode = 0555, - .child = nss_ipv6_dir, - }, - { } -}; - -static struct ctl_table nss_ipv6_root[] = { - { - .procname = "dev", - .mode = 0555, - .child = nss_ipv6_root_dir, - }, - { } -}; - -static struct ctl_table_header *nss_ipv6_header; - -/* - * nss_ipv6_register_sysctl() - * Register sysctl specific to ipv6 - */ -void nss_ipv6_register_sysctl(void) -{ - sema_init(&nss_ipv6_pvt.sem, 1); - init_completion(&nss_ipv6_pvt.complete); - - /* - * Register sysctl table. - */ - nss_ipv6_header = register_sysctl_table(nss_ipv6_root); -} - -/* - * nss_ipv6_unregister_sysctl() - * Unregister sysctl specific to ipv6 - */ -void nss_ipv6_unregister_sysctl(void) -{ - /* - * Unregister sysctl table. - */ - if (nss_ipv6_header) { - unregister_sysctl_table(nss_ipv6_header); - } -} - -/* - * nss_ipv6_msg_init() - * Initialize IPv6 message. - */ -void nss_ipv6_msg_init(struct nss_ipv6_msg *nim, uint16_t if_num, uint32_t type, uint32_t len, - nss_ipv6_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&nim->cm, if_num, type, len, (void *)cb, app_data); -} -EXPORT_SYMBOL(nss_ipv6_msg_init); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_log.c deleted file mode 100644 index ed606104e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_log.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2016, 2018, 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_ipv6_log.c - * NSS IPv6 logger file. - */ - -#include "nss_core.h" - -/* - * This macro converts IPv6 address to network format - */ -#define NSS_IPV6_ADDR_TO_NW(nss6, nw) \ - { \ - nw[0] = htonl(nss6[0]); \ - nw[1] = htonl(nss6[1]); \ - nw[2] = htonl(nss6[2]); \ - nw[3] = htonl(nss6[3]); \ - } - -/* - * nss_ipv6_log_message_types_str - * IPv6 bridge/route rule messages strings - */ -static int8_t *nss_ipv6_log_message_types_str[NSS_IPV6_MAX_MSG_TYPES] __maybe_unused = { - "IPv6 create rule message", - "IPv6 destroy rule message", - "Deprecated: NSS_IPV4_RX_ESTABLISH_RULE_MSG", - "IPv6 connection stats sync message", - "IPv6 generic statistics sync message", - "IPv6 number of connections supported rule message", - "IPv6 multicast create rule message", - "IPv6 request FW to send many conn sync message", -}; - -/* - * nss_ipv6_log_error_response_types_str - * Strings for error types for ipv6 messages - */ -static int8_t *nss_ipv6_log_error_response_types_str[] __maybe_unused = { - "No error", - "Unknown error", - "Invalid interface number", - "Missing connection rule", - "Buffer allocation failure", - "No connection found to delete", - "Conn cfg already done once", - "Conn cfg input is not multiple of quanta", - "Conn cfg input exceeds max supported connections", - "Conn cfg mem alloc fail at NSS FW", - "Invalid L4 protocol for multicast rule create", - "Invalid multicast flags for multicast update", - "Invalid interface for multicast update", -}; - -/* - * nss_ipv6_log_rule_create_msg() - * Log IPv6 create rule message. - */ -static void nss_ipv6_log_rule_create_msg(struct nss_ipv6_msg *nim) -{ - uint32_t src_ip[4]; - uint32_t dest_ip[4]; - struct nss_ipv6_rule_create_msg *nircm = &nim->msg.rule_create; - - NSS_IPV6_ADDR_TO_NW(nircm->tuple.flow_ip, src_ip); - NSS_IPV6_ADDR_TO_NW(nircm->tuple.return_ip, dest_ip); - - nss_trace("%px: IPv6 create rule message \n" - "Protocol: %d\n" - "from_mtu: %u\n" - "to_mtu: %u\n" - "from_ip: %pI6:%d\n" - "to_ip: %pI6:%d\n" - "from_mac: %pM\n" - "to_mac: %pM\n" - "src_iface_num: %u\n" - "dest_iface_num: %u\n" - "ingress_inner_vlan_tag: %u\n" - "egress_inner_vlan_tag: %u\n" - "ingress_outer_vlan_tag: %u\n" - "egress_outer_vlan_tag: %u\n" - "rule_flags: %x\n" - "valid_flags: %x\n" - "return_pppoe_if_exist: %u\n" - "return_pppoe_if_num: %u\n" - "flow_pppoe_if_exist: %u\n" - "flow_pppoe_if_num: %u\n" - "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", - nim, - nircm->tuple.protocol, - nircm->conn_rule.flow_mtu, - nircm->conn_rule.return_mtu, - src_ip, nircm->tuple.flow_ident, - dest_ip, nircm->tuple.return_ident, - nircm->conn_rule.flow_mac, - nircm->conn_rule.return_mac, - nircm->conn_rule.flow_interface_num, - nircm->conn_rule.return_interface_num, - nircm->vlan_primary_rule.ingress_vlan_tag, - nircm->vlan_primary_rule.egress_vlan_tag, - nircm->vlan_secondary_rule.ingress_vlan_tag, - nircm->vlan_secondary_rule.egress_vlan_tag, - nircm->rule_flags, - nircm->valid_flags, - nircm->pppoe_rule.return_if_exist, - nircm->pppoe_rule.return_if_num, - nircm->pppoe_rule.flow_if_exist, - nircm->pppoe_rule.flow_if_num, - 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); -} - -/* - * nss_ipv6_log_destroy_rule_msg() - * Log IPv6 destroy rule message. - */ -static void nss_ipv6_log_destroy_rule_msg(struct nss_ipv6_msg *nim) -{ - uint32_t src_ip[4]; - uint32_t dest_ip[4]; - struct nss_ipv6_rule_destroy_msg *nirdm = &nim->msg.rule_destroy; - - NSS_IPV6_ADDR_TO_NW(nirdm->tuple.flow_ip, src_ip); - NSS_IPV6_ADDR_TO_NW(nirdm->tuple.return_ip, dest_ip); - - nss_trace("%px: IPv6 destroy rule message: \n" - "flow_ip: %pI6:%d\n" - "return_ip: %pI6:%d\n" - "protocol: %d\n", - nim, - src_ip, nirdm->tuple.flow_ident, - dest_ip, nirdm->tuple.return_ident, - nirdm->tuple.protocol); -} - -/* - * nss_ipv6_log_conn_sync() - * Log IPv6 connection stats sync message. - */ -static void nss_ipv6_log_conn_sync(struct nss_ipv6_msg *nim) -{ - struct nss_ipv6_conn_sync *sync = &nim->msg.conn_stats; - if (sync->flow_tx_packet_count || sync->return_tx_packet_count) { - uint32_t src_ip[4]; - uint32_t dest_ip[4]; - - NSS_IPV6_ADDR_TO_NW(sync->flow_ip, src_ip); - NSS_IPV6_ADDR_TO_NW(sync->return_ip, dest_ip); - - nss_trace("%px: IPv6 connection stats sync message: \n" - "Protocol: %d\n" - "src_addr: %pI6:%d\n" - "dest_addr: %pI6:%d\n" - "flow_rx_packet_count: %u\n" - "flow_rx_byte_count: %u\n" - "return_rx_packet_count: %u\n" - "return_rx_byte_count: %u\n" - "flow_tx_packet_count: %u\n" - "flow_tx_byte_count: %u\n" - "return_tx_packet_count: %u\n" - "return_tx_byte_count: %u\n", - nim, - (int)sync->protocol, - src_ip, (int)sync->flow_ident, - dest_ip, (int)sync->return_ident, - sync->flow_rx_packet_count, - sync->flow_rx_byte_count, - sync->return_rx_packet_count, - sync->return_rx_byte_count, - sync->flow_tx_packet_count, - sync->flow_tx_byte_count, - sync->return_tx_packet_count, - sync->return_tx_byte_count); - } -} - -/* - * nss_ipv6_log_conn_cfg_msg() - * Log IPv6 number of connections supported rule message. - */ -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("%px: IPv6 number of connections supported rule message: \n" - "num_conn: %d\n", - nim, - nirccm->num_conn); -} - -/* - * nss_ipv6_log_mc_rule_create_msg() - * Log IPv6 multicast create rule message. - */ -static void nss_ipv6_log_mc_rule_create_msg(struct nss_ipv6_msg *nim) -{ - uint16_t vif; - uint32_t src_ip[4]; - uint32_t dest_ip[4]; - struct nss_ipv6_mc_rule_create_msg *nimrcm = &nim->msg.mc_rule_create; - - NSS_IPV6_ADDR_TO_NW(nimrcm->tuple.flow_ip, src_ip); - NSS_IPV6_ADDR_TO_NW(nimrcm->tuple.return_ip, dest_ip); - - for (vif = 0; vif < nimrcm->if_count ; vif++) { - nss_trace("%px: IPv6 multicast create rule message \n" - "Rule flag: %x\n" - "Vif: %d\n" - "Protocol: %d\n" - "to_mtu: %u\n" - "from_ip: %pI6:%d\n" - "to_ip: %pI6:%d\n" - "to_mac: %pM\n" - "dest_iface_num: %u\n" - "out_vlan[0] %x\n" - "out_vlan[1] %x\n", - nim, - nimrcm->if_rule[vif].rule_flags, - vif, - nimrcm->tuple.protocol, - nimrcm->if_rule[vif].if_mtu, - src_ip, nimrcm->tuple.flow_ident, - dest_ip, nimrcm->tuple.return_ident, - nimrcm->if_rule[vif].if_mac, - nimrcm->if_rule[vif].if_num, - nimrcm->if_rule[vif].egress_vlan_tag[0], - nimrcm->if_rule[vif].egress_vlan_tag[1]); - } -} - -/* - * nss_ipv6_log_conn_sync_many_msg() - * Log IPv6 many conn sync message. - */ -static void nss_ipv6_log_conn_sync_many_msg(struct nss_ipv6_msg *nim) -{ - uint16_t i; - struct nss_ipv6_conn_sync_many_msg *nicsm = &nim->msg.conn_stats_many; - for (i = 0; i < nicsm->count; i++) { - struct nss_ipv6_conn_sync *sync = &nicsm->conn_sync[i]; - if (sync->flow_tx_packet_count || sync->return_tx_packet_count) { - uint32_t src_ip[4]; - uint32_t dest_ip[4]; - - NSS_IPV6_ADDR_TO_NW(sync->flow_ip, src_ip); - NSS_IPV6_ADDR_TO_NW(sync->return_ip, dest_ip); - - nss_trace("%px: IPv6 many conn sync message \n" - "count: %d\n" - "i: %d\n" - "Protocol: %d\n" - "src_addr: %pI6:%d\n" - "dest_addr: %pI6:%d\n" - "flow_rx_packet_count: %u\n" - "flow_rx_byte_count: %u\n" - "return_rx_packet_count: %u\n" - "return_rx_byte_count: %u\n" - "flow_tx_packet_count: %u\n" - "flow_tx_byte_count: %u\n" - "return_tx_packet_count: %u\n" - "return_tx_byte_count: %u\n", - nim, - nicsm->count, - i, - (int)sync->protocol, - src_ip, (int)sync->flow_ident, - dest_ip, (int)sync->return_ident, - sync->flow_rx_packet_count, - sync->flow_rx_byte_count, - sync->return_rx_packet_count, - sync->return_rx_byte_count, - sync->flow_tx_packet_count, - sync->flow_tx_byte_count, - sync->return_tx_packet_count, - sync->return_tx_byte_count); - } - } -} - -/* - * nss_ipv6_log_verbose() - * Log message contents. - */ -static void nss_ipv6_log_verbose(struct nss_ipv6_msg *nim) -{ - switch (nim->cm.type) { - case NSS_IPV6_TX_CREATE_RULE_MSG: - nss_ipv6_log_rule_create_msg(nim); - break; - - case NSS_IPV6_TX_DESTROY_RULE_MSG: - nss_ipv6_log_destroy_rule_msg(nim); - break; - - case NSS_IPV6_RX_CONN_STATS_SYNC_MSG: - nss_ipv6_log_conn_sync(nim); - break; - - case NSS_IPV6_RX_NODE_STATS_SYNC_MSG: - /* Getting logged in stats */ - break; - - case NSS_IPV6_TX_CONN_CFG_RULE_MSG: - nss_ipv6_log_conn_cfg_msg(nim); - break; - - case NSS_IPV6_TX_CREATE_MC_RULE_MSG: - nss_ipv6_log_mc_rule_create_msg(nim); - break; - - case NSS_IPV6_TX_CONN_STATS_SYNC_MANY_MSG: - nss_ipv6_log_conn_sync_many_msg(nim); - break; - - default: - nss_trace("%px: Invalid message type\n", nim); - break; - } -} - -/* - * nss_ipv6_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_ipv6_log_tx_msg(struct nss_ipv6_msg *nim) -{ - 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); -} - -/* - * nss_ipv6_log_rx_msg() - * Log messages received from FW. - */ -void nss_ipv6_log_rx_msg(struct nss_ipv6_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_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("%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("%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]); - -verbose: - nss_ipv6_log_verbose(nim); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm.c deleted file mode 100644 index 4ad8a7c24..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2015,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 - * 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_ipv6_reasm.c - * NSS IPv6 Reassembly APIs - */ -#include -#include "nss_ipv6_reasm_stats.h" -#include "nss_ipv6_reasm_strings.h" - -/* - * nss_ipv6_reasm_msg_handler() - * Handle NSS -> HLOS messages for IPv6 reasm - */ -static void nss_ipv6_reasm_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_ipv6_reasm_msg *nim = (struct nss_ipv6_reasm_msg *)ncm; - - BUG_ON(ncm->interface != NSS_IPV6_REASM_INTERFACE); - - switch (nim->cm.type) { - case NSS_IPV6_REASM_STATS_SYNC_MSG: - /* - * Update driver statistics on node sync and send statistics notifications to the registered modules. - */ - nss_ipv6_reasm_stats_sync(nss_ctx, &nim->msg.stats_sync); - nss_ipv6_reasm_stats_notify(nss_ctx); - break; - default: - nss_warning("IPv6 reasm received an unknown message type"); - } -} - -/* - * nss_ipv6_reasm_get_context() - * get NSS context instance for ipv6 reassembly - */ -struct nss_ctx_instance *nss_ipv6_reasm_get_context(void) -{ - return &nss_top_main.nss[nss_top_main.ipv6_reasm_handler_id]; -} -EXPORT_SYMBOL(nss_ipv6_reasm_get_context); - -/* - * nss_ipv6_reasm_register_handler() - * Register our handler to receive messages for this interface - */ -void nss_ipv6_reasm_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_ipv6_reasm_get_context(); - - if (nss_core_register_handler(nss_ctx, NSS_IPV6_REASM_INTERFACE, nss_ipv6_reasm_msg_handler, NULL) != NSS_CORE_STATUS_SUCCESS) { - nss_warning("IPv6 reasm handler failed to register"); - } - - nss_ipv6_reasm_stats_dentry_create(); - nss_ipv6_reasm_strings_dentry_create(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm_stats.c deleted file mode 100644 index d376f5af9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm_stats.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_ipv6_reasm_stats.h" -#include "nss_ipv6_reasm.h" -#include "nss_ipv6_reasm_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_ipv6_reasm_stats_notifier); - -uint64_t nss_ipv6_reasm_stats[NSS_IPV6_REASM_STATS_MAX]; /* IPv6 reasm statistics */ - -/* - * nss_ipv6_reasm_stats_read() - * Read IPV6 reassembly stats - */ -static ssize_t nss_ipv6_reasm_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_IPV6_REASM_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_IPV6_REASM_STATS_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, "ipv6_reasm", NSS_STATS_SINGLE_CORE); - - size_wr += nss_stats_fill_common_stats(NSS_IPV6_REASM_INTERFACE, NSS_STATS_SINGLE_INSTANCE, lbuf, size_wr, size_al, "ipv6_reasm"); - - /* - * Ipv6 reasm node stats - */ - - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; (i < NSS_IPV6_REASM_STATS_MAX); i++) { - stats_shadow[i] = nss_ipv6_reasm_stats[i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - - size_wr += nss_stats_print("ipv6_reasm", NULL, NSS_STATS_SINGLE_INSTANCE - , nss_ipv6_reasm_strings_stats - , stats_shadow - , NSS_IPV6_REASM_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_ipv6_reasm_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(ipv6_reasm); - -/* - * nss_ipv6_reasm_stats_dentry_create() - * Create IPv6 reasm statistics debug entry. - */ -void nss_ipv6_reasm_stats_dentry_create(void) -{ - nss_stats_create_dentry("ipv6_reasm", &nss_ipv6_reasm_stats_ops); -} - -/* - * nss_ipv6_reasm_stats_sync() - * Update driver specific information from the messsage. - */ -void nss_ipv6_reasm_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_reasm_stats_sync *nirs) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - int j; - - spin_lock_bh(&nss_top->stats_lock); - - /* - * Common node stats - */ - nss_top->stats_node[NSS_IPV6_REASM_INTERFACE][NSS_STATS_NODE_RX_PKTS] += nirs->node_stats.rx_packets; - nss_top->stats_node[NSS_IPV6_REASM_INTERFACE][NSS_STATS_NODE_RX_BYTES] += nirs->node_stats.rx_bytes; - nss_top->stats_node[NSS_IPV6_REASM_INTERFACE][NSS_STATS_NODE_TX_PKTS] += nirs->node_stats.tx_packets; - nss_top->stats_node[NSS_IPV6_REASM_INTERFACE][NSS_STATS_NODE_TX_BYTES] += nirs->node_stats.tx_bytes; - - for (j = 0; j < NSS_MAX_NUM_PRI; j++) { - nss_top->stats_node[NSS_IPV6_REASM_INTERFACE][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + j] += nirs->node_stats.rx_dropped[j]; - } - - /* - * IPv6 reasm node stats - */ - nss_ipv6_reasm_stats[NSS_IPV6_REASM_STATS_ALLOC_FAILS] += nirs->ipv6_reasm_alloc_fails; - nss_ipv6_reasm_stats[NSS_IPV6_REASM_STATS_TIMEOUTS] += nirs->ipv6_reasm_timeouts; - nss_ipv6_reasm_stats[NSS_IPV6_REASM_STATS_DISCARDS] += nirs->ipv6_reasm_discards; - - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_ipv6_reasm_stats_notify() - * Sends notifications to the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_ipv6_reasm_stats_notify(struct nss_ctx_instance *nss_ctx) -{ - struct nss_ipv6_reasm_stats_notification ipv6_reasm_stats; - - ipv6_reasm_stats.core_id = nss_ctx->id; - memcpy(ipv6_reasm_stats.cmn_node_stats, nss_top_main.stats_node[NSS_IPV6_REASM_INTERFACE], sizeof(ipv6_reasm_stats.cmn_node_stats)); - memcpy(ipv6_reasm_stats.ipv6_reasm_stats, nss_ipv6_reasm_stats, sizeof(ipv6_reasm_stats.ipv6_reasm_stats)); - atomic_notifier_call_chain(&nss_ipv6_reasm_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&ipv6_reasm_stats); -} - -/* - * nss_ipv6_reasm_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_ipv6_reasm_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_ipv6_reasm_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_ipv6_reasm_stats_register_notifier); - -/* - * nss_ipv6_reasm_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_ipv6_reasm_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_ipv6_reasm_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_ipv6_reasm_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm_stats.h deleted file mode 100644 index cdae31405..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm_stats.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_IPV6_REASM_STATS_H -#define __NSS_IPV6_REASM_STATS_H - -/* - * NSS IPv6 reasm statistics APIs - */ -extern void nss_ipv6_reasm_stats_notify(struct nss_ctx_instance *nss_ctx); -extern void nss_ipv6_reasm_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_reasm_stats_sync *nirs); -extern void nss_ipv6_reasm_stats_dentry_create(void); - -#endif /* __NSS_IPV6_REASM_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm_strings.c deleted file mode 100644 index 7b6436ab5..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm_strings.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_ipv6_reasm_strings_stats - * IPv6 reassembly statistics strings. - */ -struct nss_stats_info nss_ipv6_reasm_strings_stats[NSS_IPV6_REASM_STATS_MAX] = { - {"alloc_fails" , NSS_STATS_TYPE_DROP}, - {"timeouts" , NSS_STATS_TYPE_DROP}, - {"discards" , NSS_STATS_TYPE_DROP} -}; - -/* - * nss_ipv6_reasm_strings_read() - * Read IPv6 reassembly node statistics names. - */ -static ssize_t nss_ipv6_reasm_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_ipv6_reasm_strings_stats, NSS_IPV6_REASM_STATS_MAX); -} - -/* - * nss_ipv6_reasm_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(ipv6_reasm); - -/* - * nss_ipv6_reasm_strings_dentry_create() - * Create IPv6 reassembly statistics strings debug entry. - */ -void nss_ipv6_reasm_strings_dentry_create(void) -{ - nss_strings_create_dentry("ipv6_reasm", &nss_ipv6_reasm_strings_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm_strings.h deleted file mode 100644 index 6cac544d0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_reasm_strings.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_IPV6_REASM_STRINGS_H -#define __NSS_IPV6_REASM_STRINGS_H - -extern struct nss_stats_info nss_ipv6_reasm_strings_stats[NSS_IPV6_REASM_STATS_MAX]; -extern void nss_ipv6_reasm_strings_dentry_create(void); - -#endif /* __NSS_IPV6_REASM_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_stats.c deleted file mode 100644 index 617f55b73..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_stats.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2016-2017, 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. - * 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 -#include "nss_ipv6_stats.h" -#include "nss_ipv6_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_ipv6_stats_notifier); - -uint64_t nss_ipv6_stats[NSS_IPV6_STATS_MAX]; -uint64_t nss_ipv6_exception_stats[NSS_IPV6_EXCEPTION_EVENT_MAX]; - -/* - * nss_ipv6_stats_read() - * Read IPV6 stats. - */ -static ssize_t nss_ipv6_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int32_t i; - - /* - * max output lines = #stats + Number of Extra outputlines for future reference to add new stats + - * start tag line + end tag line + three blank lines. - */ - uint32_t max_output_lines = NSS_STATS_NODE_MAX + NSS_IPV6_STATS_MAX + NSS_IPV6_EXCEPTION_EVENT_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; - } - - /* - * Note: The assumption here is that exception event count is larger than other statistics count for IPv6. - */ - stats_shadow = kzalloc(NSS_IPV6_EXCEPTION_EVENT_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, "ipv6", NSS_STATS_SINGLE_CORE); - size_wr += nss_stats_fill_common_stats(NSS_IPV6_RX_INTERFACE, NSS_STATS_SINGLE_INSTANCE, lbuf, size_wr, size_al, "ipv6"); - - /* - * IPv6 node stats - */ - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; (i < NSS_IPV6_STATS_MAX); i++) { - stats_shadow[i] = nss_ipv6_stats[i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - - size_wr += nss_stats_print("ipv6", "ipv6 node stats", NSS_STATS_SINGLE_INSTANCE - , nss_ipv6_strings_stats - , stats_shadow - , NSS_IPV6_STATS_MAX - , lbuf, size_wr, size_al); - - /* - * Exception stats - */ - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; (i < NSS_IPV6_EXCEPTION_EVENT_MAX); i++) { - stats_shadow[i] = nss_ipv6_exception_stats[i]; - } - spin_unlock_bh(&nss_top_main.stats_lock); - - size_wr += nss_stats_print("ipv6", "ipv6 exception stats", NSS_STATS_SINGLE_INSTANCE - , nss_ipv6_strings_exception_stats - , stats_shadow - , NSS_IPV6_EXCEPTION_EVENT_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_ipv6_stats_conn_sync() - * Update driver specific information from the messsage. - */ -void nss_ipv6_stats_conn_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_conn_sync *nics) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - - /* - * Update statistics maintained by NSS driver - */ - spin_lock_bh(&nss_top->stats_lock); - nss_ipv6_stats[NSS_IPV6_STATS_ACCELERATED_RX_PKTS] += nics->flow_rx_packet_count + nics->return_rx_packet_count; - nss_ipv6_stats[NSS_IPV6_STATS_ACCELERATED_RX_BYTES] += nics->flow_rx_byte_count + nics->return_rx_byte_count; - nss_ipv6_stats[NSS_IPV6_STATS_ACCELERATED_TX_PKTS] += nics->flow_tx_packet_count + nics->return_tx_packet_count; - nss_ipv6_stats[NSS_IPV6_STATS_ACCELERATED_TX_BYTES] += nics->flow_tx_byte_count + nics->return_tx_byte_count; - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_ipv6_stats_conn_sync_many() - * Update driver specific information from the conn_sync_many messsage. - */ -void nss_ipv6_stats_conn_sync_many(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_conn_sync_many_msg *nicsm) -{ - uint32_t i; - - /* - * Sanity check for the stats count - */ - if (nicsm->count * sizeof(struct nss_ipv6_conn_sync) >= nicsm->size) { - nss_warning("%px: stats sync count %u exceeds the size of this msg %u", nss_ctx, nicsm->count, nicsm->size); - return; - } - - for (i = 0; i < nicsm->count; i++) { - nss_ipv6_stats_conn_sync(nss_ctx, &nicsm->conn_sync[i]); - } -} - -/* - * nss_ipv6_stats_node_sync() - * Update driver specific information from the messsage. - */ -void nss_ipv6_stats_node_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_node_sync *nins) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - uint32_t i; - - /* - * Update statistics maintained by NSS driver - */ - spin_lock_bh(&nss_top->stats_lock); - nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_RX_PKTS] += nins->node_stats.rx_packets; - nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_RX_BYTES] += nins->node_stats.rx_bytes; - nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_TX_PKTS] += nins->node_stats.tx_packets; - nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_TX_BYTES] += nins->node_stats.tx_bytes; - - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - nss_top->stats_node[NSS_IPV6_RX_INTERFACE][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + i] += nins->node_stats.rx_dropped[i]; - } - - nss_ipv6_stats[NSS_IPV6_STATS_CONNECTION_CREATE_REQUESTS] += nins->ipv6_connection_create_requests; - nss_ipv6_stats[NSS_IPV6_STATS_CONNECTION_CREATE_COLLISIONS] += nins->ipv6_connection_create_collisions; - nss_ipv6_stats[NSS_IPV6_STATS_CONNECTION_CREATE_INVALID_INTERFACE] += nins->ipv6_connection_create_invalid_interface; - nss_ipv6_stats[NSS_IPV6_STATS_CONNECTION_DESTROY_REQUESTS] += nins->ipv6_connection_destroy_requests; - nss_ipv6_stats[NSS_IPV6_STATS_CONNECTION_DESTROY_MISSES] += nins->ipv6_connection_destroy_misses; - nss_ipv6_stats[NSS_IPV6_STATS_CONNECTION_HASH_HITS] += nins->ipv6_connection_hash_hits; - nss_ipv6_stats[NSS_IPV6_STATS_CONNECTION_HASH_REORDERS] += nins->ipv6_connection_hash_reorders; - nss_ipv6_stats[NSS_IPV6_STATS_CONNECTION_FLUSHES] += nins->ipv6_connection_flushes; - nss_ipv6_stats[NSS_IPV6_STATS_CONNECTION_EVICTIONS] += nins->ipv6_connection_evictions; - nss_ipv6_stats[NSS_IPV6_STATS_FRAGMENTATIONS] += nins->ipv6_fragmentations; - nss_ipv6_stats[NSS_IPV6_STATS_FRAG_FAILS] += nins->ipv6_frag_fails; - nss_ipv6_stats[NSS_IPV6_STATS_MC_CONNECTION_CREATE_REQUESTS] += nins->ipv6_mc_connection_create_requests; - nss_ipv6_stats[NSS_IPV6_STATS_MC_CONNECTION_UPDATE_REQUESTS] += nins->ipv6_mc_connection_update_requests; - nss_ipv6_stats[NSS_IPV6_STATS_MC_CONNECTION_CREATE_INVALID_INTERFACE] += nins->ipv6_mc_connection_create_invalid_interface; - 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]; - } - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_ipv6_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(ipv6); - -/* - * nss_ipv6_stats_dentry_create() - * Create IPv6 statistics debug entry. - */ -void nss_ipv6_stats_dentry_create(void) -{ - nss_stats_create_dentry("ipv6", &nss_ipv6_stats_ops); -} - -/* - * nss_ipv6_stats_notify() - * Sends notifications to all the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_ipv6_stats_notify(struct nss_ctx_instance *nss_ctx) -{ - struct nss_ipv6_stats_notification ipv6_stats; - - ipv6_stats.core_id = nss_ctx->id; - memcpy(ipv6_stats.cmn_node_stats, nss_top_main.stats_node[NSS_IPV6_RX_INTERFACE], sizeof(ipv6_stats.cmn_node_stats)); - memcpy(ipv6_stats.special_stats, nss_ipv6_stats, sizeof(ipv6_stats.special_stats)); - memcpy(ipv6_stats.exception_stats, nss_ipv6_exception_stats, sizeof(ipv6_stats.exception_stats)); - - atomic_notifier_call_chain(&nss_ipv6_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&ipv6_stats); -} - -/* - * nss_ipv6_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_ipv6_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_ipv6_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_ipv6_stats_register_notifier); - -/* - * nss_ipv6_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_ipv6_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_ipv6_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_ipv6_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_stats.h deleted file mode 100644 index 1eaff5e2b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_stats.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_IPV6_STATS_H -#define __NSS_IPV6_STATS_H - -/* - * IPV6 statistics APIs - */ -extern void nss_ipv6_stats_notify(struct nss_ctx_instance *nss_ctx); -extern void nss_ipv6_stats_node_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_node_sync *nins); -extern void nss_ipv6_stats_conn_sync(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_conn_sync *nics); -extern void nss_ipv6_stats_conn_sync_many(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_conn_sync_many_msg *nicsm); -extern void nss_ipv6_stats_dentry_create(void); - -#endif /* __NSS_IPV6_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_strings.c deleted file mode 100644 index 57b100f7b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_strings.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * - * 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_ipv6_strings_exception_stats - * Interface statistics strings for IPv6 exceptions. - */ -struct nss_stats_info nss_ipv6_strings_exception_stats[NSS_IPV6_EXCEPTION_EVENT_MAX] = { - {"icmp_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_unhandled_type" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_udp_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_tcp_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_unknown_protocol" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_flush_to_host" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_small_hop_limit" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_flags" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_seq_exceeds_right_edge" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_small_data_offs" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_bad_sack" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_big_data_offs" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_seq_before_left_edge" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_ack_exceeds_right_edge" , NSS_STATS_TYPE_EXCEPTION}, - {"tcp_ack_before_left_edge" , NSS_STATS_TYPE_EXCEPTION}, - {"udp_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"udp_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"udp_small_hop_limit" , NSS_STATS_TYPE_EXCEPTION}, - {"udp_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"wrong_target_mac" , NSS_STATS_TYPE_EXCEPTION}, - {"header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"unknown_protocol" , NSS_STATS_TYPE_EXCEPTION}, - {"ingress_vid_mismatch" , NSS_STATS_TYPE_EXCEPTION}, - {"ingress_vid_missing" , NSS_STATS_TYPE_EXCEPTION}, - {"dscp_marking_mismatch" , NSS_STATS_TYPE_EXCEPTION}, - {"vlan_marking_mismatch" , NSS_STATS_TYPE_EXCEPTION}, - {"interface_mismatch" , NSS_STATS_TYPE_EXCEPTION}, - {"gre_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"gre_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"gre_small_hop_limit" , NSS_STATS_TYPE_EXCEPTION}, - {"destroy" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_udplite_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"udplite_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"udplite_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"udplite_small_hop_limit" , NSS_STATS_TYPE_EXCEPTION}, - {"udplite_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"mc_udp_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"mc_mem_alloc_failure" , NSS_STATS_TYPE_EXCEPTION}, - {"mc_update_failure" , NSS_STATS_TYPE_EXCEPTION}, - {"mc_pbuf_alloc_failure" , NSS_STATS_TYPE_EXCEPTION}, - {"esp_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"esp_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"esp_ip_fragment" , NSS_STATS_TYPE_EXCEPTION}, - {"esp_small_hop_limit" , NSS_STATS_TYPE_EXCEPTION}, - {"esp_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"tunipip6_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"tunipip6_small_hop_limit" , NSS_STATS_TYPE_EXCEPTION}, - {"tunipip6_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"pppoe_bridge_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"dont_frag_set" , NSS_STATS_TYPE_EXCEPTION}, - {"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}, -}; - -/* - * nss_ipv6_strings_stats - * IPv6 stats strings. - */ -struct nss_stats_info nss_ipv6_strings_stats[NSS_IPV6_STATS_MAX] = { - {"rx_pkts" ,NSS_STATS_TYPE_SPECIAL}, - {"rx_bytes" ,NSS_STATS_TYPE_SPECIAL}, - {"tx_pkts" ,NSS_STATS_TYPE_SPECIAL}, - {"tx_bytes" ,NSS_STATS_TYPE_SPECIAL}, - {"create_requests" ,NSS_STATS_TYPE_SPECIAL}, - {"create_collisions" ,NSS_STATS_TYPE_SPECIAL}, - {"create_invalid_interface" ,NSS_STATS_TYPE_SPECIAL}, - {"destroy_requests" ,NSS_STATS_TYPE_SPECIAL}, - {"destroy_misses" ,NSS_STATS_TYPE_SPECIAL}, - {"hash_hits" ,NSS_STATS_TYPE_SPECIAL}, - {"hash_reorders" ,NSS_STATS_TYPE_SPECIAL}, - {"flushes" ,NSS_STATS_TYPE_SPECIAL}, - {"evictions" ,NSS_STATS_TYPE_SPECIAL}, - {"fragmentations" ,NSS_STATS_TYPE_SPECIAL}, - {"frag_fails" ,NSS_STATS_TYPE_SPECIAL}, - {"by_rule_drops" ,NSS_STATS_TYPE_DROP}, - {"mc_create_requests" ,NSS_STATS_TYPE_SPECIAL}, - {"mc_update_requests" ,NSS_STATS_TYPE_SPECIAL}, - {"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}, -}; - -/* - * nss_ipv6_special_stats_strings_read() - * Read IPv6 special node statistics names. - */ -static ssize_t nss_ipv6_special_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_ipv6_strings_stats, NSS_IPV6_STATS_MAX); -} - -/* - * nss_ipv6_exception_stats_strings_read() - * Read IPv6 exception statistics names. - */ -static ssize_t nss_ipv6_exception_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_ipv6_strings_exception_stats, NSS_IPV6_EXCEPTION_EVENT_MAX); -} - -/* - * nss_ipv6_special_stats_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(ipv6_special_stats); - -/* - * nss_ipv6_exception_stats_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(ipv6_exception_stats); - -/* - * nss_ipv6_strings_dentry_create() - * Create IPv6 statistics strings debug entry. - */ -void nss_ipv6_strings_dentry_create(void) -{ - struct dentry *ipv6_d = NULL; - struct dentry *ipv6_spcl_stats_d = NULL; - struct dentry *ipv6_excp_stats_d = NULL; - - if (!nss_top_main.strings_dentry) { - nss_warning("qca-nss-drv/strings is not present"); - return; - } - - ipv6_d = debugfs_create_dir("ipv6", nss_top_main.strings_dentry); - if (!ipv6_d) { - nss_warning("Failed to create qca-nss-drv/strings/ipv6 directory"); - return; - } - - ipv6_spcl_stats_d = debugfs_create_file("special_stats_str", 0400, ipv6_d, &nss_top_main, &nss_ipv6_special_stats_strings_ops); - if (!ipv6_spcl_stats_d) { - nss_warning("Failed to create qca-nss-drv/stats/ipv6/special_stats_str file"); - debugfs_remove_recursive(ipv6_d); - return; - } - - ipv6_excp_stats_d = debugfs_create_file("exception_stats_str", 0400, ipv6_d, &nss_top_main, &nss_ipv6_exception_stats_strings_ops); - if (!ipv6_excp_stats_d) { - nss_warning("Failed to create qca-nss-drv/stats/ipv6/exception_stats_str file"); - debugfs_remove_recursive(ipv6_d); - return; - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_strings.h deleted file mode 100644 index 4f582e581..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ipv6_strings.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_IPV6_STRINGS_H -#define __NSS_IPV6_STRINGS_H - -extern struct nss_stats_info nss_ipv6_strings_stats[NSS_IPV6_STATS_MAX]; -extern struct nss_stats_info nss_ipv6_strings_exception_stats[NSS_IPV6_EXCEPTION_EVENT_MAX]; -extern void nss_ipv6_strings_dentry_create(void); - -#endif /* __NSS_IPV6_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2.c b/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2.c deleted file mode 100644 index 2c73b4860..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -#include -#include -#include "nss_tx_rx_common.h" -#include "nss_l2tpv2_stats.h" -#include "nss_l2tpv2_log.h" -#include "nss_l2tpv2_strings.h" - -/* - * Data structures to store l2tpv2 nss debug stats - */ -static DEFINE_SPINLOCK(nss_l2tpv2_session_debug_stats_lock); -static struct nss_l2tpv2_stats_session_debug nss_l2tpv2_session_debug_stats[NSS_MAX_L2TPV2_DYNAMIC_INTERFACES]; - -/* - * nss_l2tpv2_session_debug_stats_sync - * Per session debug stats for l2tpv2 - */ -void nss_l2tpv2_session_debug_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_l2tpv2_sync_session_stats_msg *stats_msg, uint16_t if_num) -{ - int i; - spin_lock_bh(&nss_l2tpv2_session_debug_stats_lock); - for (i = 0; i < NSS_MAX_L2TPV2_DYNAMIC_INTERFACES; i++) { - if (nss_l2tpv2_session_debug_stats[i].if_num == if_num) { - nss_l2tpv2_session_debug_stats[i].stats[NSS_L2TPV2_STATS_SESSION_RX_PPP_LCP_PKTS] += stats_msg->debug_stats.rx_ppp_lcp_pkts; - nss_l2tpv2_session_debug_stats[i].stats[NSS_L2TPV2_STATS_SESSION_RX_EXP_DATA_PKTS] += stats_msg->debug_stats.rx_exception_data_pkts; - nss_l2tpv2_session_debug_stats[i].stats[NSS_L2TPV2_STATS_SESSION_ENCAP_PBUF_ALLOC_FAIL_PKTS] += stats_msg->debug_stats.encap_pbuf_alloc_fail; - nss_l2tpv2_session_debug_stats[i].stats[NSS_L2TPV2_STATS_SESSION_DECAP_PBUF_ALLOC_FAIL_PKTS] += stats_msg->debug_stats.decap_pbuf_alloc_fail; - nss_l2tpv2_session_debug_stats[i].stats[NSS_L2TPV2_STATS_SESSION_DECAP_L2TPOIPSEC_SRC_ERR] += stats_msg->debug_stats.decap_l2tpoipsec_src_error; - break; - } - } - spin_unlock_bh(&nss_l2tpv2_session_debug_stats_lock); -} - -/* - * nss_l2tpv2_global_session_stats_get() - * Get session l2tpv2 statitics. - */ -void nss_l2tpv2_session_debug_stats_get(void *stats_mem) -{ - struct nss_l2tpv2_stats_session_debug *stats = (struct nss_l2tpv2_stats_session_debug *)stats_mem; - int i; - - if (!stats) { - nss_warning("No memory to copy l2tpv2 session stats"); - return; - } - - spin_lock_bh(&nss_l2tpv2_session_debug_stats_lock); - for (i = 0; i < NSS_MAX_L2TPV2_DYNAMIC_INTERFACES; i++) { - if (nss_l2tpv2_session_debug_stats[i].valid) { - memcpy(stats, &nss_l2tpv2_session_debug_stats[i], sizeof(struct nss_l2tpv2_stats_session_debug)); - stats++; - } - } - spin_unlock_bh(&nss_l2tpv2_session_debug_stats_lock); -} - -/* - * nss_l2tpv2_handler() - * Handle NSS -> HLOS messages for l2tpv2 tunnel - */ - -static void nss_l2tpv2_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_l2tpv2_msg *ntm = (struct nss_l2tpv2_msg *)ncm; - void *ctx; - - nss_l2tpv2_msg_callback_t cb; - - BUG_ON(!(nss_is_dynamic_interface(ncm->interface) || ncm->interface == NSS_L2TPV2_INTERFACE)); - - /* - * Trace Messages - */ - nss_l2tpv2_log_rx_msg(ntm); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_L2TPV2_MSG_MAX) { - 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("%px: message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - switch (ntm->cm.type) { - - case NSS_L2TPV2_MSG_SYNC_STATS: - /* - * Update session debug stats in session stats msg and send statistics notifications to the registered modules - */ - nss_l2tpv2_session_debug_stats_sync(nss_ctx, &ntm->msg.stats, ncm->interface); - nss_l2tpv2_stats_notify(nss_ctx, ncm->interface); - break; - } - - /* - * Update the callback and app_data for NOTIFY messages, l2tpv2 sends all notify messages - * to the same callback/app_data. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->l2tpv2_msg_callback; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_l2tpv2_msg_callback_t)ncm->cb; - ctx = nss_ctx->subsys_dp_register[ncm->interface].ndev; - - /* - * call l2tpv2 tunnel callback - */ - if (!ctx) { - nss_warning("%px: Event received for l2tpv2 tunnel interface %d before registration", nss_ctx, ncm->interface); - return; - } - - cb(ctx, ntm); -} - -/* - * nss_l2tpv2_tx() - * Transmit a l2tpv2 message to NSS firmware - */ -nss_tx_status_t nss_l2tpv2_tx(struct nss_ctx_instance *nss_ctx, struct nss_l2tpv2_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace Messages - */ - nss_l2tpv2_log_tx_msg(msg); - - /* - * Sanity check the message - */ - if (!nss_is_dynamic_interface(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("%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); -} - -/* - *********************************** - * Register/Unregister/Miscellaneous APIs - *********************************** - */ - -/* - * nss_register_l2tpv2_if() - */ -struct nss_ctx_instance *nss_register_l2tpv2_if(uint32_t if_num, nss_l2tpv2_callback_t l2tpv2_callback, - nss_l2tpv2_msg_callback_t event_callback, struct net_device *netdev, uint32_t features) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.l2tpv2_handler_id]; - int i = 0; - - nss_assert(nss_ctx); - nss_assert(nss_is_dynamic_interface(if_num)); - - nss_core_register_subsys_dp(nss_ctx, if_num, l2tpv2_callback, NULL, NULL, netdev, features); - - nss_top_main.l2tpv2_msg_callback = event_callback; - - nss_core_register_handler(nss_ctx, if_num, nss_l2tpv2_handler, NULL); - - spin_lock_bh(&nss_l2tpv2_session_debug_stats_lock); - for (i = 0; i < NSS_MAX_L2TPV2_DYNAMIC_INTERFACES; i++) { - if (!nss_l2tpv2_session_debug_stats[i].valid) { - nss_l2tpv2_session_debug_stats[i].valid = true; - nss_l2tpv2_session_debug_stats[i].if_num = if_num; - nss_l2tpv2_session_debug_stats[i].if_index = netdev->ifindex; - break; - } - } - spin_unlock_bh(&nss_l2tpv2_session_debug_stats_lock); - - return nss_ctx; -} - -/* - * nss_unregister_l2tpv2_if() - */ -void nss_unregister_l2tpv2_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.l2tpv2_handler_id]; - int i; - - nss_assert(nss_ctx); - nss_assert(nss_is_dynamic_interface(if_num)); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - nss_top_main.l2tpv2_msg_callback = NULL; - - nss_core_unregister_handler(nss_ctx, if_num); - - spin_lock_bh(&nss_l2tpv2_session_debug_stats_lock); - for (i = 0; i < NSS_MAX_L2TPV2_DYNAMIC_INTERFACES; i++) { - if (nss_l2tpv2_session_debug_stats[i].if_num == if_num) { - memset(&nss_l2tpv2_session_debug_stats[i], 0, sizeof(struct nss_l2tpv2_stats_session_debug)); - break; - } - } - spin_unlock_bh(&nss_l2tpv2_session_debug_stats_lock); -} - -/* - * nss_get_l2tpv2_context() - */ -struct nss_ctx_instance *nss_l2tpv2_get_context() -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.l2tpv2_handler_id]; -} - -/* - * nss_l2tpv2_msg_init() - * Initialize nss_l2tpv2 msg. - */ -void nss_l2tpv2_msg_init(struct nss_l2tpv2_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} - -/* nss_l2tpv2_register_handler() - * debugfs stats msg handler received on static l2tpv2 interface - */ -void nss_l2tpv2_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_l2tpv2_get_context(); - - nss_info("nss_l2tpv2_register_handler"); - nss_core_register_handler(nss_ctx, NSS_L2TPV2_INTERFACE, nss_l2tpv2_handler, NULL); - - nss_l2tpv2_stats_dentry_create(); - nss_l2tpv2_strings_dentry_create(); -} - -EXPORT_SYMBOL(nss_l2tpv2_get_context); -EXPORT_SYMBOL(nss_l2tpv2_tx); -EXPORT_SYMBOL(nss_unregister_l2tpv2_if); -EXPORT_SYMBOL(nss_l2tpv2_msg_init); -EXPORT_SYMBOL(nss_register_l2tpv2_if); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_log.c deleted file mode 100644 index fc1b31fc5..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_log.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_l2tpv2_log.c - * NSS L2TPV2 logger file. - */ - -#include "nss_core.h" - -/* - * nss_l2tpv2_log_message_types_str - * NSS L2TPV2 message strings - */ -static int8_t *nss_l2tpv2_log_message_types_str[NSS_L2TPV2_MSG_MAX] __maybe_unused = { - "L2TPV2 Sesstion Create", - "L2TPV2 Session Destroy", - "L2TPV2 Stats", -}; - -/* - * nss_l2tpv2_log_session_create_msg() - * Log NSS L2TPV2 Session Create. - */ -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("%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" - "L2TPV2 Peer Session ID: %x\n" - "L2TPV2 Source IP: %x\n" - "L2TPV2 Destnation IP: %x\n" - "L2TPV2 Reorder Timeout: %d\n" - "L2TPV2 Source Port: %d\n" - "L2TPV2 Destination Port: %d\n" - "L2TPV2 Received Sequence Number: %d\n" - "L2TPV2 Outer IP Packet TTL: %d\n" - "L2TPV2 UDP Checksum: %d\n", - nlcm, nlcm->local_tunnel_id, - nlcm->local_session_id, nlcm->peer_tunnel_id, - nlcm->peer_session_id, nlcm->sip, - nlcm->dip, nlcm->reorder_timeout, - nlcm->sport, nlcm->dport, - nlcm->recv_seq, nlcm->oip_ttl, - nlcm->udp_csum); -} - -/* - * nss_l2tpv2_log_session_destroy_msg() - * Log NSS L2TPV2 Session Create. - */ -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("%px: NSS L2TPV2 Session Destroy message \n" - "L2TPV2 Local Tunnel ID: %x\n" - "L2TPV2 Local Session ID: %x\n", - nldm, nldm->local_tunnel_id, - nldm->local_session_id); -} - -/* - * nss_l2tpv2_log_verbose() - * Log message contents. - */ -static void nss_l2tpv2_log_verbose(struct nss_l2tpv2_msg *nlm) -{ - switch (nlm->cm.type) { - case NSS_L2TPV2_MSG_SESSION_CREATE: - nss_l2tpv2_log_session_create_msg(nlm); - break; - - case NSS_L2TPV2_MSG_SESSION_DESTROY: - nss_l2tpv2_log_session_destroy_msg(nlm); - break; - - case NSS_L2TPV2_MSG_SYNC_STATS: - /* - * No log for valid stats message. - */ - break; - - default: - nss_trace("%px: Invalid message type\n", nlm); - break; - } -} - -/* - * nss_l2tpv2_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_l2tpv2_log_tx_msg(struct nss_l2tpv2_msg *nlm) -{ - if (nlm->cm.type >= NSS_L2TPV2_MSG_MAX) { - nss_warning("%px: Invalid message type\n", nlm); - return; - } - - 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); -} - -/* - * nss_l2tpv2_log_rx_msg() - * Log messages received from FW. - */ -void nss_l2tpv2_log_rx_msg(struct nss_l2tpv2_msg *nlm) -{ - if (nlm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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]); - -verbose: - nss_l2tpv2_log_verbose(nlm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_log.h deleted file mode 100644 index 56cc9dee3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_L2TPV2_LOG_H -#define __NSS_L2TPV2_LOG_H - -/* - * nss_l2tpv2.h - * NSS L2TPV2 header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_l2tpv2_log_tx_msg - * Logs a l2tpv2 message that is sent to the NSS firmware. - */ -void nss_l2tpv2_log_tx_msg(struct nss_l2tpv2_msg *ntm); - -/* - * nss_l2tpv2_log_rx_msg - * Logs a l2tpv2 message that is received from the NSS firmware. - */ -void nss_l2tpv2_log_rx_msg(struct nss_l2tpv2_msg *ntm); - -#endif /* __NSS_L2TPV2_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_stats.c deleted file mode 100644 index 0784b54b8..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_stats.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_l2tpv2_stats.h" -#include "nss_l2tpv2_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_l2tpv2_stats_notifier); - -/* - * nss_l2tpv2_stats_read() - * Read l2tpv2 statistics. - */ -static ssize_t nss_l2tpv2_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - /* - * Max output lines = #stats * NSS_MAX_CORES + - * Few output lines for banner printing + Number of Extra outputlines for future reference to add new stats. - */ - uint32_t max_output_lines = NSS_MAX_L2TPV2_DYNAMIC_INTERFACES * (NSS_L2TPV2_STATS_SESSION_MAX + 2) /*session stats */ - + 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; - struct net_device *dev; - struct nss_l2tpv2_stats_session_debug l2tpv2_session_stats[NSS_MAX_L2TPV2_DYNAMIC_INTERFACES]; - int id; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(lbuf == NULL)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - memset(&l2tpv2_session_stats, 0, sizeof(struct nss_l2tpv2_stats_session_debug) * NSS_MAX_L2TPV2_DYNAMIC_INTERFACES); - size_wr += nss_stats_banner(lbuf, size_wr, size_al, "l2tpv2", NSS_STATS_SINGLE_CORE); - - /* - * Get all stats - */ - nss_l2tpv2_session_debug_stats_get((void *)&l2tpv2_session_stats); - - /* - * Session stats - */ - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nl2tp v2 session stats start:\n\n"); - for (id = 0; id < NSS_MAX_L2TPV2_DYNAMIC_INTERFACES; id++) { - - if (!l2tpv2_session_stats[id].valid) { - break; - } - - dev = dev_get_by_index(&init_net, l2tpv2_session_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, - l2tpv2_session_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, - l2tpv2_session_stats[id].if_num); - } - - size_wr += nss_stats_print("l2tpv2", "l2tp v2 session stats" - , id - , nss_l2tpv2_strings_session_stats - , l2tpv2_session_stats[id].stats - , NSS_L2TPV2_STATS_SESSION_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(lbuf); - return bytes_read; -} - -/* - * nss_l2tpv2_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(l2tpv2); - -/* - * nss_l2tpv2_stats_dentry_create() - * Create l2tpv2 statistics debug entry. - */ -void nss_l2tpv2_stats_dentry_create(void) -{ - nss_stats_create_dentry("l2tpv2", &nss_l2tpv2_stats_ops); -} - -/* - * nss_l2tpv2_stats_notify() - * Sends notifications to all the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_l2tpv2_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - struct nss_l2tpv2_stats_notification l2tpv2_stats; - struct nss_l2tpv2_stats_session_debug l2tpv2_session_stats[NSS_MAX_L2TPV2_DYNAMIC_INTERFACES]; - int id; - - memset(&l2tpv2_session_stats, 0, sizeof(l2tpv2_session_stats)); - - /* - * Get all stats - */ - nss_l2tpv2_session_debug_stats_get((void *)&l2tpv2_session_stats); - - for (id = 0; id < NSS_MAX_L2TPV2_DYNAMIC_INTERFACES; id++) { - if (l2tpv2_session_stats[id].if_num == if_num) { - memcpy(&l2tpv2_stats.stats, &l2tpv2_session_stats[id].stats, sizeof(l2tpv2_stats.stats)); - } - } - l2tpv2_stats.core_id = nss_ctx->id; - l2tpv2_stats.if_num = if_num; - atomic_notifier_call_chain(&nss_l2tpv2_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&l2tpv2_stats); -} - -/* - * nss_l2tpv2_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_l2tpv2_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_l2tpv2_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_l2tpv2_stats_register_notifier); - -/* - * nss_l2tpv2_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_l2tpv2_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_l2tpv2_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_l2tpv2_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_stats.h deleted file mode 100644 index 0c8ecda4d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_stats.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_L2TPV2_STATS_H -#define __NSS_L2TPV2_STATS_H - -struct nss_l2tpv2_stats_session_debug { - uint64_t stats[NSS_L2TPV2_STATS_SESSION_MAX]; - int32_t if_index; - uint32_t if_num; /* nss interface number */ - bool valid; -}; - -/* - * l2tpv2 statistics APIs - */ -extern void nss_l2tpv2_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); -extern void nss_l2tpv2_stats_dentry_create(void); - -#endif /* __NSS_L2TPV2_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_strings.c deleted file mode 100644 index d5db00c0b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_strings.c +++ /dev/null @@ -1,57 +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 -#include "nss_strings.h" - -/* - * nss_l2tpv2_strings_session_stats - * L2TPv2 statistics strings for NSS session statistics. - */ -struct nss_stats_info nss_l2tpv2_strings_session_stats[NSS_L2TPV2_STATS_SESSION_MAX] = { - {"rx_ppp_lcp_pkts" , NSS_STATS_TYPE_EXCEPTION}, - {"rx_exp_pkts" , NSS_STATS_TYPE_EXCEPTION}, - {"encap_pbuf_alloc_fails" , NSS_STATS_TYPE_SPECIAL}, - {"decap_pbuf_alloc_fails" , NSS_STATS_TYPE_SPECIAL}, - {"decap_l2tpoipsec_src_err" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_l2tpv2_strings_read() - * Read L2TPv2 node statistics names. - */ -static ssize_t nss_l2tpv2_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_l2tpv2_strings_session_stats, NSS_L2TPV2_STATS_SESSION_MAX); -} - -/* - * nss_l2tpv2_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(l2tpv2); - -/* - * nss_l2tpv2_strings_dentry_create() - * Create L2TPv2 statistics strings debug entry. - */ -void nss_l2tpv2_strings_dentry_create(void) -{ - nss_strings_create_dentry("l2tpv2", &nss_l2tpv2_strings_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_strings.h deleted file mode 100644 index 2e8f871c1..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_l2tpv2_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_L2TPV2_STRINGS_H -#define __NSS_L2TPV2_STRINGS_H - -extern struct nss_stats_info nss_l2tpv2_strings_session_stats[NSS_L2TPV2_STATS_SESSION_MAX]; -extern void nss_l2tpv2_strings_dentry_create(void); - -#endif /* __NSS_L2TPV2_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_lag.c b/feeds/ipq807x/qca-nss-drv/src/nss_lag.c deleted file mode 100644 index 02362e173..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_lag.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_tx_rx_lag.c - * NSS LAG Tx APIs - */ - -#include - -#include "nss_tx_rx_common.h" -#include "nss_lag_log.h" - -#define NSS_LAG_RESP_TIMEOUT 60000 /* 60 Sec */ - -/* - * Private data structure of dynamic interface - */ -struct nss_lag_pvt { - struct completion complete; /* completion structure */ - enum nss_cmn_response response; /* Message response */ -}; - -/* - * nss_lag_state_callback() - * Call back function for nss LAG State - */ -void nss_lag_state_callback(void *arg, struct nss_lag_msg *nm) -{ - struct nss_lag_pvt *lag_msg_state = arg; - - /* - * Unblock the sleeping function. - */ - lag_msg_state->response = nm->cm.response; - complete(&lag_msg_state->complete); -} - -/* - * nss_lag_verify_ifnum() - * - */ -static void nss_lag_verify_ifnum(uint32_t if_num) -{ - nss_assert((if_num == NSS_LAG0_INTERFACE_NUM) || - (if_num == NSS_LAG1_INTERFACE_NUM) || - (if_num == NSS_LAG2_INTERFACE_NUM) || - (if_num == NSS_LAG3_INTERFACE_NUM)); -} - -/* - * nss_lag_get_context() - */ -static struct nss_ctx_instance *nss_lag_get_context(void) -{ - uint8_t ipv4_handler_id = nss_top_main.ipv4_handler_id; - - return (struct nss_ctx_instance *)&nss_top_main.nss[ipv4_handler_id]; -} - -/* - * nss_lag_tx() - * Transmit a LAG msg to the firmware. - */ -nss_tx_status_t nss_lag_tx(struct nss_ctx_instance *nss_ctx, struct nss_lag_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace Messages - */ - nss_lag_log_tx_msg(msg); - - /* - * Sanity check the message - */ - nss_lag_verify_ifnum(ncm->interface); - - if (ncm->type > NSS_TX_METADATA_LAG_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); -} -EXPORT_SYMBOL(nss_lag_tx); - -/** - * nss_register_lag_if() - */ -void *nss_register_lag_if(uint32_t if_num, - nss_lag_callback_t lag_cb, - nss_lag_event_callback_t lag_ev_cb, - struct net_device *netdev) -{ - struct nss_ctx_instance *nss_ctx = nss_lag_get_context(); - uint32_t features = 0; - - nss_assert(nss_ctx); - nss_lag_verify_ifnum(if_num); - - nss_core_register_subsys_dp(nss_ctx, if_num, lag_cb, NULL, NULL, netdev, features); - - nss_top_main.lag_event_callback = lag_ev_cb; - - /* - * Return the NSS driver context for LAG (same as for ipv4 functions) - */ - return (void *)nss_ctx; -} -EXPORT_SYMBOL(nss_register_lag_if); - -/** - * nss_unregister_lag_if() - */ -void nss_unregister_lag_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_lag_get_context(); - - nss_assert(nss_ctx); - nss_lag_verify_ifnum(if_num); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - nss_top_main.lag_event_callback = NULL; -} -EXPORT_SYMBOL(nss_unregister_lag_if); - -/** - * nss_lag_handler() - */ -void nss_lag_handler(struct nss_ctx_instance *nss_ctx, - struct nss_cmn_msg *ncm, - void *app_data) -{ - struct nss_lag_msg *lm = (struct nss_lag_msg *)ncm; - void *ctx = NULL; - nss_lag_event_callback_t cb; - - BUG_ON(ncm->interface != NSS_LAG0_INTERFACE_NUM - && ncm->interface != NSS_LAG1_INTERFACE_NUM - && ncm->interface != NSS_LAG2_INTERFACE_NUM - && ncm->interface != NSS_LAG3_INTERFACE_NUM); - - /* - * Trace Messages - */ - nss_lag_log_rx_msg(lm); - - if (ncm->type >= NSS_TX_METADATA_LAG_MAX) { - 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("%px: invalid length for LAG message: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /** - * Update the callback and app_data for NOTIFY messages. - * LAG sends all notify messages to the same callback. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->lag_event_callback; - } - - /** - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /** - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /** - * callback - */ - cb = (nss_lag_event_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - cb(ctx, lm); -} - -/** - * nss_lag_register_handler() - */ -void nss_lag_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_lag_get_context(); - - nss_core_register_handler(nss_ctx, NSS_LAG0_INTERFACE_NUM, nss_lag_handler, NULL); - nss_core_register_handler(nss_ctx, NSS_LAG1_INTERFACE_NUM, nss_lag_handler, NULL); - nss_core_register_handler(nss_ctx, NSS_LAG2_INTERFACE_NUM, nss_lag_handler, NULL); - nss_core_register_handler(nss_ctx, NSS_LAG3_INTERFACE_NUM, nss_lag_handler, NULL); -} - -/** - * nss_lag_msg_init() - * Initialize lag message - */ -void nss_lag_msg_init(struct nss_lag_msg *nlm, uint16_t lag_num, uint32_t type, uint32_t len, - nss_lag_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&nlm->cm, lag_num, type, len, (void *)cb, app_data); -} -EXPORT_SYMBOL(nss_lag_msg_init); - -/** - * nss_lag_tx_slave_state() - */ -nss_tx_status_t nss_lag_tx_slave_state(uint16_t lagid, int32_t slave_ifnum, - enum nss_lag_state_change_ev slave_state) -{ - struct nss_lag_msg nm; - struct nss_lag_state_change *nlsc = NULL; - nss_tx_status_t status; - int ret; - struct nss_ctx_instance *nss_ctx = nss_lag_get_context(); - struct nss_lag_pvt lag_msg_state; - - init_completion(&lag_msg_state.complete); - lag_msg_state.response = false; - - /* - * Construct a message to the NSS to update it - */ - nss_lag_msg_init(&nm, lagid, - NSS_TX_METADATA_LAG_STATE_CHANGE, - sizeof(struct nss_lag_state_change), - nss_lag_state_callback, &lag_msg_state); - - nlsc = &nm.msg.state; - nlsc->event = slave_state; - nlsc->interface = slave_ifnum; - - status = nss_lag_tx(nss_ctx, &nm); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: Send LAG update failed, status: %d\n", nss_ctx, - status); - return NSS_TX_FAILURE; - } - - /* - * Blocking call, wait till we get ACK for this msg. - */ - ret = wait_for_completion_timeout(&lag_msg_state.complete, - msecs_to_jiffies(NSS_LAG_RESP_TIMEOUT)); - if (!ret) { - nss_warning("%px: Waiting for ack timed out\n", nss_ctx); - return NSS_TX_FAILURE; - } - - return lag_msg_state.response; -} -EXPORT_SYMBOL(nss_lag_tx_slave_state); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_lag_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_lag_log.c deleted file mode 100644 index da83df0c6..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_lag_log.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_lag_log.c - * NSS LAG logger file. - */ - -#include "nss_core.h" - -/* - * nss_lag_log_message_types_str - * NSS LAG message strings - */ -static int8_t *nss_lag_log_message_types_str[NSS_TX_METADATA_LAG_MAX] __maybe_unused = { - "LAG State Change", -}; - -/* - * nss_lag_log_state_change_msg() - * Log NSS LAG State Change. - */ -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("%px: NSS LAG State Change message \n" - "LAG ID: %x\n" - "LAG Interface: %x\n" - "LAG Event: %d\n", - nlcm, nlcm->lagid, - nlcm->interface, nlcm->event); -} - -/* - * nss_lag_log_verbose() - * Log message contents. - */ -static void nss_lag_log_verbose(struct nss_lag_msg *nlm) -{ - switch (nlm->cm.type) { - case NSS_TX_METADATA_LAG_STATE_CHANGE: - nss_lag_log_state_change_msg(nlm); - break; - - default: - nss_trace("%px: Invalid message type\n", nlm); - break; - } -} - -/* - * nss_lag_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_lag_log_tx_msg(struct nss_lag_msg *nlm) -{ - if (nlm->cm.type >= NSS_TX_METADATA_LAG_MAX) { - nss_warning("%px: Invalid message type\n", nlm); - return; - } - - 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); -} - -/* - * nss_lag_log_rx_msg() - * Log messages received from FW. - */ -void nss_lag_log_rx_msg(struct nss_lag_msg *nlm) -{ - if (nlm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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]); - -verbose: - nss_lag_log_verbose(nlm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_lag_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_lag_log.h deleted file mode 100644 index 4efe393fc..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_lag_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_LAG_LOG_H -#define __NSS_LAG_LOG_H - -/* - * nss_lag.h - * NSS LAG header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_lag_log_tx_msg - * Logs a lag message that is sent to the NSS firmware. - */ -void nss_lag_log_tx_msg(struct nss_lag_msg *nlm); - -/* - * nss_lag_log_rx_msg - * Logs a lag message that is received from the NSS firmware. - */ -void nss_lag_log_rx_msg(struct nss_lag_msg *nlm); - -#endif /* __NSS_LAG_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_log.c deleted file mode 100644 index bfdca6575..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_log.c +++ /dev/null @@ -1,602 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_log.c - * NSS FW debug logger retrieval from DDR (memory) - * - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "nss_core.h" -#include "nss_log.h" - -/* - * Private data for each device file open instance - */ -struct nss_log_data { - void *load_mem; /* Pointer to struct nss_log_descriptor - descriptor data */ - dma_addr_t dma_addr; /* Handle to DMA */ - uint32_t last_entry; /* Last known sampled entry (or index) */ - uint32_t nentries; /* Caches the total number of entries of log buffer */ - int nss_id; /* NSS Core id being used */ - struct nss_ctx_instance *nss_ctx; - /* NSS ctx instance */ -}; - -struct nss_log_ring_buffer_addr nss_rbe[NSS_MAX_CORES]; - -static DEFINE_MUTEX(nss_log_mutex); -static wait_queue_head_t nss_log_wq; -static nss_log_msg_callback_t nss_debug_interface_cb; -static void *nss_debug_interface_app_data = NULL; - -static wait_queue_head_t msg_wq; -enum nss_cmn_response msg_response; -static bool msg_event; - -/* - * nss_log_llseek() - * Seek operation. - */ -static loff_t nss_log_llseek(struct file *file, loff_t offset, int origin) -{ - struct nss_log_data *data = file->private_data; - - switch (origin) { - case SEEK_SET: - break; - case SEEK_CUR: - offset += file->f_pos; - break; - case SEEK_END: - offset = ((data->nentries * sizeof(struct nss_log_entry)) + sizeof(struct nss_log_descriptor)) - offset; - break; - default: - return -EINVAL; - } - - return (offset >= 0) ? (file->f_pos = offset) : -EINVAL; -} - -/* - * nss_log_open() - * Open operation for our device. We let as many instance run together - */ -static int nss_log_open(struct inode *inode, struct file *filp) -{ - struct nss_log_data *data = NULL; - struct nss_top_instance *nss_top; - struct nss_ctx_instance *nss_ctx; - int nss_id; - - /* - * i_private is passed to us by debug_fs_create() - */ - nss_id = (int)(nss_ptr_t)inode->i_private; - if (nss_id < 0 || nss_id >= nss_top_main.num_nss) { - nss_warning("nss_id is not valid :%d\n", nss_id); - return -ENODEV; - } - - nss_top = &nss_top_main; - nss_ctx = &nss_top->nss[nss_id]; - - data = kzalloc(sizeof(struct nss_log_data), GFP_KERNEL); - if (!data) { - nss_warning("%px: Failed to allocate memory for log_data", nss_ctx); - return -ENOMEM; - } - - mutex_lock(&nss_log_mutex); - if (!nss_rbe[nss_id].addr) { - mutex_unlock(&nss_log_mutex); - kfree(data); - nss_warning("%px: Ring buffer not configured yet for nss_id:%d", nss_ctx, nss_id); - return -EIO; - } - - /* - * Actual ring buffer. - */ - data->load_mem = nss_rbe[nss_id].addr; - data->last_entry = 0; - data->nentries = nss_rbe[nss_id].nentries; - data->dma_addr = nss_rbe[nss_id].dma_addr; - data->nss_ctx = nss_ctx; - - /* - * Increment the reference count so that we don't free - * the memory - */ - nss_rbe[nss_id].ref_cnt++; - data->nss_id = nss_id; - filp->private_data = data; - mutex_unlock(&nss_log_mutex); - - return 0; -} - -/* - * nss_log_release() - * release gets called when close() is called on the file - * descriptor. We unmap the IO region. - */ -static int nss_log_release(struct inode *inode, struct file *filp) -{ - struct nss_log_data *data = filp->private_data; - - if (!data) { - return -EINVAL; - } - - mutex_lock(&nss_log_mutex); - nss_rbe[data->nss_id].ref_cnt--; - BUG_ON(nss_rbe[data->nss_id].ref_cnt < 0); - if (!nss_rbe[data->nss_id].ref_cnt) { - wake_up(&nss_log_wq); - } - mutex_unlock(&nss_log_mutex); - kfree(data); - return 0; -} - -/* - * nss_log_current_entry() - * Reads current entry index from NSS log descriptor. - */ -static uint32_t nss_log_current_entry(struct nss_log_descriptor *desc) -{ - rmb(); - return desc->current_entry; -} - -/* - * nss_log_read() - * Read operation lets command like cat and tail read our memory log buffer data. - */ -static ssize_t nss_log_read(struct file *filp, char __user *buf, size_t size, loff_t *ppos) -{ - struct nss_log_data *data = filp->private_data; - struct nss_log_descriptor *desc; - size_t bytes = 0; - size_t b; - struct nss_log_entry *rb; - uint32_t entry; - uint32_t offset, index; - char msg[NSS_LOG_OUTPUT_LINE_SIZE]; - - if (!data) { - return -EINVAL; - } - - desc = data->load_mem; - if (!desc) { - nss_warning("%px: load_mem is NULL", data); - return -EINVAL; - } - - /* - * If buffer is too small to fit even one entry. - */ - if (size < NSS_LOG_OUTPUT_LINE_SIZE) { - return 0; - } - - /* - * Get the current index - */ - dma_sync_single_for_cpu(data->nss_ctx->dev, data->dma_addr, sizeof(struct nss_log_descriptor), DMA_FROM_DEVICE); - - entry = nss_log_current_entry(desc); - - /* - * If the current and last sampled indexes are same then bail out. - */ - if (unlikely(data->last_entry == entry)) { - return 0; - } - - /* - * If this is the first read (after open) on our device file. - */ - if (unlikely(!(*ppos))) { - /* - * If log buffer has rolled over. Almost all the time - * it will be true. - */ - if (likely(entry > data->nentries)) { - /* - * Determine how much we can stuff in one - * buffer passed to us and accordingly - * reduce our index. - */ - data->last_entry = entry - data->nentries; - } else { - data->last_entry = 0; - } - } else if (unlikely(entry > data->nentries && ((entry - data->nentries) > data->last_entry))) { - /* - * If FW is producing debug buffer at a pace faster than - * we can consume, then we restrict our iteration. - */ - data->last_entry = entry - data->nentries; - } - - /* - * Iterate over indexes. - */ - while (entry > data->last_entry) { - index = offset = (data->last_entry % data->nentries); - offset = (offset * sizeof(struct nss_log_entry)) - + offsetof(struct nss_log_descriptor, log_ring_buffer); - - dma_sync_single_for_cpu(data->nss_ctx->dev, data->dma_addr + offset, - sizeof(struct nss_log_entry), DMA_FROM_DEVICE); - rb = &desc->log_ring_buffer[index]; - - b = scnprintf(msg, sizeof(msg), NSS_LOG_LINE_FORMAT, - rb->thread_num, rb->timestamp, rb->message); - - data->last_entry++; - - /* - * Copy to user buffer and if we fail then we return - * failure. - */ - if (copy_to_user(buf + bytes, msg, b)) { - return -EFAULT; - } - - bytes += b; - - /* - * If we ran out of space in the buffer. - */ - if ((bytes + NSS_LOG_OUTPUT_LINE_SIZE) >= size) - break; - } - - if (bytes > 0) - *ppos = bytes; - - return bytes; -} - -struct file_operations nss_logs_core_ops = { - .owner = THIS_MODULE, - .open = nss_log_open, - .read = nss_log_read, - .release = nss_log_release, - .llseek = nss_log_llseek, -}; - -/* - * nss_debug_interface_set_callback() - * Sets the callback - */ -void nss_debug_interface_set_callback(nss_log_msg_callback_t cb, void *app_data) -{ - nss_debug_interface_cb = cb; - nss_debug_interface_app_data = app_data; -} - -/* - * nss_debug_interface_event() - * Received an event from NSS FW - */ -static void nss_debug_interface_event(void *app_data, struct nss_log_debug_interface_msg *nim) -{ - struct nss_cmn_msg *ncm = (struct nss_cmn_msg *)nim; - - msg_response = ncm->response; - msg_event = true; - wake_up(&msg_wq); -} - -/* - * nss_debug_interface_handler() - * handle NSS -> HLOS messages for debug interfaces - */ -static void nss_debug_interface_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_log_debug_interface_msg *ntm = (struct nss_log_debug_interface_msg *)ncm; - nss_log_msg_callback_t cb; - - BUG_ON(ncm->interface != NSS_DEBUG_INTERFACE); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type > NSS_DEBUG_INTERFACE_TYPE_MAX) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Update the callback and app_data for NOTIFY messages. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_debug_interface_cb; - ncm->app_data = (nss_ptr_t)nss_debug_interface_app_data; - } - - /* - * Do we have a callback - */ - if (!ncm->cb) { - nss_trace("%px: cb is null for interface %d", nss_ctx, ncm->interface); - return; - } - - cb = (nss_log_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, ntm); -} - -/* - * nss_debug_interface_tx() - * Transmit a debug interface message to NSS FW - */ -static nss_tx_status_t nss_debug_interface_tx(struct nss_ctx_instance *nss_ctx, struct nss_log_debug_interface_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Sanity check the message - */ - if (ncm->interface != NSS_DEBUG_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("%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_debug_log_buffer_alloc() - * Allocates and Initializes log buffer for the use in NSS FW (logging) - */ -bool nss_debug_log_buffer_alloc(uint8_t nss_id, uint32_t nentry) -{ - struct nss_log_debug_interface_msg msg; - struct nss_log_debug_memory_msg *dbg; - struct nss_top_instance *nss_top; - struct nss_ctx_instance *nss_ctx; - dma_addr_t dma_addr; - uint32_t size; - void *addr = NULL; - nss_tx_status_t status; - - if (nss_id >= nss_top_main.num_nss) { - return false; - } - - nss_top = &nss_top_main; - nss_ctx = &nss_top->nss[nss_id]; - - if (nss_ctx->state != NSS_CORE_STATE_INITIALIZED) { - 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("%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("%px: Failed to map address in DMA", nss_ctx); - kfree(addr); - return false; - } - - /* - * If we already have ring buffer associated with nss_id, then - * we must wait before we attach a new ring buffer. - */ - mutex_lock(&nss_log_mutex); - if (nss_rbe[nss_id].addr) { - mutex_unlock(&nss_log_mutex); - - /* - * Someone is using the current logbuffer. Wait until ref count become 0. - * We have to return mutex here, because the current user requires it to - * release the reference. - */ - if (!wait_event_timeout(nss_log_wq, !nss_rbe[nss_id].ref_cnt, 5 * HZ)) { - nss_warning("%px: Timeout waiting for refcnt to become 0\n", nss_ctx); - goto fail; - } - - mutex_lock(&nss_log_mutex); - if (!nss_rbe[nss_id].addr) { - mutex_unlock(&nss_log_mutex); - goto fail; - } - if (nss_rbe[nss_id].ref_cnt > 0) { - mutex_unlock(&nss_log_mutex); - nss_warning("%px: Some other thread is contending..opting out\n", nss_ctx); - goto fail; - } - } - - memset(&msg, 0, sizeof(struct nss_log_debug_interface_msg)); - nss_cmn_msg_init(&msg.cm, NSS_DEBUG_INTERFACE, NSS_DEBUG_INTERFACE_TYPE_LOG_BUF_INIT, - sizeof(struct nss_log_debug_memory_msg), nss_debug_interface_event, NULL); - - dbg = &msg.msg.addr; - dbg->nentry = nentry; - dbg->version = NSS_DEBUG_LOG_VERSION; - dbg->phy_addr = dma_addr; - - msg_event = false; - status = nss_debug_interface_tx(nss_ctx, &msg); - if (status != NSS_TX_SUCCESS) { - mutex_unlock(&nss_log_mutex); - nss_warning("%px: Failed to send message to debug interface:%d\n", nss_ctx, status); - goto fail; - } - - /* - * Wait for 5 seconds since this is a critical operation. - * Mutex is not unlocked here because we do not want someone to acquire the mutex and use the logbuffer - * while we are waiting message from NSS. - */ - if (!wait_event_timeout(msg_wq, msg_event, 5 * HZ)) { - mutex_unlock(&nss_log_mutex); - 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("%px: Response error for send message to debug interface:%d\n", nss_ctx, msg_response); - goto fail; - } - - /* - * If we had to free the previous allocation for ring buffer. - */ - if (nss_rbe[nss_id].addr) { - uint32_t old_size; - old_size = sizeof(struct nss_log_descriptor) + - (sizeof(struct nss_log_entry) * nss_rbe[nss_id].nentries); - dma_unmap_single(nss_ctx->dev, nss_rbe[nss_id].dma_addr, old_size, DMA_FROM_DEVICE); - kfree(nss_rbe[nss_id].addr); - } - - nss_rbe[nss_id].addr = addr; - nss_rbe[nss_id].nentries = nentry; - nss_rbe[nss_id].ref_cnt = 0; - nss_rbe[nss_id].dma_addr = dma_addr; - mutex_unlock(&nss_log_mutex); - wake_up(&nss_log_wq); - return true; - -fail: - dma_unmap_single(nss_ctx->dev, dma_addr, size, DMA_FROM_DEVICE); - kfree(addr); - wake_up(&nss_log_wq); - return false; -} - -/* - * nss_logbuffer_handler() - * Enable NSS debug output - */ -int nss_logbuffer_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - int ret; - int core_status; - int i; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret) { - return ret; - } - - if (!write) { - return ret; - } - - if (nss_ctl_logbuf < 32) { - nss_warning("Invalid NSS FW logbuffer size:%d (must be > 32)\n", nss_ctl_logbuf); - nss_ctl_logbuf = 0; - return ret; - } - - for (i = 0; i < nss_top_main.num_nss; i++) { - /* - * Register the callback handler and allocate the debug log buffers - */ - core_status = nss_core_register_handler(&nss_top_main.nss[i], NSS_DEBUG_INTERFACE, nss_debug_interface_handler, NULL); - if (core_status != NSS_CORE_STATUS_SUCCESS) { - nss_warning("NSS logbuffer init failed with register handler:%d\n", core_status); - } - - if (!nss_debug_log_buffer_alloc(i, nss_ctl_logbuf)) { - nss_warning("%d: Failed to set debug log buffer on NSS core", i); - } - } - - return ret; -} - -/* - * nss_log_init() - * Initializes NSS FW logs retrieval logic from /sys - */ -void nss_log_init(void) -{ - int i; - struct dentry *logs_dentry; - struct dentry *core_log_dentry; - - memset(nss_rbe, 0, sizeof(nss_rbe)); - init_waitqueue_head(&nss_log_wq); - init_waitqueue_head(&msg_wq); - - /* - * Create directory for obtaining NSS FW logs from each core - */ - logs_dentry = debugfs_create_dir("logs", nss_top_main.top_dentry); - if (unlikely(!logs_dentry)) { - nss_warning("Failed to create qca-nss-drv/logs directory in debugfs"); - return; - } - - for (i = 0; i < nss_top_main.num_nss; i++) { - char file[16]; - extern struct file_operations nss_logs_core_ops; - - snprintf(file, sizeof(file), "core%d", i); - core_log_dentry = debugfs_create_file(file, 0400, - logs_dentry, (void *)(nss_ptr_t)i, &nss_logs_core_ops); - if (unlikely(!core_log_dentry)) { - nss_warning("Failed to create qca-nss-drv/logs/%s file in debugfs", file); - return; - } - } - - nss_debug_interface_set_callback(nss_debug_interface_event, NULL); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_log.h deleted file mode 100644 index 1d27e9498..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_log.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2014-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. - * 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_log.h - * NSS FW debug log memory header file - */ - -#ifndef __NSS_LOG_H -#define __NSS_LOG_H - -#define NSS_DEBUG_LOG_VERSION 0x1 - -/** - * Dynamic Interface types - */ -enum nss_debug_interface_msg_type { - NSS_DEBUG_INTERFACE_TYPE_NONE = 0, - NSS_DEBUG_INTERFACE_TYPE_LOG_BUF_INIT = 1, - NSS_DEBUG_INTERFACE_TYPE_MAX, -}; - -/* - * The size of each log entry to be displayed. - */ -#define NSS_LOG_OUTPUT_LINE_SIZE 151 /* 5 + 12 + 132 + '\n' + '\0' (see below) */ -#define NSS_LOG_LINE_FORMAT "%3d: %010u: %s\n" -#define NSS_LOG_LINE_WIDTH 132 -#define NSS_LOG_COOKIE 0xFF785634 - -/* - * Dump last N entry during the coredump. - * This number should be lower than the minimum size of the logbuf - * which 32 right now. - */ -#define NSS_LOG_COREDUMP_LINE_NUM 25 - -/* - * Saves the ring buffer address for logging per NSS core - */ -struct nss_log_ring_buffer_addr { - void *addr; /* Pointer to struct nss_log_descriptor */ - dma_addr_t dma_addr; /* DMA Handle */ - uint32_t nentries; /* Number of entries in the ring buffer */ - int ref_cnt; /* Reference count */ -}; - -/* - * nss_log_entry is shared between Host and NSS FW - */ -struct nss_log_entry { - uint64_t sequence_num; /* Sequence number */ - uint32_t cookie; /* Magic for verification */ - uint32_t thread_num; /* thread-id */ - uint32_t timestamp; /* timestamp in ticks */ - char message[NSS_LOG_LINE_WIDTH]; /* actual debug message */ -} __attribute__((aligned(NSS_CACHE_LINE_SIZE))); - -/* - * The NSS log descripts holds ring-buffer along with other variables and - * it is shared between NSS FW and Host. - * - * NSS FW writes to ring buffer and current_entry but read by only Host. - */ -struct nss_log_descriptor { - uint32_t cookie; /* Magic for verification */ - uint32_t log_nentries; /* No.of log entries */ - uint32_t current_entry; /* pointer to current log entry */ - uint8_t pad[20]; /* pad to align ring buffer at cacheline boundary */ - struct nss_log_entry log_ring_buffer[0]; /* The actual log entry ring buffer */ -} __attribute__((aligned(NSS_CACHE_LINE_SIZE))); - -struct nss_log_debug_memory_msg { - uint32_t version; - uint32_t nentry; - uint32_t phy_addr; -}; - -struct nss_log_debug_interface_msg { - struct nss_cmn_msg cm; - union { - struct nss_log_debug_memory_msg addr; - } msg; -}; - -/** - * @brief Callback to receive debug interface messages - * - * @param app_data Application context of the message - * @param msg Message data - * - * @return void - */ -typedef void (*nss_log_msg_callback_t)(void *app_data, struct nss_log_debug_interface_msg *msg); - -/* - * Exported by nss_init.c and used in nss_log.c - */ -extern int nss_ctl_logbuf; - -extern struct nss_log_ring_buffer_addr nss_rbe[NSS_MAX_CORES]; - -#endif /* __NSS_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx.c b/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx.c deleted file mode 100644 index 3abda0101..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_lso_rx.c - * NSS LSO_RX APIs - */ - -#include -#include "nss_lso_rx_stats.h" -#include "nss_lso_rx_strings.h" - -/* - * nss_rx_lso_rx_interface_handler() - * Handle NSS -> HLOS messages for LSO_RX Changes and Statistics - */ -static void nss_rx_lso_rx_interface_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) { - - struct nss_lso_rx_msg *nlrm = (struct nss_lso_rx_msg *)ncm; - - switch (nlrm->cm.type) { - case NSS_LSO_RX_STATS_SYNC_MSG: - /* - * Update LSO_RX driver statistics and send statistics notifications to the registered modules - */ - nss_lso_rx_stats_sync(nss_ctx, &nlrm->msg.stats_sync); - nss_lso_rx_stats_notify(nss_ctx); - 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); - } - } -} - -/* - * nss_lso_rx_register_handler() - * Register handler for messaging - */ -void nss_lso_rx_register_handler(struct nss_ctx_instance *nss_ctx) -{ - nss_core_register_handler(nss_ctx, NSS_LSO_RX_INTERFACE, nss_rx_lso_rx_interface_handler, NULL); - nss_lso_rx_stats_dentry_create(); - nss_lso_rx_strings_dentry_create(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx_stats.c deleted file mode 100644 index 2763a2a8c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx_stats.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_lso_rx_stats.h" -#include "nss_lso_rx_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_lso_rx_stats_notifier); - -uint64_t nss_lso_rx_stats[NSS_LSO_RX_STATS_MAX]; /* LSO_RX statistics */ - -/* - * nss_lso_rx_stats_read() - * Read LSO_RX stats - */ -static ssize_t nss_lso_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_LSO_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_LSO_RX_STATS_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, "lso_rx", NSS_STATS_SINGLE_CORE); - size_wr += nss_stats_fill_common_stats(NSS_LSO_RX_INTERFACE, NSS_STATS_SINGLE_INSTANCE, lbuf, size_wr, size_al, "lso_rx"); - - /* - * lso_rx node stats - */ - - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; (i < NSS_LSO_RX_STATS_MAX); i++) { - stats_shadow[i] = nss_lso_rx_stats[i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("lso_rx", "lso_rx node stats" - , NSS_STATS_SINGLE_INSTANCE - , nss_lso_rx_strings_stats - , stats_shadow - , NSS_LSO_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_lso_rx_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(lso_rx); - -/* - * nss_lso_rx_stats_dentry_create() - * Create lso_rx statistics debug entry. - */ -void nss_lso_rx_stats_dentry_create(void) -{ - nss_stats_create_dentry("lso_rx", &nss_lso_rx_stats_ops); -} - -/* - * nss_lso_rx_stats_sync() - * Handle the syncing of lso_rx node statistics. - */ -void nss_lso_rx_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_lso_rx_stats_sync *nlrss) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - int j; - - spin_lock_bh(&nss_top->stats_lock); - - /* - * common node stats - */ - nss_top->stats_node[NSS_LSO_RX_INTERFACE][NSS_STATS_NODE_RX_PKTS] += nlrss->node_stats.rx_packets; - nss_top->stats_node[NSS_LSO_RX_INTERFACE][NSS_STATS_NODE_RX_BYTES] += nlrss->node_stats.rx_bytes; - nss_top->stats_node[NSS_LSO_RX_INTERFACE][NSS_STATS_NODE_TX_PKTS] += nlrss->node_stats.tx_packets; - nss_top->stats_node[NSS_LSO_RX_INTERFACE][NSS_STATS_NODE_TX_BYTES] += nlrss->node_stats.tx_bytes; - - for (j = 0; j < NSS_MAX_NUM_PRI; j++) { - nss_top->stats_node[NSS_LSO_RX_INTERFACE][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + j] += nlrss->node_stats.rx_dropped[j]; - } - - /* - * General LSO_RX stats - */ - nss_lso_rx_stats[NSS_LSO_RX_STATS_TX_DROPPED] += nlrss->tx_dropped; - nss_lso_rx_stats[NSS_LSO_RX_STATS_DROPPED] += nlrss->dropped; - - /* - * pbuf - */ - nss_lso_rx_stats[NSS_LSO_RX_STATS_PBUF_ALLOC_FAIL] += nlrss->pbuf_alloc_fail; - nss_lso_rx_stats[NSS_LSO_RX_STATS_PBUF_REFERENCE_FAIL] += nlrss->pbuf_reference_fail; - - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_lso_rx_stats_notify() - * Sends notifications to all the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_lso_rx_stats_notify(struct nss_ctx_instance *nss_ctx) -{ - struct nss_lso_rx_stats_notification lso_rx_stats; - - lso_rx_stats.core_id = nss_ctx->id; - memcpy(lso_rx_stats.cmn_node_stats, nss_top_main.stats_node[NSS_LSO_RX_INTERFACE], sizeof(lso_rx_stats.cmn_node_stats)); - memcpy(lso_rx_stats.node_stats, nss_lso_rx_stats, sizeof(lso_rx_stats.node_stats)); - atomic_notifier_call_chain(&nss_lso_rx_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&lso_rx_stats); -} - -/* - * nss_lso_rx_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_lso_rx_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_lso_rx_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_lso_rx_stats_register_notifier); - -/* - * nss_lso_rx_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_lso_rx_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_lso_rx_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_lso_rx_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx_stats.h deleted file mode 100644 index 54ab6dc51..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx_stats.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_LSO_RX_STATS_H -#define __NSS_LSO_RX_STATS_H - -#include - -/* - * lso_rx_node statistics. - */ -struct nss_lso_rx_stats_sync { - struct nss_cmn_node_stats node_stats; - - uint32_t tx_dropped; /* Number of packets dropped because lso_rx transmit queue is full */ - uint32_t dropped; /* Total of packets dropped by the node internally */ - uint32_t pbuf_alloc_fail; /* Count number of pbuf alloc fails */ - uint32_t pbuf_reference_fail; /* Count number of pbuf ref fails */ - - /* - * If we're generating per-packet statistics then we count total lso_rx processing ticks - * worst-case ticks and the number of iterations around the lso_rx handler that we take. - */ - uint32_t total_ticks; /* Total clock ticks spend inside the lso_rx handler */ - uint32_t worst_case_ticks; - /* Worst case iteration of the lso_rx handler in ticks */ - uint32_t iterations; /* Number of iterations around the lso_rx handler */ -}; - -/* - * Message types for lso_rx - */ -enum nss_lso_rx_metadata_types { - NSS_LSO_RX_STATS_SYNC_MSG, /* Message type - stats sync message */ -}; - -/* - * Message structure to send receive LSO_RX commands - */ -struct nss_lso_rx_msg { - struct nss_cmn_msg cm; /* Message header */ - union { - struct nss_lso_rx_stats_sync stats_sync; /* Stats sub-message */ - } msg; -}; - -/* - * lso_rx statistics APIs - */ -extern void nss_lso_rx_stats_notify(struct nss_ctx_instance *nss_ctx); -extern void nss_lso_rx_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_lso_rx_stats_sync *nlrss); -extern void nss_lso_rx_stats_dentry_create(void); - -#endif /* __NSS_LSO_RX_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx_strings.c deleted file mode 100644 index 627f1de08..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx_strings.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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" -#include "nss_lso_rx_strings.h" - -/* - * nss_lso_rx_strings_stats - * LSO Rx statistics strings. - */ -struct nss_stats_info nss_lso_rx_strings_stats[NSS_LSO_RX_STATS_MAX] = { - {"tx_drops" ,NSS_STATS_TYPE_DROP}, - {"drops" ,NSS_STATS_TYPE_DROP}, - {"pbuf_alloc_fail" ,NSS_STATS_TYPE_ERROR}, - {"pbuf_reference_fail" ,NSS_STATS_TYPE_ERROR} -}; - -/* - * nss_lso_rx_strings_read() - * Read LSO Rx node statistics names. - */ -static ssize_t nss_lso_rx_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_lso_rx_strings_stats, NSS_LSO_RX_STATS_MAX); -} - -/* - * nss_lso_rx_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(lso_rx); - -/* - * nss_lso_rx_strings_dentry_create() - * Create LSO Rx statistics strings debug entry. - */ -void nss_lso_rx_strings_dentry_create(void) -{ - nss_strings_create_dentry("lso_rx", &nss_lso_rx_strings_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx_strings.h deleted file mode 100644 index 901ed3073..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_lso_rx_strings.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_LSO_RX_STRINGS_H -#define __NSS_LSO_RX_STRINGS_H - -extern struct nss_stats_info nss_lso_rx_strings_stats[NSS_LSO_RX_STATS_MAX]; -extern void nss_lso_rx_strings_dentry_create(void); - -#endif /* __NSS_LSO_RX_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_map_t.c b/feeds/ipq807x/qca-nss-drv/src/nss_map_t.c deleted file mode 100644 index cfa7ab967..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_map_t.c +++ /dev/null @@ -1,412 +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_tx_rx_common.h" -#include "nss_map_t_stats.h" -#include "nss_map_t_log.h" -#include "nss_map_t_strings.h" - -#define NSS_MAP_T_TX_TIMEOUT 3000 /* 3 Seconds */ - -/* - * Private data structure - */ -static struct { - struct semaphore sem; - struct completion complete; - int response; - void *cb; - void *app_data; -} nss_map_t_pvt; - -/* - * Data structures to store map_t nss debug stats - */ -static DEFINE_SPINLOCK(nss_map_t_debug_stats_lock); -static struct nss_map_t_stats_instance_debug nss_map_t_debug_stats[NSS_MAX_MAP_T_DYNAMIC_INTERFACES]; - -/* - * nss_map_t_verify_if_num() - * Verify if_num passed to us. - */ -static bool nss_map_t_verify_if_num(uint32_t if_num) -{ - enum nss_dynamic_interface_type if_type; - - if (nss_is_dynamic_interface(if_num) == false) { - return false; - } - - if_type = nss_dynamic_interface_get_type(nss_map_t_get_context(), if_num); - switch (if_type) { - case NSS_DYNAMIC_INTERFACE_TYPE_MAP_T_INNER: - case NSS_DYNAMIC_INTERFACE_TYPE_MAP_T_OUTER: - return true; - - default: - return false; - } -} - -/* - * nss_map_t_instance_debug_stats_sync - * debug stats for map_t - */ -void nss_map_t_instance_debug_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_map_t_sync_stats_msg *stats_msg, uint16_t if_num) -{ - int i; - enum nss_dynamic_interface_type if_type; - - if_type = nss_dynamic_interface_get_type(nss_ctx, if_num); - - spin_lock_bh(&nss_map_t_debug_stats_lock); - for (i = 0; i < NSS_MAX_MAP_T_DYNAMIC_INTERFACES; i++) { - if (nss_map_t_debug_stats[i].if_num != if_num) { - continue; - } - switch (if_type) { - case NSS_DYNAMIC_INTERFACE_TYPE_MAP_T_INNER: - nss_map_t_debug_stats[i].stats[NSS_MAP_T_STATS_V4_TO_V6_PBUF_EXCEPTION] += - stats_msg->debug_stats.v4_to_v6.exception_pkts; - nss_map_t_debug_stats[i].stats[NSS_MAP_T_STATS_V4_TO_V6_PBUF_NO_MATCHING_RULE] += - stats_msg->debug_stats.v4_to_v6.no_matching_rule; - nss_map_t_debug_stats[i].stats[NSS_MAP_T_STATS_V4_TO_V6_PBUF_NOT_TCP_OR_UDP] += - stats_msg->debug_stats.v4_to_v6.not_tcp_or_udp; - nss_map_t_debug_stats[i].stats[NSS_MAP_T_STATS_V4_TO_V6_RULE_ERR_LOCAL_PSID] += - stats_msg->debug_stats.v4_to_v6.rule_err_local_psid; - nss_map_t_debug_stats[i].stats[NSS_MAP_T_STATS_V4_TO_V6_RULE_ERR_LOCAL_IPV6] += - stats_msg->debug_stats.v4_to_v6.rule_err_local_ipv6; - nss_map_t_debug_stats[i].stats[NSS_MAP_T_STATS_V4_TO_V6_RULE_ERR_REMOTE_PSID] += - stats_msg->debug_stats.v4_to_v6.rule_err_remote_psid; - nss_map_t_debug_stats[i].stats[NSS_MAP_T_STATS_V4_TO_V6_RULE_ERR_REMOTE_EA_BITS] += - stats_msg->debug_stats.v4_to_v6.rule_err_remote_ea_bits; - nss_map_t_debug_stats[i].stats[NSS_MAP_T_STATS_V4_TO_V6_RULE_ERR_REMOTE_IPV6] += - stats_msg->debug_stats.v4_to_v6.rule_err_remote_ipv6; - break; - - case NSS_DYNAMIC_INTERFACE_TYPE_MAP_T_OUTER: - nss_map_t_debug_stats[i].stats[NSS_MAP_T_STATS_V6_TO_V4_PBUF_EXCEPTION] += - stats_msg->debug_stats.v6_to_v4.exception_pkts; - nss_map_t_debug_stats[i].stats[NSS_MAP_T_STATS_V6_TO_V4_PBUF_NO_MATCHING_RULE] += - stats_msg->debug_stats.v6_to_v4.no_matching_rule; - nss_map_t_debug_stats[i].stats[NSS_MAP_T_STATS_V6_TO_V4_PBUF_NOT_TCP_OR_UDP] += - stats_msg->debug_stats.v6_to_v4.not_tcp_or_udp; - nss_map_t_debug_stats[i].stats[NSS_MAP_T_STATS_V6_TO_V4_RULE_ERR_LOCAL_IPV4] += - stats_msg->debug_stats.v6_to_v4.rule_err_local_ipv4; - nss_map_t_debug_stats[i].stats[NSS_MAP_T_STATS_V6_TO_V4_RULE_ERR_REMOTE_IPV4] += - stats_msg->debug_stats.v6_to_v4.rule_err_remote_ipv4; - break; - - default: - nss_warning("Invalid MAP-T interface encountered: %u\n", if_type); - break; - } - } - spin_unlock_bh(&nss_map_t_debug_stats_lock); -} - -/* - * nss_map_t_instance_debug_stats_get() - * Get map_t statitics. - */ -void nss_map_t_instance_debug_stats_get(void *stats_mem) -{ - struct nss_map_t_stats_instance_debug *stats = (struct nss_map_t_stats_instance_debug *)stats_mem; - int i; - - if (!stats) { - nss_warning("No memory to copy map_t stats"); - return; - } - - spin_lock_bh(&nss_map_t_debug_stats_lock); - for (i = 0; i < NSS_MAX_MAP_T_DYNAMIC_INTERFACES; i++) { - if (nss_map_t_debug_stats[i].valid) { - memcpy(stats, &nss_map_t_debug_stats[i], sizeof(struct nss_map_t_stats_instance_debug)); - stats++; - } - } - spin_unlock_bh(&nss_map_t_debug_stats_lock); -} - -/* - * nss_map_t_handler() - * Handle NSS -> HLOS messages for map_t tunnel - */ -static void nss_map_t_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_map_t_msg *ntm = (struct nss_map_t_msg *)ncm; - void *ctx; - - nss_map_t_msg_callback_t cb; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - BUG_ON(!nss_map_t_verify_if_num(ncm->interface)); - - /* - * Trace Messages - */ - nss_map_t_log_rx_msg(ntm); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_MAP_T_MSG_MAX) { - 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("%px: tx request for another interface: %d", nss_ctx, ncm->interface); - return; - } - - switch (ntm->cm.type) { - case NSS_MAP_T_MSG_SYNC_STATS: - /* - * Update debug stats in stats msg and send statistics notifications to the registered modules - */ - nss_map_t_instance_debug_stats_sync(nss_ctx, &ntm->msg.stats, ncm->interface); - nss_map_t_stats_notify(nss_ctx, ncm->interface); - break; - } - - /* - * Update the callback and app_data for NOTIFY messages, map_t sends all notify messages - * to the same callback/app_data. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->map_t_msg_callback; - ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].app_data; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * callback - */ - cb = (nss_map_t_msg_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - /* - * call map-t callback - */ - if (!cb) { - nss_warning("%px: No callback for map-t interface %d", - nss_ctx, ncm->interface); - return; - } - - cb(ctx, ntm); -} - -/* - * nss_map_t_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_map_t_callback(void *app_data, struct nss_map_t_msg *nim) -{ - nss_map_t_msg_callback_t callback = (nss_map_t_msg_callback_t)nss_map_t_pvt.cb; - void *data = nss_map_t_pvt.app_data; - - nss_map_t_pvt.cb = NULL; - nss_map_t_pvt.app_data = NULL; - - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("map_t Error response %d\n", nim->cm.response); - nss_map_t_pvt.response = NSS_TX_FAILURE; - } else { - nss_map_t_pvt.response = NSS_TX_SUCCESS; - } - - if (callback) { - callback(data, nim); - } - - complete(&nss_map_t_pvt.complete); -} - -/* - * nss_map_t_tx() - * Transmit a map_t message to NSS firmware - */ -nss_tx_status_t nss_map_t_tx(struct nss_ctx_instance *nss_ctx, struct nss_map_t_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace Messages - */ - nss_map_t_log_tx_msg(msg); - - /* - * Sanity check the message - */ - if (!nss_map_t_verify_if_num(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("%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); -} -EXPORT_SYMBOL(nss_map_t_tx); - -/* - * nss_map_t_tx_sync() - * Transmit a MAP-T message to NSS firmware synchronously. - */ -nss_tx_status_t nss_map_t_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_map_t_msg *msg) -{ - nss_tx_status_t status; - int ret = 0; - - down(&nss_map_t_pvt.sem); - nss_map_t_pvt.cb = (void *)msg->cm.cb; - nss_map_t_pvt.app_data = (void *)msg->cm.app_data; - - msg->cm.cb = (nss_ptr_t)nss_map_t_callback; - msg->cm.app_data = (nss_ptr_t)NULL; - - status = nss_map_t_tx(nss_ctx, msg); - if (status != NSS_TX_SUCCESS) { - 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("%px: MAP-T tx sync failed due to timeout\n", nss_ctx); - nss_map_t_pvt.response = NSS_TX_FAILURE; - } - - status = nss_map_t_pvt.response; - up(&nss_map_t_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_map_t_tx_sync); - -/* - *********************************** - * Register/Unregister/Miscellaneous APIs - *********************************** - */ - -/* - * nss_map_t_register_if() - */ -struct nss_ctx_instance *nss_map_t_register_if(uint32_t if_num, uint32_t type, nss_map_t_callback_t map_t_callback, - nss_map_t_msg_callback_t event_callback, struct net_device *netdev, uint32_t features) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.map_t_handler_id]; - int i = 0; - - nss_assert(nss_ctx); - nss_assert(nss_map_t_verify_if_num(if_num)); - - nss_core_register_subsys_dp(nss_ctx, if_num, map_t_callback, 0, netdev, netdev, features); - nss_ctx->subsys_dp_register[if_num].type = type; - - nss_top_main.map_t_msg_callback = event_callback; - - nss_core_register_handler(nss_ctx, if_num, nss_map_t_handler, NULL); - - spin_lock_bh(&nss_map_t_debug_stats_lock); - for (i = 0; i < NSS_MAX_MAP_T_DYNAMIC_INTERFACES; i++) { - if (!nss_map_t_debug_stats[i].valid) { - nss_map_t_debug_stats[i].valid = true; - nss_map_t_debug_stats[i].if_num = if_num; - nss_map_t_debug_stats[i].if_index = netdev->ifindex; - break; - } - } - spin_unlock_bh(&nss_map_t_debug_stats_lock); - - return nss_ctx; -} -EXPORT_SYMBOL(nss_map_t_register_if); - -/* - * nss_map_t_unregister_if() - */ -void nss_map_t_unregister_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.map_t_handler_id]; - int i; - - nss_assert(nss_ctx); - nss_assert(nss_map_t_verify_if_num(if_num)); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - nss_top_main.map_t_msg_callback = NULL; - - nss_core_unregister_handler(nss_ctx, if_num); - - spin_lock_bh(&nss_map_t_debug_stats_lock); - for (i = 0; i < NSS_MAX_MAP_T_DYNAMIC_INTERFACES; i++) { - if (nss_map_t_debug_stats[i].if_num == if_num) { - memset(&nss_map_t_debug_stats[i], 0, sizeof(struct nss_map_t_stats_instance_debug)); - break; - } - } - spin_unlock_bh(&nss_map_t_debug_stats_lock); -} -EXPORT_SYMBOL(nss_map_t_unregister_if); - -/* - * nss_get_map_t_context() - */ -struct nss_ctx_instance *nss_map_t_get_context() -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.map_t_handler_id]; -} -EXPORT_SYMBOL(nss_map_t_get_context); - -/* - * nss_map_t_msg_init() - * Initialize nss_map_t msg. - */ -void nss_map_t_msg_init(struct nss_map_t_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} -EXPORT_SYMBOL(nss_map_t_msg_init); - -/* - * nss_map_t_register_handler() - * debugfs stats msg handler received on static map_t interface - */ -void nss_map_t_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_map_t_get_context(); - - nss_info("nss_map_t_register_handler"); - sema_init(&nss_map_t_pvt.sem, 1); - init_completion(&nss_map_t_pvt.complete); - nss_core_register_handler(nss_ctx, NSS_MAP_T_INTERFACE, nss_map_t_handler, NULL); - - nss_map_t_stats_dentry_create(); - nss_map_t_strings_dentry_create(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_map_t_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_map_t_log.c deleted file mode 100644 index 5f1ef397b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_map_t_log.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_map_t_log.c - * NSS MAP_T logger file. - */ - -#include "nss_core.h" - -/* - * nss_map_t_log_message_types_str - * NSS MAP_T message strings - */ -static int8_t *nss_map_t_log_message_types_str[NSS_MAP_T_MSG_MAX] __maybe_unused = { - "MAP_T Rule Configure", - "MAP_T Rule Deconfigure", - "MAP_T Stats", -}; - -/* - * nss_map_t_log_rule_configure_msg() - * Log NSS MAP_T Rule Configure. - */ -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("%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" - "MAP_T Local IPv4 Prefix: %d\n" - "MAP_T Local IPv4 Prefix Length: %d\n" - "MAP_T Local EA Bits Length: %d\n" - "MAP_T Local PSID Offset: %d\n" - "MAP_T Reserved A: %d\n" - "MAP_T Remote IPv6 Prefix Length: %d\n" - "MAP_T Remote IPv4 Prefix: %d\n" - "MAP_T Remote IPv4 Prefix Length: %d\n" - "MAP_T Remote EA Bits Length: %d\n" - "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: %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, - ntcm->local_ipv4_prefix_len, ntcm->local_ea_len, - ntcm->local_psid_offset, ntcm->reserve_a, - ntcm->remote_ipv6_prefix_len, - ntcm->remote_ipv4_prefix, ntcm->remote_ipv4_prefix_len, - ntcm->remote_ea_len, ntcm->remote_psid_offset, - ntcm->local_map_style, ntcm->remote_map_style, - ntcm->local_ipv6_prefix, ntcm->reserve_b, - ntcm->remote_ipv6_prefix, ntcm->valid_rule); -} - -/* - * nss_map_t_log_rule_deconfig_msg() - * Log NSS MAP_T Rule Deconfigure. - */ -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("%px: NSS MAP_T Rule Deconfigure message \n" - "MAP_T Interface Number: %d\n", - ntdm, ntdm->if_number); -} - -/* - * nss_map_t_log_verbose() - * Log message contents. - */ -static void nss_map_t_log_verbose(struct nss_map_t_msg *ntm) -{ - switch (ntm->cm.type) { - case NSS_MAP_T_MSG_INSTANCE_RULE_CONFIGURE: - nss_map_t_log_rule_configure_msg(ntm); - break; - - case NSS_MAP_T_MSG_INSTANCE_RULE_DECONFIGURE: - nss_map_t_log_rule_deconfig_msg(ntm); - break; - - case NSS_MAP_T_MSG_SYNC_STATS: - /* - * No log for valid stats message. - */ - break; - - default: - nss_trace("%px: Invalid message type\n", ntm); - break; - } -} - -/* - * nss_map_t_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_map_t_log_tx_msg(struct nss_map_t_msg *ntm) -{ - if (ntm->cm.type >= NSS_MAP_T_MSG_MAX) { - nss_warning("%px: Invalid message type\n", ntm); - return; - } - - 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); -} - -/* - * nss_map_t_log_rx_msg() - * Log messages received from FW. - */ -void nss_map_t_log_rx_msg(struct nss_map_t_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_map_t_log_message_types_str[ntm->cm.type], - ntm->cm.response, nss_cmn_response_str[ntm->cm.response]); - goto verbose; - } - - 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]); - -verbose: - nss_map_t_log_verbose(ntm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_map_t_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_map_t_log.h deleted file mode 100644 index 39448898d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_map_t_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_MAP_T_LOG_H -#define __NSS_MAP_T_LOG_H - -/* - * nss_map_t.h - * NSS MAP_T header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_map_t_log_tx_msg - * Logs a map_t message that is sent to the NSS firmware. - */ -void nss_map_t_log_tx_msg(struct nss_map_t_msg *ntm); - -/* - * nss_map_t_log_rx_msg - * Logs a map_t message that is received from the NSS firmware. - */ -void nss_map_t_log_rx_msg(struct nss_map_t_msg *ntm); - -#endif /* __NSS_MAP_T_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_map_t_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_map_t_stats.c deleted file mode 100644 index 2dc4d9fa6..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_map_t_stats.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2017,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. - * 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_map_t_stats.h" -#include "nss_map_t_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_map_t_stats_notifier); - -/* - * nss_map_t_stats_read() - * Read map_t statistics - */ -static ssize_t nss_map_t_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - - uint32_t max_output_lines = 2 /* header & footer for instance stats */ - + NSS_MAX_MAP_T_DYNAMIC_INTERFACES * (NSS_MAP_T_STATS_MAX + 2) /*instance 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_map_t_stats_instance_debug map_t_instance_stats[NSS_MAX_MAP_T_DYNAMIC_INTERFACES]; - int id, i; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(!lbuf)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - memset(&map_t_instance_stats, 0, sizeof(struct nss_map_t_stats_instance_debug) * NSS_MAX_MAP_T_DYNAMIC_INTERFACES); - - /* - * Get all stats - */ - nss_map_t_instance_debug_stats_get((void *)&map_t_instance_stats); - - /* - * Session stats - */ - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nmap_t instance stats start:\n\n"); - for (id = 0; id < NSS_MAX_MAP_T_DYNAMIC_INTERFACES; id++) { - - if (!map_t_instance_stats[id].valid) { - continue; - } - - dev = dev_get_by_index(&init_net, map_t_instance_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, - map_t_instance_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, - map_t_instance_stats[id].if_num); - } - - for (i = 0; i < NSS_MAP_T_STATS_MAX; i++) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, - "\t%s = %llu\n", nss_map_t_strings_instance_stats[i].stats_name, - map_t_instance_stats[id].stats[i]); - } - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nmap_t instance stats end\n"); - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - - kfree(lbuf); - return bytes_read; -} - -/* - * nss_map_t_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(map_t); - -/* - * nss_map_t_stats_dentry_create() - * Create map_t statistics debug entry. - */ -void nss_map_t_stats_dentry_create(void) -{ - nss_stats_create_dentry("map_t", &nss_map_t_stats_ops); -} - -/* - * nss_map_t_stats_notify() - * Sends notifications to the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_map_t_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - struct nss_map_t_stats_notification map_t_stats; - struct nss_map_t_stats_instance_debug map_t_instance_stats[NSS_MAX_MAP_T_DYNAMIC_INTERFACES]; - int id; - - memset(&map_t_instance_stats, 0, sizeof(map_t_instance_stats)); - - /* - * Get all stats - */ - nss_map_t_instance_debug_stats_get((void *)&map_t_instance_stats); - - for (id = 0; id < NSS_MAX_MAP_T_DYNAMIC_INTERFACES; id++) { - if (map_t_instance_stats[id].if_num == if_num) { - memcpy(&map_t_stats.stats, &map_t_instance_stats[id].stats, sizeof(map_t_stats.stats)); - } - } - map_t_stats.if_type = nss_dynamic_interface_get_type(nss_ctx, if_num); - map_t_stats.core_id = nss_ctx->id; - map_t_stats.if_num = if_num; - atomic_notifier_call_chain(&nss_map_t_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&map_t_stats); -} - -/* - * nss_map_t_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_map_t_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_map_t_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_map_t_stats_register_notifier); - -/* - * nss_map_t_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_map_t_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_map_t_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_map_t_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_map_t_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_map_t_stats.h deleted file mode 100644 index 8fa623afc..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_map_t_stats.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - ****************************************************************************** - * 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. - * **************************************************************************** - */ - -#ifndef __NSS_MAP_T_STATS_H -#define __NSS_MAP_T_STATS_H - -/* - * NSS core stats -- for H2N/N2H map_t debug stats - */ -struct nss_map_t_stats_instance_debug { - uint64_t stats[NSS_MAP_T_STATS_MAX]; - int32_t if_index; - uint32_t if_num; /* nss interface number */ - bool valid; -}; - -/* - * MAP-T statistics APIs - */ -extern void nss_map_t_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); -extern void nss_map_t_stats_dentry_create(void); - -#endif /* __NSS_MAP_T_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_map_t_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_map_t_strings.c deleted file mode 100644 index 90fbf7ec3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_map_t_strings.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_map_t_strings_instance_stats - * MAP-T statistics strings for NSS session statistics. - */ -struct nss_stats_info nss_map_t_strings_instance_stats[NSS_MAP_T_STATS_MAX] = { - {"V4_TO_V6_PBUF_EXCEPTION_PKTS", NSS_STATS_TYPE_EXCEPTION}, - {"V4_TO_V6_PBUF_NO_MATCHING_RULE", NSS_STATS_TYPE_SPECIAL}, - {"V4_TO_V6_PBUF_NOT_TCP_OR_UDP", NSS_STATS_TYPE_SPECIAL}, - {"V4_TO_V6_RULE_ERR_LOCAL_PSID", NSS_STATS_TYPE_ERROR}, - {"V4_TO_V6_RULE_ERR_LOCAL_IPV6", NSS_STATS_TYPE_ERROR}, - {"V4_TO_V6_RULE_ERR_REMOTE_PSID", NSS_STATS_TYPE_ERROR}, - {"V4_TO_V6_RULE_ERR_REMOTE_EA_BITS", NSS_STATS_TYPE_ERROR}, - {"V4_TO_V6_RULE_ERR_REMOTE_IPV6", NSS_STATS_TYPE_ERROR}, - {"V6_TO_V4_PBUF_EXCEPTION_PKTS", NSS_STATS_TYPE_EXCEPTION}, - {"V6_TO_V4_PBUF_NO_MATCHING_RULE", NSS_STATS_TYPE_SPECIAL}, - {"V6_TO_V4_PBUF_NOT_TCP_OR_UDP", NSS_STATS_TYPE_SPECIAL}, - {"V6_TO_V4_RULE_ERR_LOCAL_IPV4", NSS_STATS_TYPE_ERROR}, - {"V6_TO_V4_RULE_ERR_REMOTE_IPV4", NSS_STATS_TYPE_ERROR} -}; - -/* - * nss_map_t_strings_read() - * Read MAP-T node statistics names. - */ -static ssize_t nss_map_t_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_map_t_strings_instance_stats, NSS_MAP_T_STATS_MAX); -} - -/* - * nss_map_t_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(map_t); - -/* - * nss_map_t_strings_dentry_create() - * Create MAP-T statistics strings debug entry. - */ -void nss_map_t_strings_dentry_create(void) -{ - nss_strings_create_dentry("map_t", &nss_map_t_strings_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_map_t_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_map_t_strings.h deleted file mode 100644 index acf2cd0b2..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_map_t_strings.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_MAP_T_STRINGS_H -#define __NSS_MAP_T_STRINGS_H - -extern struct nss_stats_info nss_map_t_strings_instance_stats[NSS_MAP_T_STATS_MAX]; -extern void nss_map_t_strings_dentry_create(void); - -#endif /* __NSS_MAP_T_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_match.c b/feeds/ipq807x/qca-nss-drv/src/nss_match.c deleted file mode 100644 index dcdfa6cba..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_match.c +++ /dev/null @@ -1,299 +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. - *************************************************************************** - */ - -/* - * nss_match.c - */ - -#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 */ - -/* - * Private data structure for match interface - */ -static struct nss_match_pvt { - struct semaphore sem; - struct completion complete; - int32_t response; -} match_pvt; - -/* - * nss_get_match_context() - */ -struct nss_ctx_instance *nss_match_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.match_handler_id]; -} -EXPORT_SYMBOL(nss_match_get_context); - -/* - * nss_match_verify_if_num() - */ -static bool nss_match_verify_if_num(uint32_t if_num) -{ - if (nss_is_dynamic_interface(if_num) == false) { - return false; - } - - if (nss_dynamic_interface_get_type(nss_match_get_context(), if_num) - != NSS_DYNAMIC_INTERFACE_TYPE_MATCH) { - return false; - } - - return true; -} - -/* - * nss_match_msg_sync_callback - * Callback to handle the completion of NSS to HLOS messages. - */ -static void nss_match_msg_sync_callback(void *app_data, struct nss_match_msg *matchm) -{ - match_pvt.response = NSS_TX_SUCCESS; - - if (matchm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("Match Error response %d\n", matchm->cm.response); - match_pvt.response = NSS_TX_FAILURE; - } - - complete(&match_pvt.complete); -} - -/* - * nss_match_msg_tx() - * Sends message to NSS. - */ -static nss_tx_status_t nss_match_msg_tx(struct nss_ctx_instance *nss_ctx, struct nss_match_msg *matchm) -{ - struct nss_cmn_msg *ncm = &matchm->cm; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - /* - * Trace Messages - */ - nss_match_log_tx_msg(matchm); - - /* - * Sanity check the message - */ - if (!nss_match_verify_if_num(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("%px: Message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, matchm, sizeof(*matchm), NSS_NBUF_PAYLOAD_SIZE); -} - -/* - * nss_match_handler() - * Handle NSS to HLOS messages for Match node - */ -static void nss_match_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_match_msg *nem = (struct nss_match_msg *)ncm; - - nss_match_msg_sync_callback_t cb; - void *ctx; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - BUG_ON(!nss_match_verify_if_num(ncm->interface)); - - /* - * Trace Messages - */ - nss_match_log_rx_msg(nem); - - /* - * Is this a valid request/response packet? - */ - if (nem->cm.type >= NSS_MATCH_MSG_MAX) { - 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("%px: Unexpected message length: %d, on interface: %d", - nss_ctx, nss_cmn_get_msg_len(ncm), ncm->interface); - return; - } - - switch (nem->cm.type) { - case NSS_MATCH_STATS_SYNC: - - /* - * 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) { - ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_match_msg_sync_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - cb(ctx, nem); -} - -/* - * nss_match_msg_tx_sync() - * Send a message to match node and wait for the response. - */ -nss_tx_status_t nss_match_msg_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_match_msg *matchm) -{ - nss_tx_status_t status; - int ret = 0; - down(&match_pvt.sem); - - matchm->cm.cb = (nss_ptr_t)nss_match_msg_sync_callback; - matchm->cm.app_data = (nss_ptr_t)NULL; - - status = nss_match_msg_tx(nss_ctx, matchm); - if (status != NSS_TX_SUCCESS) { - 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("%px: MATCH tx failed due to timeout\n", nss_ctx); - match_pvt.response = NSS_TX_FAILURE; - } - - status = match_pvt.response; - up(&match_pvt.sem); - - return status; -} -EXPORT_SYMBOL(nss_match_msg_tx_sync); - -/* - * nss_match_unregister_instance() - * Unregisters match instance. - */ -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("%px: Incorrect interface number: %d", nss_ctx, if_num); - return false; - } - - 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); - return false; - } - - nss_match_ifnum_delete(if_num); - - return true; -} -EXPORT_SYMBOL(nss_match_unregister_instance); - -/* - * nss_match_register_instance() - * Registers match instance. - */ -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("%px: Incorrect interface number: %d", nss_ctx, if_num); - return NULL; - } - - 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 register handler for interface %d with NSS core\n", nss_ctx, if_num); - return NULL; - } - - 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 nss_ctx; -} -EXPORT_SYMBOL(nss_match_register_instance); - -/* - * nss_match_msg_init() - * Initialize match message. - */ -void nss_match_msg_init(struct nss_match_msg *nmm, uint16_t if_num, uint32_t type, uint32_t len, - nss_match_msg_sync_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&nmm->cm, if_num, type, len, (void*)cb, app_data); -} -EXPORT_SYMBOL(nss_match_msg_init); - -/* - * nss_match_init() - * Initialize match. - */ -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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_match_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_match_log.c deleted file mode 100644 index 2afdf6425..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_match_log.c +++ /dev/null @@ -1,225 +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_match_log.c - * NSS match logger file. - */ - -#include "nss_core.h" - -/* - * nss_match_log_message_types_str - * Match message strings. - */ -static char *nss_match_log_message_types_str[NSS_MATCH_MSG_MAX] __maybe_unused = { - "Match no message", - "Match profile configure", - "Match add VoW rule", - "Match add L2 rule", - "Match delete VoW rule", - "Match delete L2 rule", - "Match sync stats" -}; - -/* - * nss_match_log_error_types_str - * Strings for error types for match messages - */ -static char *nss_match_log_error_types_str[NSS_MATCH_ERROR_MAX] __maybe_unused = { - "Match success", - "Match unknown message", - "Match DSCP is not in the range", - "Match 802.1p outer is not in the range", - "Match 802.1p inner is not in the range", - "Match rule ID is not in the range", - "Match action type is not in the range", - "Match rule ID already exists", - "Match rule ID doesn't exists", - "Match instance already configured", - "Match profile configuration message is invalid", - "Match database initialzation failed", - "Match table ID is not in the range", - "Match error in adding rule", - "Match error in deleting rule", - "Match error in adding table", - "Match error in deleting table", - "Match error mask ID is not in the range", - "Match error next node interface number is invalid", -}; - -/* - * nss_match_log_profile_configure_msg() - * Log NSS match profile configuration message. - */ -static void nss_match_log_profile_configure_msg(struct nss_match_msg *nmm) -{ - struct nss_match_profile_configure_msg *nmcm __maybe_unused = &nmm->msg.configure_msg; - int mask_num, mask_word; - - nss_trace("%px: NSS match configuration message \n" - "Match profile type: %u \n" - "Match mask flag: %u \n", - nmcm, - nmcm->profile_type, - nmcm->valid_mask_flag); - - for (mask_num = 0; mask_num < NSS_MATCH_MASK_MAX; mask_num++) { - nss_trace("Match mask number %d\n", mask_num + 1); - for (mask_word = 0; mask_word < NSS_MATCH_MASK_WORDS_MAX; mask_word++) { - nss_trace("%x ", nmcm->maskset[mask_num][mask_word]); - } - } -} - -/* - * nss_match_log_vow_rule_msg() - * Log NSS match VoW rule message. - */ -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("%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" - "Match interface number: %u \n" - "Match DSCP: %hu \n" - "Match outer_8021p: %hu \n" - "Match inner_8021p: %hu \n", - nmvrm, - nmvrm->rule_id, - nmvrm->mask_id, - nmvrm->action.action_flag, nmvrm->action.forward_ifnum, nmvrm->action.setprio, - nmvrm->if_num, - nmvrm->dscp, - nmvrm->outer_8021p, - nmvrm->inner_8021p); -} - -/* - * nss_match_log_l2_rule_msg() - * Log NSS match L2 rule message. - */ -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("%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" - "Match interface number: %u \n" - "Match destination mac address: %x :%x :%x \n" - "Match source mac address: %x :%x :%x \n" - "Match ether type: %x \n", - nmlrm, - nmlrm->rule_id, - nmlrm->mask_id, - nmlrm->action.action_flag, nmlrm->action.forward_ifnum, nmlrm->action.setprio, - nmlrm->if_num, - nmlrm->dmac[0], nmlrm->dmac[1], nmlrm->dmac[2], - nmlrm->smac[0], nmlrm->smac[1], nmlrm->smac[2], - nmlrm->ethertype); - -} - -/* - * nss_clmap_log_verbose() - * Log message contents. - */ -static void nss_match_log_verbose(struct nss_match_msg *nmm) -{ - switch (nmm->cm.type) { - case NSS_MATCH_TABLE_CONFIGURE_MSG: - nss_match_log_profile_configure_msg(nmm); - break; - - case NSS_MATCH_ADD_VOW_RULE_MSG: - nss_match_log_vow_rule_msg(nmm); - break; - - case NSS_MATCH_ADD_L2_RULE_MSG: - nss_match_log_l2_rule_msg(nmm); - break; - - case NSS_MATCH_DELETE_VOW_RULE_MSG: - nss_match_log_vow_rule_msg(nmm); - break; - - case NSS_MATCH_DELETE_L2_RULE_MSG: - nss_match_log_l2_rule_msg(nmm); - break; - - case NSS_MATCH_STATS_SYNC: - break; - - default: - nss_trace("%px: Invalid message type\n", nmm); - break; - } -} - -/* - * nss_match_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_match_log_tx_msg(struct nss_match_msg *nmm) -{ - if (nmm->cm.type >= NSS_MATCH_MSG_MAX) { - nss_warning("%px: Invalid message type\n", nmm); - return; - } - - 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); -} - -/* - * nss_match_log_rx_msg() - * Log messages received from FW. - */ -void nss_match_log_rx_msg(struct nss_match_msg *nmm) -{ - if (nmm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_match_log_verbose(nmm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_match_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_match_log.h deleted file mode 100644 index df5b8a9e3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_match_log.h +++ /dev/null @@ -1,39 +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_MATCH_LOG_H__ -#define __NSS_MATCH_LOG_H__ - -/** - * nss_match_log.h - * NSS match Log Header File. - */ - -/* - * nss_match_log_tx_msg - * Logs a match message that is sent to the NSS firmware. - */ -void nss_match_log_tx_msg(struct nss_match_msg *nmm); - -/* - * nss_match_log_rx_msg - * Logs a match message that is received from the NSS firmware. - */ -void nss_match_log_rx_msg(struct nss_match_msg *nmm); - -#endif /* __NSS_MATCH_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_match_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_match_stats.c deleted file mode 100644 index 29782342f..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_match_stats.c +++ /dev/null @@ -1,245 +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. - *************************************************************************** - */ - -/* - * nss_match_stats.c - */ -#include "nss_core.h" -#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); - - for (index = 0; index < NSS_MATCH_INSTANCE_MAX; index++) { - if (match_ifnum[index]) { - continue; - } - - match_ifnum[index] = if_num; - - spin_unlock_bh(&nss_match_stats_lock); - return true; - } - - spin_unlock_bh(&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); - - for (index = 0; index < NSS_MATCH_INSTANCE_MAX; index++) { - if (match_ifnum[index] != if_num) { - continue; - } - - match_ifnum[index] = 0; - - spin_unlock_bh(&nss_match_stats_lock); - return true; - } - - spin_unlock_bh(&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. - */ -void nss_match_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - struct nss_match_stats_notification match_stats; - uint32_t interface; - int index; - - match_stats.core_id = nss_ctx->id; - match_stats.if_num = if_num; - - for (index = 0; index < NSS_MATCH_INSTANCE_MAX; index++) { - spin_lock_bh(&nss_match_stats_lock); - interface = match_ifnum[index]; - spin_unlock_bh(&nss_match_stats_lock); - - if (interface == if_num) { - break; - } - } - - 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); -} - -/* - * nss_match_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_match_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_match_stats_notifier, nb); -} - -/* - * nss_match_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_match_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_match_stats_notifier, nb); -} - -/* - * nss_match_stats_dentry_create() - * Create match statistics debug entry. - */ -void nss_match_stats_dentry_create(void) -{ - nss_stats_create_dentry("match", &nss_match_stats_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_match_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_match_stats.h deleted file mode 100644 index 3cbc74629..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_match_stats.h +++ /dev/null @@ -1,81 +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_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__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_match_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_match_strings.c deleted file mode 100644 index 67d8451dd..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_match_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_match_strings.h deleted file mode 100644 index 9eb9f621a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_meminfo.c b/feeds/ipq807x/qca-nss-drv/src/nss_meminfo.c deleted file mode 100644 index e24e6be4e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_meminfo.c +++ /dev/null @@ -1,798 +0,0 @@ -/* - * 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 - * 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_meminfo.c - * NSS meminfo subsystem - */ - -#include -#include "nss_tx_rx_common.h" -#include "nss_core.h" -#include "nss_arch.h" -#include "nss_meminfo.h" - -/* - * Store user configuration - */ -static char nss_meminfo_user_config[NSS_MEMINFO_USER_CONFIG_MAXLEN]; -module_param_string(meminfo_user_config, nss_meminfo_user_config, - NSS_MEMINFO_USER_CONFIG_MAXLEN, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); -MODULE_PARM_DESC(nss_meminfo_user_config, "meminfo user configuration"); - -static bool nss_meminfo_debugfs_exist; - -/* - * Name table of memory type presented to user. - */ -char *nss_meminfo_memtype_table[NSS_MEMINFO_MEMTYPE_MAX] = {"IMEM", "SDRAM", "UTCM_SHARED"}; - -/* - * nss_meminfo_alloc_sdram() - * Allocate a SDRAM block. - */ -static void *nss_meminfo_alloc_sdram(struct nss_ctx_instance *nss_ctx, uint32_t size) -{ - void *addr = 0; - - /* - * kmalloc() return cache line aligned buffer. - */ - addr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); - if (!addr) - nss_info_always("%px: failed to alloc a sdram block of size %u\n", nss_ctx, size); - - kmemleak_not_leak((void *)addr); - return addr; -} - -/* - * nss_meminfo_free_sdram() - * Free SDRAM memory. - */ -static inline void nss_meminfo_free_sdram(struct nss_ctx_instance *nss_ctx, uint32_t dma_addr, - void *kern_addr, uint32_t size) -{ - /* - * Unmap it since every SDRAM memory had been mapped. - */ - dma_unmap_single(nss_ctx->dev, dma_addr, size, DMA_FROM_DEVICE); - kfree(kern_addr); -} - -/* - * nss_meminfo_alloc_imem() - * Allocate an IMEM block in a sequential way. - */ -static uint32_t nss_meminfo_alloc_imem(struct nss_ctx_instance *nss_ctx, uint32_t size, int alignment) -{ - struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; - uint32_t new_tail; - uint32_t addr = 0; - int mask; - - mask = alignment - 1; - - /* - * Alignment has to be a power of 2. - */ - nss_assert(!(alignment & mask)); - - new_tail = mem_ctx->imem_tail; - - /* - * Align up the address if it not aligned. - */ - if (new_tail & mask) - new_tail = (new_tail + mask) & ~mask; - - if (size > (mem_ctx->imem_end - new_tail)) { - nss_info_always("%px: failed to alloc an IMEM block of size %u\n", nss_ctx, size); - return addr; - } - - addr = new_tail; - mem_ctx->imem_tail = new_tail + size; - - return addr; -} - -/* - * nss_meminfo_free_imem() - * Free an IMEM block. Ignore the padding bytes for alignment requirement. - */ -static void nss_meminfo_free_imem(struct nss_ctx_instance *nss_ctx, uint32_t addr, uint32_t size) -{ - struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; - mem_ctx->imem_tail -= size; -} - -/* - * nss_meminfo_alloc_utcm_shared() - * Allocate an UTCM_SHARED block in a sequential way. - */ -static uint32_t nss_meminfo_alloc_utcm_shared(struct nss_ctx_instance *nss_ctx, uint32_t size, int alignment) -{ - struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; - uint32_t new_tail; - uint32_t addr = 0; - int mask; - - mask = alignment - 1; - - /* - * Alignment has to be a power of 2. - */ - nss_assert(!(alignment & mask)); - - new_tail = mem_ctx->utcm_shared_tail; - - /* - * Align up the address if it not aligned. - */ - if (new_tail & mask) - new_tail = (new_tail + mask) & ~mask; - - if (size > (mem_ctx->utcm_shared_end - new_tail)) { - nss_info_always("%px: failed to alloc an UTCM_SHARED block of size %u\n", nss_ctx, size); - return addr; - } - - addr = new_tail; - mem_ctx->utcm_shared_tail = new_tail + size; - - return addr; -} - -/* - * nss_meminfo_free_utcm_shared() - * Free an UTCM_SHARED block. Ignore the padding bytes for alignment requirement. - */ -static void nss_meminfo_free_utcm_shared(struct nss_ctx_instance *nss_ctx, uint32_t addr, uint32_t size) -{ - struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; - mem_ctx->utcm_shared_tail -= size; -} - -/* - * nss_meminfo_if_user_overwrite() - * Return user configured memory type. Otherwise, return -1. - */ -static int nss_meminfo_if_user_overwrite(struct nss_ctx_instance *nss_ctx, const char *name) -{ - char *user_config; - char **mtype_table; - char needle[NSS_MEMINFO_BLOCK_NAME_MAXLEN + 6]; - char user_choice[NSS_MEMINFO_MEMTYPE_NAME_MAXLEN]; - int i; - char *p; - - user_config = nss_meminfo_user_config; - mtype_table = nss_meminfo_memtype_table; - - snprintf(needle, sizeof(needle), "<%1d, %s, ", nss_ctx->id, name); - - p = strstr(user_config, needle); - if (!p) - return -1; - - p += strlen(needle); - - for (i = 0; i < NSS_MEMINFO_MEMTYPE_NAME_MAXLEN - 1; i++) { - /* - * Each user config is like , - * it starts with '<' and ends with '>'. - */ - if (*p == '>' || *p == '\0') - break; - user_choice[i] = *p; - p++; - } - - user_choice[i] = '\0'; - - for (i = 0; i < NSS_MEMINFO_MEMTYPE_MAX; i++) - if (!strcmp(mtype_table[i], user_choice)) - return i; - - return -1; -} - -/* - * nss_meminfo_free_block_lists() - * Free block node and memory associated with each each memory object. - */ -static void nss_meminfo_free_block_lists(struct nss_ctx_instance *nss_ctx) -{ - struct nss_meminfo_ctx *mem_ctx; - struct nss_meminfo_block_list *l; - int i; - - mem_ctx = &nss_ctx->meminfo_ctx; - for (i = 0; i < NSS_MEMINFO_MEMTYPE_MAX; i++) { - struct nss_meminfo_block *b; - l = &mem_ctx->block_lists[i]; - b = l->head; - while (b) { - struct nss_meminfo_block *tmp; - /* - * Free IMEM/SDRAM/UTCM_SHARED memory. - */ - switch (i) { - case NSS_MEMINFO_MEMTYPE_IMEM: - nss_meminfo_free_imem(nss_ctx, b->dma_addr, b->size); - break; - case NSS_MEMINFO_MEMTYPE_SDRAM: - nss_meminfo_free_sdram(nss_ctx, b->dma_addr, b->kern_addr, b->size); - break; - case NSS_MEMINFO_MEMTYPE_UTCM_SHARED: - nss_meminfo_free_utcm_shared(nss_ctx, b->dma_addr, b->size); - break; - } - - /* - * Free the struct nss_meminfo_block itself. - */ - tmp = b; - b = b->next; - kfree(tmp); - } - } -} - -/* - * nss_meminfo_init_block_lists() - * Initialize block lists and allocate memory for each block. - */ -static bool nss_meminfo_init_block_lists(struct nss_ctx_instance *nss_ctx) -{ - /* - * There is no corresponding mapped address in kernel for UTCM_SHARED. - * UTCM_SHARED access from kernel is not allowed. Mem Objects requesting - * UTCM_SHARED are not expected to use any kernel mapped address. - * Was for UTCM_SHARED, but move to here as default especially for KW scan. - * Thus, NSS_MEMINFO_POISON is the default value for non-mappable memory request. - */ - void *kern_addr = (void *)NSS_MEMINFO_POISON; - uint32_t dma_addr = 0; - struct nss_meminfo_ctx *mem_ctx; - struct nss_meminfo_block_list *l; - struct nss_meminfo_request *r; - struct nss_meminfo_map *map; - int mtype; - int i; - - mem_ctx = &nss_ctx->meminfo_ctx; - - /* - * Fill memory type for each block list. - */ - for (i = 0; i < NSS_MEMINFO_MEMTYPE_MAX; i++) - mem_ctx->block_lists[i].memtype = i; - - map = &mem_ctx->meminfo_map; - - /* - * Loop through all meminfo requests by checking the per-request magic. - */ - for (r = map->requests; r->magic == NSS_MEMINFO_REQUEST_MAGIC; r++) { - struct nss_meminfo_block *b = (struct nss_meminfo_block *) - kmalloc(sizeof(struct nss_meminfo_block), GFP_KERNEL); - if (!b) { - nss_info_always("%px: failed to allocate meminfo block\n", nss_ctx); - goto cleanup; - } - - b->index = map->num_requests++; - b->size = r->size; - - /* - * Look up the user-defined memory type. - * Return user-defined memory type if exists. Otherwise, return -1. - */ - mtype = nss_meminfo_if_user_overwrite(nss_ctx, r->name); - if (mtype == -1) - mtype = r->memtype_default; - r->memtype_user = mtype; - - 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; - } - - /* - * 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("%px: failed to alloc IMEM block\n", nss_ctx); - goto cleanup; - } - - /* - * Calulate offset to the kernel address (vmap) where the - * whole IMEM is mapped onto instead of calling ioremap(). - */ - kern_addr = nss_ctx->vmap + dma_addr - nss_ctx->vphys; - break; - case NSS_MEMINFO_MEMTYPE_SDRAM: - kern_addr = nss_meminfo_alloc_sdram(nss_ctx, r->size); - if (!kern_addr) { - 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("%px: failed to map SDRAM block\n", nss_ctx); - goto cleanup; - } - break; - case NSS_MEMINFO_MEMTYPE_UTCM_SHARED: - /* - * Return SoC real address for UTCM_SHARED as DMA address. - */ - dma_addr = nss_meminfo_alloc_utcm_shared(nss_ctx, r->size, r->alignment); - if (!dma_addr) { - nss_info_always("%px: failed to alloc UTCM_SHARED block\n", nss_ctx); - goto cleanup; - } - break; - case NSS_MEMINFO_MEMTYPE_INFO: - /* - * if FW request heap_ddr_size, fill it in from DTS values. - */ - if (!strcmp(r->name, "heap_ddr_size")) { - struct nss_mmu_ddr_info coreinfo; - r->size = nss_core_ddr_info(&coreinfo); - - /* - * split memory among the number of cores - */ - r->size /= coreinfo.num_active_cores; - dma_addr = coreinfo.start_address + nss_ctx->id * r->size; - 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("%px: %d unsupported memory type\n", nss_ctx, mtype); - goto cleanup; - } - - /* - * Update the request with DMA address for the memory that only be used by FW. - */ - r->addr = dma_addr; - - /* - * nss_if_mem_map settings - */ - if (!strcmp(r->name, "nss_if_mem_map_inst")) { - BUG_ON(mtype == NSS_MEMINFO_MEMTYPE_UTCM_SHARED); - mem_ctx->if_map_memtype = mtype; - mem_ctx->if_map_dma = dma_addr; - mem_ctx->if_map = (struct nss_if_mem_map *)kern_addr; - } - - if (!strcmp(r->name, "debug_boot_log_desc")) { - BUG_ON(mtype == NSS_MEMINFO_MEMTYPE_UTCM_SHARED); - mem_ctx->logbuffer_memtype = mtype; - mem_ctx->logbuffer_dma = dma_addr; - mem_ctx->logbuffer = (struct nss_log_descriptor *)kern_addr; - } - - if (!strcmp(r->name, "c2c_descs_if_mem_map")) { - mem_ctx->c2c_start_memtype = mtype; - mem_ctx->c2c_start_dma = dma_addr; - } - - if (strcmp(r->name, "profile_dma_ctrl") == 0) { - mem_ctx->sdma_ctrl = kern_addr; - nss_info_always("%px: set sdma %px\n", nss_ctx, kern_addr); - } - - /* - * Flush the updated meminfo request. - */ - NSS_CORE_DMA_CACHE_MAINT(r, sizeof(struct nss_meminfo_request), DMA_TO_DEVICE); - NSS_CORE_DSB(); - - /* - * Update the list - */ - l = &mem_ctx->block_lists[mtype]; - l->num_blks++; - l->total_size += r->size; - - b->next = l->head; - l->head = b; - } - - /* - * Verify memory map end magic - */ - if (*((uint16_t *)r) != NSS_MEMINFO_MAP_END_MAGIC) - goto cleanup; - - return true; - -cleanup: - nss_meminfo_free_block_lists(nss_ctx); - return false; -} - -/* - * nss_meminfo_allocate_n2h_h2n_rings() - * Allocate N2H/H2N rings. - */ -static bool nss_meminfo_allocate_n2h_h2n_rings(struct nss_ctx_instance *nss_ctx, - struct nss_meminfo_n2h_h2n_info *info) -{ - switch (info->memtype) { - case NSS_MEMINFO_MEMTYPE_SDRAM: - info->kern_addr = nss_meminfo_alloc_sdram(nss_ctx, info->total_size); - if (!info->kern_addr) - return false; - - info->dma_addr = dma_map_single(nss_ctx->dev, (void *)info->kern_addr, - info->total_size, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(nss_ctx->dev, info->dma_addr))) { - kfree((void *)info->kern_addr); - return false; - } - 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; - - info->kern_addr = nss_ctx->vmap + info->dma_addr - nss_ctx->vphys; - break; - default: - return false; - } - - return true; -} - -/* - * nss_meminfo_configure_n2h_h2n_rings() - * Configure N2H/H2N rings and if_map. - */ -static bool nss_meminfo_configure_n2h_h2n_rings(struct nss_ctx_instance *nss_ctx) -{ - struct nss_meminfo_ctx *mem_ctx = &nss_ctx->meminfo_ctx; - struct nss_meminfo_n2h_h2n_info *h2n_info; - struct nss_meminfo_n2h_h2n_info *n2h_info; - struct nss_if_mem_map *if_map; - int i; - int mtype; - - h2n_info = &mem_ctx->h2n_info; - n2h_info = &mem_ctx->n2h_info; - - /* - * Check memory type. SDRAM is the default option. - */ - mtype = nss_meminfo_if_user_overwrite(nss_ctx, "h2n_rings"); - if (mtype == -1) - mtype = NSS_MEMINFO_MEMTYPE_SDRAM; - - h2n_info->memtype = mtype; - - mtype = nss_meminfo_if_user_overwrite(nss_ctx, "n2h_rings"); - if (mtype == -1) - mtype = NSS_MEMINFO_MEMTYPE_SDRAM; - - n2h_info->memtype = mtype; - - n2h_info->total_size = sizeof(struct n2h_descriptor) * NSS_N2H_RING_COUNT * (NSS_RING_SIZE + 2); - h2n_info->total_size = sizeof(struct h2n_descriptor) * NSS_H2N_RING_COUNT * (NSS_RING_SIZE + 2); - - /* - * N2H ring allocations - */ - if (!(nss_meminfo_allocate_n2h_h2n_rings(nss_ctx, n2h_info))) { - nss_info_always("%px: failed to allocate/map n2h rings\n", nss_ctx); - return false; - } - - /* - * H2N ring allocations - */ - if (!(nss_meminfo_allocate_n2h_h2n_rings(nss_ctx, h2n_info))) { - nss_info_always("%px: failed to allocate/map h2n_rings\n", nss_ctx); - goto cleanup; - } - - /* - * Bring a fresh copy of if_map from memory in order to read it correctly. - */ - if_map = mem_ctx->if_map; - NSS_CORE_DMA_CACHE_MAINT((void *)if_map, sizeof(struct nss_if_mem_map), DMA_FROM_DEVICE); - NSS_CORE_DSB(); - - if_map->n2h_rings = NSS_N2H_RING_COUNT; - if_map->h2n_rings = NSS_H2N_RING_COUNT; - - /* - * N2H ring settings - */ - for (i = 0; i < NSS_N2H_RING_COUNT; i++) { - struct hlos_n2h_desc_ring *n2h_desc_ring = &nss_ctx->n2h_desc_ring[i]; - n2h_desc_ring->desc_ring.desc = (struct n2h_descriptor *)(n2h_info->kern_addr + i * sizeof(struct n2h_descriptor) * (NSS_RING_SIZE + 2)); - n2h_desc_ring->desc_ring.size = NSS_RING_SIZE; - n2h_desc_ring->hlos_index = if_map->n2h_hlos_index[i]; - - 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("%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); - } - - /* - * H2N ring settings - */ - for (i = 0; i < NSS_H2N_RING_COUNT; i++) { - struct hlos_h2n_desc_rings *h2n_desc_ring = &nss_ctx->h2n_desc_rings[i]; - h2n_desc_ring->desc_ring.desc = (struct h2n_descriptor *)(h2n_info->kern_addr + i * sizeof(struct h2n_descriptor) * (NSS_RING_SIZE + 2)); - h2n_desc_ring->desc_ring.size = NSS_RING_SIZE; - h2n_desc_ring->hlos_index = if_map->h2n_hlos_index[i]; - spin_lock_init(&h2n_desc_ring->lock); - - 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("%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); - } - - /* - * Flush the updated nss_if_mem_map. - */ - NSS_CORE_DMA_CACHE_MAINT((void *)if_map, sizeof(struct nss_if_mem_map), DMA_TO_DEVICE); - NSS_CORE_DSB(); - - return true; - -cleanup: - if (n2h_info->memtype == NSS_MEMINFO_MEMTYPE_SDRAM) - nss_meminfo_free_sdram(nss_ctx, n2h_info->dma_addr, n2h_info->kern_addr, n2h_info->total_size); - else - nss_meminfo_free_imem(nss_ctx, n2h_info->dma_addr, n2h_info->total_size); - - nss_meminfo_free_block_lists(nss_ctx); - return false; -} - -/* - * nss_meminfo_config_show() - * function to show meinfo configuration per core. - */ -static int nss_meminfo_config_show(struct seq_file *seq, void *v) -{ - struct nss_ctx_instance *nss_ctx; - struct nss_meminfo_ctx *mem_ctx; - struct nss_meminfo_n2h_h2n_info *n2h_info; - struct nss_meminfo_n2h_h2n_info *h2n_info; - struct nss_meminfo_map *map; - struct nss_meminfo_request *r; - int nss_id; - int i; - - /* - * i_private is passed to us by debug_fs_create() - */ - nss_id = (int)(nss_ptr_t)seq->private; - if (nss_id < 0 || nss_id >= nss_top_main.num_nss) { - nss_warning("nss_id: %d is not valid\n", nss_id); - return -ENODEV; - } - - nss_ctx = &nss_top_main.nss[nss_id]; - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - mem_ctx = &nss_ctx->meminfo_ctx; - map = &mem_ctx->meminfo_map; - n2h_info = &mem_ctx->n2h_info; - h2n_info = &mem_ctx->h2n_info; - - seq_printf(seq, "%-5s %-32s %-7s %-7s %-10s %-10s\n", - "Index", "Name", "Default", "User", "Size", "DMA Addr"); - seq_printf(seq, "%-5s %-32s %-7s %-7s 0x%-8x 0x%-8x\n", - "N/A", "n2h_rings", "SDRAM", - nss_meminfo_memtype_table[n2h_info->memtype], - n2h_info->total_size, n2h_info->dma_addr); - seq_printf(seq, "%-5s %-32s %-7s %-7s 0x%-8x 0x%-8x\n", - "N/A", "h2n_rings", "SDRAM", - nss_meminfo_memtype_table[h2n_info->memtype], - h2n_info->total_size, h2n_info->dma_addr); - - r = map->requests; - for (i = 0; i < map->num_requests; i++) { - seq_printf(seq, "%-5d %-32s %-7s %-7s 0x%-8x 0x%-8x\n", - i, r[i].name, - nss_meminfo_memtype_table[r[i].memtype_default], - nss_meminfo_memtype_table[r[i].memtype_user], - r[i].size, r[i].addr); - } - - seq_printf(seq, "Available IMEM: 0x%x\n", mem_ctx->imem_end - mem_ctx->imem_tail); - seq_printf(seq, "How to configure? \n"); - seq_printf(seq, "Overwrite the /etc/modules.d/32-qca-nss-drv with following contents then reboot\n\n"); - seq_printf(seq, "qca-nss-drv meminfo_user_config=\", ..\"\n\n"); - seq_printf(seq, "For example, <1, h2n_rings, IMEM> stands for: h2n_rings of core 1 is on IMEM\n"); - seq_printf(seq, "Note:UTCM_SHARED cannot be used for n2h_rings, h2n_rings and debug_log_boot_desc.\n"); - - return 0; -} - -/* - * nss_meminfo_debugfs_file_open() - * function to open meminfo debugfs. - */ -static int nss_meminfo_debugfs_file_open(struct inode *inode, struct file *file) -{ - return single_open(file, nss_meminfo_config_show, inode->i_private); -} - -static struct file_operations nss_meminfo_debugfs_ops = { - .owner = THIS_MODULE, - .open = nss_meminfo_debugfs_file_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -/* - * nss_meminfo_init_debugfs() - * Init meminfo debugfs. - */ -static void nss_meminfo_init_debugfs(struct nss_ctx_instance *nss_ctx) -{ - int i; - struct dentry *meminfo_main_dentry; - struct dentry *meminfo_core_dentries[NSS_MAX_CORES]; - - if (nss_meminfo_debugfs_exist) - return; - - /* - * Create directory for showing meminfo configuration of each core. - */ - meminfo_main_dentry = debugfs_create_dir("meminfo", nss_top_main.top_dentry); - if (unlikely(!meminfo_main_dentry)) { - nss_warning("Failed to create qca-nss-drv/meminfo directory in debugfs\n"); - return; - } - - for (i = 0; i < nss_top_main.num_nss; i++) { - char file[10]; - snprintf(file, sizeof(file), "core%d", i); - meminfo_core_dentries[i] = debugfs_create_file(file, 0400, meminfo_main_dentry, - (void *)(nss_ptr_t)i, &nss_meminfo_debugfs_ops); - if (unlikely(!meminfo_core_dentries[i])) { - int j; - for (j = 0; j < i; j++) - debugfs_remove(meminfo_core_dentries[j]); - debugfs_remove(meminfo_main_dentry); - nss_warning("Failed to create qca-nss-drv/meminfo/%s file in debugfs", file); - return; - } - } - - nss_meminfo_debugfs_exist = true; - nss_info("nss meminfo user config: %s\n", nss_meminfo_user_config); -} - -/* - * nss_meminfo_init - * Initilization - * - */ -bool nss_meminfo_init(struct nss_ctx_instance *nss_ctx) -{ - struct nss_meminfo_ctx *mem_ctx; - uint32_t *meminfo_start; - struct nss_meminfo_map *map; - struct nss_top_instance *nss_top = &nss_top_main; - - 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, - NSS_MEMINFO_RESERVE_AREA_SIZE); - if (!meminfo_start) { - nss_info_always("%px: cannot remap meminfo start\n", nss_ctx); - return false; - } - - /* - * Check meminfo start magic - */ - if ((uint16_t)meminfo_start[0] != NSS_MEMINFO_RESERVE_AREA_MAGIC) { - 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("%px: failed to remap meminfo map\n", nss_ctx); - return false; - } - - /* - * Check meminfo map magic - */ - if ((uint16_t)map->start[0] != NSS_MEMINFO_MAP_START_MAGIC) { - nss_info_always("%px: failed to verify meminfo map magic\n", nss_ctx); - return false; - } - - /* - * Meminfo map settings - */ - map->num_requests = 0; - map->requests = (struct nss_meminfo_request *)(map->start + 1); - - /* - * Init IMEM - */ - nss_top->hal_ops->init_imem(nss_ctx); - - /* - * Init UTCM_SHARED if supported - */ - if (!nss_top->hal_ops->init_utcm_shared(nss_ctx, meminfo_start)) { - nss_info_always("%px: failed to initialize UTCM_SHARED meminfo\n", nss_ctx); - return false; - } - - /* - * Init meminfo block lists - */ - if (!nss_meminfo_init_block_lists(nss_ctx)) { - nss_info_always("%px: failed to initialize meminfo block lists\n", nss_ctx); - return false; - } - - /* - * Configure N2H/H2N rings and nss_if_mem_map - */ - if (!nss_meminfo_configure_n2h_h2n_rings(nss_ctx)) - return false; - - nss_meminfo_init_debugfs(nss_ctx); - - nss_info_always("%px: meminfo init succeed\n", nss_ctx); - return true; -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_meminfo.h b/feeds/ipq807x/qca-nss-drv/src/nss_meminfo.h deleted file mode 100644 index 5c006cc54..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_meminfo.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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. - */ - -/* - * nss_meminfo.h - * nss meminfo header file. - */ - -#ifndef __NSS_MEMINFO_H -#define __NSS_MEMINFO_H - -#define NSS_MEMINFO_RESERVE_AREA_SIZE 0x1000 /* Size of reserved space in firmware start code aligned to one page */ -#define NSS_MEMINFO_RESERVE_AREA_MAGIC 0x9526 /* Magic at the beginning of reserved space */ -#define NSS_MEMINFO_MAP_START_OFFSET 8 /* Offset of memory map start address in reserved space */ -#define NSS_MEMINFO_MAP_SIZE 0x1000 /* Size of memory map per core aligned to one page */ -#define NSS_MEMINFO_MAP_START_MAGIC 0x9527 -#define NSS_MEMINFO_REQUEST_MAGIC 0X9528 -#define NSS_MEMINFO_MAP_END_MAGIC 0x9529 -#define NSS_MEMINFO_RESERVE_AREA_UTCM_SHARED_MAP_MAGIC 0x9530 /* Magic at the beginning of UTCM_SHARED reserved space */ -#define NSS_MEMINFO_BLOCK_NAME_MAXLEN 48 -#define NSS_MEMINFO_MEMTYPE_NAME_MAXLEN 32 -#define NSS_MEMINFO_USER_CONFIG_MAXLEN 1024 -#define NSS_MEMINFO_POISON 0x95 /* Invalid kernel memory address assigned for non mapable mem types */ - -/* - * Memory types available - */ -enum nss_meminfo_memtype { - NSS_MEMINFO_MEMTYPE_IMEM, /* NSS-IMEM also called TCM */ - NSS_MEMINFO_MEMTYPE_SDRAM, /* SDRAM also called DDR */ - NSS_MEMINFO_MEMTYPE_UTCM_SHARED, /* UTCM memory allocated for DMA objects */ - NSS_MEMINFO_MEMTYPE_INFO, /* Exchange information during boot up */ - NSS_MEMINFO_MEMTYPE_MAX -}; - -/* - * Memory request - * Firmware package defines each request asking host to feed the request. - */ -struct nss_meminfo_request { - uint16_t magic; /* Request magic */ - char name[NSS_MEMINFO_BLOCK_NAME_MAXLEN]; /* Memory block name */ - uint16_t memtype_default; /* Memory type requested */ - uint16_t memtype_user; /* User-defined memory type */ - uint32_t alignment; /* Alignment requirement */ - uint32_t size; /* Size requested */ - uint32_t addr; /* Memory block address got from host */ -}; - -/* - * Memory map - * It starts with a magic then an array of memory request and end with a checksum. - * Firmware creates the map for host to parse. - */ -struct nss_meminfo_map { - uint32_t *start; /* Start address */ - uint32_t num_requests; /* Number of requests */ - struct nss_meminfo_request *requests; /* Start of Request array */ -}; - -/* - * Memory block - * Block node for each request. - */ -struct nss_meminfo_block { - struct nss_meminfo_block *next; /* Next block in the same list */ - uint32_t index; /* Index to request array */ - uint32_t size; /* Size of memory block */ - uint32_t dma_addr; /* DMA address */ - void *kern_addr; /* Kernel address */ -}; - -/* - * Memory block list - * List of block node of same memory type. - */ -struct nss_meminfo_block_list { - enum nss_meminfo_memtype memtype; /* memory type */ - uint32_t num_blks; /* Number of blocks */ - uint32_t total_size; /* Size of all memory blocks in this list */ - struct nss_meminfo_block *head; /* list head */ -}; - -/* - * H2N/N2H rings information - */ -struct nss_meminfo_n2h_h2n_info { - enum nss_meminfo_memtype memtype; /* Memory type */ - uint32_t total_size; /* Total size */ - uint32_t dma_addr; /* DMA address */ - void *kern_addr; /* Kernel address */ -}; - -/* - * Memory context - */ -struct nss_meminfo_ctx { - struct nss_meminfo_n2h_h2n_info n2h_info; /* N2H rings info*/ - struct nss_meminfo_n2h_h2n_info h2n_info; /* H2N rings info */ - uint32_t imem_head; /* IMEM start address */ - uint32_t imem_end; /* IMEM end address */ - uint32_t imem_tail; /* IMEM data end */ - uint32_t utcm_shared_head; /* UTCM_SHARED start address */ - uint32_t utcm_shared_end; /* UTCM_SHARED end address */ - uint32_t utcm_shared_tail; /* UTCM_SHARED data end */ - struct nss_if_mem_map *if_map; /* nss_if_mem_map_inst virtual address */ - uint32_t if_map_dma; /* nss_if_mem_map_inst physical address */ - enum nss_meminfo_memtype if_map_memtype; /* Memory type for nss_if_mem_map */ - struct nss_log_descriptor *logbuffer; /* nss_logbuffer virtual address */ - uint32_t logbuffer_dma; /* nss_logbuffer physical address */ - enum nss_meminfo_memtype logbuffer_memtype; /* Memory type for logbuffer */ - uint32_t c2c_start_dma; /* nss_c2c start physical address */ - enum nss_meminfo_memtype c2c_start_memtype; /* Memory type for c2c_start */ - void *sdma_ctrl; /* Soft DMA controller */ - - struct nss_meminfo_map meminfo_map; /* Meminfo map */ - struct nss_meminfo_block_list block_lists[NSS_MEMINFO_MEMTYPE_MAX]; - /* Block lists for each memory type */ -}; - -bool nss_meminfo_init(struct nss_ctx_instance *nss_ctx); -#endif diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_mirror.c b/feeds/ipq807x/qca-nss-drv/src/nss_mirror.c deleted file mode 100644 index a2e506128..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_mirror.c +++ /dev/null @@ -1,296 +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_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 */ - -/* - * Private data structure - */ -static struct { - struct semaphore sem; - struct completion complete; - int response; -} nss_mirror_pvt; - -atomic_t nss_mirror_num_instances; /* Number of active mirror stats instances. */ - -/* - * nss_mirror_verify_if_num() - * Verify interface number passed to us. - */ -bool nss_mirror_verify_if_num(uint32_t if_num) -{ - enum nss_dynamic_interface_type if_type; - - if_type = nss_dynamic_interface_get_type(nss_mirror_get_context(), if_num); - if (if_type == NSS_DYNAMIC_INTERFACE_TYPE_MIRROR) { - return true; - } - - return false; -} -EXPORT_SYMBOL(nss_mirror_verify_if_num); - -/* - * nss_mirror_handler() - * Handle NSS -> HLOS messages for mirror device. - */ -static void nss_mirror_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, - void *app_data) -{ - struct nss_mirror_msg *nmm = (struct nss_mirror_msg *)ncm; - void *ctx; - nss_mirror_msg_callback_t cb; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - nss_assert(nss_mirror_verify_if_num(ncm->interface)); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_MIRROR_MSG_MAX) { - 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("%px: Length of message is greater than expected.", nss_ctx); - return; - } - - /* - * Log messages. - */ - nss_core_log_msg_failures(nss_ctx, ncm); - nss_mirror_log_rx_msg(nmm); - - switch (ncm->type) { - case NSS_MIRROR_MSG_SYNC_STATS: - /* - * Debug stats embedded in stats msg. - */ - nss_mirror_stats_sync(nss_ctx, nmm, ncm->interface); - nss_mirror_stats_notify(nss_ctx, 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)app_data; - } - - /* - * Callback. - */ - cb = (nss_mirror_msg_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - /* - * Call mirror interface callback. - */ - if (!cb) { - nss_warning("%px: No callback for mirror interface %d", - nss_ctx, ncm->interface); - return; - } - - cb(ctx, ncm); -} - -/* - * nss_mirror_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_mirror_callback(void *app_data, struct nss_cmn_msg *ncm) -{ - nss_mirror_pvt.response = NSS_TX_SUCCESS; - - if (ncm->response != NSS_CMN_RESPONSE_ACK) { - nss_warning("mirror interface error response %d\n", ncm->response); - nss_mirror_pvt.response = NSS_TX_FAILURE; - } - - /* - * Write memory barrier. - */ - smp_wmb(); - complete(&nss_mirror_pvt.complete); -} - -/* - * nss_mirror_tx_msg() - * Transmit a mirror interface message to NSS firmware. - */ -nss_tx_status_t nss_mirror_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_mirror_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Sanity check the message. - */ - if (!nss_mirror_verify_if_num(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("%px: message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - /* - * Trace messages. - */ - nss_mirror_log_tx_msg(msg); - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_mirror_tx_msg); - -/* - * nss_mirror_tx_msg_sync() - * Transmit a mirror interface message to NSS firmware synchronously. - */ -nss_tx_status_t nss_mirror_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_mirror_msg *msg) -{ - nss_tx_status_t status; - int ret = 0; - - down(&nss_mirror_pvt.sem); - msg->cm.cb = (nss_ptr_t)nss_mirror_callback; - msg->cm.app_data = (nss_ptr_t)NULL; - - status = nss_mirror_tx_msg(nss_ctx, msg); - if (status != NSS_TX_SUCCESS) { - 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("%px: Mirror interface tx sync failed due to timeout\n", nss_ctx); - nss_mirror_pvt.response = NSS_TX_FAILURE; - } - - status = nss_mirror_pvt.response; - up(&nss_mirror_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_mirror_tx_msg_sync); - -/* - * nss_mirror_unregister_if() - * Un-registers mirror interface from the NSS. - */ -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_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); -} -EXPORT_SYMBOL(nss_mirror_unregister_if); - -/* - * nss_mirror_register_if() - * Registers the mirror interface with NSS. - */ -struct nss_ctx_instance *nss_mirror_register_if(uint32_t if_num, - nss_mirror_data_callback_t data_callback, - nss_mirror_msg_callback_t event_callback, - struct net_device *netdev, uint32_t features) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.mirror_handler_id]; - int ret; - - nss_assert(nss_ctx); - nss_assert(netdev); - nss_assert(nss_mirror_verify_if_num(if_num)); - - if (atomic_read(&nss_mirror_num_instances) == NSS_MAX_MIRROR_DYNAMIC_INTERFACES) { - 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("%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); - - atomic_inc(&nss_mirror_num_instances); - return nss_ctx; -} -EXPORT_SYMBOL(nss_mirror_register_if); - -/* - * nss_mirror_get_context() - * Get the mirror instance context. - */ -struct nss_ctx_instance *nss_mirror_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.mirror_handler_id]; -} -EXPORT_SYMBOL(nss_mirror_get_context); - -/* - * nss_mirror_register_handler() - * Initialize and register mirror instance handler. - */ -void nss_mirror_register_handler(void) -{ - nss_info("nss_mirror_register_handler"); - sema_init(&nss_mirror_pvt.sem, 1); - init_completion(&nss_mirror_pvt.complete); - - nss_mirror_stats_dentry_create(); - nss_mirror_strings_dentry_create(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_mirror_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_mirror_log.c deleted file mode 100644 index 5fb8858f3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_mirror_log.c +++ /dev/null @@ -1,198 +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_mirror_log.c - * NSS Mirror logger file. - */ - -#include "nss_core.h" - -/* - * nss_mirror_log_message_types_str - * MIRROR message strings - */ -static int8_t *nss_mirror_log_message_types_str[NSS_MIRROR_MSG_MAX] __maybe_unused = { - "Mirror Configure Msg", - "Mirror Enable Msg", - "Mirror Disable Msg", - "Mirror Set Nexthop Msg", - "Mirror Reset Nexthop Msg", - "Mirror Stats Sync Msg", -}; - -/* - * nss_mirror_log_error_response_types_str - * Strings for error types for Mirror messages - */ -static int8_t *nss_mirror_log_error_response_types_str[NSS_MIRROR_ERROR_TYPE_MAX] __maybe_unused = { - "Mirror no error", - "Mirror No Memory", - "Mirror Transmit Failure", - "Mirror Bad Parameter", - "Mirror Bad Clone Point", - "Mirror Intance Configured", - "Mirror Intance Disabled", - "Mirror Bad Nexthop", - "Mirror Nexthop Configured", - "Mirror Nexthop Reset", - "Mirror Unknown Message", -}; - -/* - * nss_mirror_log_configure_msg() - * Log NSS Mirror Configure message. - */ -static void nss_mirror_log_configure_msg(struct nss_mirror_msg *nmm) -{ - struct nss_mirror_configure_msg *config_msg __maybe_unused = &nmm->msg.config; - - nss_trace("%px: NSS Mirror Config message \n" - "Packet clone size: %u\n" - "Packet clone point: %hu\n", - config_msg, - config_msg->pkt_clone_size, - config_msg->pkt_clone_point); -} - -/* - * nss_mirror_log_set_nexthop_msg() - * Log NSS Mirror Set Nexthop message. - */ -static void nss_mirror_log_set_nexthop_msg(struct nss_mirror_msg *nmm) -{ - struct nss_mirror_set_nexthop_msg *nexthop_msg __maybe_unused = &nmm->msg.nexthop; - - nss_trace("%px: NSS Mirror Nexthop message \n" - "Nexthop interface number: %u\n", - nexthop_msg, - nexthop_msg->if_num); -} - -/* - * nss_mirror_log_enable_msg() - * Log NSS Mirror Enable message. - */ -static void nss_mirror_log_enable_msg(struct nss_mirror_msg *nmm) -{ - nss_trace("%px: NSS Mirror message: Enable \n", nmm); -} - -/* - * nss_mirror_log_disable_msg() - * Log NSS Mirror Disable message. - */ -static void nss_mirror_log_disable_msg(struct nss_mirror_msg *nmm) -{ - nss_trace("%px: NSS Mirror message: Disable \n", nmm); -} - -/* - * nss_mirror_log_reset_nexthop_msg() - * Log NSS Mirror Reset Nexthop message. - */ -static void nss_mirror_log_reset_nexthop_msg(struct nss_mirror_msg *nmm) -{ - nss_trace("%px: NSS Mirror message: Reset Nexthop \n", nmm); -} - -/* - * nss_mirror_log_verbose() - * Log message contents. - */ -static void nss_mirror_log_verbose(struct nss_mirror_msg *nmm) -{ - switch (nmm->cm.type) { - case NSS_MIRROR_MSG_CONFIGURE: - nss_mirror_log_configure_msg(nmm); - break; - - case NSS_MIRROR_MSG_ENABLE: - nss_mirror_log_enable_msg(nmm); - break; - - case NSS_MIRROR_MSG_DISABLE: - nss_mirror_log_disable_msg(nmm); - break; - - case NSS_MIRROR_MSG_SET_NEXTHOP: - nss_mirror_log_set_nexthop_msg(nmm); - break; - - case NSS_MIRROR_MSG_RESET_NEXTHOP: - nss_mirror_log_reset_nexthop_msg(nmm); - break; - - case NSS_MIRROR_MSG_SYNC_STATS: - break; - - default: - nss_trace("%px: Invalid message type\n", nmm); - break; - } -} - -/* - * nss_mirror_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_mirror_log_tx_msg(struct nss_mirror_msg *nmm) -{ - if (nmm->cm.type >= NSS_MIRROR_MSG_MAX) { - nss_warning("%px: Invalid message type\n", nmm); - return; - } - - 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); -} - -/* - * nss_mirror_log_rx_msg() - * Log messages received from FW. - */ -void nss_mirror_log_rx_msg(struct nss_mirror_msg *nmm) -{ - if (nmm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_mirror_log_verbose(nmm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_mirror_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_mirror_log.h deleted file mode 100644 index a81a4a022..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_mirror_log.h +++ /dev/null @@ -1,39 +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_MIRROR_LOG_H__ -#define __NSS_MIRROR_LOG_H__ - -/* - * nss_mirror_log.h - * NSS Mirror Log Header File. - */ - -/* - * nss_mirror_log_tx_msg - * Logs a Mirror message that is sent to the NSS firmware. - */ -void nss_mirror_log_tx_msg(struct nss_mirror_msg *nmm); - -/* - * nss_mirror_log_rx_msg - * Logs a Mirror message that is received from the NSS firmware. - */ -void nss_mirror_log_rx_msg(struct nss_mirror_msg *nmm); - -#endif /* __NSS_MIRROR_LOG_H__*/ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_mirror_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_mirror_stats.c deleted file mode 100644 index 51fa93c38..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_mirror_stats.c +++ /dev/null @@ -1,324 +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_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 - */ -ATOMIC_NOTIFIER_HEAD(nss_mirror_stats_notifier); - -static DEFINE_SPINLOCK(nss_mirror_stats_lock); - -/* - * nss_mirror_stats_get() - * Get mirror interface statistics. - */ -static void nss_mirror_stats_get(void *stats_mem, uint32_t stats_num) -{ - struct nss_mirror_stats_debug_instance *stats = (struct nss_mirror_stats_debug_instance *)stats_mem; - int i; - - if (!stats) { - nss_warning("No memory to copy mirror interface stats"); - return; - } - - spin_lock_bh(&nss_mirror_stats_lock); - for (i = 0; i < NSS_MAX_MIRROR_DYNAMIC_INTERFACES; i++) { - - /* - * Copy maximum for given number of instances only. - */ - if (likely(stats_db[i])) { - if (likely(stats_num)) { - memcpy(stats, stats_db[i], sizeof(struct nss_mirror_stats_debug_instance)); - stats++; - stats_num--; - } else { - break; - } - } - } - spin_unlock_bh(&nss_mirror_stats_lock); -} - -/* - * nss_mirror_stats_read() - * Read mirror interface statistics. - */ -static ssize_t nss_mirror_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - - uint32_t max_output_lines = 2 /* header & footer for instance stats */ - + NSS_MAX_MIRROR_DYNAMIC_INTERFACES * - ((NSS_STATS_NODE_MAX + 3 ) + (NSS_MIRROR_STATS_MAX + 3)) /*instance 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_mirror_stats_debug_instance *mirror_shadow_stats; - uint32_t id, mirror_active_instances = atomic_read(&nss_mirror_num_instances); - char *lbuf; - - if (!mirror_active_instances) { - return 0; - } - - lbuf = vzalloc(size_al); - if (unlikely(!lbuf)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - mirror_shadow_stats = vzalloc(sizeof(struct nss_mirror_stats_debug_instance) * - mirror_active_instances); - if (unlikely(!mirror_shadow_stats)) { - nss_warning("Could not allocate memory for base debug statistics buffer"); - vfree(lbuf); - return 0; - } - - /* - * 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); - - /* - * Session stats - */ - for (id = 0; id < mirror_active_instances; id++) { - dev = dev_get_by_index(&init_net, mirror_shadow_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, - mirror_shadow_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, - mirror_shadow_stats[id].if_num); - } - - size_wr += nss_stats_fill_common_stats(mirror_shadow_stats[id].if_num, id, lbuf, size_wr, size_al, "mirror"); - - /* - * Mirror interface exception stats. - */ - size_wr += nss_stats_print("mirror", "mirror exception stats", - id, - nss_mirror_strings_stats, - mirror_shadow_stats[id].stats, - NSS_MIRROR_STATS_MAX, - lbuf, size_wr, size_al); - } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - - vfree(mirror_shadow_stats); - vfree(lbuf); - return bytes_read; -} - -/* - * nss_mirror_stats_sync() - * API to sync statistics for mirror interface. - */ -void nss_mirror_stats_sync(struct nss_ctx_instance *nss_ctx, - struct nss_mirror_msg *nmm, uint16_t if_num) -{ - uint8_t i, j; - struct nss_top_instance *nss_top = nss_ctx->nss_top; - struct nss_mirror_stats_sync_msg *stats_msg = &nmm->msg.stats; - 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); - for (i = 0; i < NSS_MAX_MIRROR_DYNAMIC_INTERFACES; i++) { - if (!stats_db[i] || (stats_db[i]->if_num != if_num)) { - continue; - } - - for (j = 0; j < NSS_MIRROR_STATS_MAX; j++) { - /* - * Sync stats. - */ - stats_db[i]->stats[j] += mirror_stats_ptr[j]; - } - spin_unlock_bh(&nss_mirror_stats_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); - return; - -sync_cmn_stats: - spin_lock_bh(&nss_mirror_stats_lock); - - /* - * Sync common stats. - */ - nss_top->stats_node[if_num][NSS_STATS_NODE_RX_PKTS] += node_stats_ptr->rx_packets; - nss_top->stats_node[if_num][NSS_STATS_NODE_RX_BYTES] += node_stats_ptr->rx_bytes; - nss_top->stats_node[if_num][NSS_STATS_NODE_TX_PKTS] += node_stats_ptr->tx_packets; - nss_top->stats_node[if_num][NSS_STATS_NODE_TX_BYTES] += node_stats_ptr->tx_bytes; - - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - nss_top->stats_node[if_num][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + i] += - node_stats_ptr->rx_dropped[i]; - } - - spin_unlock_bh(&nss_mirror_stats_lock); -} - -/* - * nss_mirror_stats_reset() - * API to reset the mirror interface stats. - */ -void nss_mirror_stats_reset(uint32_t if_num) -{ - struct nss_mirror_stats_debug_instance *mirror_debug_instance = NULL; - uint8_t i; - - /* - * Reset common node stats. - */ - nss_stats_reset_common_stats(if_num); - - /* - * Reset mirror stats. - */ - 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; - } - - mirror_debug_instance = stats_db[i]; - stats_db[i] = NULL; - break; - } - spin_unlock_bh(&nss_mirror_stats_lock); - - if (mirror_debug_instance) { - vfree(mirror_debug_instance); - } -} - -/* - * nss_mirror_stats_init() - * API to initialize mirror debug instance statistics. - */ -int nss_mirror_stats_init(uint32_t if_num, struct net_device *netdev) -{ - struct nss_mirror_stats_debug_instance *mirror_debug_instance = NULL; - uint8_t i; - - mirror_debug_instance = - (struct nss_mirror_stats_debug_instance *)vzalloc(sizeof(struct nss_mirror_stats_debug_instance)); - if (!mirror_debug_instance) { - nss_warning("Memory alloc failed for mirror stats instance.\n"); - return -1; - } - - spin_lock_bh(&nss_mirror_stats_lock); - for (i = 0; i < NSS_MAX_MIRROR_DYNAMIC_INTERFACES; i++) { - if (stats_db[i] != NULL) { - continue; - } - - 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); - return 0; - } - spin_unlock_bh(&nss_mirror_stats_lock); - vfree(mirror_debug_instance); - return -1; -} - -/* - * nss_mirror_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(mirror) - -/* - * nss_mirror_stats_dentry_create() - * Create mirror interface statistics debug entry. - */ -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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_mirror_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_mirror_stats.h deleted file mode 100644 index 22622a550..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_mirror_stats.h +++ /dev/null @@ -1,44 +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_MIRROR_STATS_H -#define __NSS_MIRROR_STATS_H - -/* - * Number of active mirror stats instances. - */ -extern atomic_t nss_mirror_num_instances; - -/* - * nss_mirror_stats_debug_instance - * Stucture for H2N/N2H mirror interface debug stats. - */ -struct nss_mirror_stats_debug_instance { - uint64_t stats[NSS_MIRROR_STATS_MAX]; /* Mirror statistics for each instance. */ - int32_t if_index; /* Mirror instance netdev index. */ - uint32_t if_num; /* Mirror instance NSS interface number */ -}; - -extern void nss_mirror_stats_sync(struct nss_ctx_instance *nss_ctx, - struct nss_mirror_msg *nmm, uint16_t if_num); -extern void nss_mirror_stats_reset(uint32_t if_num); -extern int nss_mirror_stats_init(uint32_t if_num, struct net_device *netdev); -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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_mirror_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_mirror_strings.c deleted file mode 100644 index fb68e0461..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_mirror_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_mirror_strings.h deleted file mode 100644 index 24b73f4c9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_n2h.c b/feeds/ipq807x/qca-nss-drv/src/nss_n2h.c deleted file mode 100644 index ea5c2d04b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_n2h.c +++ /dev/null @@ -1,2250 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_n2h.c - * NSS N2H node APIs - */ - -#include "nss_tx_rx_common.h" -#include "nss_n2h_stats.h" -#include "nss_n2h_strings.h" -#include "nss_drv_strings.h" - -#define NSS_N2H_MAX_BUF_POOL_SIZE (1024 * 1024 * 20) /* 20MB */ -#define NSS_N2H_MIN_EMPTY_POOL_BUF_SZ 32 -#define NSS_N2H_MAX_EMPTY_POOL_BUF_SZ 131072 -#define NSS_N2H_DEFAULT_EMPTY_POOL_BUF_SZ 8192 -#define NSS_N2H_TX_TIMEOUT 3000 /* 3 Seconds */ - -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} }; -int nss_n2h_paged_water_mark[NSS_MAX_CORES][2] __read_mostly = {{-1, -1}, {-1, -1} }; -int nss_n2h_wifi_pool_buf_cfg __read_mostly = -1; -int nss_n2h_core0_mitigation_cfg __read_mostly = 1; -int nss_n2h_core1_mitigation_cfg __read_mostly = 1; -int nss_n2h_core0_add_buf_pool_size __read_mostly; -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; - -struct nss_n2h_registered_data { - nss_n2h_msg_callback_t n2h_callback; - void *app_data; -}; - -static struct nss_n2h_cfg_pvt nss_n2h_nepbcfgp[NSS_MAX_CORES]; -static struct nss_n2h_registered_data nss_n2h_rd[NSS_MAX_CORES]; -static struct nss_n2h_cfg_pvt nss_n2h_rcp; -static struct nss_n2h_cfg_pvt nss_n2h_mitigationcp[NSS_CORE_MAX]; -static struct nss_n2h_cfg_pvt nss_n2h_bufcp[NSS_CORE_MAX]; -static struct nss_n2h_cfg_pvt nss_n2h_wp; -static struct nss_n2h_cfg_pvt nss_n2h_q_cfg_pvt; -static struct nss_n2h_cfg_pvt nss_n2h_q_lim_pvt; -static struct nss_n2h_cfg_pvt nss_n2h_host_bp_cfg_pvt; - -/* - * nss_n2h_interface_handler() - * Handle NSS -> HLOS messages for N2H node - */ -static void nss_n2h_interface_handler(struct nss_ctx_instance *nss_ctx, - struct nss_cmn_msg *ncm, - void *app_data) -{ - struct nss_n2h_msg *nnm = (struct nss_n2h_msg *)ncm; - nss_n2h_msg_callback_t cb; - - BUG_ON(ncm->interface != NSS_N2H_INTERFACE); - - /* - * Is this a valid request/response packet? - */ - if (nnm->cm.type >= NSS_METADATA_TYPE_N2H_MAX) { - nss_warning("%px: received invalid message %d for Offload stats interface", nss_ctx, nnm->cm.type); - return; - } - - switch (nnm->cm.type) { - case NSS_TX_METADATA_TYPE_N2H_RPS_CFG: - nss_info("NSS N2H rps_en %d \n",nnm->msg.rps_cfg.enable); - break; - - case NSS_TX_METADATA_TYPE_N2H_MITIGATION_CFG: - nss_info("NSS N2H mitigation_dis %d \n",nnm->msg.mitigation_cfg.enable); - break; - - case NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG: - nss_info("%px: empty pool buf cfg response from FW", nss_ctx); - break; - - case NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS: - nss_info("%px: flush payloads cmd response from FW", nss_ctx); - break; - - case NSS_RX_METADATA_TYPE_N2H_STATS_SYNC: - /* - * Update driver statistics and send statistics notifications to the registered modules. - */ - nss_n2h_stats_sync(nss_ctx, &nnm->msg.stats_sync); - nss_n2h_stats_notify(nss_ctx); - 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, n2h sends all notify messages - * to the same callback/app_data. - */ - if (nnm->cm.response == NSS_CMN_RESPONSE_NOTIFY) { - /* - * Place holder for the user to create right call - * back and app data when response is NSS_CMN_RESPONSE_NOTIFY - */ - ncm->cb = (nss_ptr_t)nss_n2h_rd[nss_ctx->id].n2h_callback; - ncm->app_data = (nss_ptr_t)nss_n2h_rd[nss_ctx->id].app_data; - } - - /* - * Do we have a callback? - */ - if (!ncm->cb) { - return; - } - - /* - * Callback - */ - cb = (nss_n2h_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, nnm); -} - -/* - * nss_n2h_mitigation_cfg_callback() - * call back function for mitigation configuration - */ -static void nss_n2h_mitigation_cfg_callback(void *app_data, struct nss_n2h_msg *nnm) -{ - uint32_t core_num = (uint32_t)(nss_ptr_t)app_data; - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num]; - - if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) { - - /* - * Error, hence we are not updating the nss_n2h_mitigate_en - */ - nss_n2h_mitigationcp[core_num].response = NSS_FAILURE; - complete(&nss_n2h_mitigationcp[core_num].complete); - nss_warning("core%d: MITIGATION configuration failed : %d\n", core_num, nnm->cm.error); - return; - } - - nss_info("core%d: MITIGATION configuration succeeded: %d\n", core_num, nnm->cm.error); - - nss_ctx->n2h_mitigate_en = nnm->msg.mitigation_cfg.enable; - nss_n2h_mitigationcp[core_num].response = NSS_SUCCESS; - complete(&nss_n2h_mitigationcp[core_num].complete); -} - -/* - * nss_n2h_buf_cfg_callback() - * call back function for pbuf configuration - */ -static void nss_n2h_bufs_cfg_callback(void *app_data, struct nss_n2h_msg *nnm) -{ - uint32_t core_num = (uint32_t)(nss_ptr_t)app_data; - unsigned int allocated_sz; - - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num]; - - if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_n2h_bufcp[core_num].response = NSS_FAILURE; - nss_warning("core%d: buf configuration failed : %d\n", core_num, nnm->cm.error); - goto done; - } - - nss_info("core%d: buf configuration succeeded: %d\n", core_num, nnm->cm.error); - - allocated_sz = nnm->msg.buf_pool.nss_buf_page_size * nnm->msg.buf_pool.nss_buf_num_pages; - nss_ctx->buf_sz_allocated += allocated_sz; - - nss_n2h_bufcp[core_num].response = NSS_SUCCESS; - -done: - complete(&nss_n2h_bufcp[core_num].complete); -} - -/* - * nss_n2h_payload_stats_callback() - * It gets called response to payload accounting. - */ -static void nss_n2h_payload_stats_callback(void *app_data, - struct nss_n2h_msg *nnm) -{ - uint32_t core_num = (uint32_t)(nss_ptr_t)app_data; - - if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) { - struct nss_n2h_empty_pool_buf *nnepbcm; - nnepbcm = &nnm->msg.empty_pool_buf_cfg; - - nss_warning("%d: core empty pool buf set failure: %d\n", - core_num, nnm->cm.error); - nss_n2h_nepbcfgp[core_num].response = NSS_FAILURE; - complete(&nss_n2h_nepbcfgp[core_num].complete); - return; - } - - if (nnm->cm.type == NSS_TX_METADATA_TYPE_GET_WATER_MARK) { - nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.pool_size = - ntohl(nnm->msg.payload_info.pool_size); - nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.low_water = - ntohl(nnm->msg.payload_info.low_water); - nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.high_water = - ntohl(nnm->msg.payload_info.high_water); - } - - if (nnm->cm.type == NSS_TX_METADATA_TYPE_GET_PAGED_WATER_MARK) { - nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.pool_size = - ntohl(nnm->msg.paged_payload_info.pool_size); - nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.low_water = - ntohl(nnm->msg.paged_payload_info.low_water); - nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.high_water = - ntohl(nnm->msg.paged_payload_info.high_water); - } - - nss_n2h_nepbcfgp[core_num].response = NSS_SUCCESS; - complete(&nss_n2h_nepbcfgp[core_num].complete); -} - -/* - * nss_n2h_set_wifi_payloads_callback() - * call back function for response to wifi pool configuration - * - */ -static void nss_n2h_set_wifi_payloads_callback(void *app_data, - struct nss_n2h_msg *nnm) -{ - struct nss_ctx_instance *nss_ctx __maybe_unused = (struct nss_ctx_instance *)app_data; - if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) { - - nss_n2h_wp.response = NSS_FAILURE; - complete(&nss_n2h_wp.complete); - nss_warning("%px: wifi pool configuration failed : %d\n", nss_ctx, - nnm->cm.error); - return; - } - - 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); - complete(&nss_n2h_wp.complete); -} - -/* - * nss_n2h_get_payload_info() - * Gets Payload information. - */ -static int nss_n2h_get_payload_info(nss_ptr_t core_num, struct nss_n2h_msg *nnm, struct nss_n2h_payload_info *nnepbcm) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num]; - nss_tx_status_t nss_tx_status; - int ret = NSS_FAILURE; - - /* - * Note that semaphore should be already held. - */ - - nss_tx_status = nss_n2h_tx_msg(nss_ctx, nnm); - - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: core %d nss_tx error errorn", nss_ctx, (int)core_num); - return NSS_FAILURE; - } - - /* - * Blocking call, wait till we get ACK for this msg. - */ - ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete, - msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); - if (ret == 0) { - 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("%px: core %d response returned failure\n", nss_ctx, (int)core_num); - return NSS_FAILURE; - } - - return NSS_SUCCESS; -} - -/* - * nss_n2h_get_default_payload_info() - * Gets the default payload information. - */ -static int nss_n2h_get_default_payload_info(nss_ptr_t core_num) -{ - struct nss_n2h_msg nnm; - - nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, - NSS_TX_METADATA_TYPE_GET_WATER_MARK, - sizeof(struct nss_n2h_payload_info), - nss_n2h_payload_stats_callback, - (void *)core_num); - - return nss_n2h_get_payload_info(core_num, &nnm, - &nnm.msg.payload_info); -} - -/* - * nss_n2h_get_paged_payload_info() - * Gets the paged payload information. - */ -static int nss_n2h_get_paged_payload_info(nss_ptr_t core_num) -{ - struct nss_n2h_msg nnm; - - nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, - NSS_TX_METADATA_TYPE_GET_PAGED_WATER_MARK, - sizeof(struct nss_n2h_payload_info), - nss_n2h_payload_stats_callback, - (void *)core_num); - - return nss_n2h_get_payload_info(core_num, &nnm, - &nnm.msg.paged_payload_info); -} - -/* - * nss_n2h_set_empty_buf_pool() - * Sets empty pool buffer - */ -static int nss_n2h_set_empty_buf_pool(struct ctl_table *ctl, int write, - void __user *buffer, - size_t *lenp, loff_t *ppos, - nss_ptr_t core_num, int *new_val) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num]; - struct nss_n2h_msg nnm; - struct nss_n2h_empty_pool_buf *nnepbcm; - nss_tx_status_t nss_tx_status; - int ret = NSS_FAILURE; - - /* - * Acquiring semaphore - */ - down(&nss_n2h_nepbcfgp[core_num].sem); - - /* - * Take snap shot of current value - */ - nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.pool_size = *new_val; - - if (!write) { - ret = nss_n2h_get_default_payload_info(core_num); - *new_val = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.pool_size; - if (ret == NSS_FAILURE) { - up(&nss_n2h_nepbcfgp[core_num].sem); - return -EBUSY; - } - - up(&nss_n2h_nepbcfgp[core_num].sem); - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - return ret; - } - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret) { - up(&nss_n2h_nepbcfgp[core_num].sem); - return ret; - } - - if ((*new_val < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) { - nss_warning("%px: core %d setting %d < min number of buffer", - nss_ctx, (int)core_num, *new_val); - goto failure; - } - - 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, - NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG, - sizeof(struct nss_n2h_empty_pool_buf), - nss_n2h_payload_stats_callback, - (nss_ptr_t *)core_num); - - nnepbcm = &nnm.msg.empty_pool_buf_cfg; - nnepbcm->pool_size = htonl(*new_val); - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); - - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: core %d nss_tx error empty pool buffer: %d\n", - nss_ctx, (int)core_num, *new_val); - goto failure; - } - - /* - * Blocking call, wait till we get ACK for this msg. - */ - ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete, - msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); - if (ret == 0) { - nss_warning("%px: core %d Waiting for ack timed out\n", nss_ctx, (int)core_num); - goto failure; - } - - /* - * ACK/NACK received from NSS FW - * If ACK: Callback function will update nss_n2h_empty_pool_buf with - * nss_n2h_nepbcfgp.num_conn_valid, which holds the user input - */ - if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) { - goto failure; - } - - up(&nss_n2h_nepbcfgp[core_num].sem); - return 0; - -failure: - /* - * Restore the current_value to its previous state - */ - *new_val = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.pool_size; - up(&nss_n2h_nepbcfgp[core_num].sem); - return NSS_FAILURE; -} - -/* - * nss_n2h_set_empty_paged_pool_buf() - * Sets empty paged pool buffer - */ -static int nss_n2h_set_empty_paged_pool_buf(struct ctl_table *ctl, int write, - void __user *buffer, - size_t *lenp, loff_t *ppos, - nss_ptr_t core_num, int *new_val) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num]; - struct nss_n2h_msg nnm; - struct nss_n2h_empty_pool_buf *nneppbcm; - nss_tx_status_t nss_tx_status; - int ret = NSS_FAILURE; - - /* - * Acquiring semaphore - */ - down(&nss_n2h_nepbcfgp[core_num].sem); - - /* - * Take snap shot of current value - */ - nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.pool_size = *new_val; - - if (!write) { - ret = nss_n2h_get_paged_payload_info(core_num); - *new_val = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.pool_size; - if (ret == NSS_FAILURE) { - up(&nss_n2h_nepbcfgp[core_num].sem); - return -EBUSY; - } - - up(&nss_n2h_nepbcfgp[core_num].sem); - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - return ret; - } - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret) { - up(&nss_n2h_nepbcfgp[core_num].sem); - return ret; - } - - if ((*new_val < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) { - nss_warning("%px: core %d setting %d < min number of buffer", - nss_ctx, (int)core_num, *new_val); - goto failure; - } - - 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, - NSS_TX_METADATA_TYPE_N2H_EMPTY_PAGED_POOL_BUF_CFG, - sizeof(struct nss_n2h_empty_pool_buf), - nss_n2h_payload_stats_callback, - (nss_ptr_t *)core_num); - - nneppbcm = &nnm.msg.empty_pool_buf_cfg; - nneppbcm->pool_size = htonl(*new_val); - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); - - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: core %d nss_tx error empty paged pool buffer: %d\n", - nss_ctx, (int)core_num, *new_val); - goto failure; - } - - /* - * Blocking call, wait till we get ACK for this msg. - */ - ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete, - msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); - if (ret == 0) { - nss_warning("%px: core %d Waiting for ack timed out\n", nss_ctx, (int)core_num); - goto failure; - } - - /* - * ACK/NACK received from NSS FW - * If ACK: Callback function will update nss_n2h_empty_pool_buf with - * nss_n2h_nepbcfgp.num_conn_valid, which holds the user input - */ - if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) { - goto failure; - } - - up(&nss_n2h_nepbcfgp[core_num].sem); - return 0; - -failure: - /* - * Restore the current_value to its previous state - */ - *new_val = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.pool_size; - up(&nss_n2h_nepbcfgp[core_num].sem); - return NSS_FAILURE; -} - -/* - * nss_n2h_set_water_mark() - * Sets water mark for N2H SOS - */ -static int nss_n2h_set_water_mark(struct ctl_table *ctl, int write, - void __user *buffer, - size_t *lenp, loff_t *ppos, - uint32_t core_num, int *low, int *high) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num]; - struct nss_n2h_msg nnm; - struct nss_n2h_water_mark *wm; - nss_tx_status_t nss_tx_status; - int ret = NSS_FAILURE; - - /* - * Acquiring semaphore - */ - down(&nss_n2h_nepbcfgp[core_num].sem); - - /* - * Take snap shot of current value - */ - nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.low_water = *low; - nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.high_water = *high; - - if (!write || *low == -1 || *high == -1) { - ret = nss_n2h_get_default_payload_info(core_num); - if (ret == NSS_FAILURE) { - up(&nss_n2h_nepbcfgp[core_num].sem); - return -EBUSY; - } - - *low = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.low_water; - *high = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.high_water; - } - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (!write || ret) { - up(&nss_n2h_nepbcfgp[core_num].sem); - return ret; - } - - if ((*low < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ) || - (*high < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) { - 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("%px: core %d setting %d, %d is > upper limit", - nss_ctx, core_num, *low, *high); - goto failure; - } - - if (*low > *high) { - nss_warning("%px: core %d setting low %d is more than high %d", - nss_ctx, core_num, *low, *high); - goto failure; - } - - 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, - NSS_TX_METADATA_TYPE_SET_WATER_MARK, - sizeof(struct nss_n2h_water_mark), - nss_n2h_payload_stats_callback, - (void *)(nss_ptr_t)core_num); - - wm = &nnm.msg.wm; - wm->low_water = htonl(*low); - wm->high_water = htonl(*high); - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); - - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: core %d nss_tx error setting : %d, %d\n", - nss_ctx, core_num, *low, *high); - goto failure; - } - - /* - * Blocking call, wait till we get ACK for this msg. - */ - ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete, - msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); - if (ret == 0) { - nss_warning("%px: core %d Waiting for ack timed out\n", nss_ctx, - core_num); - goto failure; - } - - /* - * ACK/NACK received from NSS FW - */ - if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) - goto failure; - - up(&nss_n2h_nepbcfgp[core_num].sem); - return NSS_SUCCESS; - -failure: - /* - * Restore the current_value to its previous state - */ - *low = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.low_water; - *high = nss_n2h_nepbcfgp[core_num].empty_buf_pool_info.high_water; - up(&nss_n2h_nepbcfgp[core_num].sem); - return -EINVAL; -} - -/* - * nss_n2h_set_paged_water_mark() - * Sets water mark for paged pool N2H SOS - */ -static int nss_n2h_set_paged_water_mark(struct ctl_table *ctl, int write, - void __user *buffer, - size_t *lenp, loff_t *ppos, - uint32_t core_num, int *low, int *high) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num]; - struct nss_n2h_msg nnm; - struct nss_n2h_water_mark *pwm; - nss_tx_status_t nss_tx_status; - int ret = NSS_FAILURE; - - /* - * Acquiring semaphore - */ - down(&nss_n2h_nepbcfgp[core_num].sem); - - /* - * Take snap shot of current value - */ - nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.low_water = *low; - nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.high_water = *high; - - if (!write || *low == -1 || *high == -1) { - ret = nss_n2h_get_paged_payload_info(core_num); - if (ret == NSS_FAILURE) { - up(&nss_n2h_nepbcfgp[core_num].sem); - return -EBUSY; - } - - *low = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.low_water; - *high = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.high_water; - } - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (!write || ret) { - up(&nss_n2h_nepbcfgp[core_num].sem); - return ret; - } - - if ((*low < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ) || - (*high < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) { - 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("%px: core %d setting %d, %d is > upper limit", - nss_ctx, core_num, *low, *high); - goto failure; - } - - if (*low > *high) { - nss_warning("%px: core %d setting low %d is more than high %d", - nss_ctx, core_num, *low, *high); - goto failure; - } - - 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, - NSS_TX_METADATA_TYPE_SET_PAGED_WATER_MARK, - sizeof(struct nss_n2h_water_mark), - nss_n2h_payload_stats_callback, - (void *)(nss_ptr_t)core_num); - - pwm = &nnm.msg.wm_paged; - pwm->low_water = htonl(*low); - pwm->high_water = htonl(*high); - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); - - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: core %d nss_tx error setting : %d, %d\n", - nss_ctx, core_num, *low, *high); - goto failure; - } - - /* - * Blocking call, wait till we get ACK for this msg. - */ - ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete, - msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); - if (ret == 0) { - nss_warning("%px: core %d Waiting for ack timed out\n", nss_ctx, - core_num); - goto failure; - } - - /* - * ACK/NACK received from NSS FW - */ - if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) - goto failure; - - up(&nss_n2h_nepbcfgp[core_num].sem); - return NSS_SUCCESS; - -failure: - /* - * Restore the current_value to its previous state - */ - *low = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.low_water; - *high = nss_n2h_nepbcfgp[core_num].empty_paged_buf_pool_info.high_water; - up(&nss_n2h_nepbcfgp[core_num].sem); - return -EINVAL; -} - -/* - * nss_n2h_cfg_wifi_pool() - * Sets number of wifi payloads to adjust high water mark for N2H SoS - */ -static int nss_n2h_cfg_wifi_pool(struct ctl_table *ctl, int write, - void __user *buffer, - size_t *lenp, loff_t *ppos, - int *payloads) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; - struct nss_n2h_msg nnm; - struct nss_n2h_wifi_payloads *wp; - nss_tx_status_t nss_tx_status; - int ret = NSS_FAILURE; - - /* - * Acquiring semaphore - */ - down(&nss_n2h_wp.sem); - - if (!write) { - *payloads = nss_n2h_wp.wifi_pool; - - up(&nss_n2h_wp.sem); - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - return ret; - } - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret) { - up(&nss_n2h_wp.sem); - return ret; - } - - /* - * If payloads parameter is not set, we do - * nothing. - */ - if (*payloads == -1) - goto failure; - - if ((*payloads < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) { - 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("%px: wifi setting %d > max number of buffer", - nss_ctx, *payloads); - goto failure; - } - - nss_info("%px: wifi payloads : %d\n", - nss_ctx, *payloads); - - nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, - NSS_TX_METADATA_TYPE_N2H_WIFI_POOL_BUF_CFG, - sizeof(struct nss_n2h_wifi_payloads), - nss_n2h_set_wifi_payloads_callback, - (void *)nss_ctx); - - wp = &nnm.msg.wp; - wp->payloads = htonl(*payloads); - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); - - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: wifi setting %d nss_tx error", - nss_ctx, *payloads); - goto failure; - } - - /* - * Blocking call, wait till we get ACK for this msg. - */ - ret = wait_for_completion_timeout(&nss_n2h_wp.complete, - msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); - if (ret == 0) { - nss_warning("%px: Waiting for ack timed out\n", nss_ctx); - goto failure; - } - - /* - * ACK/NACK received from NSS FW - */ - if (NSS_FAILURE == nss_n2h_wp.response) - goto failure; - - up(&nss_n2h_wp.sem); - return NSS_SUCCESS; - -failure: - up(&nss_n2h_wp.sem); - return -EINVAL; -} - -/* - * nss_n2h_empty_pool_buf_core1_handler() - * Sets the number of empty buffer for core 1 - */ -static int nss_n2h_empty_pool_buf_cfg_core1_handler(struct ctl_table *ctl, - int write, void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - return nss_n2h_set_empty_buf_pool(ctl, write, buffer, lenp, ppos, - NSS_CORE_1, &nss_n2h_empty_pool_buf_cfg[NSS_CORE_1]); -} - -/* - * nss_n2h_empty_pool_buf_core0_handler() - * Sets the number of empty buffer for core 0 - */ -static int nss_n2h_empty_pool_buf_cfg_core0_handler(struct ctl_table *ctl, - int write, void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - return nss_n2h_set_empty_buf_pool(ctl, write, buffer, lenp, ppos, - NSS_CORE_0, &nss_n2h_empty_pool_buf_cfg[NSS_CORE_0]); -} - -/* - * nss_n2h_empty_paged_pool_buf_cfg_core1_handler() - * Sets the number of empty paged buffer for core 1 - */ -static int nss_n2h_empty_paged_pool_buf_cfg_core1_handler(struct ctl_table *ctl, - int write, void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - return nss_n2h_set_empty_paged_pool_buf(ctl, write, buffer, lenp, ppos, - NSS_CORE_1, &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_1]); -} - -/* - * nss_n2h_empty_paged_pool_buf_cfg_core0_handler() - * Sets the number of empty paged buffer for core 0 - */ -static int nss_n2h_empty_paged_pool_buf_cfg_core0_handler(struct ctl_table *ctl, - int write, void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - return nss_n2h_set_empty_paged_pool_buf(ctl, write, buffer, lenp, ppos, - NSS_CORE_0, &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_0]); -} - -/* - * nss_n2h_water_mark_core1_handler() - * Sets water mark for core 1 - */ -static int nss_n2h_water_mark_core1_handler(struct ctl_table *ctl, - int write, void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - return nss_n2h_set_water_mark(ctl, write, buffer, lenp, ppos, - NSS_CORE_1, &nss_n2h_water_mark[NSS_CORE_1][0], - &nss_n2h_water_mark[NSS_CORE_1][1]); -} - -/* - * nss_n2h_water_mark_core0_handler() - * Sets water mark for core 0 - */ -static int nss_n2h_water_mark_core0_handler(struct ctl_table *ctl, - int write, void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - return nss_n2h_set_water_mark(ctl, write, buffer, lenp, ppos, - NSS_CORE_0, &nss_n2h_water_mark[NSS_CORE_0][0], - &nss_n2h_water_mark[NSS_CORE_0][1]); -} - -/* - * nss_n2h_paged_water_mark_core1_handler() - * Sets paged water mark for core 1 - */ -static int nss_n2h_paged_water_mark_core1_handler(struct ctl_table *ctl, - int write, void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - return nss_n2h_set_paged_water_mark(ctl, write, buffer, lenp, ppos, - NSS_CORE_1, &nss_n2h_paged_water_mark[NSS_CORE_1][0], - &nss_n2h_paged_water_mark[NSS_CORE_1][1]); -} - -/* - * nss_n2h_paged_water_mark_core0_handler() - * Sets paged water mark for core 0 - */ -static int nss_n2h_paged_water_mark_core0_handler(struct ctl_table *ctl, - int write, void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - return nss_n2h_set_paged_water_mark(ctl, write, buffer, lenp, ppos, - NSS_CORE_0, &nss_n2h_paged_water_mark[NSS_CORE_0][0], - &nss_n2h_paged_water_mark[NSS_CORE_0][1]); -} - -/* - * nss_n2h_wifi_payloads_handler() - * Sets number of wifi payloads - */ -static int nss_n2h_wifi_payloads_handler(struct ctl_table *ctl, - int write, void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - return nss_n2h_cfg_wifi_pool(ctl, write, buffer, lenp, ppos, - &nss_n2h_wifi_pool_buf_cfg); -} - -/* - * nss_n2h_update_queue_config_callback() - * Callback to handle the completion of queue config command - */ -static void nss_n2h_update_queue_config_callback(void *app_data, struct nss_n2h_msg *nim) -{ - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("n2h Error response %d\n", nim->cm.response); - nss_n2h_q_cfg_pvt.response = NSS_TX_FAILURE; - } else { - nss_n2h_q_cfg_pvt.response = NSS_TX_SUCCESS; - } - - complete(&nss_n2h_q_cfg_pvt.complete); -} - -/* - * nss_n2h_update_queue_config_async() - * Asynchronous call to send pnode queue configuration. - */ -nss_tx_status_t nss_n2h_update_queue_config_async(struct nss_ctx_instance *nss_ctx, bool mq_en, uint16_t *qlimits) -{ - - struct nss_n2h_msg nnm; - struct nss_n2h_pnode_queue_config *cfg; - nss_tx_status_t status; - int i; - - if (!mq_en) { - return NSS_TX_SUCCESS; - } - - /* - * MQ mode doesnot make any sense if number of priority queues in NSS - * is 1 - */ - if (NSS_MAX_NUM_PRI <= 1) { - 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_SET_PNODE_QUEUE_CFG, - sizeof(struct nss_n2h_pnode_queue_config), NULL, 0); - - cfg = &nnm.msg.pn_q_cfg; - - /* - * Update limits - */ - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - cfg->qlimits[i] = qlimits[i]; - } - cfg->mq_en = true; - - status = nss_n2h_tx_msg(nss_ctx, &nnm); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: nss_tx error to send pnode queue config\n", nss_ctx); - return status; - } - - return NSS_TX_SUCCESS; -} -EXPORT_SYMBOL(nss_n2h_update_queue_config_async); - -/* - * nss_n2h_update_queue_config_sync() - * Synchronous call to send pnode queue configuration. - */ -nss_tx_status_t nss_n2h_update_queue_config_sync(struct nss_ctx_instance *nss_ctx, bool mq_en, uint16_t *qlimits) -{ - - struct nss_n2h_msg nnm; - struct nss_n2h_pnode_queue_config *cfg; - nss_tx_status_t status; - int ret, i; - - if (!mq_en) { - return NSS_TX_SUCCESS; - } - - /* - * MQ mode doesnot make any sense if number of priority queues in NSS - * is 1 - */ - if (NSS_MAX_NUM_PRI <= 1) { - 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_SET_PNODE_QUEUE_CFG, - sizeof(struct nss_n2h_pnode_queue_config), nss_n2h_update_queue_config_callback, 0); - - cfg = &nnm.msg.pn_q_cfg; - - /* - * Update limits - */ - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - cfg->qlimits[i] = qlimits[i]; - } - cfg->mq_en = true; - - down(&nss_n2h_q_cfg_pvt.sem); - - status = nss_n2h_tx_msg(nss_ctx, &nnm); - - if (status != NSS_TX_SUCCESS) { - 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("%px: Timeout expired for pnode queue config sync message\n", nss_ctx); - nss_n2h_q_cfg_pvt.response = NSS_TX_FAILURE; - } - - status = nss_n2h_q_cfg_pvt.response; - up(&nss_n2h_q_cfg_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_n2h_update_queue_config_sync); - -/* - * nss_n2h_mitigation_cfg() - * Send Message to NSS to disable MITIGATION. - */ -static nss_tx_status_t nss_n2h_mitigation_cfg(struct nss_ctx_instance *nss_ctx, int enable_mitigation, nss_core_id_t core_num) -{ - struct nss_n2h_msg nnm; - struct nss_n2h_mitigation *mitigation_cfg; - nss_tx_status_t nss_tx_status; - int ret; - - nss_assert(core_num < NSS_CORE_MAX); - - down(&nss_n2h_mitigationcp[core_num].sem); - nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_MITIGATION_CFG, - sizeof(struct nss_n2h_mitigation), - nss_n2h_mitigation_cfg_callback, - (void *)core_num); - - mitigation_cfg = &nnm.msg.mitigation_cfg; - mitigation_cfg->enable = enable_mitigation; - - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); - - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: nss_tx error setting mitigation\n", nss_ctx); - goto failure; - } - - /* - * Blocking call, wait till we get ACK for this msg. - */ - ret = wait_for_completion_timeout(&nss_n2h_mitigationcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); - if (ret == 0) { - nss_warning("%px: Waiting for ack timed out\n", nss_ctx); - goto failure; - } - - /* - * ACK/NACK received from NSS FW - */ - if (NSS_FAILURE == nss_n2h_mitigationcp[core_num].response) { - goto failure; - } - - up(&nss_n2h_mitigationcp[core_num].sem); - return NSS_SUCCESS; - -failure: - up(&nss_n2h_mitigationcp[core_num].sem); - return NSS_FAILURE; -} - -static inline void nss_n2h_buf_pool_free(struct nss_n2h_buf_pool *buf_pool) -{ - int page_count; - for (page_count = 0; page_count < buf_pool->nss_buf_num_pages; page_count++) { - kfree((void *)buf_pool->nss_buf_pool_vaddr[page_count]); - } -} - -/* - * nss_n2h_buf_cfg() - * Send Message to NSS to enable pbufs. - */ -static nss_tx_status_t nss_n2h_buf_pool_cfg(struct nss_ctx_instance *nss_ctx, - int buf_pool_size, nss_core_id_t core_num) -{ - static struct nss_n2h_msg nnm; - struct nss_n2h_buf_pool *buf_pool; - nss_tx_status_t nss_tx_status; - int ret; - int page_count; - int num_pages = ALIGN(buf_pool_size, PAGE_SIZE)/PAGE_SIZE; - - nss_assert(core_num < NSS_CORE_MAX); - - nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_METADATA_TYPE_N2H_ADD_BUF_POOL, - sizeof(struct nss_n2h_buf_pool), - nss_n2h_bufs_cfg_callback, - (void *)core_num); - - do { - - down(&nss_n2h_bufcp[core_num].sem); - - buf_pool = &nnm.msg.buf_pool; - buf_pool->nss_buf_page_size = PAGE_SIZE; - - for (page_count = 0; page_count < MAX_PAGES_PER_MSG && num_pages; page_count++, num_pages--) { - void *kern_addr = kzalloc(PAGE_SIZE, GFP_ATOMIC); - if (!kern_addr) { - BUG_ON(!page_count); - break; - } - - kmemleak_not_leak(kern_addr); - buf_pool->nss_buf_pool_vaddr[page_count] = (nss_ptr_t)kern_addr; - buf_pool->nss_buf_pool_addr[page_count] = dma_map_single(nss_ctx->dev, kern_addr, PAGE_SIZE, DMA_TO_DEVICE); - } - - buf_pool->nss_buf_num_pages = page_count; - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); - if (nss_tx_status != NSS_TX_SUCCESS) { - - nss_n2h_buf_pool_free(buf_pool); - nss_warning("%px: nss_tx error setting pbuf\n", nss_ctx); - goto failure; - } - - /* - * Blocking call, wait till we get ACK for this msg. - */ - ret = wait_for_completion_timeout(&nss_n2h_bufcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); - if (ret == 0) { - nss_warning("%px: Waiting for ack timed out\n", nss_ctx); - goto failure; - } - - /* - * ACK/NACK received from NSS FW - */ - if (NSS_FAILURE == nss_n2h_bufcp[core_num].response) { - - nss_n2h_buf_pool_free(buf_pool); - goto failure; - } - - up(&nss_n2h_bufcp[core_num].sem); - } while(num_pages); - - return NSS_SUCCESS; -failure: - up(&nss_n2h_bufcp[core_num].sem); - return NSS_FAILURE; -} - -/* - * nss_mitigation_handler() - * Enable NSS MITIGATION - */ -static int nss_n2h_mitigationcfg_core0_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_0]; - int ret; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret) { - return ret; - } - - /* - * It's a read operation - */ - if (!write) { - return ret; - } - - if (!nss_n2h_core0_mitigation_cfg) { - printk(KERN_INFO "Disabling NSS MITIGATION\n"); - nss_n2h_mitigation_cfg(nss_ctx, 0, NSS_CORE_0); - return 0; - } - printk(KERN_INFO "Invalid input value.Valid value is 0, Runtime re-enabling not supported\n"); - return -EINVAL; -} - -/* - * nss_mitigation_handler() - * Enable NSS MITIGATION - */ -static int nss_n2h_mitigationcfg_core1_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_1]; - int ret; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret) { - return ret; - } - - /* - * It's a read operation - */ - if (!write) { - return ret; - } - - if (!nss_n2h_core1_mitigation_cfg) { - printk(KERN_INFO "Disabling NSS MITIGATION\n"); - nss_n2h_mitigation_cfg(nss_ctx, 0, NSS_CORE_1); - return 0; - } - printk(KERN_INFO "Invalid input value.Valid value is 0, Runtime re-enabling not supported\n"); - return -EINVAL; -} - -/* - * nss_buf_handler() - * Add extra NSS bufs from host memory - */ -static int nss_n2h_buf_cfg_core0_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_0]; - int ret; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret) { - return ret; - } - - /* - * It's a read operation - */ - if (!write) { - return ret; - } - - if (nss_ctx->buf_sz_allocated) { - nss_n2h_core0_add_buf_pool_size = nss_ctx->buf_sz_allocated; - return -EPERM; - } - - if ((nss_n2h_core0_add_buf_pool_size >= 1) && (nss_n2h_core0_add_buf_pool_size <= NSS_N2H_MAX_BUF_POOL_SIZE)) { - printk(KERN_INFO "configuring additional NSS pbufs\n"); - ret = nss_n2h_buf_pool_cfg(nss_ctx, nss_n2h_core0_add_buf_pool_size, NSS_CORE_0); - nss_n2h_core0_add_buf_pool_size = nss_ctx->buf_sz_allocated; - printk(KERN_INFO "additional pbufs of size %d got added to NSS\n", nss_ctx->buf_sz_allocated); - return ret; - } - - printk(KERN_INFO "Invalid input value. should be greater than 1 and less than %d\n", NSS_N2H_MAX_BUF_POOL_SIZE); - return -EINVAL; -} - -/* - * nss_n2h_buf_handler() - * Add extra NSS bufs from host memory - */ -static int nss_n2h_buf_cfg_core1_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[NSS_CORE_1]; - int ret; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret) { - return ret; - } - - /* - * It's a read operation - */ - if (!write) { - return ret; - } - - if (nss_ctx->buf_sz_allocated) { - nss_n2h_core1_add_buf_pool_size = nss_ctx->buf_sz_allocated; - return -EPERM; - } - - if ((nss_n2h_core1_add_buf_pool_size >= 1) && (nss_n2h_core1_add_buf_pool_size <= NSS_N2H_MAX_BUF_POOL_SIZE)) { - printk(KERN_INFO "configuring additional NSS pbufs\n"); - ret = nss_n2h_buf_pool_cfg(nss_ctx, nss_n2h_core1_add_buf_pool_size, NSS_CORE_1); - nss_n2h_core1_add_buf_pool_size = nss_ctx->buf_sz_allocated; - printk(KERN_INFO "additional pbufs of size %d got added to NSS\n", nss_ctx->buf_sz_allocated); - return ret; - } - - printk(KERN_INFO "Invalid input value. should be greater than 1 and less than %d\n", NSS_N2H_MAX_BUF_POOL_SIZE); - return -EINVAL; -} - -/* - * nss_n2h_queue_limit_callback() - * Callback to handle the completion of queue limit command. - */ -static void nss_n2h_queue_limit_callback(void *app_data, struct nss_n2h_msg *nim) -{ - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("n2h error response %d\n", nim->cm.response); - } - - nss_n2h_q_lim_pvt.response = nim->cm.response; - complete(&nss_n2h_q_lim_pvt.complete); -} - -/* - * nss_n2h_set_queue_limit_sync() - * Sets the n2h queue size limit synchronously. - */ -static int nss_n2h_set_queue_limit_sync(struct ctl_table *ctl, int write, void __user *buffer, - size_t *lenp, loff_t *ppos, uint32_t core_id) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_id]; - struct nss_n2h_msg nim; - struct nss_n2h_queue_limit_config *nnqlc = NULL; - int ret, current_val; - nss_tx_status_t nss_tx_status; - - /* - * Take a snap shot of current value - */ - current_val = nss_n2h_queue_limit[core_id]; - - /* - * Write the variable with user input - */ - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret || (!write)) { - return ret; - } - - /* - * We dont allow shortening of the queue size at run-time - */ - if (nss_n2h_queue_limit[core_id] < current_val) { - 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; - } - - memset(&nim, 0, sizeof(struct nss_n2h_msg)); - nss_n2h_msg_init(&nim, NSS_N2H_INTERFACE, - NSS_TX_METADATA_TYPE_N2H_QUEUE_LIMIT_CFG, - sizeof(struct nss_n2h_queue_limit_config), nss_n2h_queue_limit_callback, NULL); - - nnqlc = &nim.msg.ql_cfg; - nnqlc->qlimit = nss_n2h_queue_limit[core_id]; - - /* - * Send synchronous message to firmware - */ - down(&nss_n2h_q_lim_pvt.sem); - - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nim); - if (nss_tx_status != NSS_TX_SUCCESS) { - 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; - } - - ret = wait_for_completion_timeout(&nss_n2h_q_lim_pvt.complete, msecs_to_jiffies(NSS_N2H_TX_TIMEOUT)); - if (!ret) { - 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; - } - - /* - * If setting the queue limit failed, reset the value to original value - */ - if (nss_n2h_q_lim_pvt.response != NSS_CMN_RESPONSE_ACK) { - nss_n2h_queue_limit[core_id] = current_val; - } - - up(&nss_n2h_q_lim_pvt.sem); - return NSS_TX_SUCCESS; -} - -/* - * nss_n2h_queue_limit_core0_handler() - * Sets the n2h queue size limit for core0 - */ -static int nss_n2h_queue_limit_core0_handler(struct ctl_table *ctl, - int write, void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - return nss_n2h_set_queue_limit_sync(ctl, write, buffer, lenp, ppos, - NSS_CORE_0); -} - -/* - * nss_n2h_queue_limit_core1_handler() - * Sets the n2h queue size limit for core1 - */ -static int nss_n2h_queue_limit_core1_handler(struct ctl_table *ctl, - int write, void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - return nss_n2h_set_queue_limit_sync(ctl, write, buffer, lenp, ppos, - NSS_CORE_1); -} - -/* - * nss_n2h_host_bp_cfg_callback() - * Callback function for back pressure configuration. - */ -static void nss_n2h_host_bp_cfg_callback(void *app_data, struct nss_n2h_msg *nnm) -{ - struct nss_ctx_instance *nss_ctx __maybe_unused = (struct nss_ctx_instance *)app_data; - 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("%px: n2h back pressure configuration failed : %d\n", nss_ctx, nnm->cm.error); - return; - } - - 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); -} - -/* - * nss_n2h_host_bp_cfg() - * Send Message to n2h to enable back pressure. - */ -static nss_tx_status_t nss_n2h_host_bp_cfg_sync(struct nss_ctx_instance *nss_ctx, int enable_bp) -{ - struct nss_n2h_msg nnm; - nss_tx_status_t nss_tx_status; - int ret; - - down(&nss_n2h_host_bp_cfg_pvt.sem); - nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_HOST_BACK_PRESSURE_CFG, - sizeof(struct nss_n2h_host_back_pressure), - nss_n2h_host_bp_cfg_callback, - (void *)nss_ctx); - - nnm.msg.host_bp_cfg.enable = enable_bp; - - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); - 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); - return NSS_FAILURE; - } - - /* - * Blocking call, wait till we get ACK for this msg. - */ - ret = wait_for_completion_timeout(&nss_n2h_host_bp_cfg_pvt.complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); - if (ret == 0) { - nss_warning("%px: Waiting for ack timed out\n", nss_ctx); - up(&nss_n2h_host_bp_cfg_pvt.sem); - return NSS_FAILURE; - } - - /* - * Response received from NSS FW - */ - if (nss_n2h_host_bp_cfg_pvt.response == NSS_FAILURE) { - up(&nss_n2h_host_bp_cfg_pvt.sem); - return NSS_FAILURE; - } - - up(&nss_n2h_host_bp_cfg_pvt.sem); - return NSS_SUCCESS; -} - -/* - * nss_n2h_host_bp_cfg_handler() - * Enable n2h back pressure. - */ -static int nss_n2h_host_bp_cfg_handler(struct ctl_table *ctl, int write, - void __user *buffer, size_t *lenp, loff_t *ppos, uint32_t core_id) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_id]; - int ret, ret_bp, current_state; - current_state = nss_n2h_host_bp_config[core_id]; - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - - if (ret != NSS_SUCCESS) { - return ret; - } - - if (!write) { - return ret; - } - - if ((nss_n2h_host_bp_config[core_id] != 0) && (nss_n2h_host_bp_config[core_id] != 1)) { - nss_info_always("Invalid input value. Valid values are 0 and 1\n"); - nss_n2h_host_bp_config[core_id] = current_state; - return ret; - } - - nss_info("Configuring n2h back pressure\n"); - ret_bp = nss_n2h_host_bp_cfg_sync(nss_ctx, nss_n2h_host_bp_config[core_id]); - - if (ret_bp != NSS_SUCCESS) { - nss_warning("%px: n2h back pressure config failed\n", nss_ctx); - nss_n2h_host_bp_config[core_id] = current_state; - } - - return ret_bp; -} - -/* - * nss_n2h_host_bp_cfg_core0_handler() - * Enable n2h back pressure in core 0. - */ -static int nss_n2h_host_bp_cfg_core0_handler(struct ctl_table *ctl, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) -{ - return nss_n2h_host_bp_cfg_handler(ctl, write, buffer, lenp, ppos, NSS_CORE_0); -} - -/* - * nss_n2h_host_bp_cfg_core1_handler() - * Enable n2h back pressure in core 1. - */ -static int nss_n2h_host_bp_cfg_core1_handler(struct ctl_table *ctl, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) -{ - return nss_n2h_host_bp_cfg_handler(ctl, write, buffer, lenp, ppos, NSS_CORE_1); -} - -static struct ctl_table nss_n2h_table_single_core[] = { - { - .procname = "n2h_empty_pool_buf_core0", - .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_empty_pool_buf_cfg_core0_handler, - }, - { - .procname = "n2h_empty_paged_pool_buf_core0", - .data = &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_empty_paged_pool_buf_cfg_core0_handler, - }, - { - .procname = "n2h_low_water_core0", - .data = &nss_n2h_water_mark[NSS_CORE_0][0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_water_mark_core0_handler, - }, - { - .procname = "n2h_high_water_core0", - .data = &nss_n2h_water_mark[NSS_CORE_0][1], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_water_mark_core0_handler, - }, - { - .procname = "n2h_paged_low_water_core0", - .data = &nss_n2h_paged_water_mark[NSS_CORE_0][0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_paged_water_mark_core0_handler, - }, - { - .procname = "n2h_paged_high_water_core0", - .data = &nss_n2h_paged_water_mark[NSS_CORE_0][1], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_paged_water_mark_core0_handler, - }, - { - .procname = "n2h_wifi_pool_buf", - .data = &nss_n2h_wifi_pool_buf_cfg, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_wifi_payloads_handler, - }, - { - .procname = "mitigation_core0", - .data = &nss_n2h_core0_mitigation_cfg, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_mitigationcfg_core0_handler, - }, - { - .procname = "extra_pbuf_core0", - .data = &nss_n2h_core0_add_buf_pool_size, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_buf_cfg_core0_handler, - }, - { - .procname = "n2h_queue_limit_core0", - .data = &nss_n2h_queue_limit[NSS_CORE_0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_queue_limit_core0_handler, - }, - { - .procname = "host_bp_enable0", - .data = &nss_n2h_host_bp_config[NSS_CORE_0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_host_bp_cfg_core0_handler, - }, - - { } -}; - -static struct ctl_table nss_n2h_table_multi_core[] = { - { - .procname = "n2h_empty_pool_buf_core0", - .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_empty_pool_buf_cfg_core0_handler, - }, - { - .procname = "n2h_empty_pool_buf_core1", - .data = &nss_n2h_empty_pool_buf_cfg[NSS_CORE_1], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_empty_pool_buf_cfg_core1_handler, - }, - { - .procname = "n2h_empty_paged_pool_buf_core0", - .data = &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_empty_paged_pool_buf_cfg_core0_handler, - }, - { - .procname = "n2h_empty_paged_pool_buf_core1", - .data = &nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_1], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_empty_paged_pool_buf_cfg_core1_handler, - }, - - { - .procname = "n2h_low_water_core0", - .data = &nss_n2h_water_mark[NSS_CORE_0][0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_water_mark_core0_handler, - }, - { - .procname = "n2h_low_water_core1", - .data = &nss_n2h_water_mark[NSS_CORE_1][0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_water_mark_core1_handler, - }, - { - .procname = "n2h_high_water_core0", - .data = &nss_n2h_water_mark[NSS_CORE_0][1], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_water_mark_core0_handler, - }, - { - .procname = "n2h_high_water_core1", - .data = &nss_n2h_water_mark[NSS_CORE_1][1], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_water_mark_core1_handler, - }, - { - .procname = "n2h_paged_low_water_core0", - .data = &nss_n2h_paged_water_mark[NSS_CORE_0][0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_paged_water_mark_core0_handler, - }, - { - .procname = "n2h_paged_low_water_core1", - .data = &nss_n2h_paged_water_mark[NSS_CORE_1][0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_paged_water_mark_core1_handler, - }, - { - .procname = "n2h_paged_high_water_core0", - .data = &nss_n2h_paged_water_mark[NSS_CORE_0][1], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_paged_water_mark_core0_handler, - }, - { - .procname = "n2h_paged_high_water_core1", - .data = &nss_n2h_paged_water_mark[NSS_CORE_1][1], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_paged_water_mark_core1_handler, - }, - { - .procname = "n2h_wifi_pool_buf", - .data = &nss_n2h_wifi_pool_buf_cfg, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_wifi_payloads_handler, - }, - { - .procname = "mitigation_core0", - .data = &nss_n2h_core0_mitigation_cfg, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_mitigationcfg_core0_handler, - }, - { - .procname = "mitigation_core1", - .data = &nss_n2h_core1_mitigation_cfg, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_mitigationcfg_core1_handler, - }, - { - .procname = "extra_pbuf_core0", - .data = &nss_n2h_core0_add_buf_pool_size, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_buf_cfg_core0_handler, - }, - { - .procname = "extra_pbuf_core1", - .data = &nss_n2h_core1_add_buf_pool_size, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_buf_cfg_core1_handler, - }, - { - .procname = "n2h_queue_limit_core0", - .data = &nss_n2h_queue_limit[NSS_CORE_0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_queue_limit_core0_handler, - }, - { - .procname = "n2h_queue_limit_core1", - .data = &nss_n2h_queue_limit[NSS_CORE_1], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_queue_limit_core1_handler, - }, - { - .procname = "host_bp_enable0", - .data = &nss_n2h_host_bp_config[NSS_CORE_0], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_host_bp_cfg_core0_handler, - }, - { - .procname = "host_bp_enable1", - .data = &nss_n2h_host_bp_config[NSS_CORE_1], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_n2h_host_bp_cfg_core1_handler, - }, - { } -}; - -/* - * This table will be overwritten during single-core registration - */ -static struct ctl_table nss_n2h_dir[] = { - { - .procname = "n2hcfg", - .mode = 0555, - .child = nss_n2h_table_multi_core, - }, - { } -}; - -static struct ctl_table nss_n2h_root_dir[] = { - { - .procname = "nss", - .mode = 0555, - .child = nss_n2h_dir, - }, - { } -}; - -static struct ctl_table nss_n2h_root[] = { - { - .procname = "dev", - .mode = 0555, - .child = nss_n2h_root_dir, - }, - { } -}; - -static struct ctl_table_header *nss_n2h_header; - -/* - * nss_n2h_cfg_empty_pool_size() - * Config empty buffer pool - */ -nss_tx_status_t nss_n2h_cfg_empty_pool_size(struct nss_ctx_instance *nss_ctx, uint32_t pool_sz) -{ - struct nss_n2h_msg nnm; - struct nss_n2h_empty_pool_buf *nnepbcm; - nss_tx_status_t nss_tx_status; - - if (pool_sz < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ) { - 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("%px: setting pool size %d > max number of buffer", - nss_ctx, pool_sz); - return NSS_TX_FAILURE; - } - - nss_info("%px: update number of empty buffer pool size: %d\n", - nss_ctx, pool_sz); - - nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, - NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG, - sizeof(struct nss_n2h_empty_pool_buf), NULL, 0); - - nnepbcm = &nnm.msg.empty_pool_buf_cfg; - nnepbcm->pool_size = htonl(pool_sz); - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); - - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: nss_tx error empty buffer pool: %d\n", nss_ctx, pool_sz); - return nss_tx_status; - } - - return nss_tx_status; -} - -/* - * nss_n2h_paged_buf_pool_init() - * Sends a command down to NSS to initialize paged buffer pool - */ -nss_tx_status_t nss_n2h_paged_buf_pool_init(struct nss_ctx_instance *nss_ctx) -{ - struct nss_n2h_msg nnm; - nss_tx_status_t nss_tx_status; - - /* - * No additional information needed at this point - */ - nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, - NSS_TX_METADATA_TYPE_N2H_PAGED_BUFFER_POOL_INIT, - sizeof(struct nss_n2h_paged_buffer_pool_init), - NULL, - NULL); - - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: failed to send paged buf configuration init command to NSS\n", - nss_ctx); - return NSS_TX_FAILURE; - } - - return NSS_TX_SUCCESS; -} - -/* - * nss_n2h_flush_payloads() - * Sends a command down to NSS for flushing all payloads - */ -nss_tx_status_t nss_n2h_flush_payloads(struct nss_ctx_instance *nss_ctx) -{ - struct nss_n2h_msg nnm; - struct nss_n2h_flush_payloads *nnflshpl; - nss_tx_status_t nss_tx_status; - - nnflshpl = &nnm.msg.flush_payloads; - - /* - * TODO: No additional information sent in message - * as of now. Need to initialize message content accordingly - * if needed. - */ - nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, - NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS, - sizeof(struct nss_n2h_flush_payloads), - NULL, - NULL); - - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: failed to send flush payloads command to NSS\n", - nss_ctx); - - return NSS_TX_FAILURE; - } - - return NSS_TX_SUCCESS; -} - -/* - * nss_n2h_msg_init() - * Initialize n2h message. - */ -void nss_n2h_msg_init(struct nss_n2h_msg *nim, uint16_t if_num, uint32_t type, - uint32_t len, nss_n2h_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&nim->cm, if_num, type, len, (void *)cb, app_data); -} - -/* - * nss_n2h_tx_msg() - * Send messages to NSS n2h package. - */ -nss_tx_status_t nss_n2h_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_n2h_msg *nnm) -{ - struct nss_cmn_msg *ncm = &nnm->cm; - - /* - * Sanity check the message - */ - if (ncm->interface != NSS_N2H_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("%px: message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, nnm, sizeof(*nnm), NSS_NBUF_PAYLOAD_SIZE); -} - -/* - * nss_n2h_notify_register() - * Register to received N2H events. - * - * NOTE: Do we want to pass an nss_ctx here so that we can register for n2h on any core? - */ -struct nss_ctx_instance *nss_n2h_notify_register(int core, nss_n2h_msg_callback_t cb, void *app_data) -{ - if (core >= nss_top_main.num_nss) { - nss_warning("Input core number %d is wrong \n", core); - return NULL; - } - /* - * TODO: We need to have a new array in support of the new API - * TODO: If we use a per-context array, we would move the array into nss_ctx based. - */ - nss_n2h_rd[core].n2h_callback = cb; - nss_n2h_rd[core].app_data = app_data; - return &nss_top_main.nss[core]; -} - -/* - * nss_n2h_register_handler() - */ -void nss_n2h_register_handler(struct nss_ctx_instance *nss_ctx) -{ - sema_init(&nss_n2h_q_cfg_pvt.sem, 1); - init_completion(&nss_n2h_q_cfg_pvt.complete); - - nss_core_register_handler(nss_ctx, NSS_N2H_INTERFACE, nss_n2h_interface_handler, NULL); - - if (nss_ctx->id == NSS_CORE_0) { - nss_n2h_stats_dentry_create(); - } - nss_n2h_strings_dentry_create(); - - nss_drv_strings_dentry_create(); -} - -/* - * nss_n2h_single_core_register_sysctl() - */ -void nss_n2h_single_core_register_sysctl(void) -{ - /* - * RPS sema init - */ - sema_init(&nss_n2h_rcp.sem, 1); - init_completion(&nss_n2h_rcp.complete); - - /* - * MITIGATION sema init for core0 - */ - sema_init(&nss_n2h_mitigationcp[NSS_CORE_0].sem, 1); - init_completion(&nss_n2h_mitigationcp[NSS_CORE_0].complete); - - /* - * PBUF addition sema init for core0 - */ - sema_init(&nss_n2h_bufcp[NSS_CORE_0].sem, 1); - init_completion(&nss_n2h_bufcp[NSS_CORE_0].complete); - - /* - * Core0 - */ - sema_init(&nss_n2h_nepbcfgp[NSS_CORE_0].sem, 1); - init_completion(&nss_n2h_nepbcfgp[NSS_CORE_0].complete); - nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.pool_size = - nss_n2h_empty_pool_buf_cfg[NSS_CORE_0]; - nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.low_water = - nss_n2h_water_mark[NSS_CORE_0][0]; - nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.high_water = - nss_n2h_water_mark[NSS_CORE_0][1]; - nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.pool_size = - nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_0]; - nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.low_water = - nss_n2h_paged_water_mark[NSS_CORE_0][0]; - nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.high_water = - nss_n2h_paged_water_mark[NSS_CORE_0][1]; - - /* - * WiFi pool buf cfg sema init - */ - sema_init(&nss_n2h_wp.sem, 1); - init_completion(&nss_n2h_wp.complete); - - /* - * N2H queue config sema init - */ - sema_init(&nss_n2h_q_lim_pvt.sem, 1); - init_completion(&nss_n2h_q_lim_pvt.complete); - - /* - * Back pressure config sema init - */ - sema_init(&nss_n2h_host_bp_cfg_pvt.sem, 1); - init_completion(&nss_n2h_host_bp_cfg_pvt.complete); - - nss_n2h_notify_register(NSS_CORE_0, NULL, NULL); - - /* - * Register sysctl table. - */ - nss_n2h_dir[0].child = nss_n2h_table_single_core; - nss_n2h_header = register_sysctl_table(nss_n2h_root); -} - -/* - * nss_n2h_multi_core_register_sysctl() - */ -void nss_n2h_multi_core_register_sysctl(void) -{ - /* - * RPS sema init - */ - sema_init(&nss_n2h_rcp.sem, 1); - init_completion(&nss_n2h_rcp.complete); - - /* - * MITIGATION sema init for core0 - */ - sema_init(&nss_n2h_mitigationcp[NSS_CORE_0].sem, 1); - init_completion(&nss_n2h_mitigationcp[NSS_CORE_0].complete); - - /* - * MITIGATION sema init for core1 - */ - sema_init(&nss_n2h_mitigationcp[NSS_CORE_1].sem, 1); - init_completion(&nss_n2h_mitigationcp[NSS_CORE_1].complete); - - /* - * PBUF addition sema init for core0 - */ - sema_init(&nss_n2h_bufcp[NSS_CORE_0].sem, 1); - init_completion(&nss_n2h_bufcp[NSS_CORE_0].complete); - - /* - * PBUF addition sema init for core1 - */ - sema_init(&nss_n2h_bufcp[NSS_CORE_1].sem, 1); - init_completion(&nss_n2h_bufcp[NSS_CORE_1].complete); - - /* - * Core0 - */ - sema_init(&nss_n2h_nepbcfgp[NSS_CORE_0].sem, 1); - init_completion(&nss_n2h_nepbcfgp[NSS_CORE_0].complete); - nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.pool_size = - nss_n2h_empty_pool_buf_cfg[NSS_CORE_0]; - nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.low_water = - nss_n2h_water_mark[NSS_CORE_0][0]; - nss_n2h_nepbcfgp[NSS_CORE_0].empty_buf_pool_info.high_water = - nss_n2h_water_mark[NSS_CORE_0][1]; - nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.pool_size = - nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_0]; - nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.low_water = - nss_n2h_paged_water_mark[NSS_CORE_0][0]; - nss_n2h_nepbcfgp[NSS_CORE_0].empty_paged_buf_pool_info.high_water = - nss_n2h_paged_water_mark[NSS_CORE_0][1]; - - /* - * Core1 - */ - sema_init(&nss_n2h_nepbcfgp[NSS_CORE_1].sem, 1); - init_completion(&nss_n2h_nepbcfgp[NSS_CORE_1].complete); - nss_n2h_nepbcfgp[NSS_CORE_1].empty_buf_pool_info.pool_size = - nss_n2h_empty_pool_buf_cfg[NSS_CORE_1]; - nss_n2h_nepbcfgp[NSS_CORE_1].empty_buf_pool_info.low_water = - nss_n2h_water_mark[NSS_CORE_1][0]; - nss_n2h_nepbcfgp[NSS_CORE_1].empty_buf_pool_info.high_water = - nss_n2h_water_mark[NSS_CORE_1][1]; - nss_n2h_nepbcfgp[NSS_CORE_1].empty_paged_buf_pool_info.pool_size = - nss_n2h_empty_paged_pool_buf_cfg[NSS_CORE_1]; - nss_n2h_nepbcfgp[NSS_CORE_1].empty_paged_buf_pool_info.low_water = - nss_n2h_paged_water_mark[NSS_CORE_1][0]; - nss_n2h_nepbcfgp[NSS_CORE_1].empty_paged_buf_pool_info.high_water = - nss_n2h_paged_water_mark[NSS_CORE_1][1]; - - /* - * WiFi pool buf cfg sema init - */ - sema_init(&nss_n2h_wp.sem, 1); - init_completion(&nss_n2h_wp.complete); - - /* - * N2H queue config sema init - */ - sema_init(&nss_n2h_q_lim_pvt.sem, 1); - init_completion(&nss_n2h_q_lim_pvt.complete); - - /* - * Back pressure config sema init - */ - sema_init(&nss_n2h_host_bp_cfg_pvt.sem, 1); - init_completion(&nss_n2h_host_bp_cfg_pvt.complete); - - nss_n2h_notify_register(NSS_CORE_0, NULL, NULL); - nss_n2h_notify_register(NSS_CORE_1, NULL, NULL); - - /* - * Register sysctl table. - */ - nss_n2h_header = register_sysctl_table(nss_n2h_root); -} - -/* - * nss_n2h_unregister_sysctl() - * Unregister sysctl specific to n2h - */ -void nss_n2h_unregister_sysctl(void) -{ - /* - * Unregister sysctl table. - */ - if (nss_n2h_header) { - unregister_sysctl_table(nss_n2h_header); - } -} - -EXPORT_SYMBOL(nss_n2h_notify_register); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_n2h_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_n2h_stats.c deleted file mode 100644 index 60ff88ba9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_n2h_stats.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -#include "nss_core.h" -#include "nss_n2h_stats.h" -#include "nss_n2h.h" -#include "nss_n2h_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_n2h_stats_notifier); - -uint64_t nss_n2h_stats[NSS_MAX_CORES][NSS_N2H_STATS_MAX]; - -/* - * nss_n2h_stats_read() - * Read N2H stats - */ -static ssize_t nss_n2h_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int32_t i, core; - - /* - * 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; - 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_N2H_STATS_MAX * 8, GFP_KERNEL); - if (unlikely(stats_shadow == NULL)) { - nss_warning("Could not allocate memory for local shadow buffer"); - kfree(lbuf); - return 0; - } - - /* - * N2H node stats - */ - for (core = 0; core < nss_top_main.num_nss; core++) { - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; i < NSS_N2H_STATS_MAX; i++) { - stats_shadow[i] = nss_n2h_stats[core][i]; - } - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_banner(lbuf, size_wr, size_al, "n2h", core); - size_wr += nss_stats_print("n2h", NULL, NSS_STATS_SINGLE_INSTANCE - , nss_n2h_strings_stats - , stats_shadow - , NSS_N2H_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_n2h_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(n2h); - -/* - * nss_n2h_stats_dentry_create() - * Create N2H statistics debug entry. - */ -void nss_n2h_stats_dentry_create(void) -{ - nss_stats_create_dentry("n2h", &nss_n2h_stats_ops); -} - -/* - * nss_n2h_stats_sync() - * Handle the syncing of NSS statistics. - */ -void nss_n2h_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_n2h_stats_sync *nnss) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - int id = nss_ctx->id; - int j; - - spin_lock_bh(&nss_top->stats_lock); - - /* - * common node stats - */ - nss_n2h_stats[id][NSS_STATS_NODE_RX_PKTS] += nnss->node_stats.rx_packets; - nss_n2h_stats[id][NSS_STATS_NODE_RX_BYTES] += nnss->node_stats.rx_bytes; - nss_n2h_stats[id][NSS_STATS_NODE_TX_PKTS] += nnss->node_stats.tx_packets; - nss_n2h_stats[id][NSS_STATS_NODE_TX_BYTES] += nnss->node_stats.tx_bytes; - - for (j = 0; j < NSS_MAX_NUM_PRI; j++) { - nss_n2h_stats[id][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + j] += nnss->node_stats.rx_dropped[j]; - } - - /* - * General N2H stats - */ - nss_n2h_stats[id][NSS_N2H_STATS_QUEUE_DROPPED] += nnss->queue_dropped; - nss_n2h_stats[id][NSS_N2H_STATS_TOTAL_TICKS] += nnss->total_ticks; - nss_n2h_stats[id][NSS_N2H_STATS_WORST_CASE_TICKS] += nnss->worst_case_ticks; - nss_n2h_stats[id][NSS_N2H_STATS_ITERATIONS] += nnss->iterations; - - /* - * pbuf manager ocm and default pool stats - */ - nss_n2h_stats[id][NSS_N2H_STATS_PBUF_OCM_ALLOC_FAILS_WITH_PAYLOAD] += nnss->pbuf_ocm_stats.pbuf_alloc_fails_with_payload; - nss_n2h_stats[id][NSS_N2H_STATS_PBUF_OCM_FREE_COUNT] = nnss->pbuf_ocm_stats.pbuf_free_count; - nss_n2h_stats[id][NSS_N2H_STATS_PBUF_OCM_TOTAL_COUNT] = nnss->pbuf_ocm_stats.pbuf_total_count; - nss_n2h_stats[id][NSS_N2H_STATS_PBUF_OCM_ALLOC_FAILS_NO_PAYLOAD] += nnss->pbuf_ocm_stats.pbuf_alloc_fails_no_payload; - - nss_n2h_stats[id][NSS_N2H_STATS_PBUF_DEFAULT_ALLOC_FAILS_WITH_PAYLOAD] += nnss->pbuf_default_stats.pbuf_alloc_fails_with_payload; - nss_n2h_stats[id][NSS_N2H_STATS_PBUF_DEFAULT_FREE_COUNT] = nnss->pbuf_default_stats.pbuf_free_count; - nss_n2h_stats[id][NSS_N2H_STATS_PBUF_DEFAULT_TOTAL_COUNT] = nnss->pbuf_default_stats.pbuf_total_count; - nss_n2h_stats[id][NSS_N2H_STATS_PBUF_DEFAULT_ALLOC_FAILS_NO_PAYLOAD] += nnss->pbuf_default_stats.pbuf_alloc_fails_no_payload; - - /* - * payload mgr stats - */ - nss_n2h_stats[id][NSS_N2H_STATS_PAYLOAD_ALLOC_FAILS] += nnss->payload_alloc_fails; - nss_n2h_stats[id][NSS_N2H_STATS_PAYLOAD_FREE_COUNT] = nnss->payload_free_count; - - /* - * Host <=> NSS control traffic stats - */ - nss_n2h_stats[id][NSS_N2H_STATS_H2N_CONTROL_PACKETS] += nnss->h2n_ctrl_pkts; - nss_n2h_stats[id][NSS_N2H_STATS_H2N_CONTROL_BYTES] += nnss->h2n_ctrl_bytes; - nss_n2h_stats[id][NSS_N2H_STATS_N2H_CONTROL_PACKETS] += nnss->n2h_ctrl_pkts; - nss_n2h_stats[id][NSS_N2H_STATS_N2H_CONTROL_BYTES] += nnss->n2h_ctrl_bytes; - - /* - * Host <=> NSS control data traffic stats - */ - nss_n2h_stats[id][NSS_N2H_STATS_H2N_DATA_PACKETS] += nnss->h2n_data_pkts; - nss_n2h_stats[id][NSS_N2H_STATS_H2N_DATA_BYTES] += nnss->h2n_data_bytes; - nss_n2h_stats[id][NSS_N2H_STATS_N2H_DATA_PACKETS] += nnss->n2h_data_pkts; - nss_n2h_stats[id][NSS_N2H_STATS_N2H_DATA_BYTES] += nnss->n2h_data_bytes; - - /* - * Payloads related stats - */ - nss_n2h_stats[id][NSS_N2H_STATS_N2H_TOT_PAYLOADS] = nnss->tot_payloads; - - nss_n2h_stats[id][NSS_N2H_STATS_N2H_INTERFACE_INVALID] += nnss->data_interface_invalid; - nss_n2h_stats[id][NSS_N2H_STATS_ENQUEUE_RETRIES] += nnss->enqueue_retries; - - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_n2h_stats_notify() - * Sends notifications to all the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_n2h_stats_notify(struct nss_ctx_instance *nss_ctx) -{ - int i; - struct nss_n2h_stats_notification stats; - - for (i = 0; (i < NSS_STATS_DRV_MAX); i++) { - stats.drv_stats[i] = NSS_PKT_STATS_READ(&nss_top_main.stats_drv[i]); - } - - stats.core_id = nss_ctx->id; - memcpy(stats.n2h_stats, nss_n2h_stats[stats.core_id], sizeof(stats.n2h_stats)); - atomic_notifier_call_chain(&nss_n2h_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&stats); -} - -/* - * nss_n2h_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_n2h_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_n2h_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_n2h_stats_register_notifier); - -/* - * nss_n2h_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_n2h_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_n2h_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_n2h_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_n2h_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_n2h_stats.h deleted file mode 100644 index 96d065eb1..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_n2h_stats.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_N2H_STATS_H -#define __NSS_N2H_STATS_H - -/* - * N2H statistics APIs - */ -extern void nss_n2h_stats_notify(struct nss_ctx_instance *nss_ctx); -extern void nss_n2h_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_n2h_stats_sync *nnss); -extern void nss_n2h_stats_dentry_create(void); - -#endif /* __NSS_N2H_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_n2h_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_n2h_strings.c deleted file mode 100644 index c4c2ce525..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_n2h_strings.c +++ /dev/null @@ -1,85 +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 -#include "nss_strings.h" - -/* - * nss_n2h_strings_stats - * N2H statistics strings. - */ -struct nss_stats_info nss_n2h_strings_stats[NSS_N2H_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}, - {"queue_drops" , NSS_STATS_TYPE_DROP}, - {"ticks" , NSS_STATS_TYPE_SPECIAL}, - {"worst_ticks" , NSS_STATS_TYPE_SPECIAL}, - {"iterations" , NSS_STATS_TYPE_SPECIAL}, - {"pbuf_ocm_total_count" , NSS_STATS_TYPE_SPECIAL}, - {"pbuf_ocm_free_count" , NSS_STATS_TYPE_SPECIAL}, - {"pbuf_ocm_alloc_fail_payload" , NSS_STATS_TYPE_SPECIAL}, - {"pbuf_ocm_alloc_fail_nopayload", NSS_STATS_TYPE_SPECIAL}, - {"pbuf_def_total_count" , NSS_STATS_TYPE_SPECIAL}, - {"pbuf_def_free_count" , NSS_STATS_TYPE_SPECIAL}, - {"pbuf_def_alloc_fail_payload" , NSS_STATS_TYPE_SPECIAL}, - {"pbuf_def_alloc_fail_nopayload", NSS_STATS_TYPE_SPECIAL}, - {"payload_alloc_fails" , NSS_STATS_TYPE_SPECIAL}, - {"payload_free_count" , NSS_STATS_TYPE_SPECIAL}, - {"h2n_control_pkts" , NSS_STATS_TYPE_SPECIAL}, - {"h2n_control_byts" , NSS_STATS_TYPE_SPECIAL}, - {"n2h_control_pkts" , NSS_STATS_TYPE_SPECIAL}, - {"n2h_control_byts" , NSS_STATS_TYPE_SPECIAL}, - {"h2n_data_pkts" , NSS_STATS_TYPE_SPECIAL}, - {"h2n_data_byts" , NSS_STATS_TYPE_SPECIAL}, - {"n2h_data_pkts" , NSS_STATS_TYPE_SPECIAL}, - {"n2h_data_byts" , NSS_STATS_TYPE_SPECIAL}, - {"n2h_tot_payloads" , NSS_STATS_TYPE_SPECIAL}, - {"n2h_data_interface_invalid" , NSS_STATS_TYPE_SPECIAL}, - {"n2h_enqueue_retries" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_n2h_strings_read() - * Read N2H node statistics names. - */ -static ssize_t nss_n2h_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_n2h_strings_stats, NSS_N2H_STATS_MAX); -} - -/* - * nss_n2h_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(n2h); - -/* - * nss_n2h_strings_dentry_create() - * Create N2H statistics strings debug entry. - */ -void nss_n2h_strings_dentry_create(void) -{ - nss_strings_create_dentry("n2h", &nss_n2h_strings_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_n2h_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_n2h_strings.h deleted file mode 100644 index 5d8c2131c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_n2h_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_N2H_STRINGS_H -#define __NSS_N2H_STRINGS_H - -extern struct nss_stats_info nss_n2h_strings_stats[NSS_N2H_STATS_MAX]; -extern void nss_n2h_strings_dentry_create(void); - -#endif /* __NSS_N2H_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_oam.c b/feeds/ipq807x/qca-nss-drv/src/nss_oam.c deleted file mode 100644 index baf43d352..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_oam.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_oam.c - * OAM - Operations, Administration and Maintenance Service for NSS - * - * This adapter module is responsible for sending and - * receiving to and from NSS FW - * This file contains the API for communicating NSS FW to send/receive - * commands OAM commands. - */ - -#include "nss_tx_rx_common.h" -#include "nss_oam_log.h" - -/* - * nss_oam_rx_msg_handler() - * Message handler for OAM messages from NSS - */ -static void nss_oam_rx_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused)) void *app_data) -{ - struct nss_oam_msg *nom = (struct nss_oam_msg *)ncm; - nss_oam_msg_callback_t cb; - - /* - * Trace Messages - */ - nss_oam_log_rx_msg(nom); - - /* - * Sanity check the message type - */ - if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_oam_msg)) { - 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("%px: received with invalid resp type: %d", nss_ctx, ncm->type); - return; - } - - /* - * Log the failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_top_main.oam_callback; - ncm->app_data = (nss_ptr_t)nss_top_main.oam_ctx; - } - - cb = (nss_oam_msg_callback_t)ncm->cb; - if (unlikely(!cb)) { - nss_trace("%px: rx handler has been unregistered for i/f: %d", nss_ctx, ncm->interface); - return; - } - cb((void *)ncm->app_data, nom); -} - -/* - * nss_oam_tx() - * Transmit an oam message to the FW. - */ -nss_tx_status_t nss_oam_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_oam_msg *nom) -{ - struct nss_cmn_msg *ncm = &nom->cm; - - /* - * Trace Messages - */ - nss_oam_log_tx_msg(nom); - - if (ncm->type > NSS_OAM_MSG_TYPE_MAX) { - 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("%px: tx message request for another interface: %d", nss_ctx, ncm->interface); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, nom, sizeof(*nom), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_oam_tx_msg); - -/* - * nss_oam_notify_register() - * Register to receive OAM events. - */ -struct nss_ctx_instance *nss_oam_notify_register(nss_oam_msg_callback_t cb, void *app_data) -{ - if (nss_top_main.oam_ctx || nss_top_main.oam_callback) { - nss_warning("Failed to register notify callback - already registered\n"); - return NULL; - } - - nss_top_main.oam_ctx = app_data; - nss_top_main.oam_callback = cb; - return &nss_top_main.nss[nss_top_main.oam_handler_id]; -} -EXPORT_SYMBOL(nss_oam_notify_register); - -/* - * nss_oam_notify_unregister() - * Unregister to received OAM events. - */ -void nss_oam_notify_unregister(void) -{ - nss_top_main.oam_callback = NULL; - nss_top_main.oam_ctx = NULL; -} -EXPORT_SYMBOL(nss_oam_notify_unregister); - -/* - * nss_register_oam_handler() - * Register our handler to receive messages for this interface - */ -void nss_oam_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[nss_top_main.oam_handler_id]; - - if (nss_core_register_handler(nss_ctx, NSS_OAM_INTERFACE, nss_oam_rx_msg_handler, NULL) != NSS_CORE_STATUS_SUCCESS) { - nss_warning("OAM handler failed to register"); - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_oam_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_oam_log.c deleted file mode 100644 index 08ffec483..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_oam_log.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_oam_log.c - * NSS OAM logger file. - */ - -#include "nss_core.h" - -/* - * nss_oam_log_message_types_str - * NSS OAM message strings - */ -static int8_t *nss_oam_log_message_types_str[NSS_OAM_MSG_TYPE_MAX] __maybe_unused = { - "OAM Message None", - "OAM Get FW Version", -}; - -/* - * nss_oam_log_get_fw_version_msg() - * Log NSS OAM GET FW Version. - */ -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("%px: NSS OAM Get FW Version message \n" - "OAM FW Version: %px\n", - nofm, nofm->string); -} - -/* - * nss_oam_log_verbose() - * Log message contents. - */ -static void nss_oam_log_verbose(struct nss_oam_msg *nom) -{ - switch (nom->cm.type) { - case NSS_OAM_MSG_TYPE_GET_FW_VER: - nss_oam_log_get_fw_version_msg(nom); - break; - - default: - nss_trace("%px: Invalid message type\n", nom); - break; - } -} - -/* - * nss_oam_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_oam_log_tx_msg(struct nss_oam_msg *nom) -{ - if (nom->cm.type >= NSS_OAM_MSG_TYPE_MAX) { - nss_warning("%px: Invalid message type\n", nom); - return; - } - - 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); -} - -/* - * nss_oam_log_rx_msg() - * Log messages received from FW. - */ -void nss_oam_log_rx_msg(struct nss_oam_msg *nom) -{ - if (nom->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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]); - -verbose: - nss_oam_log_verbose(nom); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_oam_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_oam_log.h deleted file mode 100644 index b02611ba2..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_oam_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_OAM_LOG_H -#define __NSS_OAM_LOG_H - -/* - * nss_oam.h - * NSS OAM header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_oam_log_tx_msg - * Logs a oam message that is sent to the NSS firmware. - */ -void nss_oam_log_tx_msg(struct nss_oam_msg *nom); - -/* - * nss_oam_log_rx_msg - * Logs a oam message that is received from the NSS firmware. - */ -void nss_oam_log_rx_msg(struct nss_oam_msg *nom); - -#endif /* __NSS_OAM_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_phys_if.c b/feeds/ipq807x/qca-nss-drv/src/nss_phys_if.c deleted file mode 100644 index 4e5811a3e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_phys_if.c +++ /dev/null @@ -1,629 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_phy_if.c - * NSS physical interface functions - */ - -#include "nss_tx_rx_common.h" -#include "nss_tstamp.h" -#if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) -#include -#endif - -#define NSS_PHYS_IF_TX_TIMEOUT 3000 /* 3 Seconds */ - -/* - * NSS phys_if modes - */ -#define NSS_PHYS_IF_MODE0 0 /* phys_if mode 0 */ -#define NSS_PHYS_IF_MODE1 1 /* phys_if mode 1 */ -#define NSS_PHYS_IF_MODE2 2 /* phys_if mode 2 */ - -/* - * Private data structure for phys_if interface - */ -static struct nss_phys_if_pvt { - struct semaphore sem; - struct completion complete; - int response; -} phif; - -static int nss_phys_if_sem_init_done; - -/* - * nss_phys_if_update_driver_stats() - * Snoop the extended message and update driver statistics. - */ -static void nss_phys_if_update_driver_stats(struct nss_ctx_instance *nss_ctx, uint32_t id, struct nss_phys_if_stats *stats) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - uint64_t *top_stats = &(nss_top->stats_gmac[id][0]); - - spin_lock_bh(&nss_top->stats_lock); - top_stats[NSS_GMAC_STATS_TOTAL_TICKS] += stats->estats.gmac_total_ticks; - if (unlikely(top_stats[NSS_GMAC_STATS_WORST_CASE_TICKS] < stats->estats.gmac_worst_case_ticks)) { - top_stats[NSS_GMAC_STATS_WORST_CASE_TICKS] = stats->estats.gmac_worst_case_ticks; - } - top_stats[NSS_GMAC_STATS_ITERATIONS] += stats->estats.gmac_iterations; - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_phys_if_msg_handler() - * Handle NSS -> HLOS messages for physical interface/gmacs - */ -static void nss_phys_if_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, - __attribute__((unused))void *app_data) -{ - struct nss_phys_if_msg *nim = (struct nss_phys_if_msg *)ncm; - nss_phys_if_msg_callback_t cb; - - /* - * Sanity check the message type - */ - if (ncm->type > NSS_PHYS_IF_MAX_MSG_TYPES) { - nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); - return; - } - - if (!NSS_IS_IF_TYPE(PHYSICAL, 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("%px: message length too big: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Messages value that are within the base class are handled by the base class. - */ - if (ncm->type < NSS_IF_MAX_MSG_TYPES) { - return nss_if_msg_handler(nss_ctx, ncm, app_data); - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Snoop messages for local driver and handle deprecated interfaces. - */ - switch (nim->cm.type) { - case NSS_PHYS_IF_EXTENDED_STATS_SYNC: - /* - * To create the old API gmac statistics, we use the new extended GMAC stats. - */ - nss_phys_if_update_driver_stats(nss_ctx, ncm->interface, &nim->msg.stats); - nss_top_main.data_plane_ops->data_plane_stats_sync(&nim->msg.stats, ncm->interface); - break; - } - - /* - * Update the callback and app_data for NOTIFY messages, IPv4 sends all notify messages - * to the same callback/app_data. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->phys_if_msg_callback[ncm->interface]; - ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].ndev; - } - - /* - * Do we have a callback? - */ - if (!ncm->cb) { - return; - } - - /* - * Callback - */ - cb = (nss_phys_if_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, nim); -} - -/* - * nss_phys_if_callback - * Callback to handle the completion of NSS ->HLOS messages. - */ -static void nss_phys_if_callback(void *app_data, struct nss_phys_if_msg *nim) -{ - if(nim->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("phys_if Error response %d\n", nim->cm.response); - phif.response = NSS_TX_FAILURE; - complete(&phif.complete); - return; - } - - phif.response = NSS_TX_SUCCESS; - complete(&phif.complete); -} - -/* - * nss_phys_if_buf() - * Send packet to physical interface owned by NSS - */ -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("%px: Phys If Tx packet, id:%d, data=%px", nss_ctx, if_num, os_buf->data); - -#ifdef NSS_DRV_TSTAMP_ENABLE - /* - * If we need the packet to be timestamped by GMAC Hardware at Tx - * send the packet to tstamp NSS module - */ - if (unlikely(skb_shinfo(os_buf)->tx_flags & SKBTX_HW_TSTAMP)) { - /* try PHY Driver hook for transmit timestamping firstly */ -#if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) - nss_phy_tstamp_tx_buf(os_buf->dev, os_buf); -#endif - if (!(skb_shinfo(os_buf)->tx_flags & SKBTX_IN_PROGRESS)) - return nss_tstamp_tx_buf(nss_ctx, os_buf, if_num); - } -#endif - - return nss_core_send_packet(nss_ctx, os_buf, if_num, H2N_BIT_FLAG_BUFFER_REUSABLE); -} - -/* - * nss_phys_if_msg() - */ -nss_tx_status_t nss_phys_if_msg(struct nss_ctx_instance *nss_ctx, struct nss_phys_if_msg *nim) -{ - struct nss_cmn_msg *ncm = &nim->cm; - struct net_device *dev; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - /* - * Sanity check the message - */ - if (!NSS_IS_IF_TYPE(PHYSICAL, 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("%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("%px: Unregister physical interface %d: no context", nss_ctx, ncm->interface); - return NSS_TX_FAILURE_BAD_PARAM; - } - - return nss_core_send_cmd(nss_ctx, nim, sizeof(*nim), NSS_NBUF_PAYLOAD_SIZE); -} - -/* - * nss_phys_if_tx_msg_sync() - * Send a message to physical interface & wait for the response. - */ -nss_tx_status_t nss_phys_if_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_phys_if_msg *nim) -{ - nss_tx_status_t status; - int ret = 0; - - down(&phif.sem); - - status = nss_phys_if_msg(nss_ctx, nim); - if(status != NSS_TX_SUCCESS) - { - nss_warning("%px: nss_phys_if_msg failed\n", nss_ctx); - up(&phif.sem); - return status; - } - - ret = wait_for_completion_timeout(&phif.complete, msecs_to_jiffies(NSS_PHYS_IF_TX_TIMEOUT)); - - if(!ret) - { - nss_warning("%px: phys_if tx failed due to timeout\n", nss_ctx); - phif.response = NSS_TX_FAILURE; - } - - status = phif.response; - up(&phif.sem); - - return status; -} - -/* - ********************************** - Register/Unregister/Miscellaneous APIs - ********************************** - */ - -/* - * nss_phys_if_register() - */ -struct nss_ctx_instance *nss_phys_if_register(uint32_t if_num, - nss_phys_if_rx_callback_t rx_callback, - nss_phys_if_msg_callback_t msg_callback, - struct net_device *netdev, - uint32_t features) -{ - uint8_t id = nss_top_main.phys_if_handler_id[if_num]; - struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[id]; - - nss_assert(nss_ctx); - nss_assert(if_num <= NSS_MAX_PHYSICAL_INTERFACES); - - nss_core_register_subsys_dp(nss_ctx, if_num, rx_callback, NULL, NULL, netdev, features); - - nss_top_main.phys_if_msg_callback[if_num] = msg_callback; - - nss_ctx->phys_if_mtu[if_num] = ETH_DATA_LEN; - return nss_ctx; -} - -/* - * nss_phys_if_unregister() - */ -void nss_phys_if_unregister(uint32_t if_num) -{ - uint8_t id = nss_top_main.phys_if_handler_id[if_num]; - struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[id]; - - nss_assert(nss_ctx); - nss_assert(if_num < NSS_MAX_PHYSICAL_INTERFACES); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - nss_top_main.phys_if_msg_callback[if_num] = NULL; - - nss_top_main.nss[0].phys_if_mtu[if_num] = 0; - nss_top_main.nss[1].phys_if_mtu[if_num] = 0; -} - -/* - * nss_phys_if_register_handler() - */ -void nss_phys_if_register_handler(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - uint32_t ret; - - ret = nss_core_register_handler(nss_ctx, if_num, nss_phys_if_msg_handler, NULL); - - if (ret != NSS_CORE_STATUS_SUCCESS) { - nss_warning("Message handler FAILED to be registered for interface %d", if_num); - return; - } - - if(!nss_phys_if_sem_init_done) { - sema_init(&phif.sem, 1); - init_completion(&phif.complete); - nss_phys_if_sem_init_done = 1; - } -} - -/* - * nss_phys_if_open() - * Send open command to physical interface - */ -nss_tx_status_t nss_phys_if_open(struct nss_ctx_instance *nss_ctx, uint32_t tx_desc_ring, uint32_t rx_desc_ring, uint32_t mode, uint32_t if_num, uint32_t bypass_nw_process) -{ - struct nss_phys_if_msg nim; - struct nss_if_open *nio; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - 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); - - nio = &nim.msg.if_msg.open; - nio->tx_desc_ring = tx_desc_ring; - nio->rx_desc_ring = rx_desc_ring; - - if (mode == NSS_PHYS_IF_MODE0) { - nio->rx_forward_if = NSS_ETH_RX_INTERFACE; - nio->alignment_mode = NSS_IF_DATA_ALIGN_2BYTE; - } else if (mode == NSS_PHYS_IF_MODE1) { - nio->rx_forward_if = NSS_SJACK_INTERFACE; - nio->alignment_mode = NSS_IF_DATA_ALIGN_4BYTE; - } else if (mode == NSS_PHYS_IF_MODE2) { - nio->rx_forward_if = NSS_PORTID_INTERFACE; - nio->alignment_mode = NSS_IF_DATA_ALIGN_2BYTE; - } else { - nss_info("%px: Phys If Open, unknown mode %d\n", nss_ctx, mode); - return NSS_TX_FAILURE; - } - - /* - * If Network processing in NSS is bypassed - * update next hop and alignment accordingly - */ - if (bypass_nw_process) { - nio->rx_forward_if = NSS_N2H_INTERFACE; - nio->alignment_mode = NSS_IF_DATA_ALIGN_2BYTE; - } - - return nss_phys_if_msg_sync(nss_ctx, &nim); -} - -/* - * nss_phys_if_close() - * Send close command to physical interface - */ -nss_tx_status_t nss_phys_if_close(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - struct nss_phys_if_msg nim; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - 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); - - return nss_phys_if_msg_sync(nss_ctx, &nim); -} - -/* - * nss_phys_if_link_state() - * Send link state to physical interface - */ -nss_tx_status_t nss_phys_if_link_state(struct nss_ctx_instance *nss_ctx, uint32_t link_state, uint32_t if_num) -{ - struct nss_phys_if_msg nim; - struct nss_if_link_state_notify *nils; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - 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); - - nils = &nim.msg.if_msg.link_state_notify; - nils->state = link_state; - return nss_phys_if_msg_sync(nss_ctx, &nim); -} - -/* - * nss_phys_if_mac_addr() - * Send a MAC address to physical interface - */ -nss_tx_status_t nss_phys_if_mac_addr(struct nss_ctx_instance *nss_ctx, uint8_t *addr, uint32_t if_num) -{ - struct nss_phys_if_msg nim; - struct nss_if_mac_address_set *nmas; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - 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, - sizeof(struct nss_if_mac_address_set), nss_phys_if_callback, NULL); - - nmas = &nim.msg.if_msg.mac_address_set; - memcpy(nmas->mac_addr, addr, ETH_ALEN); - return nss_phys_if_msg_sync(nss_ctx, &nim); -} - -/* - * nss_phys_if_change_mtu() - * Send a MTU change command - */ -nss_tx_status_t nss_phys_if_change_mtu(struct nss_ctx_instance *nss_ctx, uint32_t mtu, uint32_t if_num) -{ - struct nss_phys_if_msg nim; - struct nss_if_mtu_change *nimc; - uint16_t mtu_sz, max_mtu; - int i; - nss_tx_status_t status; - -/* - * We disallow MTU changes for low memory profiles in order to keep the buffer size constant - */ -#ifdef NSS_FIXED_BUFFER_SIZE - if (mtu > ETH_DATA_LEN) { - nss_info_always("MTU change beyond 1500 restricted for low memory profile \n"); - return NSS_TX_FAILURE; - } -#endif - NSS_VERIFY_CTX_MAGIC(nss_ctx); - 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); - - nimc = &nim.msg.if_msg.mtu_change; - nimc->min_buf_size = mtu; - - status = nss_phys_if_msg_sync(nss_ctx, &nim); - if (status != NSS_TX_SUCCESS) { - return status; - } - - /* - * Update the mtu and max_buf_size accordingly - */ - nss_ctx->phys_if_mtu[if_num] = (uint16_t)mtu; - - /* - * Loop through MTU values of all Physical - * interfaces and get the maximum one of all - */ - max_mtu = nss_ctx->phys_if_mtu[0]; - for (i = 1; i < NSS_MAX_PHYSICAL_INTERFACES; i++) { - if (max_mtu < nss_ctx->phys_if_mtu[i]) { - max_mtu = nss_ctx->phys_if_mtu[i]; - } - } - - mtu_sz = nss_top_main.data_plane_ops->data_plane_get_mtu_sz(max_mtu); - -/* - * We need to ensure the max_buf_size for 256MB profile stays - * constant at NSS_EMPTY_BUFFER_SIZE. We do this by disallowing changes - * to it due to MTU changes. Also, NSS_EMPTY_BUFFER_SIZE includes the - * PAD and ETH_HLEN, and is aligned to SMP_CACHE_BYTES - */ -#ifndef NSS_FIXED_BUFFER_SIZE - nss_ctx->max_buf_size = ((mtu_sz + ETH_HLEN + SMP_CACHE_BYTES - 1) & ~(SMP_CACHE_BYTES - 1)) + NSS_NBUF_ETH_EXTRA + NSS_NBUF_PAD_EXTRA; - - /* - * max_buf_size should not be lesser than NSS_NBUF_PAYLOAD_SIZE - */ - if (nss_ctx->max_buf_size < NSS_NBUF_PAYLOAD_SIZE) { - nss_ctx->max_buf_size = NSS_NBUF_PAYLOAD_SIZE; - } -#else - 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)); -#endif - - nss_info("Current mtu:%u mtu_sz:%u max_buf_size:%d\n", mtu, mtu_sz, nss_ctx->max_buf_size); - - if (mtu_sz > nss_ctx->nss_top->prev_mtu_sz) { - - /* If crypto is enabled on platform - * Send the flush payloads message - */ - if (nss_ctx->nss_top->crypto_enabled) { - if (nss_n2h_flush_payloads(nss_ctx) != NSS_TX_SUCCESS) { - nss_info("Unable to send flush payloads command to NSS\n"); - } - } - } - nss_ctx->nss_top->prev_mtu_sz = mtu_sz; - - return status; -} - -/* - * nss_phys_if_vsi_assign() - * Send a vsi assign to physical interface - */ -nss_tx_status_t nss_phys_if_vsi_assign(struct nss_ctx_instance *nss_ctx, uint32_t vsi, uint32_t if_num) -{ - struct nss_phys_if_msg nim; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - nss_info("%px: Phys If VSI Assign, id:%d\n", nss_ctx, if_num); - - memset(&nim, 0, sizeof(struct nss_phys_if_msg)); - - nss_cmn_msg_init(&nim.cm, if_num, NSS_PHYS_IF_VSI_ASSIGN, - sizeof(struct nss_if_vsi_assign), nss_phys_if_callback, NULL); - - nim.msg.if_msg.vsi_assign.vsi = vsi; - return nss_phys_if_msg_sync(nss_ctx, &nim); -} - -/* - * nss_phys_if_vsi_unassign() - * Send a vsi unassign to physical interface - */ -nss_tx_status_t nss_phys_if_vsi_unassign(struct nss_ctx_instance *nss_ctx, uint32_t vsi, uint32_t if_num) -{ - struct nss_phys_if_msg nim; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - nss_info("%px: Phys If VSI Unassign, id:%d\n", nss_ctx, if_num); - - memset(&nim, 0, sizeof(struct nss_phys_if_msg)); - - nss_cmn_msg_init(&nim.cm, if_num, NSS_PHYS_IF_VSI_UNASSIGN, - sizeof(struct nss_if_vsi_unassign), nss_phys_if_callback, NULL); - - nim.msg.if_msg.vsi_unassign.vsi = vsi; - return nss_phys_if_msg_sync(nss_ctx, &nim); -} - -/* - * nss_phys_if_pause_on_off() - * Send a pause enabled/disabled message to GMAC - */ -nss_tx_status_t nss_phys_if_pause_on_off(struct nss_ctx_instance *nss_ctx, uint32_t pause_on, uint32_t if_num) -{ - struct nss_phys_if_msg nim; - struct nss_if_pause_on_off *nipe; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - 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); - - nipe = &nim.msg.if_msg.pause_on_off; - nipe->pause_on = pause_on; - - return nss_phys_if_msg_sync(nss_ctx, &nim); -} - -/* - * 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 - */ -nss_tx_status_t nss_phys_if_set_nexthop(struct nss_ctx_instance *nss_ctx, uint32_t if_num, uint32_t nexthop) -{ - struct nss_phys_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_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); - nim.msg.if_msg.set_nexthop.nexthop = nexthop; - - return nss_phys_if_msg_sync(nss_ctx, &nim); -} -EXPORT_SYMBOL(nss_phys_if_set_nexthop); - -/* - * nss_get_state() - * Return the NSS initialization state - */ -nss_state_t nss_get_state(void *ctx) -{ - return nss_cmn_get_state(ctx); -} - -EXPORT_SYMBOL(nss_get_state); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_phys_if.h b/feeds/ipq807x/qca-nss-drv/src/nss_phys_if.h deleted file mode 100644 index 0df6bc32f..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_phys_if.h +++ /dev/null @@ -1,326 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_phys_if - * Physical interface message structure - */ - -#ifndef __NSS_PHYS_IF_H -#define __NSS_PHYS_IF_H - -/** - * Physical IF - */ - -/** - * The NSS per-GMAC statistics sync structure. - */ -struct nss_phys_if_estats { - uint32_t rx_errors; /**< Number of RX errors */ - uint32_t rx_receive_errors; /**< Number of RX receive errors */ - uint32_t rx_descriptor_errors; /**< Number of RX descriptor errors */ - uint32_t rx_late_collision_errors; - /**< Number of RX late collision errors */ - uint32_t rx_dribble_bit_errors; /**< Number of RX dribble bit errors */ - uint32_t rx_length_errors; /**< Number of RX length errors */ - uint32_t rx_ip_header_errors; /**< Number of RX IP header errors */ - uint32_t rx_ip_payload_errors; /**< Number of RX IP payload errors */ - uint32_t rx_no_buffer_errors; /**< Number of RX no-buffer errors */ - uint32_t rx_transport_csum_bypassed; - /**< Number of RX packets where the transport checksum was bypassed */ - uint32_t tx_collisions; /**< Number of TX collisions */ - uint32_t tx_errors; /**< Number of TX errors */ - uint32_t tx_jabber_timeout_errors; - /**< Number of TX jabber timeout errors */ - uint32_t tx_frame_flushed_errors; - /**< Number of TX frame flushed errors */ - uint32_t tx_loss_of_carrier_errors; - /**< Number of TX loss of carrier errors */ - uint32_t tx_no_carrier_errors; /**< Number of TX no carrier errors */ - uint32_t tx_late_collision_errors; - /**< Number of TX late collision errors */ - uint32_t tx_excessive_collision_errors; - /**< Number of TX excessive collision errors */ - uint32_t tx_excessive_deferral_errors; - /**< Number of TX excessive deferral errors */ - uint32_t tx_underflow_errors; /**< Number of TX underflow errors */ - uint32_t tx_ip_header_errors; /**< Number of TX IP header errors */ - uint32_t tx_ip_payload_errors; /**< Number of TX IP payload errors */ - uint32_t tx_dropped; /**< Number of TX dropped packets */ - uint32_t hw_errs[10]; /**< GMAC DMA error counters */ - uint32_t rx_missed; /**< Number of RX packets missed by the DMA */ - uint32_t fifo_overflows; /**< Number of RX FIFO overflows signalled by the DMA */ - uint32_t rx_scatter_errors; /**< Number of scattered frames received by the DMA */ - uint32_t tx_ts_create_errors; /**< Number of tx timestamp creation errors */ - uint32_t gmac_total_ticks; /**< Total clock ticks spend inside the GMAC */ - 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 */ - uint32_t mmc_rx_overflow_errors; - /**< Number of RX overflow errors */ - uint32_t mmc_rx_watchdog_timeout_errors; - /**< Number of RX watchdog timeout errors */ - uint32_t mmc_rx_crc_errors; /**< Number of RX CRC errors */ - uint32_t mmc_rx_ip_header_errors; - /**< Number of RX IP header errors */ - uint32_t mmc_rx_octets_g; /* Number of good octets received */ - uint32_t mmc_rx_ucast_frames; /* Number of Unicast frames received */ - uint32_t mmc_rx_bcast_frames; /* Number of Bcast frames received */ - uint32_t mmc_rx_mcast_frames; /* Number of Mcast frames received */ - uint32_t mmc_rx_undersize; /* Number of RX undersize frames */ - uint32_t mmc_rx_oversize; /* Number of RX oversize frames */ - uint32_t mmc_rx_jabber; /* Number of jabber frames */ - uint32_t mmc_rx_octets_gb; /* Number of good/bad octets */ - uint32_t mmc_rx_frag_frames_g; /* Number of good ipv4 frag frames */ - uint32_t mmc_tx_octets_g; /* Number of good octets sent */ - uint32_t mmc_tx_ucast_frames; /* Number of Unicast frames sent*/ - uint32_t mmc_tx_bcast_frames; /* Number of Broadcast frames sent */ - uint32_t mmc_tx_mcast_frames; /* Number of Multicast frames sent */ - uint32_t mmc_tx_deferred; /* Number of Deferred frames sent */ - 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*/ -}; - -/** - * The NSS GMAC statistics sync structure. - */ -struct nss_phys_if_stats { - struct nss_cmn_node_stats if_stats; /**< Generic interface stats */ - struct nss_phys_if_estats estats; /**< Extended Statistics specific to GMAC */ -}; - -/** - * @brief Request/Response types - */ -enum nss_phys_if_msg_types { - NSS_PHYS_IF_OPEN = NSS_IF_OPEN, - NSS_PHYS_IF_CLOSE = NSS_IF_CLOSE, - NSS_PHYS_IF_LINK_STATE_NOTIFY = NSS_IF_LINK_STATE_NOTIFY, - NSS_PHYS_IF_MTU_CHANGE = NSS_IF_MTU_CHANGE, - NSS_PHYS_IF_MAC_ADDR_SET = NSS_IF_MAC_ADDR_SET, - NSS_PHYS_IF_STATS = NSS_IF_STATS, - NSS_PHYS_IF_ISHAPER_ASSIGN = NSS_IF_ISHAPER_ASSIGN, - NSS_PHYS_IF_BSHAPER_ASSIGN = NSS_IF_BSHAPER_ASSIGN, - NSS_PHYS_IF_ISHAPER_UNASSIGN = NSS_IF_ISHAPER_UNASSIGN, - NSS_PHYS_IF_BSHAPER_UNASSIGN = NSS_IF_BSHAPER_UNASSIGN, - NSS_PHYS_IF_ISHAPER_CONFIG = NSS_IF_ISHAPER_CONFIG, - NSS_PHYS_IF_BSHAPER_CONFIG = NSS_IF_BSHAPER_CONFIG, - NSS_PHYS_IF_PAUSE_ON_OFF = NSS_IF_PAUSE_ON_OFF, - 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 -}; - -/** - * Message structure to send/receive physical interface commands - * - * NOTE: Do not adjust the location of if_msg relative to new - * message types as it represents the base messages for all - * intefaces. - */ -struct nss_phys_if_msg { - struct nss_cmn_msg cm; /**< Message Header */ - union { - union nss_if_msgs if_msg; /**< Interfaces messages */ - struct nss_phys_if_stats stats; /**< Phys If Statistics */ - } msg; -}; - -/** - * @brief Callback to receive physical interface messages - * - * @param app_data Application context for this message - * @param msg NSS physical interface message - * - * @return void - */ -typedef void (*nss_phys_if_msg_callback_t)(void *app_data, struct nss_phys_if_msg *msg); - -/** - * @brief Callback to send physical interface data to the tranmsit path. - * - * @param netdev Net device - * @param skb Data buffer - * - * @return void - */ -typedef void (*nss_phys_if_xmit_callback_t)(struct net_device *netdev, struct sk_buff *skb); - -/** - * @brief Callback to receive physical interface data - * TODO: Adjust to pass app_data as unknown to the - * list layer and netdev/sk as known. - * - * @param app_data Application context for this message - * @param os_buf Data buffer - * - * @return void - */ -typedef void (*nss_phys_if_rx_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * @brief Callback to recieve extended data plane packet on interface. - * - * @param app_data Application context for this message - * @param skb Data buffer - * @param napi napi pointer - * - * @return void - */ -typedef void (*nss_phys_if_rx_ext_data_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - -/** - * @brief Register to send/receive GMAC packets/messages - * - * @param if_num GMAC i/f number - * @param rx_callback Receive callback for packets - * @param event_callback Receive callback for events - * @param netdev netdevice associated with this interface. - * @param features denote the skb types supported by this interface - * - * @return void* NSS context - */ -struct nss_ctx_instance *nss_phys_if_register(uint32_t if_num, - nss_phys_if_rx_callback_t rx_callback, - nss_phys_if_msg_callback_t msg_callback, - struct net_device *netdev, - uint32_t features); - -/** - * @brief Send GMAC packet - * - * @param nss_ctx NSS context - * @param os_buf OS buffer (e.g. skbuff) - * @param if_num GMAC i/f number - * - * @return nss_tx_status_t Tx status - */ -nss_tx_status_t nss_phys_if_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, uint32_t if_num); - -/** - * @brief Send message to physical interface - * - * @param nim Physical interface message - * - * @return command Tx status - */ -nss_tx_status_t nss_phys_if_msg(struct nss_ctx_instance *nss_ctx, struct nss_phys_if_msg *nim); - -/** - * @brief Send a message to physical interface & wait for the response. - * - * @param nim Physical interface message - * - * @return command Tx status - */ -nss_tx_status_t nss_phys_if_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_phys_if_msg *nim); - -/** - * @brief Open GMAC interface on NSS - * - * @param nss_ctx NSS context - * @param tx_desc_ring Tx descriptor ring address - * @param rx_desc_ring Rx descriptor ring address - * @param if_num GMAC i/f number - * @param bypass_nw_process network processing in nss is bypassed for GMAC - * - * @return nss_tx_status_t Tx status - */ -nss_tx_status_t nss_phys_if_open(struct nss_ctx_instance *nss_ctx, uint32_t tx_desc_ring, uint32_t rx_desc_ring, uint32_t mode, uint32_t if_num, - uint32_t bypass_nw_process); - -/** - * @brief Close GMAC interface on NSS - * - * @param nss_ctx NSS context - * @param if_num GMAC i/f number - * - * @return nss_tx_status_t Tx status - */ -nss_tx_status_t nss_phys_if_close(struct nss_ctx_instance *nss_ctx, uint32_t if_num); - -/** - * @brief Send link state message to NSS - * - * @param nss_ctx NSS context - * @param link_state Link state - * @param if_num GMAC i/f number - * - * @return nss_tx_status_t Tx status - */ -nss_tx_status_t nss_phys_if_link_state(struct nss_ctx_instance *nss_ctx, uint32_t link_state, uint32_t if_num); - -/** - * @brief Send MAC address to NSS - * - * @param nss_ctx NSS context - * @param addr MAC address pointer - * @param if_num GMAC i/f number - * - * @return nss_tx_status_t Tx status - */ -nss_tx_status_t nss_phys_if_mac_addr(struct nss_ctx_instance *nss_ctx, uint8_t *addr, uint32_t if_num); - -/** - * @brief Send MTU change notification to NSS - * - * @param nss_ctx NSS context - * @param mtu MTU - * @param if_num GMAC i/f number - * - * @return nss_tx_status_t Tx status - */ -nss_tx_status_t nss_phys_if_change_mtu(struct nss_ctx_instance *nss_ctx, uint32_t mtu, uint32_t if_num); - -/** - * @brief Send vsi assign to NSS - * - * @param nss_ctx NSS context - * @param vsi VSI number - * @param if_num GMAC i/f number - * - * @return nss_tx_status_t Tx status - */ -nss_tx_status_t nss_phys_if_vsi_assign(struct nss_ctx_instance *nss_ctx, uint32_t vsi, uint32_t if_num); - -/** - * @brief Send vsi unassign to NSS - * - * @param nss_ctx NSS context - * @param vsi VSI number - * @param if_num GMAC i/f number - * - * @return nss_tx_status_t Tx status - */ -nss_tx_status_t nss_phys_if_vsi_unassign(struct nss_ctx_instance *nss_ctx, uint32_t vsi, uint32_t if_num); - -/** - * @brief Send pause frame enabled notification to NSS - * - * @param nss_ctx NSS context - * @param pause_on Pause on or off - * @param if_num GMAC i/f number - * - * @return nss_tx_status_t Tx status - */ -nss_tx_status_t nss_phys_if_pause_on_off(struct nss_ctx_instance *nss_ctx, uint32_t pause_on, uint32_t if_num); - -#endif /* __NSS_PHYS_IF_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pm.c b/feeds/ipq807x/qca-nss-drv/src/nss_pm.c deleted file mode 100644 index 75527cddb..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pm.c +++ /dev/null @@ -1,447 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2014-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. - ************************************************************************** - */ - -/* - * nss_pm.c - * NSS Power Management APIs - * - */ -#include -#include -#include -#include -#include - -#if (NSS_DT_SUPPORT != 1) -#include -#endif - -#if (NSS_PM_SUPPORT == 1) -#include "nss_pm.h" - -/* - * Global NSS PM structure - */ -struct nss_pm_global_ctx ctx; - -/* - * Bus vector table for GMAC driver - */ -static struct msm_bus_paths nss_gmac_bw_level_tbl[NSS_PM_PERF_MAX_LEVELS] = { - [NSS_PM_PERF_LEVEL_SUSPEND] = GMAC_BW_MBPS(0, 0), - /* 0 MHz to DDR, 0 MHz to TCM */ - [NSS_PM_PERF_LEVEL_IDLE] = GMAC_BW_MBPS(133, 5), - /* 133 MHz to DDR, 5 MHz to TCM */ - [NSS_PM_PERF_LEVEL_NOMINAL] = GMAC_BW_MBPS(200, 400), - /* 200 MHz to DDR, 10 MHz to TCM */ - [NSS_PM_PERF_LEVEL_TURBO] = GMAC_BW_MBPS(266, 533), - /* 266 MHz to DDR, 20 MHz to TCM */ -}; - -/* - * Bus vector table for Crypto driver - */ -static struct msm_bus_paths nss_crypto_bw_level_tbl[NSS_PM_PERF_MAX_LEVELS] = { - [NSS_PM_PERF_LEVEL_SUSPEND] = CRYPTO_BW_MBPS(0, 0), - /* 0 MHz to DDR, 0 MHz to TCM */ - [NSS_PM_PERF_LEVEL_IDLE] = CRYPTO_BW_MBPS(133, 5), - /* 133 MHz to DDR, 5 MHz to TCM */ - [NSS_PM_PERF_LEVEL_NOMINAL] = CRYPTO_BW_MBPS(200, 400), - /* 200 MHz to DDR, 10 MHz to TCM */ - [NSS_PM_PERF_LEVEL_TURBO] = CRYPTO_BW_MBPS(266, 533), - /* 266 MHz to DDR, 20 MHz to TCM */ -}; - -#ifdef NSS_PM_NETAP_GMAC_SCALING - -/* - * Bus vector table for NSS HLOS driver - * This requests bw for both NSS Fab0 and Fab1 on behalf of GMAC and NSS Drivers - */ -static struct msm_bus_paths nss_netap_bw_level_tbl[NSS_PM_PERF_MAX_LEVELS] = { - [NSS_PM_PERF_LEVEL_SUSPEND] = GMAC_BW_MBPS(0, 0), - /* 0 MHz to DDR, 0 MHz to TCM */ - [NSS_PM_PERF_LEVEL_IDLE] = GMAC_BW_MBPS(122, 122), - /* 133 MHz to DDR and TCM */ - [NSS_PM_PERF_LEVEL_NOMINAL] = GMAC_BW_MBPS(200, 200), - /* 400 MHz to DDR and TCM */ - [NSS_PM_PERF_LEVEL_TURBO] = GMAC_BW_MBPS(400, 400), - /* 533 MHz to DDR and TCM */ -}; - -#else - -/* - * Bus vector table for NSS HLOS driver - */ -static struct msm_bus_paths nss_netap_bw_level_tbl[NSS_PM_PERF_MAX_LEVELS] = { - [NSS_PM_PERF_LEVEL_SUSPEND] = NETAP_BW_MBPS(0, 0), - /* 0 MHz to DDR, 0 MHz to TCM */ - [NSS_PM_PERF_LEVEL_IDLE] = NETAP_BW_MBPS(133, 133), - /* 133 MHz to DDR and TCM */ - [NSS_PM_PERF_LEVEL_NOMINAL] = NETAP_BW_MBPS(400, 400), - /* 400 MHz to DDR and TCM */ - [NSS_PM_PERF_LEVEL_TURBO] = NETAP_BW_MBPS(533, 533), - /* 533 MHz to DDR and TCM */ -}; - -#endif - -/* - * Bus Driver Platform data for GMAC, Crypto and Netap clients - */ -static struct msm_bus_scale_pdata nss_bus_scale[] = { - [NSS_PM_CLIENT_GMAC] = { - .usecase = nss_gmac_bw_level_tbl, - .num_usecases = ARRAY_SIZE(nss_gmac_bw_level_tbl), - .active_only = 1, - .name = "qca-nss-gmac", - }, - - [NSS_PM_CLIENT_CRYPTO] = { - .usecase = nss_crypto_bw_level_tbl, - .num_usecases = ARRAY_SIZE(nss_crypto_bw_level_tbl), - .active_only = 1, - .name = "qca-nss-crypto", - }, - - [NSS_PM_CLIENT_NETAP] = { - .usecase = nss_netap_bw_level_tbl, - .num_usecases = ARRAY_SIZE(nss_netap_bw_level_tbl), - .active_only = 1, - .name = "qca-nss-drv", - }, -}; - -/* - * nss_pm_dbg_perf_level_get - * debugfs hook to get the current performance level - */ -static int nss_pm_dbg_perf_level_get(void *data, u64 *val) -{ - nss_pm_client_data_t *pm_client; - - pm_client = (nss_pm_client_data_t *)data; - *val = pm_client->current_perf_lvl; - - return NSS_PM_API_SUCCESS; -} - -/* - * nss_pm_dbg_autoscale_get - * debugfs hook to get the current autoscale setting - */ -static int nss_pm_dbg_autoscale_get(void *data, u64 *val) -{ - nss_pm_client_data_t *pm_client; - - pm_client = (nss_pm_client_data_t *)data; - *val = pm_client->auto_scale; - - return NSS_PM_API_SUCCESS; -} - -/* - * nss_pm_dbg_perf_level_set - * debugfs hook to set perf level for a client - */ -static int nss_pm_dbg_perf_level_set(void *data, u64 val) -{ - uint32_t perf_level; - - perf_level = (uint32_t) val; - - if (perf_level >= NSS_PM_PERF_MAX_LEVELS || - perf_level < NSS_PM_PERF_LEVEL_IDLE) { - nss_pm_warning("unsupported performance level %d \n", perf_level); - return NSS_PM_API_FAILED; - } - - nss_pm_set_perf_level(data, perf_level); - return NSS_PM_API_SUCCESS; -} - -/* - * nss_pm_dbg_autoscale_set - * debugfs hook to enable auto scaling for a client - */ -static int nss_pm_dbg_autoscale_set(void *data, u64 val) -{ - nss_pm_client_data_t *pm_client; - - if (val > 1) { - nss_pm_warning(" Invalid set value, valid values are 0/1 \n"); - return NSS_PM_API_FAILED; - } - - pm_client->auto_scale = (uint32_t)val; - return NSS_PM_API_SUCCESS; -} - -DEFINE_SIMPLE_ATTRIBUTE(perf_level_fops, nss_pm_dbg_perf_level_get, nss_pm_dbg_perf_level_set, "%llu\n"); - -DEFINE_SIMPLE_ATTRIBUTE(autoscale_fops, nss_pm_dbg_autoscale_get, nss_pm_dbg_autoscale_set, "%llu\n"); -#endif /** (NSS_PM_SUPPORT == 1) */ - -/* - * nss_pm_client_register - * Initialize GMAC specific PM parameters - * - * Creates debugfs hooks for user-space control of NSS Client PM - * Initializes Bus BW to Idle Perf level - * Returns PM handle to the caller. - * - */ -void *nss_pm_client_register(nss_pm_client_t client_id) -{ -#if (NSS_PM_SUPPORT == 1) - int ret; - struct dentry *pm_dentry; - nss_pm_client_data_t *pm_client; - - if (unlikely(client_id >= NSS_PM_MAX_CLIENTS)) { - nss_pm_warning("nss_pm_client_register invalid client id %d \n", client_id); - goto error; - } - - pm_client = &ctx.nss_pm_client[client_id]; - - pm_client->bus_perf_client = msm_bus_scale_register_client(&nss_bus_scale[client_id]); - if (!pm_client->bus_perf_client) { - nss_pm_warning("unable to register bus client \n"); - goto error; - } - - ret = msm_bus_scale_client_update_request(pm_client->bus_perf_client, NSS_PM_PERF_LEVEL_IDLE); - if (ret) { - nss_pm_warning("initial bandwidth req failed (%d)\n", ret); - msm_bus_scale_unregister_client((uint32_t) pm_client->bus_perf_client); - goto error; - } - - pm_client->current_perf_lvl = NSS_PM_PERF_LEVEL_IDLE; - - switch (client_id) { - case NSS_PM_CLIENT_GMAC: - pm_dentry = debugfs_create_dir("gmac" , ctx.pm_dentry); - break; - - case NSS_PM_CLIENT_CRYPTO: - pm_dentry = debugfs_create_dir("crypto" , ctx.pm_dentry); - break; - - case NSS_PM_CLIENT_NETAP: - pm_dentry = debugfs_create_dir("netap" , ctx.pm_dentry); - break; - - default: - nss_pm_warning("debugfs create failed invalid client id %d \n", client_id); - msm_bus_scale_unregister_client((uint32_t) pm_client->bus_perf_client); - goto error; - - } - - if (unlikely(pm_dentry == NULL)) { - nss_pm_info("debugfs not created for %d client pm \n", client_id); - goto out; - } - - pm_client->dentry = pm_dentry; - pm_client->client_id = client_id; - - if (!debugfs_create_file("perf_level", S_IRUGO | S_IWUSR, pm_dentry, pm_client, &perf_level_fops)) { - nss_pm_info("debugfs perf_level file not created for %d client pm \n", client_id); - } - - if (!debugfs_create_file("auto-scale", S_IRUGO | S_IWUSR, pm_dentry, pm_client, &autoscale_fops)) { - nss_pm_info("debugfs auto-scale file not created for %d client pm \n", client_id); - } - -out: - return (void *)pm_client; -error: -#endif - return NULL; -} -EXPORT_SYMBOL(nss_pm_client_register); - -/* - * nss_pm_client_unregister - * Unregister the client for any PM operations - */ -int nss_pm_client_unregister(nss_pm_client_t client_id) -{ -#if (NSS_PM_SUPPORT == 1) - nss_pm_client_data_t *pm_client; - - if (unlikely(client_id >= NSS_PM_MAX_CLIENTS)) { - nss_pm_warning("nss_pm_client_unregister invalid client id %d \n", client_id); - goto error; - } - - pm_client = &ctx.nss_pm_client[client_id]; - - if (unlikely(pm_client == NULL)) { - nss_pm_warning("nss_pm_client_unregister client not registered %d \n", client_id); - goto error; - } - - if (pm_client->bus_perf_client) { - msm_bus_scale_unregister_client((uint32_t) pm_client->bus_perf_client); - } else { - nss_pm_info("nss_pm_client_unregister: client not registered \n"); - } - - if (likely(pm_client->dentry != NULL)) { - debugfs_remove_recursive(pm_client->dentry); - } - - return NSS_PM_API_SUCCESS; - -error: -#endif - return NSS_PM_API_FAILED; -} - -/* - * nss_pm_set_perf_level() - * Sets the performance level of client specific Fabrics and Clocks to requested level - */ -nss_pm_interface_status_t nss_pm_set_perf_level(void *handle, nss_pm_perf_level_t lvl) -{ -#if ((NSS_DT_SUPPORT == 1) && (NSS_FREQ_SCALE_SUPPORT == 1)) - nss_freq_scales_t index; - - switch (lvl) { - case NSS_PM_PERF_LEVEL_TURBO: - index = NSS_FREQ_HIGH_SCALE; - break; - - case NSS_PM_PERF_LEVEL_NOMINAL: - index = NSS_FREQ_MID_SCALE; - break; - - default: - index = NSS_PM_PERF_LEVEL_IDLE; - } - -#if !defined(NSS_HAL_IPQ807x_SUPPORT) - nss_freq_sched_change(index, false); -#endif - -#elif (NSS_PM_SUPPORT == 1) - - int ret = 0; - nss_pm_client_data_t *pm_client; - - pm_client = (nss_pm_client_data_t *) handle; - if (pm_client->current_perf_lvl == lvl) { - nss_pm_trace("Already at perf level %d , ignoring request \n", lvl); - return NSS_PM_API_SUCCESS; - } - - if (!pm_client->bus_perf_client) { - nss_pm_warning("Bus driver client not registered.request failed \n"); - return NSS_PM_API_FAILED; - } - - /* - * Do client specific operations here - */ - if (pm_client->client_id == NSS_PM_CLIENT_NETAP) { - if ((lvl == NSS_PM_PERF_LEVEL_TURBO) && (ctx.turbo_support == true)) { - /* - * For turbo perf level, switch TCM source to - * SRC1 to set TCM clock = 400 MHz - * SRC0 and SRC1 are set to 266 and 400 MHz resp. - * in nss_hal/ipq806x/nss_hal_pvt.c - */ - writel(0x3, NSSTCM_CLK_SRC_CTL); - } else { - /* - * For Nominal and Idle perf level, switch to SRC0 to - * set TCM clock = 266 MHz - */ - writel(0x2, NSSTCM_CLK_SRC_CTL); - - if (lvl == NSS_PM_PERF_LEVEL_TURBO) { - lvl = NSS_PM_PERF_LEVEL_NOMINAL; - } - } - } - - if (pm_client->client_id == NSS_PM_CLIENT_CRYPTO) { - if ((lvl == NSS_PM_PERF_LEVEL_TURBO) && (ctx.turbo_support == true)) { - /* - * For Turbo mode, set Crypto core and - * Fabric port clocks to 213 MHz - */ - writel(0x23, CE5_ACLK_SRC0_NS); - writel(0x23, CE5_HCLK_SRC0_NS); - writel(0x23, CE5_CORE_CLK_SRC0_NS); - - writel(0x2, CE5_ACLK_SRC_CTL); - writel(0x2, CE5_HCLK_SRC_CTL); - writel(0x2, CE5_CORE_CLK_SRC_CTL); - } else { - lvl = NSS_PM_PERF_LEVEL_NOMINAL; - } - } - - /* Update bandwidth if request has changed. This may sleep. */ - ret = msm_bus_scale_client_update_request(pm_client->bus_perf_client, lvl); - if (ret) { - nss_pm_warning("bandwidth request failed (%d)\n", ret); - return NSS_PM_API_FAILED; - } - - nss_pm_info("perf level request, current: %d new: %d \n", pm_client->current_perf_lvl, lvl); - pm_client->current_perf_lvl = lvl; -#endif - - return NSS_PM_API_SUCCESS; -} -EXPORT_SYMBOL(nss_pm_set_perf_level); - -#if (NSS_PM_SUPPORT == 1) -/* - * nss_pm_set_turbo() - * Sets the turbo support flag globally for all clients - */ -void nss_pm_set_turbo() { - - nss_pm_info("NSS Bus PM - Platform supports Turbo Mode \n"); - ctx.turbo_support = true; -} - -/* - * nss_pm_init() - * Initialize NSS PM top level structures - */ -void nss_pm_init(void) { - - nss_pm_info("NSS Bus PM (platform - IPQ806x, build - %s:%s)\n", __DATE__, __TIME__); - - ctx.pm_dentry = debugfs_create_dir("qca-nss-pm", NULL); - - /* Default turbo support is set to off */ - ctx.turbo_support = false; - - if (unlikely(ctx.pm_dentry == NULL)) { - nss_pm_warning("Failed to create qca-nss-drv directory in debugfs"); - } -} -#endif diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pm.h b/feeds/ipq807x/qca-nss-drv/src/nss_pm.h deleted file mode 100644 index aaca293cb..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pm.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2014-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. - * 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_pm.h - * NSS PM Driver header file - */ - -#ifndef __NSS_PM_H -#define __NSS_PM_H - -#include - -#include -#include -#include -#include - -#include - -/* - * NSS PM debug macros - */ -#if (NSS_PM_DEBUG_LEVEL < 1) -#define nss_pm_assert(fmt, args...) -#else -#define nss_pm_assert(c) if (!(c)) { BUG_ON(!(c)); } -#endif - -#if (NSS_PM_DEBUG_LEVEL < 2) -#define nss_pm_warning(fmt, args...) -#else -#define nss_pm_warning(fmt, args...) printk(KERN_WARNING "nss_pm:"fmt, ##args) -#endif - -#if (NSS_PM_DEBUG_LEVEL < 3) -#define nss_pm_info(fmt, args...) -#else -#define nss_pm_info(fmt, args...) printk(KERN_INFO "nss_pm:"fmt, ##args) -#endif - -#if (NSS_PM_DEBUG_LEVEL < 4) -#define nss_pm_trace(fmt, args...) -#else -#define nss_pm_trace(fmt, args...) printk(KERN_DEBUG "nss_pm:"fmt, ##args) -#endif - -/* - * Define this to use NETAP driver also request for NSS Fab1 BW on behalf of GMAC driver - */ -#define NSS_PM_NETAP_GMAC_SCALING 1 - -/* - * PM Client data structure - */ -typedef struct { - uint32_t bus_perf_client; - uint32_t clk_handle; - uint32_t current_perf_lvl; - uint32_t auto_scale; - struct dentry *dentry; - nss_pm_client_t client_id; -} nss_pm_client_data_t; - -/* - * NSS PM driver context - */ -struct nss_pm_global_ctx { - struct dentry *pm_dentry; - bool turbo_support; - nss_pm_client_data_t nss_pm_client[NSS_PM_MAX_CLIENTS]; -}; - -/* - * Macro defining Bus vector for GMAC driver - */ -#define GMAC_BW_MBPS(_data_bw, _desc_bw) \ -{ \ - .vectors = (struct msm_bus_vectors[]){ \ - {\ - .src = MSM_BUS_MASTER_NSS_GMAC_0, \ - .dst = MSM_BUS_SLAVE_EBI_CH0, \ - .ab = (_data_bw) * 16 * 1000000ULL, \ - .ib = (_data_bw) * 16 * 1000000ULL, \ - }, \ - { \ - .src = MSM_BUS_MASTER_NSS_GMAC_0, \ - .dst = MSM_BUS_SLAVE_NSS_TCM, \ - .ab = (_desc_bw) * 8 * 1000000ULL, \ - .ib = (_desc_bw) * 8 * 1000000ULL, \ - }, \ - }, \ - .num_paths = 2, \ -} - -/* - * Macro defining Bus vector for NSS crypto driver - */ -#define CRYPTO_BW_MBPS(_data_bw, _desc_bw) \ -{ \ - .vectors = (struct msm_bus_vectors[]){ \ - {\ - .src = MSM_BUS_MASTER_NSS_CRYPTO5_0, \ - .dst = MSM_BUS_SLAVE_EBI_CH0, \ - .ab = 0, \ - .ib = 0, \ - }, \ - { \ - .src = MSM_BUS_MASTER_NSS_CRYPTO5_0, \ - .dst = MSM_BUS_SLAVE_NSS_TCM, \ - .ab = (_desc_bw) * 8 * 1000000ULL, \ - .ib = (_desc_bw) * 8 * 1000000ULL, \ - }, \ - }, \ - .num_paths = 2, \ -} - -/* - * Macro defining Bus vector for NSS driver - * - */ -#define NETAP_BW_MBPS(_data_bw, _desc_bw) \ -{ \ - .vectors = (struct msm_bus_vectors[]){ \ - {\ - .src = MSM_BUS_MASTER_UBI32_0, \ - .dst = MSM_BUS_SLAVE_EBI_CH0, \ - .ab = (_data_bw) * 16 * 1000000ULL, \ - .ib = (_data_bw) * 16 * 1000000ULL, \ - }, \ - { \ - .src = MSM_BUS_MASTER_UBI32_0, \ - .dst = MSM_BUS_SLAVE_NSS_TCM, \ - .ab = (_desc_bw) * 8 * 1000000ULL, \ - .ib = (_desc_bw) * 8 * 1000000ULL, \ - }, \ - }, \ - .num_paths = 2, \ -} - -/* - * Initialize NSS PM top level structures - */ -void nss_pm_init(void); - -/* - * Sets the turbo support flag globally for all PM clients - */ -void nss_pm_set_turbo(void); - -#endif /** __NSS_PM_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_portid.c b/feeds/ipq807x/qca-nss-drv/src/nss_portid.c deleted file mode 100644 index 65982f09a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_portid.c +++ /dev/null @@ -1,423 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_portid_stats.h" -#include "nss_portid_log.h" - -/* - * Spinlock to protect portid interface create/destroy/update - */ -DEFINE_SPINLOCK(nss_portid_spinlock); - -#define NSS_PORTID_TX_TIMEOUT 3000 /* 3 Seconds */ - -/* - * Private data structure for phys_if interface - */ -static struct nss_portid_pvt { - struct semaphore sem; - struct completion complete; - int response; -} pid; - -/* - * Array of portid interface handles. Indexing based on the physical port_id - */ -struct nss_portid_handle nss_portid_hdl[NSS_PORTID_MAX_SWITCH_PORT]; - -/* - * nss_portid_handler() - * Handle NSS -> HLOS messages for portid - */ -static void nss_portid_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, - __attribute__((unused))void *app_data) -{ - nss_portid_msg_callback_t cb; - struct nss_portid_msg *npm = (struct nss_portid_msg *)ncm; - - BUG_ON(ncm->interface != NSS_PORTID_INTERFACE); - - /* - * Trace Messages - */ - nss_portid_log_rx_msg(npm); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_PORTID_MAX_MSG_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("%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_PORTID_STATS_SYNC_MSG: - /* - * Update portid statistics. - */ - nss_portid_stats_sync(nss_ctx, &npm->msg.stats_sync); - break; - } - - /* - * Update the callback and app_data for NOTIFY messages, portid 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_portid_msg_callback_t)ncm->cb; - - cb((void *)ncm->app_data, npm); -} - -/* - * nss_portid_get_ctx() - * Return a portid's NSS context. - */ -struct nss_ctx_instance *nss_portid_get_ctx(void) -{ - struct nss_ctx_instance *nss_ctx; - - nss_ctx = &nss_top_main.nss[nss_top_main.portid_handler_id]; - return nss_ctx; -} - -/* - * nss_portid_verify_if_num() - * Verify if_num passed to us. - */ -static bool nss_portid_verify_if_num(uint32_t if_num) -{ - if (nss_is_dynamic_interface(if_num) == false) { - return false; - } - - if (nss_dynamic_interface_get_type(nss_portid_get_ctx(), if_num) != NSS_DYNAMIC_INTERFACE_TYPE_PORTID) { - return false; - } - - return true; -} - -/* - * nss_portid_get_stats() - * API for getting stats from a port interface - */ -bool nss_portid_get_stats(uint32_t if_num, struct rtnl_link_stats64 *stats) -{ - int i; - - spin_lock_bh(&nss_portid_spinlock); - for (i = 0; i < NSS_PORTID_MAX_SWITCH_PORT; i++) { - if (nss_portid_hdl[i].if_num == if_num) { - memcpy(stats, &nss_portid_hdl[i].stats, sizeof(*stats)); - spin_unlock_bh(&nss_portid_spinlock); - return true; - } - } - spin_unlock_bh(&nss_portid_spinlock); - return false; -} -EXPORT_SYMBOL(nss_portid_get_stats); - -/* - * nss_portid_if_tx_data() - * Transmit data buffer (skb) to a NSS interface number - */ -nss_tx_status_t nss_portid_if_tx_data(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, uint32_t if_num) -{ - return nss_if_tx_buf(nss_ctx, os_buf, if_num); -} -EXPORT_SYMBOL(nss_portid_if_tx_data); - -/* - * nss_portid_tx_msg() - * Transmit a portid message to NSSFW - */ -nss_tx_status_t nss_portid_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_portid_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace Messages - */ - nss_portid_log_tx_msg(msg); - - /* - * Sanity check the message - */ - if (ncm->interface != NSS_PORTID_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("%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); -} -EXPORT_SYMBOL(nss_portid_tx_msg); - -/* - * nss_portid_callback - * Callback to handle the completion of NSS ->HLOS messages. - */ -static void nss_portid_callback(void *app_data, struct nss_portid_msg *npm) -{ - if(npm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("portid error response %d\n", npm->cm.response); - pid.response = NSS_TX_FAILURE; - complete(&pid.complete); - return; - } - - pid.response = NSS_TX_SUCCESS; - complete(&pid.complete); -} - -/* - * nss_portid_tx_msg_sync() - * Send a message to portid interface & wait for the response. - */ -nss_tx_status_t nss_portid_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_portid_msg *msg) -{ - nss_tx_status_t status; - int ret = 0; - - down(&pid.sem); - - status = nss_portid_tx_msg(nss_ctx, msg); - if(status != NSS_TX_SUCCESS) - { - nss_warning("%px: nss_phys_if_msg failed\n", nss_ctx); - up(&pid.sem); - return status; - } - - ret = wait_for_completion_timeout(&pid.complete, msecs_to_jiffies(NSS_PORTID_TX_TIMEOUT)); - - if(!ret) - { - nss_warning("%px: portid tx failed due to timeout\n", nss_ctx); - pid.response = NSS_TX_FAILURE; - } - - status = pid.response; - up(&pid.sem); - - return status; -} -EXPORT_SYMBOL(nss_portid_tx_msg_sync); - -/* - * nss_portid_msg_init() - * Initialize portid message. - */ -void nss_portid_msg_init(struct nss_portid_msg *npm, uint16_t if_num, uint32_t type, uint32_t len, - nss_portid_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&npm->cm, if_num, type, len, (void*)cb, app_data); -} -EXPORT_SYMBOL(nss_portid_msg_init); - -/* - * nss_portid_tx_configure_port_if_msg - * API to send configure port message to NSS FW - */ -nss_tx_status_t nss_portid_tx_configure_port_if_msg(struct nss_ctx_instance *nss_ctx, uint32_t port_if_num, uint8_t port_id, uint8_t gmac_id) -{ - struct nss_portid_msg npm; - struct nss_portid_configure_msg *npcm; - - if (nss_portid_verify_if_num(port_if_num) == false) { - nss_warning("received invalid interface %d", port_if_num); - return NSS_TX_FAILURE; - } - - if (port_id >= NSS_PORTID_MAX_SWITCH_PORT) { - nss_warning("port_id %d exceeds NSS_PORTID_MAX_SWITCH_PORT\n", port_id); - return NSS_TX_FAILURE; - } - - if (gmac_id >= NSS_MAX_PHYSICAL_INTERFACES) { - nss_warning("gmac_id %d not valid\n", gmac_id); - return NSS_TX_FAILURE; - } - - /* - * Prepare message to configure a port interface - */ - npcm = &npm.msg.configure; - npcm->port_if_num = port_if_num; - npcm->port_id = port_id; - npcm->gmac_id = gmac_id; - - nss_portid_msg_init(&npm, NSS_PORTID_INTERFACE, NSS_PORTID_CONFIGURE_MSG, - sizeof(struct nss_portid_configure_msg), nss_portid_callback, NULL); - nss_info("Dynamic interface allocated, sending message to FW with port_if_num %d port_id %d gmac_id %d\n", - npcm->port_if_num, npcm->port_id, npcm->gmac_id); - return nss_portid_tx_msg_sync(nss_ctx, &npm); -} -EXPORT_SYMBOL(nss_portid_tx_configure_port_if_msg); - -/* - * nss_portid_tx_unconfigure_port_if_msg - * API to send unconfigure port message to NSS FW - */ -nss_tx_status_t nss_portid_tx_unconfigure_port_if_msg(struct nss_ctx_instance *nss_ctx, uint32_t port_if_num, uint8_t port_id) -{ - struct nss_portid_msg npm; - struct nss_portid_unconfigure_msg *npum; - - if (nss_portid_verify_if_num(port_if_num) == false) { - nss_warning("received invalid interface %d", port_if_num); - return NSS_TX_FAILURE; - } - - if (port_id >= NSS_PORTID_MAX_SWITCH_PORT) { - nss_warning("port_id %d exceeds NSS_PORTID_MAX_SWITCH_PORT\n", port_id); - return NSS_TX_FAILURE; - } - - /* - * Prepare message to unconfigure a port interface - */ - npum = &npm.msg.unconfigure; - npum->port_if_num = port_if_num; - npum->port_id = port_id; - - nss_portid_msg_init(&npm, NSS_PORTID_INTERFACE, NSS_PORTID_UNCONFIGURE_MSG, - sizeof(struct nss_portid_configure_msg), nss_portid_callback, NULL); - - return nss_portid_tx_msg_sync(nss_ctx, &npm); -} -EXPORT_SYMBOL(nss_portid_tx_unconfigure_port_if_msg); - -/* - * nss_portid_register_port_if() - * Register with portid node and get back nss_ctx - */ -struct nss_ctx_instance *nss_portid_register_port_if(uint32_t if_num, uint32_t port_id, struct net_device *netdev, - nss_portid_buf_callback_t buf_callback) -{ - struct nss_ctx_instance *nss_ctx = nss_portid_get_ctx(); - - if (nss_portid_verify_if_num(if_num) == false) { - nss_warning("nss portid register received invalid interface %d", if_num); - return NULL; - } - - if (port_id >= NSS_PORTID_MAX_SWITCH_PORT) { - nss_warning("nss portid register received invalid port number %d", port_id); - return NULL; - } - - spin_lock(&nss_portid_spinlock); - if (nss_portid_hdl[port_id].if_num != 0) { - nss_warning("nss portid failed: port already registered %d", port_id); - spin_unlock(&nss_portid_spinlock); - return NULL; - } - nss_portid_hdl[port_id].if_num = if_num; - spin_unlock(&nss_portid_spinlock); - - nss_core_register_subsys_dp(nss_ctx, if_num, buf_callback, NULL, NULL, netdev, 0); - - return nss_ctx; -} -EXPORT_SYMBOL(nss_portid_register_port_if); - -/* - * nss_portid_unregister_port_if() - * Unregister portid node with NSS FW - */ -bool nss_portid_unregister_port_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx; - int i; - - nss_ctx = nss_portid_get_ctx(); - if (nss_portid_verify_if_num(if_num) == false) { - nss_warning("%px: unregister received for invalid interface %d", nss_ctx, if_num); - return false; - } - - spin_lock(&nss_portid_spinlock); - for (i = 0; i < NSS_PORTID_MAX_SWITCH_PORT; i++) { - if (nss_portid_hdl[i].if_num == if_num) { - nss_portid_hdl[i].if_num = 0; - } - } - spin_unlock(&nss_portid_spinlock); - - nss_core_unregister_handler(nss_ctx, if_num); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - return true; -} -EXPORT_SYMBOL(nss_portid_unregister_port_if); - -/* - * nss_portid_init() - * Initializes portid node. Gets called from nss_init.c - */ -void nss_portid_init(void) -{ - memset(&nss_portid_hdl, 0, sizeof(struct nss_portid_handle) * NSS_PORTID_MAX_SWITCH_PORT); -} - -/* - * nss_portid_register_handler() - * Registering handler for sending msg to portid node on NSS. - */ -void nss_portid_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_portid_get_ctx(); - - nss_core_register_handler(nss_ctx, NSS_PORTID_INTERFACE, nss_portid_handler, NULL); - - nss_portid_stats_dentry_create(); - - sema_init(&pid.sem, 1); - init_completion(&pid.complete); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_portid_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_portid_log.c deleted file mode 100644 index 700e1181b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_portid_log.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_portid_log.c - * NSS PORTID logger file. - */ - -#include "nss_core.h" - -/* - * nss_portid_log_message_types_str - * NSS PORTID message strings - */ -static int8_t *nss_portid_log_message_types_str[NSS_PORTID_MAX_MSG_TYPE] __maybe_unused = { - "PORTID Configure", - "PORTID Unconfigure", - "PORTID Stats", -}; - -/* - * nss_portid_log_configure_msg() - * Log NSS PORTID Configure. - */ -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("%px: NSS PORTID Configure message \n" - "PORTID Interface Number: %d\n" - "PORTID Interface ID: %d\n" - "PORTID GMAC ID: %d\n", - npcm, npcm->port_if_num, - npcm->port_id, npcm->gmac_id); -} - -/* - * nss_portid_log_unconfigure_msg() - * Log NSS PORTID Unconfigure. - */ -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("%px: NSS PORTID Configure message \n" - "PORTID Interface Number: %d\n" - "PORTID Interface ID: %d\n", - npum, npum->port_if_num, - npum->port_id); -} - -/* - * nss_portid_log_verbose() - * Log message contents. - */ -static void nss_portid_log_verbose(struct nss_portid_msg *npm) -{ - switch (npm->cm.type) { - case NSS_PORTID_CONFIGURE_MSG: - nss_portid_log_configure_msg(npm); - break; - - case NSS_PORTID_UNCONFIGURE_MSG: - nss_portid_log_unconfigure_msg(npm); - break; - - case NSS_PORTID_STATS_SYNC_MSG: - /* - * No log for valid stats message. - */ - break; - - default: - nss_trace("%px: Invalid message type\n", npm); - break; - } -} - -/* - * nss_portid_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_portid_log_tx_msg(struct nss_portid_msg *npm) -{ - if (npm->cm.type >= NSS_PORTID_MAX_MSG_TYPE) { - nss_warning("%px: Invalid message type\n", npm); - return; - } - - 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); -} - -/* - * nss_portid_log_rx_msg() - * Log messages received from FW. - */ -void nss_portid_log_rx_msg(struct nss_portid_msg *npm) -{ - if (npm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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]); - -verbose: - nss_portid_log_verbose(npm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_portid_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_portid_log.h deleted file mode 100644 index 54d904fe9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_portid_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_PORTID_LOG_H -#define __NSS_PORTID_LOG_H - -/* - * nss_portid.h - * NSS PORTID header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_portid_log_tx_msg - * Logs a portid message that is sent to the NSS firmware. - */ -void nss_portid_log_tx_msg(struct nss_portid_msg *ntm); - -/* - * nss_portid_log_rx_msg - * Logs a portid message that is received from the NSS firmware. - */ -void nss_portid_log_rx_msg(struct nss_portid_msg *ntm); - -#endif /* __NSS_PORTID_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_portid_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_portid_stats.c deleted file mode 100644 index 8b6086dba..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_portid_stats.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_portid_stats.h" - -extern spinlock_t nss_portid_spinlock; -extern struct nss_portid_handle nss_portid_hdl[]; - -/* - * nss_portid_stats_str - * PortID statistics strings. - */ -struct nss_stats_info nss_portid_stats_str[NSS_PORTID_STATS_MAX] = { - {"rx_invalid_header" , NSS_STATS_TYPE_EXCEPTION} -}; - -uint64_t nss_portid_stats[NSS_PORTID_STATS_MAX]; - -/* - * nss_portid_stats_read() - * Read PortID stats. - */ -static ssize_t nss_portid_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int32_t i; - /* - * Max output lines = #stats + few output 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_PORTID_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, "portid", NSS_STATS_SINGLE_CORE); - size_wr += nss_stats_fill_common_stats(NSS_PORTID_INTERFACE, NSS_STATS_SINGLE_INSTANCE, lbuf, size_wr, size_al, "portid"); - - /* - * PortID node stats - */ - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; (i < NSS_PORTID_STATS_MAX); i++) { - stats_shadow[i] = nss_portid_stats[i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - - size_wr += nss_stats_print("portid", NULL, NSS_STATS_SINGLE_INSTANCE - , nss_portid_stats_str - , stats_shadow - , NSS_PORTID_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_portid_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(portid) - -/* - * nss_portid_stats_dentry_create() - * Create portid node statistics debug entry. - */ -void nss_portid_stats_dentry_create(void) -{ - nss_stats_create_dentry("portid", &nss_portid_stats_ops); -} - -/* - * nss_portid_stats_sync() - * Update portid node stats. - */ -void nss_portid_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_portid_stats_sync_msg *npsm) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - struct nss_portid_handle *hdl; - int j; - - if (npsm->port_id == NSS_PORTID_MAX_SWITCH_PORT) { - /* - * Update PORTID base node stats. - */ - spin_lock_bh(&nss_top->stats_lock); - nss_top->stats_node[NSS_PORTID_INTERFACE][NSS_STATS_NODE_RX_PKTS] += npsm->node_stats.rx_packets; - nss_top->stats_node[NSS_PORTID_INTERFACE][NSS_STATS_NODE_RX_BYTES] += npsm->node_stats.rx_bytes; - nss_top->stats_node[NSS_PORTID_INTERFACE][NSS_STATS_NODE_TX_PKTS] += npsm->node_stats.tx_packets; - nss_top->stats_node[NSS_PORTID_INTERFACE][NSS_STATS_NODE_TX_BYTES] += npsm->node_stats.tx_bytes; - - for (j = 0; j < NSS_MAX_NUM_PRI; j++) { - nss_top->stats_node[NSS_PORTID_INTERFACE][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + j] += npsm->node_stats.rx_dropped[j]; - } - - nss_portid_stats[NSS_PORTID_STATS_RX_INVALID_HEADER] += npsm->rx_invalid_header; - spin_unlock_bh(&nss_top->stats_lock); - return; - } - - if (npsm->port_id >= NSS_PORTID_MAX_SWITCH_PORT) { - nss_warning("port_id %d exceeds NSS_PORTID_MAX_SWITCH_PORT\n", npsm->port_id); - return; - } - - /* - * Update PORTID interface stats. - */ - spin_lock_bh(&nss_portid_spinlock); - hdl = &nss_portid_hdl[npsm->port_id]; - if (hdl->if_num == 0) { - nss_warning("%px: nss_portid recv'd stats with unconfigured port %d", nss_ctx, npsm->port_id); - spin_unlock_bh(&nss_portid_spinlock); - return; - } - hdl->stats.rx_packets += npsm->node_stats.rx_packets; - hdl->stats.rx_bytes += npsm->node_stats.rx_bytes; - hdl->stats.rx_dropped += nss_cmn_rx_dropped_sum(&npsm->node_stats); - hdl->stats.tx_packets += npsm->node_stats.tx_packets; - hdl->stats.tx_bytes += npsm->node_stats.tx_bytes; - spin_unlock_bh(&nss_portid_spinlock); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_portid_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_portid_stats.h deleted file mode 100644 index b1a1ee5b7..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_portid_stats.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - ****************************************************************************** - * 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_PORTID_STATS_H -#define __NSS_PORTID_STATS_H - -/* - * PortID statistics - */ -enum nss_portid_stats_types { - NSS_PORTID_STATS_RX_INVALID_HEADER, - NSS_PORTID_STATS_MAX, -}; - -struct nss_portid_handle { - uint32_t if_num; /**< Interface number */ - struct rtnl_link_stats64 stats; /**< statistics counters */ -}; - -/* - * PortID statistics APIs - */ -extern void nss_portid_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_portid_stats_sync_msg *npsm); -extern void nss_portid_stats_dentry_create(void); - -#endif /* __NSS_PORTID_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ppe.c b/feeds/ipq807x/qca-nss-drv/src/nss_ppe.c deleted file mode 100644 index 46ce217b6..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ppe.c +++ /dev/null @@ -1,374 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2016-2018, 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_ppe.h" -#include "nss_ppe_stats.h" -#include "nss_ppe_strings.h" - -DEFINE_SPINLOCK(nss_ppe_stats_lock); - -struct nss_ppe_stats_debug nss_ppe_debug_stats; -struct nss_ppe_pvt ppe_pvt; - -/* - * nss_ppe_verify_ifnum() - * Verify PPE interface number. - */ -static inline bool nss_ppe_verify_ifnum(int if_num) -{ - return nss_is_dynamic_interface(if_num) || (if_num == NSS_PPE_INTERFACE); -} - -/* - * nss_ppe_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_ppe_callback(void *app_data, struct nss_ppe_msg *npm) -{ - nss_ppe_msg_callback_t callback = (nss_ppe_msg_callback_t)ppe_pvt.cb; - void *data = ppe_pvt.app_data; - - ppe_pvt.response = NSS_TX_SUCCESS; - ppe_pvt.cb = NULL; - ppe_pvt.app_data = NULL; - - if (npm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("ppe error response %d\n", npm->cm.response); - ppe_pvt.response = npm->cm.response; - } - - if (callback) { - callback(data, npm); - } - complete(&ppe_pvt.complete); -} - -/* - * nss_ppe_tx_msg() - * Transmit a ppe message to NSSFW - */ -nss_tx_status_t nss_ppe_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_ppe_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace messages. - */ - nss_ppe_log_tx_msg(msg); - - /* - * Sanity check the message - */ - if (ncm->type >= NSS_PPE_MSG_MAX) { - 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("%px: invalid interface %d\n", nss_ctx, ncm->interface); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} - -/* - * nss_ppe_tx_msg_sync() - * Transmit a ppe message to NSS firmware synchronously. - */ -nss_tx_status_t nss_ppe_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_ppe_msg *npm) -{ - nss_tx_status_t status; - int ret = 0; - - down(&ppe_pvt.sem); - ppe_pvt.cb = (void *)npm->cm.cb; - ppe_pvt.app_data = (void *)npm->cm.app_data; - - npm->cm.cb = (nss_ptr_t)nss_ppe_callback; - npm->cm.app_data = (nss_ptr_t)NULL; - - status = nss_ppe_tx_msg(nss_ctx, npm); - if (status != NSS_TX_SUCCESS) { - 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("%px: ppe msg tx failed due to timeout\n", nss_ctx); - ppe_pvt.response = NSS_TX_FAILURE; - } - - status = ppe_pvt.response; - up(&ppe_pvt.sem); - return status; -} - -/* - * nss_ppe_get_context() - * Get NSS context instance for ppe - */ -struct nss_ctx_instance *nss_ppe_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.ppe_handler_id]; -} - -/* - * nss_ppe_msg_init() - * Initialize nss_ppe_msg. - */ -void nss_ppe_msg_init(struct nss_ppe_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} - -/* - * nss_ppe_tx_ipsec_config_msg - * API to send inline IPsec port configure message to NSS FW - */ -nss_tx_status_t nss_ppe_tx_ipsec_config_msg(uint32_t nss_ifnum, uint32_t vsi_num, uint16_t mtu, - __attribute__((unused))uint16_t mru) -{ - struct nss_ctx_instance *nss_ctx = nss_ppe_get_context(); - struct nss_ppe_msg npm = {0}; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - if (vsi_num >= NSS_PPE_VSI_NUM_MAX) { - nss_warning("Invalid vsi number:%u\n", vsi_num); - return NSS_TX_FAILURE; - } - - nss_ppe_msg_init(&npm, NSS_PPE_INTERFACE, NSS_PPE_MSG_IPSEC_PORT_CONFIG, - sizeof(struct nss_ppe_ipsec_port_config_msg), NULL, NULL); - - npm.msg.ipsec_config.nss_ifnum = nss_ifnum; - npm.msg.ipsec_config.vsi_num = vsi_num; - npm.msg.ipsec_config.mtu = mtu; - - return nss_ppe_tx_msg_sync(nss_ctx, &npm); -} - -/* - * nss_ppe_tx_ipsec_mtu_msg - * API to send IPsec port MTU change message to NSS FW - */ -nss_tx_status_t nss_ppe_tx_ipsec_mtu_msg(uint32_t nss_ifnum, uint16_t mtu, __attribute__((unused))uint16_t mru) -{ - struct nss_ctx_instance *nss_ctx = nss_ppe_get_context(); - struct nss_ppe_msg npm = {0}; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - nss_ppe_msg_init(&npm, NSS_PPE_INTERFACE, NSS_PPE_MSG_IPSEC_PORT_MTU_CHANGE, - sizeof(struct nss_ppe_ipsec_port_mtu_msg), NULL, NULL); - - npm.msg.ipsec_mtu.nss_ifnum = nss_ifnum; - npm.msg.ipsec_mtu.mtu = mtu; - - return nss_ppe_tx_msg_sync(nss_ctx, &npm); -} - -/* - * nss_ppe_tx_ipsec_add_intf_msg - * API to attach NSS interface to IPsec port - */ -nss_tx_status_t nss_ppe_tx_ipsec_add_intf_msg(uint32_t nss_ifnum) -{ - struct nss_ctx_instance *nss_ctx = nss_ppe_get_context(); - struct nss_ppe_msg npm = {0}; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - nss_ppe_msg_init(&npm, NSS_PPE_INTERFACE, NSS_PPE_MSG_IPSEC_ADD_INTF, - sizeof(struct nss_ppe_ipsec_add_intf_msg), NULL, NULL); - - npm.msg.ipsec_addif.nss_ifnum = nss_ifnum; - - return nss_ppe_tx_msg_sync(nss_ctx, &npm); -} - -/* - * nss_ppe_tx_ipsec_del_intf_msg - * API to detach NSS interface to IPsec port - */ -nss_tx_status_t nss_ppe_tx_ipsec_del_intf_msg(uint32_t nss_ifnum) -{ - struct nss_ctx_instance *nss_ctx = nss_ppe_get_context(); - struct nss_ppe_msg npm = {0}; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - nss_ppe_msg_init(&npm, NSS_PPE_INTERFACE, NSS_PPE_MSG_IPSEC_DEL_INTF, - sizeof(struct nss_ppe_ipsec_del_intf_msg), NULL, NULL); - - npm.msg.ipsec_delif.nss_ifnum = nss_ifnum; - - return nss_ppe_tx_msg_sync(nss_ctx, &npm); -} - -/* - * nss_ppe_handler() - * Handle NSS -> HLOS messages for ppe - */ -static void nss_ppe_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_ppe_msg *msg = (struct nss_ppe_msg *)ncm; - void *ctx; - - nss_ppe_msg_callback_t cb; - - nss_trace("nss_ctx: %px ppe msg: %px\n", nss_ctx, msg); - BUG_ON(!nss_ppe_verify_ifnum(ncm->interface)); - - /* - * Trace messages. - */ - nss_ppe_log_rx_msg(msg); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_PPE_MSG_MAX) { - 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("%px: Length of message is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - switch (msg->cm.type) { - case NSS_PPE_MSG_SYNC_STATS: - /* - * 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; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_ppe_msg_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - cb(ctx, msg); -} - -/* - * nss_ppe_register_handler() - * debugfs stats msg handler received on static ppe interface - * - * TODO: Export API so that others can also read PPE stats. - */ -void nss_ppe_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_ppe_get_context(); - - nss_core_register_handler(nss_ctx, NSS_PPE_INTERFACE, nss_ppe_handler, NULL); - - if (nss_ppe_debug_stats.valid) { - nss_ppe_stats_dentry_create(); - nss_ppe_strings_dentry_create(); - } -} - -/* - * nss_ppe_free() - * Uninitialize PPE base - */ -void nss_ppe_free(void) -{ - /* - * Check if PPE base is already uninitialized. - */ - if (!ppe_pvt.ppe_base) { - return; - } - - /* - * Unmap PPE base address - */ - iounmap(ppe_pvt.ppe_base); - ppe_pvt.ppe_base = NULL; - - spin_lock_bh(&nss_ppe_stats_lock); - nss_ppe_debug_stats.valid = false; - nss_ppe_debug_stats.if_num = 0; - nss_ppe_debug_stats.if_index = 0; - spin_unlock_bh(&nss_ppe_stats_lock); -} - -/* - * nss_ppe_init() - * Initialize PPE base - */ -void nss_ppe_init(void) -{ - /* - * Check if PPE base is already initialized. - */ - if (ppe_pvt.ppe_base) { - return; - } - - /* - * Get the PPE base address - */ - ppe_pvt.ppe_base = ioremap_nocache(PPE_BASE_ADDR, PPE_REG_SIZE); - if (!ppe_pvt.ppe_base) { - nss_warning("DRV can't get PPE base address\n"); - return; - } - - spin_lock_bh(&nss_ppe_stats_lock); - nss_ppe_debug_stats.valid = true; - nss_ppe_debug_stats.if_num = 0; - nss_ppe_debug_stats.if_index = 0; - spin_unlock_bh(&nss_ppe_stats_lock); - - sema_init(&ppe_pvt.sem, 1); - init_completion(&ppe_pvt.complete); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ppe.h b/feeds/ipq807x/qca-nss-drv/src/nss_ppe.h deleted file mode 100644 index d71021145..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ppe.h +++ /dev/null @@ -1,423 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2016-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. - ************************************************************************** - */ - -/* - * nss_ppe.h - * NSS PPE header file - */ - -#include -#include "nss_tx_rx_common.h" - -#define PPE_BASE_ADDR 0x3a000000 -#define PPE_REG_SIZE 0x1000000 - -#define PPE_L3_DBG_WR_OFFSET 0x200c04 -#define PPE_L3_DBG_RD_OFFSET 0x200c0c -#define PPE_L3_DBG0_OFFSET 0x10001 -#define PPE_L3_DBG1_OFFSET 0x10002 -#define PPE_L3_DBG2_OFFSET 0x10003 -#define PPE_L3_DBG3_OFFSET 0x10004 -#define PPE_L3_DBG4_OFFSET 0x10005 -#define PPE_L3_DBG_PORT_OFFSET 0x11e80 - -#define PPE_PKT_CODE_WR_OFFSET 0x100080 -#define PPE_PKT_CODE_RD_OFFSET 0x100084 -#define PPE_PKT_CODE_DROP0_OFFSET 0xf000000 -#define PPE_PKT_CODE_DROP1_OFFSET 0x10000000 -#define PPE_PKT_CODE_CPU_OFFSET 0x40000000 - -#define PPE_PKT_CODE_DROP0_GET(x) (((x) & 0xe0000000) >> 29) -#define PPE_PKT_CODE_DROP1_GET(x) (((x) & 0x7) << 3) -#define PPE_PKT_CODE_DROP_GET(d0, d1) (PPE_PKT_CODE_DROP0_GET(d0) | PPE_PKT_CODE_DROP1_GET(d1)) - -#define PPE_PKT_CODE_CPU_GET(x) (((x) >> 3) & 0xff) - -#define PPE_IPE_PC_REG 0x100000 - -/* - * NSS_SYS_REG_DROP_CPU_CNT_TBL - * Address map and access APIs for DROP_CPU_CNT table. - */ -#define PPE_DROP_CPU_CNT_TBL_OFFSET 0x60000 -#define PPE_DROP_CPU_CNT_TBL_ENTRY_SIZE 0x10 -#define PPE_DROP_CPU_CNT_TBL_BASE_OFFSET (PPE_IPE_PC_REG + PPE_DROP_CPU_CNT_TBL_OFFSET) -#define PPE_CPU_CODE_MAX_NUM 256 - -/* - * CPU code offset - */ -#define PPE_CPU_CODE_OFFSET(n) (PPE_DROP_CPU_CNT_TBL_BASE_OFFSET + ((n) * PPE_DROP_CPU_CNT_TBL_ENTRY_SIZE)) - -/* - * DROP code offset - */ -#define PPE_DROP_CODE_IDX(code, src_port) (PPE_CPU_CODE_MAX_NUM + (8 * (code)) + (src_port)) -#define PPE_DROP_CODE_OFFSET(code, src_port) (PPE_DROP_CPU_CNT_TBL_BASE_OFFSET + ((PPE_DROP_CODE_IDX(code, src_port)) * PPE_DROP_CPU_CNT_TBL_ENTRY_SIZE)) - -#define NSS_PPE_TX_TIMEOUT 1000 /* 1 Second */ - -/* - * Maximum number of VSI - */ -#define NSS_PPE_VSI_NUM_MAX 32 - -/* - * ppe nss debug stats lock - */ -extern spinlock_t nss_ppe_stats_lock; - -/* - * Private data structure - */ -struct nss_ppe_pvt { - void * __iomem ppe_base; - struct semaphore sem; - struct completion complete; - int response; - void *cb; - void *app_data; -}; - -/* - * Data structure to store to PPE private context - */ -extern struct nss_ppe_pvt ppe_pvt; - -/** - * nss_ppe_message_types - * Message types for Packet Processing Engine (PPE) requests and responses. - * - * Note: PPE messages are added as short term approach, expect all - * messages below to be deprecated for more integrated approach. - */ -enum nss_ppe_message_types { - NSS_PPE_MSG_SYNC_STATS, - NSS_PPE_MSG_IPSEC_PORT_CONFIG, - NSS_PPE_MSG_IPSEC_PORT_MTU_CHANGE, - NSS_PPE_MSG_IPSEC_ADD_INTF, - NSS_PPE_MSG_IPSEC_DEL_INTF, - NSS_PPE_MSG_MAX, -}; - -/** - * nss_ppe_msg_error_type - * PPE error types. - */ -enum nss_ppe_msg_error_type { - PPE_MSG_ERROR_OK, - PPE_MSG_ERROR_UNKNOWN_TYPE, - PPE_MSG_ERROR_PORT_CREATION_FAIL, - PPE_MSG_ERROR_INVALID_PORT_VSI, - PPE_MSG_ERROR_INVALID_L3_IF, - PPE_MSG_ERROR_IPSEC_PORT_CONFIG, - PPE_MSG_ERROR_IPSEC_INTF_TABLE_FULL, - PPE_MSG_ERROR_IPSEC_INTF_ATTACHED, - PPE_MSG_ERROR_IPSEC_INTF_UNATTACHED, - PPE_ERROR_MAX -}; - -/** - * nss_ppe_stats_sc - * Message structure for per service code stats. - */ -struct nss_ppe_stats_sc { - uint32_t nss_ppe_sc_cb_unregister; /* Per service-code counter for callback not registered */ - uint32_t nss_ppe_sc_cb_success; /* Per service-code coutner for successful callback */ - uint32_t nss_ppe_sc_cb_failure; /* Per service-code counter for failure callback */ -}; - -/** - * nss_ppe_stats - * Message structure for ppe general stats - */ -struct nss_ppe_stats { - uint32_t nss_ppe_v4_l3_flows; /**< Number of IPv4 routed flows. */ - uint32_t nss_ppe_v4_l2_flows; /**< Number of IPv4 bridge flows. */ - uint32_t nss_ppe_v4_create_req; /**< Number of IPv4 create requests. */ - uint32_t nss_ppe_v4_create_fail; /**< Number of IPv4 create failures. */ - uint32_t nss_ppe_v4_destroy_req; /**< Number of IPv4 delete requests. */ - uint32_t nss_ppe_v4_destroy_fail; /**< Number of IPv4 delete failures. */ - uint32_t nss_ppe_v4_mc_create_req; /**< Number of IPv4 MC create requests. */ - uint32_t nss_ppe_v4_mc_create_fail; /**< Number of IPv4 MC create failure. */ - uint32_t nss_ppe_v4_mc_update_req; /**< Number of IPv4 MC update requests. */ - uint32_t nss_ppe_v4_mc_update_fail; /**< Number of IPv4 MC update failure. */ - uint32_t nss_ppe_v4_mc_destroy_req; /**< Number of IPv4 MC delete requests. */ - uint32_t nss_ppe_v4_mc_destroy_fail; /**< Number of IPv4 MC delete failure. */ - uint32_t nss_ppe_v4_unknown_interface; /**< Number of IPv4 create failures */ - - uint32_t nss_ppe_v6_l3_flows; /**< Number of IPv6 routed flows. */ - uint32_t nss_ppe_v6_l2_flows; /**< Number of IPv6 bridge flows. */ - uint32_t nss_ppe_v6_create_req; /**< Number of IPv6 create requests. */ - uint32_t nss_ppe_v6_create_fail; /**< Number of IPv6 create failures. */ - uint32_t nss_ppe_v6_destroy_req; /**< Number of IPv6 delete requests. */ - uint32_t nss_ppe_v6_destroy_fail; /**< Number of IPv6 delete failures. */ - uint32_t nss_ppe_v6_mc_create_req; /**< Number of IPv6 MC create requests. */ - uint32_t nss_ppe_v6_mc_create_fail; /**< Number of IPv6 MC create failure. */ - uint32_t nss_ppe_v6_mc_update_req; /**< Number of IPv6 MC update requests. */ - uint32_t nss_ppe_v6_mc_update_fail; /**< Number of IPv6 MC update failure. */ - uint32_t nss_ppe_v6_mc_destroy_req; /**< Number of IPv6 MC delete requests. */ - uint32_t nss_ppe_v6_mc_destroy_fail; /**< Number of IPv6 MC delete failure. */ - uint32_t nss_ppe_v6_unknown_interface; /**< Number of IPv6 create failures */ - - uint32_t nss_ppe_fail_vp_full; - /**< Request failed because the virtual port table is full */ - uint32_t nss_ppe_fail_nh_full; - /**< Request failed because the next hop table is full. */ - uint32_t nss_ppe_fail_flow_full; - /**< Request failed because the flow table is full. */ - uint32_t nss_ppe_fail_host_full; - /**< Request failed because the host table is full. */ - uint32_t nss_ppe_fail_pubip_full; - /**< Request failed because the public IP table is full. */ - uint32_t nss_ppe_fail_port_setup; - /**< Request failed because the PPE port is not setup. */ - uint32_t nss_ppe_fail_rw_fifo_full; - /**< Request failed because the read/write FIFO is full. */ - uint32_t nss_ppe_fail_flow_command; - /**< Request failed because the PPE flow command failed. */ - uint32_t nss_ppe_fail_unknown_proto; - /**< Request failed because of an unknown protocol. */ - uint32_t nss_ppe_fail_ppe_unresponsive; - /**< Request failed because the PPE is not responding. */ - uint32_t nss_ppe_ce_opaque_invalid; - /**< Request failed because of invalid opaque in connection entry. */ - uint32_t nss_ppe_fail_fqg_full; - /**< Request failed because the flow QoS group is full. */ -}; - - -/** - * nss_ppe_sync_stats_msg - * Message information for PPE synchronization statistics. - */ -struct nss_ppe_sync_stats_msg { - struct nss_ppe_stats stats; /**< General stats */ - struct nss_ppe_stats_sc sc_stats[NSS_PPE_SC_MAX]; - /**< Per service-code stats */ -}; - -/** - * nss_ppe_ipsec_port_config_msg - * Message structure for inline IPsec port configuration. - */ -struct nss_ppe_ipsec_port_config_msg { - uint32_t nss_ifnum; /**< NSS interface number corresponding to inline IPsec port. */ - uint16_t mtu; /**< MTU value for inline IPsec port. */ - uint8_t vsi_num; /**< Default port VSI for inline IPsec port. */ -}; - -/** - * nss_ppe_ipsec_port_mtu_msg - * Message structure for inline IPsec port MTU change. - */ -struct nss_ppe_ipsec_port_mtu_msg { - uint32_t nss_ifnum; /**< NSS interface number corresponding to inline IPsec port. */ - uint16_t mtu; /**< MTU value for inline IPsec port. */ -}; - -/** - * nss_ppe_ipsec_add_intf_msg - * Message structure for adding dynamic IPsec/DTLS interface to inline IPsec port. - */ -struct nss_ppe_ipsec_add_intf_msg { - uint32_t nss_ifnum; /**< Dynamic IPsec/DTLS interface number. */ -}; - -/** - * nss_ppe_ipsec_del_intf_msg - * Message structure for deleting dynamic IPsec/DTLS interface to inline IPsec port. - */ -struct nss_ppe_ipsec_del_intf_msg { - uint32_t nss_ifnum; /**< Dynamic IPsec/DTLS interface number. */ -}; - -/** - * nss_ppe_msg - * Data for sending and receiving PPE host-to-NSS messages. - */ -struct nss_ppe_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** - * Payload of a PPE host-to-NSS message. - */ - union { - struct nss_ppe_sync_stats_msg stats; - /**< Synchronization statistics. */ - struct nss_ppe_ipsec_port_config_msg ipsec_config; - /**< PPE inline IPsec port configuration message. */ - struct nss_ppe_ipsec_port_mtu_msg ipsec_mtu; - /**< Inline IPsec port MTU change message. */ - struct nss_ppe_ipsec_add_intf_msg ipsec_addif; - /**< Inline IPsec NSS interface attach message. */ - struct nss_ppe_ipsec_del_intf_msg ipsec_delif; - /**< Inline IPsec NSS interface detach message. */ - } msg; /**< Message payload. */ -}; - -/** - * Callback function for receiving PPE messages. - * - * @datatypes - * nss_ppe_msg - * - * @param[in] app_data Pointer to the application context of the message. - * @param[in] msg Pointer to the message data. - */ -typedef void (*nss_ppe_msg_callback_t)(void *app_data, struct nss_ppe_msg *msg); - -/** - * nss_ppe_tx_msg - * Sends PPE messages to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_ppe_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_ppe_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_ppe_msg *msg); - -/** - * nss_ppe_tx_msg_sync - * Sends PPE messages synchronously to the NSS. - * - * @datatypes - * nss_ctx_instance \n - * nss_ppe_msg - * - * @param[in] nss_ctx Pointer to the NSS context. - * @param[in,out] msg Pointer to the message data. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_ppe_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_ppe_msg *msg); - -/** - * nss_ppe_msg_init - * Initializes a PPE message. - * - * @datatypes - * nss_ppe_msg - * - * @param[in,out] ncm Pointer to the message. - * @param[in] if_num 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. - */ -void nss_ppe_msg_init(struct nss_ppe_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); - -/** - * nss_ppe_get_context - * Gets the PPE context used in nss_ppe_tx. - * - * @return - * Pointer to the NSS core context. - */ -struct nss_ctx_instance *nss_ppe_get_context(void); - -/** - * nss_ppe_tx_ipsec_config_msg - * Sends the PPE a message to configure inline IPsec port. - * - * @param[in] if_num Static IPsec interface number. - * @param[in] vsi_num Default VSI number associated with inline IPsec port. - * @param[in] mtu Default MTU of static inline IPsec port. - * @param[in] mru Default MRU of static inline IPsec port. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_ppe_tx_ipsec_config_msg(uint32_t nss_ifnum, uint32_t vsi_num, uint16_t mtu, uint16_t mru); - -/** - * nss_ppe_tx_ipsec_mtu_msg - * Sends the PPE a message to configure MTU value on IPsec port. - * - * @param[in] nss_ifnum Static IPsec interface number. - * @param[in] mtu MTU of static IPsec interface. - * @param[in] mru MRU of static IPsec interface. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_ppe_tx_ipsec_mtu_msg(uint32_t nss_ifnum, uint16_t mtu, uint16_t mru); - -/** - * nss_ppe_tx_ipsec_add_intf_msg - * Sends the PPE a message to attach a dynamic interface number to IPsec port. - * - * @param[in] if_num Dynamic IPsec/DTLS interface number. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_ppe_tx_ipsec_add_intf_msg(uint32_t nss_ifnum); - -/** - * nss_ppe_tx_ipsec_del_intf_msg - * Sends the PPE a message to detach a dynamic interface number to IPsec port. - * - * @param[in] if_num Dynamic IPsec/DTLS interface number. - * - * @return - * Status of the Tx operation. - */ -nss_tx_status_t nss_ppe_tx_ipsec_del_intf_msg(uint32_t nss_ifnum); - -/* - * nss_ppe_reg_read() - */ -static inline void nss_ppe_reg_read(u32 reg, u32 *val) -{ - *val = readl((ppe_pvt.ppe_base + reg)); -} - -/* - * nss_ppe_reg_write() - */ -static inline void nss_ppe_reg_write(u32 reg, u32 val) -{ - writel(val, (ppe_pvt.ppe_base + reg)); -} - -/* - * nss_ppe_log.h - * NSS PPE Log Header File - */ - -/* - * nss_ppe_log_tx_msg - * Logs a ppe message that is sent to the NSS firmware. - */ -void nss_ppe_log_tx_msg(struct nss_ppe_msg *npm); - -/* - * nss_ppe_log_rx_msg - * Logs a ppe message that is received from the NSS firmware. - */ -void nss_ppe_log_rx_msg(struct nss_ppe_msg *npm); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_ppe_log.c deleted file mode 100644 index a6517322b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_log.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_ppe_log.c - * NSS PPE logger file. - */ - -#include "nss_core.h" -#include "nss_ppe.h" - -/* - * nss_ppe_log_message_types_str - * PPE message strings - */ -static int8_t *nss_ppe_log_message_types_str[NSS_PPE_MSG_MAX] __maybe_unused = { - "PPE Stats", - "PPE IPSEC Port Config", - "PPE IPSEC Port MTU Change", - "PPE IPSEC Add Interface", - "PPE IPSEC Del Interface", -}; - -/* - * nss_ppe_log_error_response_types_str - * Strings for error types for PPE messages - */ -static int8_t *nss_ppe_log_error_response_types_str[PPE_ERROR_MAX] __maybe_unused = { - "PPE No Error", - "PPE Uknown Type", - "PPE Port Creation Failure", - "PPE Invalid Port VSI", - "PPE Invalid L3 Interface", - "PPE IPSEC Port Config Error", - "PPE IPSEC Interface Table Full", - "PPE IPSEC Interface Attached", - "PPE IPSEC Interface Unattached", -}; - -/* - * nss_ppe_log_port_config_msg() - * Log NSS PPE port config message. - */ -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("%px: NSS PPE Port Configure Message:\n" - "PPE NSS Interface Number: %d\n" - "PPE MTU: %d\n" - "PPE VSI Number: %d\n", - npcm, npcm->nss_ifnum, - npcm->mtu, npcm->vsi_num); -} - -/* - * nss_ppe_log_port_mtu_msg() - * Log NSS PPE port mtu message. - */ -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("%px: NSS PPE Port Configure Message:\n" - "PPE NSS Interface Number: %d\n" - "PPE MTU: %d\n", - npmm, npmm->nss_ifnum, - npmm->mtu); -} - -/* - * nss_ppe_log_add_intf_msg() - * Log NSS PPE IPSEC Add Interface Message. - */ -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("%px: NSS PPE IPSEC add Interface Message:\n" - "PPE NSS Interface Number: %d\n", - npam, npam->nss_ifnum); -} - -/* - * nss_ppe_log_del_intf_msg() - * Log NSS PPE IPSEC Delete Interface Message. - */ -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("%px: NSS PPE IPSEC Delete Interface Message:\n" - "PPE NSS Interface Number: %d\n", - npdm, npdm->nss_ifnum); -} - -/* - * nss_ppe_log_verbose() - * Log message contents. - */ -static void nss_ppe_log_verbose(struct nss_ppe_msg *npm) -{ - switch (npm->cm.type) { - case NSS_PPE_MSG_IPSEC_PORT_CONFIG: - nss_ppe_log_port_config_msg(npm); - break; - - case NSS_PPE_MSG_IPSEC_PORT_MTU_CHANGE: - nss_ppe_log_port_mtu_msg(npm); - break; - - case NSS_PPE_MSG_IPSEC_ADD_INTF: - nss_ppe_log_add_intf_msg(npm); - break; - - case NSS_PPE_MSG_IPSEC_DEL_INTF: - nss_ppe_log_del_intf_msg(npm); - break; - - case NSS_PPE_MSG_SYNC_STATS: - /* - * No log for valid stats message. - */ - break; - - default: - nss_warning("%px: Invalid message type\n", npm); - break; - } -} - -/* - * nss_ppe_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_ppe_log_tx_msg(struct nss_ppe_msg *npm) -{ - if (npm->cm.type >= NSS_PPE_MSG_MAX) { - nss_warning("%px: Invalid message type\n", npm); - return; - } - - 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); -} - -/* - * nss_ppe_log_rx_msg() - * Log messages received from FW. - */ -void nss_ppe_log_rx_msg(struct nss_ppe_msg *npm) -{ - if (npm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_ppe_log_verbose(npm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_ppe_stats.c deleted file mode 100644 index e544856ed..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_stats.c +++ /dev/null @@ -1,925 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2017-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_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, - NSS_PPE_STATS_CPU_CODE_EXP_FAKE_MAC_HEADER_ERR, - NSS_PPE_STATS_CPU_CODE_EXP_BITMAP_MAX, - NSS_PPE_STATS_CPU_CODE_L2_EXP_MRU_FAIL, - NSS_PPE_STATS_CPU_CODE_L2_EXP_MTU_FAIL, - NSS_PPE_STATS_CPU_CODE_L3_EXP_IP_PREFIX_BC, - NSS_PPE_STATS_CPU_CODE_L3_EXP_MTU_FAIL, - NSS_PPE_STATS_CPU_CODE_L3_EXP_MRU_FAIL, - NSS_PPE_STATS_CPU_CODE_L3_EXP_ICMP_RDT, - NSS_PPE_STATS_CPU_CODE_L3_EXP_IP_RT_TTL1_TO_ME, - NSS_PPE_STATS_CPU_CODE_L3_EXP_IP_RT_TTL_ZERO, - NSS_PPE_STATS_CPU_CODE_L3_FLOW_SERVICE_CODE_LOOP, - NSS_PPE_STATS_CPU_CODE_L3_FLOW_DE_ACCELERATE, - NSS_PPE_STATS_CPU_CODE_L3_EXP_FLOW_SRC_IF_CHK_FAIL, - NSS_PPE_STATS_CPU_CODE_L3_FLOW_SYNC_TOGGLE_MISMATCH, - NSS_PPE_STATS_CPU_CODE_L3_EXP_MTU_DF_FAIL, - NSS_PPE_STATS_CPU_CODE_L3_EXP_PPPOE_MULTICAST, - NSS_PPE_STATS_CPU_CODE_MGMT_OFFSET, - NSS_PPE_STATS_CPU_CODE_MGMT_EAPOL, - NSS_PPE_STATS_CPU_CODE_MGMT_PPPOE_DIS, - NSS_PPE_STATS_CPU_CODE_MGMT_IGMP, - NSS_PPE_STATS_CPU_CODE_MGMT_ARP_REQ, - NSS_PPE_STATS_CPU_CODE_MGMT_ARP_REP, - NSS_PPE_STATS_CPU_CODE_MGMT_DHCPv4, - NSS_PPE_STATS_CPU_CODE_MGMT_MLD, - NSS_PPE_STATS_CPU_CODE_MGMT_NS, - NSS_PPE_STATS_CPU_CODE_MGMT_NA, - NSS_PPE_STATS_CPU_CODE_MGMT_DHCPv6, - NSS_PPE_STATS_CPU_CODE_PTP_OFFSET, - NSS_PPE_STATS_CPU_CODE_PTP_SYNC, - NSS_PPE_STATS_CPU_CODE_PTP_FOLLOW_UP, - NSS_PPE_STATS_CPU_CODE_PTP_DELAY_REQ, - NSS_PPE_STATS_CPU_CODE_PTP_DELAY_RESP, - NSS_PPE_STATS_CPU_CODE_PTP_PDELAY_REQ, - NSS_PPE_STATS_CPU_CODE_PTP_PDELAY_RESP, - NSS_PPE_STATS_CPU_CODE_PTP_PDELAY_RESP_FOLLOW_UP, - NSS_PPE_STATS_CPU_CODE_PTP_ANNOUNCE, - NSS_PPE_STATS_CPU_CODE_PTP_MANAGEMENT, - NSS_PPE_STATS_CPU_CODE_PTP_SIGNALING, - NSS_PPE_STATS_CPU_CODE_PTP_PKT_RSV_MSG, - NSS_PPE_STATS_CPU_CODE_IPV4_SG_UNKNOWN, - NSS_PPE_STATS_CPU_CODE_IPV6_SG_UNKNOWN, - NSS_PPE_STATS_CPU_CODE_ARP_SG_UNKNOWN, - NSS_PPE_STATS_CPU_CODE_ND_SG_UNKNOWN, - NSS_PPE_STATS_CPU_CODE_IPV4_SG_VIO, - NSS_PPE_STATS_CPU_CODE_IPV6_SG_VIO, - NSS_PPE_STATS_CPU_CODE_ARP_SG_VIO, - NSS_PPE_STATS_CPU_CODE_ND_SG_VIO, - NSS_PPE_STATS_CPU_CODE_L3_ROUTING_IP_TO_ME, - NSS_PPE_STATS_CPU_CODE_L3_FLOW_SNAT_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_FLOW_DNAT_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_FLOW_RT_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_FLOW_BR_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_MC_BRIDGE_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_ROUTE_PREHEAD_RT_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_ROUTE_PREHEAD_SNAPT_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_ROUTE_PREHEAD_DNAPT_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_ROUTE_PREHEAD_SNAT_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_ROUTE_PREHEAD_DNAT_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_NO_ROUTE_PREHEAD_NAT_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_NO_ROUTE_PREHEAD_NAT_ERROR, - NSS_PPE_STATS_CPU_CODE_L3_ROUTE_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_NO_ROUTE_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_NO_ROUTE_NH_INVALID_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_NO_ROUTE_PREHEAD_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_BRIDGE_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_FLOW_ACTION, - NSS_PPE_STATS_CPU_CODE_L3_FLOW_MISS_ACTION, - NSS_PPE_STATS_CPU_CODE_L2_NEW_MAC_ADDRESS, - NSS_PPE_STATS_CPU_CODE_L2_HASH_COLLISION, - NSS_PPE_STATS_CPU_CODE_L2_STATION_MOVE, - NSS_PPE_STATS_CPU_CODE_L2_LEARN_LIMIT, - NSS_PPE_STATS_CPU_CODE_L2_SA_LOOKUP_ACTION, - NSS_PPE_STATS_CPU_CODE_L2_DA_LOOKUP_ACTION, - NSS_PPE_STATS_CPU_CODE_APP_CTRL_ACTION, - NSS_PPE_STATS_CPU_CODE_IN_VLAN_FILTER_ACTION, - NSS_PPE_STATS_CPU_CODE_IN_VLAN_XLT_MISS, - NSS_PPE_STATS_CPU_CODE_EG_VLAN_FILTER_DROP, - NSS_PPE_STATS_CPU_CODE_ACL_PRE_ACTION, - NSS_PPE_STATS_CPU_CODE_ACL_POST_ACTION, - NSS_PPE_STATS_CPU_CODE_SERVICE_CODE_ACTION, -}; - -/* - * nss_ppe_stats_str_sc_type - * PPE service-code stats type - */ -static int8_t *nss_ppe_stats_str_sc_type[NSS_PPE_SC_MAX] = { - "SC_NONE ", - "SC_BYPASS_ALL ", - "SC_ADV_QOS_BRIDGED", - "SC_BR_QOS ", - "SC_BNC_0 ", - "SC_BNC_CMPL_0 ", - "SC_ADV_QOS_ROUTED ", - "SC_IPSEC_PPE2EIP ", - "SC_IPSEC_EIP2PPE ", - "SC_PTP ", - "SC_VLAN_FILTER ", - "SC_L3_EXCEPT ", -}; - -/* - * nss_ppe_stats_sync - * PPE connection sync statistics from NSS - */ -void nss_ppe_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_ppe_sync_stats_msg *stats_msg, uint16_t if_num) -{ - 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_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; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_DESTROY_FAIL] += stats_msg->stats.nss_ppe_v4_destroy_fail; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_MC_CREATE_REQ] += stats_msg->stats.nss_ppe_v4_mc_create_req; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_MC_CREATE_FAIL] += stats_msg->stats.nss_ppe_v4_mc_create_fail; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_MC_UPDATE_REQ] += stats_msg->stats.nss_ppe_v4_mc_update_req; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_MC_UPDATE_FAIL] += stats_msg->stats.nss_ppe_v4_mc_update_fail; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_MC_DESTROY_REQ] += stats_msg->stats.nss_ppe_v4_mc_destroy_req; - 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_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; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_DESTROY_FAIL] += stats_msg->stats.nss_ppe_v6_destroy_fail; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_MC_CREATE_REQ] += stats_msg->stats.nss_ppe_v6_mc_create_req; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_MC_CREATE_FAIL] += stats_msg->stats.nss_ppe_v6_mc_create_fail; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_MC_UPDATE_REQ] += stats_msg->stats.nss_ppe_v6_mc_update_req; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_MC_UPDATE_FAIL] += stats_msg->stats.nss_ppe_v6_mc_update_fail; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_MC_DESTROY_REQ] += stats_msg->stats.nss_ppe_v6_mc_destroy_req; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_MC_DESTROY_FAIL] += stats_msg->stats.nss_ppe_v6_mc_destroy_fail; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_UNKNOWN_INTERFACE] += stats_msg->stats.nss_ppe_v6_unknown_interface; - - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_FAIL_VP_FULL] += stats_msg->stats.nss_ppe_fail_vp_full; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_FAIL_NH_FULL] += stats_msg->stats.nss_ppe_fail_nh_full; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_FAIL_FLOW_FULL] += stats_msg->stats.nss_ppe_fail_flow_full; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_FAIL_HOST_FULL] += stats_msg->stats.nss_ppe_fail_host_full; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_FAIL_PUBIP_FULL] += stats_msg->stats.nss_ppe_fail_pubip_full; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_FAIL_PORT_SETUP] += stats_msg->stats.nss_ppe_fail_port_setup; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_FAIL_RW_FIFO_FULL] += stats_msg->stats.nss_ppe_fail_rw_fifo_full; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_FAIL_FLOW_COMMAND] += stats_msg->stats.nss_ppe_fail_flow_command; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_FAIL_UNKNOWN_PROTO] += stats_msg->stats.nss_ppe_fail_unknown_proto; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_FAIL_PPE_UNRESPONSIVE] += stats_msg->stats.nss_ppe_fail_ppe_unresponsive; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_CE_OPAQUE_INVALID] += stats_msg->stats.nss_ppe_ce_opaque_invalid; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_FAIL_FQG_FULL] += stats_msg->stats.nss_ppe_fail_fqg_full; - - /* - * Update service-code stats. - */ - for (sc = 0; sc < NSS_PPE_SC_MAX; sc++) { - nss_ppe_debug_stats.sc_stats[sc].nss_ppe_sc_cb_unregister += stats_msg->sc_stats[sc].nss_ppe_sc_cb_unregister; - nss_ppe_debug_stats.sc_stats[sc].nss_ppe_sc_cb_success += stats_msg->sc_stats[sc].nss_ppe_sc_cb_success; - nss_ppe_debug_stats.sc_stats[sc].nss_ppe_sc_cb_failure += stats_msg->sc_stats[sc].nss_ppe_sc_cb_failure; - } - - spin_unlock_bh(&nss_ppe_stats_lock); -} - -/* - * nss_ppe_stats_conn_get() - * Get PPE connection statistics. - */ -static void nss_ppe_stats_conn_get(uint64_t *stats) -{ - if (!stats) { - nss_warning("No memory to copy ppe connection stats"); - return; - } - - /* - * 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)); - spin_unlock_bh(&nss_ppe_stats_lock); -} - -/* - * nss_ppe_stats_sc_get() - * Get PPE service-code statistics. - */ -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"); - return; - } - - /* - * Get flow stats - */ - spin_lock_bh(&nss_ppe_stats_lock); - memcpy(sc_stats, nss_ppe_debug_stats.sc_stats, (sizeof(struct nss_ppe_sc_stats_debug) * NSS_PPE_SC_MAX)); - spin_unlock_bh(&nss_ppe_stats_lock); -} - -/* - * nss_ppe_stats_l3_get() - * Get PPE L3 debug statistics. - */ -static void nss_ppe_stats_l3_get(uint32_t *stats) -{ - if (!stats) { - nss_warning("No memory to copy ppe l3 dbg stats\n"); - return; - } - - spin_lock_bh(&nss_ppe_stats_lock); - nss_ppe_reg_write(PPE_L3_DBG_WR_OFFSET, PPE_L3_DBG0_OFFSET); - nss_ppe_reg_read(PPE_L3_DBG_RD_OFFSET, &stats[NSS_PPE_STATS_L3_DBG_0]); - - nss_ppe_reg_write(PPE_L3_DBG_WR_OFFSET, PPE_L3_DBG1_OFFSET); - nss_ppe_reg_read(PPE_L3_DBG_RD_OFFSET, &stats[NSS_PPE_STATS_L3_DBG_1]); - - nss_ppe_reg_write(PPE_L3_DBG_WR_OFFSET, PPE_L3_DBG2_OFFSET); - nss_ppe_reg_read(PPE_L3_DBG_RD_OFFSET, &stats[NSS_PPE_STATS_L3_DBG_2]); - - nss_ppe_reg_write(PPE_L3_DBG_WR_OFFSET, PPE_L3_DBG3_OFFSET); - nss_ppe_reg_read(PPE_L3_DBG_RD_OFFSET, &stats[NSS_PPE_STATS_L3_DBG_3]); - - nss_ppe_reg_write(PPE_L3_DBG_WR_OFFSET, PPE_L3_DBG4_OFFSET); - nss_ppe_reg_read(PPE_L3_DBG_RD_OFFSET, &stats[NSS_PPE_STATS_L3_DBG_4]); - - nss_ppe_reg_write(PPE_L3_DBG_WR_OFFSET, PPE_L3_DBG_PORT_OFFSET); - nss_ppe_reg_read(PPE_L3_DBG_RD_OFFSET, &stats[NSS_PPE_STATS_L3_DBG_PORT]); - spin_unlock_bh(&nss_ppe_stats_lock); -} - -/* - * nss_ppe_stats_code_get() - * Get PPE CPU and DROP code for last packet processed. - */ -static void nss_ppe_stats_code_get(uint32_t *stats) -{ - uint32_t drop_0, drop_1, cpu_code; - - nss_trace("%s(%d) Start\n", __func__, __LINE__); - if (!stats) { - nss_warning("No memory to copy ppe code\n"); - return; - } - - spin_lock_bh(&nss_ppe_stats_lock); - nss_ppe_reg_write(PPE_PKT_CODE_WR_OFFSET, PPE_PKT_CODE_DROP0_OFFSET); - nss_ppe_reg_read(PPE_PKT_CODE_RD_OFFSET, &drop_0); - - nss_ppe_reg_write(PPE_PKT_CODE_WR_OFFSET, PPE_PKT_CODE_DROP1_OFFSET); - nss_ppe_reg_read(PPE_PKT_CODE_RD_OFFSET, &drop_1); - - stats[NSS_PPE_STATS_CODE_DROP] = PPE_PKT_CODE_DROP_GET(drop_0, drop_1); - - nss_ppe_reg_write(PPE_PKT_CODE_WR_OFFSET, PPE_PKT_CODE_CPU_OFFSET); - nss_ppe_reg_read(PPE_PKT_CODE_RD_OFFSET, &cpu_code); - - stats[NSS_PPE_STATS_CODE_CPU] = PPE_PKT_CODE_CPU_GET(cpu_code); - - spin_unlock_bh(&nss_ppe_stats_lock); -} - -/* - * nss_ppe_port_drop_code_get() - * Get ppe per port drop code. - */ -static void nss_ppe_port_drop_code_get(uint32_t *stats, uint8_t port_id) -{ - uint8_t i; - nss_trace("%s(%d) Start\n", __func__, __LINE__); - if (!stats) { - nss_warning("No memory to copy ppe code\n"); - return; - } - - if (port_id > NSS_PPE_NUM_PHY_PORTS_MAX) { - nss_warning("Port id is out of range\n"); - return; - } - - spin_lock_bh(&nss_ppe_stats_lock); - - for (i = 0; i < NSS_PPE_STATS_DROP_CODE_MAX; i++) { - nss_ppe_reg_read(PPE_DROP_CODE_OFFSET(i, port_id), &stats[i]); - } - - spin_unlock_bh(&nss_ppe_stats_lock); -} - -/* - * nss_ppe_cpu_code_exception_get() - * Get ppe cpu code specific for flow exceptions. - */ -static void nss_ppe_cpu_code_exception_get(uint32_t *stats) -{ - uint8_t i; - nss_trace("%s(%d) Start\n", __func__, __LINE__); - if (!stats) { - nss_warning("No memory to copy ppe code\n"); - return; - } - - spin_lock_bh(&nss_ppe_stats_lock); - - for (i = 0; i < NSS_PPE_STATS_CPU_CODE_EXCEPTION_MAX ; i++) { - nss_ppe_reg_read(PPE_CPU_CODE_OFFSET(i), &stats[i]); - } - - spin_unlock_bh(&nss_ppe_stats_lock); -} - -/* - * nss_ppe_cpu_code_nonexception_get() - * Get ppe cpu code specific for flow exceptions. - */ -static void nss_ppe_cpu_code_nonexception_get(uint32_t *stats) -{ - uint8_t i; - nss_trace("%s(%d) Start\n", __func__, __LINE__); - if (!stats) { - nss_warning("No memory to copy ppe code\n"); - return; - } - - spin_lock_bh(&nss_ppe_stats_lock); - - for (i = 0; i < NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_MAX; i++) { - nss_ppe_reg_read(PPE_CPU_CODE_OFFSET(ppe_cc_nonexception[i]), &stats[i]); - } - - spin_unlock_bh(&nss_ppe_stats_lock); -} - -/* - * nss_ppe_conn_stats_read() - * Read ppe connection statistics - */ -static ssize_t nss_ppe_conn_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int i; - 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; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - - 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_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); - - /* - * Get all stats - */ - nss_ppe_stats_conn_get(ppe_stats); - - /* - * flow stats - */ - spin_lock_bh(&nss_ppe_stats_lock); - for (i = 0; i < NSS_PPE_STATS_CONN_MAX; i++) { - stats_shadow[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); - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - - kfree(lbuf); - kfree(stats_shadow); - return bytes_read; -} - -/* - * nss_ppe_sc_stats_read() - * Read ppe service code statistics - */ -static ssize_t nss_ppe_sc_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int i; - char *lbuf = NULL; - 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; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - - lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(lbuf == NULL)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - memset(sc_stats, 0, sizeof(sc_stats)); - - /* - * Get stats - */ - nss_ppe_stats_sc_get(sc_stats); - - /* - * service code stats - */ - - 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); - } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(lbuf); - return bytes_read; -} - -/* - * nss_ppe_l3_stats_read() - * Read PPE L3 debug statistics - */ -static ssize_t nss_ppe_l3_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int i; - 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; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - - lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(!lbuf)) { - nss_warning("Could not allocate memory for local statistics buffer"); - 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); - - /* - * Get all stats - */ - nss_ppe_stats_l3_get(ppe_stats); - - /* - * flow stats - */ - spin_lock_bh(&nss_ppe_stats_lock); - for (i = 0; i < NSS_PPE_STATS_L3_MAX; i++) { - stats_shadow[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); - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(lbuf); - kfree(stats_shadow); - return bytes_read; -} - -/* - * nss_ppe_code_stats_read() - * Read ppe CPU & DROP code - */ -static ssize_t nss_ppe_code_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int i; - 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; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - - lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(!lbuf)) { - nss_warning("Could not allocate memory for local statistics buffer"); - 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); - - /* - * Get all stats - */ - nss_ppe_stats_code_get(ppe_stats); - - /* - * flow stats - */ - spin_lock_bh(&nss_ppe_stats_lock); - for (i = 0; i < NSS_PPE_STATS_CODE_MAX; i++) { - stats_shadow[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); - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - - kfree(lbuf); - kfree(stats_shadow); - return bytes_read; -} - -/* - * nss_ppe_port_dc_stats_read() - * Read PPE per port drop code stats - */ -static ssize_t nss_ppe_port_dc_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 future reference to add new stats. - */ - uint32_t max_output_lines = NSS_PPE_STATS_DROP_CODE_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; - struct nss_stats_data *data = fp->private_data; - uint32_t *ppe_stats; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(lbuf == NULL)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - ppe_stats = kzalloc(sizeof(uint32_t) * NSS_PPE_STATS_DROP_CODE_MAX, GFP_KERNEL); - if (unlikely(ppe_stats == NULL)) { - kfree(lbuf); - nss_warning("Could not allocate memory for ppe stats buffer"); - 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); - - /* - * 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]; - } - - 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); - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(ppe_stats); - kfree(lbuf); - kfree(stats_shadow); - return bytes_read; -} - -/* - * nss_ppe_exception_cc_stats_read() - * Read PPE CPU code stats specific to flow exceptions - */ -static ssize_t nss_ppe_exception_cc_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 future reference to add new stats. - */ - uint32_t max_output_lines = NSS_PPE_STATS_CPU_CODE_EXCEPTION_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 *ppe_stats; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(lbuf == NULL)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - ppe_stats = kzalloc(sizeof(uint32_t) * NSS_PPE_STATS_CPU_CODE_EXCEPTION_MAX, GFP_KERNEL); - if (unlikely(ppe_stats == NULL)) { - kfree(lbuf); - nss_warning("Could not allocate memory for ppe stats buffer"); - 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); - - /* - * 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]; - } - - 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); - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(ppe_stats); - kfree(lbuf); - kfree(stats_shadow); - return bytes_read; -} - -/* - * nss_ppe_nonexception_cc_stats_read() - * Read PPE CPU code stats for other than flow exceptions - */ -static ssize_t nss_ppe_nonexception_cc_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 future reference to add new stats. - */ - uint32_t max_output_lines = NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_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 *ppe_stats; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(lbuf == NULL)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - ppe_stats = kzalloc(sizeof(uint32_t) * NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_MAX, GFP_KERNEL); - if (unlikely(ppe_stats == NULL)) { - kfree(lbuf); - nss_warning("Could not allocate memory for ppe stats buffer"); - 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 - */ - nss_ppe_cpu_code_nonexception_get(ppe_stats); - - /* - * CPU code stats - */ - - spin_lock_bh(&nss_ppe_stats_lock); - for (i = 0; i < NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_MAX; i++) { - stats_shadow[i] = ppe_stats[i]; - } - - 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); - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(ppe_stats); - kfree(stats_shadow); - kfree(lbuf); - - return bytes_read; -} - -/* - * nss_ppe_conn_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_conn) - -/* - * nss_ppe_l3_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_l3) - -/* - * nss_ppe_code_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_code) - -/* - * nss_ppe_port_dc_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_port_dc) -/* - * nss_ppe_exception_cc_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_exception_cc) - -/* - * nss_ppe_nonexception_cc_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_nonexception_cc) - -/* - * nss_ppe_sc_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_sc) - -/* - * nss_ppe_stats_dentry_create() - * Create PPE statistics debug entry. - */ -void nss_ppe_stats_dentry_create(void) -{ - int i; - struct dentry *ppe_dentry = NULL; - struct dentry *ppe_code_d = NULL; - struct dentry *ppe_drop_d = NULL; - struct dentry *ppe_cpu_d = NULL; - char file_name[10]; - - ppe_dentry = debugfs_create_dir("ppe", nss_top_main.stats_dentry); - if (!ppe_dentry) { - 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)) { - 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)) { - 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); - return; - } - - if (!debugfs_create_file("ppe_code", 0400, ppe_dentry, &nss_top_main, &nss_ppe_code_stats_ops)) { - nss_warning("Failed to create qca-nss-drv/stats/ppe/ppe_code file"); - debugfs_remove_recursive(ppe_dentry); - return; - } - - /* - * ppe exception and drop code stats - */ - ppe_code_d = debugfs_create_dir("code", ppe_dentry); - if (!ppe_code_d) { - 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) { - 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)) { - 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)) { - 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) { - nss_warning("Failed to create qca-nss-drv/stats/ppe/code/drop directory"); - return; - } - - for (i = 0; i < NSS_PPE_NUM_PHY_PORTS_MAX; i++) { - if (i > 0) { - memset(file_name, 0, sizeof(file_name)); - 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)) { - 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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_ppe_stats.h deleted file mode 100644 index bd2cecb8d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_stats.h +++ /dev/null @@ -1,447 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2017-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 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_ppe_stats.h - * NSS PPE statistics header file. - */ - -#ifndef __NSS_PPE_STATS_H -#define __NSS_PPE_STATS_H - -#include - -/* - * NSS PPE connection statistics - */ -enum nss_ppe_stats_conn { - NSS_PPE_STATS_V4_L3_FLOWS, /* No of v4 routed flows */ - NSS_PPE_STATS_V4_L2_FLOWS, /* No of v4 bridge flows */ - NSS_PPE_STATS_V4_CREATE_REQ, /* No of v4 create requests */ - NSS_PPE_STATS_V4_CREATE_FAIL, /* No of v4 create failure */ - NSS_PPE_STATS_V4_DESTROY_REQ, /* No of v4 delete requests */ - NSS_PPE_STATS_V4_DESTROY_FAIL, /* No of v4 delete failure */ - NSS_PPE_STATS_V4_MC_CREATE_REQ, /* No of v4 MC create requests */ - NSS_PPE_STATS_V4_MC_CREATE_FAIL, /* No of v4 MC create failure */ - NSS_PPE_STATS_V4_MC_UPDATE_REQ, /* No of v4 MC update requests */ - NSS_PPE_STATS_V4_MC_UPDATE_FAIL, /* No of v4 MC update failure */ - NSS_PPE_STATS_V4_MC_DESTROY_REQ, /* No of v4 MC delete requests */ - NSS_PPE_STATS_V4_MC_DESTROY_FAIL, /* No of v4 MC delete failure */ - NSS_PPE_STATS_V4_UNKNOWN_INTERFACE, /* No of v4 create failure due to invalid if */ - - NSS_PPE_STATS_V6_L3_FLOWS, /* No of v6 routed flows */ - NSS_PPE_STATS_V6_L2_FLOWS, /* No of v6 bridge flows */ - NSS_PPE_STATS_V6_CREATE_REQ, /* No of v6 create requests */ - NSS_PPE_STATS_V6_CREATE_FAIL, /* No of v6 create failure */ - NSS_PPE_STATS_V6_DESTROY_REQ, /* No of v6 delete requests */ - NSS_PPE_STATS_V6_DESTROY_FAIL, /* No of v6 delete failure */ - NSS_PPE_STATS_V6_MC_CREATE_REQ, /* No of v6 MC create requests */ - NSS_PPE_STATS_V6_MC_CREATE_FAIL, /* No of v6 MC create failure */ - NSS_PPE_STATS_V6_MC_UPDATE_REQ, /* No of v6 MC update requests */ - NSS_PPE_STATS_V6_MC_UPDATE_FAIL, /* No of v6 MC update failure */ - NSS_PPE_STATS_V6_MC_DESTROY_REQ, /* No of v6 MC delete requests */ - NSS_PPE_STATS_V6_MC_DESTROY_FAIL, /* No of v6 MC delete failure */ - NSS_PPE_STATS_V6_UNKNOWN_INTERFACE, /* No of v6 create failure due to invalid if */ - - NSS_PPE_STATS_FAIL_VP_FULL, /* Create req fail due to VP table full */ - NSS_PPE_STATS_FAIL_NH_FULL, /* Create req fail due to nexthop table full */ - NSS_PPE_STATS_FAIL_FLOW_FULL, /* Create req fail due to flow table full */ - NSS_PPE_STATS_FAIL_HOST_FULL, /* Create req fail due to host table full */ - NSS_PPE_STATS_FAIL_PUBIP_FULL, /* Create req fail due to pub-ip table full */ - NSS_PPE_STATS_FAIL_PORT_SETUP, /* Create req fail due to PPE port not setup */ - NSS_PPE_STATS_FAIL_RW_FIFO_FULL, /* Create req fail due to rw fifo full */ - NSS_PPE_STATS_FAIL_FLOW_COMMAND, /* Create req fail due to PPE flow command failure */ - NSS_PPE_STATS_FAIL_UNKNOWN_PROTO, /* Create req fail due to unknown protocol */ - NSS_PPE_STATS_FAIL_PPE_UNRESPONSIVE, /* Create req fail due to PPE not responding */ - NSS_PPE_STATS_CE_OPAQUE_INVALID, /* Create req fail due to invalid opaque in CE */ - NSS_PPE_STATS_FAIL_FQG_FULL, /* Create req fail due to flow qos group full */ - NSS_PPE_STATS_CONN_MAX -}; - -/* - * 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 { - NSS_PPE_STATS_L3_DBG_0, /* PPE L3 debug register 0 */ - NSS_PPE_STATS_L3_DBG_1, /* PPE L3 debug register 1 */ - NSS_PPE_STATS_L3_DBG_2, /* PPE L3 debug register 2 */ - NSS_PPE_STATS_L3_DBG_3, /* PPE L3 debug register 3 */ - NSS_PPE_STATS_L3_DBG_4, /* PPE L3 debug register 4 */ - NSS_PPE_STATS_L3_DBG_PORT, /* PPE L3 debug register Port */ - NSS_PPE_STATS_L3_MAX -}; - -/* - * NSS PPE_code statistics - */ -enum nss_ppe_stats_code { - NSS_PPE_STATS_CODE_CPU, /* PPE CPU code for last packet processed */ - NSS_PPE_STATS_CODE_DROP, /* PPE DROP code for last packet processed */ - NSS_PPE_STATS_CODE_MAX -}; - -/* - * PPE drop codes - */ -enum nss_ppe_stats_dc { - NSS_PPE_STATS_DROP_CODE_UNKNOWN, /* PPE drop code unknown */ - NSS_PPE_STATS_DROP_CODE_EXP_UNKNOWN_L2_PROT, /* PPE drop code exp unknown l2 prot */ - NSS_PPE_STATS_DROP_CODE_EXP_PPPOE_WRONG_VER_TYPE, /* PPE drop code exp pppoe wrong ver type */ - NSS_PPE_STATS_DROP_CODE_EXP_PPPOE_WRONG_CODE, /* PPE drop code exp pppoe wrong code */ - NSS_PPE_STATS_DROP_CODE_EXP_PPPOE_UNSUPPORTED_PPP_PROT, /* PPE drop code exp pppoe unsupported ppp prot */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_WRONG_VER, /* PPE drop code exp ipv4 wrong ver */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_SMALL_IHL, /* PPE drop code exp ipv4 small ihl */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_WITH_OPTION, /* PPE drop code exp ipv4 with option */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_HDR_INCOMPLETE, /* PPE drop code exp ipv4 hdr incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_BAD_TOTAL_LEN, /* PPE drop code exp ipv4 bad total len */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_DATA_INCOMPLETE, /* PPE drop code exp ipv4 data incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_FRAG, /* PPE drop code exp ipv4 frag */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_PING_OF_DEATH, /* PPE drop code exp ipv4 ping of death */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_SNALL_TTL, /* PPE drop code exp ipv4 snall ttl */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_UNK_IP_PROT, /* PPE drop code exp ipv4 unk ip prot */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_CHECKSUM_ERR, /* PPE drop code exp ipv4 checksum err */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_INV_SIP, /* PPE drop code exp ipv4 inv sip */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_INV_DIP, /* PPE drop code exp ipv4 inv dip */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_LAND_ATTACK, /* PPE drop code exp ipv4 land attack */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_AH_HDR_INCOMPLETE, /* PPE drop code exp ipv4 ah hdr incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_AH_HDR_CROSS_BORDER, /* PPE drop code exp ipv4 ah hdr cross border */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV4_ESP_HDR_INCOMPLETE, /* PPE drop code exp ipv4 esp hdr incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_WRONG_VER, /* PPE drop code exp ipv6 wrong ver */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_HDR_INCOMPLETE, /* PPE drop code exp ipv6 hdr incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_BAD_PAYLOAD_LEN, /* PPE drop code exp ipv6 bad payload len */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_DATA_INCOMPLETE, /* PPE drop code exp ipv6 data incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_WITH_EXT_HDR, /* PPE drop code exp ipv6 with ext hdr */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_SMALL_HOP_LIMIT, /* PPE drop code exp ipv6 small hop limit */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_INV_SIP, /* PPE drop code exp ipv6 inv sip */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_INV_DIP, /* PPE drop code exp ipv6 inv dip */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_LAND_ATTACK, /* PPE drop code exp ipv6 land attack */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_FRAG, /* PPE drop code exp ipv6 frag */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_PING_OF_DEATH, /* PPE drop code exp ipv6 ping of death */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_WITH_MORE_EXT_HDR, /* PPE drop code exp ipv6 with more ext hdr */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_UNK_LAST_NEXT_HDR, /* PPE drop code exp ipv6 unk last next hdr */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_MOBILITY_HDR_INCOMPLETE, /* PPE drop code exp ipv6 mobility hdr incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_MOBILITY_HDR_CROSS_BORDER, /* PPE drop code exp ipv6 mobility hdr cross border */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_AH_HDR_INCOMPLETE, /* PPE drop code exp ipv6 ah hdr incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_AH_HDR_CROSS_BORDER, /* PPE drop code exp ipv6 ah hdr cross border */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_ESP_HDR_INCOMPLETE, /* PPE drop code exp ipv6 esp hdr incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_ESP_HDR_CROSS_BORDER, /* PPE drop code exp ipv6 esp hdr cross border */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_OTHER_EXT_HDR_INCOMPLETE, /* PPE drop code exp ipv6 other ext hdr incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_IPV6_OTHER_EXT_HDR_CROSS_BORDER, /* PPE drop code exp ipv6 other ext hdr cross border */ - NSS_PPE_STATS_DROP_CODE_EXP_TCP_HDR_INCOMPLETE, /* PPE drop code exp tcp hdr incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_TCP_HDR_CROSS_BORDER, /* PPE drop code exp tcp hdr cross border */ - NSS_PPE_STATS_DROP_CODE_EXP_TCP_SMAE_SP_DP, /* PPE drop code exp tcp smae sp dp */ - NSS_PPE_STATS_DROP_CODE_EXP_TCP_SMALL_DATA_OFFSET, /* PPE drop code exp tcp small data offset */ - NSS_PPE_STATS_DROP_CODE_EXP_TCP_FLAGS_0, /* PPE drop code exp tcp flags 0 */ - NSS_PPE_STATS_DROP_CODE_EXP_TCP_FLAGS_1, /* PPE drop code exp tcp flags 1 */ - NSS_PPE_STATS_DROP_CODE_EXP_TCP_FLAGS_2, /* PPE drop code exp tcp flags 2 */ - NSS_PPE_STATS_DROP_CODE_EXP_TCP_FLAGS_3, /* PPE drop code exp tcp flags 3 */ - NSS_PPE_STATS_DROP_CODE_EXP_TCP_FLAGS_4, /* PPE drop code exp tcp flags 4 */ - NSS_PPE_STATS_DROP_CODE_EXP_TCP_FLAGS_5, /* PPE drop code exp tcp flags 5 */ - NSS_PPE_STATS_DROP_CODE_EXP_TCP_FLAGS_6, /* PPE drop code exp tcp flags 6 */ - NSS_PPE_STATS_DROP_CODE_EXP_TCP_FLAGS_7, /* PPE drop code exp tcp flags 7 */ - NSS_PPE_STATS_DROP_CODE_EXP_TCP_CHECKSUM_ERR, /* PPE drop code exp tcp checksum err */ - NSS_PPE_STATS_DROP_CODE_EXP_UDP_HDR_INCOMPLETE, /* PPE drop code exp udp hdr incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_UDP_HDR_CROSS_BORDER, /* PPE drop code exp udp hdr cross border */ - NSS_PPE_STATS_DROP_CODE_EXP_UDP_SMAE_SP_DP, /* PPE drop code exp udp smae sp dp */ - NSS_PPE_STATS_DROP_CODE_EXP_UDP_BAD_LEN, /* PPE drop code exp udp bad len */ - NSS_PPE_STATS_DROP_CODE_EXP_UDP_DATA_INCOMPLETE, /* PPE drop code exp udp data incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_UDP_CHECKSUM_ERR, /* PPE drop code exp udp checksum err */ - NSS_PPE_STATS_DROP_CODE_EXP_UDP_LITE_HDR_INCOMPLETE, /* PPE drop code exp udp lite hdr incomplete */ - NSS_PPE_STATS_DROP_CODE_EXP_UDP_LITE_HDR_CROSS_BORDER, /* PPE drop code exp udp lite hdr cross border */ - NSS_PPE_STATS_DROP_CODE_EXP_UDP_LITE_SMAE_SP_DP, /* PPE drop code exp udp lite smae sp dp */ - NSS_PPE_STATS_DROP_CODE_EXP_UDP_LITE_CSM_COV_1_TO_7, /* PPE drop code exp udp lite csm cov 1 to 7 */ - NSS_PPE_STATS_DROP_CODE_EXP_UDP_LITE_CSM_COV_TOO_LONG, /* PPE drop code exp udp lite csm cov too long */ - NSS_PPE_STATS_DROP_CODE_EXP_UDP_LITE_CSM_COV_CROSS_BORDER, /* PPE drop code exp udp lite csm cov cross border */ - NSS_PPE_STATS_DROP_CODE_EXP_UDP_LITE_CHECKSUM_ERR, /* PPE drop code exp udp lite checksum err */ - NSS_PPE_STATS_DROP_CODE_L3_MC_BRIDGE_ACTION, /* PPE drop code l3 mc bridge action */ - NSS_PPE_STATS_DROP_CODE_L3_NO_ROUTE_PREHEAD_NAT_ACTION, /* PPE drop code l3 no route prehead nat action */ - NSS_PPE_STATS_DROP_CODE_L3_NO_ROUTE_PREHEAD_NAT_ERROR, /* PPE drop code l3 no route prehead nat error */ - NSS_PPE_STATS_DROP_CODE_L3_ROUTE_ACTION, /* PPE drop code l3 route action */ - NSS_PPE_STATS_DROP_CODE_L3_NO_ROUTE_ACTION, /* PPE drop code l3 no route action */ - NSS_PPE_STATS_DROP_CODE_L3_NO_ROUTE_NH_INVALID_ACTION, /* PPE drop code l3 no route nh invalid action */ - NSS_PPE_STATS_DROP_CODE_L3_NO_ROUTE_PREHEAD_ACTION, /* PPE drop code l3 no route prehead action */ - NSS_PPE_STATS_DROP_CODE_L3_BRIDGE_ACTION, /* PPE drop code l3 bridge action */ - NSS_PPE_STATS_DROP_CODE_L3_FLOW_ACTION, /* PPE drop code l3 flow action */ - NSS_PPE_STATS_DROP_CODE_L3_FLOW_MISS_ACTION, /* PPE drop code l3 flow miss action */ - NSS_PPE_STATS_DROP_CODE_L2_EXP_MRU_FAIL, /* PPE drop code l2 exp mru fail */ - NSS_PPE_STATS_DROP_CODE_L2_EXP_MTU_FAIL, /* PPE drop code l2 exp mtu fail */ - NSS_PPE_STATS_DROP_CODE_L3_EXP_IP_PREFIX_BC, /* PPE drop code l3 exp ip prefix bc */ - NSS_PPE_STATS_DROP_CODE_L3_EXP_MTU_FAIL, /* PPE drop code l3 exp mtu fail */ - NSS_PPE_STATS_DROP_CODE_L3_EXP_MRU_FAIL, /* PPE drop code l3 exp mru fail */ - NSS_PPE_STATS_DROP_CODE_L3_EXP_ICMP_RDT, /* PPE drop code l3 exp icmp rdt */ - NSS_PPE_STATS_DROP_CODE_FAKE_MAC_HEADER_ERR, /* PPE drop code fake mac header err */ - NSS_PPE_STATS_DROP_CODE_L3_EXP_IP_RT_TTL_ZERO, /* PPE drop code l3 exp ip rt ttl zero */ - NSS_PPE_STATS_DROP_CODE_L3_FLOW_SERVICE_CODE_LOOP, /* PPE drop code l3 flow service code loop */ - NSS_PPE_STATS_DROP_CODE_L3_FLOW_DE_ACCELEARTE, /* PPE drop code l3 flow de accelearte */ - NSS_PPE_STATS_DROP_CODE_L3_EXP_FLOW_SRC_IF_CHK_FAIL, /* PPE drop code l3 exp flow src if chk fail */ - NSS_PPE_STATS_DROP_CODE_L3_FLOW_SYNC_TOGGLE_MISMATCH, /* PPE drop code l3 flow sync toggle mismatch */ - NSS_PPE_STATS_DROP_CODE_L3_EXP_MTU_DF_FAIL, /* PPE drop code l3 exp mtu df fail */ - NSS_PPE_STATS_DROP_CODE_L3_EXP_PPPOE_MULTICAST, /* PPE drop code l3 exp pppoe multicast */ - NSS_PPE_STATS_DROP_CODE_IPV4_SG_UNKNOWN, /* PPE drop code ipv4 sg unknown */ - NSS_PPE_STATS_DROP_CODE_IPV6_SG_UNKNOWN, /* PPE drop code ipv6 sg unknown */ - NSS_PPE_STATS_DROP_CODE_ARP_SG_UNKNOWN, /* PPE drop code arp sg unknown */ - NSS_PPE_STATS_DROP_CODE_ND_SG_UNKNOWN, /* PPE drop code nd sg unknown */ - NSS_PPE_STATS_DROP_CODE_IPV4_SG_VIO, /* PPE drop code ipv4 sg vio */ - NSS_PPE_STATS_DROP_CODE_IPV6_SG_VIO, /* PPE drop code ipv6 sg vio */ - NSS_PPE_STATS_DROP_CODE_ARP_SG_VIO, /* PPE drop code arp sg vio */ - NSS_PPE_STATS_DROP_CODE_ND_SG_VIO, /* PPE drop code nd sg vio */ - NSS_PPE_STATS_DROP_CODE_L2_NEW_MAC_ADDRESS, /* PPE drop code l2 new mac address */ - NSS_PPE_STATS_DROP_CODE_L2_HASH_COLLISION, /* PPE drop code l2 hash collision */ - NSS_PPE_STATS_DROP_CODE_L2_STATION_MOVE, /* PPE drop code l2 station move */ - NSS_PPE_STATS_DROP_CODE_L2_LEARN_LIMIT, /* PPE drop code l2 learn limit */ - NSS_PPE_STATS_DROP_CODE_L2_SA_LOOKUP_ACTION, /* PPE drop code l2 sa lookup action */ - NSS_PPE_STATS_DROP_CODE_L2_DA_LOOKUP_ACTION, /* PPE drop code l2 da lookup action */ - NSS_PPE_STATS_DROP_CODE_APP_CTRL_ACTION, /* PPE drop code app ctrl action */ - NSS_PPE_STATS_DROP_CODE_IN_VLAN_FILTER_ACTION, /* PPE drop code in vlan filter action */ - NSS_PPE_STATS_DROP_CODE_IN_VLAN_XLT_MISS, /* PPE drop code in vlan xlt miss */ - NSS_PPE_STATS_DROP_CODE_EG_VLAN_FILTER_DROP, /* PPE drop code eg vlan filter drop */ - NSS_PPE_STATS_DROP_CODE_ACL_PRE_ACTION, /* PPE drop code acl pre action */ - NSS_PPE_STATS_DROP_CODE_ACL_POST_ACTION, /* PPE drop code acl post action */ - NSS_PPE_STATS_DROP_CODE_MC_BC_SA, /* PPE drop code mc bc sa */ - NSS_PPE_STATS_DROP_CODE_NO_DESTINATION, /* PPE drop code no destination */ - NSS_PPE_STATS_DROP_CODE_STG_IN_FILTER, /* PPE drop code stg in filter */ - NSS_PPE_STATS_DROP_CODE_STG_EG_FILTER, /* PPE drop code stg eg filter */ - NSS_PPE_STATS_DROP_CODE_SOURCE_FILTER_FAIL, /* PPE drop code source filter fail */ - NSS_PPE_STATS_DROP_CODE_TRUNK_SEL_FAIL, /* PPE drop code trunk sel fail */ - NSS_PPE_STATS_DROP_CODE_TX_EN_FAIL, /* PPE drop code tx en fail */ - NSS_PPE_STATS_DROP_CODE_VLAN_TAG_FMT, /* PPE drop code vlan tag fmt */ - NSS_PPE_STATS_DROP_CODE_CRC_ERR, /* PPE drop code crc err */ - NSS_PPE_STATS_DROP_CODE_PAUSE_FRAME, /* PPE drop code pause frame */ - NSS_PPE_STATS_DROP_CODE_PROMISC, /* PPE drop code promisc */ - NSS_PPE_STATS_DROP_CODE_ISOLATION, /* PPE drop code isolation */ - NSS_PPE_STATS_DROP_CODE_MGMT_APP, /* PPE drop code mgmt app */ - NSS_PPE_STATS_DROP_CODE_FAKE_L2_PROT_ERR, /* PPE drop code fake l2 prot err */ - NSS_PPE_STATS_DROP_CODE_POLICER, /* PPE drop code policer */ - NSS_PPE_STATS_DROP_CODE_MAX /* PPE drop code max */ -}; - -/* - * PPE CPU codes - */ -#define NSS_PPE_STATS_CPU_CODE_MAX 150 -#define NSS_PPE_STATS_CPU_CODE_EXCEPTION_MAX 69 -#define NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_START 69 -#define NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_MAX (NSS_PPE_STATS_CPU_CODE_MAX - NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_START) - -enum nss_ppe_stats_cc { - NSS_PPE_STATS_CPU_CODE_FORWARDING = 0, /* PPE cpu code forwarding */ - NSS_PPE_STATS_CPU_CODE_EXP_UNKNOWN_L2_PROT = 1, /* PPE cpu code exp unknown l2 prot */ - NSS_PPE_STATS_CPU_CODE_EXP_PPPOE_WRONG_VER_TYPE = 2, /* PPE cpu code exp pppoe wrong ver type */ - NSS_PPE_STATS_CPU_CODE_EXP_PPPOE_WRONG_CODE = 3, /* PPE cpu code exp pppoe wrong code */ - NSS_PPE_STATS_CPU_CODE_EXP_PPPOE_UNSUPPORTED_PPP_PROT = 4, /* PPE cpu code exp pppoe unsupported ppp prot */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_WRONG_VER = 5, /* PPE cpu code exp ipv4 wrong ver */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_SMALL_IHL = 6, /* PPE cpu code exp ipv4 small ihl */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_WITH_OPTION = 7, /* PPE cpu code exp ipv4 with option */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_HDR_INCOMPLETE = 8, /* PPE cpu code exp ipv4 hdr incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_BAD_TOTAL_LEN = 9, /* PPE cpu code exp ipv4 bad total len */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_DATA_INCOMPLETE = 10, /* PPE cpu code exp ipv4 data incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_FRAG = 11, /* PPE cpu code exp ipv4 frag */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_PING_OF_DEATH = 12, /* PPE cpu code exp ipv4 ping of death */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_SNALL_TTL = 13, /* PPE cpu code exp ipv4 snall ttl */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_UNK_IP_PROT = 14, /* PPE cpu code exp ipv4 unk ip prot */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_CHECKSUM_ERR = 15, /* PPE cpu code exp ipv4 checksum err */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_INV_SIP = 16, /* PPE cpu code exp ipv4 inv sip */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_INV_DIP = 17, /* PPE cpu code exp ipv4 inv dip */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_LAND_ATTACK = 18, /* PPE cpu code exp ipv4 land attack */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_AH_HDR_INCOMPLETE = 19, /* PPE cpu code exp ipv4 ah hdr incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_AH_HDR_CROSS_BORDER = 20, /* PPE cpu code exp ipv4 ah hdr cross border */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV4_ESP_HDR_INCOMPLETE = 21, /* PPE cpu code exp ipv4 esp hdr incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_WRONG_VER = 22, /* PPE cpu code exp ipv6 wrong ver */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_HDR_INCOMPLETE = 23, /* PPE cpu code exp ipv6 hdr incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_BAD_PAYLOAD_LEN = 24, /* PPE cpu code exp ipv6 bad payload len */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_DATA_INCOMPLETE = 25, /* PPE cpu code exp ipv6 data incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_WITH_EXT_HDR = 26, /* PPE cpu code exp ipv6 with ext hdr */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_SMALL_HOP_LIMIT = 27, /* PPE cpu code exp ipv6 small hop limit */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_INV_SIP = 28, /* PPE cpu code exp ipv6 inv sip */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_INV_DIP = 29, /* PPE cpu code exp ipv6 inv dip */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_LAND_ATTACK = 30, /* PPE cpu code exp ipv6 land attack */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_FRAG = 31, /* PPE cpu code exp ipv6 frag */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_PING_OF_DEATH = 32, /* PPE cpu code exp ipv6 ping of death */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_WITH_MORE_EXT_HDR = 33, /* PPE cpu code exp ipv6 with more ext hdr */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_UNK_LAST_NEXT_HDR = 34, /* PPE cpu code exp ipv6 unk last next hdr */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_MOBILITY_HDR_INCOMPLETE = 35, /* PPE cpu code exp ipv6 mobility hdr incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_MOBILITY_HDR_CROSS_BORDER = 36, /* PPE cpu code exp ipv6 mobility hdr cross border */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_AH_HDR_INCOMPLETE = 37, /* PPE cpu code exp ipv6 ah hdr incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_AH_HDR_CROSS_BORDER = 38, /* PPE cpu code exp ipv6 ah hdr cross border */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_ESP_HDR_INCOMPLETE = 39, /* PPE cpu code exp ipv6 esp hdr incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_ESP_HDR_CROSS_BORDER = 40, /* PPE cpu code exp ipv6 esp hdr cross border */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_OTHER_EXT_HDR_INCOMPLETE = 41, /* PPE cpu code exp ipv6 other ext hdr incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_IPV6_OTHER_EXT_HDR_CROSS_BORDER = 42, /* PPE cpu code exp ipv6 other ext hdr cross border */ - NSS_PPE_STATS_CPU_CODE_EXP_TCP_HDR_INCOMPLETE = 43, /* PPE cpu code exp tcp hdr incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_TCP_HDR_CROSS_BORDER = 44, /* PPE cpu code exp tcp hdr cross border */ - NSS_PPE_STATS_CPU_CODE_EXP_TCP_SMAE_SP_DP = 45, /* PPE cpu code exp tcp smae sp dp */ - NSS_PPE_STATS_CPU_CODE_EXP_TCP_SMALL_DATA_OFFSET = 46, /* PPE cpu code exp tcp small data offset */ - NSS_PPE_STATS_CPU_CODE_EXP_TCP_FLAGS_0 = 47, /* PPE cpu code exp tcp flags 0 */ - NSS_PPE_STATS_CPU_CODE_EXP_TCP_FLAGS_1 = 48, /* PPE cpu code exp tcp flags 1 */ - NSS_PPE_STATS_CPU_CODE_EXP_TCP_FLAGS_2 = 49, /* PPE cpu code exp tcp flags 2 */ - NSS_PPE_STATS_CPU_CODE_EXP_TCP_FLAGS_3 = 50, /* PPE cpu code exp tcp flags 3 */ - NSS_PPE_STATS_CPU_CODE_EXP_TCP_FLAGS_4 = 51, /* PPE cpu code exp tcp flags 4 */ - NSS_PPE_STATS_CPU_CODE_EXP_TCP_FLAGS_5 = 52, /* PPE cpu code exp tcp flags 5 */ - NSS_PPE_STATS_CPU_CODE_EXP_TCP_FLAGS_6 = 53, /* PPE cpu code exp tcp flags 6 */ - NSS_PPE_STATS_CPU_CODE_EXP_TCP_FLAGS_7 = 54, /* PPE cpu code exp tcp flags 7 */ - NSS_PPE_STATS_CPU_CODE_EXP_TCP_CHECKSUM_ERR = 55, /* PPE cpu code exp tcp checksum err */ - NSS_PPE_STATS_CPU_CODE_EXP_UDP_HDR_INCOMPLETE = 56, /* PPE cpu code exp udp hdr incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_UDP_HDR_CROSS_BORDER = 57, /* PPE cpu code exp udp hdr cross border */ - NSS_PPE_STATS_CPU_CODE_EXP_UDP_SMAE_SP_DP = 58, /* PPE cpu code exp udp smae sp dp */ - NSS_PPE_STATS_CPU_CODE_EXP_UDP_BAD_LEN = 59, /* PPE cpu code exp udp bad len */ - NSS_PPE_STATS_CPU_CODE_EXP_UDP_DATA_INCOMPLETE = 60, /* PPE cpu code exp udp data incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_UDP_CHECKSUM_ERR = 61, /* PPE cpu code exp udp checksum err */ - NSS_PPE_STATS_CPU_CODE_EXP_UDP_LITE_HDR_INCOMPLETE = 62, /* PPE cpu code exp udp lite hdr incomplete */ - NSS_PPE_STATS_CPU_CODE_EXP_UDP_LITE_HDR_CROSS_BORDER = 63, /* PPE cpu code exp udp lite hdr cross border */ - NSS_PPE_STATS_CPU_CODE_EXP_UDP_LITE_SMAE_SP_DP = 64, /* PPE cpu code exp udp lite smae sp dp */ - NSS_PPE_STATS_CPU_CODE_EXP_UDP_LITE_CSM_COV_1_TO_7 = 65, /* PPE cpu code exp udp lite csm cov 1 to 7 */ - NSS_PPE_STATS_CPU_CODE_EXP_UDP_LITE_CSM_COV_TOO_LONG = 66, /* PPE cpu code exp udp lite csm cov too long */ - NSS_PPE_STATS_CPU_CODE_EXP_UDP_LITE_CSM_COV_CROSS_BORDER = 67, /* PPE cpu code exp udp lite csm cov cross border */ - NSS_PPE_STATS_CPU_CODE_EXP_UDP_LITE_CHECKSUM_ERR = 68, /* PPE cpu code exp udp lite checksum err */ - NSS_PPE_STATS_CPU_CODE_EXP_FAKE_L2_PROT_ERR = 69, /* PPE cpu code exp fake l2 prot err */ - NSS_PPE_STATS_CPU_CODE_EXP_FAKE_MAC_HEADER_ERR = 70, /* PPE cpu code exp fake mac header err */ - NSS_PPE_STATS_CPU_CODE_EXP_BITMAP_MAX = 78, /* PPE cpu code exp bitmap max */ - NSS_PPE_STATS_CPU_CODE_L2_EXP_MRU_FAIL = 79, /* PPE cpu code l2 exp mru fail */ - NSS_PPE_STATS_CPU_CODE_L2_EXP_MTU_FAIL = 80, /* PPE cpu code l2 exp mtu fail */ - NSS_PPE_STATS_CPU_CODE_L3_EXP_IP_PREFIX_BC = 81, /* PPE cpu code l3 exp ip prefix bc */ - NSS_PPE_STATS_CPU_CODE_L3_EXP_MTU_FAIL = 82, /* PPE cpu code l3 exp mtu fail */ - NSS_PPE_STATS_CPU_CODE_L3_EXP_MRU_FAIL = 83, /* PPE cpu code l3 exp mru fail */ - NSS_PPE_STATS_CPU_CODE_L3_EXP_ICMP_RDT = 84, /* PPE cpu code l3 exp icmp rdt */ - NSS_PPE_STATS_CPU_CODE_L3_EXP_IP_RT_TTL1_TO_ME = 85, /* PPE cpu code l3 exp ip rt ttl1 to me */ - NSS_PPE_STATS_CPU_CODE_L3_EXP_IP_RT_TTL_ZERO = 86, /* PPE cpu code l3 exp ip rt ttl zero */ - NSS_PPE_STATS_CPU_CODE_L3_FLOW_SERVICE_CODE_LOOP = 87, /* PPE cpu code l3 flow service code loop */ - NSS_PPE_STATS_CPU_CODE_L3_FLOW_DE_ACCELERATE = 88, /* PPE cpu code l3 flow de accelerate */ - NSS_PPE_STATS_CPU_CODE_L3_EXP_FLOW_SRC_IF_CHK_FAIL = 89, /* PPE cpu code l3 exp flow src if chk fail */ - NSS_PPE_STATS_CPU_CODE_L3_FLOW_SYNC_TOGGLE_MISMATCH = 90, /* PPE cpu code l3 flow sync toggle mismatch */ - NSS_PPE_STATS_CPU_CODE_L3_EXP_MTU_DF_FAIL = 91, /* PPE cpu code l3 exp mtu df fail */ - NSS_PPE_STATS_CPU_CODE_L3_EXP_PPPOE_MULTICAST = 92, /* PPE cpu code l3 exp pppoe multicast */ - NSS_PPE_STATS_CPU_CODE_MGMT_OFFSET = 96, /* PPE cpu code mgmt offset */ - NSS_PPE_STATS_CPU_CODE_MGMT_EAPOL = 97, /* PPE cpu code mgmt eapol */ - NSS_PPE_STATS_CPU_CODE_MGMT_PPPOE_DIS = 98, /* PPE cpu code mgmt pppoe dis */ - NSS_PPE_STATS_CPU_CODE_MGMT_IGMP = 99, /* PPE cpu code mgmt igmp */ - NSS_PPE_STATS_CPU_CODE_MGMT_ARP_REQ = 100, /* PPE cpu code mgmt arp req */ - NSS_PPE_STATS_CPU_CODE_MGMT_ARP_REP = 101, /* PPE cpu code mgmt arp rep */ - NSS_PPE_STATS_CPU_CODE_MGMT_DHCPv4 = 102, /* PPE cpu code mgmt dhcpv4 */ - NSS_PPE_STATS_CPU_CODE_MGMT_MLD = 107, /* PPE cpu code mgmt mld */ - NSS_PPE_STATS_CPU_CODE_MGMT_NS = 108, /* PPE cpu code mgmt ns */ - NSS_PPE_STATS_CPU_CODE_MGMT_NA = 109, /* PPE cpu code mgmt na */ - NSS_PPE_STATS_CPU_CODE_MGMT_DHCPv6 = 110, /* PPE cpu code mgmt dhcpv6 */ - NSS_PPE_STATS_CPU_CODE_PTP_OFFSET = 112, /* PPE cpu code ptp offset */ - NSS_PPE_STATS_CPU_CODE_PTP_SYNC = 113, /* PPE cpu code ptp sync */ - NSS_PPE_STATS_CPU_CODE_PTP_FOLLOW_UP = 114, /* PPE cpu code ptp follow up */ - NSS_PPE_STATS_CPU_CODE_PTP_DELAY_REQ = 115, /* PPE cpu code ptp delay req */ - NSS_PPE_STATS_CPU_CODE_PTP_DELAY_RESP = 116, /* PPE cpu code ptp delay resp */ - NSS_PPE_STATS_CPU_CODE_PTP_PDELAY_REQ = 117, /* PPE cpu code ptp pdelay req */ - NSS_PPE_STATS_CPU_CODE_PTP_PDELAY_RESP = 118, /* PPE cpu code ptp pdelay resp */ - NSS_PPE_STATS_CPU_CODE_PTP_PDELAY_RESP_FOLLOW_UP = 119, /* PPE cpu code ptp pdelay resp follow up */ - NSS_PPE_STATS_CPU_CODE_PTP_ANNOUNCE = 120, /* PPE cpu code ptp announce */ - NSS_PPE_STATS_CPU_CODE_PTP_MANAGEMENT = 121, /* PPE cpu code ptp management */ - NSS_PPE_STATS_CPU_CODE_PTP_SIGNALING = 122, /* PPE cpu code ptp signaling */ - NSS_PPE_STATS_CPU_CODE_PTP_PKT_RSV_MSG = 127, /* PPE cpu code ptp pkt rsv msg */ - NSS_PPE_STATS_CPU_CODE_IPV4_SG_UNKNOWN = 136, /* PPE cpu code ipv4 sg unknown */ - NSS_PPE_STATS_CPU_CODE_IPV6_SG_UNKNOWN = 137, /* PPE cpu code ipv6 sg unknown */ - NSS_PPE_STATS_CPU_CODE_ARP_SG_UNKNOWN = 138, /* PPE cpu code arp sg unknown */ - NSS_PPE_STATS_CPU_CODE_ND_SG_UNKNOWN = 139, /* PPE cpu code nd sg unknown */ - NSS_PPE_STATS_CPU_CODE_IPV4_SG_VIO = 140, /* PPE cpu code ipv4 sg vio */ - NSS_PPE_STATS_CPU_CODE_IPV6_SG_VIO = 141, /* PPE cpu code ipv6 sg vio */ - NSS_PPE_STATS_CPU_CODE_ARP_SG_VIO = 142, /* PPE cpu code arp sg vio */ - NSS_PPE_STATS_CPU_CODE_ND_SG_VIO = 143, /* PPE cpu code nd sg vio */ - NSS_PPE_STATS_CPU_CODE_L3_ROUTING_IP_TO_ME = 148, /* PPE cpu code l3 routing ip to me */ - NSS_PPE_STATS_CPU_CODE_L3_FLOW_SNAT_ACTION = 149, /* PPE cpu code l3 flow snat action */ - NSS_PPE_STATS_CPU_CODE_L3_FLOW_DNAT_ACTION = 150, /* PPE cpu code l3 flow dnat action */ - NSS_PPE_STATS_CPU_CODE_L3_FLOW_RT_ACTION = 151, /* PPE cpu code l3 flow rt action */ - NSS_PPE_STATS_CPU_CODE_L3_FLOW_BR_ACTION = 152, /* PPE cpu code l3 flow br action */ - NSS_PPE_STATS_CPU_CODE_L3_MC_BRIDGE_ACTION = 153, /* PPE cpu code l3 mc bridge action */ - NSS_PPE_STATS_CPU_CODE_L3_ROUTE_PREHEAD_RT_ACTION = 154, /* PPE cpu code l3 route prehead rt action */ - NSS_PPE_STATS_CPU_CODE_L3_ROUTE_PREHEAD_SNAPT_ACTION = 155, /* PPE cpu code l3 route prehead snapt action */ - NSS_PPE_STATS_CPU_CODE_L3_ROUTE_PREHEAD_DNAPT_ACTION = 156, /* PPE cpu code l3 route prehead dnapt action */ - NSS_PPE_STATS_CPU_CODE_L3_ROUTE_PREHEAD_SNAT_ACTION = 157, /* PPE cpu code l3 route prehead snat action */ - NSS_PPE_STATS_CPU_CODE_L3_ROUTE_PREHEAD_DNAT_ACTION = 158, /* PPE cpu code l3 route prehead dnat action */ - NSS_PPE_STATS_CPU_CODE_L3_NO_ROUTE_PREHEAD_NAT_ACTION = 159, /* PPE cpu code l3 no route prehead nat action */ - NSS_PPE_STATS_CPU_CODE_L3_NO_ROUTE_PREHEAD_NAT_ERROR = 160, /* PPE cpu code l3 no route prehead nat error */ - NSS_PPE_STATS_CPU_CODE_L3_ROUTE_ACTION = 161, /* PPE cpu code l3 route action */ - NSS_PPE_STATS_CPU_CODE_L3_NO_ROUTE_ACTION = 162, /* PPE cpu code l3 no route action */ - NSS_PPE_STATS_CPU_CODE_L3_NO_ROUTE_NH_INVALID_ACTION = 163, /* PPE cpu code l3 no route nh invalid action */ - NSS_PPE_STATS_CPU_CODE_L3_NO_ROUTE_PREHEAD_ACTION = 164, /* PPE cpu code l3 no route prehead action */ - NSS_PPE_STATS_CPU_CODE_L3_BRIDGE_ACTION = 165, /* PPE cpu code l3 bridge action */ - NSS_PPE_STATS_CPU_CODE_L3_FLOW_ACTION = 166, /* PPE cpu code l3 flow action */ - NSS_PPE_STATS_CPU_CODE_L3_FLOW_MISS_ACTION = 167, /* PPE cpu code l3 flow miss action */ - NSS_PPE_STATS_CPU_CODE_L2_NEW_MAC_ADDRESS = 168, /* PPE cpu code l2 new mac address */ - NSS_PPE_STATS_CPU_CODE_L2_HASH_COLLISION = 169, /* PPE cpu code l2 hash collision */ - NSS_PPE_STATS_CPU_CODE_L2_STATION_MOVE = 170, /* PPE cpu code l2 station move */ - NSS_PPE_STATS_CPU_CODE_L2_LEARN_LIMIT = 171, /* PPE cpu code l2 learn limit */ - NSS_PPE_STATS_CPU_CODE_L2_SA_LOOKUP_ACTION = 172, /* PPE cpu code l2 sa lookup action */ - NSS_PPE_STATS_CPU_CODE_L2_DA_LOOKUP_ACTION = 173, /* PPE cpu code l2 da lookup action */ - NSS_PPE_STATS_CPU_CODE_APP_CTRL_ACTION = 174, /* PPE cpu code app ctrl action */ - NSS_PPE_STATS_CPU_CODE_IN_VLAN_FILTER_ACTION = 175, /* PPE cpu code in vlan filter action */ - NSS_PPE_STATS_CPU_CODE_IN_VLAN_XLT_MISS = 176, /* PPE cpu code in vlan xlt miss */ - NSS_PPE_STATS_CPU_CODE_EG_VLAN_FILTER_DROP = 177, /* PPE cpu code eg vlan filter drop */ - NSS_PPE_STATS_CPU_CODE_ACL_PRE_ACTION = 178, /* PPE cpu code acl pre action */ - NSS_PPE_STATS_CPU_CODE_ACL_POST_ACTION = 179, /* PPE cpu code acl post action */ - NSS_PPE_STATS_CPU_CODE_SERVICE_CODE_ACTION = 180, /* PPE cpu code service code action */ -}; - -/* - * nss_ppe_sc_stats_debug - */ -struct nss_ppe_sc_stats_debug { - uint64_t nss_ppe_sc_cb_unregister; /* Per service-code counter for callback not registered */ - uint64_t nss_ppe_sc_cb_success; /* Per service-code coutner for successful callback */ - uint64_t nss_ppe_sc_cb_failure; /* Per service-code counter for failure callback */ -}; - -/* - * NSS PPE statistics - */ -struct nss_ppe_stats_debug { - uint64_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]; - int32_t if_index; - uint32_t if_num; /* nss interface number */ - bool valid; -}; - -/* - * Data structures to store NSS PPE debug statistics - */ -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); - -#endif /* __NSS_PPE_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_ppe_strings.c deleted file mode 100644 index 294996449..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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; - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_ppe_strings.h deleted file mode 100644 index e8fe77ec2..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp.c b/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp.c deleted file mode 100644 index a5411cec9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp.c +++ /dev/null @@ -1,864 +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. - ************************************************************************** - */ - -/* - * 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 - */ -static struct nss_ppe_vp_pvt { - struct semaphore sem; - struct completion complete; - int response; - void *cb; - void *app_data; - nss_ppe_port_t ppe_port_num; -} ppe_vp_pvt; - -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. - */ -static inline bool nss_ppe_vp_verify_ifnum(int if_num) -{ - return (if_num == NSS_PPE_VP_INTERFACE); -} - -/* - * 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. - */ -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) -{ - 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; -} - -/* - * nss_ppe_vp_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -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; - } - - 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. - */ - nss_ppe_vp_log_tx_msg(msg); - - /* - * 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); - 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); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} - -/* - * nss_ppe_vp_tx_msg_sync() - * Transmit a ppe_vp message to NSS firmware synchronously. - */ -nss_tx_status_t nss_ppe_vp_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_ppe_vp_msg *npvm) -{ - nss_tx_status_t status; - int ret = 0; - - down(&ppe_vp_pvt.sem); - - status = nss_ppe_vp_tx_msg(nss_ctx, npvm); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: ppe_tx_msg failed", 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); - 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_port_t nss_ppe_vp_get_ppe_port_by_nssif(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num) -{ - 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_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; - } - - 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_trace("%px: PPE_VP will be created for an interface: %d", nss_ctx, if_num); - - /* - * 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); - - 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; - } - - 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); - } -} - -/* - * nss_ppe_vp_handler() - * Handle NSS -> HLOS messages for ppe - */ -static void nss_ppe_vp_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_ppe_vp_msg *msg = (struct nss_ppe_vp_msg *)ncm; - 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); - BUG_ON(!nss_ppe_vp_verify_ifnum(ncm->interface)); - - /* - * 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); - 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)); - 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; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * Callback - */ - cb = (nss_ppe_vp_msg_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - cb(ctx, msg); -} - -/* - * nss_ppe_vp_destroy_handler() - * PPE VP destroy handler. - */ -static int nss_ppe_vp_destroy_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_ctx_instance *nss_ctx = nss_ppe_vp_get_context(); - int32_t if_num; - nss_tx_status_t nss_tx_status; - - if (!nss_ctx) { - nss_warning("%px: NSS Context not found.", nss_ctx); - return -ENODEV; - } - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - 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 (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; - } - - 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; - } - - return 0; -} - -/* - * nss_ppe_vp_create_handler() - * PPE VP create handler. - */ -static int nss_ppe_vp_create_handler(struct ctl_table *ctl, 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_VERIFY_CTX_MAGIC(nss_ctx); - - 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; - } - - 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; - } - - 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; - } - - return 0; -} - -static struct ctl_table nss_ppe_vp_table[] = { - { - .procname = "create", - .data = &nss_ppe_vp_cmd, - .maxlen = sizeof(nss_ppe_vp_cmd), - .mode = 0644, - .proc_handler = &nss_ppe_vp_create_handler, - }, - { - .procname = "destroy", - .data = &nss_ppe_vp_cmd, - .maxlen = sizeof(nss_ppe_vp_cmd), - .mode = 0644, - .proc_handler = &nss_ppe_vp_destroy_handler, - }, - { } -}; - -static struct ctl_table nss_ppe_vp_dir[] = { - { - .procname = "ppe_vp", - .mode = 0555, - .child = nss_ppe_vp_table, - }, - { } -}; - -static struct ctl_table nss_ppe_vp_root_dir[] = { - { - .procname = "nss", - .mode = 0555, - .child = nss_ppe_vp_dir, - }, - { } -}; - -static struct ctl_table_header *nss_ppe_vp_procfs_header; - -/* - * nss_ppe_vp_procfs_register() - * Register sysctl specific to ppe_vp - */ -void nss_ppe_vp_procfs_register(void) -{ - /* - * Register sysctl table. - */ - nss_ppe_vp_procfs_header = register_sysctl_table(nss_ppe_vp_root_dir); -} - -/* - * uss_ppe_vp_procfs_unregister() - * Unregister sysctl specific for ppe_vp - */ -void nss_ppe_vp_procfs_unregister(void) -{ - /* - * Unregister sysctl table. - */ - if (nss_ppe_vp_procfs_header) { - unregister_sysctl_table(nss_ppe_vp_procfs_header); - } -} - -/* - * nss_ppe_vp_register_handler() - * - */ -void nss_ppe_vp_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_ppe_vp_get_context(); - - 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); - return; - } - - nss_core_register_handler(nss_ctx, NSS_PPE_VP_INTERFACE, nss_ppe_vp_handler, NULL); - nss_ppe_vp_procfs_register(); - - sema_init(&ppe_vp_pvt.sem, 1); - init_completion(&ppe_vp_pvt.complete); -} - -/* - * nss_ppe_vp_unregister_handler() - * - */ -void nss_ppe_vp_unregister_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_ppe_vp_get_context(); - - debugfs_remove_recursive(nss_ppe_vp_dentry); - nss_ppe_vp_procfs_unregister(); - nss_core_unregister_handler(nss_ctx, NSS_PPE_VP_INTERFACE); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp.h b/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp.h deleted file mode 100644 index ee656497f..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp.h +++ /dev/null @@ -1,130 +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. - ************************************************************************** - */ - -/* - * nss_ppe_vp.h - * NSS PPE virtual port header file - */ - -#include -#include "nss_tx_rx_common.h" - -/* - * Maximum number of virtual port supported by PPE hardware - */ -#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 - */ -extern spinlock_t nss_ppe_vp_stats_lock; - -/* - * nss_ppe_vp_msg_error_type - * ppe_vp message errors - */ -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_MAX /* Maximum error type */ -}; - -/* - * nss_ppe_vp_message_types - * Message types for Packet Processing Engine (PPE) requests and responses. - */ -enum nss_ppe_vp_message_types { - NSS_PPE_VP_MSG_SYNC_STATS, - NSS_PPE_VP_MSG_DESTROY_NOTIFY, - NSS_PPE_VP_MSG_MAX, -}; - -/* - * 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 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 */ - struct nss_cmn_node_stats stats; /* Common node statistics */ -}; - -/* - * nss_ppe_vp_sync_stats_msg - * Message information for ppe_vp synchronization statistics. - */ -struct nss_ppe_vp_sync_stats_msg { - uint16_t count; /* Number of VP node stats with the sync message */ - uint32_t rx_dropped[NSS_MAX_NUM_PRI]; /* Rx packet dropped due to queue full */ - struct nss_ppe_vp_statistics vp_stats[NSS_PPE_VP_NODE_STATS_MAX]; - /* Per service-code stats */ -}; - -/* - * 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. */ - - /* - * Payload. - */ - union { - union nss_if_msgs if_msg; - /* NSS interface base messages. */ - 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. */ -}; - -typedef void (*nss_ppe_vp_msg_callback_t)(void *app_data, struct nss_ppe_vp_msg *msg); - -/* - * Logging APIs. - */ -void nss_ppe_vp_log_tx_msg(struct nss_ppe_vp_msg *npvm); -void nss_ppe_vp_log_rx_msg(struct nss_ppe_vp_msg *npvm); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp_log.c deleted file mode 100644 index 8c853dfcb..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp_log.c +++ /dev/null @@ -1,135 +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. - ************************************************************************** - */ - -/* - * nss_ppe_vp_log.c - * NSS PPE logger file. - */ - -#include "nss_core.h" -#include "nss_ppe_vp.h" - -/* - * nss_ppe_vp_log_error_response_types_str - * Strings for error types for PPE-VP messages - */ -static int8_t *nss_ppe_vp_log_error_response_types_str[NSS_PPE_VP_MSG_ERROR_TYPE_MAX] __maybe_unused = { - "PPE VP Unknown message type", - "PPE VP Invalid dynamic interface type", -}; - -/* - * nss_ppe_vp_log_destroy_notify_msg() - * Log NSS PPE VP destroy notification message. - */ -static void nss_ppe_vp_log_destroy_notify_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); -} - -/* - * nss_ppe_vp_log_verbose() - * Log message contents. - */ -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); - break; - - case NSS_PPE_VP_MSG_SYNC_STATS: - /* - * No log for valid stats message. - */ - break; - - default: - nss_warning("%px: Invalid message type\n", npvm); - break; - } -} - -/* - * nss_ppe_vp_log_tx_msg() - * Log messages transmitted to FW. - */ -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))) { - nss_warning("%px: Invalid message type\n", npvm); - return; - } - - nss_info("%px: type:%d\n", npvm, npvm->cm.type); - nss_ppe_vp_log_verbose(npvm); -} - -/* - * nss_ppe_vp_log_rx_msg() - * Log messages received from FW. - */ -void nss_ppe_vp_log_rx_msg(struct nss_ppe_vp_msg *npvm) -{ - if (npvm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%px: type: %d, response[%d]: %s\n", npvm, 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], - 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], - npvm->cm.error, nss_ppe_vp_log_error_response_types_str[npvm->cm.error]); - -verbose: - nss_ppe_vp_log_verbose(npvm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp_stats.c deleted file mode 100644 index 57c79953f..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp_stats.c +++ /dev/null @@ -1,229 +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_ppe_vp.h" -#include "nss_ppe_vp_stats.h" - -/* - * nss_ppe_vp_stats_cntrs - * PPE VP stats counters displayed using debugfs - */ -enum nss_ppe_vp_stats_cntrs { - NSS_PPE_VP_STATS_VP_NUM, - NSS_PPE_VP_STATS_NSS_IF, - NSS_PPE_VP_STATS_RX_PKTS, - NSS_PPE_VP_STATS_RX_BYTES, - NSS_PPE_VP_STATS_TX_PKTS, - NSS_PPE_VP_STATS_TX_BYTES, - NSS_PPE_VP_STATS_RX_INACTIVE, - NSS_PPE_VP_STATS_TX_INACTIVE, - NSS_PPE_VP_STATS_PACKET_BIG, - NSS_PPE_VP_STATS_TX_Q_0_DROP, - NSS_PPE_VP_STATS_TX_Q_1_DROP, - NSS_PPE_VP_STATS_TX_Q_2_DROP, - NSS_PPE_VP_STATS_TX_Q_3_DROP, - NSS_PPE_VP_STATS_MAX -}; - -/* - * nss_ppe_vp_stats_rx_cntrs - * PPE VP RX stats counters displayed using debugfs - */ -enum nss_ppe_vp_stats_rx_cntrs { - NSS_PPE_VP_STATS_RX_Q_0_DROP, - NSS_PPE_VP_STATS_RX_Q_1_DROP, - NSS_PPE_VP_STATS_RX_Q_2_DROP, - NSS_PPE_VP_STATS_RX_Q_3_DROP, - NSS_PPE_VP_STATS_RX_MAX -}; - -/* - * nss_ppe_vp_rx_stats_str - * PPE VP Rx statistics strings - */ -struct nss_stats_info nss_ppe_vp_stats_rx_str[NSS_PPE_VP_STATS_RX_MAX] = { - {"rx_queue_0_drop" , NSS_STATS_TYPE_DROP}, - {"rx_queue_1_drop" , NSS_STATS_TYPE_DROP}, - {"rx_queue_2_drop" , NSS_STATS_TYPE_DROP}, - {"rx_queue_3_drop" , NSS_STATS_TYPE_DROP}, -}; - -/* - * nss_ppe_vp_stats_str - * 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}, - {"nss_if" , NSS_STATS_TYPE_SPECIAL}, - {"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_inactive" , NSS_STATS_TYPE_DROP}, - {"tx_inactive" , NSS_STATS_TYPE_DROP}, - {"packet_large_err" , NSS_STATS_TYPE_EXCEPTION}, - {"tx_queue_0_drop" , NSS_STATS_TYPE_DROP}, - {"tx_queue_1_drop" , NSS_STATS_TYPE_DROP}, - {"tx_queue_2_drop" , NSS_STATS_TYPE_DROP}, - {"tx_queue_3_drop" , NSS_STATS_TYPE_DROP}, -}; - -/* - * nss_ppe_vp_stats_sync - * PPE VP sync statistics from NSS - */ -void nss_ppe_vp_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_ppe_vp_sync_stats_msg *stats_msg, uint16_t if_num) -{ - uint16_t count = stats_msg->count; - uint16_t vp_index, i; - - spin_lock_bh(&nss_ppe_vp_stats_lock); - - /* - * Update general rx dropped stats. - */ - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - nss_ppe_vp_debug_stats.rx_dropped[i] += stats_msg->rx_dropped[i]; - } - - /* - * Update per VP tx and rx stats. - */ - while (count) { - count--; - - /* - * 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].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; - nss_ppe_vp_debug_stats.vp_stats[vp_index].tx_packets += stats_msg->vp_stats[count].stats.tx_packets; - nss_ppe_vp_debug_stats.vp_stats[vp_index].tx_bytes += stats_msg->vp_stats[count].stats.tx_bytes; - nss_ppe_vp_debug_stats.vp_stats[vp_index].rx_inactive_drop += stats_msg->vp_stats[count].rx_drop; - nss_ppe_vp_debug_stats.vp_stats[vp_index].tx_inactive_drop += stats_msg->vp_stats[count].tx_drop; - nss_ppe_vp_debug_stats.vp_stats[vp_index].packet_big_err += stats_msg->vp_stats[count].packet_big_err; - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - 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, - stats_msg->vp_stats[count].stats.rx_packets, - stats_msg->vp_stats[count].stats.tx_packets); - } - spin_unlock_bh(&nss_ppe_vp_stats_lock); -} - -/* - * nss_ppe_vp_stats_read() - * Read ppe vp statistics - */ -static ssize_t nss_ppe_vp_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int i; - char *lbuf = NULL; - size_t size_wr = 0; - ssize_t bytes_read = 0; - struct nss_ppe_vp_stats_debug *ppe_vp_stats; - uint32_t max_output_lines = ((NSS_PPE_VP_STATS_RX_MAX + NSS_PPE_VP_STATS_MAX) * NSS_PPE_VP_MAX_NUM) + NSS_STATS_EXTRA_OUTPUT_LINES; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - size_t stats_sz = sizeof(struct nss_ppe_vp_stats_debug); - - ppe_vp_stats = kzalloc(stats_sz, GFP_KERNEL); - if (!ppe_vp_stats) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - - lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(!lbuf)) { - kfree(ppe_vp_stats); - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - /* - * Get vp stats - */ - spin_lock_bh(&nss_ppe_vp_stats_lock); - memcpy(ppe_vp_stats, &nss_ppe_vp_debug_stats, stats_sz); - spin_unlock_bh(&nss_ppe_vp_stats_lock); - - /* - * VP stats - */ - size_wr += nss_stats_banner(lbuf, size_wr, size_al, "ppe_vp", NSS_STATS_SINGLE_CORE); - - /* - * Print Rx dropped. - */ - size_wr += nss_stats_print("ppe_vp", "ppe_vp rx dropped:" - , NSS_STATS_SINGLE_INSTANCE - , nss_ppe_vp_stats_rx_str - , ppe_vp_stats->rx_dropped - , NSS_PPE_VP_STATS_RX_MAX - , lbuf, size_wr, size_al); - - /* - * Print individual VP stats - */ - for (i = 0; i < NSS_PPE_VP_MAX_NUM; i++) { - if (!ppe_vp_stats->vp_stats[i].nss_if) { - continue; - } - - size_wr += nss_stats_print("ppe_vp", "ppe_vp stats" - , NSS_STATS_SINGLE_INSTANCE - , nss_ppe_vp_stats_str - , (uint64_t *) &ppe_vp_stats->vp_stats[i] - , NSS_PPE_VP_STATS_MAX - , lbuf, size_wr, size_al); - } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - - kfree(ppe_vp_stats); - kfree(lbuf); - return bytes_read; -} - -/* - * nss_ppe_vp_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(ppe_vp) - -/* - * nss_ppe_vp_stats_dentry_create() - * Create PPE statistics debug entry. - */ -struct dentry *nss_ppe_vp_stats_dentry_create(void) -{ - struct dentry *ppe_vp_d = debugfs_create_file("ppe_vp", 0400, nss_top_main.stats_dentry, - &nss_top_main, &nss_ppe_vp_stats_ops); - if (unlikely(ppe_vp_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/ppe_vp file"); - return NULL; - } - - return ppe_vp_d; -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp_stats.h deleted file mode 100644 index b435da5ba..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_ppe_vp_stats.h +++ /dev/null @@ -1,63 +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_ppe_vp_stats.h - * NSS PPE-VP statistics header file. - */ - -#ifndef __NSS_PPE_VP_STATS_H -#define __NSS_PPE_VP_STATS_H - -/* - * NSS PPE-VP statistics - */ -struct nss_ppe_vp_statistics_debug { - uint64_t ppe_port_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. */ - uint64_t tx_packets; /* Number of packets transmitted. */ - uint64_t tx_bytes; /* Number of bytes transmitted. */ - uint64_t rx_inactive_drop; /* Number of packets dropped from PPE to VP due to VP inactive */ - uint64_t tx_inactive_drop; /* Number of packets dropped from VP to PPE due to VP inactive */ - uint64_t packet_big_err; /* Number of packets not sent to PPE because packet was too large */ - uint64_t tx_dropped[NSS_MAX_NUM_PRI]; /* Tx packets dropped on due to queue full. */ -}; - -/* - * NSS PPE-VP statistics - */ -struct nss_ppe_vp_stats_debug { - uint64_t rx_dropped[NSS_MAX_NUM_PRI]; /* Packets dropped on receive due to queue full. */ - struct nss_ppe_vp_statistics_debug vp_stats[NSS_PPE_VP_MAX_NUM]; - /* Per VP Tx and Rx stats. */ -}; - -/* - * Data structures to store NSS PPE_VP debug statistics - */ -extern struct nss_ppe_vp_stats_debug nss_ppe_vp_debug_stats; - -/* - * NSS PPE-VP statistics APIs - */ -extern void nss_ppe_vp_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_ppe_vp_sync_stats_msg *stats_msg, uint16_t if_num); -extern struct dentry *nss_ppe_vp_stats_dentry_create(void); - -#endif /* __NSS_PPE_VP_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe.c b/feeds/ipq807x/qca-nss-drv/src/nss_pppoe.c deleted file mode 100644 index df613f76a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe.c +++ /dev/null @@ -1,435 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_pppoe.c - * NSS PPPoE APIs - */ - -#include "nss_tx_rx_common.h" -#include "nss_pppoe_stats.h" -#include "nss_pppoe_log.h" -#include "nss_pppoe_strings.h" - -#define NSS_PPPOE_TX_TIMEOUT 3000 /* 3 Seconds */ - -int nss_pppoe_br_accel_mode __read_mostly = NSS_PPPOE_BR_ACCEL_MODE_EN_5T; - -/* - * Private data structure - */ -static struct nss_pppoe_pvt { - struct semaphore sem; - struct completion complete; - int response; - void *cb; - void *app_data; -} pppoe_pvt; - -/* - * nss_pppoe_br_help() - * Usage information for pppoe bride accel mode - */ -static inline void nss_pppoe_br_help(int mode) -{ - printk("Incorrect pppoe bridge accel mode: %d\n", mode); - printk("Supported modes\n"); - printk("%d: pppoe bridge acceleration disable\n", NSS_PPPOE_BR_ACCEL_MODE_DIS); - printk("%d: pppoe bridge acceleration enable with 5-tuple\n", NSS_PPPOE_BR_ACCEL_MODE_EN_5T); - printk("%d: pppoe bridge acceleration enable with 3-tuple\n", NSS_PPPOE_BR_ACCEL_MODE_EN_3T); -} - -/* - * nss_pppoe_get_context() - */ -struct nss_ctx_instance *nss_pppoe_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.pppoe_handler_id]; -} -EXPORT_SYMBOL(nss_pppoe_get_context); - -/* - * nss_pppoe_tx_msg() - * Transmit a PPPoE message to NSS firmware - */ -static nss_tx_status_t nss_pppoe_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_pppoe_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - enum nss_dynamic_interface_type type; - - /* - * Trace Messages - */ - nss_pppoe_log_tx_msg(msg); - - /* - * Sanity check the message - */ - 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("%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("%px: message type out of range: %d\n", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} - -/* - * nss_pppoe_sync_msg_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_pppoe_sync_msg_callback(void *app_data, struct nss_pppoe_msg *npm) -{ - nss_pppoe_msg_callback_t callback = (nss_pppoe_msg_callback_t)pppoe_pvt.cb; - void *data = pppoe_pvt.app_data; - - pppoe_pvt.cb = NULL; - pppoe_pvt.app_data = NULL; - - pppoe_pvt.response = NSS_TX_SUCCESS; - if (npm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("pppoe Error response %d\n", npm->cm.response); - pppoe_pvt.response = NSS_TX_FAILURE; - } - - if (callback) { - callback(data, npm); - } - - complete(&pppoe_pvt.complete); -} - -/* - * nss_pppoe_handler() - * Handle NSS -> HLOS messages for PPPoE - */ -static void nss_pppoe_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_pppoe_msg *npm = (struct nss_pppoe_msg *)ncm; - void *ctx; - nss_pppoe_msg_callback_t cb; - - BUG_ON(!(nss_is_dynamic_interface(ncm->interface) || ncm->interface == NSS_PPPOE_INTERFACE)); - - /* - * Trace Messages - */ - nss_pppoe_log_rx_msg(npm); - - /* - * Sanity check the message type - */ - if (ncm->type >= NSS_PPPOE_MSG_MAX) { - 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("%px: message length is invalid: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Handling PPPoE messages coming from NSS fw. - */ - switch (npm->cm.type) { - case NSS_PPPOE_MSG_SYNC_STATS: - /* - * Update PPPoE debug statistics and send statistics notifications to the registered modules - */ - nss_pppoe_stats_sync(nss_ctx, &npm->msg.sync_stats, ncm->interface); - nss_pppoe_stats_notify(nss_ctx, ncm->interface); - break; - default: - nss_warning("%px: Received response %d for type %d, interface %d\n", - nss_ctx, ncm->response, ncm->type, ncm->interface); - } - - /* - * Update the callback and app_data for NOTIFY messages, pppoe sends all notify messages - * to the same callback/app_data. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->pppoe_msg_callback; - ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].app_data; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_pppoe_msg_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - cb(ctx, npm); -} - -/* - * nss_pppoe_br_accel_mode_handler() - * Enable/disable pppoe bridge acceleration in NSS - */ -int nss_pppoe_br_accel_mode_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_ctx_instance *nss_ctx = nss_pppoe_get_context(); - struct nss_pppoe_msg npm; - struct nss_pppoe_br_accel_cfg_msg *npbacm; - nss_tx_status_t status; - int ret; - enum nss_pppoe_br_accel_modes current_value, new_val; - - /* - * Take snap shot of current value - */ - current_value = nss_pppoe_br_accel_mode; - - /* - * Write the variable with user input - */ - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - if (ret || (!write)) { - return ret; - } - - 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("%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; - } - - memset(&npm, 0, sizeof(struct nss_pppoe_msg)); - nss_pppoe_msg_init(&npm, NSS_PPPOE_INTERFACE, NSS_PPPOE_MSG_BR_ACCEL_CFG, - sizeof(struct nss_pppoe_br_accel_cfg_msg), NULL, NULL); - - npbacm = &npm.msg.br_accel; - npbacm->br_accel_cfg = new_val; - - status = nss_pppoe_tx_msg_sync(nss_ctx, &npm); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: Send acceleration mode message failed\n", nss_ctx); - nss_pppoe_br_accel_mode = current_value; - return -EIO; - } - - return 0; -} - -/* - * nss_pppoe_get_br_accel_mode() - * Gets PPPoE bridge acceleration mode - */ -enum nss_pppoe_br_accel_modes nss_pppoe_get_br_accel_mode(void) -{ - return nss_pppoe_br_accel_mode; -} -EXPORT_SYMBOL(nss_pppoe_get_br_accel_mode); - -/* - * nss_pppoe_tx_msg_sync() - */ -nss_tx_status_t nss_pppoe_tx_msg_sync(struct nss_ctx_instance *nss_ctx, - struct nss_pppoe_msg *msg) -{ - nss_tx_status_t status; - int ret = 0; - - down(&pppoe_pvt.sem); - pppoe_pvt.cb = (void *)msg->cm.cb; - pppoe_pvt.app_data = (void *)msg->cm.app_data; - - msg->cm.cb = (nss_ptr_t)nss_pppoe_sync_msg_callback; - msg->cm.app_data = (nss_ptr_t)NULL; - - status = nss_pppoe_tx_msg(nss_ctx, msg); - if (status != NSS_TX_SUCCESS) { - 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("%px: PPPoE msg tx failed due to timeout\n", nss_ctx); - pppoe_pvt.response = NSS_TX_FAILURE; - } - - status = pppoe_pvt.response; - up(&pppoe_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_pppoe_tx_msg_sync); - -/* - * nss_register_pppoe_session_if() - */ -struct nss_ctx_instance *nss_register_pppoe_session_if(uint32_t if_num, - nss_pppoe_msg_callback_t notification_callback, - struct net_device *netdev, uint32_t features, void *app_ctx) -{ - struct nss_ctx_instance *nss_ctx = nss_pppoe_get_context(); - - nss_assert(nss_ctx); - nss_assert(nss_is_dynamic_interface(if_num)); - - if (!nss_pppoe_stats_pppoe_session_init(if_num, netdev)) { - return NULL; - } - - nss_core_register_subsys_dp(nss_ctx, if_num, NULL, NULL, app_ctx, netdev, features); - - nss_top_main.pppoe_msg_callback = notification_callback; - - nss_core_register_handler(nss_ctx, if_num, nss_pppoe_handler, NULL); - - return nss_ctx; -} -EXPORT_SYMBOL(nss_register_pppoe_session_if); - -/* - * nss_unregister_pppoe_session_if() - */ -void nss_unregister_pppoe_session_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_pppoe_get_context(); - - nss_assert(nss_ctx); - nss_assert(nss_is_dynamic_interface(if_num)); - - nss_pppoe_stats_pppoe_session_deinit(if_num); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - nss_top_main.pppoe_msg_callback = NULL; - - nss_core_unregister_handler(nss_ctx, if_num); - -} -EXPORT_SYMBOL(nss_unregister_pppoe_session_if); - -static struct ctl_table nss_pppoe_table[] = { - { - .procname = "br_accel_mode", - .data = &nss_pppoe_br_accel_mode, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_pppoe_br_accel_mode_handler, - }, - { } -}; - -static struct ctl_table nss_pppoe_dir[] = { - { - .procname = "pppoe", - .mode = 0555, - .child = nss_pppoe_table, - }, - { } -}; - -static struct ctl_table nss_pppoe_root_dir[] = { - { - .procname = "nss", - .mode = 0555, - .child = nss_pppoe_dir, - }, - { } -}; - -static struct ctl_table nss_pppoe_root[] = { - { - .procname = "dev", - .mode = 0555, - .child = nss_pppoe_root_dir, - }, - { } -}; - -static struct ctl_table_header *nss_pppoe_header; - -/* - * nss_pppoe_register_sysctl() - * Register sysctl specific to pppoe - */ -void nss_pppoe_register_sysctl(void) -{ - /* - * Register sysctl table. - */ - nss_pppoe_header = register_sysctl_table(nss_pppoe_root); -} - -/* - * nss_pppoe_unregister_sysctl() - * Unregister sysctl specific to pppoe - */ -void nss_pppoe_unregister_sysctl(void) -{ - /* - * Unregister sysctl table. - */ - if (nss_pppoe_header) { - unregister_sysctl_table(nss_pppoe_header); - } -} - -/* - * nss_pppoe_register_handler() - */ -void nss_pppoe_register_handler(void) -{ - nss_info("nss_pppoe_register_handler\n"); - nss_core_register_handler(nss_pppoe_get_context(), NSS_PPPOE_INTERFACE, nss_pppoe_handler, NULL); - - sema_init(&pppoe_pvt.sem, 1); - init_completion(&pppoe_pvt.complete); - - nss_pppoe_stats_dentry_create(); - nss_pppoe_strings_dentry_create(); -} - -/* - * nss_pppoe_msg_init() - */ -void nss_pppoe_msg_init(struct nss_pppoe_msg *npm, uint16_t if_num, uint32_t type, uint32_t len, - void *cb, void *app_data) -{ - nss_cmn_msg_init(&npm->cm, if_num, type, len, (void *)cb, app_data); - -} -EXPORT_SYMBOL(nss_pppoe_msg_init); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_log.c deleted file mode 100644 index 7ab8b1902..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_log.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_pppoe_log.c - * NSS PPPOE logger file. - */ - -#include "nss_core.h" - -/* - * nss_pppoe_log_message_types_str - * NSS PPPOE message strings - */ -static int8_t *nss_pppoe_log_message_types_str[NSS_PPPOE_MSG_MAX] __maybe_unused = { - "PPPOE Session Create", - "PPPOE Session Destroy", - "PPPOE Stats", -}; - -/* - * nss_pppoe_log_session_create_msg() - * Log NSS Session Create. - */ -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("%px: NSS PPPOE Session Create message \n" - "PPPOE Base Interface Number: %d\n" - "PPPOE MTU: %d\n" - "PPPOE Server MAC: %pM\n" - "PPPOE Local MAC: %pM\n" - "PPPOE Session ID: %d\n", - npcm, npcm->base_if_num, - npcm->mtu, npcm->server_mac, - npcm->local_mac, npcm->session_id); -} - -/* - * nss_pppoe_log_session_destroy_msg() - * Log NSS Session Destroy. - */ -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("%px: NSS PPPOE Session Destroy message \n" - "PPPOE Session ID: %d\n" - "PPPOE Server MAC: %pM\n" - "PPPOE Local MAC: %pM\n", - npdm, npdm->session_id, - npdm->server_mac, npdm->local_mac); -} - -/* - * nss_pppoe_log_verbose() - * Log message contents. - */ -static void nss_pppoe_log_verbose(struct nss_pppoe_msg *npm) -{ - switch (npm->cm.type) { - case NSS_PPPOE_MSG_SESSION_CREATE: - nss_pppoe_log_session_create_msg(npm); - break; - - case NSS_PPPOE_MSG_SESSION_DESTROY: - nss_pppoe_log_session_destroy_msg(npm); - break; - - case NSS_PPPOE_MSG_SYNC_STATS: - /* - * No log for valid stats message. - */ - break; - - default: - nss_trace("%px: Invalid message type\n", npm); - break; - } -} - -/* - * nss_pppoe_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_pppoe_log_tx_msg(struct nss_pppoe_msg *npm) -{ - if (npm->cm.type >= NSS_PPPOE_MSG_MAX) { - nss_warning("%px: Invalid message type\n", npm); - return; - } - - 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); -} - -/* - * nss_pppoe_log_rx_msg() - * Log messages received from FW. - */ -void nss_pppoe_log_rx_msg(struct nss_pppoe_msg *npm) -{ - if (npm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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]); - -verbose: - nss_pppoe_log_verbose(npm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_log.h deleted file mode 100644 index 4636b08d8..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_PPPOE_LOG_H -#define __NSS_PPPOE_LOG_H - -/* - * nss_pppoe.h - * NSS PPPOE header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_pppoe_log_tx_msg - * Logs a pppoe message that is sent to the NSS firmware. - */ -void nss_pppoe_log_tx_msg(struct nss_pppoe_msg *nim); - -/* - * nss_pppoe_log_rx_msg - * Logs a pppoe message that is received from the NSS firmware. - */ -void nss_pppoe_log_rx_msg(struct nss_pppoe_msg *nim); - -#endif /* __NSS_PPPOE_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_stats.c deleted file mode 100644 index 75b24c8ed..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_stats.c +++ /dev/null @@ -1,265 +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_core.h" -#include -#include "nss_pppoe_stats.h" -#include "nss_pppoe_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_pppoe_stats_notifier); - -/* - * Lock used for PPPoE statistics - */ -static DEFINE_SPINLOCK(nss_pppoe_stats_lock); - -/* - * PPPoE session stats structure for debug interface - */ -struct nss_pppoe_stats_session_stats { - uint64_t stats[NSS_PPPOE_STATS_SESSION_MAX]; - /* stats for the session */ - int32_t if_index; /* net device index for the session */ - uint32_t if_num; /* nss interface number */ - bool valid; /* dynamic interface valid flag */ -}; - -/* - * PPPoE interface stats structure for base node and sessions - */ -struct nss_pppoe_stats { - uint64_t base_stats[NSS_PPPOE_STATS_BASE_MAX]; - /* Base node stats */ - struct nss_pppoe_stats_session_stats session_stats[NSS_MAX_PPPOE_DYNAMIC_INTERFACES]; - /* Per session stats */ -}; - -/* - * Global PPPoE stats decleration. - */ -static struct nss_pppoe_stats pppoe_stats; - -/* - * nss_pppoe_stats_read() - * Read pppoe statistics - */ -static ssize_t nss_pppoe_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - - uint32_t max_output_lines = 2 /* header & footer for session stats */ - + NSS_MAX_PPPOE_DYNAMIC_INTERFACES * (NSS_PPPOE_STATS_SESSION_MAX + 2) /*session stats */ - + 2 + NSS_PPPOE_STATS_BASE_MAX + 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; - int id; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(lbuf == NULL)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - /* - * Base node stats - */ - size_wr += nss_stats_print("pppoe", "pppoe base node stats start" - , NSS_STATS_SINGLE_INSTANCE - , nss_pppoe_strings_base_stats - , pppoe_stats.base_stats - , NSS_PPPOE_STATS_BASE_MAX - , lbuf, size_wr, size_al); - - /* - * Session stats - */ - for (id = 0; id < NSS_MAX_PPPOE_DYNAMIC_INTERFACES; id++) { - if (!pppoe_stats.session_stats[id].valid) { - continue; - } - - dev = dev_get_by_index(&init_net, pppoe_stats.session_stats[id].if_index); - if (unlikely(!dev)) { - continue; - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "%d. nss interface id=%d, netdevice=%s\n", id, - pppoe_stats.session_stats[id].if_num, dev->name); - dev_put(dev); - - size_wr += nss_stats_print("pppoe", "pppoe session node stats" - , id - , nss_pppoe_strings_session_stats - , pppoe_stats.session_stats[id].stats - , NSS_PPPOE_STATS_SESSION_MAX - , lbuf, size_wr, size_al); - } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - - kfree(lbuf); - return bytes_read; -} - -/* - * nss_pppoe_stats_pppoe_session_init() - * Initialize the session statistics. - */ -bool nss_pppoe_stats_pppoe_session_init(uint32_t if_num, struct net_device *dev) -{ - int i; - - spin_lock_bh(&nss_pppoe_stats_lock); - for (i = 0; i < NSS_MAX_PPPOE_DYNAMIC_INTERFACES; i++) { - if (!pppoe_stats.session_stats[i].valid) { - pppoe_stats.session_stats[i].valid = true; - pppoe_stats.session_stats[i].if_num = if_num; - pppoe_stats.session_stats[i].if_index = dev->ifindex; - spin_unlock_bh(&nss_pppoe_stats_lock); - return true; - } - } - spin_unlock_bh(&nss_pppoe_stats_lock); - - return false; -} - -/* - * nss_pppoe_stats_pppoe_session_deinit() - * De-initialize the session's stats. - */ -void nss_pppoe_stats_pppoe_session_deinit(uint32_t if_num) -{ - int i; - - spin_lock_bh(&nss_pppoe_stats_lock); - for (i = 0; i < NSS_MAX_PPPOE_DYNAMIC_INTERFACES; i++) { - if (pppoe_stats.session_stats[i].if_num == if_num) { - memset(&pppoe_stats.session_stats[i], 0, sizeof(pppoe_stats.session_stats[i])); - } - } - spin_unlock_bh(&nss_pppoe_stats_lock); -} - -/* - * nss_pppoe_stats_sync - * Per session debug stats for pppoe - */ -void nss_pppoe_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_pppoe_sync_stats_msg *stats_msg, uint16_t if_num) -{ - int i; - spin_lock_bh(&nss_pppoe_stats_lock); - for (i = 0; i < NSS_MAX_PPPOE_DYNAMIC_INTERFACES; i++) { - if (pppoe_stats.session_stats[i].if_num == if_num) { - int j; - - /* - * Sync PPPoE session stats. - */ - pppoe_stats.session_stats[i].stats[NSS_PPPOE_STATS_SESSION_RX_PACKETS] += stats_msg->session_stats.node.rx_packets; - pppoe_stats.session_stats[i].stats[NSS_PPPOE_STATS_SESSION_RX_BYTES] += stats_msg->session_stats.node.rx_bytes; - pppoe_stats.session_stats[i].stats[NSS_PPPOE_STATS_SESSION_TX_PACKETS] += stats_msg->session_stats.node.tx_packets; - pppoe_stats.session_stats[i].stats[NSS_PPPOE_STATS_SESSION_TX_BYTES] += stats_msg->session_stats.node.tx_bytes; - pppoe_stats.session_stats[i].stats[NSS_PPPOE_STATS_SESSION_WRONG_VERSION_OR_TYPE] += stats_msg->session_stats.exception[NSS_PPPOE_SESSION_EXCEPTION_EVENT_WRONG_VERSION_OR_TYPE]; - pppoe_stats.session_stats[i].stats[NSS_PPPOE_STATS_SESSION_WRONG_CODE] += stats_msg->session_stats.exception[NSS_PPPOE_SESSION_EXCEPTION_EVENT_WRONG_CODE]; - pppoe_stats.session_stats[i].stats[NSS_PPPOE_STATS_SESSION_UNSUPPORTED_PPP_PROTOCOL] += stats_msg->session_stats.exception[NSS_PPPOE_SESSION_EXCEPTION_EVENT_UNSUPPORTED_PPP_PROTOCOL]; - - /* - * Sync PPPoE base node stats coming with this session's stats. - */ - pppoe_stats.base_stats[NSS_PPPOE_STATS_BASE_RX_PACKETS] += stats_msg->base_stats.node.rx_packets; - pppoe_stats.base_stats[NSS_PPPOE_STATS_BASE_RX_BYTES] += stats_msg->base_stats.node.rx_bytes; - pppoe_stats.base_stats[NSS_PPPOE_STATS_BASE_TX_PACKETS] += stats_msg->base_stats.node.tx_packets; - pppoe_stats.base_stats[NSS_PPPOE_STATS_BASE_TX_BYTES] += stats_msg->base_stats.node.tx_bytes; - - for (j = 0; j < NSS_MAX_NUM_PRI; j++) { - pppoe_stats.base_stats[NSS_PPPOE_STATS_BASE_RX_QUEUE_0_DROPPED + j] += stats_msg->base_stats.node.rx_dropped[j]; - } - - /* - * Sync PPPoE base exception stats coming with this session's stats. - */ - pppoe_stats.base_stats[NSS_PPPOE_STATS_BASE_SHORT_PPPOE_HDR_LENGTH] += stats_msg->base_stats.exception[NSS_PPPOE_BASE_EXCEPTION_EVENT_SHORT_PPPOE_HDR_LENGTH]; - pppoe_stats.base_stats[NSS_PPPOE_STATS_BASE_SHORT_PACKET_LENGTH] += stats_msg->base_stats.exception[NSS_PPPOE_BASE_EXCEPTION_EVENT_SHORT_PACKET_LENGTH]; - pppoe_stats.base_stats[NSS_PPPOE_STATS_BASE_WRONG_VERSION_OR_TYPE] += stats_msg->base_stats.exception[NSS_PPPOE_BASE_EXCEPTION_EVENT_WRONG_VERSION_OR_TYPE]; - pppoe_stats.base_stats[NSS_PPPOE_STATS_BASE_WRONG_CODE] += stats_msg->base_stats.exception[NSS_PPPOE_BASE_EXCEPTION_EVENT_WRONG_CODE]; - pppoe_stats.base_stats[NSS_PPPOE_STATS_BASE_UNSUPPORTED_PPP_PROTOCOL] += stats_msg->base_stats.exception[NSS_PPPOE_BASE_EXCEPTION_EVENT_UNSUPPORTED_PPP_PROTOCOL]; - pppoe_stats.base_stats[NSS_PPPOE_STATS_BASE_DISABLED_BRIDGE_PACKET] += stats_msg->base_stats.exception[NSS_PPPOE_BASE_EXCEPTION_EVENT_DISABLED_BRIDGE_PACKET]; - break; - } - } - spin_unlock_bh(&nss_pppoe_stats_lock); -} - -/* - * nss_pppoe_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(pppoe); - -/* - * nss_pppoe_stats_dentry_create() - * Create PPPoE node statistics debug entry. - */ -void nss_pppoe_stats_dentry_create(void) -{ - nss_stats_create_dentry("pppoe", &nss_pppoe_stats_ops); -} - -/* - * nss_pppoe_stats_notify() - * Sends notifications to the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_pppoe_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - struct nss_pppoe_stats_notification nss_pppoe_stats; - int id; - - for (id = 0; id < NSS_MAX_PPPOE_DYNAMIC_INTERFACES; id++) { - if (pppoe_stats.session_stats[id].if_num == if_num) { - memcpy(&nss_pppoe_stats.session_stats, &pppoe_stats.session_stats[id].stats, sizeof(nss_pppoe_stats.session_stats)); - } - } - memcpy(&nss_pppoe_stats.base_stats, &pppoe_stats.base_stats, sizeof(nss_pppoe_stats.base_stats)); - nss_pppoe_stats.core_id = nss_ctx->id; - nss_pppoe_stats.if_num = if_num; - atomic_notifier_call_chain(&nss_pppoe_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&nss_pppoe_stats); -} - -/* - * nss_pppoe_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_pppoe_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_pppoe_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_pppoe_stats_register_notifier); - -/* - * nss_pppoe_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_pppoe_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_pppoe_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_pppoe_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_stats.h deleted file mode 100644 index 41c726ed1..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_stats.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_PPPOE_STATS_H -#define __NSS_PPPOE_STATS_H - -/* - * PPPoE statistics APIs - */ -extern void nss_pppoe_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); -extern void nss_pppoe_stats_dentry_create(void); -extern void nss_pppoe_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_pppoe_sync_stats_msg *stats_msg, uint16_t if_num); -extern bool nss_pppoe_stats_pppoe_session_init(uint32_t if_num, struct net_device *dev); -extern void nss_pppoe_stats_pppoe_session_deinit(uint32_t if_num); -#endif /* __NSS_PPPOE_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_strings.c deleted file mode 100644 index 953945bc6..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_strings.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_pppoe_strings_session_stats - * PPPoE session stats strings. - */ -struct nss_stats_info nss_pppoe_strings_session_stats[NSS_PPPOE_STATS_SESSION_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}, - {"wrong_version_or_type" , NSS_STATS_TYPE_EXCEPTION}, - {"wrong_code" , NSS_STATS_TYPE_EXCEPTION}, - {"unsupported_ppp_protocol" , NSS_STATS_TYPE_EXCEPTION} -}; - -/* - * nss_pppoe_strings_base_stats - * PPPoE base node stats strings. - */ -struct nss_stats_info nss_pppoe_strings_base_stats[NSS_PPPOE_STATS_BASE_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}, - {"short_pppoe_hdr_length" , NSS_STATS_TYPE_EXCEPTION}, - {"short_packet_length" , NSS_STATS_TYPE_EXCEPTION}, - {"wrong_version_or_type" , NSS_STATS_TYPE_EXCEPTION}, - {"wrong_code" , NSS_STATS_TYPE_EXCEPTION}, - {"unsupported_ppp_protocol" , NSS_STATS_TYPE_EXCEPTION}, - {"disabled_bridge_packet" , NSS_STATS_TYPE_EXCEPTION} -}; - -/* - * nss_pppoe_isession_stats_strings_read() - * Read PPPoE session statistics names. - */ -static ssize_t nss_pppoe_session_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_pppoe_strings_session_stats, NSS_PPPOE_STATS_SESSION_MAX); -} - -/* - * nss_pppoe_base_stats_strings_read() - * Read PPPoE base statistics names. - */ -static ssize_t nss_pppoe_base_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_pppoe_strings_base_stats, NSS_PPPOE_STATS_BASE_MAX); -} - -/* - * nss_pppoe_session_stats_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(pppoe_session_stats); - -/* - * nss_pppoe_base_stats_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(pppoe_base_stats); - -/* - * nss_pppoe_strings_dentry_create() - * Create PPPoE statistics strings debug entry. - */ -void nss_pppoe_strings_dentry_create(void) -{ - struct dentry *pppoe_d = NULL; - struct dentry *pppoe_session_stats_d = NULL; - struct dentry *pppoe_base_stats_d = NULL; - - if (!nss_top_main.strings_dentry) { - nss_warning("qca-nss-drv/strings is not present"); - return; - } - - pppoe_d = debugfs_create_dir("pppoe", nss_top_main.strings_dentry); - if (!pppoe_d) { - nss_warning("Failed to create qca-nss-drv/strings/pppoe directory"); - return; - } - - pppoe_session_stats_d = debugfs_create_file("session_stats_str", 0400, pppoe_d, &nss_top_main, &nss_pppoe_session_stats_strings_ops); - if (!pppoe_session_stats_d) { - nss_warning("Failed to create qca-nss-drv/stats/pppoe/session_stats_str file"); - debugfs_remove_recursive(pppoe_d); - return; - } - - pppoe_base_stats_d = debugfs_create_file("base_stats_str", 0400, pppoe_d, &nss_top_main, &nss_pppoe_base_stats_strings_ops); - if (!pppoe_base_stats_d) { - nss_warning("Failed to create qca-nss-drv/stats/pppoe/base_stats_str file"); - debugfs_remove_recursive(pppoe_d); - return; - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_strings.h deleted file mode 100644 index 8cf9393a1..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pppoe_strings.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_PPPOE_STRINGS_H -#define __NSS_PPPOE_STRINGS_H - -extern struct nss_stats_info nss_pppoe_strings_session_stats[NSS_PPPOE_STATS_SESSION_MAX]; -extern struct nss_stats_info nss_pppoe_strings_base_stats[NSS_PPPOE_STATS_BASE_MAX]; -extern void nss_pppoe_strings_dentry_create(void); - -#endif /* __NSS_PPPOE_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pptp.c b/feeds/ipq807x/qca-nss-drv/src/nss_pptp.c deleted file mode 100644 index 73cf43460..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pptp.c +++ /dev/null @@ -1,472 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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 "nss_tx_rx_common.h" -#include "nss_pptp_stats.h" -#include "nss_pptp_log.h" -#include "nss_pptp_strings.h" - -#define NSS_PPTP_TX_TIMEOUT 3000 /* 3 Seconds */ - -/* - * Data structures to store pptp nss debug stats - */ -static DEFINE_SPINLOCK(nss_pptp_session_debug_stats_lock); -static struct nss_pptp_stats_session_debug nss_pptp_session_debug_stats[NSS_MAX_PPTP_DYNAMIC_INTERFACES]; - -/* - * Private data structure - */ -static struct nss_pptp_pvt { - struct semaphore sem; - struct completion complete; - int response; - void *cb; - void *app_data; -} pptp_pvt; - -/* - * nss_pptp_session_debug_stats_sync - * Per session debug stats for pptp - */ -void nss_pptp_session_debug_stats_sync(struct nss_ctx_instance *nss_ctx, - struct nss_pptp_sync_session_stats_msg *stats_msg, uint16_t if_num) -{ - int i, j, if_type; - - if_type = nss_dynamic_interface_get_type(nss_pptp_get_context(), if_num); - spin_lock_bh(&nss_pptp_session_debug_stats_lock); - for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) { - if (nss_pptp_session_debug_stats[i].if_num == if_num) { - break; - } - } - - if (i == NSS_MAX_PPTP_DYNAMIC_INTERFACES) { - spin_unlock_bh(&nss_pptp_session_debug_stats_lock); - return; - } - - if (if_type == NSS_DYNAMIC_INTERFACE_TYPE_PPTP_OUTER) { - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_DECAP_RX_PACKETS] += - stats_msg->node_stats.rx_packets; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_DECAP_RX_BYTES] += - stats_msg->node_stats.rx_bytes; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_DECAP_TX_PACKETS] += - stats_msg->node_stats.tx_packets; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_DECAP_TX_BYTES] += - stats_msg->node_stats.tx_bytes; - for (j = 0; j < NSS_MAX_NUM_PRI; j++) { - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_DECAP_RX_QUEUE_0_DROP + j] += - stats_msg->node_stats.rx_dropped[j]; - } - } else { - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_ENCAP_RX_PACKETS] += - stats_msg->node_stats.rx_packets; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_ENCAP_RX_BYTES] += - stats_msg->node_stats.rx_bytes; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_ENCAP_TX_PACKETS] += - stats_msg->node_stats.tx_packets; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_ENCAP_TX_BYTES] += - stats_msg->node_stats.tx_bytes; - for (j = 0; j < NSS_MAX_NUM_PRI; j++) { - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_ENCAP_RX_QUEUE_0_DROP + j] += - stats_msg->node_stats.rx_dropped[j]; - } - } - - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_ENCAP_HEADROOM_ERR] += - stats_msg->exception_events[PPTP_EXCEPTION_EVENT_ENCAP_HEADROOM_ERR]; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_ENCAP_SMALL_SIZE] += - stats_msg->exception_events[PPTP_EXCEPTION_EVENT_ENCAP_SMALL_SIZE]; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_ENCAP_PNODE_ENQUEUE_FAIL] += - stats_msg->exception_events[PPTP_EXCEPTION_EVENT_ENCAP_PNODE_ENQUEUE_FAIL]; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_NO_SEQ_NOR_ACK] += - stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_NO_SEQ_NOR_ACK]; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_INVAL_GRE_FLAGS] += - stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_INVAL_GRE_FLAGS]; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_INVAL_GRE_PROTO] += - stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_INVAL_GRE_PROTO]; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_WRONG_SEQ] += - stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_WRONG_SEQ]; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_INVAL_PPP_HDR] += - stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_INVAL_PPP_HDR]; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_PPP_LCP] += - stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_PPP_LCP]; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_UNSUPPORTED_PPP_PROTO] += - stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_UNSUPPORTED_PPP_PROTO]; - nss_pptp_session_debug_stats[i].stats[NSS_PPTP_STATS_SESSION_DECAP_PNODE_ENQUEUE_FAIL] += - stats_msg->exception_events[PPTP_EXCEPTION_EVENT_DECAP_PNODE_ENQUEUE_FAIL]; - - spin_unlock_bh(&nss_pptp_session_debug_stats_lock); -} - -/* - * nss_pptp_global_session_stats_get() - * Get session pptp statitics. - */ -void nss_pptp_session_debug_stats_get(void *stats_mem) -{ - struct nss_pptp_stats_session_debug *stats = (struct nss_pptp_stats_session_debug *)stats_mem; - int i; - - if (!stats) { - nss_warning("No memory to copy pptp session stats"); - return; - } - - spin_lock_bh(&nss_pptp_session_debug_stats_lock); - for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) { - if (nss_pptp_session_debug_stats[i].valid) { - memcpy(stats, &nss_pptp_session_debug_stats[i], sizeof(struct nss_pptp_stats_session_debug)); - stats++; - } - } - spin_unlock_bh(&nss_pptp_session_debug_stats_lock); -} - -/* - * nss_pptp_verify_if_num() - * Verify if_num passed to us. - */ -static bool nss_pptp_verify_if_num(uint32_t if_num) -{ - uint32_t if_type; - - if (nss_is_dynamic_interface(if_num) == false) { - return false; - } - - if_type = nss_dynamic_interface_get_type(nss_pptp_get_context(), if_num); - switch(if_type) { - case NSS_DYNAMIC_INTERFACE_TYPE_PPTP_INNER: - case NSS_DYNAMIC_INTERFACE_TYPE_PPTP_OUTER: - case NSS_DYNAMIC_INTERFACE_TYPE_PPTP_HOST_INNER: - return true; - } - - return false; -} - -/* - * nss_pptp_handler() - * Handle NSS -> HLOS messages for pptp tunnel - */ -static void nss_pptp_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_pptp_msg *ntm = (struct nss_pptp_msg *)ncm; - void *ctx; - - nss_pptp_msg_callback_t cb; - - BUG_ON(!nss_pptp_verify_if_num(ncm->interface)); - - /* - * Trace Messages - */ - nss_pptp_log_rx_msg(ntm); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_PPTP_MSG_MAX) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - switch (ntm->cm.type) { - - case NSS_PPTP_MSG_SYNC_STATS: - /* - * Update session debug stats in stats msg and send statistics notifications to the registered modules. - */ - nss_pptp_session_debug_stats_sync(nss_ctx, &ntm->msg.stats, ncm->interface); - nss_pptp_stats_notify(nss_ctx, ncm->interface); - break; - } - - /* - * Update the callback and app_data for NOTIFY messages, pptp sends all notify messages - * to the same callback/app_data. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->pptp_msg_callback; - ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].app_data; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_pptp_msg_callback_t)ncm->cb; - ctx = (void *)ncm->app_data; - - /* - * call pptp tunnel callback - */ - if (!cb) { - nss_warning("%px: Event received for pptp tunnel interface %d before registration", nss_ctx, ncm->interface); - return; - } - - cb(ctx, ntm); -} - -/* - * nss_pptp_tx_msg() - * Transmit a pptp message to NSS firmware - */ -static nss_tx_status_t nss_pptp_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_pptp_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace Messages - */ - nss_pptp_log_tx_msg(msg); - - /* - * Sanity check the message - */ - if (!nss_is_dynamic_interface(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("%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_pptp_sync_msg_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_pptp_sync_msg_callback(void *app_data, struct nss_pptp_msg *nim) -{ - nss_pptp_msg_callback_t callback = (nss_pptp_msg_callback_t)pptp_pvt.cb; - void *data = pptp_pvt.app_data; - - pptp_pvt.cb = NULL; - pptp_pvt.app_data = NULL; - - if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("pptp Error response %d\n", nim->cm.response); - - pptp_pvt.response = NSS_TX_FAILURE; - if (callback) { - callback(data, nim); - } - - complete(&pptp_pvt.complete); - return; - } - - pptp_pvt.response = NSS_TX_SUCCESS; - if (callback) { - callback(data, nim); - } - - complete(&pptp_pvt.complete); -} - -/* - * nss_pptp_tx_msg() - * Transmit a pptp message to NSS firmware synchronously. - */ -nss_tx_status_t nss_pptp_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_pptp_msg *msg) -{ - - nss_tx_status_t status; - int ret = 0; - - down(&pptp_pvt.sem); - pptp_pvt.cb = (void *)msg->cm.cb; - pptp_pvt.app_data = (void *)msg->cm.app_data; - - msg->cm.cb = (nss_ptr_t)nss_pptp_sync_msg_callback; - msg->cm.app_data = (nss_ptr_t)NULL; - - status = nss_pptp_tx_msg(nss_ctx, msg); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: pptp_tx_msg failed\n", nss_ctx); - up(&pptp_pvt.sem); - return status; - } - - ret = wait_for_completion_timeout(&pptp_pvt.complete, msecs_to_jiffies(NSS_PPTP_TX_TIMEOUT)); - - if (!ret) { - nss_warning("%px: PPTP msg tx failed due to timeout\n", nss_ctx); - pptp_pvt.response = NSS_TX_FAILURE; - } - - status = pptp_pvt.response; - up(&pptp_pvt.sem); - return status; -} - -/* - * nss_pptp_tx_buf() - * Send packet to pptp interface owned by NSS - */ -nss_tx_status_t nss_pptp_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, struct sk_buff *skb) -{ - 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); -} - -/* - * nss_register_pptp_if() - */ -struct nss_ctx_instance *nss_register_pptp_if(uint32_t if_num, - uint32_t type, - nss_pptp_callback_t pptp_data_callback, - nss_pptp_msg_callback_t notification_callback, - struct net_device *netdev, - uint32_t features, - void *app_ctx) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.pptp_handler_id]; - int i = 0; - - nss_assert(nss_ctx); - nss_assert(nss_pptp_verify_if_num(if_num)); - - nss_ctx->subsys_dp_register[if_num].type = type; - - nss_core_register_subsys_dp(nss_ctx, if_num, pptp_data_callback, NULL, app_ctx, netdev, features); - - nss_top_main.pptp_msg_callback = notification_callback; - - nss_core_register_handler(nss_ctx, if_num, nss_pptp_handler, NULL); - - spin_lock_bh(&nss_pptp_session_debug_stats_lock); - for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) { - if (!nss_pptp_session_debug_stats[i].valid) { - nss_pptp_session_debug_stats[i].valid = true; - nss_pptp_session_debug_stats[i].if_num = if_num; - nss_pptp_session_debug_stats[i].if_index = netdev->ifindex; - break; - } - } - spin_unlock_bh(&nss_pptp_session_debug_stats_lock); - - return nss_ctx; -} - -/* - * nss_unregister_pptp_if() - */ -void nss_unregister_pptp_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.pptp_handler_id]; - int i; - int j; - - nss_assert(nss_ctx); - nss_assert(nss_is_dynamic_interface(if_num)); - - spin_lock_bh(&nss_pptp_session_debug_stats_lock); - for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) { - if (nss_pptp_session_debug_stats[i].valid == true && - nss_pptp_session_debug_stats[i].if_num == if_num) { - nss_pptp_session_debug_stats[i].valid = false; - nss_pptp_session_debug_stats[i].if_num = 0; - nss_pptp_session_debug_stats[i].if_index = 0; - for (j = 0; j < NSS_PPTP_STATS_SESSION_MAX; j++) - nss_pptp_session_debug_stats[i].stats[j] = 0; - break; - } - } - spin_unlock_bh(&nss_pptp_session_debug_stats_lock); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - nss_top_main.pptp_msg_callback = NULL; - - nss_core_unregister_handler(nss_ctx, if_num); -} - -/* - * nss_get_pptp_context() - */ -struct nss_ctx_instance *nss_pptp_get_context() -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.pptp_handler_id]; -} - -/* - * nss_pptp_msg_init() - * Initialize nss_pptp msg. - */ -void nss_pptp_msg_init(struct nss_pptp_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} - -/* nss_pptp_register_handler() - * debugfs stats msg handler received on static pptp interface - */ -void nss_pptp_register_handler(void) -{ - int i; - - nss_info("nss_pptp_register_handler"); - nss_core_register_handler(nss_pptp_get_context(), NSS_PPTP_INTERFACE, nss_pptp_handler, NULL); - - spin_lock_bh(&nss_pptp_session_debug_stats_lock); - for (i = 0; i < NSS_MAX_PPTP_DYNAMIC_INTERFACES; i++) { - nss_pptp_session_debug_stats[i].valid = false; - nss_pptp_session_debug_stats[i].if_num = 0; - nss_pptp_session_debug_stats[i].if_index = 0; - } - spin_unlock_bh(&nss_pptp_session_debug_stats_lock); - - sema_init(&pptp_pvt.sem, 1); - init_completion(&pptp_pvt.complete); - - nss_pptp_stats_dentry_create(); - nss_pptp_strings_dentry_create(); -} - -EXPORT_SYMBOL(nss_pptp_get_context); -EXPORT_SYMBOL(nss_pptp_tx_msg_sync); -EXPORT_SYMBOL(nss_pptp_tx_buf); -EXPORT_SYMBOL(nss_unregister_pptp_if); -EXPORT_SYMBOL(nss_pptp_msg_init); -EXPORT_SYMBOL(nss_register_pptp_if); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pptp_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_pptp_log.c deleted file mode 100644 index 136a3c863..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pptp_log.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_pptp_log.c - * NSS PPTP logger file. - */ - -#include "nss_core.h" - -/* - * nss_pptp_log_message_types_str - * NSS PPTP message strings - */ -static int8_t *nss_pptp_log_message_types_str[NSS_PPTP_MSG_MAX] __maybe_unused = { - "PPTP Session Configure", - "PPTP Session Deconfigure", - "PPTP Stats", -}; - -/* - * nss_pptp_log_configure_msg() - * Log NSS PPTP Session Configure. - */ -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("%px: NSS PPTP Session Configure message\n" - "PPTP Source Call ID: %x\n" - "PPTP Destination Call ID: %x\n" - "PPTP Source IP: %pI4\n" - "PPTP Destination IP: %pI4\n", - npcm, npcm->src_call_id, - npcm->dst_call_id, &npcm->sip, - &npcm->dip); -} - -/* - * nss_pptp_log_deconfigure_msg() - * Log NSS PPTP Session Deconfigure. - */ -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("%px: NSS PPTP Session Configure message \n" - "PPTP Source Call ID: %x\n", - npdm, npdm->src_call_id); -} - -/* - * nss_pptp_log_verbose() - * Log message contents. - */ -static void nss_pptp_log_verbose(struct nss_pptp_msg *npm) -{ - switch (npm->cm.type) { - case NSS_PPTP_MSG_SESSION_CONFIGURE: - nss_pptp_log_configure_msg(npm); - break; - - case NSS_PPTP_MSG_SESSION_DECONFIGURE: - nss_pptp_log_deconfigure_msg(npm); - break; - - case NSS_PPTP_MSG_SYNC_STATS: - /* - * No log for valid stats message. - */ - break; - - default: - nss_trace("%px: Invalid message type\n", npm); - break; - } -} - -/* - * nss_pptp_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_pptp_log_tx_msg(struct nss_pptp_msg *npm) -{ - if (npm->cm.type >= NSS_PPTP_MSG_MAX) { - nss_warning("%px: Invalid message type\n", npm); - return; - } - - 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); -} - -/* - * nss_pptp_log_rx_msg() - * Log messages received from FW. - */ -void nss_pptp_log_rx_msg(struct nss_pptp_msg *npm) -{ - if (npm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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]); - -verbose: - nss_pptp_log_verbose(npm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pptp_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_pptp_log.h deleted file mode 100644 index bb800d5ed..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pptp_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_PPTP_LOG_H -#define __NSS_PPTP_LOG_H - -/* - * nss_pptp.h - * NSS PPTP header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_pptp_log_tx_msg - * Logs a pptp message that is sent to the NSS firmware. - */ -void nss_pptp_log_tx_msg(struct nss_pptp_msg *ntm); - -/* - * nss_pptp_log_rx_msg - * Logs a pptp message that is received from the NSS firmware. - */ -void nss_pptp_log_rx_msg(struct nss_pptp_msg *ntm); - -#endif /* __NSS_PPTP_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pptp_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_pptp_stats.c deleted file mode 100644 index afbe00ee0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pptp_stats.c +++ /dev/null @@ -1,154 +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_core.h" -#include "nss_pptp_stats.h" -#include "nss_pptp_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_pptp_stats_notifier); - -struct nss_pptp_stats_session_debug pptp_session_stats[NSS_MAX_PPTP_DYNAMIC_INTERFACES]; - -/* - * nss_pptp_stats_read() - * Read pptp statistics - */ -static ssize_t nss_pptp_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - - uint32_t max_output_lines = 2 /* header & footer for session stats */ - + NSS_MAX_PPTP_DYNAMIC_INTERFACES * (NSS_PPTP_STATS_SESSION_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; - int id, i; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(lbuf == NULL)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - memset(&pptp_session_stats, 0, sizeof(struct nss_pptp_stats_session_debug) * NSS_MAX_PPTP_DYNAMIC_INTERFACES); - - /* - * Get all stats - */ - nss_pptp_session_debug_stats_get((void *)&pptp_session_stats); - - /* - * Session stats - */ - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npptp session stats start:\n\n"); - for (id = 0; id < NSS_MAX_PPTP_DYNAMIC_INTERFACES; id++) { - - if (!pptp_session_stats[id].valid) { - break; - } - - dev = dev_get_by_index(&init_net, pptp_session_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, - pptp_session_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, - pptp_session_stats[id].if_num); - } - - for (i = 0; i < NSS_PPTP_STATS_SESSION_MAX; i++) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, - "\t%s = %llu\n", nss_pptp_strings_session_debug_stats[i].stats_name, - pptp_session_stats[id].stats[i]); - } - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\npptp session stats end\n"); - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - - kfree(lbuf); - return bytes_read; -} - -/* - * nss_pptp_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(pptp); - -/* - * nss_pptp_stats_dentry_create() - * Create PPTP node statistics debug entry. - */ -void nss_pptp_stats_dentry_create(void) -{ - nss_stats_create_dentry("pptp", &nss_pptp_stats_ops); -} - -/* - * nss_pptp_stats_notify() - * Sends notifications to the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_pptp_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - struct nss_pptp_stats_notification pptp_stats; - int id; - - memset(&pptp_session_stats, 0, sizeof(pptp_session_stats)); - - /* - * Get all stats - */ - nss_pptp_session_debug_stats_get((void *)&pptp_session_stats); - - for (id = 0; id < NSS_MAX_PPTP_DYNAMIC_INTERFACES; id++) { - if (pptp_session_stats[id].if_num == if_num) { - memcpy(&pptp_stats.stats, &pptp_session_stats[id].stats, sizeof(pptp_stats.stats)); - } - } - pptp_stats.if_type = nss_dynamic_interface_get_type(nss_ctx, if_num); - pptp_stats.core_id = nss_ctx->id; - pptp_stats.if_num = if_num; - atomic_notifier_call_chain(&nss_pptp_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&pptp_stats); -} - -/* - * nss_pptp_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_pptp_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_pptp_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_pptp_stats_register_notifier); - -/* - * nss_pptp_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_pptp_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_pptp_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_pptp_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pptp_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_pptp_stats.h deleted file mode 100644 index 11c016617..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pptp_stats.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_PPTP_STATS_H -#define __NSS_PPTP_STATS_H - -/* - * NSS PPTP node statistics session - */ -struct nss_pptp_stats_session_debug { - uint64_t stats[NSS_PPTP_STATS_SESSION_MAX]; - int32_t if_index; - uint32_t if_num; /* nss interface number */ - bool valid; -}; - -/* - * NSS PPTP statistics APIs - */ -extern void nss_pptp_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); -extern void nss_pptp_stats_dentry_create(void); - -#endif /* __NSS_PPTP_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pptp_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_pptp_strings.c deleted file mode 100644 index 966ec07f3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pptp_strings.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_pptp_strings_session_debug_stats - * PPTP statistics strings for NSS session statistics. - */ -struct nss_stats_info nss_pptp_strings_session_debug_stats[NSS_PPTP_STATS_SESSION_MAX] = { - {"ENCAP_RX_PACKETS", NSS_STATS_TYPE_COMMON}, - {"ENCAP_RX_BYTES", NSS_STATS_TYPE_COMMON}, - {"ENCAP_TX_PACKETS", NSS_STATS_TYPE_COMMON}, - {"ENCAP_TX_BYTES", NSS_STATS_TYPE_COMMON}, - {"ENCAP_RX_QUEUE_0_DROP", NSS_STATS_TYPE_DROP}, - {"ENCAP_RX_QUEUE_1_DROP", NSS_STATS_TYPE_DROP}, - {"ENCAP_RX_QUEUE_2_DROP", NSS_STATS_TYPE_DROP}, - {"ENCAP_RX_QUEUE_3_DROP", NSS_STATS_TYPE_DROP}, - {"DECAP_RX_PACKETS", NSS_STATS_TYPE_COMMON}, - {"DECAP_RX_BYTES", NSS_STATS_TYPE_COMMON}, - {"DECAP_TX_PACKETS", NSS_STATS_TYPE_COMMON}, - {"DECAP_TX_BYTES", NSS_STATS_TYPE_COMMON}, - {"DECAP_RX_QUEUE_0_DROP", NSS_STATS_TYPE_DROP}, - {"DECAP_RX_QUEUE_1_DROP", NSS_STATS_TYPE_DROP}, - {"DECAP_RX_QUEUE_2_DROP", NSS_STATS_TYPE_DROP}, - {"DECAP_RX_QUEUE_3_DROP", NSS_STATS_TYPE_DROP}, - {"ENCAP_HEADROOM_ERR", NSS_STATS_TYPE_ERROR}, - {"ENCAP_SMALL_SIZE", NSS_STATS_TYPE_SPECIAL}, - {"ENCAP_PNODE_ENQUEUE_FAIL", NSS_STATS_TYPE_ERROR}, - {"DECAP_NO_SEQ_NOR_ACK", NSS_STATS_TYPE_ERROR}, - {"DECAP_INVAL_GRE_FLAGS", NSS_STATS_TYPE_ERROR}, - {"DECAP_INVAL_GRE_PROTO", NSS_STATS_TYPE_ERROR}, - {"DECAP_WRONG_SEQ", NSS_STATS_TYPE_ERROR}, - {"DECAP_INVAL_PPP_HDR", NSS_STATS_TYPE_ERROR}, - {"DECAP_PPP_LCP", NSS_STATS_TYPE_SPECIAL}, - {"DECAP_UNSUPPORTED_PPP_PROTO", NSS_STATS_TYPE_ERROR}, - {"DECAP_PNODE_ENQUEUE_FAIL", NSS_STATS_TYPE_ERROR} -}; - -/* - * nss_pptp_strings_read() - * Read PPTP node statistics names. - */ -static ssize_t nss_pptp_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_pptp_strings_session_debug_stats, NSS_PPTP_STATS_SESSION_MAX); -} - -/* - * nss_pptp_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(pptp); - -/* - * nss_pptp_strings_dentry_create() - * Create PPTP statistics strings debug entry. - */ -void nss_pptp_strings_dentry_create(void) -{ - nss_strings_create_dentry("pptp", &nss_pptp_strings_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pptp_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_pptp_strings.h deleted file mode 100644 index 788a387c6..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pptp_strings.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_PPTP_STRINGS_H -#define __NSS_PPTP_STRINGS_H - -extern struct nss_stats_info nss_pptp_strings_session_debug_stats[NSS_PPTP_STATS_SESSION_MAX]; -extern void nss_pptp_strings_dentry_create(void); - -#endif /* __NSS_PPTP_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_profiler.c b/feeds/ipq807x/qca-nss-drv/src/nss_profiler.c deleted file mode 100755 index 5717ac365..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_profiler.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_profiler.c - * NSS profiler APIs - */ - -#include "nss_tx_rx_common.h" - -/* - * nss_profiler_rx_msg_handler() - * Handle profiler information. - */ -static void nss_profiler_rx_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *app) -{ - struct nss_profiler_msg *pm = (struct nss_profiler_msg*)ncm; - void *ctx = nss_ctx->nss_top->profiler_ctx[nss_ctx->id]; - nss_profiler_callback_t cb = nss_ctx->nss_top->profiler_callback[nss_ctx->id]; - - if (ncm->type >= NSS_PROFILER_MAX_MSG_TYPES) { - 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("%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("%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("%px: %d params data is too big %d : %d\n", nss_ctx, ncm->type, ncm->len, ncm->interface); - return; - } - } - - /* - * status per request callback - */ - if (ncm->response != NSS_CMN_RESPONSE_NOTIFY && ncm->cb) { - 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; - } - - /* - * sample related callback - */ - if (!cb || !ctx) { - nss_warning("%px: Event received for profiler interface before registration", nss_ctx); - return; - } - - cb(ctx, (struct nss_profiler_msg *)ncm); -} - -/* - * nss_tx_profiler_if_buf() - * NSS profiler Tx API - */ -nss_tx_status_t nss_profiler_if_tx_buf(void *ctx, void *buf, uint32_t len, - void *cb, void *app_data) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)ctx; - struct nss_profiler_msg *npm; - struct nss_profiler_data_msg *pdm = (struct nss_profiler_data_msg *)buf; - nss_tx_status_t ret; - - nss_trace("%px: Profiler If Tx, buf=%px", nss_ctx, buf); - - if (sizeof(npm->payload) < 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("%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("%px: Failed to allocate memory for message\n", nss_ctx); - return NSS_TX_FAILURE; - } - - memcpy(&npm->payload, pdm, len); - nss_profiler_msg_init(npm, NSS_PROFILER_INTERFACE, pdm->hd_magic & 0xFF, len, - cb, app_data); - - ret = nss_core_send_cmd(nss_ctx, npm, sizeof(npm->cm) + len, NSS_NBUF_PAYLOAD_SIZE); - kfree(npm); - return ret; -} -EXPORT_SYMBOL(nss_profiler_if_tx_buf); - -/* - * nss_profiler_alloc_dma() - * Allocate a DMA for profiler. - */ -void *nss_profiler_alloc_dma(struct nss_ctx_instance *nss_ctx, struct nss_profile_sdma_producer **dma_p) -{ - int size; - void *kaddr; - struct nss_profile_sdma_producer *dma; - struct nss_profile_sdma_ctrl *ctrl = (struct nss_profile_sdma_ctrl *)nss_ctx->meminfo_ctx.sdma_ctrl; - if (!ctrl) - return NULL; - - dma = ctrl->producer; - *dma_p = dma; - size = dma->num_bufs * dma->buf_size; - kaddr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); - - if (kaddr) { - dma->desc_ring = dma_map_single(nss_ctx->dev, kaddr, size, DMA_FROM_DEVICE); - NSS_CORE_DSB(); - } - ctrl->consumer[0].ring.kp = kaddr; - return kaddr; -} -EXPORT_SYMBOL(nss_profiler_alloc_dma); - -/* - * nss_profiler_release_dma() - * Free profiler DMA. - */ -void nss_profiler_release_dma(struct nss_ctx_instance *nss_ctx) -{ - struct nss_profile_sdma_ctrl *ctrl; - if (!nss_ctx) - return; - - ctrl = nss_ctx->meminfo_ctx.sdma_ctrl; - - 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); - -/* - * nss_profile_dma_register_cb - * Register a handler for profile DMA. - */ -bool nss_profile_dma_register_cb(struct nss_ctx_instance *nss_ctx, int id, - void (*cb)(void*), void *arg) -{ - struct nss_profile_sdma_ctrl *ctrl = (struct nss_profile_sdma_ctrl *)nss_ctx->meminfo_ctx.sdma_ctrl; - nss_info("%px dma_register_cb %d: %px %px\n", ctrl, id, cb, arg); - if (!ctrl) - return false; - - ctrl->consumer[id].dispatch.fp = cb; - ctrl->consumer[id].arg.kp = arg; - return true; -} -EXPORT_SYMBOL(nss_profile_dma_register_cb); - -/* - * nss_profile_dma_deregister_cb - * Deregister callback for profile DMA. - */ -bool nss_profile_dma_deregister_cb(struct nss_ctx_instance *nss_ctx, int id) -{ - struct nss_profile_sdma_ctrl *ctrl = (struct nss_profile_sdma_ctrl *)nss_ctx->meminfo_ctx.sdma_ctrl; - if (!ctrl) - return false; - - ctrl->consumer[id].dispatch.fp = NULL; - return true; -} -EXPORT_SYMBOL(nss_profile_dma_deregister_cb); - -/* - * nss_profile_dma_get_ctrl - * Wrapper to get profile DMA control. - */ -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) { - return ctrl; - } - - dmac_inv_range(ctrl, &ctrl->cidx); - dsb(sy); - return ctrl; -} -EXPORT_SYMBOL(nss_profile_dma_get_ctrl); - -/* - * nss_profiler_notify_register() - */ -void *nss_profiler_notify_register(nss_core_id_t core_id, nss_profiler_callback_t profiler_callback, void *ctx) -{ - nss_assert(core_id < NSS_CORE_MAX); - - if (NSS_CORE_STATUS_SUCCESS != - nss_core_register_handler(&nss_top_main.nss[core_id], NSS_PROFILER_INTERFACE, nss_profiler_rx_msg_handler, NULL)) { - nss_warning("Message handler FAILED to be registered for profiler"); - return NULL; - } - - nss_top_main.profiler_ctx[core_id] = ctx; - nss_top_main.profiler_callback[core_id] = profiler_callback; - - return (void *)&nss_top_main.nss[core_id]; -} -EXPORT_SYMBOL(nss_profiler_notify_register); - -/* - * nss_profiler_notify_unregister() - */ -void nss_profiler_notify_unregister(nss_core_id_t core_id) -{ - nss_assert(core_id < NSS_CORE_MAX); - - 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; -} -EXPORT_SYMBOL(nss_profiler_notify_unregister); - -/* - * nss_profiler_msg_init() - * Initialize profiler message. - */ -void nss_profiler_msg_init(struct nss_profiler_msg *npm, uint16_t if_num, uint32_t type, uint32_t len, - nss_profiler_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&npm->cm, if_num, type, len, (void *)cb, app_data); -} -EXPORT_SYMBOL(nss_profiler_msg_init); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_project.c b/feeds/ipq807x/qca-nss-drv/src/nss_project.c deleted file mode 100644 index 07402fb76..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_project.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_project.h - * NSS project APIs. - */ -#include "nss_tx_rx_common.h" - -static int nss_project_wt_stats_enable; - -/* - * nss_project_free_wt_stats() - * Frees a number of allocated worker thread statistics. - */ -static void nss_project_free_wt_stats(struct nss_worker_thread_stats *wt_stats, int num_alloc) -{ - int i; - - if (!wt_stats) { - return; - } - - for (i = 0; i < num_alloc; i++) { - kfree(wt_stats[i].irq_stats); - } - kfree(wt_stats); -} - -/* - * nss_project_alloc_wt_stats() - * Allocates worker thread stats for a given number of threads and IRQs. - */ -static struct nss_worker_thread_stats *nss_project_alloc_wt_stats(uint32_t thread_count, uint32_t irq_count) -{ - struct nss_worker_thread_stats *wt_stats; - int i; - - wt_stats = kzalloc(thread_count * sizeof(struct nss_worker_thread_stats), GFP_ATOMIC); - if (unlikely(!wt_stats)) { - return NULL; - } - - for (i = 0; i < thread_count; i++) { - wt_stats[i].irq_stats = - kzalloc(irq_count * sizeof(struct nss_project_irq_stats), GFP_ATOMIC); - if (unlikely(!wt_stats[i].irq_stats)) { - nss_project_free_wt_stats(wt_stats, i); - return NULL; - } - } - - return wt_stats; -} - -/* - * nss_project_wt_stats_enable_callback() - * Callback function for wt stats enable messages - */ -static void nss_project_wt_stats_enable_callback(void *app_data, struct nss_project_msg *msg) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)app_data; - struct nss_project_msg_wt_stats_enable *stats_enable = &msg->msg.wt_stats_enable; - struct nss_worker_thread_stats *stats_temp; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - if (msg->cm.response != NSS_CMN_RESPONSE_ACK) { - return; - } - - 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. - */ - if (nss_ctx->wt_stats) { - return; - } - - stats_temp = nss_project_alloc_wt_stats(stats_enable->worker_thread_count, - stats_enable->irq_count); - if (unlikely(!stats_temp)) { - nss_warning("%px: Unable to allocate worker thread statistics.\n", nss_ctx); - return; - } - - spin_lock_bh(&nss_ctx->nss_top->stats_lock); - nss_ctx->wt_stats = stats_temp; - nss_ctx->worker_thread_count = stats_enable->worker_thread_count; - nss_ctx->irq_count = stats_enable->irq_count; - spin_unlock_bh(&nss_ctx->nss_top->stats_lock); -} - -/* - * nss_project_wt_stats_send_enable() - * Sends message to firmware to enable or disable worker_thread statistics collection. - */ -static nss_tx_status_t nss_project_wt_stats_send_enable(struct nss_ctx_instance *nss_ctx, bool enable) -{ - struct nss_project_msg *npm; - struct nss_cmn_msg *ncm; - nss_tx_status_t ret; - - npm = kzalloc(sizeof(*npm), GFP_KERNEL); - 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_WT_STATS_ENABLE, - sizeof(struct nss_project_msg_wt_stats_enable), - (void *)nss_project_wt_stats_enable_callback, - (void *)nss_ctx); - npm->msg.wt_stats_enable.enable = enable; - - ret = nss_core_send_cmd(nss_ctx, npm, sizeof(*npm), NSS_NBUF_PAYLOAD_SIZE); - kfree(npm); - return ret; -} - -/* - * nss_project_wt_stats_update() - * Updates stored statistics with the data found in the notify. - */ -static void nss_project_wt_stats_update(struct nss_ctx_instance *nss_ctx, - struct nss_project_msg_wt_stats_notify *stats_notify) -{ - struct nss_worker_thread_stats *wt_stats; - int i; - - if (unlikely(!nss_ctx->wt_stats)) { - 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("%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("%px: Invalid worker thread stats written count %d\n", - nss_ctx, stats_notify->stats_written); - return; - } - - wt_stats = &(nss_ctx->wt_stats[stats_notify->threadno]); - - if (unlikely(!wt_stats->irq_stats)) { - nss_warning("%px: Worker thread statistics not allocated for thread %d\n", - nss_ctx, stats_notify->threadno); - return; - } - - spin_lock_bh(&nss_ctx->nss_top->stats_lock); - 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("%px: Invalid IRQ number %d\n", nss_ctx, irq); - continue; - } - - wt_stats->irq_stats[irq] = stats_notify->stats[i]; - } - spin_unlock_bh(&nss_ctx->nss_top->stats_lock); -} - -/* - * nss_project_msg_handler() - * Handles metadata messages on the project interface. - */ -static void nss_project_msg_handler(struct nss_ctx_instance *nss_ctx, - struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_project_msg *npm = (struct nss_project_msg *)ncm; - nss_project_msg_callback_t cb; - - /* - * Sanity checks on message - */ - if (npm->cm.type >= NSS_PROJECT_MSG_MAX) { - 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("%px: message length is invalid: %d\n", nss_ctx, nss_cmn_get_msg_len(&(npm->cm))); - return; - } - - switch (npm->cm.type) { - case NSS_PROJECT_MSG_WT_STATS_NOTIFY: - nss_project_wt_stats_update(nss_ctx, &(npm->msg.wt_stats_notify)); - return; - } - - nss_core_log_msg_failures(nss_ctx, ncm); - - if (!ncm->cb) { - return; - } - - cb = (nss_project_msg_callback_t)ncm->cb; - cb((void *)nss_ctx, npm); -} - -/* - * nss_project_wt_stats_handler() - * Sysctl handler for wt_stats. - * - * Uses proc_dointvec to process data. For a write operation, also sends worker - * thread stats enable messages containing the new value to each NSS core. - */ -static int nss_project_wt_stats_handler(struct ctl_table *ctl, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) -{ - int ret; - int i; - - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - - /* - * In case of error, stop now. - */ - if (ret) { - return ret; - } - - /* - * No additional behavior necessary for a read operation. - */ - if (!write) { - return ret; - } - - /* - * If a value was written, send a message containing that value to each - * NSS core. - */ - for (i = 0; i < nss_top_main.num_nss; ++i) { - nss_project_wt_stats_send_enable(&(nss_top_main.nss[i]), - nss_project_wt_stats_enable); - } - return ret; - -} - -/* - * 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). - */ -static struct ctl_table nss_project_table[] = { - { - .procname = "wt_stats", - .data = &nss_project_wt_stats_enable, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_project_wt_stats_handler, - }, - { } -}; - -static struct ctl_table nss_project_dir[] = { - { - .procname = "project", - .mode = 0555, - .child = nss_project_table, - }, - { } -}; - -static struct ctl_table nss_project_root_dir[] = { - { - .procname = "nss", - .mode = 0555, - .child = nss_project_dir, - }, - { } -}; - -static struct ctl_table nss_project_root[] = { - { - .procname = "dev", - .mode = 0555, - .child = nss_project_root_dir, - }, - { } -}; - -static struct ctl_table_header *nss_project_header; - -/* - * nss_project_register_sysctl() - * Registers any sysctl handlers for the project. - */ -void nss_project_register_sysctl(void) -{ - nss_project_header = register_sysctl_table(nss_project_root); -} - -/* - * nss_project_unregister_sysctl() - * De-registers any sysctl handlers for the project. - */ -void nss_project_unregister_sysctl(void) -{ - if (nss_project_header) { - unregister_sysctl_table(nss_project_header); - } -} - -/* - * nss_project_register_handler() - * Registers the handler for NSS->HLOS messages - */ -void nss_project_register_handler(struct nss_ctx_instance *nss_ctx) -{ - nss_core_register_handler(nss_ctx, NSS_PROJECT_INTERFACE, nss_project_msg_handler, NULL); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan.c b/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan.c deleted file mode 100644 index abe78eeb7..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan.c +++ /dev/null @@ -1,446 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_pvxlan.c - * NSS PVXLAN driver interface APIs - */ -#include "nss_core.h" -#include "nss_pvxlan.h" -#include "nss_cmn.h" -#include "nss_tx_rx_common.h" -#include "nss_pvxlan_stats.h" -#include "nss_pvxlan_log.h" - -#define NSS_PVXLAN_TX_TIMEOUT 3000 - -/* - * Spinlock for protecting tunnel operations colliding with a tunnel destroy - */ -DEFINE_SPINLOCK(nss_pvxlan_spinlock); - -/* - * Private data structure - */ -static struct nss_pvxlan_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. */ -} pvxlan_pvt; - -/* - * Per PVxLAN tunnel/interface number instance. - */ -struct nss_pvxlan_handle { - atomic_t refcnt; /* Reference count on the tunnel */ - uint32_t if_num; /* Interface number */ - uint32_t tunnel_status; /* 0=disable, 1=enabled */ - nss_pvxlan_msg_callback_t msg_callback; /* Msg callback */ - void *app_data; /* App data (argument) */ -}; - -/* - * Array of pointer for NSS PvLAN handles. Each handle has per-tunnel - * stats based on the if_num which is an index. - */ -static struct nss_pvxlan_handle *nss_pvxlan_hdl[NSS_MAX_DYNAMIC_INTERFACES]; - -/* - * nss_pvxlan_verify_if_num() - * Verify if_num passed to us. - */ -static bool nss_pvxlan_verify_if_num(uint32_t if_num) -{ - uint32_t type = nss_dynamic_interface_get_type(nss_pvxlan_get_ctx(), if_num); - - return ((type == NSS_DYNAMIC_INTERFACE_TYPE_PVXLAN_HOST_INNER) || - (type == NSS_DYNAMIC_INTERFACE_TYPE_PVXLAN_OUTER)); -} - -/* - * nss_pvxlan_hdl_instance_free() - * Free PVxLAN tunnel handle instance. - */ -static bool nss_pvxlan_hdl_instance_free(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - struct nss_pvxlan_handle *h; - - spin_lock_bh(&nss_pvxlan_spinlock); - h = nss_pvxlan_hdl[if_num - NSS_DYNAMIC_IF_START]; - if (!h) { - spin_unlock_bh(&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); - 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); - kfree(h); - return true; -} - -/* - * nss_pvxlan_hdl_instance_alloc() - * Allocate PVxLAN tunnel instance. - */ -static bool nss_pvxlan_hdl_instance_alloc(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - nss_pvxlan_msg_callback_t notify_cb, void *app_data) -{ - struct nss_pvxlan_handle *h; - - /* - * Allocate a handle - */ - h = kzalloc(sizeof(struct nss_pvxlan_handle), GFP_ATOMIC); - if (!h) { - nss_warning("%px: no memory for allocating PVxLAN handle instance for interface : %d", nss_ctx, if_num); - return false; - } - h->if_num = if_num; - - spin_lock_bh(&nss_pvxlan_spinlock); - if (nss_pvxlan_hdl[if_num - NSS_DYNAMIC_IF_START] != NULL) { - spin_unlock_bh(&nss_pvxlan_spinlock); - kfree(h); - nss_warning("%px: The handle has been taken by another thread :%d", nss_ctx, if_num); - return false; - } - - 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); - - return true; -} - -/* - * nss_pvxlan_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_pvxlan_callback(void *app_data, struct nss_pvxlan_msg *nvxm) -{ - nss_pvxlan_msg_callback_t callback = (nss_pvxlan_msg_callback_t)pvxlan_pvt.cb; - void *data = pvxlan_pvt.app_data; - - pvxlan_pvt.response = NSS_TX_SUCCESS; - pvxlan_pvt.cb = NULL; - pvxlan_pvt.app_data = NULL; - - if (nvxm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("Pvxlan Error response %d\n", nvxm->cm.response); - pvxlan_pvt.response = nvxm->cm.response; - } - - if (callback) { - callback(data, nvxm); - } - complete(&pvxlan_pvt.complete); -} - -/* - * nss_pvxlan_handler() - * Handle NSS -> HLOS messages for PVxLAN. - */ -static void nss_pvxlan_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_pvxlan_msg *nvxm = (struct nss_pvxlan_msg *)ncm; - nss_pvxlan_msg_callback_t cb; - struct nss_pvxlan_handle * h; - - BUG_ON(!nss_pvxlan_verify_if_num(ncm->interface)); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_PVXLAN_MSG_TYPE_MAX) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Trace messages. - */ - nss_core_log_msg_failures(nss_ctx, ncm); - nss_pvxlan_log_rx_msg(nvxm); - - switch (nvxm->cm.type) { - case NSS_PVXLAN_MSG_TYPE_SYNC_STATS: - nss_pvxlan_stats_sync(nss_ctx, &nvxm->msg.stats, ncm->interface); - break; - } - - /* - * Update the callback and app_data for NOTIFY messages. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - uint32_t if_num = ncm->interface - NSS_DYNAMIC_IF_START; - spin_lock_bh(&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); - - } - - cb = (nss_pvxlan_msg_callback_t)ncm->cb; - - /* - * Do we have a callback - */ - if (!cb) { - nss_trace("%px: cb is null for interface %d", nss_ctx, ncm->interface); - return; - } - - cb((void *)ncm->app_data, nvxm); -} - -/* - * nss_pvxlan_tx_msg() - * Transmit a PVXLAN message to NSS FW. Don't call this from softirq/interrupts. - */ -nss_tx_status_t nss_pvxlan_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_pvxlan_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - if (!nss_pvxlan_verify_if_num(msg->cm.interface)) { - return NSS_TX_FAILURE_BAD_PARAM; - } - - if (ncm->type >= NSS_PVXLAN_MSG_TYPE_MAX) { - return NSS_TX_FAILURE_BAD_PARAM; - } - - /* - * Trace messages. - */ - nss_pvxlan_log_tx_msg(msg); - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_pvxlan_tx_msg); - -/* - * nss_pvxlan_tx_msg_sync() - * Transmit a pvxlan message to NSS firmware synchronously. - */ -nss_tx_status_t nss_pvxlan_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_pvxlan_msg *nvxm) -{ - nss_tx_status_t status; - int ret; - - down(&pvxlan_pvt.sem); - nvxm->cm.cb = (nss_ptr_t)nss_pvxlan_callback; - nvxm->cm.app_data = (nss_ptr_t)NULL; - - status = nss_pvxlan_tx_msg(nss_ctx, nvxm); - if (status != NSS_TX_SUCCESS) { - 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("%px: pvxlan tx sync failed due to timeout\n", nss_ctx); - pvxlan_pvt.response = NSS_TX_FAILURE; - } - - status = pvxlan_pvt.response; - up(&pvxlan_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_pvxlan_tx_msg_sync); - -/* - * nss_pvxlan_tx_buf() - * Transmit data buffer (skb) to a NSS interface number - */ -nss_tx_status_t nss_pvxlan_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *buf, uint32_t if_num) -{ - BUG_ON(!nss_pvxlan_verify_if_num(if_num)); - - return nss_core_send_packet(nss_ctx, buf, if_num, H2N_BIT_FLAG_VIRTUAL_BUFFER | H2N_BIT_FLAG_BUFFER_REUSABLE); -} -EXPORT_SYMBOL(nss_pvxlan_tx_buf); - -/* - *********************************** - * Register/Unregister/Miscellaneous APIs - *********************************** - */ - -/* - * nss_pvxlan_unregister() - * Unregister a data packet notifier with NSS FW. - */ -bool nss_pvxlan_unregister(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx; - int32_t i; - - nss_ctx = nss_pvxlan_get_ctx(); - if (!nss_pvxlan_verify_if_num(if_num)) { - nss_warning("%px: data unregister received for invalid interface %d", nss_ctx, if_num); - return false; - } - - spin_lock_bh(&nss_pvxlan_tunnel_stats_debug_lock); - for (i = 0; i < NSS_PVXLAN_MAX_INTERFACES; i++) { - if (nss_pvxlan_tunnel_debug_stats[i].if_num != if_num) { - continue; - } - - memset(&nss_pvxlan_tunnel_debug_stats[i], 0, - sizeof(struct nss_pvxlan_tunnel_stats_debug)); - break; - } - spin_unlock_bh(&nss_pvxlan_tunnel_stats_debug_lock); - - nss_core_unregister_handler(nss_ctx, if_num); - nss_core_unregister_subsys_dp(nss_ctx, if_num); - nss_pvxlan_hdl_instance_free(nss_ctx, if_num); - return true; -} -EXPORT_SYMBOL(nss_pvxlan_unregister); - -/* - * nss_pvxlan_register() - * Registers a data packet notifier with NSS FW. - */ -struct nss_ctx_instance *nss_pvxlan_register(uint32_t if_num, - nss_pvxlan_buf_callback_t data_cb, - nss_pvxlan_msg_callback_t notify_cb, - struct net_device *netdev, - uint32_t features) -{ - struct nss_ctx_instance *nss_ctx; - int core_status; - int32_t i; - - nss_ctx = nss_pvxlan_get_ctx(); - if (!nss_pvxlan_verify_if_num(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("%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("%px: couldn't allocate handle instance for if_num:%d", nss_ctx, if_num); - return NULL; - } - - spin_lock_bh(&nss_pvxlan_tunnel_stats_debug_lock); - for (i = 0; i < NSS_PVXLAN_MAX_INTERFACES; i++) { - if (nss_pvxlan_tunnel_debug_stats[i].valid) { - continue; - } - - nss_pvxlan_tunnel_debug_stats[i].valid = true; - nss_pvxlan_tunnel_debug_stats[i].if_num = if_num; - nss_pvxlan_tunnel_debug_stats[i].if_index = netdev->ifindex; - break; - } - spin_unlock_bh(&nss_pvxlan_tunnel_stats_debug_lock); - - if (i == NSS_PVXLAN_MAX_INTERFACES) { - 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; - } - - nss_core_register_subsys_dp(nss_ctx, if_num, data_cb, NULL, NULL, netdev, features); - return nss_ctx; -} -EXPORT_SYMBOL(nss_pvxlan_register); - -/* - * nss_pvxlan_ifnum_with_core_id() - * Append core id to pvxlan interface num. - */ -int nss_pvxlan_ifnum_with_core_id(int if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_pvxlan_get_ctx(); - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (!nss_is_dynamic_interface(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); -} -EXPORT_SYMBOL(nss_pvxlan_ifnum_with_core_id); - -/* - * nss_pvxlan_msg_init() - * Initialize pvxlan message. - */ -void nss_pvxlan_msg_init(struct nss_pvxlan_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, - nss_pvxlan_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, (void*)cb, app_data); -} -EXPORT_SYMBOL(nss_pvxlan_msg_init); - -/* - * nss_pvxlan_get_ctx() - * Return a Pvxlan NSS context. - */ -struct nss_ctx_instance *nss_pvxlan_get_ctx() -{ - struct nss_ctx_instance *nss_ctx; - - nss_ctx = &nss_top_main.nss[nss_top_main.pvxlan_handler_id]; - return nss_ctx; -} -EXPORT_SYMBOL(nss_pvxlan_get_ctx); - -/* - * nss_pvxlan_init() - * Initializes Pvxlan. Gets called from nss_init.c. - */ -void nss_pvxlan_init() -{ - nss_pvxlan_stats_dentry_create(); - sema_init(&pvxlan_pvt.sem, 1); - init_completion(&pvxlan_pvt.complete); - - memset(&nss_pvxlan_hdl, 0, sizeof(nss_pvxlan_hdl)); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan_log.c deleted file mode 100644 index af516ab54..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan_log.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_pvxlan_log.c - * NSS PVXLAN logger file. - */ - -#include "nss_core.h" - -/* - * nss_pvxlan_log_message_types_str - * PVXLAN message strings - */ -static int8_t *nss_pvxlan_log_message_types_str[NSS_PVXLAN_MSG_TYPE_MAX] __maybe_unused = { - "PVxLAN Sync Stats", - "PVxLAN Tunnel Configure Rule", - "PVxLAN Tunnel Unconfigure Rule", - "PVxLAN Enable Tunnel", - "PVxLAN Disable Tunnel", - "PVxLAN Add MAC rule", - "PVxLAN Delete MAC rule" -}; - -/* - * nss_pvxlan_log_error_response_types_str - * Strings for error types for PVXLAN messages - */ -static int8_t *nss_pvxlan_log_error_response_types_str[NSS_PVXLAN_ERROR_MAX] __maybe_unused = { - "PVXLAN Invalid L3 Protocool", - "PVXLAN Invalid UDP Protocol", - "PVXLAN Tunnel Disabled", - "PVXLAN Tunnel Enabled", - "PVXLAN Tunnel Not Configured", - "PVXLAN Invalid IP Node", - "PVXLAN Invalid Flag", - "PVXLAN MAC Table Full", - "PVXLAN MAC Exists", - "PVXLAN MAC Does Not Exist" -}; - -/* - * nss_pvxlan_log_rule_msg() - * Log NSS PVXLAN rule message. - */ -static void nss_pvxlan_log_rule_msg(struct nss_pvxlan_rule_msg *npvrm) -{ - nss_trace("%px: NSS PVXLAN Rule message \n" - "Encap Rule Src IP: %px\n" - "Encap Rule Src Port: %d\n" - "Encap Rule Dst Ip: %px\n" - "Encap Rule Dst Port: %d\n" - "RPS: %d\n" - "Flags: %x\n" - "Tunnel ID: %d\n", - npvrm, - &npvrm->encap.src.ip, - npvrm->encap.src_port, - &npvrm->encap.dest.ip, - npvrm->encap.dest_port, - npvrm->rps, npvrm->flags, - npvrm->tunnel_id); -} - -/* - * nss_pvxlan_mac_rule_msg() - * Log NSS PVxLAN MAC rule message. - */ -static void nss_pvxlan_log_mac_msg(struct nss_pvxlan_mac_msg *npvcm) -{ - nss_trace("%px: NSS PVXLAN MAC message \n" - "PVxLAN Mac Addr: %x : %x : %x" - "PVxLAN Flags: %u\n" - "PVxLAN VNet ID: %u\n" - "PVxLAN Tunnel ID: %d\n" - "PVxLAN Policy ID: %d", - npvcm, - npvcm->mac_addr[0], npvcm->mac_addr[1], - npvcm->mac_addr[2], npvcm->flags, - npvcm->vnet_id, npvcm->tunnel_id, - npvcm->policy_id); -} - -/* - * nss_pvxlan_log_rule_cfg_msg() - * Log NSS PVxLAN rule configure message. - */ -static void nss_pvxlan_log_rule_cfg_msg(struct nss_pvxlan_msg *npvm) -{ - struct nss_pvxlan_rule_msg *npvrm __maybe_unused = &npvm->msg.rule_cfg; - nss_pvxlan_log_rule_msg(npvrm); -} - -/* - * nss_pvxlan_log_rule_uncfg_msg() - * Log NSS PVxLAN rule unconfigure message. - */ -static void nss_pvxlan_log_rule_uncfg_msg(struct nss_pvxlan_msg *npvm) -{ - struct nss_pvxlan_rule_msg *npvrm __maybe_unused = &npvm->msg.rule_uncfg; - nss_pvxlan_log_rule_msg(npvrm); -} - -/* - * nss_pvxlan_log_enable_msg() - * Log NSS PVxLAN rule enable message. - */ -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("%px: NSS PVXLAN Tunnel state message: Enable \n", npvrm); -} - -/* - * nss_pvxlan_log_disable_msg() - * Log NSS PVxLAN rule disable message. - */ -static void nss_pvxlan_log_disable_msg(struct nss_pvxlan_msg *npvm) -{ - nss_trace("%px: NSS PVXLAN Tunnel state message: Disable \n", npvm); -} - -/* - * nss_pvxlan_log_mac_add_msg() - * Log NSS PVXLAN mac rule add message. - */ -static void nss_pvxlan_log_mac_add_msg(struct nss_pvxlan_msg *npvm) -{ - struct nss_pvxlan_mac_msg *npvcm __maybe_unused = &npvm->msg.mac_add; - nss_pvxlan_log_mac_msg(npvcm); -} - -/* - * nss_pvxlan_log_mac_del_msg() - * Log NSS PVXLAN mac rule del message. - */ -static void nss_pvxlan_log_mac_del_msg(struct nss_pvxlan_msg *npvm) -{ - struct nss_pvxlan_mac_msg *npvcm __maybe_unused = &npvm->msg.mac_del; - nss_pvxlan_log_mac_msg(npvcm); -} - -/* - * nss_pvxlan_log_verbose() - * Log message contents. - */ -static void nss_pvxlan_log_verbose(struct nss_pvxlan_msg *npvm) -{ - switch (npvm->cm.type) { - case NSS_PVXLAN_MSG_TYPE_TUNNEL_CREATE_RULE: - nss_pvxlan_log_rule_cfg_msg(npvm); - break; - - case NSS_PVXLAN_MSG_TYPE_TUNNEL_DESTROY_RULE: - nss_pvxlan_log_rule_uncfg_msg(npvm); - break; - - case NSS_PVXLAN_MSG_TYPE_TUNNEL_ENABLE: - nss_pvxlan_log_enable_msg(npvm); - break; - - case NSS_PVXLAN_MSG_TYPE_TUNNEL_DISABLE: - nss_pvxlan_log_disable_msg(npvm); - break; - - case NSS_PVXLAN_MSG_TYPE_MAC_ADD: - nss_pvxlan_log_mac_add_msg(npvm); - break; - - case NSS_PVXLAN_MSG_TYPE_MAC_DEL: - nss_pvxlan_log_mac_del_msg(npvm); - break; - - case NSS_PVXLAN_MSG_TYPE_SYNC_STATS: - break; - - default: - nss_trace("%px: Invalid message type\n", npvm); - break; - } -} - -/* - * nss_pvxlan_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_pvxlan_log_tx_msg(struct nss_pvxlan_msg *npvm) -{ - if (npvm->cm.type >= NSS_PVXLAN_MSG_TYPE_MAX) { - nss_warning("%px: Invalid message type\n", npvm); - return; - } - - 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); -} - -/* - * nss_pvxlan_log_rx_msg() - * Log messages received from FW. - */ -void nss_pvxlan_log_rx_msg(struct nss_pvxlan_msg *npvm) -{ - if (npvm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_pvxlan_log_verbose(npvm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan_log.h deleted file mode 100644 index cdc0dd772..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_PVXLAN_LOG_H__ -#define __NSS_PVXLAN_LOG_H__ - -/* - * nss_pvxlan_log.h - * NSS PVXLAN Log Header File. - */ - -/* - * nss_pvxlan_log_tx_msg - * Logs a PVxLAN message that is sent to the NSS firmware. - */ -void nss_pvxlan_log_tx_msg(struct nss_pvxlan_msg *ncm); - -/* - * nss_pvxlan_log_rx_msg - * Logs a PVxLAN message that is received from the NSS firmware. - */ -void nss_pvxlan_log_rx_msg(struct nss_pvxlan_msg *ncm); - -#endif /* __NSS_PVXLAN_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan_stats.c deleted file mode 100644 index 59f861604..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan_stats.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_pvxlan_stats.h" - -DEFINE_SPINLOCK(nss_pvxlan_tunnel_stats_debug_lock); -struct nss_pvxlan_tunnel_stats_debug nss_pvxlan_tunnel_debug_stats[NSS_PVXLAN_MAX_INTERFACES]; - -/* - * nss_pvxlan_tunnel_stats_debug_str - * PVxLAN statistics strings for nss tunnel stats - */ -static int8_t *nss_pvxlan_tunnel_stats_debug_str[NSS_PVXLAN_MAX_INTERFACES] = { - "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", - "UDP ENCAP look up failed", - "dropped packet malformed", - "dropped next node queue is full", - "dropped headroom insufficient", - "dropped version mismatch", - "dropped zero sized packet", - "dropped pbuf alloc failed", - "dropped linearization failed" -}; - -/* - * nss_pvxlan_tunnel_stats_debug_get() - * Get PVxLAN Tunnel statitics. - */ -static void nss_pvxlan_tunnel_stats_debug_get(struct nss_pvxlan_tunnel_stats_debug *stats) -{ - uint32_t i; - - if (!stats) { - nss_warning("No memory to copy pvxlan tunnel stats"); - return; - } - - spin_lock_bh(&nss_pvxlan_tunnel_stats_debug_lock); - for (i = 0; i < NSS_PVXLAN_MAX_INTERFACES; i++) { - if (nss_pvxlan_tunnel_debug_stats[i].valid) { - memcpy(stats, &nss_pvxlan_tunnel_debug_stats[i], - sizeof(struct nss_pvxlan_tunnel_stats_debug)); - stats++; - } - } - spin_unlock_bh(&nss_pvxlan_tunnel_stats_debug_lock); -} - -/* - * nss_pvxlan_stats_read() - * Read PVxLAN Tunnel statistics - */ -static ssize_t nss_pvxlan_stats_read(struct file *fp, char __user *ubuf, - size_t sz, loff_t *ppos) -{ - uint32_t max_output_lines = 2 + (NSS_PVXLAN_MAX_INTERFACES - * (NSS_PVXLAN_TUNNEL_STATS_MAX + 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, i; - struct nss_pvxlan_tunnel_stats_debug *pvxlan_tunnel_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; - } - - pvxlan_tunnel_stats = kzalloc((sizeof(struct nss_pvxlan_tunnel_stats_debug) - * NSS_PVXLAN_MAX_INTERFACES), GFP_KERNEL); - if (unlikely(!pvxlan_tunnel_stats)) { - nss_warning("Could not allocate memory for populating PVxLAN stats"); - kfree(lbuf); - return 0; - } - - /* - * Get all stats - */ - nss_pvxlan_tunnel_stats_debug_get(pvxlan_tunnel_stats); - - /* - * Tunnel stats - */ - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, - "\n PVxLAN Tunnel stats start:\n\n"); - - for (id = 0; id < NSS_PVXLAN_MAX_INTERFACES; id++) { - if (!pvxlan_tunnel_stats[id].valid) - break; - - dev = dev_get_by_index(&init_net, pvxlan_tunnel_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, pvxlan_tunnel_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, - pvxlan_tunnel_stats[id].if_num); - } - - for (i = 0; i < NSS_PVXLAN_TUNNEL_STATS_MAX; i++) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, - "\t%s = %llu\n", - nss_pvxlan_tunnel_stats_debug_str[i], - pvxlan_tunnel_stats[id].stats[i]); - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, - "\n PVxLAN Tunnel stats end\n"); - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - - kfree(pvxlan_tunnel_stats); - kfree(lbuf); - return bytes_read; -} - -/* - * nss_pvxlan_stats_sync() - * Sync function for pvxlan statistics - */ -void nss_pvxlan_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_pvxlan_stats_msg *stats_msg, uint32_t if_num) -{ - uint32_t i; - struct nss_pvxlan_tunnel_stats_debug *s = NULL; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - spin_lock_bh(&nss_pvxlan_tunnel_stats_debug_lock); - for (i = 0; i < NSS_PVXLAN_MAX_INTERFACES; i++) { - if (nss_pvxlan_tunnel_debug_stats[i].if_num == if_num) { - s = &nss_pvxlan_tunnel_debug_stats[i]; - break; - } - } - - if (!s) { - spin_unlock_bh(&nss_pvxlan_tunnel_stats_debug_lock); - nss_warning("%px: Tunnel not found: %u", nss_ctx, if_num); - return; - } - - s->stats[NSS_PVXLAN_TUNNEL_STATS_RX_PKTS] += stats_msg->node_stats.rx_packets; - s->stats[NSS_PVXLAN_TUNNEL_STATS_RX_BYTES] += stats_msg->node_stats.rx_bytes; - s->stats[NSS_PVXLAN_TUNNEL_STATS_TX_PKTS] += stats_msg->node_stats.tx_packets; - s->stats[NSS_PVXLAN_TUNNEL_STATS_TX_BYTES] += stats_msg->node_stats.tx_bytes; - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - s->stats[NSS_PVXLAN_TUNNEL_STATS_RX_QUEUE_0_DROPPED + i] += stats_msg->node_stats.rx_dropped[i]; - } - s->stats[NSS_PVXLAN_TUNNEL_STATS_MAC_DB_LOOKUP_FAILED] += - stats_msg->mac_db_lookup_failed; - s->stats[NSS_PVXLAN_TUNNEL_STATS_UDP_ENCAP_LOOKUP_FAILED] += - stats_msg->udp_encap_lookup_failed; - s->stats[NSS_PVXLAN_TUNNEL_STATS_DROP_MALFORMED] += - stats_msg->dropped_malformed; - s->stats[NSS_PVXLAN_TUNNEL_STATS_DROP_NEXT_NODE_QUEUE_FULL] += - stats_msg->dropped_next_node_queue_full; - s->stats[NSS_PVXLAN_TUNNEL_STATS_DROP_HEADROOM_INSUFFICIENT] += - stats_msg->dropped_hroom; - s->stats[NSS_PVXLAN_TUNNEL_STATS_DROP_VERSION_MISMATCH] += - stats_msg->dropped_ver_mis; - s->stats[NSS_PVXLAN_TUNNEL_STATS_DROP_ZERO_SIZED_PACKET] += - stats_msg->dropped_zero_sized_packet; - s->stats[NSS_PVXLAN_TUNNEL_STATS_DROP_PBUF_ALLOC_FAILED] += - stats_msg->dropped_pbuf_alloc_failed; - s->stats[NSS_PVXLAN_TUNNEL_STATS_DROP_LINEAR_FAILED] += - stats_msg->dropped_linear_failed; - spin_unlock_bh(&nss_pvxlan_tunnel_stats_debug_lock); -} - -/* - * nss_pvxlan_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(pvxlan) - -/* - * nss_pvxlan_stats_dentry_create() - * Create gre tunnel statistics debug entry. - */ -void nss_pvxlan_stats_dentry_create(void) -{ - nss_stats_create_dentry("pvxlan", &nss_pvxlan_stats_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan_stats.h deleted file mode 100644 index 874bf785e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_pvxlan_stats.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_PVXLAN_STATS_H -#define __NSS_PVXLAN_STATS_H - -/* - * pvxlan statistic counters - */ -enum nss_pvxlan_tunnel_stats { - NSS_PVXLAN_TUNNEL_STATS_RX_PKTS, - NSS_PVXLAN_TUNNEL_STATS_RX_BYTES, - NSS_PVXLAN_TUNNEL_STATS_TX_PKTS, - NSS_PVXLAN_TUNNEL_STATS_TX_BYTES, - NSS_PVXLAN_TUNNEL_STATS_RX_QUEUE_0_DROPPED, - NSS_PVXLAN_TUNNEL_STATS_RX_QUEUE_1_DROPPED, - NSS_PVXLAN_TUNNEL_STATS_RX_QUEUE_2_DROPPED, - NSS_PVXLAN_TUNNEL_STATS_RX_QUEUE_3_DROPPED, - NSS_PVXLAN_TUNNEL_STATS_MAC_DB_LOOKUP_FAILED, - NSS_PVXLAN_TUNNEL_STATS_UDP_ENCAP_LOOKUP_FAILED, - NSS_PVXLAN_TUNNEL_STATS_DROP_MALFORMED, - NSS_PVXLAN_TUNNEL_STATS_DROP_NEXT_NODE_QUEUE_FULL, - NSS_PVXLAN_TUNNEL_STATS_DROP_HEADROOM_INSUFFICIENT, - NSS_PVXLAN_TUNNEL_STATS_DROP_VERSION_MISMATCH, - NSS_PVXLAN_TUNNEL_STATS_DROP_ZERO_SIZED_PACKET, - NSS_PVXLAN_TUNNEL_STATS_DROP_PBUF_ALLOC_FAILED, - NSS_PVXLAN_TUNNEL_STATS_DROP_LINEAR_FAILED, - NSS_PVXLAN_TUNNEL_STATS_MAX, -}; - -/* - * PVxLAN session debug statistics - */ -struct nss_pvxlan_tunnel_stats_debug { - uint64_t stats[NSS_PVXLAN_TUNNEL_STATS_MAX]; - int32_t if_index; - uint32_t if_num; /* nss interface number */ - bool valid; -}; - -/* - * Data structures to store PVxLAN nss debug stats - */ -extern spinlock_t nss_pvxlan_tunnel_stats_debug_lock; -extern struct nss_pvxlan_tunnel_stats_debug nss_pvxlan_tunnel_debug_stats[NSS_PVXLAN_MAX_INTERFACES]; - -/* - * PVxLAN statistics APIs - */ -extern void nss_pvxlan_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_pvxlan_stats_msg *stats_msg, uint32_t if_num); -extern void nss_pvxlan_stats_dentry_create(void); - -#endif /* __NSS_PVXLAN_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_qrfs.c b/feeds/ipq807x/qca-nss-drv/src/nss_qrfs.c deleted file mode 100644 index cfbff597e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_qrfs.c +++ /dev/null @@ -1,472 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -#include "nss_tx_rx_common.h" -#include "nss_qrfs_stats.h" -#include "nss_qrfs_log.h" - -/* - * Notify data structure - */ -struct nss_qrfs_notify_data { - nss_qrfs_msg_callback_t qrfs_callback; - void *app_data; -}; - -static struct nss_qrfs_notify_data nss_qrfs_notify[NSS_CORE_MAX]; - -/* - * nss_qrfs_verify_if_num() - * Verify if_num passed to us. - */ -static bool nss_qrfs_verify_if_num(uint32_t if_num) -{ - return if_num == NSS_QRFS_INTERFACE; -} - -/* - * nss_qrfs_msg_handler() - * Handle NSS -> HLOS messages for QRFS - */ -static void nss_qrfs_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *app_data) -{ - struct nss_qrfs_msg *nqm = (struct nss_qrfs_msg *)ncm; - nss_qrfs_msg_callback_t cb; - - /* - * Trace messages. - */ - nss_qrfs_log_rx_msg(nqm); - - if (!nss_qrfs_verify_if_num(ncm->interface)) { - nss_warning("%px: invalid interface %d for QRFS\n", nss_ctx, ncm->interface); - return; - } - - /* - * Is this a valid request/response? - */ - if (ncm->type >= NSS_QRFS_MSG_MAX) { - 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("%px: message length is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - switch (ncm->type) { - case NSS_QRFS_MSG_STATS_SYNC: - /* - * Update QRFS statistics. - */ - nss_qrfs_stats_sync(nss_ctx, &nqm->msg.stats_sync); - break; - } - - /* - * Update the callback and app_data for NOTIFY messages - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_qrfs_notify[nss_ctx->id].qrfs_callback; - ncm->app_data = (nss_ptr_t)nss_qrfs_notify[nss_ctx->id].app_data; - } - - /* - * Do we have a callback? - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_qrfs_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, nqm); -} - -/* - * nss_qrfs_get_ctx() - */ -static struct nss_ctx_instance *nss_qrfs_get_ctx(int core_id) -{ - return &nss_top_main.nss[core_id]; -} - -/* - * nss_qrfs_get_flow_keys() - * Get 5 tuple information from flow keys and set in flow rule message. - */ -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 18, 21)) -static bool nss_qrfs_get_flow_keys(struct nss_ctx_instance *nss_ctx, struct sk_buff *skb, - struct nss_qrfs_flow_rule_msg *nqfrm) -{ - struct flow_keys keys; - uint16_t protocol = skb->protocol; - bool res; - struct ipv6hdr *ip6hdr; - - res = skb_flow_dissect(skb, &keys); - if (!res) { - nss_warning("%px: failed to get flow keys\n", nss_ctx); - return res; - } - - nqfrm->protocol = keys.ip_proto; - nqfrm->src_port = keys.port16[0]; - nqfrm->dst_port = keys.port16[1]; - - if (protocol == htons(ETH_P_IP)) { - nqfrm->ip_version = 4; - nqfrm->src_addr[0] = keys.src; - nqfrm->dst_addr[0] = keys.dst; - return true; - } - - nqfrm->ip_version = 6; - ip6hdr = (struct ipv6hdr *)skb_network_header(skb); - if (!ip6hdr) { - nss_warning("%px: failed to get IPv6 address\n", nss_ctx); - return false; - } - - memcpy(nqfrm->src_addr, &ip6hdr->saddr, sizeof(struct in6_addr)); - memcpy(nqfrm->dst_addr, &ip6hdr->daddr, sizeof(struct in6_addr)); - - return true; -} -#else -static bool nss_qrfs_get_flow_keys(struct nss_ctx_instance *nss_ctx, struct sk_buff *skb, - struct nss_qrfs_flow_rule_msg *nqfrm) -{ - struct flow_keys keys; - bool res; - - res = skb_flow_dissect_flow_keys(skb, &keys, 0); - if (!res) { - nss_warning("%px: failed to get flow keys\n", nss_ctx); - return res; - } - - nqfrm->protocol = (uint16_t)keys.basic.ip_proto; - nqfrm->src_port = keys.ports.src; - nqfrm->dst_port = keys.ports.dst; - - if (keys.basic.n_proto == htons(ETH_P_IP)) { - nqfrm->ip_version = 4; - nqfrm->src_addr[0] = keys.addrs.v4addrs.src; - nqfrm->dst_addr[0] = keys.addrs.v4addrs.dst; - return true; - } - - nqfrm->ip_version = 6; - memcpy(nqfrm->src_addr, &keys.addrs.v6addrs.src, sizeof(struct in6_addr)); - memcpy(nqfrm->dst_addr, &keys.addrs.v6addrs.dst, sizeof(struct in6_addr)); - - return true; -} -#endif - -/* - * nss_qrfs_flow_add_msg_callback() - * Callback function for receiving flow add response messages. - */ -static void nss_qrfs_flow_add_msg_callback(void *app_data, struct nss_qrfs_msg *nqm) -{ - struct nss_ctx_instance *nss_ctx __maybe_unused = (struct nss_ctx_instance *)app_data; - struct nss_qrfs_flow_rule_msg *nqfrm; - - if (nqm->cm.type != NSS_QRFS_MSG_FLOW_ADD) { - 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("%px: invalid IP version %d\n", nss_ctx, nqfrm->ip_version); - return; - } - - if (nqm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("%px: flow add configuration error: %d for NSS core %d\n", - nss_ctx, nqm->cm.error, nss_ctx->id); - } -} - -/* - * nss_qrfs_flow_delete_msg_callback() - * Callback function for receiving flow delete response messages. - */ -static void nss_qrfs_flow_delete_msg_callback(void *app_data, struct nss_qrfs_msg *nqm) -{ - struct nss_ctx_instance *nss_ctx __maybe_unused = (struct nss_ctx_instance *)app_data; - struct nss_qrfs_flow_rule_msg *nqfrm; - - if (nqm->cm.type != NSS_QRFS_MSG_FLOW_DELETE) { - 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("%px: invalid IP version %d\n", nss_ctx, nqfrm->ip_version); - return; - } - - if (nqm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("%px: flow delete configuration error: %d for NSS core %d\n", - nss_ctx, nqm->cm.error, nss_ctx->id); - } -} - -/* - * nss_qrfs_msg_init() - * Initialize the common header of QRFS message - */ -static void nss_qrfs_msg_init(struct nss_qrfs_msg *nqm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&nqm->cm, if_num, type, len, cb, app_data); -} - -/* - * nss_qrfs_tx_msg() - * Transmit a QRFS message to NSS firmware - */ -static nss_tx_status_t nss_qrfs_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_qrfs_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace messages. - */ - nss_qrfs_log_tx_msg(msg); - - /* - * Sanity check the message - */ - if (!nss_qrfs_verify_if_num(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("%px: message type is out of range: %d\n", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} - -/* - * nss_qrfs_add_flow_rule() - * Set a QRFS flow rule add message and transmit the message to NSS core. - */ -static nss_tx_status_t nss_qrfs_add_flow_rule(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - struct sk_buff *skb, uint32_t cpu, bool need_cb) -{ - struct nss_qrfs_msg nqm; - struct nss_qrfs_flow_rule_msg *nqfrm; - nss_tx_status_t status; - nss_qrfs_msg_callback_t cb = NULL; - void *app_data = NULL; - bool res; - - memset(&nqm, 0, sizeof(struct nss_qrfs_msg)); - - if (need_cb) { - cb = nss_qrfs_flow_add_msg_callback; - app_data = (void *)nss_ctx; - } - - /* - * Initialize common header of QRFS flow rule add message. - */ - nss_qrfs_msg_init(&nqm, NSS_QRFS_INTERFACE, NSS_QRFS_MSG_FLOW_ADD, - sizeof(struct nss_qrfs_flow_rule_msg), cb, app_data); - - /* - * Set flow rule of QRFS flow rule add message - */ - nqfrm = &nqm.msg.flow_add; - res = nss_qrfs_get_flow_keys(nss_ctx, skb, nqfrm); - if (!res) { - return NSS_TX_FAILURE; - } - - nqfrm->cpu = (uint16_t)cpu; - nqfrm->if_num = if_num; - - /* - * Send QRFS flow rule add message to NSS core - */ - status = nss_qrfs_tx_msg(nss_ctx, &nqm); - if (status == NSS_TX_SUCCESS) { - return status; - } - - return NSS_TX_FAILURE; -} - -/* - * nss_qrfs_delete_flow_rule() - * Set a QRFS delete flow rule message and transmit the message to all NSS core. - */ -static nss_tx_status_t nss_qrfs_delete_flow_rule(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - struct sk_buff *skb, uint32_t cpu, bool need_cb) -{ - struct nss_qrfs_msg nqm; - struct nss_qrfs_flow_rule_msg *nqfrm; - nss_tx_status_t status; - nss_qrfs_msg_callback_t cb = NULL; - void *app_data = NULL; - bool res; - - memset(&nqm, 0, sizeof(struct nss_qrfs_msg)); - - if (need_cb) { - cb = nss_qrfs_flow_delete_msg_callback; - app_data = (void *)nss_ctx; - } - - /* - * Initialize common header of QRFS flow rule delete message. - */ - nss_qrfs_msg_init(&nqm, NSS_QRFS_INTERFACE, NSS_QRFS_MSG_FLOW_DELETE, - sizeof(struct nss_qrfs_flow_rule_msg), cb, app_data); - - /* - * Set flow rule of QRFS flow rule delete message - */ - nqfrm = &nqm.msg.flow_delete; - res = nss_qrfs_get_flow_keys(nss_ctx, skb, nqfrm); - if (!res) { - return NSS_TX_FAILURE; - } - - nqfrm->cpu = (uint16_t)cpu; - nqfrm->if_num = if_num; - - /* - * Send QRFS flow rule delete message to NSS core - */ - status = nss_qrfs_tx_msg(nss_ctx, &nqm); - if (status == NSS_TX_SUCCESS) { - return status; - } - - return NSS_TX_FAILURE; -} - -/* - * nss_qrfs_set_flow_rule() - * Set a QRFS flow rule message and transmit the message to all NSS cores. - */ -nss_tx_status_t nss_qrfs_set_flow_rule(struct sk_buff *skb, uint32_t cpu, uint32_t action) -{ - struct nss_ctx_instance *nss_ctx; - nss_tx_status_t status; - int i; - - for (i = 0; i < NSS_CORE_MAX; i++) { - nss_ctx = nss_qrfs_get_ctx(i); - - /* - * Set QRFS flow rule message and transmit the message to NSS core. - * - * TODO: Remove if_num parameter from add_flow_rule() and - * delete_flow_rule(), since it is unused in firmware. - */ - if (action == NSS_QRFS_MSG_FLOW_ADD) { - status = nss_qrfs_add_flow_rule(nss_ctx, 0, skb, cpu, true); - } else { - status = nss_qrfs_delete_flow_rule(nss_ctx, 0, skb, cpu, true); - } - - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: failed to send flow rule to NSS core %d\n", nss_ctx, i); - return NSS_TX_FAILURE; - } - } - - return NSS_TX_SUCCESS; -} -EXPORT_SYMBOL(nss_qrfs_set_flow_rule); - -/* - * nss_qrfs_register_handler() - */ -void nss_qrfs_register_handler(struct nss_ctx_instance *nss_ctx) -{ - nss_core_register_handler(nss_ctx, NSS_QRFS_INTERFACE, nss_qrfs_msg_handler, NULL); - - if (nss_ctx->id == NSS_CORE_0) { - nss_qrfs_stats_dentry_create(); - } -} -EXPORT_SYMBOL(nss_qrfs_register_handler); - -/* - * nss_qrfs_notify_register() - * Register to receive QRFS notify messages. - */ -struct nss_ctx_instance *nss_qrfs_notify_register(int core, nss_qrfs_msg_callback_t cb, void *app_data) -{ - if (core >= NSS_CORE_MAX) { - nss_warning("Input core number %d is wrong\n", core); - return NULL; - } - - nss_qrfs_notify[core].qrfs_callback = cb; - nss_qrfs_notify[core].app_data = app_data; - - return (struct nss_ctx_instance *)&nss_top_main.nss[core]; -} - -/* - * nss_qrfs_notify_unregister() - * Unregister to receive QRFS notify messages. - */ -void nss_qrfs_notify_unregister(int core) -{ - if (core >= NSS_CORE_MAX) { - nss_warning("Input core number %d is wrong\n", core); - return; - } - - nss_qrfs_notify[core].qrfs_callback = NULL; - nss_qrfs_notify[core].app_data = NULL; -} - -/* - * nss_qrfs_init() - */ -void nss_qrfs_init(void) -{ - int core; - - for (core = 0; core < NSS_CORE_MAX; core++) { - nss_qrfs_notify_register(core, NULL, NULL); - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_qrfs_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_qrfs_log.c deleted file mode 100644 index d481e2866..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_qrfs_log.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_qrfs_log.c - * NSS QRFS logger file. - */ - -#include "nss_core.h" -#define NSS_QRFS_LOG_IPV4 4 -#define NSS_QRFS_LOG_IPV6 6 - -/* - * nss_qrfs_log_message_types_str - * QRFS message strings - */ -static int8_t *nss_qrfs_log_message_types_str[NSS_QRFS_MSG_MAX] __maybe_unused = { - "QRFS Flow Add Message", - "QRFS Flow Delete Message", - "QRFS MAC Add Message", - "QRFS MAC Delete Message", - "QRFS Stats Sync", -}; - -/* - * nss_qrfs_log_error_response_types_str - * Strings for error types for QRFS messages - */ -static int8_t *nss_qrfs_log_error_response_types_str[NSS_QRFS_ERROR_MAX] __maybe_unused = { - "QRFS Invalid Message Type", - "QRFS Invalid Message Size", - "QRFS Invalid IP Version", - "QRFS V4 Flow Table Full", - "QRFS V6 Flow Table Full", - "QRFS MAC Table Full", -}; - -/* - * nss_qrfs_log_flow_rule_msg() - * Log NSS QRFS Flow Rule Message. - */ -static void nss_qrfs_log_flow_rule_msg(struct nss_qrfs_flow_rule_msg *nqfm) -{ - nss_trace("%px: NSS QRFS Flow Rule Message:\n" - "QRFS Source Port: %d\n" - "QRFS Destination Port: %d\n" - "QRFS IP Version: %d\n" - "QRFS Protcol: %d\n" - "QRFS CPU ID: %d\n" - "QRFS Physical Interface Number: %d\n", - nqfm, nqfm->src_port, - nqfm->dst_port, nqfm->ip_version, - nqfm->protocol, nqfm->cpu, - nqfm->if_num); - - /* - * Continuation of log. Different identifiers based on ip_version - */ - if (nqfm->ip_version == NSS_QRFS_LOG_IPV6) { - nss_trace("QRFS Source Address: %pI6\n" - "QRFS Destination Address: %pI6\n", - nqfm->src_addr, nqfm->dst_addr); - } else if (nqfm->ip_version == NSS_QRFS_LOG_IPV4) { - nss_trace("QRFS Source Address: %pI4\n" - "QRFS Destination Address: %pI4\n", - nqfm->src_addr, nqfm->dst_addr); - } -} - -/* - * nss_qrfs_log_mac_rule_msg() - * Log NSS QRFS MAC Rule Message. - */ -static void nss_qrfs_log_mac_rule_msg(struct nss_qrfs_mac_rule_msg *nqmm) -{ - nss_trace("%px: NSS QRFS MAC Rule Message:\n" - "QRFS MAC: %pM\n" - "QRFS CPU ID: %d\n" - "QRFS Physical Interface Number: %d\n", - nqmm, nqmm->mac, - nqmm->cpu, nqmm->if_num); -} - -/* - * nss_qrfs_log_verbose() - * Log message contents. - */ -static void nss_qrfs_log_verbose(struct nss_qrfs_msg *nqm) -{ - switch (nqm->cm.type) { - case NSS_QRFS_MSG_FLOW_ADD: - case NSS_QRFS_MSG_FLOW_DELETE: - nss_qrfs_log_flow_rule_msg(&nqm->msg.flow_add); - break; - - case NSS_QRFS_MSG_MAC_ADD: - case NSS_QRFS_MSG_MAC_DELETE: - nss_qrfs_log_mac_rule_msg(&nqm->msg.mac_add); - break; - - case NSS_QRFS_MSG_STATS_SYNC: - /* - * No log for valid stats message. - */ - break; - - default: - nss_warning("%px: Invalid message type\n", nqm); - break; - } -} - -/* - * nss_qrfs_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_qrfs_log_tx_msg(struct nss_qrfs_msg *nqm) -{ - if (nqm->cm.type >= NSS_QRFS_MSG_MAX) { - nss_warning("%px: Invalid message type\n", nqm); - return; - } - - 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); -} - -/* - * nss_qrfs_log_rx_msg() - * Log messages received from FW. - */ -void nss_qrfs_log_rx_msg(struct nss_qrfs_msg *nqm) -{ - if (nqm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_qrfs_log_verbose(nqm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_qrfs_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_qrfs_log.h deleted file mode 100644 index de9832e66..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_qrfs_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_QRFS_LOG_H__ -#define __NSS_QRFS_LOG_H__ - -/* - * nss_qrfs_log.h - * NSS QRFS Log Header File - */ - -/* - * nss_qrfs_log_tx_msg - * Logs a qrfs message that is sent to the NSS firmware. - */ -void nss_qrfs_log_tx_msg(struct nss_qrfs_msg *nqm); - -/* - * nss_qrfs_log_rx_msg - * Logs a qrfs message that is received from the NSS firmware. - */ -void nss_qrfs_log_rx_msg(struct nss_qrfs_msg *nqm); - -#endif /* __NSS_QRFS_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_qrfs_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_qrfs_stats.c deleted file mode 100644 index 694908307..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_qrfs_stats.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2018-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_qrfs_stats.h" - -/* - * Spinlock to protect QRFS statistics update/read - */ -DEFINE_SPINLOCK(nss_qrfs_stats_lock); - -/* - * nss_qrfs_stats_str - * QRFS stats strings - */ -struct nss_stats_info nss_qrfs_stats_str[NSS_QRFS_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}, - {"invalid_offset" , NSS_STATS_TYPE_EXCEPTION}, - {"unknown_protocol" , NSS_STATS_TYPE_EXCEPTION}, - {"ipv4_flow_rule_hits" , NSS_STATS_TYPE_SPECIAL}, - {"ipv6_flow_rule_hits" , NSS_STATS_TYPE_SPECIAL} -}; - -uint64_t nss_qrfs_stats[NSS_MAX_CORES][NSS_QRFS_STATS_MAX]; - -/* - * nss_qrfs_stats_read() - * Read QRFS statistics. - */ -static ssize_t nss_qrfs_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int32_t i, core; - - /* - * 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_QRFS_STATS_MAX + 3) * NSS_MAX_CORES + 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_QRFS_STATS_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, "qrfs", NSS_STATS_SINGLE_CORE); - /* - * QRFS statistics - */ - for (core = 0; core < nss_top_main.num_nss; core++) { - spin_lock_bh(&nss_qrfs_stats_lock); - for (i = 0; i < NSS_QRFS_STATS_MAX; i++) { - stats_shadow[i] = nss_qrfs_stats[core][i]; - } - spin_unlock_bh(&nss_qrfs_stats_lock); - - size_wr += nss_stats_print("qrfs", NULL, NSS_STATS_SINGLE_INSTANCE - , nss_qrfs_stats_str - , stats_shadow - , NSS_QRFS_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_qrfs_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(qrfs) - -/* - * nss_qrfs_stats_dentry_create() - * Create QRFS statistics debug entry. - */ -void nss_qrfs_stats_dentry_create(void) -{ - nss_stats_create_dentry("qrfs", &nss_qrfs_stats_ops); -} - -/* - * nss_qrfs_stats_sync() - * Handle the syncing of NSS QRFS statistics. - */ -void nss_qrfs_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_qrfs_stats_sync_msg *nqssm) -{ - int id = nss_ctx->id; - int j; - - spin_lock_bh(&nss_qrfs_stats_lock); - - /* - * Common node stats - */ - nss_qrfs_stats[id][NSS_STATS_NODE_RX_PKTS] += nqssm->node_stats.rx_packets; - nss_qrfs_stats[id][NSS_STATS_NODE_RX_BYTES] += nqssm->node_stats.rx_bytes; - nss_qrfs_stats[id][NSS_STATS_NODE_TX_PKTS] += nqssm->node_stats.tx_packets; - nss_qrfs_stats[id][NSS_STATS_NODE_TX_BYTES] += nqssm->node_stats.tx_bytes; - - for (j = 0; j < NSS_MAX_NUM_PRI; j++) { - nss_qrfs_stats[id][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + j] += nqssm->node_stats.rx_dropped[j]; - } - - /* - * QRFS statistics - */ - nss_qrfs_stats[id][NSS_QRFS_STATS_INVALID_OFFSET] += nqssm->invalid_offset; - nss_qrfs_stats[id][NSS_QRFS_STATS_UNKNOWN_PROTO] += nqssm->unknown_protocol; - nss_qrfs_stats[id][NSS_QRFS_STATS_IPV4_FLOW_HITS] += nqssm->ipv4_flow_rule_hits; - nss_qrfs_stats[id][NSS_QRFS_STATS_IPV6_FLOW_HITS] += nqssm->ipv6_flow_rule_hits; - - spin_unlock_bh(&nss_qrfs_stats_lock); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_qrfs_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_qrfs_stats.h deleted file mode 100644 index 7992270da..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_qrfs_stats.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_QRFS_STATS_H -#define __NSS_QRFS_STATS_H - -/* - * QRFS node statistics - */ -enum nss_qrfs_stats_types { - NSS_QRFS_STATS_INVALID_OFFSET = NSS_STATS_NODE_MAX, - /* Number of packets with invalid L3, L4 offset */ - NSS_QRFS_STATS_UNKNOWN_PROTO, /* Number of packets with protocol other than TCP, UDP */ - NSS_QRFS_STATS_IPV4_FLOW_HITS, /* Number of IPv4 flow rule hits */ - NSS_QRFS_STATS_IPV6_FLOW_HITS, /* Number of IPv6 flow rule hits */ - NSS_QRFS_STATS_MAX, -}; - -/* - * QRFS statistics APIs - */ -extern void nss_qrfs_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_qrfs_stats_sync_msg *nqssm); -extern void nss_qrfs_stats_dentry_create(void); - -#endif /* __NSS_QRFS_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_qvpn.c b/feeds/ipq807x/qca-nss-drv/src/nss_qvpn.c deleted file mode 100644 index b6068d947..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_qvpn.c +++ /dev/null @@ -1,344 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_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 - */ -static struct nss_qvpn_pvt { - struct semaphore sem; - struct completion complete; - unsigned long if_map[NSS_QVPN_INTERFACE_MAX_LONG]; - enum nss_qvpn_error_type resp; -} qvpn_pvt; - -/* - * nss_qvpn_verify_if_num() - * Verify if_num passed to us. - */ -static bool nss_qvpn_verify_if_num(uint32_t if_num) -{ - enum nss_dynamic_interface_type if_type; - - 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("%px: if_num = %u interface type returned is %d\n", nss_qvpn_get_context(), if_num, if_type); - return false; - } - - return true; -} - -/* - * nss_qvpn_handler() - * Handle NSS to HLOS messages for QVPN - */ -static void nss_qvpn_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *app_data) -{ - nss_qvpn_msg_callback_t cb; - - nss_assert(nss_qvpn_verify_if_num(ncm->interface)); - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_QVPN_MSG_TYPE_MAX) { - 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("%px: length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Log failures - */ - - nss_core_log_msg_failures(nss_ctx, ncm); - /* - * Trace messages. - */ - 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); - } - - /* - * Update the callback and app_data for NOTIFY messages, qvpn 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->nss_rx_interface_handlers[ncm->interface].app_data; - } - - /* - * load, test & call - */ - cb = (nss_qvpn_msg_callback_t)ncm->cb; - if (unlikely(!cb)) { - nss_trace("%px: rx handler unregistered for i/f: %u\n", nss_ctx, ncm->interface); - return; - } - - cb((void *)ncm->app_data, ncm); -} - -/* - * nss_qvpn_callback() - * Callback to handle the completion of NSS to HLOS messages. - */ -static void nss_qvpn_callback(void *app_data, struct nss_qvpn_msg *nvm) -{ - enum nss_qvpn_error_type *resp = (enum nss_qvpn_error_type *)app_data; - - *resp = (nvm->cm.response == NSS_CMN_RESPONSE_ACK) ? NSS_QVPN_ERROR_TYPE_NONE : nvm->cm.error; - - /* - * Write memory barrier - */ - smp_wmb(); - - complete(&qvpn_pvt.complete); -} - -/* - * nss_qvpn_ifmap_get() - * Return QVPN active interfaces map. - */ -unsigned long *nss_qvpn_ifmap_get(void) -{ - return qvpn_pvt.if_map; -} - -/* - * nss_qvpn_get_context() - * Return NSS QVPN context. - */ -struct nss_ctx_instance *nss_qvpn_get_context(void) -{ - return &nss_top_main.nss[nss_top_main.qvpn_handler_id]; -} -EXPORT_SYMBOL(nss_qvpn_get_context); - -/* - * nss_qvpn_tx_msg() - * Transmit a QVPN message to NSS firmware - */ -nss_tx_status_t nss_qvpn_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_qvpn_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Sanity check the message - */ - if (!nss_qvpn_verify_if_num(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("%px: message type out of range: %d\n", nss_ctx, ncm->type); - return NSS_TX_FAILURE_BAD_PARAM; - } - - /* - * Trace messages. - */ - nss_qvpn_log_tx_msg(msg); - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_qvpn_tx_msg); - -/* - * nss_qvpn_tx_msg_sync() - * Transmit a QVPN message to NSS firmware synchronously. - */ -nss_tx_status_t nss_qvpn_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_qvpn_msg *nvm, - uint32_t if_num, enum nss_qvpn_msg_type type, uint16_t len, enum nss_qvpn_error_type *resp) -{ - struct nss_qvpn_msg nqm; - nss_tx_status_t status; - int ret = 0; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (len > sizeof(nqm.msg)) { - 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("%px: Invalid input, resp=NULL\n", nss_ctx); - return NSS_TX_FAILURE_BAD_PARAM; - } - - nss_qvpn_msg_init(&nqm, if_num, type, len, nss_qvpn_callback, &qvpn_pvt.resp); - memcpy(&nqm.msg, &nvm->msg, len); - - down(&qvpn_pvt.sem); - - status = nss_qvpn_tx_msg(nss_ctx, &nqm); - if (status != NSS_TX_SUCCESS) { - 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("%px: qvpn msg tx failed due to timeout\n", nss_ctx); - status = NSS_TX_FAILURE_SYNC_TIMEOUT; - goto done; - } - - /* - * Read memory barrier - */ - smp_rmb(); - - *resp = qvpn_pvt.resp; - if (*resp != NSS_QVPN_ERROR_TYPE_NONE) - status = NSS_TX_FAILURE; -done: - up(&qvpn_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_qvpn_tx_msg_sync); - -/* - * nss_qvpn_tx_buf() - * Send packet to QVPN interface owned by NSS - */ -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("%px: tx request for interface that is not a qvpn: %u\n", nss_ctx, if_num); - return NSS_TX_FAILURE_BAD_PARAM; - } - - return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_BUFFER_REUSABLE); -} -EXPORT_SYMBOL(nss_qvpn_tx_buf); - -/* - * nss_qvpn_msg_init() - * Initialize nss_qvpn_msg. - */ -void nss_qvpn_msg_init(struct nss_qvpn_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} -EXPORT_SYMBOL(nss_qvpn_msg_init); - -/* - * nss_qvpn_register_if() - * Register QVPN interface. - */ -struct nss_ctx_instance *nss_qvpn_register_if(uint32_t if_num, nss_qvpn_callback_t qvpn_data_callback, - nss_qvpn_msg_callback_t qvpn_event_callback, - 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); - 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; -} -EXPORT_SYMBOL(nss_qvpn_register_if); - -/* - * nss_unregister_qvpn_if() - * Unregister QVPN interface. - */ -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); - 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; - } - - 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); - -/* - * nss_qvpn_ifnum_with_core_id() - * Append core id to QVPN interface number - */ -int nss_qvpn_ifnum_with_core_id(int if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_qvpn_get_context(); - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - if (nss_qvpn_verify_if_num(if_num) == false) { - 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); -} -EXPORT_SYMBOL(nss_qvpn_ifnum_with_core_id); - -/* - * nss_qvpn_register_handler() - * Intialize QVPN driver and register handler. - */ -void nss_qvpn_register_handler(void) -{ - nss_info("nss_qvpn_register_handler\n"); - sema_init(&qvpn_pvt.sem, 1); - init_completion(&qvpn_pvt.complete); - nss_qvpn_stats_dentry_create(); - nss_qvpn_strings_dentry_create(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_log.c deleted file mode 100644 index d71c79ee1..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_log.c +++ /dev/null @@ -1,262 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_qvpn_log.c - * NSS qvpn logger file. - */ - -#include "nss_core.h" - -/* - * nss_qvpn_log_message_types_str - * qvpn message strings - */ -static int8_t *nss_qvpn_log_message_types_str[NSS_QVPN_MSG_TYPE_MAX] __maybe_unused = { - "QVPN tunnel config", - "QVPN tunnel deconfig", - "QVPN crypto key add", - "QVPN crypto key delete", - "QVPN crypto crypto key activate", - "QVPN crypto key Deactivate", - "QVPN statistics synchronization" -}; - -/* - * nss_qvpn_log_error_response_types_str - * Strings for error types for qvpn messages - */ -static int8_t *nss_qvpn_log_error_response_types_str[NSS_QVPN_ERROR_TYPE_MAX] __maybe_unused = { - "QVPN No error", - "QVPN Unknown message", - "QVPN Tunnel already configured", - "QVPN Invalid interface", - "QVPN Invalid sibling interface number", - "QVPN Invalid IV size", - "QVPN Invalid HMAC size", - "QVPN Invalid crypto block size", - "QVPN Invalid session idx size", - "QVPN Supported processing command count invalid", - "QVPN L4 protocol encapsulation is not supported", - "QVPN Invalid sibling interface type", - "QVPN Total number of commands is invalid", - "QVPN Entry not found", - "QVPN Entry not active", - "QVPN Entry already active", - "QVPN Invalid crypto index", - "QVPN Key info allocation failure", - "QVPN Invalid command profile", - "QVPN VPN with tail not supported" -}; - -/* - * nss_qvpn_tun_config_msg() - * Log NSS QVPN configuration message. - */ -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("%px: NSS QVPN tunnel config message \n" - "Sibling interface: %d" - "Total number of commands: %d" - "Commands: %px" - "Source IP: %x:%x:%x:%x\n" - "Source Port: %d\n" - "Destination IP: %x:%x:%x:%x\n" - "Destination Port: %d\n" - "Header Flags: %x\n" - "Sequence number size: %d\n" - "Sequence number offset: %d\n" - "Anti-replay algorithm: %d\n" - "Session ID size: %d\n" - "Session ID offset: %x\n" - "VPN header head size: %d\n" - "VPN header head offset: %d\n" - "VPN header tail size: %d\n" - "VPN header head: %px\n" - "VPN header tail: %px\n", - nqtcm, - nqtcm->sibling_if, - nqtcm->total_cmds, - nqtcm->cmd, - nqtcm->hdr_cfg.src_ip[0], nqtcm->hdr_cfg.src_ip[1], nqtcm->hdr_cfg.src_ip[2], nqtcm->hdr_cfg.src_ip[3], - nqtcm->hdr_cfg.src_port, - nqtcm->hdr_cfg.dst_ip[0], nqtcm->hdr_cfg.dst_ip[1], nqtcm->hdr_cfg.dst_ip[2], nqtcm->hdr_cfg.dst_ip[3], - nqtcm->hdr_cfg.dst_port, - nqtcm->hdr_cfg.hdr_flags, - nqtcm->hdr_cfg.seqnum_size, - nqtcm->hdr_cfg.seqnum_offset, - nqtcm->hdr_cfg.anti_replay_alg, - nqtcm->hdr_cfg.session_id_size, - nqtcm->hdr_cfg.session_id_offset, - nqtcm->hdr_cfg.vpn_hdr_head_size, - nqtcm->hdr_cfg.vpn_hdr_head_offset, - nqtcm->hdr_cfg.vpn_hdr_tail_size, - nqtcm->hdr_cfg.vpn_hdr_head, - nqtcm->hdr_cfg.vpn_hdr_tail); -} - -/* - * nss_qvpn_log_tun_deconfig_msg() - * Log NSS qvpn tunnel deconfigure message. - */ -static void nss_qvpn_log_tun_deconfig_msg(struct nss_qvpn_msg *ncm) -{ - nss_trace("%px: NSS QVPN deconfigure message \n", ncm); -} - -/* - * nss_qvpn_log_crypto_key_add_msg() - * Log NSS QVPN crypto key add message. - */ -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("%px: NSS QVPN crypto key add message \n" - "Crypto index: %d\n" - "Crypto session ID: %px", - nqckam, - nqckam->crypto_idx, - nqckam->session_id); -} - -/* - * nss_qvpn_log_crypto_key_activate_msg() - * Log NSS QVPN crypto key activate message. - */ -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("%px: NSS QVPN crypto key activate message \n" - "Crypto index: %d\n" - "Crypto VPN header head: %px", - nqckam, - nqckam->crypto_idx, - nqckam->vpn_hdr_head); -} - -/* - * nss_qvpn_log_crypto_key_del_msg() - * Log NSS QVPN crypto key delete message. - */ -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("%px: NSS QVPN crypto key delete message \n" - "Crypto index: %d\n", - nqckdm, - nqckdm->crypto_idx); -} - -/* - * nss_qvpn_log_crypto_key_deactivate_msg() - * Log NSS QVPN crypto key deactivate message. - */ -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("%px: NSS QVPN crypto key deactivate message \n" - "Crypto index: %d\n", - nqckdm, - nqckdm->crypto_idx); -} - -/* - * nss_qvpn_log_verbose() - * Log message contents. - */ -static void nss_qvpn_log_verbose(struct nss_qvpn_msg *ncm) -{ - switch (ncm->cm.type) { - case NSS_QVPN_MSG_TYPE_TUNNEL_CONFIGURE: - nss_qvpn_log_tun_config_msg(ncm); - break; - - case NSS_QVPN_MSG_TYPE_TUNNEL_DECONFIGURE: - nss_qvpn_log_tun_deconfig_msg(ncm); - break; - - case NSS_QVPN_MSG_TYPE_CRYPTO_KEY_ADD: - nss_qvpn_log_crypto_key_add_msg(ncm); - break; - - case NSS_QVPN_MSG_TYPE_CRYPTO_KEY_ACTIVATE: - nss_qvpn_log_crypto_key_activate_msg(ncm); - break; - - case NSS_QVPN_MSG_TYPE_CRYPTO_KEY_DEL: - nss_qvpn_log_crypto_key_del_msg(ncm); - break; - - case NSS_QVPN_MSG_TYPE_CRYPTO_KEY_DEACTIVATE: - nss_qvpn_log_crypto_key_deactivate_msg(ncm); - break; - - default: - nss_trace("%px: Invalid message type\n", ncm); - break; - } -} - -/* - * nss_qvpn_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_qvpn_log_tx_msg(struct nss_qvpn_msg *ncm) -{ - if (ncm->cm.type >= NSS_QVPN_MSG_TYPE_MAX) { - nss_warning("%px: Invalid message type\n", ncm); - return; - } - - 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); -} - -/* - * nss_qvpn_log_rx_msg() - * Log messages received from FW. - */ -void nss_qvpn_log_rx_msg(struct nss_qvpn_msg *ncm) -{ - if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_qvpn_log_verbose(ncm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_log.h deleted file mode 100644 index e1dee898b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_LOG_H__ -#define __NSS_QVPN_LOG_H__ - -/* - * nss_qvpn_log.h - * NSS QVPN Log Header File. - */ - -/* - * nss_qvpn_log_tx_msg - * Logs QVPN message that is sent to the NSS firmware. - */ -void nss_qvpn_log_tx_msg(struct nss_qvpn_msg *ncm); - -/* - * nss_qvpn_log_rx_msg - * Logs QVPN message that is received from the NSS firmware. - */ -void nss_qvpn_log_rx_msg(struct nss_qvpn_msg *ncm); - -#endif /* __NSS_QVPN_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_stats.c deleted file mode 100644 index 4a9bdc116..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_stats.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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 -#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() - * Read qvpn node statiistics. - */ -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; - uint32_t if_num; - int32_t i; - int count; - char *lbuf; - - ifmap = nss_qvpn_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_STATS_NODE_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 QVPN dynamic interface. - */ - size_wr += nss_stats_banner(lbuf, size_wr, size_al, "qvpn 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_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]; - } - 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); - } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - vfree(lbuf); - vfree(stats_shadow); - return bytes_read; -} - -/* - * nss_qvpn_stats_ops - */ -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. - */ -void nss_qvpn_stats_dentry_create(void) -{ - nss_stats_create_dentry("qvpn", &nss_qvpn_stats_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_stats.h deleted file mode 100644 index 74bbe11de..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_stats.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 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. - * 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_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); - -#endif /* _NSS_QVPN_STATS_H_ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_strings.c deleted file mode 100644 index 2af34aad4..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_qvpn_strings.h deleted file mode 100644 index 4b874d803..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_rmnet_rx.c b/feeds/ipq807x/qca-nss-drv/src/nss_rmnet_rx.c deleted file mode 100644 index c77ef3f3e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_rmnet_rx.c +++ /dev/null @@ -1,781 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_rmnet_rx.c - * NSS rmnet receive handler APIs - */ - -#include "nss_tx_rx_common.h" -#include "nss_rmnet_rx_stats.h" -#include - -#define NSS_RMNET_RX_TX_TIMEOUT 3000 /* 3 Seconds */ -#define NSS_RMNET_RX_GET_INDEX(if_num) (if_num - NSS_DYNAMIC_IF_START) - -/* - * Spinlock to protect the global data structure rmnet handle. - */ -DEFINE_SPINLOCK(nss_rmnet_rx_lock); - -extern int nss_ctl_redirect; - -/* - * Data structure that holds theinterface context. - */ -struct nss_rmnet_rx_handle *rmnet_rx_handle[NSS_MAX_DYNAMIC_INTERFACES]; - -/* - * nss_rmnet_rx_verify_if_num() - * Verify if_num passed to us. - */ -bool nss_rmnet_rx_verify_if_num(uint32_t if_num) -{ - enum nss_dynamic_interface_type type = nss_dynamic_interface_get_type(nss_rmnet_rx_get_context(), if_num); - - return type == NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_N2H - || type == NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_H2N; -} - -/* - * nss_rmnet_rx_msg_handler() - * Handle msg responses from the FW on interfaces - */ -static void nss_rmnet_rx_msg_handler(struct nss_ctx_instance *nss_ctx, - struct nss_cmn_msg *ncm, - void *app_data) -{ - struct nss_rmnet_rx_msg *nvim = (struct nss_rmnet_rx_msg *)ncm; - int32_t if_num; - - nss_rmnet_rx_msg_callback_t cb; - struct nss_rmnet_rx_handle *handle = NULL; - - /* - * Sanity check the message type - */ - if (ncm->type > NSS_RMNET_RX_MAX_MSG_TYPES) { - nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); - return; - } - - /* - * Messages value that are within the base class are handled by the base class. - */ - if (ncm->type < NSS_IF_MAX_MSG_TYPES) { - return nss_if_msg_handler(nss_ctx, ncm, app_data); - } - - if (!nss_rmnet_rx_verify_if_num(ncm->interface)) { - nss_warning("%px: response for another interface: %d", nss_ctx, ncm->interface); - return; - } - - if_num = NSS_RMNET_RX_GET_INDEX(ncm->interface); - - spin_lock_bh(&nss_rmnet_rx_lock); - if (!rmnet_rx_handle[if_num]) { - spin_unlock_bh(&nss_rmnet_rx_lock); - nss_warning("%px: rmnet_rx handle is NULL\n", nss_ctx); - return; - } - - handle = rmnet_rx_handle[if_num]; - spin_unlock_bh(&nss_rmnet_rx_lock); - - switch (nvim->cm.type) { - case NSS_RMNET_RX_STATS_SYNC_MSG: - nss_rmnet_rx_stats_sync(handle, &nvim->msg.stats, ncm->interface); - break; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Update the callback and app_data for NOTIFY messages, IPv4 sends all notify messages - * to the same callback/app_data. - * - * TODO: RMNet driver does not provide a registration for a notifier callback. - * Since dynamic interface are allocated on both cores and since the array for - * registered callback is not core specific, we call the Wi-Fi callback - * inappropriately. Disable the callback locally until we have per-core - * callback registrations. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)NULL; - ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].ndev; - } - - /* - * Do we have a callback? - */ - if (!ncm->cb) { - return; - } - - /* - * Callback - */ - cb = (nss_rmnet_rx_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, ncm); -} - -/* - * nss_rmnet_rx_callback - * Callback to handle the completion of NSS ->HLOS messages. - */ -static void nss_rmnet_rx_callback(void *app_data, struct nss_cmn_msg *ncm) -{ - struct nss_rmnet_rx_handle *handle = (struct nss_rmnet_rx_handle *)app_data; - struct nss_rmnet_rx_pvt *nvip = handle->pvt; - - if (ncm->response != NSS_CMN_RESPONSE_ACK) { - nss_warning("%px: rmnet_rx Error response %d\n", handle->nss_ctx, ncm->response); - nvip->response = NSS_TX_FAILURE; - complete(&nvip->complete); - return; - } - - nvip->response = NSS_TX_SUCCESS; - complete(&nvip->complete); -} - -/* - * nss_rmnet_rx_tx_msg_sync - * Send a message from HLOS to NSS synchronously. - */ -static nss_tx_status_t nss_rmnet_rx_tx_msg_sync(struct nss_rmnet_rx_handle *handle, - struct nss_rmnet_rx_msg *nvim) -{ - nss_tx_status_t status; - int ret = 0; - struct nss_rmnet_rx_pvt *nwip = handle->pvt; - struct nss_ctx_instance *nss_ctx = handle->nss_ctx; - - down(&nwip->sem); - - status = nss_rmnet_rx_tx_msg(nss_ctx, nvim); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: nss_rmnet_rx_msg failed\n", nss_ctx); - up(&nwip->sem); - return status; - } - - ret = wait_for_completion_timeout(&nwip->complete, - msecs_to_jiffies(NSS_RMNET_RX_TX_TIMEOUT)); - if (!ret) { - nss_warning("%px: rmnet_rx tx failed due to timeout\n", nss_ctx); - nwip->response = NSS_TX_FAILURE; - } - - status = nwip->response; - up(&nwip->sem); - - return status; -} - -/* - * nss_rmnet_rx_msg_init() - * Initialize virt specific message structure. - */ -static void nss_rmnet_rx_msg_init(struct nss_rmnet_rx_msg *nvim, - uint16_t if_num, - uint32_t type, - uint32_t len, - nss_rmnet_rx_msg_callback_t cb, - struct nss_rmnet_rx_handle *app_data) -{ - nss_cmn_msg_init(&nvim->cm, if_num, type, len, (void *)cb, (void *)app_data); -} - -/* - * nss_rmnet_rx_handle_destroy_sync() - * Destroy the virt handle either due to request from user or due to error, synchronously. - */ -static int nss_rmnet_rx_handle_destroy_sync(struct nss_rmnet_rx_handle *handle) -{ - nss_tx_status_t status; - int32_t if_num_n2h = handle->if_num_n2h; - int32_t if_num_h2n = handle->if_num_h2n; - int32_t index_n2h; - 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("%px: bad interface numbers %d %d\n", handle->nss_ctx, if_num_n2h, if_num_h2n); - return NSS_TX_FAILURE_BAD_PARAM; - } - - index_n2h = NSS_RMNET_RX_GET_INDEX(if_num_n2h); - index_h2n = NSS_RMNET_RX_GET_INDEX(if_num_h2n); - - status = nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_N2H); - if (status != NSS_TX_SUCCESS) { - 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("%px: Dynamic interface destroy failed status %d\n", handle->nss_ctx, status); - return status; - } - - spin_lock_bh(&nss_rmnet_rx_lock); - rmnet_rx_handle[index_n2h] = NULL; - rmnet_rx_handle[index_h2n] = NULL; - spin_unlock_bh(&nss_rmnet_rx_lock); - - kfree(handle->pvt); - kfree(handle); - - return status; -} - -/* - * nss_rmnet_rx_handle_create_sync() - * Initialize virt handle which holds the if_num and stats per interface. - */ -static struct nss_rmnet_rx_handle *nss_rmnet_rx_handle_create_sync(struct nss_ctx_instance *nss_ctx, int32_t if_num_n2h, int32_t if_num_h2n, int32_t *cmd_rsp) -{ - int32_t index_n2h; - int32_t index_h2n; - 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("%px: bad interface numbers %d %d\n", nss_ctx, if_num_n2h, if_num_h2n); - return NULL; - } - - index_n2h = NSS_RMNET_RX_GET_INDEX(if_num_n2h); - index_h2n = NSS_RMNET_RX_GET_INDEX(if_num_h2n); - - handle = (struct nss_rmnet_rx_handle *)kzalloc(sizeof(struct nss_rmnet_rx_handle), - GFP_KERNEL); - if (!handle) { - nss_warning("%px: handle memory alloc failed\n", nss_ctx); - *cmd_rsp = NSS_RMNET_RX_ALLOC_FAILURE; - goto error1; - } - - handle->nss_ctx = nss_ctx; - handle->if_num_n2h = if_num_n2h; - handle->if_num_h2n = if_num_h2n; - handle->pvt = (struct nss_rmnet_rx_pvt *)kzalloc(sizeof(struct nss_rmnet_rx_pvt), - GFP_KERNEL); - if (!handle->pvt) { - nss_warning("%px: failure allocating memory for nss_rmnet_rx_pvt\n", nss_ctx); - *cmd_rsp = NSS_RMNET_RX_ALLOC_FAILURE; - goto error2; - } - - handle->stats_n2h = (uint64_t *)kzalloc(sizeof(uint64_t) * NSS_RMNET_RX_STATS_MAX, - GFP_KERNEL); - if (!handle->stats_n2h) { - nss_warning("%px: failure allocating memory for N2H stats\n", nss_ctx); - *cmd_rsp = NSS_RMNET_RX_ALLOC_FAILURE; - goto error3; - } - - handle->stats_h2n = (uint64_t *)kzalloc(sizeof(uint64_t) * NSS_RMNET_RX_STATS_MAX, - GFP_KERNEL); - if (!handle->stats_h2n) { - nss_warning("%px: failure allocating memory for H2N stats\n", nss_ctx); - *cmd_rsp = NSS_RMNET_RX_ALLOC_FAILURE; - goto error4; - } - - handle->cb = NULL; - handle->app_data = NULL; - - spin_lock_bh(&nss_rmnet_rx_lock); - rmnet_rx_handle[index_n2h] = handle; - rmnet_rx_handle[index_h2n] = handle; - spin_unlock_bh(&nss_rmnet_rx_lock); - - *cmd_rsp = NSS_RMNET_RX_SUCCESS; - - return handle; - -error4: - kfree(handle->stats_n2h); -error3: - kfree(handle->pvt); -error2: - kfree(handle); -error1: - return NULL; -} - -/* - * nss_rmnet_rx_register_handler_sync() - * register msg handler for interface and initialize semaphore and completion. - */ -static uint32_t nss_rmnet_rx_register_handler_sync(struct nss_ctx_instance *nss_ctx, struct nss_rmnet_rx_handle *handle) -{ - uint32_t ret; - struct nss_rmnet_rx_pvt *nvip = NULL; - int32_t if_num_n2h = handle->if_num_n2h; - int32_t if_num_h2n = handle->if_num_h2n; - - ret = nss_core_register_handler(nss_ctx, if_num_n2h, nss_rmnet_rx_msg_handler, NULL); - if (ret != NSS_CORE_STATUS_SUCCESS) { - 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("%px: Failed to register message handler for redir_h2n interface %d\n", nss_ctx, if_num_h2n); - return NSS_RMNET_RX_REG_FAILURE; - } - - nvip = handle->pvt; - if (!nvip->sem_init_done) { - sema_init(&nvip->sem, 1); - init_completion(&nvip->complete); - nvip->sem_init_done = 1; - } - - nss_rmnet_rx_stats_dentry_create(); - return NSS_RMNET_RX_SUCCESS; -} - -/* - * nss_rmnet_rx_destroy_sync() - * Destroy the virt interface associated with the interface number, synchronously. - */ -nss_tx_status_t nss_rmnet_rx_destroy_sync(struct nss_rmnet_rx_handle *handle) -{ - nss_tx_status_t status; - struct net_device *dev; - int32_t if_num_n2h; - int32_t if_num_h2n; - struct nss_ctx_instance *nss_ctx; - uint32_t ret; - - if (!handle) { - nss_warning("handle is NULL\n"); - return NSS_TX_FAILURE_BAD_PARAM; - } - - if_num_n2h = handle->if_num_n2h; - if_num_h2n = handle->if_num_h2n; - 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_n2h].ndev || !nss_ctx->subsys_dp_register[if_num_h2n].ndev) { - spin_unlock_bh(&nss_top_main.lock); - 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; - } - - dev = nss_ctx->subsys_dp_register[if_num_n2h].ndev; - nss_assert(dev == nss_ctx->subsys_dp_register[if_num_h2n].ndev); - nss_core_unregister_subsys_dp(nss_ctx, if_num_n2h); - nss_core_unregister_subsys_dp(nss_ctx, if_num_h2n); - spin_unlock_bh(&nss_top_main.lock); - dev_put(dev); - - status = nss_rmnet_rx_handle_destroy_sync(handle); - if (status != NSS_TX_SUCCESS) { - 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("%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("%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; - } - - return status; -} -EXPORT_SYMBOL(nss_rmnet_rx_destroy_sync); - -/* - * nss_rmnet_rx_create_sync_nexthop() - * Create redir_n2h and redir_h2n interfaces, synchronously and associate it with same netdev. - */ -struct nss_rmnet_rx_handle *nss_rmnet_rx_create_sync_nexthop(struct net_device *netdev, uint32_t nexthop_n2h, uint32_t nexthop_h2n) -{ - struct nss_ctx_instance *nss_ctx = nss_rmnet_rx_get_context(); - struct nss_rmnet_rx_msg nvim; - struct nss_rmnet_rx_config_msg *nvcm; - uint32_t ret; - struct nss_rmnet_rx_handle *handle = NULL; - int32_t if_num_n2h, if_num_h2n; - - 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; - } - - if_num_n2h = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_N2H); - if (if_num_n2h < 0) { - 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("%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("%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; - } - - /* - * Initializes the semaphore and also sets the msg handler for if_num. - */ - ret = nss_rmnet_rx_register_handler_sync(nss_ctx, handle); - if (ret != NSS_RMNET_RX_SUCCESS) { - nss_warning("%px: Registration handler failed reason: %d\n", nss_ctx, ret); - goto error1; - } - - nss_rmnet_rx_msg_init(&nvim, handle->if_num_n2h, NSS_RMNET_RX_TX_CONFIG_MSG, - sizeof(struct nss_rmnet_rx_config_msg), nss_rmnet_rx_callback, handle); - - nvcm = &nvim.msg.if_config; - nvcm->flags = 0; - nvcm->sibling = if_num_h2n; - nvcm->nexthop = nexthop_n2h; - nvcm->no_channel = 0; - - ret = nss_rmnet_rx_tx_msg_sync(handle, &nvim); - if (ret != NSS_TX_SUCCESS) { - nss_warning("%px: nss_rmnet_rx_tx_msg_sync failed %u\n", nss_ctx, ret); - goto error2; - } - - nvim.cm.interface = if_num_h2n; - nvcm->sibling = if_num_n2h; - nvcm->nexthop = nexthop_h2n; - nvcm->no_channel = NSS_RMNET_RX_CHANNEL_MAX; - - ret = nss_rmnet_rx_tx_msg_sync(handle, &nvim); - if (ret != NSS_TX_SUCCESS) { - nss_warning("%px: nss_rmnet_rx_tx_msg_sync failed %u\n", nss_ctx, ret); - goto error2; - } - - nss_core_register_subsys_dp(nss_ctx, (uint32_t)if_num_n2h, NULL, NULL, NULL, netdev, 0); - nss_core_register_subsys_dp(nss_ctx, (uint32_t)if_num_h2n, NULL, NULL, NULL, netdev, 0); - - nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num_n2h, NSS_RMNET_RX_DP_N2H); - nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num_h2n, NSS_RMNET_RX_DP_H2N); - - /* - * Hold a reference to the net_device - */ - dev_hold(netdev); - - /* - * The context returned is the handle interface # which contains all the info related to - * the interface if_num. - */ - - return handle; - -error2: - nss_core_unregister_handler(nss_ctx, if_num_n2h); - nss_core_unregister_handler(nss_ctx, if_num_h2n); - -error1: - nss_rmnet_rx_handle_destroy_sync(handle); - return NULL; -} -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. - */ -nss_tx_status_t nss_rmnet_rx_tx_buf(struct nss_rmnet_rx_handle *handle, - struct sk_buff *skb) -{ - int32_t if_num = handle->if_num_h2n; - struct nss_ctx_instance *nss_ctx = handle->nss_ctx; - int cpu = 0; - - if (unlikely(nss_ctl_redirect == 0)) { - return NSS_TX_FAILURE_NOT_ENABLED; - } - - if (unlikely(skb->vlan_tci)) { - return NSS_TX_FAILURE_NOT_SUPPORTED; - } - - if (!nss_rmnet_rx_verify_if_num(if_num)) { - nss_warning("%px: bad interface number %d\n", nss_ctx, if_num); - return NSS_TX_FAILURE_BAD_PARAM; - } - - 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("%px: Rmnet 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_rmnet_rx_tx_buf); - -/* - * nss_rmnet_rx_tx_msg() - */ -nss_tx_status_t nss_rmnet_rx_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_rmnet_rx_msg *nvim) -{ - struct nss_cmn_msg *ncm = &nvim->cm; - - /* - * Sanity check the message - */ - if (!nss_rmnet_rx_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_RMNET_RX_MAX_MSG_TYPES) { - nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, nvim, sizeof(*nvim), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_rmnet_rx_tx_msg); - -/* - * nss_rmnet_rx_xmit_callback_unregister() - * Unregister interface xmit callback. - */ -void nss_rmnet_rx_xmit_callback_unregister(struct nss_rmnet_rx_handle *handle) -{ - struct nss_ctx_instance *nss_ctx; - struct nss_subsystem_dataplane_register *reg; - - if (!handle) { - nss_warning("handle is NULL\n"); - return; - } - - nss_ctx = handle->nss_ctx; - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (!nss_rmnet_rx_verify_if_num(handle->if_num_n2h)) { - nss_warning("if_num is invalid\n"); - return; - } - - reg = &nss_ctx->subsys_dp_register[handle->if_num_n2h]; - reg->xmit_cb = NULL; -} -EXPORT_SYMBOL(nss_rmnet_rx_xmit_callback_unregister); - -/* - * nss_rmnet_rx_xmit_callback_register() - * Register interface xmit callback. - */ -void nss_rmnet_rx_xmit_callback_register(struct nss_rmnet_rx_handle *handle, - nss_rmnet_rx_xmit_callback_t cb) -{ - struct nss_ctx_instance *nss_ctx; - struct nss_subsystem_dataplane_register *reg; - - if (!handle) { - nss_warning("handle is NULL\n"); - return; - } - - nss_ctx = handle->nss_ctx; - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (!nss_rmnet_rx_verify_if_num(handle->if_num_n2h)) { - nss_warning("if_num is invalid\n"); - return; - } - - reg = &nss_ctx->subsys_dp_register[handle->if_num_n2h]; - reg->xmit_cb = cb; -} -EXPORT_SYMBOL(nss_rmnet_rx_xmit_callback_register); - -/* - * nss_rmnet_rx_unregister() - */ -void nss_rmnet_rx_unregister(struct nss_rmnet_rx_handle *handle) -{ - struct nss_ctx_instance *nss_ctx; - int32_t if_num; - - if (!handle) { - nss_warning("handle is NULL\n"); - return; - } - - nss_ctx = handle->nss_ctx; - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (!nss_rmnet_rx_verify_if_num(handle->if_num_n2h)) { - nss_warning("if_num is invalid\n"); - return; - } - - if_num = handle->if_num_n2h; - - nss_core_unregister_subsys_dp(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_rmnet_rx_unregister); - -/* - * nss_rmnet_rx_register() - */ -void nss_rmnet_rx_register(struct nss_rmnet_rx_handle *handle, - nss_rmnet_rx_data_callback_t data_callback, - struct net_device *netdev) -{ - struct nss_ctx_instance *nss_ctx; - int32_t if_num; - - if (!handle) { - nss_warning("handle is NULL\n"); - return; - } - - nss_ctx = handle->nss_ctx; - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (!nss_rmnet_rx_verify_if_num(handle->if_num_n2h)) { - nss_warning("if_num is invalid\n"); - return; - } - - if_num = handle->if_num_n2h; - - nss_core_register_subsys_dp(nss_ctx, if_num, data_callback, NULL, NULL, netdev, (uint32_t)netdev->features); -} -EXPORT_SYMBOL(nss_rmnet_rx_register); - -/* - * nss_rmnet_rx_get_ifnum_with_core_id() - * Append core id to rmnet interface number - */ -int32_t nss_rmnet_rx_get_ifnum_with_core_id(int32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_rmnet_rx_get_context(); - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - if (nss_rmnet_rx_verify_if_num(if_num) == false) { - 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); -} -EXPORT_SYMBOL(nss_rmnet_rx_get_ifnum_with_core_id); - -/* - * nss_rmnet_rx_get_ifnum() - * Return rmnet interface number with core ID - */ -int32_t nss_rmnet_rx_get_ifnum(struct net_device *dev) -{ - int32_t ifnum = nss_cmn_get_interface_number_by_dev(dev); - return nss_rmnet_rx_get_ifnum_with_core_id(ifnum); -} -EXPORT_SYMBOL(nss_rmnet_rx_get_ifnum); - -/* - * nss_rmnet_rx_get_interface_num() - * Get interface number for an interface - */ -int32_t nss_rmnet_rx_get_interface_num(struct nss_rmnet_rx_handle *handle) -{ - if (!handle) { - nss_warning("rmnet_rx handle is NULL\n"); - return -1; - } - - /* - * Return if_num_n2h whose datapath type is 0. - */ - return handle->if_num_n2h; -} -EXPORT_SYMBOL(nss_rmnet_rx_get_interface_num); - -/* - * nss_rmnet_rx_get_context() - */ -struct nss_ctx_instance *nss_rmnet_rx_get_context(void) -{ - return &nss_top_main.nss[nss_top_main.rmnet_rx_handler_id]; -} -EXPORT_SYMBOL(nss_rmnet_rx_get_context); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_rmnet_rx_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_rmnet_rx_stats.c deleted file mode 100644 index efbcaffc0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_rmnet_rx_stats.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_rmnet_rx_stats.h" - -/* - * Data structure that holds the virtual interface context. - */ -extern struct nss_rmnet_rx_handle *rmnet_rx_handle[]; - -/* - * Spinlock to protect the global data structure virt_handle. - */ -extern spinlock_t nss_rmnet_rx_lock; - -/* - * nss_rmnet_rx_stats_str - * rmnet_rx interface stats strings - */ -struct nss_stats_info nss_rmnet_rx_stats_str[NSS_RMNET_RX_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_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}, - {"enqueue failed" , NSS_STATS_TYPE_DROP}, - {"no available channel" , NSS_STATS_TYPE_SPECIAL}, - {"linear pbuf count" , NSS_STATS_TYPE_SPECIAL}, - {"no pbuf to linear" , NSS_STATS_TYPE_SPECIAL}, - {"no enough room" , NSS_STATS_TYPE_SPECIAL}, - {"channel[0]" , NSS_STATS_TYPE_SPECIAL}, - {"channel[1]" , NSS_STATS_TYPE_SPECIAL}, - {"channel[2]" , NSS_STATS_TYPE_SPECIAL}, - {"channel[3]" , NSS_STATS_TYPE_SPECIAL}, - {"channel[4]" , NSS_STATS_TYPE_SPECIAL}, - {"channel[5]" , NSS_STATS_TYPE_SPECIAL}, - {"channel[6]" , NSS_STATS_TYPE_SPECIAL}, - {"channel[7]" , NSS_STATS_TYPE_SPECIAL}, - {"channel[8]" , NSS_STATS_TYPE_SPECIAL}, - {"channel[9]" , NSS_STATS_TYPE_SPECIAL}, - {"channel[10]" , NSS_STATS_TYPE_SPECIAL}, - {"channel[11]" , NSS_STATS_TYPE_SPECIAL}, - {"DMA full" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_rmnet_rx_stats_get() - * Get rmnet_rx interface stats by interface number. - */ -static bool nss_rmnet_rx_stats_get(struct nss_ctx_instance *nss_ctx, uint32_t if_num, uint64_t *stats, bool is_base) -{ - int i; - uint32_t if_num_curr = if_num; - uint64_t *stats_local; - - if_num = if_num - NSS_DYNAMIC_IF_START; - - spin_lock_bh(&nss_rmnet_rx_lock); - if (!rmnet_rx_handle[if_num]) { - spin_unlock_bh(&nss_rmnet_rx_lock); - return false; - } - - if (if_num_curr == rmnet_rx_handle[if_num]->if_num_n2h) { - stats_local = rmnet_rx_handle[if_num]->stats_n2h; - } else { - stats_local = rmnet_rx_handle[if_num]->stats_h2n; - } - - for (i = 0; i < NSS_RMNET_RX_STATS_MAX; i++) { - stats[i] = stats_local[i]; - } - spin_unlock_bh(&nss_rmnet_rx_lock); - - return true; -} - -/* - * nss_rmnet_rx_stats_read() - * Read rmnet_rx statistics - */ -static ssize_t nss_rmnet_rx_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 = nss_rmnet_rx_get_context(); - int32_t if_num = NSS_DYNAMIC_IF_START; - int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES; - uint32_t max_output_lines = ((NSS_RMNET_RX_STATS_MAX + 3) * NSS_MAX_DYNAMIC_INTERFACES) - + 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)) { - 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("%px: Could not allocate memory for local shadow buffer", data); - kfree(lbuf); - return 0; - } - - if (data) { - if_num = data->if_num; - } - - if (if_num > max_if_num) { - return 0; - } - - size_wr += nss_stats_banner(lbuf, size_wr, size_al, "rmnet_rx", NSS_STATS_SINGLE_CORE); - - /* - * Interface statistics for all interfaces. - */ - for (; if_num < max_if_num; if_num++) { - - if (!nss_rmnet_rx_stats_get(nss_ctx, if_num, stats_shadow, false)) { - 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); - } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(lbuf); - kfree(stats_shadow); - - return bytes_read; -} - -/* - * nss_rmnet_rx_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(rmnet_rx) - -/* - * nss_rmnet_rx_stats_dentry_create() - * Create rmnet_rx statistics debug entry. - */ -void nss_rmnet_rx_stats_dentry_create(void) -{ - nss_stats_create_dentry("rmnet_rx", &nss_rmnet_rx_stats_ops); -} - -/* - * nss_rmnet_rx_stats_sync() - * Sync stats from the NSS FW - */ -void nss_rmnet_rx_stats_sync(struct nss_rmnet_rx_handle *handle, - struct nss_rmnet_rx_stats *nwis, uint32_t if_num) -{ - int i; - uint64_t *stats; - spin_lock_bh(&nss_rmnet_rx_lock); - if (if_num == handle->if_num_n2h) { - stats = handle->stats_n2h; - } else { - stats = handle->stats_h2n; - } - - stats[NSS_RMNET_RX_STATS_RX_PKTS] += nwis->node_stats.rx_packets; - stats[NSS_RMNET_RX_STATS_RX_BYTES] += nwis->node_stats.rx_bytes; - stats[NSS_RMNET_RX_STATS_TX_PKTS] += nwis->node_stats.tx_packets; - stats[NSS_RMNET_RX_STATS_TX_BYTES] += nwis->node_stats.tx_bytes; - - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - stats[NSS_RMNET_RX_STATS_QUEUE_0_DROPPED + i] += nwis->node_stats.rx_dropped[i]; - } - - stats[NSS_RMNET_RX_STATS_ENQUEUE_FAILED] += nwis->enqueue_failed; - stats[NSS_RMNET_RX_STATS_NO_AVAIL_CHANNEL] += nwis->no_avail_channel; - stats[NSS_RMNET_RX_STATS_NUM_LINEAR_PBUF] += nwis->num_linear_pbuf; - stats[NSS_RMNET_RX_STATS_NO_PBUF_TO_LINEAR] += nwis->no_pbuf_to_linear; - stats[NSS_RMNET_RX_STATS_NO_ENOUGH_ROOM] += nwis->no_enough_room; - - for (i = 0; i < NSS_RMNET_RX_CHANNEL_MAX; i++) { - stats[NSS_RMNET_RX_STATS_USING_CHANNEL0 + i] += nwis->using_channel[i]; - } - - stats[NSS_RMNET_RX_STATS_DMA_FAILED] += nwis->dma_failed; - spin_unlock_bh(&nss_rmnet_rx_lock); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_rmnet_rx_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_rmnet_rx_stats.h deleted file mode 100644 index 638593a6c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_rmnet_rx_stats.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - ****************************************************************************** - * 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. - * - * 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_RMNET_RX_STATS_H -#define __NSS_RMNET_RX_STATS_H - -/* - * rmnet_rx interface statistics types. - */ -enum nss_rmnet_rx_stats_types { - NSS_RMNET_RX_STATS_RX_PKTS, - NSS_RMNET_RX_STATS_RX_BYTES, - NSS_RMNET_RX_STATS_TX_PKTS, - NSS_RMNET_RX_STATS_TX_BYTES, - NSS_RMNET_RX_STATS_QUEUE_0_DROPPED, - NSS_RMNET_RX_STATS_QUEUE_1_DROPPED, - NSS_RMNET_RX_STATS_QUEUE_2_DROPPED, - NSS_RMNET_RX_STATS_QUEUE_3_DROPPED, - NSS_RMNET_RX_STATS_ENQUEUE_FAILED, - NSS_RMNET_RX_STATS_NO_AVAIL_CHANNEL, - NSS_RMNET_RX_STATS_NUM_LINEAR_PBUF, - NSS_RMNET_RX_STATS_NO_PBUF_TO_LINEAR, - NSS_RMNET_RX_STATS_NO_ENOUGH_ROOM, - NSS_RMNET_RX_STATS_USING_CHANNEL0, - NSS_RMNET_RX_STATS_USING_CHANNEL1, - NSS_RMNET_RX_STATS_USING_CHANNEL2, - NSS_RMNET_RX_STATS_USING_CHANNEL3, - NSS_RMNET_RX_STATS_USING_CHANNEL4, - NSS_RMNET_RX_STATS_USING_CHANNEL5, - NSS_RMNET_RX_STATS_USING_CHANNEL6, - NSS_RMNET_RX_STATS_USING_CHANNEL7, - NSS_RMNET_RX_STATS_USING_CHANNEL8, - NSS_RMNET_RX_STATS_USING_CHANNEL9, - NSS_RMNET_RX_STATS_USING_CHANNEL10, - NSS_RMNET_RX_STATS_USING_CHANNEL11, - NSS_RMNET_RX_STATS_DMA_FAILED, - NSS_RMNET_RX_STATS_MAX, -}; - -/* - * Virtual interface statistics APIs - */ -extern void nss_rmnet_rx_stats_sync(struct nss_rmnet_rx_handle *handle, struct nss_rmnet_rx_stats *nwis, uint32_t if_num); -extern void nss_rmnet_rx_stats_dentry_create(void); - -#endif /* __NSS_RMNET_RX_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_rps.c b/feeds/ipq807x/qca-nss-drv/src/nss_rps.c deleted file mode 100644 index c2a603f2d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_rps.c +++ /dev/null @@ -1,644 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2013-2017, 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. - * 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_rps.c - * NSS RPS based APIs - */ - -#include "nss_tx_rx_common.h" - -#define NSS_RPS_MAX_CORE_HASH_BITMAP ((1 << (NSS_HOST_CORES)) - 1) - /**< Maximum value that when all cores are available. */ -#define NSS_RPS_PRI_MAP_PARAM_FIELD_COUNT 2 - -int nss_rps_config __read_mostly; -int nss_rps_hash_bitmap = NSS_RPS_MAX_CORE_HASH_BITMAP; -int nss_rps_pri_map[NSS_MAX_NUM_PRI]; - -/* - * It is used to parse priority and core from the input. - */ -struct nss_rps_pri_map_parse_data { - uint8_t pri; /**< Priority Index. */ - int8_t core; /**< Host core-id. */ -}; - -/* - * Private data structure. - */ -struct nss_rps_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_rps_pvt nss_rps_cfg_pvt; - -/* - * nss_rps_pri_map_usage() - * Help function shows the usage of the command. - */ -static inline void nss_rps_pri_map_usage(void) -{ - nss_info_always("\nUsage:\n"); - nss_info_always("echo > /proc/sys/dev/nss/rps/pri_map\n\n"); - nss_info_always("priority[0 to %u] core[-1 to %u]:\n\n", - NSS_MAX_NUM_PRI - 1, - NSS_HOST_CORES - 1); -} - -/* - * nss_rps_pri_map_print() - * Sysctl handler for printing rps/pri mapping. - */ -static int nss_rps_pri_map_print(struct ctl_table *ctl, void __user *buffer, - size_t *lenp, loff_t *ppos, int *pri_map) -{ - char *r_buf; - int i, len; - size_t cp_bytes = 0; - - /* - * (2 * 4) + 12 bytes for the buffer size is sufficient to write - * the table including the spaces and new line characters. - */ - r_buf = kzalloc(((4 * NSS_MAX_NUM_PRI) + 12) * sizeof(char), - GFP_KERNEL); - if (!r_buf) { - nss_warning("Failed to alloc buffer to print pri map\n"); - return -EFAULT; - } - - /* - * Write the core values that corresponds to each priorities. - */ - len = scnprintf(r_buf + cp_bytes, 8, "Cores: "); - cp_bytes += len; - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - len = scnprintf(r_buf + cp_bytes, 4, "%d ", pri_map[i]); - if (!len) { - nss_warning("failed to read from buffer %d\n", pri_map[i]); - kfree(r_buf); - return -EFAULT; - } - cp_bytes += len; - } - - /* - * Add new line character at the end. - */ - len = scnprintf(r_buf + cp_bytes, 4, "\n"); - cp_bytes += len; - - cp_bytes = simple_read_from_buffer(buffer, *lenp, ppos, r_buf, cp_bytes); - *lenp = cp_bytes; - kfree(r_buf); - return 0; -} - -/* - * nss_rps_pri_map_parse() - * Sysctl handler for rps/pri mappings. - */ -static int nss_rps_pri_map_parse(struct ctl_table *ctl, void __user *buffer, - size_t *lenp, loff_t *ppos, struct nss_rps_pri_map_parse_data *out) -{ - size_t cp_bytes = 0; - char w_buf[5]; - loff_t w_offset = 0; - char *str; - unsigned int pri; - int core, res; - - /* - * Buffer length cannot be different than 4 or 5. - */ - if (*lenp < 4 || *lenp > 5) { - nss_warning("Buffer is not correct. Invalid lenght: %d\n", (int)*lenp); - return -EINVAL; - } - - /* - * It's a write operation - */ - cp_bytes = simple_write_to_buffer(w_buf, *lenp, &w_offset, buffer, 5); - if (cp_bytes != *lenp) { - nss_warning("failed to write to buffer\n"); - return -EFAULT; - } - - str = w_buf; - res = sscanf(str, "%u %d", &pri, &core); - if (res != NSS_RPS_PRI_MAP_PARAM_FIELD_COUNT) { - nss_warning("failed to read the buffer\n"); - return -EFAULT; - } - /* - * pri value cannot be higher than NSS_MAX_NUM_PRI. - */ - if (pri >= NSS_MAX_NUM_PRI) { - nss_warning("invalid pri value: %d\n", pri); - return -EINVAL; - } - - /* - * Host core must be less than NSS_HOST_CORE. - */ - if (core >= NSS_HOST_CORES || core < NSS_N2H_RPS_PRI_DEFAULT) { - nss_warning("invalid priority value: %d\n", core); - return -EINVAL; - } - - nss_info("priority: %d core: %d\n", pri, core); - - out->pri = pri; - out->core = core; - return 0; -} - -/* - * nss_rps_cfg_callback() - * Callback function for rps configuration. - */ -static void nss_rps_cfg_callback(void *app_data, struct nss_n2h_msg *nnm) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)app_data; - if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) { - - /* - * Error, hence we are not updating the nss_rps - * Send a FAILURE to restore the current value - * to its previous state. - */ - nss_rps_cfg_pvt.response = NSS_FAILURE; - complete(&nss_rps_cfg_pvt.complete); - nss_warning("%px: RPS configuration failed : %d\n", nss_ctx, - nnm->cm.error); - return; - } - - 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; - complete(&nss_rps_cfg_pvt.complete); -} - -/* - * nss_rps_pri_map_cfg_callback() - * Callback function for rps pri map configuration. - */ -static void nss_rps_pri_map_cfg_callback(void *app_data, struct nss_n2h_msg *nnm) -{ - if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) { - - /* - * Error, hence we are not updating the nss_pri_map - * Send a failure to restore the current value - * to its previous state. - */ - nss_rps_cfg_pvt.response = NSS_FAILURE; - complete(&nss_rps_cfg_pvt.complete); - nss_warning("%px: RPS pri_map configuration failed : %d\n", - app_data, nnm->cm.error); - return; - } - - nss_info("%px: RPS pri_map configuration succeeded: %d\n", - app_data, nnm->cm.error); - - nss_rps_cfg_pvt.response = NSS_SUCCESS; - complete(&nss_rps_cfg_pvt.complete); -} - -/* - * nss_rps_cfg() - * Send Message to NSS to enable RPS. - */ -static nss_tx_status_t nss_rps_cfg(struct nss_ctx_instance *nss_ctx, int enable_rps) -{ - struct nss_n2h_msg nnm; - nss_tx_status_t nss_tx_status; - int ret; - - down(&nss_rps_cfg_pvt.sem); - nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_RPS_CFG, - sizeof(struct nss_n2h_rps), - nss_rps_cfg_callback, - (void *)nss_ctx); - - nnm.msg.rps_cfg.enable = enable_rps; - - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); - - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: nss_tx error setting rps\n", nss_ctx); - - up(&nss_rps_cfg_pvt.sem); - return NSS_FAILURE; - } - - /* - * Blocking call, wait till we get ACK for this msg. - */ - ret = wait_for_completion_timeout(&nss_rps_cfg_pvt.complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); - if (ret == 0) { - nss_warning("%px: Waiting for ack timed out\n", nss_ctx); - up(&nss_rps_cfg_pvt.sem); - return NSS_FAILURE; - } - - /* - * ACK/NACK received from NSS FW - * If NACK: Handler function will restore nss_rps_config - * to previous state. - */ - if (NSS_FAILURE == nss_rps_cfg_pvt.response) { - up(&nss_rps_cfg_pvt.sem); - return NSS_FAILURE; - } - - up(&nss_rps_cfg_pvt.sem); - return NSS_SUCCESS; -} - -/* - * nss_rps_ipv4_hash_bitmap_cfg() - * Send Message to NSS to configure hash_bitmap. - */ -static nss_tx_status_t nss_rps_ipv4_hash_bitmap_cfg(struct nss_ctx_instance *nss_ctx, int hash_bitmap) -{ - struct nss_ipv4_msg nim; - nss_tx_status_t nss_tx_status; - - down(&nss_rps_cfg_pvt.sem); - nss_ipv4_msg_init(&nim, NSS_IPV4_RX_INTERFACE, NSS_IPV4_TX_RPS_HASH_BITMAP_CFG_MSG, - sizeof(struct nss_ipv4_rps_hash_bitmap_cfg_msg), - NULL, NULL); - - nim.msg.rps_hash_bitmap.hash_bitmap = hash_bitmap; - - nss_tx_status = nss_ipv4_tx_sync(nss_ctx, &nim); - - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: nss_tx error setting rps\n", nss_ctx); - - up(&nss_rps_cfg_pvt.sem); - return NSS_FAILURE; - } - - up(&nss_rps_cfg_pvt.sem); - return NSS_SUCCESS; -} - -#ifdef NSS_DRV_IPV6_ENABLE -/* - * nss_rps_ipv6_hash_bitmap_cfg() - * Send Message to NSS to configure hash_bitmap. - */ -static nss_tx_status_t nss_rps_ipv6_hash_bitmap_cfg(struct nss_ctx_instance *nss_ctx, int hash_bitmap) -{ - struct nss_ipv6_msg nim; - nss_tx_status_t nss_tx_status; - - down(&nss_rps_cfg_pvt.sem); - nss_ipv6_msg_init(&nim, NSS_IPV6_RX_INTERFACE, NSS_IPV6_TX_RPS_HASH_BITMAP_CFG_MSG, - sizeof(struct nss_ipv4_rps_hash_bitmap_cfg_msg), - NULL, NULL); - - nim.msg.rps_hash_bitmap.hash_bitmap = hash_bitmap; - - nss_tx_status = nss_ipv6_tx_sync(nss_ctx, &nim); - - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: nss_tx error setting rps\n", nss_ctx); - - up(&nss_rps_cfg_pvt.sem); - return NSS_FAILURE; - } - - up(&nss_rps_cfg_pvt.sem); - return NSS_SUCCESS; -} -#endif - -/* - * nss_rps_pri_map_cfg() - * Send Message to NSS to configure pri_map. - */ -static nss_tx_status_t nss_rps_pri_map_cfg(struct nss_ctx_instance *nss_ctx, int *pri_map) -{ - struct nss_n2h_msg nnm; - struct nss_n2h_rps_pri_map *rps_pri_map; - nss_tx_status_t nss_tx_status; - int ret, i; - - down(&nss_rps_cfg_pvt.sem); - nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, NSS_TX_METADATA_TYPE_N2H_RPS_PRI_MAP_CFG, - sizeof(struct nss_n2h_rps_pri_map), - nss_rps_pri_map_cfg_callback, - (void *)nss_ctx); - - rps_pri_map = &nnm.msg.rps_pri_map; - - /* - * Fill entries at pri_map. - */ - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - rps_pri_map->pri_map[i] = pri_map[i]; - } - - nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); - - if (nss_tx_status != NSS_TX_SUCCESS) { - nss_warning("%px: nss_tx error setting rps\n", nss_ctx); - - up(&nss_rps_cfg_pvt.sem); - return NSS_FAILURE; - } - - /* - * Blocking call, wait till we get ACK for this msg. - */ - ret = wait_for_completion_timeout(&nss_rps_cfg_pvt.complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); - if (ret == 0) { - nss_warning("%px: Waiting for ack timed out\n", nss_ctx); - up(&nss_rps_cfg_pvt.sem); - return NSS_FAILURE; - } - - /* - * ACK/NACK received from NSS FW - * If NACK: Handler function will restore nss_rps_config - * to previous state. - */ - if (NSS_FAILURE == nss_rps_cfg_pvt.response) { - up(&nss_rps_cfg_pvt.sem); - return NSS_FAILURE; - } - - up(&nss_rps_cfg_pvt.sem); - return NSS_SUCCESS; -} - -/* - * nss_rps_cfg_handler() - * Enable NSS RPS. - */ -static int nss_rps_cfg_handler(struct ctl_table *ctl, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx; - int ret, ret_rps, current_state, i; - current_state = nss_rps_config; - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - - if (ret != NSS_SUCCESS) { - return ret; - } - - if (!write) { - return ret; - } - - if (nss_rps_config == 0) { - nss_info_always("Runtime disabling of NSS RPS not supported\n"); - return ret; - } - - if (nss_rps_config != 1) { - nss_info_always("Invalid input value. Valid values are 0 and 1\n"); - return ret; - } - - for (i = 0; i < nss_top_main.num_nss; i++) { - nss_ctx = &nss_top->nss[i]; - nss_info("Enabling NSS RPS\n"); - ret_rps = nss_rps_cfg(nss_ctx, 1); - - /* - * In here, we also need to revert the state of the previously enabled cores. - * However, runtime disabling is currently not supported since queues are not - * flushed in NSS FW. - * TODO: Flush queues in NSS FW. - */ - if (ret_rps != NSS_SUCCESS) { - nss_warning("%px: rps enabling failed\n", nss_ctx); - nss_rps_config = current_state; - return ret_rps; - } - } - return NSS_SUCCESS; -} - -/* - * nss_rps_hash_bitmap_cfg_handler() - * Configure NSS rps_hash_bitmap - */ -static int nss_rps_hash_bitmap_cfg_handler(struct ctl_table *ctl, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; - int ret, ret_ipv4, current_state; - - current_state = nss_rps_hash_bitmap; - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - - if (ret != NSS_SUCCESS) { - nss_rps_hash_bitmap = current_state; - return ret; - } - - if (!write) { - return ret; - } - - if (nss_rps_hash_bitmap <= (NSS_RPS_MAX_CORE_HASH_BITMAP)) { - nss_info("Configuring NSS RPS hash_bitmap\n"); - 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; - } - -#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; - } - } -#endif - return 0; - } - - nss_info_always("Invalid input value. Valid values are less than %d\n", (NSS_RPS_MAX_CORE_HASH_BITMAP)); - return ret; -} - -/* nss_rps_pri_map_cfg_handler() - * Configure NSS rps_pri_map - */ -static int nss_rps_pri_map_cfg_handler(struct ctl_table *ctl, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; - - int ret, ret_pri_map; - struct nss_rps_pri_map_parse_data out, current_state; - if (!write) { - return nss_rps_pri_map_print(ctl, buffer, lenp, ppos, nss_rps_pri_map); - } - - ret = nss_rps_pri_map_parse(ctl, buffer, lenp, ppos, &out); - - if (ret != NSS_SUCCESS) { - nss_rps_pri_map_usage(); - return ret; - } - - nss_info("Configuring NSS RPS Priority Map\n"); - current_state.pri = out.pri; - current_state.core = nss_rps_pri_map[out.pri]; - nss_rps_pri_map[out.pri] = out.core; - 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("%px: pri_map config message failed\n", nss_ctx); - } - - return ret_pri_map; -} - -static struct ctl_table nss_rps_table[] = { - { - .procname = "enable", - .data = &nss_rps_config, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_rps_cfg_handler, - }, - { - .procname = "hash_bitmap", - .data = &nss_rps_hash_bitmap, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_rps_hash_bitmap_cfg_handler, - }, - { - .procname = "pri_map", - .data = &nss_rps_pri_map[NSS_MAX_NUM_PRI], - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_rps_pri_map_cfg_handler, - }, - { } -}; - -static struct ctl_table nss_rps_dir[] = { - { - .procname = "rps", - .mode = 0555, - .child = nss_rps_table, - }, - { } -}; - -static struct ctl_table nss_rps_root_dir[] = { - { - .procname = "nss", - .mode = 0555, - .child = nss_rps_dir, - }, - { } -}; - -static struct ctl_table nss_rps_root[] = { - { - .procname = "dev", - .mode = 0555, - .child = nss_rps_root_dir, - }, - { } -}; - -static struct ctl_table_header *nss_rps_header; - -/* - * nss_rps_pri_map_init_handler() - * Initialize pri_map for priority based rps selection. - */ -void nss_rps_pri_map_init_handler(void) -{ - int i; - - /* - Initialize the mapping table with the default values. - */ - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - nss_rps_pri_map[i] = NSS_N2H_RPS_PRI_DEFAULT; - } - -} - -/* - * nss_rps_register_sysctl() - */ -void nss_rps_register_sysctl(void) -{ - - /* - * rps sema init. - */ - sema_init(&nss_rps_cfg_pvt.sem, 1); - init_completion(&nss_rps_cfg_pvt.complete); - - nss_rps_pri_map_init_handler(); - - /* - * Register sysctl table. - */ - nss_rps_header = register_sysctl_table(nss_rps_root); -} - -/* - * nss_rps_unregister_sysctl() - * Unregister sysctl specific to rps - */ -void nss_rps_unregister_sysctl(void) -{ - /* - * Unregister sysctl table. - */ - if (nss_rps_header) { - unregister_sysctl_table(nss_rps_header); - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_shaper.c b/feeds/ipq807x/qca-nss-drv/src/nss_shaper.c deleted file mode 100644 index 2726b8ba5..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_shaper.c +++ /dev/null @@ -1,367 +0,0 @@ -/* - ************************************************************************** - * 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_tx_rx_common.h" - -/* - * nss_shaper_register_shaping() - * Register to obtain an NSS context for basic shaping operations - */ -void *nss_shaper_register_shaping(void) -{ - if (nss_top_main.shaping_handler_id == (uint8_t)-1) { - nss_warning("%px: SHAPING IS NOT ENABLED", __func__); - return NULL; - } - return (void *)&nss_top_main.nss[nss_top_main.shaping_handler_id]; -} - -/* - * nss_shaper_unregister_shaping() - * Unregister an NSS shaping context - */ -void nss_shaper_unregister_shaping(void *nss_ctx) -{ -} - -/* - * nss_shaper_register_shaper_bounce_interface() - * Register for performing shaper bounce operations for interface shaper - */ -void *nss_shaper_register_shaper_bounce_interface(uint32_t if_num, nss_shaper_bounced_callback_t cb, void *app_data, struct module *owner) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_shaper_bounce_registrant *reg; - - nss_info("Shaper bounce interface register: %u, cb: %px, app_data: %px, owner: %px", - if_num, cb, app_data, owner); - - /* - * Must be valid interface number - */ - if (if_num >= NSS_MAX_NET_INTERFACES) { - nss_warning("Invalid if_num: %u", if_num); - BUG_ON(false); - } - - /* - * Shaping enabled? - */ - if (nss_top_main.shaping_handler_id == (uint8_t)-1) { - nss_warning("%px: SHAPING IS NOT ENABLED", __func__); - return NULL; - } - - /* - * Can we hold the module? - */ - if (!try_module_get(owner)) { - nss_warning("%px: Unable to hold owner", __func__); - return NULL; - } - - spin_lock_bh(&nss_top->lock); - - /* - * Must not have existing registrant - */ - reg = &nss_top->bounce_interface_registrants[if_num]; - if (reg->registered) { - spin_unlock_bh(&nss_top->stats_lock); - module_put(owner); - nss_warning("Already registered: %u", if_num); - BUG_ON(false); - } - - /* - * Register - */ - reg->bounced_callback = cb; - reg->app_data = app_data; - reg->owner = owner; - reg->registered = true; - spin_unlock_bh(&nss_top->lock); - - return (void *)&nss_top->nss[nss_top->shaping_handler_id]; -} - -/* - * nss_shaper_unregister_shaper_bounce_interface() - * Unregister for shaper bounce operations for interface shaper - */ -void nss_shaper_unregister_shaper_bounce_interface(uint32_t if_num) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_shaper_bounce_registrant *reg; - struct module *owner; - - nss_info("Shaper bounce interface unregister: %u", if_num); - - /* - * Must be valid interface number - */ - if (if_num >= NSS_MAX_NET_INTERFACES) { - nss_warning("Invalid if_num: %u", if_num); - BUG_ON(false); - } - - spin_lock_bh(&nss_top->lock); - - /* - * Must have existing registrant - */ - reg = &nss_top->bounce_interface_registrants[if_num]; - if (!reg->registered) { - spin_unlock_bh(&nss_top->stats_lock); - nss_warning("Already unregistered: %u", if_num); - BUG_ON(false); - } - - /* - * Unegister - */ - owner = reg->owner; - reg->owner = NULL; - reg->registered = false; - spin_unlock_bh(&nss_top->lock); - - module_put(owner); -} - -/* - * nss_shaper_register_shaper_bounce_bridge() - * Register for performing shaper bounce operations for bridge shaper - */ -void *nss_shaper_register_shaper_bounce_bridge(uint32_t if_num, nss_shaper_bounced_callback_t cb, void *app_data, struct module *owner) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_ctx_instance *nss_ctx; - struct nss_shaper_bounce_registrant *reg; - - nss_info("Shaper bounce bridge register: %u, cb: %px, app_data: %px, owner: %px", - if_num, cb, app_data, owner); - - /* - * Must be valid interface number - */ - if (if_num >= NSS_MAX_NET_INTERFACES) { - nss_warning("Invalid if_num: %u", if_num); - BUG_ON(false); - } - - /* - * Shaping enabled? - */ - if (nss_top_main.shaping_handler_id == (uint8_t)-1) { - nss_warning("%px: SHAPING IS NOT ENABLED", __func__); - return NULL; - } - - /* - * Can we hold the module? - */ - if (!try_module_get(owner)) { - nss_warning("%px: Unable to hold owner", __func__); - return NULL; - } - - spin_lock_bh(&nss_top->lock); - - /* - * Must not have existing registrant - */ - reg = &nss_top->bounce_bridge_registrants[if_num]; - if (reg->registered) { - spin_unlock_bh(&nss_top->stats_lock); - module_put(owner); - nss_warning("Already registered: %u", if_num); - BUG_ON(false); - } - - /* - * Register - */ - reg->bounced_callback = cb; - reg->app_data = app_data; - reg->owner = owner; - reg->registered = true; - spin_unlock_bh(&nss_top->lock); - - nss_ctx = &nss_top->nss[nss_top->shaping_handler_id]; - return (void *)nss_ctx; -} - -/* - * nss_shaper_unregister_shaper_bounce_bridge() - * Unregister for shaper bounce operations for bridge shaper - */ -void nss_shaper_unregister_shaper_bounce_bridge(uint32_t if_num) -{ - struct nss_top_instance *nss_top = &nss_top_main; - struct nss_shaper_bounce_registrant *reg; - struct module *owner; - - nss_info("Shaper bounce bridge unregister: %u", if_num); - - /* - * Must be valid interface number - */ - if (if_num >= NSS_MAX_NET_INTERFACES) { - nss_warning("Invalid if_num: %u", if_num); - BUG_ON(false); - } - - spin_lock_bh(&nss_top->lock); - - /* - * Must have existing registrant - */ - reg = &nss_top->bounce_bridge_registrants[if_num]; - if (!reg->registered) { - spin_unlock_bh(&nss_top->stats_lock); - nss_warning("Already unregistered: %u", if_num); - BUG_ON(false); - } - - /* - * Wait until any bounce callback that is active is finished - */ - while (reg->callback_active) { - spin_unlock_bh(&nss_top->stats_lock); - yield(); - spin_lock_bh(&nss_top->stats_lock); - } - - /* - * Unegister - */ - owner = reg->owner; - reg->owner = NULL; - reg->registered = false; - spin_unlock_bh(&nss_top->lock); - - module_put(owner); -} - -/* - * nss_shaper_bounce_interface_packet() - * Bounce a packet to the NSS for interface shaping. - * - * You must have registered for interface bounce shaping to call this. - */ -nss_tx_status_t nss_shaper_bounce_interface_packet(void *ctx, uint32_t if_num, struct sk_buff *skb) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)ctx; - struct nss_top_instance *nss_top = nss_ctx->nss_top; - struct nss_shaper_bounce_registrant *reg; - int32_t status; - - /* - * Must be valid interface number - */ - if (if_num >= NSS_MAX_NET_INTERFACES) { - nss_warning("Invalid if_num: %u", if_num); - BUG_ON(false); - } - - /* - * Must have existing registrant - */ - spin_lock_bh(&nss_top->lock); - reg = &nss_top->bounce_interface_registrants[if_num]; - if (!reg->registered) { - spin_unlock_bh(&nss_top->stats_lock); - nss_warning("unregistered: %u", if_num); - return NSS_TX_FAILURE; - } - spin_unlock_bh(&nss_top->lock); - - status = nss_core_send_buffer(nss_ctx, if_num, skb, NSS_IF_H2N_DATA_QUEUE, - H2N_BUFFER_SHAPER_BOUNCE_INTERFACE, 0); - if (status != NSS_CORE_STATUS_SUCCESS) { - return NSS_TX_FAILURE; - } - nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); - - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_PACKET]); - return NSS_TX_SUCCESS; -} - -/* - * nss_shaper_bounce_bridge_packet() - * Bounce a packet to the NSS for bridge shaping. - * - * You must have registered for bridge bounce shaping to call this. - */ -nss_tx_status_t nss_shaper_bounce_bridge_packet(void *ctx, uint32_t if_num, struct sk_buff *skb) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)ctx; - struct nss_top_instance *nss_top = nss_ctx->nss_top; - struct nss_shaper_bounce_registrant *reg; - int32_t status; - - /* - * Must be valid interface number - */ - if (if_num >= NSS_MAX_NET_INTERFACES) { - nss_warning("Invalid if_num: %u", if_num); - BUG_ON(false); - } - - /* - * Must have existing registrant - */ - spin_lock_bh(&nss_top->lock); - reg = &nss_top->bounce_bridge_registrants[if_num]; - if (!reg->registered) { - spin_unlock_bh(&nss_top->stats_lock); - nss_warning("unregistered: %u", if_num); - return NSS_TX_FAILURE; - } - spin_unlock_bh(&nss_top->lock); - - 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) { - nss_info("%s: Bridge bounce core send rejected", __func__); - return NSS_TX_FAILURE; - } - nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); - - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_PACKET]); - return NSS_TX_SUCCESS; -} - -/* - * nss_shaper_get_device() - * Gets the original device from probe. - */ -struct device *nss_shaper_get_dev(void) -{ - struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[nss_top_main.shaping_handler_id]; - return nss_ctx->dev; -} - -EXPORT_SYMBOL(nss_shaper_bounce_bridge_packet); -EXPORT_SYMBOL(nss_shaper_bounce_interface_packet); -EXPORT_SYMBOL(nss_shaper_unregister_shaper_bounce_interface); -EXPORT_SYMBOL(nss_shaper_register_shaper_bounce_interface); -EXPORT_SYMBOL(nss_shaper_unregister_shaper_bounce_bridge); -EXPORT_SYMBOL(nss_shaper_register_shaper_bounce_bridge); -EXPORT_SYMBOL(nss_shaper_register_shaping); -EXPORT_SYMBOL(nss_shaper_unregister_shaping); -EXPORT_SYMBOL(nss_shaper_get_dev); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_sjack.c b/feeds/ipq807x/qca-nss-drv/src/nss_sjack.c deleted file mode 100644 index 086eedfea..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_sjack.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_sjack_stats.h" -#include "nss_sjack_log.h" - -/* - * nss_sjack_handler() - * Handle NSS -> HLOS messages for sjack - */ -static void nss_sjack_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, - __attribute__((unused))void *app_data) -{ - void *ctx; - nss_sjack_msg_callback_t cb; - struct nss_sjack_msg *nsm = (struct nss_sjack_msg *)ncm; - - BUG_ON(ncm->interface != NSS_SJACK_INTERFACE); - - /* - * Trace Messages - */ - nss_sjack_log_rx_msg(nsm); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_SJACK_MAX_MSG_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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Update the callback and app_data for NOTIFY messages, sjack 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); - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - switch (ncm->type) { - case NSS_SJACK_STATS_SYNC_MSG: - /* - * Update sjack statistics on node sync. - */ - nss_sjack_stats_node_sync(nss_ctx, &nsm->msg.stats_sync); - break; - } - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_sjack_msg_callback_t)ncm->cb; - ctx = nss_ctx->subsys_dp_register[ncm->interface].ndev; - - cb(ctx, ncm); -} - -/* - * nss_sjack_tx_msg() - * Transmit a sjack message to NSSFW - */ -nss_tx_status_t nss_sjack_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_sjack_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace Messages - */ - nss_sjack_log_tx_msg(msg); - - /* - * Sanity check the message - */ - if (ncm->interface != NSS_SJACK_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("%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_sjack_register_if() - */ -struct nss_ctx_instance *nss_sjack_register_if(uint32_t if_num, struct net_device *netdev, - 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); - - 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; -} - -/* - * nss_sjack_unregister_if() - */ -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); - - 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; -} - -/* - * nss_sjack_get_context() - * get NSS context instance for sjack - */ -struct nss_ctx_instance *nss_sjack_get_context(void) -{ - return &nss_top_main.nss[nss_top_main.sjack_handler_id]; -} -EXPORT_SYMBOL(nss_sjack_get_context); - -/* - * nss_sjack_register_handler() - * Registering handler for sending msg to sjack node on NSS. - */ -void nss_sjack_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_sjack_get_context(); - - nss_core_register_handler(nss_ctx, NSS_SJACK_INTERFACE, nss_sjack_handler, NULL); - - nss_sjack_stats_dentry_create(); -} - -EXPORT_SYMBOL(nss_sjack_register_if); -EXPORT_SYMBOL(nss_sjack_unregister_if); -EXPORT_SYMBOL(nss_sjack_tx_msg); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_sjack_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_sjack_log.c deleted file mode 100644 index c585b7483..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_sjack_log.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_sjack_log.c - * NSS SJACK logger file. - */ - -#include "nss_core.h" - -/* - * nss_sjack_log_message_types_str - * NSS SJACK message strings - */ -static int8_t *nss_sjack_log_message_types_str[NSS_SJACK_MAX_MSG_TYPE] __maybe_unused = { - "SJACK Configure", - "SJACK Unconfigure", - "SJACK Stats", -}; - -/* - * nss_sjack_log_configure_msg() - * Log NSS SJACK Configure. - */ -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("%px: NSS SJACK Configure message \n" - "SJACK Ingress Interface Number: %d\n" - "SJACK Engress Interface Number: %d\n" - "SJACK Tunnel ID: %d\n" - "SJACK DSCP Value: %d\n" - "SJACK GRE Priority: %d\n" - "SJACK GRE Flags: %d\n" - "SJACK IPSEC SA Pattern Flag: %d\n", - nscm, nscm->ingress_if_num, - nscm->egress_if_num, nscm->tunnel_id, - nscm->ip_dscp, nscm->gre_prio, - nscm->gre_flags, nscm->use_ipsec_sa_pattern); -} - -/* - * nss_sjack_log_unconfigure_msg() - * Log NSS SJACK Unconfigure. - */ -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("%px: NSS SJACK UnConfigure message \n" - "SJACK Ingress Interface Number: %d\n", - nsum, nsum->ingress_if_num); -} - -/* - * nss_sjack_log_verbose() - * Log message contents. - */ -static void nss_sjack_log_verbose(struct nss_sjack_msg *nsm) -{ - switch (nsm->cm.type) { - case NSS_SJACK_CONFIGURE_MSG: - nss_sjack_log_configure_msg(nsm); - break; - - case NSS_SJACK_UNCONFIGURE_MSG: - nss_sjack_log_unconfigure_msg(nsm); - break; - - case NSS_SJACK_STATS_SYNC_MSG: - /* - * No log for valid stats message. - */ - break; - - default: - nss_trace("%px: Invalid message type\n", nsm); - break; - } -} - -/* - * nss_sjack_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_sjack_log_tx_msg(struct nss_sjack_msg *nsm) -{ - if (nsm->cm.type >= NSS_SJACK_MAX_MSG_TYPE) { - nss_warning("%px: Invalid message type\n", nsm); - return; - } - - 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); -} - -/* - * nss_sjack_log_rx_msg() - * Log messages received from FW. - */ -void nss_sjack_log_rx_msg(struct nss_sjack_msg *nsm) -{ - if (nsm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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]); - -verbose: - nss_sjack_log_verbose(nsm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_sjack_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_sjack_log.h deleted file mode 100644 index 56435a444..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_sjack_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_SJACK_LOG_H -#define __NSS_SJACK_LOG_H - -/* - * nss_sjack.h - * NSS SJACK header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_sjack_log_tx_msg - * Logs a sjack message that is sent to the NSS firmware. - */ -void nss_sjack_log_tx_msg(struct nss_sjack_msg *nsm); - -/* - * nss_sjack_log_rx_msg - * Logs a sjack message that is received from the NSS firmware. - */ -void nss_sjack_log_rx_msg(struct nss_sjack_msg *nsm); - -#endif /* __NSS_SJACK_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_sjack_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_sjack_stats.c deleted file mode 100644 index 139a34941..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_sjack_stats.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - ************************************************************************** - * 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_sjack_stats.h" - -/* - * nss_sjack_stats_read() - * Read SJACK stats - */ -static ssize_t nss_sjack_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - /* - * max output lines = #stats + start tag line + end tag line + three blank lines - */ - uint32_t max_output_lines = NSS_STATS_NODE_MAX + 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; - - 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, "sjack", NSS_STATS_SINGLE_CORE); - size_wr += nss_stats_fill_common_stats(NSS_SJACK_INTERFACE, NSS_STATS_SINGLE_INSTANCE, lbuf, size_wr, size_al, "sjack"); - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(lbuf); - kfree(stats_shadow); - - return bytes_read; -} - -/* - * nss_sjack_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(sjack) - -/* - * nss_sjack_stats_dentry_create() - * Create SJACK node statistics debug entry. - */ -void nss_sjack_stats_dentry_create(void) -{ - nss_stats_create_dentry("sjack", &nss_sjack_stats_ops); -} - -/* - * nss_sjack_stats_node_sync() - * Update sjack node stats. - */ -void nss_sjack_stats_node_sync(struct nss_ctx_instance *nss_ctx, struct nss_sjack_stats_sync_msg *nins) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - int j; - - /* - * Update SJACK node stats. - */ - spin_lock_bh(&nss_top->stats_lock); - nss_top->stats_node[NSS_SJACK_INTERFACE][NSS_SJACK_STATS_RX_PKTS] += nins->node_stats.rx_packets; - nss_top->stats_node[NSS_SJACK_INTERFACE][NSS_SJACK_STATS_RX_BYTES] += nins->node_stats.rx_bytes; - nss_top->stats_node[NSS_SJACK_INTERFACE][NSS_SJACK_STATS_TX_PKTS] += nins->node_stats.tx_packets; - nss_top->stats_node[NSS_SJACK_INTERFACE][NSS_SJACK_STATS_TX_BYTES] += nins->node_stats.tx_bytes; - - for (j = 0; j < NSS_MAX_NUM_PRI; j++) { - nss_top->stats_node[NSS_SJACK_INTERFACE][NSS_SJACK_STATS_RX_QUEUE_0_DROPPED + j] += nins->node_stats.rx_dropped[j]; - } - - spin_unlock_bh(&nss_top->stats_lock); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_sjack_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_sjack_stats.h deleted file mode 100644 index cbcd60453..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_sjack_stats.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - ****************************************************************************** - * 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_SJACK_STATS_H -#define __NSS_SJACK_STATS_H - -/* - * SJACK statistics - */ -enum nss_sjack_stats_types { - NSS_SJACK_STATS_RX_PKTS, /* sjack node RX packets */ - NSS_SJACK_STATS_RX_BYTES, /* sjack node RX bytes */ - NSS_SJACK_STATS_TX_PKTS, /* sjack node TX packets */ - NSS_SJACK_STATS_TX_BYTES, /* sjack node TX bytes */ - NSS_SJACK_STATS_RX_QUEUE_0_DROPPED, - /* sjack node RX Queue 0 dropped */ - NSS_SJACK_STATS_RX_QUEUE_1_DROPPED, - /* sjack node RX Queue 1 dropped */ - NSS_SJACK_STATS_RX_QUEUE_2_DROPPED, - /* sjack node RX Queue 2 dropped */ - NSS_SJACK_STATS_RX_QUEUE_3_DROPPED, - /* sjack node RX Queue 3 dropped */ - NSS_SJACK_STATS_MAX, -}; - -/* - * SJACK statistics APIs - */ -extern void nss_sjack_stats_node_sync(struct nss_ctx_instance *nss_ctx, struct nss_sjack_stats_sync_msg *nins); -extern void nss_sjack_stats_dentry_create(void); - -#endif /* __NSS_SJACK_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_stats.c deleted file mode 100644 index 9605c372b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_stats.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_strings.h" -#include "nss_drv_stats.h" - -/* - * Maximum banner length: - */ -#define NSS_STATS_BANNER_MAX_LENGTH 80 - -/* - * Maximum number of digits a stats value can have: - */ -#define NSS_STATS_DIGITS_MAX 16 - -/* - * Spaces to print core details inside banner - */ -#define NSS_STATS_BANNER_SPACES 12 - -/* - * Max characters for a node name. - */ -#define NSS_STATS_NODE_NAME_MAX 24 - -int nonzero_stats_print = 0; - -/* - * nss_stats_spacing() - * Framework to maintain consistent spacing between stats value and stats type. - */ -static size_t nss_stats_spacing(uint64_t stats_val, char *lbuf, size_t size_wr, size_t size_al) -{ - int i; - int digit_counter = (stats_val == 0 ? 1 : 0); - while (stats_val != 0) { - /* - * TODO: need to check for (nss_ptr_t) - */ - stats_val = (nss_ptr_t)stats_val / 10; - digit_counter++; - } - - for (i = 0; i < NSS_STATS_DIGITS_MAX - digit_counter; i++) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, " "); - } - - return size_wr; -} - -/* - * nss_stats_nonzero_handler() - * Handler to take nonzero stats print configuration. - */ -static int nss_stats_nonzero_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - int ret; - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); - return ret; -} - -static struct ctl_table nss_stats_table[] = { - { - .procname = "non_zero_stats", - .data = &nonzero_stats_print, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &nss_stats_nonzero_handler, - }, - { } -}; - -static struct ctl_table nss_stats_dir[] = { - { - .procname = "stats", - .mode = 0555, - .child = nss_stats_table, - }, - { } -}; - -static struct ctl_table nss_stats_root_dir[] = { - { - .procname = "nss", - .mode = 0555, - .child = nss_stats_dir, - }, - { } -}; - -static struct ctl_table nss_stats_root[] = { - { - .procname = "dev", - .mode = 0555, - .child = nss_stats_root_dir, - }, - { } -}; -static struct ctl_table_header *nss_stats_header; - -/* - * nss_stats_register_sysctl() - * Register a sysctl table for stats. - */ -void nss_stats_register_sysctl(void) -{ - /* - * Register sysctl table. - */ - nss_stats_header = register_sysctl_table(nss_stats_root); -} - -/* - * nss_stats_open() - * Opens stats file. - */ -int nss_stats_open(struct inode *inode, struct file *filp) -{ - struct nss_stats_data *data = NULL; - - data = kzalloc(sizeof(struct nss_stats_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - - memset(data, 0, sizeof (struct nss_stats_data)); - data->if_num = NSS_DYNAMIC_IF_START; - data->index = 0; - data->edma_id = (nss_ptr_t)inode->i_private; - data->nss_ctx = (struct nss_ctx_instance *)(inode->i_private); - filp->private_data = data; - - return 0; -} - -/* - * nss_stats_release() - * Releases stats file. - */ -int nss_stats_release(struct inode *inode, struct file *filp) -{ - struct nss_stats_data *data = filp->private_data; - - if (data) { - kfree(data); - } - - return 0; -} - -/* - * nss_stats_clean() - * Cleanup NSS statistics files. - */ -void nss_stats_clean(void) -{ - /* - * Remove debugfs tree - */ - if (likely(nss_top_main.top_dentry != NULL)) { - debugfs_remove_recursive(nss_top_main.top_dentry); - nss_top_main.top_dentry = NULL; - } -} - -/* - * nss_stats_reset_common_stats() - * Reset common node statistics. - */ -void nss_stats_reset_common_stats(uint32_t if_num) -{ - if (unlikely(if_num >= NSS_MAX_NET_INTERFACES)) { - return; - } - - spin_lock_bh(&nss_top_main.stats_lock); - memset(nss_top_main.stats_node[if_num], 0, NSS_STATS_NODE_MAX * sizeof(uint64_t)); - spin_unlock_bh(&nss_top_main.stats_lock); -} - -/* - * nss_stats_fill_common_stats() - * Fill common node statistics. - */ -size_t nss_stats_fill_common_stats(uint32_t if_num, int instance, char *lbuf, size_t size_wr, size_t size_al, char *node) -{ - uint64_t stats_val[NSS_STATS_NODE_MAX]; - int i; - size_t orig_size_wr = size_wr; - - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; i < NSS_STATS_NODE_MAX; i++) { - stats_val[i] = nss_top_main.stats_node[if_num][i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print(node, NULL, instance, nss_strings_stats_node, stats_val, NSS_STATS_NODE_MAX, lbuf, size_wr, size_al); - return size_wr - orig_size_wr; -} - -/* - * nss_stats_banner() - * Printing banner for node. - */ -size_t nss_stats_banner(char *lbuf, size_t size_wr, size_t size_al, char *node, int core) -{ - uint16_t banner_char_length, i; - size_t orig_size_wr = size_wr; - char node_upr[NSS_STATS_NODE_NAME_MAX + 1]; - - if (strlen(node) > NSS_STATS_NODE_NAME_MAX) { - nss_warning("Node name %s larger than %d characters\n", node, NSS_STATS_NODE_NAME_MAX); - return 0; - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); - for (i = 0; i < NSS_STATS_BANNER_MAX_LENGTH ; i++) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "_"); - } - if (core > NSS_STATS_SINGLE_CORE) { - banner_char_length = (uint16_t)((NSS_STATS_BANNER_MAX_LENGTH - (strlen(node) + NSS_STATS_BANNER_SPACES)) / 2); - } else { - banner_char_length = (uint16_t)((NSS_STATS_BANNER_MAX_LENGTH - (strlen(node) + 2)) / 2); - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\n"); - for (i = 0; i < banner_char_length; i++) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "<"); - } - - strlcpy(node_upr, node, NSS_STATS_NODE_NAME_MAX); - for (i = 0; node_upr[i] != '\0' && i < NSS_STATS_NODE_NAME_MAX; i++) { - node_upr[i] = toupper(node_upr[i]); - } - - /* - * TODO: Enhance so that both core0 and core1 print the same way for a - * node that has presence in both cores. i.e. Core0 should have [CORE 0] - * and not just Core1. - */ - if (core > 1) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, " %s [CORE %d] ", node_upr, core); - } else { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, " %s ", node_upr); - } - for (i = 0; i < banner_char_length; i++) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, ">"); - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); - for (i = 0; i < NSS_STATS_BANNER_MAX_LENGTH; i++) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "_"); - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\n"); - return size_wr - orig_size_wr; -} - -/* - * nss_stats_print() - * Helper API to print stats. - */ -size_t nss_stats_print(char *node, char *stat_details, int instance, struct nss_stats_info *stats_info, - uint64_t *stats_val, uint16_t max, char *lbuf, size_t size_wr, size_t size_al) -{ - uint16_t i, j; - uint16_t maxlen = 0; - char stats_string[NSS_STATS_MAX_STR_LENGTH]; - size_t orig_size_wr = size_wr; - char node_lwr[NSS_STATS_NODE_NAME_MAX + 1]; - - if (strlen(node) > NSS_STATS_NODE_NAME_MAX) { - nss_warning("Node name %s (%u chars) is longer than max chars of %d\n", - node, (uint32_t)strlen(node), NSS_STATS_NODE_NAME_MAX); - return 0; - } - - /* - * Calculating the maximum of the array for indentation purposes. - */ - for (i = 0; i < max; i++){ - if (strlen(stats_info[i].stats_name) > maxlen) { - maxlen = strlen(stats_info[i].stats_name); - } - } - - if (stat_details != NULL) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n#%s\n\n", stat_details); - } - - for (i = 0; i < max; i++){ - if (nonzero_stats_print == 1 && stats_val[i] == 0) { - continue; - } - - strlcpy(stats_string, stats_info[i].stats_name, NSS_STATS_MAX_STR_LENGTH); - - /* - * Converting uppercase to lower case. - */ - for (j = 0; stats_string[j] != '\0' && j < NSS_STATS_MAX_STR_LENGTH; j++) { - stats_string[j] = tolower(stats_string[j]); - } - - strlcpy(node_lwr, node, NSS_STATS_NODE_NAME_MAX); - for (j = 0; node_lwr[j] != '\0' && j < NSS_STATS_NODE_NAME_MAX; j++) { - node_lwr[j] = tolower(node_lwr[j]); - } - - /* - * Space before %s is needed to avoid printing stat name from start of the line. - */ - if (instance < 0) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\t%s_%s", node_lwr, stats_string); - } else { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\t%s[%d]_%s", node_lwr, instance, stats_string); - } - - for (j = 0; j < (1 + maxlen - strlen(stats_string)); j++){ - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, " "); - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "= %llu", stats_val[i]); - size_wr = nss_stats_spacing(stats_val[i], lbuf, size_wr, size_al); - - /* - * Switch case will take care of the indentation and spacing details. - */ - switch (stats_info[i].stats_type) { - case NSS_STATS_TYPE_COMMON: - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "common\n"); - break; - - case NSS_STATS_TYPE_SPECIAL: - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "special\n"); - break; - - case NSS_STATS_TYPE_DROP: - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "drop\n"); - break; - - case NSS_STATS_TYPE_ERROR: - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "error\n"); - break; - - case NSS_STATS_TYPE_EXCEPTION: - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "exception\n"); - break; - - default: - nss_warning("unknown statistics type"); - break; - } - } - - return size_wr - orig_size_wr; -} - -/* - * nss_stats_create_dentry() - * Create statistics debug entry for subsystem. - */ -void nss_stats_create_dentry(char *name, const struct file_operations *ops) -{ - if (!debugfs_create_file(name, 0400, nss_top_main.stats_dentry, &nss_top_main, ops)) { - nss_warning("Failed to create debug entry for subsystem %s\n", name); - } -} - -/* - * TODO: Move the rest of the code to (nss_wt_stats.c, nss_gmac_stats.c) accordingly. - */ - -/* - * gmac_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(gmac); - -/* - * wt_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(wt); - -/* - * nss_stats_init() - * Enable NSS statistics. - */ -void nss_stats_init(void) -{ - struct dentry *core_dentry = NULL; - struct dentry *wt_dentry = NULL; - char file_name[10]; - int i; - - /* - * NSS driver entry - */ - nss_top_main.top_dentry = debugfs_create_dir("qca-nss-drv", NULL); - if (unlikely(nss_top_main.top_dentry == NULL)) { - nss_warning("Failed to create qca-nss-drv directory in debugfs"); - - /* - * Non availability of debugfs directory is not a catastrophy. - * We can still go ahead with other initialization. - */ - return; - } - - nss_top_main.stats_dentry = debugfs_create_dir("stats", nss_top_main.top_dentry); - if (unlikely(nss_top_main.stats_dentry == NULL)) { - nss_warning("Failed to create qca-nss-drv directory in debugfs"); - - /* - * Non availability of debugfs directory is not a catastrophy. - * We can still go ahead with rest of initialization. - */ - return; - } - - /* - * Create files to obtain statistics. - */ - - /* - * drv_stats - */ - nss_drv_stats_dentry_create(); - - /* - * gmac_stats - */ - nss_stats_create_dentry("gmac", &nss_gmac_stats_ops); - - /* - * Per-project stats - */ - nss_top_main.project_dentry = debugfs_create_dir("project", - nss_top_main.stats_dentry); - if (unlikely(nss_top_main.project_dentry == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/project directory in debugfs"); - return; - } - - for (i = 0; i < nss_top_main.num_nss; ++i) { - memset(file_name, 0, sizeof(file_name)); - scnprintf(file_name, sizeof(file_name), "core%d", i); - core_dentry = debugfs_create_dir(file_name, - nss_top_main.project_dentry); - if (unlikely(core_dentry == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/project/core%d directory in debugfs", i); - return; - } - - wt_dentry = debugfs_create_file("worker_threads", - 0400, - core_dentry, - &(nss_top_main.nss[i]), - &nss_wt_stats_ops); - if (unlikely(wt_dentry == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/project/core%d/worker_threads file in debugfs", i); - return; - } - } - - nss_log_init(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_stats.h deleted file mode 100644 index 385c71aad..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_stats.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_stats.h - * printing stats header file - */ - -#ifndef __NSS_STATS_PRINT_H -#define __NSS_STATS_PRINT_H -#include -#include -#include -#include - -/* - * Defines to be used by single instance/core packages. -*/ -#define NSS_STATS_SINGLE_CORE -1 -#define NSS_STATS_SINGLE_INSTANCE -1 - -/* - * Number of Extra outputlines for future reference to add new stats + start tag line + end tag line + three blank lines - */ -#define NSS_STATS_EXTRA_OUTPUT_LINES 35 - -#define NSS_STATS_DECLARE_FILE_OPERATIONS(name) \ -static const struct file_operations nss_##name##_stats_ops = { \ - .open = nss_stats_open, \ - .read = nss_##name##_stats_read, \ - .llseek = generic_file_llseek, \ - .release = nss_stats_release, \ -}; - -/* - * Private data for every file descriptor - */ -struct nss_stats_data { - uint32_t if_num; /**< Interface number for stats */ - uint32_t index; /**< Index for GRE_REDIR stats */ - uint32_t edma_id; /**< EDMA port ID or ring ID */ - struct nss_ctx_instance *nss_ctx; - /**< The core for project stats */ -}; - -/* - * Structure definition carrying stats info. - */ -struct nss_stats_info { - char stats_name[NSS_STATS_MAX_STR_LENGTH]; /* stat name */ - enum nss_stats_types stats_type; /* enum that tags stat type */ -}; - -extern void nss_stats_register_sysctl(void); -void nss_stats_init(void); -extern int nss_stats_release(struct inode *inode, struct file *filp); -extern int nss_stats_open(struct inode *inode, struct file *filp); -void nss_stats_create_dentry(char *name, const struct file_operations *ops); -extern void nss_stats_reset_common_stats(uint32_t if_num); -extern size_t nss_stats_fill_common_stats(uint32_t if_num, int instance, char *lbuf, size_t size_wr, size_t size_al, char *node); -extern size_t nss_stats_banner(char *lbuf , size_t size_wr, size_t size_al, char *node, int core); -extern size_t nss_stats_print(char *node, char *stat_details, int instance, struct nss_stats_info *stats_info, uint64_t *stats_val, uint16_t max, char *lbuf, size_t size_wr, size_t size_al); -#endif /* __NSS_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_strings.c deleted file mode 100644 index 432b1546b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_strings.c +++ /dev/null @@ -1,148 +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_strings.c - * NSS driver strings APIs. - */ - -#include "nss_strings.h" -#include "nss_core.h" -#include "nss_drv_strings.h" - -/* - * common stats - */ -struct nss_stats_info nss_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_strings_print() - * Helper API to print stats names - */ -size_t nss_strings_print(char __user *ubuf, size_t sz, loff_t *ppos, struct nss_stats_info *stats_info, uint16_t max) -{ - int32_t i; - size_t size_al = (NSS_STATS_MAX_STR_LENGTH + 12) * max; - size_t size_wr = 0; - ssize_t bytes_read = 0; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (!lbuf) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - for (i = 0; i < max; i++) { - /* - * Print what we have but don't exceed the buffer. - */ - if (size_wr >= size_al) { - nss_info_always("Buffer overflowed.\n"); - break; - } - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, - "\t%d , %s\n", stats_info[i].stats_type, stats_info[i].stats_name); - } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(lbuf); - - return bytes_read; -} - -/* - * nss_strings_create_dentry() - * Create strings debug entry for subsystem. - */ -void nss_strings_create_dentry(char *name, const struct file_operations *ops) -{ - if (!nss_top_main.strings_dentry || !debugfs_create_file(name, 0400, nss_top_main.strings_dentry, &nss_top_main, ops)) { - nss_warning("Failed to create debug entry for subsystem %s\n", name); - } -} - -/* - * nss_strings_open() - */ -int nss_strings_open(struct inode *inode, struct file *filp) -{ - struct nss_strings_data *data = NULL; - - data = kzalloc(sizeof(struct nss_strings_data), GFP_KERNEL); - if (!data) { - return -ENOMEM; - } - data->if_num = NSS_DYNAMIC_IF_START; - data->nss_ctx = (struct nss_ctx_instance *)(inode->i_private); - filp->private_data = data; - - return 0; -} - -/* - * nss_strings_release() - */ -int nss_strings_release(struct inode *inode, struct file *filp) -{ - struct nss_strings_data *data = filp->private_data; - - if (data) { - kfree(data); - } - - return 0; -} - -/* - * nss_common_node_stats_strings_read() - * Read common node statistics names. - */ -static ssize_t nss_common_node_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_strings_stats_node, NSS_STATS_NODE_MAX); -} - -/* - * nss_common_node_stats_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(common_node_stats); - -/* - * nss_strings_init() - * Enable NSS statistics - */ -void nss_strings_init(void) -{ - nss_top_main.strings_dentry = debugfs_create_dir("strings", nss_top_main.top_dentry); - if (unlikely(nss_top_main.strings_dentry == NULL)) { - nss_warning("Failed to create strings directory in debugfs/qca-nss-drv"); - return; - } - - /* - * Common node statistics - */ - nss_strings_create_dentry("common_node_stats", &nss_common_node_stats_strings_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_strings.h deleted file mode 100644 index 32bf46601..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_strings.h +++ /dev/null @@ -1,52 +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_strings.h - * NSS driver strings header file. - */ - -#ifndef __NSS_STRINGS_H -#define __NSS_STRINGS_H - -#include -#include "nss_stats.h" - -#define NSS_STRINGS_DECLARE_FILE_OPERATIONS(name) \ -static const struct file_operations nss_##name##_strings_ops = { \ - .open = nss_strings_open, \ - .read = nss_##name##_strings_read, \ - .llseek = generic_file_llseek, \ - .release = nss_strings_release, \ -} - -/* - * Private data for every file descriptor - */ -struct nss_strings_data { - uint32_t if_num; /**< Interface number for stats */ - struct nss_ctx_instance *nss_ctx; /**< The core for project stats */ -}; - -extern struct nss_stats_info nss_strings_stats_node[NSS_STATS_NODE_MAX]; -void nss_strings_init(void); -int nss_strings_release(struct inode *inode, struct file *filp); -int nss_strings_open(struct inode *inode, struct file *filp); -void nss_strings_create_dentry(char *name, const struct file_operations *ops); -size_t nss_strings_fill_common_stats(char __user *ubuf, size_t sz, loff_t *ppos); -size_t nss_strings_print(char __user *ubuf, size_t sz, loff_t *ppos, struct nss_stats_info *stats_info, uint16_t max); - -#endif /* __NSS_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tls.c b/feeds/ipq807x/qca-nss-drv/src/nss_tls.c deleted file mode 100644 index ff5336333..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tls.c +++ /dev/null @@ -1,475 +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_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_TX_TIMEOUT 3000 /* 3 Seconds */ - -/* - * Private data structure for handling synchronous messaging. - */ -static struct nss_tls_pvt { - struct semaphore sem; - struct completion complete; - struct nss_tls_msg ntcm; - unsigned long if_map[NSS_TLS_INTERFACE_MAX_LONG]; -} tls_pvt; - -/* - * nss_tls_verify_ifnum() - * Verify if the interface number is a TLS interface. - */ -static bool nss_tls_verify_ifnum(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - enum nss_dynamic_interface_type type = nss_dynamic_interface_get_type(nss_ctx, if_num); - - if (type == NSS_DYNAMIC_INTERFACE_TYPE_TLS_INNER) - return true; - - if (type == NSS_DYNAMIC_INTERFACE_TYPE_TLS_OUTER) - return true; - - if (if_num == NSS_TLS_INTERFACE) - return true; - - return false; -} - -/* - * nss_tls_handler() - * Handle NSS -> HLOS messages for tls tunnel - */ -static void nss_tls_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *data) -{ - nss_tls_msg_callback_t cb; - void *app_data; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - 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("%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("%px:Bad message length(%d)", nss_ctx, ncm->len); - return; - } - - 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; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Trace messages. - */ - nss_tls_log_rx_msg((struct nss_tls_msg *)ncm); - - /* - * Callback - */ - cb = (nss_tls_msg_callback_t)ncm->cb; - app_data = (void *)ncm->app_data; - - /* - * Call TLS session callback - */ - if (!cb) { - nss_warning("%px: No callback for tls session interface %d", nss_ctx, ncm->interface); - return; - } - - nss_trace("%px: calling tlsmgr event handler(%u)", nss_ctx, ncm->interface); - cb(app_data, ncm); -} - -/* - * nss_tls_sync_resp() - * Callback to handle the completion of HLOS-->NSS messages. - */ -static void nss_tls_sync_resp(void *app_data, struct nss_cmn_msg *ncm) -{ - struct nss_tls_msg *pvt_msg = app_data; - struct nss_tls_msg *resp_msg = container_of(ncm, struct nss_tls_msg, cm); - - /* - * Copy response message to pvt message - */ - memcpy(pvt_msg, resp_msg, sizeof(*resp_msg)); - - /* - * Write memory barrier - */ - smp_wmb(); - - complete(&tls_pvt.complete); -} - -/* - * 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 - */ -nss_tx_status_t nss_tls_tx_buf(struct sk_buff *skb, uint32_t if_num, struct nss_ctx_instance *nss_ctx) -{ - int32_t status; - - if (!nss_tls_verify_ifnum(nss_ctx, if_num)) - return NSS_TX_FAILURE; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { - 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, 0); - switch (status) { - case NSS_CORE_STATUS_SUCCESS: - break; - - case NSS_CORE_STATUS_FAILURE_QUEUE: /* queue full condition */ - nss_warning("%px: H2N queue full for tx_buf", nss_ctx); - return NSS_TX_FAILURE_QUEUE; - - default: - nss_warning("%px: general failure for tx_buf", nss_ctx); - return NSS_TX_FAILURE; - } - - /* - * Kick the NSS awake so it can process our new entry. - */ - nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); - - return NSS_TX_SUCCESS; -} -EXPORT_SYMBOL(nss_tls_tx_buf); - -/* - * nss_tls_tx_msg() - * Transmit a TLS message to NSS firmware - */ -nss_tx_status_t nss_tls_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_tls_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - if (ncm->type >= NSS_TLS_MSG_MAX) { - 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("%px: tls message interface is bad: %u", nss_ctx, ncm->interface); - return NSS_TX_FAILURE; - } - - /* - * Trace messages. - */ - nss_tls_log_tx_msg(msg); - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_tls_tx_msg); - -/* - * nss_tls_tx_msg_sync() - * Transmit a TLS message to NSS firmware synchronously. - */ -nss_tx_status_t nss_tls_tx_msg_sync(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - enum nss_tls_msg_type type, uint16_t len, - struct nss_tls_msg *ntcm) -{ - struct nss_tls_msg *local_ntcm = &tls_pvt.ntcm; - nss_tx_status_t status; - int ret = 0; - - /* - * Length of the message should be the based on type - */ - if (len > sizeof(struct nss_tls_msg)) { - nss_warning("%px: Invalid message length(%u), type (%d), I/F(%u)\n", nss_ctx, len, type, if_num); - return NSS_TX_FAILURE; - } - - down(&tls_pvt.sem); - - /* - * We need to copy the message content into the actual message - * to be sent to NSS - */ - memset(local_ntcm, 0, sizeof(*local_ntcm)); - - nss_tls_msg_init(local_ntcm, if_num, type, len, nss_tls_sync_resp, local_ntcm); - memcpy(&local_ntcm->msg, &ntcm->msg, len); - - status = nss_tls_tx_msg(nss_ctx, local_ntcm); - if (status != NSS_TX_SUCCESS) { - 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("%px: Failed to receive response, timeout(%d)\n", nss_ctx, ret); - status = NSS_TX_FAILURE_NOT_READY; - goto done; - } - - /* - * Read memory barrier - */ - smp_rmb(); - - if (local_ntcm->cm.response != NSS_CMN_RESPONSE_ACK) { - status = NSS_TX_FAILURE; - ntcm->cm.response = local_ntcm->cm.response; - ntcm->cm.error = local_ntcm->cm.error; - goto done; - } - - /* - * Copy the message received - */ - memcpy(&ntcm->msg, &local_ntcm->msg, len); - -done: - up(&tls_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_tls_tx_msg_sync); - -/* - * nss_tls_notify_register() - * Register a handler for notification from NSS firmware. - */ -struct nss_ctx_instance *nss_tls_notify_register(uint32_t if_num, nss_tls_msg_callback_t ev_cb, void *app_data) -{ - struct nss_ctx_instance *nss_ctx = nss_tls_get_context(); - uint32_t ret; - - BUG_ON(!nss_ctx); - - ret = nss_core_register_handler(nss_ctx, if_num, nss_tls_handler, app_data); - if (ret != NSS_CORE_STATUS_SUCCESS) { - nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num); - return NULL; - } - - 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; -} -EXPORT_SYMBOL(nss_tls_notify_register); - -/* - * nss_tls_notify_unregister() - * Unregister notification callback handler. - */ -void nss_tls_notify_unregister(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_tls_get_context(); - uint32_t ret; - - BUG_ON(!nss_ctx); - - 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; - } - - 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; -} -EXPORT_SYMBOL(nss_tls_notify_unregister); - -/* - * nss_tls_register_if() - * Register data and event callback handlers for dynamic interface. - */ -struct nss_ctx_instance *nss_tls_register_if(uint32_t if_num, - nss_tls_data_callback_t data_cb, - nss_tls_msg_callback_t ev_cb, - struct net_device *netdev, - uint32_t features, - uint32_t type, - void *app_data) -{ - struct nss_ctx_instance *nss_ctx = nss_tls_get_context(); - uint32_t ret; - - if (!nss_tls_verify_ifnum(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("%px: Cannot find free slot for TLS NSS I/F:%u", nss_ctx, if_num); - return NULL; - } - - nss_core_register_subsys_dp(nss_ctx, if_num, data_cb, NULL, app_data, netdev, features); - nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, type); - - ret = nss_core_register_handler(nss_ctx, if_num, nss_tls_handler, app_data); - if (ret != NSS_CORE_STATUS_SUCCESS) { - nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num); - return NULL; - } - - 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 - */ - set_bit(if_num, tls_pvt.if_map); - return nss_ctx; -} -EXPORT_SYMBOL(nss_tls_register_if); - -/* - * nss_tls_unregister_if() - * Unregister data and event callback handlers for the interface. - */ -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("%px: Cannot find registered netdev for TLS NSS I/F:%u", nss_ctx, if_num); - return; - } - - /* - * Atomically clear the bitmap for the interface number - */ - 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_core_unregister_subsys_dp(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_tls_unregister_if); - -/* - * nss_tls_get_context() - * Return TLS NSS context. - */ -struct nss_ctx_instance *nss_tls_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.tls_handler_id]; -} -EXPORT_SYMBOL(nss_tls_get_context); - -/* - * nss_tls_get_device() - * Gets the original device from probe. - */ -struct device *nss_tls_get_dev(struct nss_ctx_instance *nss_ctx) -{ - return nss_ctx->dev; -} -EXPORT_SYMBOL(nss_tls_get_dev); - -/* - * nss_tls_msg_init() - * Initialize nss_tls msg to be sent asynchronously. - */ -void nss_tls_msg_init(struct nss_tls_msg *ncm, uint32_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} -EXPORT_SYMBOL(nss_tls_msg_init); - -/* - * nss_tls_msg_sync_init() - * Initialize nss_tls_msg to be sent synchronously. - */ -void nss_tls_msg_sync_init(struct nss_tls_msg *ncm, uint32_t if_num, uint32_t type, uint32_t len) -{ - nss_cmn_msg_sync_init(&ncm->cm, if_num, type, len); -} -EXPORT_SYMBOL(nss_tls_msg_sync_init); - -/* - * nss_tls_register_handler() - * TLS initialization. - */ -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(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tls_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_tls_log.c deleted file mode 100644 index 11afe45ed..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tls_log.c +++ /dev/null @@ -1,167 +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_tls_log.c - * NSS TLS logger file. - */ - -#include "nss_core.h" - -/* - * nss_tls_log_message_types_str - * TLS message strings - */ -static int8_t *nss_tls_log_message_types_str[NSS_TLS_MSG_MAX] __maybe_unused = { - "TLS Node Configure", - "TLS Context Configure", - "TLS Context Deconfigure", - "TLS Cipher Update", - "TLS Context Sync", - "TLS Node Sync", -}; - -/* - * nss_tls_log_error_response_types_str - * Strings for error types for TLS messages - */ -static int8_t *nss_tls_log_error_response_types_str[NSS_TLS_ERROR_MAX] __maybe_unused = { - "TLS no_error", - "TLS unknown message", - "TLS fail node already config", - "TLS fail inner ctx", - "TLS fail outer ctx", - "TLS fail req pool", - "TLS invalid block len", - "TLS invalid hash len", - "TLS invalid version", - "TLS invalid context words", - "TLS fail alloc hwctx", - "TLS fail copy ctx", - "TLS Invalid algorithm", - "TLS fail nomem" -}; - -/* - * nss_tls_node_config_msg() - * Log TLS node configure message. - */ -static void nss_tls_node_config_msg(struct nss_tls_msg *ntm) -{ - nss_trace("%px: NSS TLS Node Configure Message:\n" - "TLS Interface: %d\n", ntm, ntm->cm.interface); -} - -/* - * nss_tls_ctx_config_msg() - * Log TLS session configure message. - */ -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("%px: NSS TLS Context Configure Message:\n" - "TLS Except if_num: %d\n", - ntccm, ntccm->except_ifnum); -} - -/* - * nss_tls_cipher_upddate_msg() - * Log TLS Cipher Update message. - */ -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("%px: NSS TLS Cipher Update message\n" - "TLS crypto index: %d\n", - ntcum, ntcum->crypto_idx); -} - -/* - * nss_tls_log_verbose() - * Log message contents. - */ -static void nss_tls_log_verbose(struct nss_tls_msg *ntm) -{ - switch (ntm->cm.type) { - case NSS_TLS_MSG_TYPE_NODE_CONFIG: - nss_tls_node_config_msg(ntm); - break; - - case NSS_TLS_MSG_TYPE_CIPHER_UPDATE: - nss_tls_cipher_update_msg(ntm); - break; - - case NSS_TLS_MSG_TYPE_CTX_CONFIG: - nss_tls_ctx_config_msg(ntm); - break; - - default: - nss_warning("%px: Invalid message type\n", ntm); - break; - } -} - -/* - * nss_tls_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_tls_log_tx_msg(struct nss_tls_msg *ntm) -{ - if (ntm->cm.type >= NSS_TLS_MSG_MAX) { - nss_warning("%px: Invalid message type\n", ntm); - return; - } - - 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); -} - -/* - * nss_tls_log_rx_msg() - * Log messages received from FW. - */ -void nss_tls_log_rx_msg(struct nss_tls_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_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("%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("%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]); - -verbose: - nss_tls_log_verbose(ntm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tls_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_tls_log.h deleted file mode 100644 index 37846c2b6..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tls_log.h +++ /dev/null @@ -1,39 +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_TLS_LOG_H -#define __NSS_TLS_LOG_H - -/* - * nss_tls_log.h - * NSS TLS Log Header File - */ - -/* - * nss_tls_log_tx_msg - * Logs a TLS message that is sent to the NSS firmware. - */ -void nss_tls_log_tx_msg(struct nss_tls_msg *ndm); - -/* - * nss_tls_log_rx_msg - * Logs a TLS message that is received from the NSS firmware. - */ -void nss_tls_log_rx_msg(struct nss_tls_msg *ndm); - -#endif /* __NSS_TLS_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tls_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_tls_stats.c deleted file mode 100644 index 58082708e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tls_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_tls_stats.h deleted file mode 100644 index 3883f6297..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tls_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_tls_strings.c deleted file mode 100644 index 8c4854865..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tls_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_tls_strings.h deleted file mode 100644 index 1509722b0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx.c b/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx.c deleted file mode 100644 index 2ba6ee64d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx.c +++ /dev/null @@ -1,299 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_tx_stats.h" -#include "nss_trustsec_tx_log.h" - -#define NSS_TRUSTSEC_TX_TIMEOUT 3000 /* 3 Seconds */ - -/* - * Private data structure for trustsec_tx interface - */ -static struct nss_trustsec_tx_pvt { - struct semaphore sem; - struct completion complete; - int response; -} ttx; - -/* - * nss_trustsec_tx_handler() - * 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) -{ - nss_trustsec_tx_msg_callback_t cb; - struct nss_trustsec_tx_msg *npm = (struct nss_trustsec_tx_msg *)ncm; - - BUG_ON(ncm->interface != NSS_TRUSTSEC_TX_INTERFACE); - - /* - * Trace messages. - */ - nss_trustsec_tx_log_rx_msg(npm); - - /* - * Is this a valid request/response packet? - */ - 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("%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_TX_MSG_STATS_SYNC: - /* - * Update trustsec_tx statistics. - */ - nss_trustsec_tx_stats_sync(nss_ctx, &npm->msg.stats_sync); - break; - } - - /* - * Update the callback and app_data for NOTIFY messages, trustsec_tx 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_tx_msg_callback_t)ncm->cb; - - cb((void *)ncm->app_data, npm); -} - -/* - * nss_trustsec_tx_msg() - * 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) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace messages. - */ - nss_trustsec_tx_log_tx_msg(msg); - - /* - * Sanity check the message - */ - if (ncm->interface != NSS_TRUSTSEC_TX_INTERFACE) { - nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); - return NSS_TX_FAILURE; - } - - 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; - } - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_trustsec_tx_msg); - -/* - * nss_trustsec_tx_callback - * Callback to handle the completion of NSS ->HLOS messages. - */ -static void nss_trustsec_tx_callback(void *app_data, struct nss_trustsec_tx_msg *npm) -{ - if (npm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("trustsec_tx error response %d\n", npm->cm.response); - ttx.response = NSS_TX_FAILURE; - complete(&ttx.complete); - return; - } - - ttx.response = NSS_TX_SUCCESS; - complete(&ttx.complete); -} - -/* - * nss_trustsec_tx_msg_sync() - * Send a message to trustsec_tx interface & wait for the response. - */ -nss_tx_status_t nss_trustsec_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_trustsec_tx_msg *msg) -{ - nss_tx_status_t status; - int ret = 0; - - down(&ttx.sem); - - msg->cm.cb = (nss_ptr_t)nss_trustsec_tx_callback; - msg->cm.app_data = (nss_ptr_t)NULL; - - status = nss_trustsec_tx_msg(nss_ctx, msg); - if (status != NSS_TX_SUCCESS) { - 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("%px: trustsec_tx 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_tx_msg_sync); - -/* - * nss_trustsec_tx_get_ctx() - * Return a TrustSec TX NSS context. - */ -struct nss_ctx_instance *nss_trustsec_tx_get_ctx() -{ - return &nss_top_main.nss[nss_top_main.trustsec_tx_handler_id]; -} -EXPORT_SYMBOL(nss_trustsec_tx_get_ctx); - -/* - * nss_trustsec_tx_msg_init() - * Initialize trustsec_tx message. - */ -void nss_trustsec_tx_msg_init(struct nss_trustsec_tx_msg *npm, uint16_t if_num, uint32_t type, uint32_t len, - nss_trustsec_tx_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&npm->cm, if_num, type, len, (void *)cb, app_data); -} -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 = {{0}}; - struct nss_trustsec_tx_configure_msg *ttxcfg; - nss_tx_status_t status; - - 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_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("%px: configure trustsec_tx failed: %d\n", ctx, status); - } - - return status; -} -EXPORT_SYMBOL(nss_trustsec_tx_configure_sgt); - -/* - * nss_trustsec_tx_unconfigure() - */ -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 = {{0}}; - struct nss_trustsec_tx_unconfigure_msg *ttxucfg; - nss_tx_status_t status; - - 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_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("%px: unconfigure trustsec_tx failed: %d\n", ctx, status); - } - - return status; -} -EXPORT_SYMBOL(nss_trustsec_tx_unconfigure_sgt); - -/* - * nss_trustsec_tx_register_handler() - * Registering handler for sending msg to trustsec_tx node on NSS. - */ -void nss_trustsec_tx_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_trustsec_tx_get_ctx(); - - nss_core_register_handler(nss_ctx, NSS_TRUSTSEC_TX_INTERFACE, nss_trustsec_tx_handler, NULL); - - nss_trustsec_tx_stats_dentry_create(); - - sema_init(&ttx.sem, 1); - init_completion(&ttx.complete); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx_log.c deleted file mode 100644 index 3ed5b5149..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx_log.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_trustsec_tx_log.c - * NSS TRUSTSEC_TX logger file. - */ - -#include "nss_core.h" - -/* - * nss_trustsec_tx_log_message_types_str - * TRUSTSEC_TX message strings - */ -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", -}; - -/* - * nss_trustsec_tx_log_error_response_types_str - * Strings for error types for TRUSTSEC_TX messages - */ -static int8_t *nss_trustsec_tx_log_error_response_types_str[NSS_TRUSTSEC_TX_ERR_UNKNOWN] __maybe_unused = { - "TRUSTSEC_TX Invalid Source Interface", - "TRUSTSEC_TX Reconfigure Source Interface" - "TRUSTSEC_TX Destination Interface Not Found", - "TRUSTSEC_TX Not Configured", - "TRUSTSEC_TX SGT Mismatch", - "TRUSTSEC_TX Unknown Error", -}; - -/* - * nss_trustsec_tx_log_configure_msg() - * Log NSS TRUSTSEC_TX configure message. - */ -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("%px: NSS TRUSTSEC_TX Configure Message:\n" - "TRUSTSEC_TX Source: %d\n" - "TRUSTSEC_TX Destination: %d\n" - "TRUSTSEC_TX Security Group Tag: %d\n", - ntcm, ntcm->src, - ntcm->dest, ntcm->sgt); -} - -/* - * nss_trustsec_tx_log_unconfigure_msg() - * Log NSS TRUSTSEC_TX unconfigure message. - */ -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("%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_MSG_CONFIGURE: - nss_trustsec_tx_log_configure_msg(ntm); - break; - - case NSS_TRUSTSEC_TX_MSG_UNCONFIGURE: - nss_trustsec_tx_log_unconfigure_msg(ntm); - break; - - 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("%px: Invalid message type\n", ntm); - break; - } -} - -/* - * nss_trustsec_tx_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_trustsec_tx_log_tx_msg(struct nss_trustsec_tx_msg *ntm) -{ - if (ntm->cm.type >= NSS_TRUSTSEC_TX_MSG_MAX) { - nss_warning("%px: Invalid message type\n", ntm); - return; - } - - 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); -} - -/* - * nss_trustsec_tx_log_rx_msg() - * Log messages received from FW. - */ -void nss_trustsec_tx_log_rx_msg(struct nss_trustsec_tx_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_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("%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("%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]); - -verbose: - nss_trustsec_tx_log_verbose(ntm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx_log.h deleted file mode 100644 index 58633c942..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_TX_LOG_H__ -#define __NSS_TRUSTSEC_TX_LOG_H__ - -/* - * nss_trustsec_tx_log.h - * NSS TRUSTSEC_TX Log Header File - */ - -/* - * nss_trustsec_tx_log_tx_msg - * Logs a trustsec_tx message that is sent to the NSS firmware. - */ -void nss_trustsec_tx_log_tx_msg(struct nss_trustsec_tx_msg *ncm); - -/* - * nss_trustsec_tx_log_rx_msg - * Logs a trustsec_tx message that is received from the NSS firmware. - */ -void nss_trustsec_tx_log_rx_msg(struct nss_trustsec_tx_msg *ncm); - -#endif /* __NSS_TRUSTSEC_TX_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx_stats.c deleted file mode 100644 index 5302321ae..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx_stats.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_tx_stats.h" - -/* - * nss_trustsec_tx_stats_str - * Trustsec TX statistics strings. - */ - -struct nss_stats_info nss_trustsec_tx_stats_str[NSS_TRUSTSEC_TX_STATS_MAX] = { - {"INVALID_SRC" , NSS_STATS_TYPE_ERROR}, - {"UNCONFIGURED_SRC" , NSS_STATS_TYPE_ERROR}, - {"HEADROOM_NOT_ENOUGH" , NSS_STATS_TYPE_ERROR} -}; - -/* - * trustsec_tx_stats - * Trustsec TX statistics. - */ -uint64_t trustsec_tx_stats[NSS_TRUSTSEC_TX_STATS_MAX]; - -/* - * Trustsec TX statistics APIs - */ - -/* - * nss_trustsec_tx_stats_sync() - * Update trustsec_tx node statistics. - */ -void nss_trustsec_tx_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_trustsec_tx_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_TX_INTERFACE][NSS_STATS_NODE_RX_PKTS] += ntsm->node_stats.rx_packets; - nss_top->stats_node[NSS_TRUSTSEC_TX_INTERFACE][NSS_STATS_NODE_RX_BYTES] += ntsm->node_stats.rx_bytes; - nss_top->stats_node[NSS_TRUSTSEC_TX_INTERFACE][NSS_STATS_NODE_TX_PKTS] += ntsm->node_stats.tx_packets; - nss_top->stats_node[NSS_TRUSTSEC_TX_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_TX_INTERFACE][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + j] += ntsm->node_stats.rx_dropped[j]; - } - - /* - * Update trustsec node stats - */ - trustsec_tx_stats[NSS_TRUSTSEC_TX_STATS_INVALID_SRC] += ntsm->invalid_src; - trustsec_tx_stats[NSS_TRUSTSEC_TX_STATS_UNCONFIGURED_SRC] += ntsm->unconfigured_src; - trustsec_tx_stats[NSS_TRUSTSEC_TX_STATS_HEADROOM_NOT_ENOUGH] += ntsm->headroom_not_enough; - - spin_unlock_bh(&nss_top->stats_lock); -} - -/* - * nss_trustsec_tx_stats_read() - * Read trustsec_tx statiistics. - */ -static ssize_t nss_trustsec_tx_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_TX_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_tx", NSS_STATS_SINGLE_CORE); - - /* - * Common node stats - */ - size_wr += nss_stats_fill_common_stats(NSS_TRUSTSEC_TX_INTERFACE, NSS_STATS_SINGLE_INSTANCE, lbuf, size_wr, size_al, "trustsec_tx"); - - /* - * TrustSec TX node stats - */ - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; (i < NSS_TRUSTSEC_TX_STATS_MAX); i++) { - stats_shadow[i] = trustsec_tx_stats[i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("trustsec_tx", NULL, NSS_STATS_SINGLE_INSTANCE - , nss_trustsec_tx_stats_str - , stats_shadow - , NSS_TRUSTSEC_TX_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_tx_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(trustsec_tx) - -/* - * nss_trustsec_tx_stats_dentry_create() - * Create trustsec_tx statistics debug entry. - */ -void nss_trustsec_tx_stats_dentry_create(void) -{ - nss_stats_create_dentry("trustsec_tx", &nss_trustsec_tx_stats_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx_stats.h deleted file mode 100644 index 11a4d8f56..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_trustsec_tx_stats.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_trustsec_tx_stats.h - * NSS TRUSTSEC TX statistics header file. - */ - -#ifndef __NSS_TRUSTSEC_TX_STATS_H -#define __NSS_TRUSTSEC_TX_STATS_H - -/* - * Trustsec TX statistics - */ -enum nss_trustsec_tx_stats { - NSS_TRUSTSEC_TX_STATS_INVALID_SRC, - /* Number of packets with invalid src if */ - NSS_TRUSTSEC_TX_STATS_UNCONFIGURED_SRC, - /* Number of packets with unconfigured src if */ - NSS_TRUSTSEC_TX_STATS_HEADROOM_NOT_ENOUGH, - /* Number of packets with not enough headroom */ - NSS_TRUSTSEC_TX_STATS_MAX -}; - -/* - * Trustsec TX statistics APIs - */ -extern void nss_trustsec_tx_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_trustsec_tx_stats_sync_msg *ntsm); -extern void nss_trustsec_tx_stats_dentry_create(void); - -#endif /* __NSS_TRUSTSEC_TX_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tstamp.c b/feeds/ipq807x/qca-nss-drv/src/nss_tstamp.c deleted file mode 100644 index 1984afb07..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tstamp.c +++ /dev/null @@ -1,423 +0,0 @@ -/* - ************************************************************************** - * 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_tstamp.c - * NSS Tstamp APIs - */ - -#include -#include -#include -#include -#include -#include -#include "nss_tx_rx_common.h" -#include "nss_tstamp.h" -#include "nss_tstamp_stats.h" - -#define NSS_TSTAMP_HEADER_SIZE max(sizeof(struct nss_tstamp_h2n_pre_hdr), sizeof(struct nss_tstamp_n2h_pre_hdr)) - -/* - * Notify data structure - */ -struct nss_tstamp_notify_data { - nss_tstamp_msg_callback_t tstamp_callback; - void *app_data; -}; - -static struct nss_tstamp_notify_data nss_tstamp_notify = { - .tstamp_callback = NULL, - .app_data = NULL, -}; - -static struct net_device_stats *nss_tstamp_ndev_stats(struct net_device *ndev); - -/* - * dummy netdevice ops - */ -static const struct net_device_ops nss_tstamp_ndev_ops = { - .ndo_get_stats = nss_tstamp_ndev_stats, -}; - -/* - * nss_tstamp_ndev_setup() - * Dummy setup for net_device handler - */ -static void nss_tstamp_ndev_setup(struct net_device *ndev) -{ - return; -} - -/* - * nss_tstamp_ndev_stats() - * Return net device stats - */ -static struct net_device_stats *nss_tstamp_ndev_stats(struct net_device *ndev) -{ - return &ndev->stats; -} - -/* - * nss_tstamp_verify_if_num() - * Verify if_num passed to us. - */ -static bool nss_tstamp_verify_if_num(uint32_t if_num) -{ - return (if_num == NSS_TSTAMP_TX_INTERFACE) || (if_num == NSS_TSTAMP_RX_INTERFACE); -} - -/* - * nss_tstamp_interface_handler() - * Handle NSS -> HLOS messages for TSTAMP Statistics - */ -static void nss_tstamp_interface_handler(struct nss_ctx_instance *nss_ctx, - struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_tstamp_msg *ntm = (struct nss_tstamp_msg *)ncm; - nss_tstamp_msg_callback_t cb; - - if (!nss_tstamp_verify_if_num(ncm->interface)) { - nss_warning("%px: invalid interface %d for tstamp_tx", nss_ctx, ncm->interface); - return; - } - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_TSTAMP_MSG_TYPE_MAX) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - switch (ntm->cm.type) { - case NSS_TSTAMP_MSG_TYPE_SYNC_STATS: - nss_tstamp_stats_sync(nss_ctx, &ntm->msg.stats, ncm->interface); - break; - default: - nss_warning("%px: Unknown message type %d", - nss_ctx, ncm->type); - return; - } - - /* - * Update the callback and app_data for NOTIFY messages - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_tstamp_notify.tstamp_callback; - ncm->app_data = (nss_ptr_t)nss_tstamp_notify.app_data; - } - - /* - * Do we have a callback? - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_tstamp_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, ntm); -} - -/* - * nss_tstamp_copy_data() - * Copy timestamps from received nss frame into skb - */ -static void nss_tstamp_copy_data(struct nss_tstamp_n2h_pre_hdr *ntm, struct sk_buff *skb) -{ - struct skb_shared_hwtstamps *tstamp; - - tstamp = skb_hwtstamps(skb); - tstamp->hwtstamp = ktime_set(ntm->ts_data_hi, ntm->ts_data_lo); -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 16, 0)) - tstamp->syststamp = ktime_set(ntm->ts_data_hi, ntm->ts_data_lo); -#endif -} - -/* - * nss_tstamp_get_dev() - * Get the net_device associated with the packet. - */ -static struct net_device *nss_tstamp_get_dev(struct sk_buff *skb) -{ - struct dst_entry *dst; - struct net_device *dev; - struct rtable *rt; - struct flowi6 fl6; - uint32_t ip_addr; - - /* - * It seems like the data came over IPsec, hence indicate - * it to the Linux over this interface - */ - skb_reset_network_header(skb); - skb_reset_mac_header(skb); - - skb->pkt_type = PACKET_HOST; - - switch (ip_hdr(skb)->version) { - case IPVERSION: - ip_addr = ip_hdr(skb)->saddr; - - rt = ip_route_output(&init_net, ip_addr, 0, 0, 0); - if (IS_ERR(rt)) { - return NULL; - } - - dst = (struct dst_entry *)rt; - skb->protocol = cpu_to_be16(ETH_P_IP); - break; - - case 6: - memset(&fl6, 0, sizeof(fl6)); - memcpy(&fl6.daddr, &ipv6_hdr(skb)->saddr, sizeof(fl6.daddr)); - - dst = ip6_route_output(&init_net, NULL, &fl6); - if (IS_ERR(dst)) { - return NULL; - } - - skb->protocol = cpu_to_be16(ETH_P_IPV6); - break; - - default: - nss_warning("%px:could not get dev for the skb\n", skb); - return NULL; - } - - dev = dst->dev; - dev_hold(dev); - - dst_release(dst); - return dev; -} - -/* - * nss_tstamp_buf_receive() - * Receive nss exception packets. - */ -static void nss_tstamp_buf_receive(struct net_device *ndev, struct sk_buff *skb, struct napi_struct *napi) -{ - struct nss_tstamp_n2h_pre_hdr *n2h_hdr = (struct nss_tstamp_n2h_pre_hdr *)skb->data; - struct nss_ctx_instance *nss_ctx; - struct net_device *dev; - uint32_t tstamp_sz; - - BUG_ON(!n2h_hdr); - - tstamp_sz = n2h_hdr->ts_hdr_sz; - if (tstamp_sz > (NSS_TSTAMP_HEADER_SIZE)) { - goto free; - } - - nss_ctx = &nss_top_main.nss[nss_top_main.tstamp_handler_id]; - BUG_ON(!nss_ctx); - - skb_pull_inline(skb, tstamp_sz); - - /* - * copy the time stamp and convert into ktime_t - */ - nss_tstamp_copy_data(n2h_hdr, skb); - if (unlikely(n2h_hdr->ts_tx)) { - /* - * We are in TX Path - */ - skb_tstamp_tx(skb, skb_hwtstamps(skb)); - - ndev->stats.tx_packets++; - ndev->stats.tx_bytes += skb->len; - goto free; - } - - /* - * We are in RX path. - */ - dev = nss_cmn_get_interface_dev(nss_ctx, n2h_hdr->ts_ifnum); - if (!dev) { - ndev->stats.rx_dropped++; - goto free; - } - - /* - * Hold the dev until we finish - */ - dev_hold(dev); - - switch(dev->type) { - case NSS_IPSEC_ARPHRD_IPSEC: - /* - * Release the prev dev reference - */ - dev_put(dev); - - /* - * find the actual IPsec tunnel device - */ - dev = nss_tstamp_get_dev(skb); - break; - - default: - /* - * This is a plain non-encrypted data packet. - */ - skb->protocol = eth_type_trans(skb, dev); - break; - } - - skb->skb_iif = dev->ifindex; - skb->dev = dev; - - ndev->stats.rx_packets++; - ndev->stats.rx_bytes += skb->len; - - netif_receive_skb(skb); - - /* - * release the device as we are done - */ - dev_put(dev); - return; -free: - dev_kfree_skb_any(skb); - return; -} - -/* - * nss_tstamp_tx_buf() - * Send data packet for tstamp processing - */ -nss_tx_status_t nss_tstamp_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *skb, uint32_t if_num) -{ - struct nss_tstamp_h2n_pre_hdr *h2n_hdr; - int extra_head; - int extra_tail = 0; - char *align_data; - uint32_t hdr_sz; - - nss_trace("%px: Tstamp If Tx packet, id:%d, data=%px", nss_ctx, NSS_TSTAMP_RX_INTERFACE, skb->data); - - /* - * header size + alignment size - */ - hdr_sz = NSS_TSTAMP_HEADER_SIZE; - extra_head = hdr_sz - skb_headroom(skb); - - /* - * Expand the head for h2n_hdr - */ - if (extra_head > 0) { - /* - * Try to accommodate using available tailroom. - */ - if (skb->end - skb->tail >= extra_head) - extra_tail = -extra_head; - if (pskb_expand_head(skb, extra_head, extra_tail, GFP_KERNEL)) { - nss_trace("%px: expand head room failed", nss_ctx); - return NSS_TX_FAILURE; - } - } - - align_data = PTR_ALIGN((skb->data - hdr_sz), sizeof(uint32_t)); - hdr_sz = (nss_ptr_t)skb->data - (nss_ptr_t)align_data; - - h2n_hdr = (struct nss_tstamp_h2n_pre_hdr *)skb_push(skb, hdr_sz); - h2n_hdr->ts_ifnum = if_num; - h2n_hdr->ts_tx_hdr_sz = hdr_sz; - - return nss_core_send_packet(nss_ctx, skb, NSS_TSTAMP_RX_INTERFACE, H2N_BIT_FLAG_VIRTUAL_BUFFER | H2N_BIT_FLAG_BUFFER_REUSABLE); -} -EXPORT_SYMBOL(nss_tstamp_tx_buf); - -/* - * nss_tstamp_register_netdev() - * register dummy netdevice for tstamp interface - */ -struct net_device *nss_tstamp_register_netdev(void) -{ - struct net_device *ndev; - uint32_t err = 0; - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 16, 0)) - ndev = alloc_netdev(sizeof(struct netdev_priv_instance), "qca-nss-tstamp", nss_tstamp_ndev_setup); -#else - ndev = alloc_netdev(sizeof(struct netdev_priv_instance), "qca-nss-tstamp", NET_NAME_ENUM, nss_tstamp_ndev_setup); -#endif - if (!ndev) { - nss_warning("Tstamp: Could not allocate tstamp net_device "); - return NULL; - } - - ndev->netdev_ops = &nss_tstamp_ndev_ops; - - err = register_netdev(ndev); - if (err) { - nss_warning("Tstamp: Could not register tstamp net_device "); - free_netdev(ndev); - return NULL; - } - - return ndev; -} - -/* - * nss_tstamp_notify_register() - * Register to receive tstamp notify messages. - */ -struct nss_ctx_instance *nss_tstamp_notify_register(nss_tstamp_msg_callback_t cb, void *app_data) -{ - struct nss_ctx_instance *nss_ctx; - - nss_ctx = &nss_top_main.nss[nss_top_main.tstamp_handler_id]; - - nss_tstamp_notify.tstamp_callback = cb; - nss_tstamp_notify.app_data = app_data; - - return nss_ctx; -} -EXPORT_SYMBOL(nss_tstamp_notify_register); - -/* - * nss_tstamp_register_handler() - */ -void nss_tstamp_register_handler(struct net_device *ndev) -{ - uint32_t features = 0; - struct nss_ctx_instance *nss_ctx; - - nss_ctx = &nss_top_main.nss[nss_top_main.tstamp_handler_id]; - - nss_core_register_subsys_dp(nss_ctx, NSS_TSTAMP_TX_INTERFACE, nss_tstamp_buf_receive, NULL, NULL, ndev, features); - - nss_core_register_handler(nss_ctx, NSS_TSTAMP_TX_INTERFACE, nss_tstamp_interface_handler, NULL); - - nss_core_register_handler(nss_ctx, NSS_TSTAMP_RX_INTERFACE, nss_tstamp_interface_handler, NULL); - - nss_tstamp_stats_dentry_create(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tstamp_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_tstamp_stats.c deleted file mode 100644 index 6285ad84b..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tstamp_stats.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_tstamp_stats.h" - -/* - * Spinlock to protect TSTAMP statistics update/read - */ -DEFINE_SPINLOCK(nss_tstamp_stats_lock); - -/* - * nss_tstamp_stats_str - * TSTAMP stats strings - */ -struct nss_stats_info nss_tstamp_stats_str[NSS_TSTAMP_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_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}, - {"boomeranged" , NSS_STATS_TYPE_SPECIAL}, - {"dropped_fail_enqueue" , NSS_STATS_TYPE_DROP}, - {"dropped_fail_alloc" , NSS_STATS_TYPE_DROP}, - {"dropped_fail_copy" , NSS_STATS_TYPE_DROP}, - {"dropped_no_interface" , NSS_STATS_TYPE_DROP}, - {"dropped_no_headroom" , NSS_STATS_TYPE_DROP} -}; - -/* - * nss_tstamp_stats - * tstamp statistics - */ -uint64_t nss_tstamp_stats[2][NSS_TSTAMP_STATS_MAX]; - -/* - * nss_tstamp_stats_read() - * Read tstamp statistics - */ -static ssize_t nss_tstamp_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - int32_t i, num; - - /* - * Max output lines = (#stats + tx or rx tag + two blank lines) * 2(TX and RX) + - * start tag line + end tag line + three blank lines - */ - uint32_t max_output_lines = (NSS_TSTAMP_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; - 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 -ENOMEM; - } - - stats_shadow = kzalloc(NSS_TSTAMP_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 -ENOMEM; - } - size_wr += nss_stats_banner(lbuf, size_wr, size_al, "tstamp", NSS_STATS_SINGLE_CORE); - /* - * TSTAMP statistics - */ - for (num = 0; num < 2; num++) { - if (num == 0) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ntstamp TX stats:\n\n"); - } else { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\ntstamp RX stats:\n\n"); - } - - spin_lock_bh(&nss_tstamp_stats_lock); - for (i = 0; i < NSS_TSTAMP_STATS_MAX; i++) { - stats_shadow[i] = nss_tstamp_stats[num][i]; - } - spin_unlock_bh(&nss_tstamp_stats_lock); - size_wr += nss_stats_print("tstamp", NULL, NSS_STATS_SINGLE_INSTANCE - , nss_tstamp_stats_str - , stats_shadow - , NSS_TSTAMP_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_tstamp_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(tstamp) - -/* - * nss_tstamp_stats_dentry_create() - * Create tstamp statistics debug entry. - */ -void nss_tstamp_stats_dentry_create(void) -{ - nss_stats_create_dentry("tstamp", &nss_tstamp_stats_ops); -} - -/* - * nss_tstamp_stats_sync() - * Handle the syncing of NSS TSTAMP statistics. - */ -void nss_tstamp_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_tstamp_stats_msg *nts, uint32_t interface) -{ - int id, j; - - if (interface == NSS_TSTAMP_TX_INTERFACE) { - id = 0; - } else { - id = 1; - } - - spin_lock_bh(&nss_tstamp_stats_lock); - - /* - * Common node stats - */ - nss_tstamp_stats[id][NSS_STATS_NODE_RX_PKTS] += nts->node_stats.rx_packets; - nss_tstamp_stats[id][NSS_STATS_NODE_RX_BYTES] += nts->node_stats.rx_bytes; - nss_tstamp_stats[id][NSS_STATS_NODE_TX_PKTS] += nts->node_stats.tx_packets; - nss_tstamp_stats[id][NSS_STATS_NODE_TX_BYTES] += nts->node_stats.tx_bytes; - - for (j = 0; j < NSS_MAX_NUM_PRI; j++) { - nss_tstamp_stats[id][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + j] += nts->node_stats.rx_dropped[j]; - } - - /* - * TSTAMP statistics - */ - nss_tstamp_stats[id][NSS_TSTAMP_STATS_BOOMERANGED] += nts->boomeranged; - nss_tstamp_stats[id][NSS_TSTAMP_STATS_DROPPED_FAIL_ENQUEUE] += nts->dropped_fail_enqueue; - nss_tstamp_stats[id][NSS_TSTAMP_STATS_DROPPED_FAIL_ALLOC] += nts->dropped_fail_alloc; - nss_tstamp_stats[id][NSS_TSTAMP_STATS_DROPPED_FAIL_COPY] += nts->dropped_fail_copy; - nss_tstamp_stats[id][NSS_TSTAMP_STATS_DROPPED_NO_INTERFACE] += nts->dropped_no_interface; - nss_tstamp_stats[id][NSS_TSTAMP_STATS_DROPPED_NO_HEADROOM] += nts->dropped_no_headroom; - spin_unlock_bh(&nss_tstamp_stats_lock); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tstamp_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_tstamp_stats.h deleted file mode 100644 index d488ae7d7..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tstamp_stats.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_TSTAMP_STATS_H -#define __NSS_TSTAMP_STATS_H - -#include - -/** - * TSTAMP node statistics - */ -enum nss_tstamp_stats_types { - - NSS_TSTAMP_STATS_BOOMERANGED = NSS_STATS_NODE_MAX, - /**< Number of boomeranged packets. */ - NSS_TSTAMP_STATS_DROPPED_FAIL_ENQUEUE, - /**< Number of failed enqueue drops. */ - NSS_TSTAMP_STATS_DROPPED_FAIL_ALLOC, - /**< Number of failed allocation drops. */ - NSS_TSTAMP_STATS_DROPPED_FAIL_COPY, - /**< Number of failed copy drops. */ - NSS_TSTAMP_STATS_DROPPED_NO_INTERFACE, - /**< Number of failed no interface drops. */ - NSS_TSTAMP_STATS_DROPPED_NO_HEADROOM, - /**< Number of failed no headroom drops. */ - NSS_TSTAMP_STATS_MAX, -}; - -/* - * TSTAMP statistics APIs - */ -extern void nss_tstamp_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_tstamp_stats_msg *nts, uint32_t interface); -extern void nss_tstamp_stats_dentry_create(void); - -#endif /* __NSS_TSTAMP_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tun6rd.c b/feeds/ipq807x/qca-nss-drv/src/nss_tun6rd.c deleted file mode 100644 index af1a4ac2f..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tun6rd.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_tun6rd_log.h" - -/* - * nss_tun6rd_handler() - * Handle NSS -> HLOS messages for 6rd tunnel - */ -static void nss_tun6rd_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_tun6rd_msg *ntm = (struct nss_tun6rd_msg *)ncm; - void *ctx; - - nss_tun6rd_msg_callback_t cb; - - BUG_ON(!nss_is_dynamic_interface(ncm->interface)); - - /* - * Trace Messages - */ - nss_tun6rd_log_rx_msg(ntm); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_TUN6RD_MAX) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Update the callback and app_data for NOTIFY messages, tun6rd sends all notify messages - * to the same callback/app_data. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->tun6rd_msg_callback; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_tun6rd_msg_callback_t)ncm->cb; - ctx = nss_ctx->subsys_dp_register[ncm->interface].ndev; - - /* - * call 6rd tunnel callback - */ - if (!ctx) { - nss_warning("%px: Event received for 6rd tunnel interface %d before registration", nss_ctx, ncm->interface); - return; - } - - cb(ctx, ntm); -} - -/* - * nss_tun6rd_tx() - * Transmit a tun6rd message to NSSFW - */ -nss_tx_status_t nss_tun6rd_tx(struct nss_ctx_instance *nss_ctx, struct nss_tun6rd_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace Messages - */ - nss_tun6rd_log_tx_msg(msg); - - /* - * Sanity check the message - */ - if (!nss_is_dynamic_interface(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("%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); -} - -/* - *********************************** - * Register/Unregister/Miscellaneous APIs - *********************************** - */ - -/* - * nss_register_tun6rd_if() - */ -struct nss_ctx_instance *nss_register_tun6rd_if(uint32_t if_num, uint32_t type, nss_tun6rd_callback_t tun6rd_callback, - nss_tun6rd_msg_callback_t event_callback, struct net_device *netdev, uint32_t features) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.tun6rd_handler_id]; - - nss_assert(nss_ctx); - nss_assert((if_num >= NSS_DYNAMIC_IF_START) && (if_num < NSS_SPECIAL_IF_START)); - - nss_core_register_subsys_dp(nss_ctx, if_num, tun6rd_callback, NULL, NULL, netdev, features); - nss_ctx->subsys_dp_register[if_num].type = type; - - nss_top_main.tun6rd_msg_callback = event_callback; - - nss_core_register_handler(nss_ctx, if_num, nss_tun6rd_handler, NULL); - - return nss_ctx; -} - -/* - * nss_tun6rd_get_context() - */ -struct nss_ctx_instance *nss_tun6rd_get_context() -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.tun6rd_handler_id]; -} - -/* - * nss_unregister_tun6rd_if() - */ -void nss_unregister_tun6rd_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.tun6rd_handler_id]; - - nss_assert(nss_ctx); - nss_assert(nss_is_dynamic_interface(if_num)); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - nss_ctx->subsys_dp_register[if_num].type = 0; - - nss_top_main.tun6rd_msg_callback = NULL; - - nss_core_unregister_handler(nss_ctx, if_num); -} - -/* - * nss_tun6rd_msg_init() - * Initialize nss_tun6rd msg. - */ -void nss_tun6rd_msg_init(struct nss_tun6rd_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} - -EXPORT_SYMBOL(nss_tun6rd_get_context); -EXPORT_SYMBOL(nss_tun6rd_tx); -EXPORT_SYMBOL(nss_register_tun6rd_if); -EXPORT_SYMBOL(nss_unregister_tun6rd_if); -EXPORT_SYMBOL(nss_tun6rd_msg_init); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tun6rd_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_tun6rd_log.c deleted file mode 100644 index 121d70f82..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tun6rd_log.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_tun6rd_log.c - * NSS TUN6RD logger file. - */ - -#include "nss_core.h" - -/* - * nss_tun6rd_log_message_types_str - * NSS TUN6RD message strings - */ -static int8_t *nss_tun6rd_log_message_types_str[NSS_TUN6RD_MAX] __maybe_unused = { - "TUN6RD Attach PNODE", - "TUN6RD Stats", - "TUN6RD Update Peer", -}; - -/* - * nss_tun6rd_log_attach_pnode_msg() - * Log NSS TUN6RD Attach PNODE - */ -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("%px: NSS TUN6RD Attach Tunnel message \n" - "TUN6RD Source Address: %pI4\n" - "TUN6RD Destination Address: %pI4\n" - "TUN6RD Type of Service: %d\n" - "TUN6RD Time To Live: %d\n" - "TUN6RD Sibling Interface Number: %d\n", - ntam, &ntam->saddr, - &ntam->daddr, ntam->tos, - ntam->ttl, ntam->sibling_if_num); -} - -/* - * nss_tun6rd_log_set_peer_msg() - * Log NSS TUN6RD Set Peer Message - */ -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("%px: NSS TUN6RD Set Peer message \n" - "TUN6RD IPv6 Address: %pI6\n" - "TUN6RD Destination: %pI4\n", - ntspm, ntspm->ipv6_address, - &ntspm->dest); -} - -/* - * nss_tun6rd_log_verbose() - * Log message contents. - */ -static void nss_tun6rd_log_verbose(struct nss_tun6rd_msg *ntm) -{ - switch (ntm->cm.type) { - case NSS_TUN6RD_ATTACH_PNODE: - nss_tun6rd_log_attach_pnode_msg(ntm); - break; - - case NSS_TUN6RD_ADD_UPDATE_PEER: - nss_tun6rd_log_set_peer_msg(ntm); - break; - - case NSS_TUN6RD_RX_STATS_SYNC: - /* - * No log for valid stats message. - */ - break; - - default: - nss_trace("%px: Invalid message type\n", ntm); - break; - } -} - -/* - * nss_tun6rd_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_tun6rd_log_tx_msg(struct nss_tun6rd_msg *ntm) -{ - if (ntm->cm.type >= NSS_TUN6RD_MAX) { - nss_warning("%px: Invalid message type\n", ntm); - return; - } - - 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); -} - -/* - * nss_tun6rd_log_rx_msg() - * Log messages received from FW. - */ -void nss_tun6rd_log_rx_msg(struct nss_tun6rd_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_tun6rd_log_message_types_str[ntm->cm.type], - ntm->cm.response, nss_cmn_response_str[ntm->cm.response]); - goto verbose; - } - - 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]); - -verbose: - nss_tun6rd_log_verbose(ntm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tun6rd_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_tun6rd_log.h deleted file mode 100644 index c7c3b3a90..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tun6rd_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_TUN6RD_LOG_H -#define __NSS_TUN6RD_LOG_H - -/* - * nss_tun6rd.h - * NSS TUN6RD header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_tun6rd_log_tx_msg - * Logs a tun6rd message that is sent to the NSS firmware. - */ -void nss_tun6rd_log_tx_msg(struct nss_tun6rd_msg *ntm); - -/* - * nss_tun6rd_log_rx_msg - * Logs a tun6rd message that is received from the NSS firmware. - */ -void nss_tun6rd_log_rx_msg(struct nss_tun6rd_msg *ntm); - -#endif /* __NSS_TUN6RD_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tunipip6.c b/feeds/ipq807x/qca-nss-drv/src/nss_tunipip6.c deleted file mode 100644 index 1801e861f..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tunipip6.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_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 - * Verify the interface is a valid interface - */ -static bool nss_tunipip6_verify_if_num(uint32_t if_num) -{ - enum nss_dynamic_interface_type type; - - type = nss_dynamic_interface_get_type(nss_tunipip6_get_context(), if_num); - - switch (type) { - case NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_INNER: - case NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_OUTER: - return true; - default: - return false; - } -} - -/* - * nss_tunipip6_handler() - * Handle NSS -> HLOS messages for ipip6 tunnel - */ -static void nss_tunipip6_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_tunipip6_msg *ntm = (struct nss_tunipip6_msg *)ncm; - void *ctx; - nss_tunipip6_msg_callback_t cb; - - BUG_ON(!nss_tunipip6_verify_if_num(ncm->interface)); - - /* - * Trace Messages - */ - nss_tunipip6_log_rx_msg(ntm); - - /* - * 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); - 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)); - 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. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->tunipip6_msg_callback; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_tunipip6_msg_callback_t)ncm->cb; - ctx = nss_ctx->subsys_dp_register[ncm->interface].ndev; - - /* - * call ipip6 tunnel callback - */ - if (!ctx) { - nss_warning("%px: Event received for DS-Lite tunnel interface %d before registration", nss_ctx, ncm->interface); - return; - } - - cb(ctx, ntm); -} - -/* - * nss_tunipip6_tx() - * Transmit a tunipip6 message to NSSFW - */ -nss_tx_status_t nss_tunipip6_tx(struct nss_ctx_instance *nss_ctx, struct nss_tunipip6_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace Messages - */ - nss_tunipip6_log_tx_msg(msg); - - /* - * 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); - return NSS_TX_FAILURE; - } - - if (ncm->type > NSS_TUNIPIP6_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); -} -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 - * ********************************** - */ - -/* - * nss_register_tunipip6_if() - */ -struct nss_ctx_instance *nss_register_tunipip6_if(uint32_t if_num, - uint32_t dynamic_interface_type, - nss_tunipip6_callback_t tunipip6_callback, - nss_tunipip6_msg_callback_t event_callback, - struct net_device *netdev, - uint32_t features) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.tunipip6_handler_id]; - - nss_assert(nss_ctx); - nss_assert(nss_tunipip6_verify_if_num(if_num)); - - nss_ctx->subsys_dp_register[if_num].type = dynamic_interface_type; - nss_top_main.tunipip6_msg_callback = event_callback; - nss_core_register_subsys_dp(nss_ctx, if_num, tunipip6_callback, NULL, NULL, netdev, features); - nss_core_register_handler(nss_ctx, if_num, nss_tunipip6_handler, NULL); - - return nss_ctx; -} -EXPORT_SYMBOL(nss_register_tunipip6_if); - -/* - * nss_unregister_tunipip6_if() - */ -void nss_unregister_tunipip6_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.tunipip6_handler_id]; - - 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); - - nss_top_main.tunipip6_msg_callback = NULL; -} -EXPORT_SYMBOL(nss_unregister_tunipip6_if); - -/* - * nss_tunipip6_get_context() - */ -struct nss_ctx_instance *nss_tunipip6_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.tunipip6_handler_id]; -} -EXPORT_SYMBOL(nss_tunipip6_get_context); - -/* - * nss_tunipip6_register_handler() - */ -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); -} - -/* - * nss_tunipip6_msg_init() - * Initialize nss_tunipip6 msg. - */ -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_cmn_msg_init(&ntm->cm, if_num, type, len, cb, app_data); -} -EXPORT_SYMBOL(nss_tunipip6_msg_init); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tunipip6_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_tunipip6_log.c deleted file mode 100644 index 1565ed87c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tunipip6_log.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_tunipip6_log.c - * NSS TUNIPIP6 logger file. - */ - -#include "nss_core.h" - -/* - * nss_tunipip6_log_message_types_str - * 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 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" - "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", - 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); -} - -/* - * nss_tunipip6_log_verbose() - * Log message contents. - */ -static void nss_tunipip6_log_verbose(struct nss_tunipip6_msg *ntm) -{ - switch (ntm->cm.type) { - case NSS_TUNIPIP6_TX_ENCAP_IF_CREATE: - case NSS_TUNIPIP6_TX_DECAP_IF_CREATE: - nss_tunipip6_log_if_create_msg(ntm); - break; - - case NSS_TUNIPIP6_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); - break; - } -} - -/* - * nss_tunipip6_log_tx_msg() - * Log messages transmitted to FW. - */ -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); - return; - } - - 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); -} - -/* - * nss_tunipip6_log_rx_msg() - * Log messages received from FW. - */ -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); - 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_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", - 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]); - -verbose: - nss_tunipip6_log_verbose(ntm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tunipip6_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_tunipip6_log.h deleted file mode 100644 index 2ebccee1f..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tunipip6_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_LOG_H -#define __NSS_TUNIPIP6_LOG_H - -/* - * nss_tunipip6.h - * NSS TUNIPIP6 header file. - */ - -/* - * Logger APIs - */ - -/* - * nss_tunipip6_log_tx_msg - * Logs a tunipip6 message that is sent to the NSS firmware. - */ -void nss_tunipip6_log_tx_msg(struct nss_tunipip6_msg *ntm); - -/* - * nss_tunipip6_log_rx_msg - * Logs a tunipip6 message that is received from the NSS firmware. - */ -void nss_tunipip6_log_rx_msg(struct nss_tunipip6_msg *ntm); - -#endif /* __NSS_TUNIPIP6_LOG_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tunipip6_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_tunipip6_stats.c deleted file mode 100644 index 76834d3ef..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tunipip6_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_tunipip6_stats.h deleted file mode 100644 index 0f1748fc3..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tx_msg_sync.c b/feeds/ipq807x/qca-nss-drv/src/nss_tx_msg_sync.c deleted file mode 100644 index 9eb0c70a9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tx_msg_sync.c +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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. - */ - -/* - * nss_tx_msg_sync.c - * NSS Tx msg sync core APIs - */ - -#include "nss_tx_rx_common.h" - -/* - * nss_tx_msg_sync_callback() - * Internal callback used to handle the message response. - */ -static void nss_tx_msg_sync_callback(void *app_data, struct nss_cmn_msg *ncm) -{ - uint32_t resp_offset; - - /* - * Per-message sync data was used as app_data. - * Retrieve the address of the original message from it. - */ - struct nss_tx_msg_sync_cmn_data *sync_data = (struct nss_tx_msg_sync_cmn_data *)app_data; - struct nss_cmn_msg *original_msg = (struct nss_cmn_msg *)sync_data->original_msg; - - /* - * Set TX status. And Copy back ncm->error and ncm->response if it is NACK. - */ - sync_data->status = NSS_TX_SUCCESS; - if (ncm->response != NSS_CMN_RESPONSE_ACK) { - nss_warning("Tx msg sync error response %d\n", ncm->response); - sync_data->status = NSS_TX_FAILURE_SYNC_FW_ERR; - original_msg->error = ncm->error; - original_msg->response = ncm->response; - } - - /* - * ncm is the return message containing message response. - * It is different from the original message caller built. - * Because the return message is only visible in this callback context, - * we copy back message response by specifying offset and length to - * the return message. So the caller can use response in their context - * once wake up instead of calling a passed-in user callback here. - */ - resp_offset = sync_data->resp_offset + sizeof(struct nss_cmn_msg); - - if (sync_data->copy_len > 0) - memcpy((uint8_t *)((nss_ptr_t)original_msg + resp_offset), - (uint8_t *)((nss_ptr_t)ncm + resp_offset), - sync_data->copy_len); - - /* - * Wake up the caller - */ - complete(&sync_data->complete); -} - -/* - * nss_tx_msg_sync_internal() - * Internal call for sending messages to FW synchronously. - */ -static nss_tx_status_t nss_tx_msg_sync_internal(struct nss_ctx_instance *nss_ctx, - nss_tx_msg_sync_subsys_async_t tx_msg_async, - nss_tx_msg_sync_subsys_async_with_size_t tx_msg_async_with_size, - uint32_t msg_buf_size, - struct nss_tx_msg_sync_cmn_data *sync_data, - struct nss_cmn_msg *ncm, - uint32_t timeout) -{ - nss_tx_status_t status; - int ret; - - /* - * Per-msg sync data is used as app_data. - * A generic callback is used to handle the return message. - */ - ncm->cb = (nss_ptr_t)nss_tx_msg_sync_callback; - ncm->app_data = (nss_ptr_t)sync_data; - - BUG_ON(!tx_msg_async && !tx_msg_async_with_size); - - /* - * Per-subsystem asynchronous call to send down the message. - */ - if (tx_msg_async) - status = tx_msg_async(nss_ctx, ncm); - else - status = tx_msg_async_with_size(nss_ctx, ncm, msg_buf_size); - - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: Tx msg async failed\n", nss_ctx); - return status; - } - - /* - * Sleep. Wake up either by notification or timeout. - */ - ret = wait_for_completion_timeout(&sync_data->complete, msecs_to_jiffies(timeout)); - if (!ret) { - nss_warning("%px: Tx msg sync timeout\n", nss_ctx); - return NSS_TX_FAILURE_SYNC_TIMEOUT; - } - - /* - * Wake up. Message response has been received within timeout. - */ - return sync_data->status; -} - -/* - * nss_tx_msg_sync() - * Send messages to FW synchronously with default message buffer size. - * - * tx_msg_async specifies the per-subsystem asynchronous call. - * timeout specifies the maximum sleep time for the completion. - * ncm is the original message the caller built. - * Since the caller cannot access the return message containing message response, - * we copy back message response from return message. - * resp_offset and copy_len specify the part of return message it'll copy. - */ -nss_tx_status_t nss_tx_msg_sync(struct nss_ctx_instance *nss_ctx, - nss_tx_msg_sync_subsys_async_t tx_msg_async, - uint32_t timeout, struct nss_cmn_msg *ncm, - uint32_t resp_offset, uint32_t copy_len) -{ - struct nss_tx_msg_sync_cmn_data sync_data; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - /* - * Check Tx msg async API - */ - if (!unlikely(tx_msg_async)) { - nss_warning("%px: missing Tx msg async API\n", nss_ctx); - return NSS_TX_FAILURE_SYNC_BAD_PARAM; - } - - /* - * Initialize the per-message sync data. - */ - init_completion(&sync_data.complete); - sync_data.status = NSS_TX_FAILURE; - sync_data.original_msg = (void *)ncm; - sync_data.resp_offset = resp_offset; - sync_data.copy_len = copy_len; - - return nss_tx_msg_sync_internal(nss_ctx, tx_msg_async, NULL, 0, &sync_data, ncm, timeout); -} -EXPORT_SYMBOL(nss_tx_msg_sync); - -/* - * nss_tx_msg_sync_with_size() - * Send messages to FW synchronously with specified message buffer size. - */ -nss_tx_status_t nss_tx_msg_sync_with_size(struct nss_ctx_instance *nss_ctx, - nss_tx_msg_sync_subsys_async_with_size_t tx_msg_async_with_size, - uint32_t msg_buf_size, uint32_t timeout, - struct nss_cmn_msg *ncm, uint32_t resp_offset, uint32_t copy_len) -{ - struct nss_tx_msg_sync_cmn_data sync_data; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - /* - * Check Tx msg async API - */ - if (!unlikely(tx_msg_async_with_size)) { - nss_warning("%px: missing Tx msg async API\n", nss_ctx); - return NSS_TX_FAILURE_SYNC_BAD_PARAM; - } - - /* - * Initialize the per-message sync data. - */ - init_completion(&sync_data.complete); - sync_data.status = NSS_TX_FAILURE; - sync_data.original_msg = (void *)ncm; - sync_data.resp_offset = resp_offset; - sync_data.copy_len = copy_len; - - return nss_tx_msg_sync_internal(nss_ctx, NULL, tx_msg_async_with_size, - msg_buf_size, &sync_data, ncm, timeout); -} -EXPORT_SYMBOL(nss_tx_msg_sync_with_size); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tx_msg_sync.h b/feeds/ipq807x/qca-nss-drv/src/nss_tx_msg_sync.h deleted file mode 100644 index 248287e2e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tx_msg_sync.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2018-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. - */ - -/* - * nss_tx_msg_sync.h - * NSS Tx msg sync header file - */ - -#ifndef __NSS_TX_MSG_SYNC_H -#define __NSS_TX_MSG_SYNC_H - -#include - -/* - * Amount time in msec the synchronous message should wait for response - * from NSS before the timeout happens. - */ -#define NSS_TX_MSG_SYNC_DEFAULT_TIMEOUT_MSEC (5000) - -/* - * Per-message sync data - * Used as message app_data. - */ -struct nss_tx_msg_sync_cmn_data { - struct completion complete; /* Completion structure */ - nss_tx_status_t status; /* Tx status */ - void *original_msg; /* Address of the caller-build message */ - uint32_t resp_offset; /* Response offset in message payload */ - uint32_t copy_len; /* Length in bytes copied from the return message */ -}; - -/* - * nss_tx_msg_sync_subsys_async_t() - * Tx msg asynchronous API of each subsystem. - */ -typedef nss_tx_status_t (*nss_tx_msg_sync_subsys_async_t)(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm); - -/* - * nss_tx_msg_sync_subsys_async_with_size_t() - * Tx msg asynchronous API of each subsystem with message buffer size specified. - */ -typedef nss_tx_status_t (*nss_tx_msg_sync_subsys_async_with_size_t)(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, uint32_t size); - -/* - * nss_tx_msg_sync() - * Core function to send message to FW synchronously. - * - * tx_msg_async specifies the per-subsystem asynchronous call. - * timeout specifies the maximum sleep time for the completion. - * ncm is the original message the caller built. - * Since the caller cannot access the return message containing message response, - * we copy back message response from the return message. - * resp_offset and copy_len specify the part of return message it'll copy. - */ -nss_tx_status_t nss_tx_msg_sync(struct nss_ctx_instance *nss_ctx, - nss_tx_msg_sync_subsys_async_t tx_msg_async, - uint32_t timeout, struct nss_cmn_msg *ncm, - uint32_t resp_offset, uint32_t copy_len); - -/* - * nss_tx_msg_sync_with_size() - * Send messages to FW synchronously with specified message buffer size. - */ -nss_tx_status_t nss_tx_msg_sync_with_size(struct nss_ctx_instance *nss_ctx, - nss_tx_msg_sync_subsys_async_with_size_t tx_msg_async_with_size, - uint32_t msg_buf_size, uint32_t timeout, - struct nss_cmn_msg *ncm, uint32_t resp_offset, uint32_t copy_len); - -#endif /* __NSS_TX_MSG_SYNC_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_tx_rx_common.h b/feeds/ipq807x/qca-nss-drv/src/nss_tx_rx_common.h deleted file mode 100644 index 6e148c450..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_tx_rx_common.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_tx_rx_common.h - * NSS APIs common header file - */ - -#ifndef __NSS_TX_RX_COMMON_H -#define __NSS_TX_RX_COMMON_H - -#include -#include -#include -#include -#include "nss_tx_msg_sync.h" - -/* - * Global definitions - */ -#define NSS_HLOS_MESSAGE_VERSION 1 /* Update when the common message structure changed */ - -#if (NSS_DEBUG_LEVEL > 0) -#define NSS_VERIFY_CTX_MAGIC(x) nss_verify_ctx_magic(x) -#define NSS_VERIFY_INIT_DONE(x) nss_verify_init_done(x) - -/* - * nss_verify_ctx_magic() - */ -static inline void nss_verify_ctx_magic(struct nss_ctx_instance *nss_ctx) -{ - nss_assert(nss_ctx->magic == NSS_CTX_MAGIC); -} - -static inline void nss_verify_init_done(struct nss_ctx_instance *nss_ctx) -{ - nss_assert(nss_ctx->state == NSS_CORE_STATE_INITIALIZED); -} - -#else -#define NSS_VERIFY_CTX_MAGIC(x) -#define NSS_VERIFY_INIT_DONE(x) -#endif - -/* - * CB handlers for variour interfaces - */ -void nss_phys_if_register_handler(struct nss_ctx_instance *nss_ctx, uint32_t if_num); -extern void nss_c2c_tx_register_handler(struct nss_ctx_instance *nss_ctx); -extern void nss_c2c_rx_register_handler(struct nss_ctx_instance *nss_ctx); -extern void nss_crypto_register_handler(void); -extern void nss_crypto_cmn_register_handler(void); -extern void nss_ipsec_register_handler(void); -extern void nss_ipsec_cmn_register_handler(void); -extern void nss_ipv4_register_handler(void); -extern void nss_ipv4_reasm_register_handler(void); -extern void nss_ipv6_register_handler(void); -extern void nss_ipv6_reasm_register_handler(void); -extern void nss_n2h_register_handler(struct nss_ctx_instance *nss_ctx); -extern void nss_tunipip6_register_handler(void); -extern void nss_pppoe_register_handler(void); -extern void nss_freq_register_handler(void); -extern void nss_eth_rx_register_handler(struct nss_ctx_instance *nss_ctx); -extern void nss_edma_register_handler(void); -extern void nss_lag_register_handler(void); -extern void nss_dynamic_interface_register_handler(struct nss_ctx_instance *nss_ctx); -extern void nss_gre_redir_register_handler(void); -extern void nss_gre_redir_lag_us_register_handler(void); -extern void nss_gre_redir_lag_ds_register_handler(void); -extern void nss_lso_rx_register_handler(struct nss_ctx_instance *nss_ctx); -extern void nss_sjack_register_handler(void); -extern void nss_wifi_register_handler(void); -extern struct net_device *nss_tstamp_register_netdev(void); -extern void nss_tstamp_register_handler(struct net_device *ndev); -extern void nss_portid_register_handler(void); -extern void nss_oam_register_handler(void); -extern void nss_dtls_register_handler(void); -extern void nss_dtls_cmn_register_handler(void); -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_wifili_register_handler(void); -extern void nss_ppe_register_handler(void); -extern void nss_gre_redir_mark_register_handler(void); -extern void nss_ppe_vp_register_handler(void); -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); - -/* - * nss_if_msg_handler() - * External reference for internal base class handler for interface messages. - * - * This is not registered with nss_core.c as it is really a base class feature - * of the phys_if and virt_if handlers. - */ -extern void nss_if_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, - __attribute__((unused))void *app_data); - -#endif /* __NSS_TX_RX_COMMON_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_udp_st.c b/feeds/ipq807x/qca-nss-drv/src/nss_udp_st.c deleted file mode 100755 index eeab9ad03..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_udp_st.c +++ /dev/null @@ -1,233 +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_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. - */ -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. - */ -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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_log.c deleted file mode 100644 index bd4e07b20..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_log.c +++ /dev/null @@ -1,254 +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_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 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", -}; - -/* - * 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", - create, - msg_type, - create->rate, - create->buffer_size, - create->dscp); -} - -/* - * 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_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_RESET_STATS_MSG: - case NSS_UDP_ST_STATS_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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_log.h deleted file mode 100644 index fa2a551fb..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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__*/ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_stats.c deleted file mode 100755 index 0fee47b2e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_stats.c +++ /dev/null @@ -1,178 +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_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]; - -/* - * 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_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); - - 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; - } - 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]; - } - } - spin_unlock_bh(&nss_top->stats_lock); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_stats.h deleted file mode 100755 index 86b387da8..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_strings.c deleted file mode 100644 index 3b67b13b9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_strings.c +++ /dev/null @@ -1,151 +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_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}, -}; - -/* - * 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_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_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_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; - } - - return; -fail: - debugfs_remove_recursive(dir_d); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_strings.h deleted file mode 100644 index 6f5b513cf..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_udp_st_strings.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_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 void nss_udp_st_strings_dentry_create(void); - -#endif /* __NSS_UDP_ST_STRINGS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_unaligned.c b/feeds/ipq807x/qca-nss-drv/src/nss_unaligned.c deleted file mode 100644 index 099abdb0a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_unaligned.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_unaligned.c - * NSS unaligned APIs - */ - -#include "nss_tx_rx_common.h" -#include "nss_unaligned_stats.h" -#include "nss_unaligned_log.h" - -/* - * nss_unaligned_update_stats() - * Updates the statistics in the nss_ctx. - */ -static void nss_unaligned_update_stats(struct nss_ctx_instance *nss_ctx, - struct nss_unaligned_stats_msg *usm) -{ - uint32_t start_index = NSS_UNALIGNED_OPS_PER_MSG * usm->current_iteration; - uint32_t i; - spin_lock_bh(&nss_top_main.stats_lock); - nss_ctx->unaligned_stats.trap_count = usm->trap_count; - for (i = 0; i < NSS_UNALIGNED_OPS_PER_MSG; i++) { - uint32_t index = i + start_index; - if (unlikely(index >= NSS_UNALIGNED_EMULATED_OPS)) { - break; - } - nss_ctx->unaligned_stats.ops[index] = usm->ops[i]; - } - spin_unlock_bh(&nss_top_main.stats_lock); -} - -/* - * nss_unaligned_msg_handler() - * Handles metadata messages on the unaligned interface. - */ -static void nss_unaligned_msg_handler(struct nss_ctx_instance *nss_ctx, - struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_unaligned_msg *um = (struct nss_unaligned_msg *)ncm; - - /* - * Sanity checks on message - */ - if (um->cm.type >= NSS_UNALIGNED_MSG_MAX) { - 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("%px: message length is invalid: %d\n", nss_ctx, nss_cmn_get_msg_len(&(um->cm))); - return; - } - - nss_unaligned_log_rx_msg(um); - - switch (um->cm.type) { - case NSS_UNALIGNED_MSG_STATS: - nss_unaligned_update_stats(nss_ctx, &um->msg.stats_msg); - return; - } - - nss_core_log_msg_failures(nss_ctx, ncm); -} - -/* - * nss_unaligned_register_handler() - * Registers message handler on the NSS unaligned interface and stats dentry. - */ -void nss_unaligned_register_handler(struct nss_ctx_instance *nss_ctx) -{ - nss_core_register_handler(nss_ctx, NSS_UNALIGNED_INTERFACE, nss_unaligned_msg_handler, NULL); - - if (nss_ctx->id == NSS_CORE_0) { - nss_unaligned_stats_dentry_create(); - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_unaligned_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_unaligned_log.c deleted file mode 100644 index 079e2d76c..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_unaligned_log.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_unaligned_log.c - * NSS unaligned logger file. - */ - -#include "nss_core.h" - -/* - * nss_unaligned_log_message_types_str - * NSS unaligned message strings - */ -static int8_t *nss_unaligned_log_message_types_str[NSS_UNALIGNED_MSG_MAX] __maybe_unused = { - "Unaligned Stats Message", -}; - -/* - * nss_unaligned_log_verbose() - * Log message contents. - */ -static void nss_unaligned_log_verbose(struct nss_unaligned_msg *um) -{ - switch (um->cm.type) { - case NSS_UNALIGNED_MSG_STATS: - /* - * No log for valid stats message. - */ - break; - - default: - nss_trace("%px: Invalid message type\n", um); - break; - } -} - -/* - * nss_unaligned_log_rx_msg() - * Log messages received from FW. - */ -void nss_unaligned_log_rx_msg(struct nss_unaligned_msg *um) -{ - if (um->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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]); - -verbose: - nss_unaligned_log_verbose(um); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_unaligned_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_unaligned_log.h deleted file mode 100644 index 98ec707de..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_unaligned_log.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_UNALIGNED_LOG_H__ -#define __NSS_UNALIGNED_LOG_H__ - -/* - * nss_unaligned_log.h - * NSS Unaligned Log Header File. - */ - -/* - * nss_unaligned_log_rx_msg - * Logs an unaligned trap handler message that is received from the NSS firmware. - */ -void nss_unaligned_log_rx_msg(struct nss_unaligned_msg *um); - -#endif /* __NSS_UNALIGNED_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_unaligned_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_unaligned_stats.c deleted file mode 100644 index af0fd74be..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_unaligned_stats.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_unaligned_stats.h" - -/* - * nss_unaligned_stats_read() - * Read unaligned stats - */ -static ssize_t nss_unaligned_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - uint32_t max_output_lines = NSS_MAX_CORES * NSS_UNALIGNED_OPS_PER_MSG; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - size_t size_wr = 0; - ssize_t bytes_read = 0; - struct nss_unaligned_stats *stats_shadow; - uint32_t i, j; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(!lbuf)) { - nss_warning("Could not allocate memory for local statistics buffer"); - return 0; - } - - stats_shadow = kzalloc(NSS_MAX_CORES * sizeof(struct nss_unaligned_stats), GFP_KERNEL); - if (unlikely(!stats_shadow)) { - nss_warning("Could not allocate memory for local shadow buffer"); - kfree(lbuf); - return 0; - } - - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; i < NSS_MAX_CORES; i++) { - stats_shadow[i] = nss_top_main.nss[i].unaligned_stats; - } - spin_unlock_bh(&nss_top_main.stats_lock); - - for (i = 0; i < NSS_MAX_CORES; i++) { - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, - "core: %u, total unaligned traps: %llu\n", - i, stats_shadow[i].trap_count); - for (j = 0; j < NSS_UNALIGNED_OPS_PER_MSG; j++) { - struct nss_unaligned_stats_op op = stats_shadow[i].ops[j]; - if (op.count == 0) { - break; - } - - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, - "op: %2x, ext: %2x, count:%10llu, min: %10u, avg: %10u, max: %10u\n", - op.opcode_primary, op.opcode_extension, op.count, op.ticks_min, - op.ticks_avg, op.ticks_max); - } - } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(lbuf); - kfree(stats_shadow); - - return bytes_read; -} - -/* - * nss_unaligned_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(unaligned) - -/* - * nss_unaligned_stats_dentry_create() - * Create unaligned statistics debug entry. - */ -void nss_unaligned_stats_dentry_create(void) -{ - nss_stats_create_dentry("unaligned", &nss_unaligned_stats_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_unaligned_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_unaligned_stats.h deleted file mode 100644 index 761cda634..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_unaligned_stats.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_UNALIGNED_STATS_H -#define __NSS_UNALIGNED_STATS_H - -extern void nss_unaligned_stats_dentry_create(void); - -#endif diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_virt_if.c b/feeds/ipq807x/qca-nss-drv/src/nss_virt_if.c deleted file mode 100644 index b530517cf..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_virt_if.c +++ /dev/null @@ -1,736 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_virt_if.c - * NSS virtual/redirect handler APIs - */ - -#include "nss_tx_rx_common.h" -#include "nss_virt_if_stats.h" -#include - -#define NSS_VIRT_IF_TX_TIMEOUT 3000 /* 3 Seconds */ -#define NSS_VIRT_IF_GET_INDEX(if_num) (if_num-NSS_DYNAMIC_IF_START) - -extern int nss_ctl_redirect; - -/* - * Data structure that holds the virtual interface context. - */ -struct nss_virt_if_handle *nss_virt_if_handle_t[NSS_MAX_DYNAMIC_INTERFACES]; - -/* - * Spinlock to protect the global data structure virt_handle. - */ -DEFINE_SPINLOCK(nss_virt_if_lock); - -/* - * nss_virt_if_get_context() - */ -struct nss_ctx_instance *nss_virt_if_get_context(void) -{ - return &nss_top_main.nss[nss_top_main.virt_if_handler_id]; -} - -/* - * nss_virt_if_verify_if_num() - * Verify if_num passed to us. - */ -bool nss_virt_if_verify_if_num(uint32_t if_num) -{ - enum nss_dynamic_interface_type type = nss_dynamic_interface_get_type(nss_virt_if_get_context(), if_num); - - return type == NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H - || type == NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N; -} -EXPORT_SYMBOL(nss_virt_if_verify_if_num); - -/* - * nss_virt_if_msg_handler() - * Handle msg responses from the FW on virtual interfaces - */ -static void nss_virt_if_msg_handler(struct nss_ctx_instance *nss_ctx, - struct nss_cmn_msg *ncm, - void *app_data) -{ - struct nss_virt_if_msg *nvim = (struct nss_virt_if_msg *)ncm; - int32_t if_num; - - nss_virt_if_msg_callback_t cb; - struct nss_virt_if_handle *handle = NULL; - - /* - * Sanity check the message type - */ - if (ncm->type > NSS_VIRT_IF_MAX_MSG_TYPES) { - nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); - return; - } - - /* - * Messages value that are within the base class are handled by the base class. - */ - if (ncm->type < NSS_IF_MAX_MSG_TYPES) { - return nss_if_msg_handler(nss_ctx, ncm, app_data); - } - - if (!nss_virt_if_verify_if_num(ncm->interface)) { - nss_warning("%px: response for another interface: %d", nss_ctx, ncm->interface); - return; - } - - if_num = NSS_VIRT_IF_GET_INDEX(ncm->interface); - - spin_lock_bh(&nss_virt_if_lock); - if (!nss_virt_if_handle_t[if_num]) { - spin_unlock_bh(&nss_virt_if_lock); - nss_warning("%px: virt_if handle is NULL\n", nss_ctx); - return; - } - - handle = nss_virt_if_handle_t[if_num]; - spin_unlock_bh(&nss_virt_if_lock); - - switch (nvim->cm.type) { - case NSS_VIRT_IF_STATS_SYNC_MSG: - nss_virt_if_stats_sync(handle, &nvim->msg.stats); - break; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Update the callback and app_data for NOTIFY messages, IPv4 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 callback? - */ - if (!ncm->cb) { - return; - } - - /* - * Callback - */ - cb = (nss_virt_if_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, ncm); -} - -/* - * nss_virt_if_callback - * Callback to handle the completion of NSS ->HLOS messages. - */ -static void nss_virt_if_callback(void *app_data, struct nss_cmn_msg *ncm) -{ - struct nss_virt_if_handle *handle = (struct nss_virt_if_handle *)app_data; - struct nss_virt_if_pvt *nvip = handle->pvt; - - if (ncm->response != NSS_CMN_RESPONSE_ACK) { - nss_warning("%px: virt_if Error response %d\n", handle->nss_ctx, ncm->response); - nvip->response = NSS_TX_FAILURE; - complete(&nvip->complete); - return; - } - - nvip->response = NSS_TX_SUCCESS; - complete(&nvip->complete); -} - -/* - * nss_virt_if_tx_msg_sync - * Send a message from HLOS to NSS synchronously. - */ -static nss_tx_status_t nss_virt_if_tx_msg_sync(struct nss_virt_if_handle *handle, - struct nss_virt_if_msg *nvim) -{ - nss_tx_status_t status; - int ret = 0; - struct nss_virt_if_pvt *nwip = handle->pvt; - struct nss_ctx_instance *nss_ctx = handle->nss_ctx; - - down(&nwip->sem); - - status = nss_virt_if_tx_msg(nss_ctx, nvim); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: nss_virt_if_msg failed\n", nss_ctx); - up(&nwip->sem); - return status; - } - - ret = wait_for_completion_timeout(&nwip->complete, - msecs_to_jiffies(NSS_VIRT_IF_TX_TIMEOUT)); - if (!ret) { - nss_warning("%px: virt_if tx failed due to timeout\n", nss_ctx); - nwip->response = NSS_TX_FAILURE; - } - - status = nwip->response; - up(&nwip->sem); - - return status; -} - -/* - * nss_virt_if_msg_init() - * Initialize virt specific message structure. - */ -static void nss_virt_if_msg_init(struct nss_virt_if_msg *nvim, - uint16_t if_num, - uint32_t type, - uint32_t len, - nss_virt_if_msg_callback_t cb, - struct nss_virt_if_handle *app_data) -{ - nss_cmn_msg_init(&nvim->cm, if_num, type, len, (void *)cb, (void *)app_data); -} - -/* - * nss_virt_if_handle_destroy_sync() - * Destroy the virt handle either due to request from user or due to error, synchronously. - */ -static int nss_virt_if_handle_destroy_sync(struct nss_virt_if_handle *handle) -{ - nss_tx_status_t status; - int32_t if_num_n2h = handle->if_num_n2h; - int32_t if_num_h2n = handle->if_num_h2n; - int32_t index_n2h; - 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("%px: bad interface numbers %d %d\n", handle->nss_ctx, if_num_n2h, if_num_h2n); - return NSS_TX_FAILURE_BAD_PARAM; - } - - index_n2h = NSS_VIRT_IF_GET_INDEX(if_num_n2h); - index_h2n = NSS_VIRT_IF_GET_INDEX(if_num_h2n); - - status = nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H); - if (status != NSS_TX_SUCCESS) { - 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("%px: Dynamic interface destroy failed status %d\n", handle->nss_ctx, status); - return status; - } - - spin_lock_bh(&nss_virt_if_lock); - nss_virt_if_handle_t[index_n2h] = NULL; - nss_virt_if_handle_t[index_h2n] = NULL; - spin_unlock_bh(&nss_virt_if_lock); - - kfree(handle->pvt); - kfree(handle); - - return status; -} - -/* - * nss_virt_if_handle_create_sync() - * Initialize virt handle which holds the if_num and stats per interface. - */ -static struct nss_virt_if_handle *nss_virt_if_handle_create_sync(struct nss_ctx_instance *nss_ctx, int32_t if_num_n2h, int32_t if_num_h2n, int32_t *cmd_rsp) -{ - int32_t index_n2h; - int32_t index_h2n; - 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("%px: bad interface numbers %d %d\n", nss_ctx, if_num_n2h, if_num_h2n); - return NULL; - } - - index_n2h = NSS_VIRT_IF_GET_INDEX(if_num_n2h); - index_h2n = NSS_VIRT_IF_GET_INDEX(if_num_h2n); - - handle = (struct nss_virt_if_handle *)kzalloc(sizeof(struct nss_virt_if_handle), - GFP_KERNEL); - if (!handle) { - nss_warning("%px: handle memory alloc failed\n", nss_ctx); - *cmd_rsp = NSS_VIRT_IF_ALLOC_FAILURE; - goto error1; - } - - handle->nss_ctx = nss_ctx; - handle->if_num_n2h = if_num_n2h; - handle->if_num_h2n = if_num_h2n; - handle->pvt = (struct nss_virt_if_pvt *)kzalloc(sizeof(struct nss_virt_if_pvt), - GFP_KERNEL); - if (!handle->pvt) { - nss_warning("%px: failure allocating memory for nss_virt_if_pvt\n", nss_ctx); - *cmd_rsp = NSS_VIRT_IF_ALLOC_FAILURE; - goto error2; - } - - handle->cb = NULL; - handle->app_data = NULL; - - spin_lock_bh(&nss_virt_if_lock); - nss_virt_if_handle_t[index_n2h] = handle; - nss_virt_if_handle_t[index_h2n] = handle; - spin_unlock_bh(&nss_virt_if_lock); - - *cmd_rsp = NSS_VIRT_IF_SUCCESS; - - return handle; - -error2: - kfree(handle); -error1: - return NULL; -} - -/* - * nss_virt_if_register_handler_sync() - * register msg handler for virtual interface and initialize semaphore and completion. - */ -static uint32_t nss_virt_if_register_handler_sync(struct nss_ctx_instance *nss_ctx, struct nss_virt_if_handle *handle) -{ - uint32_t ret; - struct nss_virt_if_pvt *nvip = NULL; - int32_t if_num_n2h = handle->if_num_n2h; - int32_t if_num_h2n = handle->if_num_h2n; - - ret = nss_core_register_handler(nss_ctx, if_num_n2h, nss_virt_if_msg_handler, NULL); - if (ret != NSS_CORE_STATUS_SUCCESS) { - 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("%px: Failed to register message handler for redir_h2n interface %d\n", nss_ctx, if_num_h2n); - return NSS_VIRT_IF_CORE_FAILURE; - } - - nvip = handle->pvt; - if (!nvip->sem_init_done) { - sema_init(&nvip->sem, 1); - init_completion(&nvip->complete); - nvip->sem_init_done = 1; - } - - nss_virt_if_stats_dentry_create(); - return NSS_VIRT_IF_SUCCESS; -} - -/* - * nss_virt_if_create_sync_nexthop() - * Create redir_n2h and redir_h2n interfaces, synchronously and associate it with same netdev. - */ -struct nss_virt_if_handle *nss_virt_if_create_sync_nexthop(struct net_device *netdev, uint32_t nexthop_n2h, uint32_t nexthop_h2n) -{ - struct nss_ctx_instance *nss_ctx = nss_virt_if_get_context(); - struct nss_virt_if_msg nvim; - struct nss_virt_if_config_msg *nvcm; - uint32_t ret; - struct nss_virt_if_handle *handle = NULL; - int32_t if_num_n2h, if_num_h2n; - - 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; - } - - if_num_n2h = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H); - if (if_num_n2h < 0) { - 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("%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("%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; - } - - /* - * Initializes the semaphore and also sets the msg handler for if_num. - */ - ret = nss_virt_if_register_handler_sync(nss_ctx, handle); - if (ret != NSS_VIRT_IF_SUCCESS) { - nss_warning("%px: Registration handler failed reason: %d\n", nss_ctx, ret); - goto error1; - } - - nss_virt_if_msg_init(&nvim, handle->if_num_n2h, NSS_VIRT_IF_TX_CONFIG_MSG, - sizeof(struct nss_virt_if_config_msg), nss_virt_if_callback, handle); - - nvcm = &nvim.msg.if_config; - nvcm->flags = 0; - nvcm->sibling = if_num_h2n; - nvcm->nexthop = nexthop_n2h; - memcpy(nvcm->mac_addr, netdev->dev_addr, ETH_ALEN); - - ret = nss_virt_if_tx_msg_sync(handle, &nvim); - if (ret != NSS_TX_SUCCESS) { - nss_warning("%px: nss_virt_if_tx_msg_sync failed %u\n", nss_ctx, ret); - goto error2; - } - - nvim.cm.interface = if_num_h2n; - nvcm->sibling = if_num_n2h; - nvcm->nexthop = nexthop_h2n; - - ret = nss_virt_if_tx_msg_sync(handle, &nvim); - if (ret != NSS_TX_SUCCESS) { - nss_warning("%px: nss_virt_if_tx_msg_sync failed %u\n", nss_ctx, ret); - goto error2; - } - - nss_core_register_subsys_dp(nss_ctx, handle->if_num_n2h, NULL, NULL, NULL, netdev, 0); - nss_core_register_subsys_dp(nss_ctx, handle->if_num_h2n, NULL, NULL, NULL, netdev, 0); - - nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num_n2h, NSS_VIRT_IF_DP_REDIR_N2H); - nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num_h2n, NSS_VIRT_IF_DP_REDIR_H2N); - - /* - * Hold a reference to the net_device - */ - dev_hold(netdev); - - /* - * The context returned is the handle interface # which contains all the info related to - * the interface if_num. - */ - - return handle; - -error2: - nss_core_unregister_handler(nss_ctx, if_num_n2h); - nss_core_unregister_handler(nss_ctx, if_num_h2n); - -error1: - nss_virt_if_handle_destroy_sync(handle); - return NULL; -} -EXPORT_SYMBOL(nss_virt_if_create_sync_nexthop); - -/* - * nss_virt_if_create_sync() - * Create redir_n2h and redir_h2n interfaces, synchronously and associate it with same netdev. - * It uses the default nexthop interfaces. - * - * - */ -struct nss_virt_if_handle *nss_virt_if_create_sync(struct net_device *netdev) -{ - /* - * NSS_N2H_INTERFACE is the nexthop of the dynamic interface which is created for handling the - * n2h traffic. - * NSS_ETH_RX_INTERFACE is the nexthop of the dynamic interface which is created for handling the - * h2n traffic. - */ - return nss_virt_if_create_sync_nexthop(netdev, NSS_N2H_INTERFACE, NSS_ETH_RX_INTERFACE); -} -EXPORT_SYMBOL(nss_virt_if_create_sync); - -/* - * nss_virt_if_destroy_sync() - * Destroy the virt interface associated with the interface number, synchronously. - */ -nss_tx_status_t nss_virt_if_destroy_sync(struct nss_virt_if_handle *handle) -{ - nss_tx_status_t status; - struct net_device *dev; - int32_t if_num_n2h; - int32_t if_num_h2n; - struct nss_ctx_instance *nss_ctx; - uint32_t ret; - - if (!handle) { - nss_warning("handle is NULL\n"); - return NSS_TX_FAILURE_BAD_PARAM; - } - - if_num_n2h = handle->if_num_n2h; - if_num_h2n = handle->if_num_h2n; - 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_n2h].ndev || !nss_ctx->subsys_dp_register[if_num_h2n].ndev) { - spin_unlock_bh(&nss_top_main.lock); - 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; - } - - dev = nss_ctx->subsys_dp_register[if_num_n2h].ndev; - nss_assert(dev == nss_ctx->subsys_dp_register[if_num_h2n].ndev); - nss_core_unregister_subsys_dp(nss_ctx, if_num_n2h); - nss_core_unregister_subsys_dp(nss_ctx, if_num_h2n); - spin_unlock_bh(&nss_top_main.lock); - dev_put(dev); - - status = nss_virt_if_handle_destroy_sync(handle); - if (status != NSS_TX_SUCCESS) { - 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("%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("%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; - } - - return status; -} -EXPORT_SYMBOL(nss_virt_if_destroy_sync); - -/* - * nss_virt_if_tx_buf() - * HLOS interface has received a packet which we redirect to the NSS, if appropriate to do so. - */ -nss_tx_status_t nss_virt_if_tx_buf(struct nss_virt_if_handle *handle, - struct sk_buff *skb) -{ - int32_t if_num = handle->if_num_h2n; - struct nss_ctx_instance *nss_ctx = handle->nss_ctx; - int cpu = 0; - - if (unlikely(nss_ctl_redirect == 0)) { - return NSS_TX_FAILURE_NOT_ENABLED; - } - - if (unlikely(skb->vlan_tci)) { - return NSS_TX_FAILURE_NOT_SUPPORTED; - } - - if (!nss_virt_if_verify_if_num(if_num)) { - nss_warning("%px: bad interface number %d\n", nss_ctx, if_num); - return NSS_TX_FAILURE_BAD_PARAM; - } - - 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("%px: Virtual 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 | - H2N_BIT_FLAG_BUFFER_REUSABLE); -} -EXPORT_SYMBOL(nss_virt_if_tx_buf); - -/* - * nss_virt_if_tx_msg() - */ -nss_tx_status_t nss_virt_if_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_virt_if_msg *nvim) -{ - struct nss_cmn_msg *ncm = &nvim->cm; - - /* - * Sanity check the message - */ - if (!nss_virt_if_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_VIRT_IF_MAX_MSG_TYPES) { - nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, nvim, sizeof(*nvim), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_virt_if_tx_msg); - -/* - * nss_virt_if_xmit_callback_register() - * Register virtual interface xmit callback. - */ -void nss_virt_if_xmit_callback_register(struct nss_virt_if_handle *handle, - nss_virt_if_xmit_callback_t cb) -{ - struct nss_ctx_instance *nss_ctx; - struct nss_subsystem_dataplane_register *reg; - - if (!handle) { - nss_warning("handle is NULL\n"); - return; - } - - nss_ctx = handle->nss_ctx; - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (!nss_virt_if_verify_if_num(handle->if_num_n2h)) { - nss_warning("if_num is invalid\n"); - return; - } - - reg = &nss_ctx->subsys_dp_register[handle->if_num_n2h]; - reg->xmit_cb = cb; -} -EXPORT_SYMBOL(nss_virt_if_xmit_callback_register); - -/* - * nss_virt_if_xmit_callback_unregister() - * Unregister virtual interface xmit callback. - */ -void nss_virt_if_xmit_callback_unregister(struct nss_virt_if_handle *handle) -{ - struct nss_ctx_instance *nss_ctx; - struct nss_subsystem_dataplane_register *reg; - - if (!handle) { - nss_warning("handle is NULL\n"); - return; - } - - nss_ctx = handle->nss_ctx; - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (!nss_virt_if_verify_if_num(handle->if_num_n2h)) { - nss_warning("if_num is invalid\n"); - return; - } - - reg = &nss_ctx->subsys_dp_register[handle->if_num_n2h]; - reg->xmit_cb = NULL; -} -EXPORT_SYMBOL(nss_virt_if_xmit_callback_unregister); - -/* - * nss_virt_if_register() - */ -void nss_virt_if_register(struct nss_virt_if_handle *handle, - nss_virt_if_data_callback_t data_callback, - struct net_device *netdev) -{ - struct nss_ctx_instance *nss_ctx; - int32_t if_num; - uint32_t status; - - if (!handle) { - nss_warning("handle is NULL\n"); - return; - } - - nss_ctx = handle->nss_ctx; - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (!nss_virt_if_verify_if_num(handle->if_num_n2h)) { - nss_warning("if_num is invalid\n"); - return; - } - - if_num = handle->if_num_n2h; - - nss_core_register_subsys_dp(nss_ctx, if_num, data_callback, NULL, NULL, netdev, (uint32_t)netdev->features); - 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); - -/* - * nss_virt_if_unregister() - */ -void nss_virt_if_unregister(struct nss_virt_if_handle *handle) -{ - struct nss_ctx_instance *nss_ctx; - int32_t if_num; - uint32_t status; - - if (!handle) { - nss_warning("handle is NULL\n"); - return; - } - - nss_ctx = handle->nss_ctx; - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (!nss_virt_if_verify_if_num(handle->if_num_n2h)) { - nss_warning("if_num is invalid\n"); - return; - } - - if_num = handle->if_num_n2h; - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - 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); - -/* - * nss_virt_if_get_interface_num() - * Get interface number for a virtual interface - */ -int32_t nss_virt_if_get_interface_num(struct nss_virt_if_handle *handle) -{ - if (!handle) { - nss_warning("virt_if handle is NULL\n"); - return -1; - } - - /* - * Return if_num_n2h whose datapath type is 0. - */ - return handle->if_num_n2h; -} -EXPORT_SYMBOL(nss_virt_if_get_interface_num); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_virt_if_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_virt_if_stats.c deleted file mode 100644 index d43b72c3d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_virt_if_stats.c +++ /dev/null @@ -1,339 +0,0 @@ -/* - ************************************************************************** - * 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_virt_if_stats.h" - -/* - * Data structure that holds the virtual interface context. - */ -extern struct nss_virt_if_handle *nss_virt_if_handle_t[]; - -/* - * Spinlock to protect the global data structure virt_handle. - */ -extern spinlock_t nss_virt_if_lock; - -/* - * nss_virt_if_base_node_stats_str - * virt_if base node stats strings - */ -static int8_t *nss_virt_if_base_node_stats_str[NSS_VIRT_IF_BASE_NODE_STATS_MAX] = { - "active_interfaces", - "ocm_alloc_failed", - "ddr_alloc_failed", -}; - -/* - * nss_virt_if_interface_stats_str - * virt_if interface stats strings - */ -static int8_t *nss_virt_if_interface_stats_str[NSS_VIRT_IF_INTERFACE_STATS_MAX] = { - "rx_packets", - "rx_bytes", - "rx_dropped", - "tx_packets", - "tx_bytes", - "tx_enqueue_failed", - "shaper_enqueue_failed", - "ocm_alloc_failed", -}; - -/* - * nss_virt_if_base_node_stats_fill_row() - * Fill one row of virt_if base node stats. - */ -static int32_t nss_virt_if_base_node_stats_fill_row(char *line, int len, int start, struct nss_virt_if_base_node_stats *stats) -{ - uint64_t tcnt = 0; - switch (start) { - case NSS_VIRT_IF_BASE_NODE_STATS_ACTIVE_INTERFACES: - tcnt = stats->active_interfaces; - break; - - case NSS_VIRT_IF_BASE_NODE_STATS_OCM_ALLOC_FAILED: - tcnt = stats->ocm_alloc_failed; - break; - - case NSS_VIRT_IF_BASE_NODE_STATS_DDR_ALLOC_FAILED: - tcnt = stats->ddr_alloc_failed; - break; - - default: - return 0; - } - - return scnprintf(line, len, "%s = %llu\n", nss_virt_if_base_node_stats_str[start], tcnt); -} - -/* - * nss_virt_if_interface_stats_fill_row() - * Fill one row of virt_if interface stats. - */ -static int32_t nss_virt_if_interface_stats_fill_row(char *line, int len, int start, struct nss_virt_if_interface_stats *stats) -{ - uint64_t tcnt = 0; - switch (start) { - case NSS_VIRT_IF_INTERFACE_STATS_RX_PACKETS: - tcnt = stats->node_stats.rx_packets; - break; - - case NSS_VIRT_IF_INTERFACE_STATS_RX_BYTES: - tcnt = stats->node_stats.rx_bytes; - break; - - case NSS_VIRT_IF_INTERFACE_STATS_RX_DROPPED: - tcnt = nss_cmn_rx_dropped_sum(&stats->node_stats); - break; - - case NSS_VIRT_IF_INTERFACE_STATS_TX_PACKETS: - tcnt = stats->node_stats.tx_packets; - break; - - case NSS_VIRT_IF_INTERFACE_STATS_TX_BYTES: - tcnt = stats->node_stats.tx_bytes; - break; - - case NSS_VIRT_IF_INTERFACE_STATS_TX_ENQUEUE_FAILED: - tcnt = stats->tx_enqueue_failed; - break; - - case NSS_VIRT_IF_INTERFACE_STATS_SHAPER_ENQUEUE_FAILED: - tcnt = stats->shaper_enqueue_failed; - break; - - case NSS_VIRT_IF_INTERFACE_STATS_OCM_ALLOC_FAILED: - tcnt = stats->ocm_alloc_failed; - break; - - default: - return 0; - } - - return scnprintf(line, len, "%s = %llu\n", nss_virt_if_interface_stats_str[start], tcnt); -} - -/* - * nss_virt_if_stats_get() - * Get virt_if base node stats or interface stats by interface number. - */ -bool nss_virt_if_stats_get(struct nss_ctx_instance *nss_ctx, uint32_t if_num, void *stats, bool is_base) -{ - if (nss_virt_if_verify_if_num(if_num) == false) { - return false; - } - - /* - * Statistics for redir_h2n and redir_n2h are collected on redir_h2n in NSS. - */ - if (nss_dynamic_interface_get_type(nss_ctx, if_num) != NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N) - return false; - - if_num = if_num - NSS_DYNAMIC_IF_START; - spin_lock_bh(&nss_virt_if_lock); - if (!nss_virt_if_handle_t[if_num]) { - spin_unlock_bh(&nss_virt_if_lock); - return false; - } - - /* - * Check if it is base node statistics or interface statistics. - */ - if (is_base) { - memcpy((struct nss_virt_if_base_node_stats *)stats, - &nss_virt_if_handle_t[if_num]->stats.base_stats, - sizeof(struct nss_virt_if_base_node_stats)); - } else { - memcpy((struct nss_virt_if_interface_stats *)stats, - &nss_virt_if_handle_t[if_num]->stats.if_stats, - sizeof(struct nss_virt_if_interface_stats)); - } - - spin_unlock_bh(&nss_virt_if_lock); - return true; -} - -/* - * nss_virt_if_stats_read() - * Read virt_if statistics - */ -static ssize_t nss_virt_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 = nss_virt_if_get_context(); - 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; - int32_t if_num_valid = NSS_DYNAMIC_IF_START - 1; - struct nss_virt_if_base_node_stats base_node_stats_local; - struct nss_virt_if_interface_stats interface_stats_local; - - if (data) { - if_num = data->if_num; - } - - if (if_num > max_if_num) { - return 0; - } - - /* - * Interface statistics for all virtual interface pairs. - */ - for (; if_num < max_if_num; if_num++) { - - if (!nss_virt_if_stats_get(nss_ctx, if_num, &interface_stats_local, false)) - 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) - return -EFAULT; - - bytes_read += bytes; - - start = NSS_VIRT_IF_INTERFACE_STATS_RX_PACKETS; - end = NSS_VIRT_IF_INTERFACE_STATS_MAX; - while (bytes_read < sz && start < end) { - bytes = nss_virt_if_interface_stats_fill_row(line, sizeof(line), start, &interface_stats_local); - if (!bytes) - break; - - if ((bytes_read + bytes) > sz) - break; - - if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) - return -EFAULT; - - bytes_read += bytes; - start++; - } - - /* - * Save one valid interface number for base node statistics. - */ - if_num_valid = if_num; - - 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) - return -EFAULT; - - bytes_read += bytes; - } - - /* - * Base node statistics. - */ - if (!nss_virt_if_stats_get(nss_ctx, if_num_valid, &base_node_stats_local, true)) - goto done; - - bytes = scnprintf(line, sizeof(line), "base node stats begin (shown on if_num %d):\n\n", if_num_valid); - if ((bytes_read + bytes) > sz) - goto done; - - if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) - return -EFAULT; - - bytes_read += bytes; - - start = NSS_VIRT_IF_BASE_NODE_STATS_ACTIVE_INTERFACES; - end = NSS_VIRT_IF_BASE_NODE_STATS_MAX; - while (bytes_read < sz && start < end) { - bytes = nss_virt_if_base_node_stats_fill_row(line, sizeof(line), start, &base_node_stats_local); - if (!bytes) - break; - - if ((bytes_read + bytes) > sz) - break; - - if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) - return -EFAULT; - - bytes_read += bytes; - start++; - } - - bytes = scnprintf(line, sizeof(line), "base node stats end.\n\n"); - if ((bytes_read + bytes) > sz) - goto done; - - if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) - return -EFAULT; - - bytes_read += bytes; - -done: - if (bytes_read > 0) { - *ppos = bytes_read; - } - - if (data) { - data->if_num = if_num; - } - - return bytes_read; -} - -/* - * nss_virt_if_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(virt_if) - -/* - * nss_virt_if_stats_dentry_create() - * Create virt_if statistics debug entry. - */ -void nss_virt_if_stats_dentry_create(void) -{ - nss_stats_create_dentry("virt_if", &nss_virt_if_stats_ops); -} - -/* - * nss_virt_if_stats_sync() - * Sync stats from the NSS FW - */ -void nss_virt_if_stats_sync(struct nss_virt_if_handle *handle, - struct nss_virt_if_stats *nwis) -{ - struct nss_virt_if_stats *stats = &handle->stats; - int i; - - spin_lock_bh(&nss_virt_if_lock); - stats->if_stats.node_stats.rx_packets += nwis->if_stats.node_stats.rx_packets; - stats->if_stats.node_stats.rx_bytes += nwis->if_stats.node_stats.rx_bytes; - stats->if_stats.node_stats.tx_packets += nwis->if_stats.node_stats.tx_packets; - stats->if_stats.node_stats.tx_bytes += nwis->if_stats.node_stats.tx_bytes; - - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - stats->if_stats.node_stats.rx_dropped[i] += nwis->if_stats.node_stats.rx_dropped[i]; - } - - stats->if_stats.tx_enqueue_failed += nwis->if_stats.tx_enqueue_failed; - stats->if_stats.shaper_enqueue_failed += nwis->if_stats.shaper_enqueue_failed; - stats->if_stats.ocm_alloc_failed += nwis->if_stats.ocm_alloc_failed; - - stats->base_stats.active_interfaces = nwis->base_stats.active_interfaces; - stats->base_stats.ocm_alloc_failed = nwis->base_stats.ocm_alloc_failed; - stats->base_stats.ddr_alloc_failed = nwis->base_stats.ddr_alloc_failed; - spin_unlock_bh(&nss_virt_if_lock); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_virt_if_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_virt_if_stats.h deleted file mode 100644 index 0c26fac92..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_virt_if_stats.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_VIRT_IF_STATS_H -#define __NSS_VIRT_IF_STATS_H - -/* - * virt_if base node statistics types. - */ -enum nss_virt_if_base_node_stats_types { - NSS_VIRT_IF_BASE_NODE_STATS_ACTIVE_INTERFACES, /* Number of active virtual interfaces */ - NSS_VIRT_IF_BASE_NODE_STATS_OCM_ALLOC_FAILED, /* Number of interface allocation failure on OCM */ - NSS_VIRT_IF_BASE_NODE_STATS_DDR_ALLOC_FAILED, /* Number of interface allocation failure on DDR */ - NSS_VIRT_IF_BASE_NODE_STATS_MAX, -}; - -/* - * virt_if interface statistics types. - */ -enum nss_virt_if_interface_stats_types { - NSS_VIRT_IF_INTERFACE_STATS_RX_PACKETS, /* Rx packets */ - NSS_VIRT_IF_INTERFACE_STATS_RX_BYTES, /* Rx bytes */ - NSS_VIRT_IF_INTERFACE_STATS_RX_DROPPED, /* Rx drop count */ - NSS_VIRT_IF_INTERFACE_STATS_TX_PACKETS, /* Tx packets */ - NSS_VIRT_IF_INTERFACE_STATS_TX_BYTES, /* Tx bytes */ - NSS_VIRT_IF_INTERFACE_STATS_TX_ENQUEUE_FAILED, /* Number of Tx enqueue failure */ - NSS_VIRT_IF_INTERFACE_STATS_SHAPER_ENQUEUE_FAILED, /* Number of shaper enqueue failure */ - NSS_VIRT_IF_INTERFACE_STATS_OCM_ALLOC_FAILED, /* Number of interface allocation failure on OCM */ - NSS_VIRT_IF_INTERFACE_STATS_MAX, -}; - -/* - * Virtual interface statistics APIs - */ -extern void nss_virt_if_stats_sync(struct nss_virt_if_handle *handle, struct nss_virt_if_stats *nwis); -extern void nss_virt_if_stats_dentry_create(void); - -#endif /* __NSS_VIRT_IF_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_vlan.c b/feeds/ipq807x/qca-nss-drv/src/nss_vlan.c deleted file mode 100644 index 23b5c0ba5..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_vlan.c +++ /dev/null @@ -1,411 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_vlan_log.h" - -#define NSS_VLAN_TX_TIMEOUT 1000 /* 1 Second */ - -/* - * Private data structure - */ -static struct nss_vlan_pvt { - struct semaphore sem; - struct completion complete; - int response; - void *cb; - void *app_data; -} vlan_pvt; - -/* - * nss_vlan_get_context() - */ -struct nss_ctx_instance *nss_vlan_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.vlan_handler_id]; -} -EXPORT_SYMBOL(nss_vlan_get_context); - -/* - * nss_vlan_verify_if_num() - * Verify if_num passed to us. - */ -static bool nss_vlan_verify_if_num(uint32_t if_num) -{ - if (!nss_is_dynamic_interface(if_num)) { - return false; - } - - if (nss_dynamic_interface_get_type(nss_vlan_get_context(), if_num) != NSS_DYNAMIC_INTERFACE_TYPE_VLAN) { - return false; - } - - return true; -} - -/* - * nss_vlan_handler() - * Handle NSS -> HLOS messages for vlan - */ -static void nss_vlan_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *app_data) -{ - struct nss_vlan_msg *nvm = (struct nss_vlan_msg *)ncm; - nss_vlan_msg_callback_t cb; - - nss_assert(nss_vlan_verify_if_num(ncm->interface)); - - /* - * Trace messages. - */ - nss_vlan_log_rx_msg(nvm); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_VLAN_MSG_TYPE_MAX) { - 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("%px: length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Update the callback and app_data for NOTIFY messages, vlan sends all notify messages - * to the same callback/app_data. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->vlan_callback; - ncm->app_data = (nss_ptr_t)app_data; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Do we have a call back - */ - if (!ncm->cb) { - return; - } - - /* - * callback - */ - cb = (nss_vlan_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, nvm); -} - -/* - * nss_vlan_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_vlan_callback(void *app_data, struct nss_vlan_msg *nvm) -{ - nss_vlan_msg_callback_t callback = (nss_vlan_msg_callback_t)vlan_pvt.cb; - void *data = vlan_pvt.app_data; - - vlan_pvt.response = NSS_TX_SUCCESS; - vlan_pvt.cb = NULL; - vlan_pvt.app_data = NULL; - - if (nvm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("vlan error response %d\n", nvm->cm.response); - vlan_pvt.response = nvm->cm.response; - } - - if (callback) { - callback(data, nvm); - } - complete(&vlan_pvt.complete); -} - -/* - * nss_vlan_tx_msg() - * Transmit a vlan message to NSSFW - */ -nss_tx_status_t nss_vlan_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_vlan_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace messages. - */ - nss_vlan_log_tx_msg(msg); - - /* - * Sanity check the message - */ - if (!nss_vlan_verify_if_num(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("%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); -} -EXPORT_SYMBOL(nss_vlan_tx_msg); - -/* - * nss_vlan_tx_msg_sync() - * Transmit a vlan message to NSS firmware synchronously. - */ -nss_tx_status_t nss_vlan_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_vlan_msg *nvm) -{ - nss_tx_status_t status; - int ret = 0; - - down(&vlan_pvt.sem); - vlan_pvt.cb = (void *)nvm->cm.cb; - vlan_pvt.app_data = (void *)nvm->cm.app_data; - - nvm->cm.cb = (nss_ptr_t)nss_vlan_callback; - nvm->cm.app_data = (nss_ptr_t)NULL; - - status = nss_vlan_tx_msg(nss_ctx, nvm); - if (status != NSS_TX_SUCCESS) { - 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("%px: vlan msg tx failed due to timeout\n", nss_ctx); - vlan_pvt.response = NSS_TX_FAILURE; - } - - status = vlan_pvt.response; - up(&vlan_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_vlan_tx_msg_sync); - -/* - * nss_vlan_msg_init() - * Initialize nss_vlan_msg. - */ -void nss_vlan_msg_init(struct nss_vlan_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} -EXPORT_SYMBOL(nss_vlan_msg_init); - -/* - * nss_vlan_tx_change_mtu_msg - * API to send change mtu message to NSS FW - */ -nss_tx_status_t nss_vlan_tx_set_mtu_msg(uint32_t vlan_if_num, uint32_t mtu) -{ - struct nss_ctx_instance *nss_ctx = nss_vlan_get_context(); - struct nss_vlan_msg nvm; - struct nss_if_mtu_change *nimc; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - if (nss_vlan_verify_if_num(vlan_if_num) == false) { - nss_warning("%px: received invalid interface %d", nss_ctx, vlan_if_num); - return NSS_TX_FAILURE; - } - - nss_vlan_msg_init(&nvm, vlan_if_num, NSS_IF_MTU_CHANGE, - sizeof(struct nss_if_mtu_change), NULL, NULL); - - nimc = &nvm.msg.if_msg.mtu_change; - nimc->min_buf_size = (uint16_t)mtu; - - return nss_vlan_tx_msg_sync(nss_ctx, &nvm); -} -EXPORT_SYMBOL(nss_vlan_tx_set_mtu_msg); - -/* - * nss_vlan_tx_set_mac_addr_msg - * API to send change mac addr message to NSS FW - */ -nss_tx_status_t nss_vlan_tx_set_mac_addr_msg(uint32_t vlan_if_num, uint8_t *addr) -{ - struct nss_ctx_instance *nss_ctx = nss_vlan_get_context(); - struct nss_vlan_msg nvm; - struct nss_if_mac_address_set *nmas; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - if (nss_vlan_verify_if_num(vlan_if_num) == false) { - nss_warning("%px: received invalid interface %d", nss_ctx, vlan_if_num); - return NSS_TX_FAILURE; - } - - nss_vlan_msg_init(&nvm, vlan_if_num, NSS_IF_MAC_ADDR_SET, - sizeof(struct nss_if_mac_address_set), NULL, NULL); - - nmas = &nvm.msg.if_msg.mac_address_set; - memcpy(nmas->mac_addr, addr, ETH_ALEN); - return nss_vlan_tx_msg_sync(nss_ctx, &nvm); -} -EXPORT_SYMBOL(nss_vlan_tx_set_mac_addr_msg); - -/* - * nss_vlan_tx_vsi_attach_msg - * API to send VSI attach message to NSS FW - */ -nss_tx_status_t nss_vlan_tx_vsi_attach_msg(uint32_t vlan_if_num, uint32_t vsi) -{ - struct nss_ctx_instance *nss_ctx = nss_vlan_get_context(); - struct nss_vlan_msg nvm; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - if (nss_vlan_verify_if_num(vlan_if_num) == false) { - nss_warning("%px: received invalid interface %d\n", nss_ctx, vlan_if_num); - return NSS_TX_FAILURE; - } - - nvm.msg.if_msg.vsi_assign.vsi = vsi; - nss_vlan_msg_init(&nvm, vlan_if_num, NSS_IF_VSI_ASSIGN, - sizeof(struct nss_if_vsi_assign), NULL, NULL); - - return nss_vlan_tx_msg_sync(nss_ctx, &nvm); -} -EXPORT_SYMBOL(nss_vlan_tx_vsi_attach_msg); - -/* - * nss_vlan_tx_vsi_detach_msg - * API to send VSI detach message to NSS FW - */ -nss_tx_status_t nss_vlan_tx_vsi_detach_msg(uint32_t vlan_if_num, uint32_t vsi) -{ - struct nss_ctx_instance *nss_ctx = nss_vlan_get_context(); - struct nss_vlan_msg nvm; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - if (nss_vlan_verify_if_num(vlan_if_num) == false) { - nss_warning("%px: received invalid interface %d\n", nss_ctx, vlan_if_num); - return NSS_TX_FAILURE; - } - - nvm.msg.if_msg.vsi_unassign.vsi = vsi; - nss_vlan_msg_init(&nvm, vlan_if_num, NSS_IF_VSI_UNASSIGN, - sizeof(struct nss_if_vsi_unassign), NULL, NULL); - - return nss_vlan_tx_msg_sync(nss_ctx, &nvm); -} -EXPORT_SYMBOL(nss_vlan_tx_vsi_detach_msg); - -/* - * nss_vlan_tx_add_tag_msg - * API to send vlan add tag message to NSS FW - */ -nss_tx_status_t nss_vlan_tx_add_tag_msg(uint32_t vlan_if_num, uint32_t vlan_tag, uint32_t next_hop, uint32_t physical_dev) -{ - struct nss_ctx_instance *nss_ctx = nss_vlan_get_context(); - struct nss_vlan_msg nvm; - - if (!nss_ctx) { - nss_warning("Can't get nss context\n"); - return NSS_TX_FAILURE; - } - - if (nss_vlan_verify_if_num(vlan_if_num) == false) { - nss_warning("%px: received invalid interface %d\n", nss_ctx, vlan_if_num); - return NSS_TX_FAILURE; - } - - nvm.msg.add_tag.next_hop = next_hop; - nvm.msg.add_tag.if_num = physical_dev; - nvm.msg.add_tag.vlan_tag = vlan_tag; - nss_vlan_msg_init(&nvm, vlan_if_num, NSS_VLAN_MSG_ADD_TAG, - sizeof(struct nss_vlan_msg_add_tag), NULL, NULL); - - return nss_vlan_tx_msg_sync(nss_ctx, &nvm); -} -EXPORT_SYMBOL(nss_vlan_tx_add_tag_msg); - -/** - * @brief Register to send/receive vlan messages to NSS - * - * @param if_num NSS interface number - * @param vlan_data_callback Callback for vlan data - * @param netdev netdevice associated with the vlan interface - * @param features denotes the skb types supported by this interface - * - * @return nss_ctx_instance* NSS context - */ -struct nss_ctx_instance *nss_register_vlan_if(uint32_t if_num, nss_vlan_callback_t vlan_data_callback, - struct net_device *netdev, uint32_t features, void *app_ctx) -{ - struct nss_ctx_instance *nss_ctx = nss_vlan_get_context(); - - nss_assert(nss_vlan_verify_if_num(if_num)); - - nss_core_register_subsys_dp(nss_ctx, if_num, vlan_data_callback, NULL, app_ctx, netdev, features); - - nss_core_register_handler(nss_ctx, if_num, nss_vlan_handler, app_ctx); - - return nss_ctx; -} -EXPORT_SYMBOL(nss_register_vlan_if); - -/* - * nss_unregister_vlan_if() - */ -void nss_unregister_vlan_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_vlan_get_context(); - - nss_assert(nss_vlan_verify_if_num(if_num)); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); - - nss_core_unregister_handler(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_unregister_vlan_if); - -/* - * nss_vlan_register_handler() - * debugfs stats msg handler received on static vlan interface - */ -void nss_vlan_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = nss_vlan_get_context(); - - nss_info("nss_vlan_register_handler\n"); - nss_core_register_handler(nss_ctx, NSS_VLAN_INTERFACE, nss_vlan_handler, NULL); - - sema_init(&vlan_pvt.sem, 1); - init_completion(&vlan_pvt.complete); -} -EXPORT_SYMBOL(nss_vlan_register_handler); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_vlan_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_vlan_log.c deleted file mode 100644 index b9e946a74..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_vlan_log.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_vlan_log.c - * NSS VLAN logger file. - */ - -#include "nss_core.h" - -/* - * nss_vlan_log_message_types_str - * VLAN message strings - */ -static int8_t *nss_vlan_log_message_types_str[NSS_VLAN_MSG_TYPE_MAX] __maybe_unused = { - "VLAN ADD TAG", -}; - -/* - * nss_vlan_log_error_response_types_str - * Strings for error types for VLAN messages - */ -static int8_t *nss_vlan_log_error_response_types_str[NSS_VLAN_ERROR_TYPE_MAX] __maybe_unused = { - "VLAN Unknown Message", -}; - -/* - * nss_vlan_log_add_tag_msg() - * Log NSS VLAN Add Tag message. - */ -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("%px: NSS VLAN Add Tag Message:\n" - "VLAN Tag: %d\n" - "VLAN Next Hop: %d\n" - "VLAN Interface Number: %d\n", - nvtm, nvtm->vlan_tag, - nvtm->next_hop, nvtm->if_num); -} - -/* - * nss_vlan_log_verbose() - * Log message contents. - */ -static void nss_vlan_log_verbose(struct nss_vlan_msg *nvm) -{ - switch (nvm->cm.type) { - case NSS_VLAN_MSG_ADD_TAG: - nss_vlan_log_add_tag_msg(nvm); - break; - - default: - nss_warning("%px: Invalid message type\n", nvm); - break; - } -} - -/* - * nss_vlan_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_vlan_log_tx_msg(struct nss_vlan_msg *nvm) -{ - if (nvm->cm.type >= NSS_VLAN_MSG_TYPE_MAX) { - nss_warning("%px: Invalid message type\n", nvm); - return; - } - - 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); -} - -/* - * nss_vlan_log_rx_msg() - * Log messages received from FW. - */ -void nss_vlan_log_rx_msg(struct nss_vlan_msg *nvm) -{ - if (nvm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_vlan_log_verbose(nvm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_vlan_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_vlan_log.h deleted file mode 100644 index 21b365d15..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_vlan_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_VLAN_LOG_H__ -#define __NSS_VLAN_LOG_H__ - -/* - * nss_vlan_log.h - * NSS VLAN Log Header File - */ - -/* - * nss_vlan_log_tx_msg - * Logs a vlan message that is sent to the NSS firmware. - */ -void nss_vlan_log_tx_msg(struct nss_vlan_msg *ncm); - -/* - * nss_vlan_log_rx_msg - * Logs a vlan message that is received from the NSS firmware. - */ -void nss_vlan_log_rx_msg(struct nss_vlan_msg *ncm); - -#endif /* __NSS_VLAN_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_vxlan.c b/feeds/ipq807x/qca-nss-drv/src/nss_vxlan.c deleted file mode 100644 index bde299663..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_vxlan.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_vxlan.c - * NSS VxLAN driver interface APIs - */ -#include "nss_core.h" -#include "nss_vxlan.h" -#include "nss_cmn.h" -#include "nss_tx_rx_common.h" -#include "nss_vxlan_log.h" -#include "nss_vxlan_stats.h" - -#define NSS_VXLAN_TX_TIMEOUT 3000 - -/* - * Private data structure - */ -static struct { - 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. */ -} nss_vxlan_pvt; - -/* - * nss_vxlan_verify_if_num() - * Verify if_num passed to us. - */ -static bool nss_vxlan_verify_if_num(uint32_t if_num) -{ - uint32_t type; - - if (if_num == NSS_VXLAN_INTERFACE) { - return true; - } - - type = nss_dynamic_interface_get_type(nss_vxlan_get_ctx(), if_num); - - return ((type == NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_INNER) || - (type == NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_OUTER)); -} - -/* - * nss_vxlan_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_vxlan_callback(void *app_data, struct nss_cmn_msg *msg) -{ - nss_vxlan_msg_callback_t callback = (nss_vxlan_msg_callback_t)nss_vxlan_pvt.cb; - void *data = nss_vxlan_pvt.app_data; - - nss_vxlan_pvt.response = NSS_TX_SUCCESS; - nss_vxlan_pvt.cb = NULL; - nss_vxlan_pvt.app_data = NULL; - - if (msg->response != NSS_CMN_RESPONSE_ACK) { - nss_warning("Vxlan Error response %d\n", msg->response); - nss_vxlan_pvt.response = NSS_TX_FAILURE; - } - - if (callback) { - callback(data, msg); - } - complete(&nss_vxlan_pvt.complete); -} - -/* - * nss_vxlan_handler() - * Handle NSS -> HLOS messages for vxlan. - */ -static void nss_vxlan_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_vxlan_msg *nvm = (struct nss_vxlan_msg *)ncm; - nss_vxlan_msg_callback_t cb; - - BUG_ON(!nss_vxlan_verify_if_num(ncm->interface)); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_VXLAN_MSG_TYPE_MAX) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Log messages. - */ - nss_core_log_msg_failures(nss_ctx, ncm); - nss_vxlan_log_rx_msg(nvm); - - switch (nvm->cm.type) { - case NSS_VXLAN_MSG_TYPE_STATS_SYNC: - /* - * Update common node statistics - */ - nss_vxlan_stats_sync(nss_ctx, nvm); - } - - /* - * Update the callback for NOTIFY messages - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); - } - - cb = (nss_vxlan_msg_callback_t)ncm->cb; - - /* - * Do we have a callback? - */ - if (!cb) { - nss_trace("%px: cb is null for interface %d\n", nss_ctx, ncm->interface); - return; - } - - cb((void *)nss_ctx->subsys_dp_register[ncm->interface].ndev, ncm); -} - -/* - * nss_vxlan_tx_msg() - * Transmit a vxlan message to NSS FW. Don't call this from softirq/interrupts. - */ -nss_tx_status_t nss_vxlan_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_vxlan_msg *nvm) -{ - struct nss_cmn_msg *ncm = &nvm->cm; - - if (!nss_vxlan_verify_if_num(ncm->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("%px: wrong message type %u\n", nss_ctx, ncm->type); - return NSS_TX_FAILURE_BAD_PARAM; - } - - /* - * Trace messages. - */ - nss_vxlan_log_tx_msg(nvm); - - return nss_core_send_cmd(nss_ctx, nvm, sizeof(*nvm), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_vxlan_tx_msg); - -/* - * nss_vxlan_tx_msg_sync() - * Transmit a vxlan message to NSS firmware synchronously. - */ -nss_tx_status_t nss_vxlan_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_vxlan_msg *nvm) -{ - nss_tx_status_t status; - int ret; - - down(&nss_vxlan_pvt.sem); - nss_vxlan_pvt.cb = (void *)nvm->cm.cb; - nss_vxlan_pvt.app_data = (void *)nvm->cm.app_data; - - nvm->cm.cb = (nss_ptr_t)nss_vxlan_callback; - nvm->cm.app_data = (nss_ptr_t)NULL; - - status = nss_vxlan_tx_msg(nss_ctx, nvm); - if (status != NSS_TX_SUCCESS) { - 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("%px: vxlan tx sync failed due to timeout\n", nss_ctx); - nss_vxlan_pvt.response = NSS_TX_FAILURE; - } - - status = nss_vxlan_pvt.response; - up(&nss_vxlan_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_vxlan_tx_msg_sync); - -/* - * nss_vxlan_msg_init() - * Initialize VxLAN message. - */ -void nss_vxlan_msg_init(struct nss_vxlan_msg *nvm, uint16_t if_num, uint32_t type, uint32_t len, - nss_vxlan_msg_callback_t cb, void *app_data) -{ - nss_cmn_msg_init(&nvm->cm, if_num, type, len, (void*)cb, app_data); -} -EXPORT_SYMBOL(nss_vxlan_msg_init); - -/* - * nss_vxlan_unregister_if() - * Unregister a data packet notifier with NSS FW. - */ -bool nss_vxlan_unregister_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx; - - nss_ctx = nss_vxlan_get_ctx(); - if (!nss_vxlan_verify_if_num(if_num)) { - nss_warning("%px: data unregister received for invalid interface %d", nss_ctx, if_num); - return false; - } - - nss_core_unregister_handler(nss_ctx, if_num); - nss_core_unregister_subsys_dp(nss_ctx, if_num); - return true; -} -EXPORT_SYMBOL(nss_vxlan_unregister_if); - -/* - * nss_vxlan_register_if() - * Registers a data packet notifier with NSS FW. - */ -struct nss_ctx_instance *nss_vxlan_register_if(uint32_t if_num, - uint32_t type, - nss_vxlan_buf_callback_t data_cb, - nss_vxlan_msg_callback_t notify_cb, - struct net_device *netdev, - uint32_t features) -{ - struct nss_ctx_instance *nss_ctx; - int core_status; - - nss_ctx = nss_vxlan_get_ctx(); - if (!nss_vxlan_verify_if_num(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("%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); - return nss_ctx; -} -EXPORT_SYMBOL(nss_vxlan_register_if); - -/* - * nss_vxlan_ifnum_with_core_id() - * Append core id to vxlan interface num. - */ -int nss_vxlan_ifnum_with_core_id(int if_num) -{ - struct nss_ctx_instance *nss_ctx = nss_vxlan_get_ctx(); - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (!nss_vxlan_verify_if_num(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); -} -EXPORT_SYMBOL(nss_vxlan_ifnum_with_core_id); - -/* - * nss_vxlan_get_ctx() - * Return a VxLAN NSS context. - */ -struct nss_ctx_instance *nss_vxlan_get_ctx() -{ - struct nss_ctx_instance *nss_ctx; - - nss_ctx = &nss_top_main.nss[nss_top_main.vxlan_handler_id]; - return nss_ctx; -} -EXPORT_SYMBOL(nss_vxlan_get_ctx); - -/* - * nss_vxlan_init() - * Initializes Vxlan. Gets called from nss_init.c. - */ -void nss_vxlan_init() -{ - uint32_t core_status; - struct nss_ctx_instance *nss_ctx = nss_vxlan_get_ctx(); - if (!nss_ctx) { - nss_warning("%px: VxLAN is not registered", nss_ctx); - return; - } - - nss_vxlan_stats_dentry_create(); - sema_init(&nss_vxlan_pvt.sem, 1); - init_completion(&nss_vxlan_pvt.complete); - 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("%px: nss core register handler failed for if_num:%d with error :%d", nss_ctx, NSS_VXLAN_INTERFACE, core_status); - } - -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_vxlan_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_vxlan_log.c deleted file mode 100644 index 7bbfc5e87..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_vxlan_log.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_vxlan_log.c - * NSS VXLAN logger file. - */ - -#include "nss_core.h" - -/* - * nss_vxlan_log_message_types_str - * VXLAN message strings - */ -static int8_t *nss_vxlan_log_message_types_str[NSS_VXLAN_MSG_TYPE_MAX] __maybe_unused = { - "VxLAN Sync Stats", - "VxLAN Tunnel Configure Rule", - "VxLAN Tunnel Unconfigure Rule", - "VxLAN Enable Tunnel", - "VxLAN Disable Tunnel", - "VxLAN Add MAC rule", - "VxLAN Delete MAC rule", - "VxLAN MAC DB Stats" -}; - -/* - * nss_vxlan_log_error_response_types_str - * Strings for error types for VXLAN messages - */ -static int8_t *nss_vxlan_log_error_response_types_str[NSS_VXLAN_ERROR_TYPE_MAX] __maybe_unused = { - "VxLAN Unknown Error", - "VXLAN Decap Register fail", - "VXLAN Dest IP mismatch", - "VXLAN Invalid VNI", - "VXLAN Invalid L3 Proto", - "VXLAN Invalid UDP Proto", - "VXLAN Invalid Src Port", - "VXLAN MAC Bad entry", - "VXLAN MAC Entry exists", - "VXLAN MAC Entry does not exist", - "VXLAN MAC Entry unhashed", - "VXLAN MAC Entry alloc failed", - "VXLAN MAC Entry delete failed", - "VXLAN MAC Table full", - "VXLAN Sibling Node does not exist", - "VXLAN Tunnel Configured", - "VXLAN Tunnel Unconfigured", - "VXLAN Tunnel addition failed", - "VXLAN Tunnel Disabled", - "VXLAN Tunnel Enabled", - "VXLAN Tunnel Entry exists" -}; - -/* - * nss_vxlan_log_rule_msg() - * Log NSS VXLAN rule message. - */ -static void nss_vxlan_log_rule_msg(struct nss_vxlan_rule_msg *nvrm) -{ - nss_trace("%px: NSS VXLAN Rule message \n" - "VxLAN Tunnel Flags: %x\n" - "VNET ID: %u\n" - "Flowlabel: %u\n" - "TOS: %u\n" - "TTL: %u\n" - "source port min: %u max: %u" - "destination port: %u", - nvrm, - nvrm->tunnel_flags, - nvrm->vni, - nvrm->flow_label, - nvrm->tos, - nvrm->ttl, - nvrm->src_port_min, - nvrm->src_port_max, - nvrm->dest_port); -} - -/* - * nss_vxlan_mac_rule_msg() - * Log NSS Vxlan MAC rule message. - */ -static void nss_vxlan_log_mac_msg(struct nss_vxlan_mac_msg *nvmm) -{ - 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, - &nvmm->encap.src_ip, - &nvmm->encap.dest_ip, - nvmm->vni, - nvmm->mac_addr); -} - -/* - * nss_vxlan_log_rule_create_msg() - * Log NSS Vxlan rule create message. - */ -static void nss_vxlan_log_rule_create_msg(struct nss_vxlan_msg *nvm) -{ - struct nss_vxlan_rule_msg *nvrm __maybe_unused = &nvm->msg.vxlan_create; - nss_vxlan_log_rule_msg(nvrm); -} - -/* - * nss_vxlan_log_rule_destroy_msg() - * Log NSS Vxlan rule destroy message. - */ -static void nss_vxlan_log_rule_destroy_msg(struct nss_vxlan_msg *nvm) -{ - struct nss_vxlan_rule_msg *nvrm __maybe_unused = &nvm->msg.vxlan_destroy; - nss_vxlan_log_rule_msg(nvrm); -} - -/* - * nss_vxlan_log_enable_msg() - * Log NSS Vxlan rule enable message. - */ -static void nss_vxlan_log_enable_msg(struct nss_vxlan_msg *nvm) -{ - nss_trace("%px: NSS VXLAN Tunnel state message: Enable \n", nvm); -} - -/* - * nss_vxlan_log_disable_msg() - * Log NSS Vxlan rule disable message. - */ -static void nss_vxlan_log_disable_msg(struct nss_vxlan_msg *nvm) -{ - nss_trace("%px: NSS VXLAN Tunnel state message: Disable \n", nvm); -} - -/* - * nss_vxlan_log_mac_add_msg() - * Log NSS VXLAN mac rule add message. - */ -static void nss_vxlan_log_mac_add_msg(struct nss_vxlan_msg *nvm) -{ - struct nss_vxlan_mac_msg *nvmm __maybe_unused = &nvm->msg.mac_add; - nss_vxlan_log_mac_msg(nvmm); -} - -/* - * nss_vxlan_log_mac_del_msg() - * Log NSS VXLAN mac rule del message. - */ -static void nss_vxlan_log_mac_del_msg(struct nss_vxlan_msg *nvm) -{ - struct nss_vxlan_mac_msg *nvmm __maybe_unused = &nvm->msg.mac_del; - nss_vxlan_log_mac_msg(nvmm); -} - -/* - * nss_vxlan_log_verbose() - * Log message contents. - */ -static void nss_vxlan_log_verbose(struct nss_vxlan_msg *nvm) -{ - switch (nvm->cm.type) { - case NSS_VXLAN_MSG_TYPE_TUN_CONFIGURE: - nss_vxlan_log_rule_create_msg(nvm); - break; - - case NSS_VXLAN_MSG_TYPE_TUN_UNCONFIGURE: - nss_vxlan_log_rule_destroy_msg(nvm); - break; - - case NSS_VXLAN_MSG_TYPE_TUN_ENABLE: - nss_vxlan_log_enable_msg(nvm); - break; - - case NSS_VXLAN_MSG_TYPE_TUN_DISABLE: - nss_vxlan_log_disable_msg(nvm); - break; - - case NSS_VXLAN_MSG_TYPE_MAC_ADD: - nss_vxlan_log_mac_add_msg(nvm); - break; - - case NSS_VXLAN_MSG_TYPE_MAC_DEL: - nss_vxlan_log_mac_del_msg(nvm); - break; - - case NSS_VXLAN_MSG_TYPE_STATS_SYNC: - case NSS_VXLAN_MSG_TYPE_MACDB_STATS: - break; - - default: - nss_trace("%px: Invalid message type\n", nvm); - break; - } -} - -/* - * nss_vxlan_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_vxlan_log_tx_msg(struct nss_vxlan_msg *nvm) -{ - if (nvm->cm.type >= NSS_VXLAN_MSG_TYPE_MAX) { - nss_warning("%px: Invalid message type\n", nvm); - return; - } - - 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); -} - -/* - * nss_vxlan_log_rx_msg() - * Log messages received from FW. - */ -void nss_vxlan_log_rx_msg(struct nss_vxlan_msg *nvm) -{ - if (nvm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_vxlan_log_verbose(nvm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_vxlan_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_vxlan_log.h deleted file mode 100644 index 2db12be9f..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_vxlan_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_VXLAN_LOG_H__ -#define __NSS_VXLAN_LOG_H__ - -/* - * nss_vxlan_log.h - * NSS VXLAN Log Header File. - */ - -/* - * nss_vxlan_log_tx_msg - * Logs a Vxlan message that is sent to the NSS firmware. - */ -void nss_vxlan_log_tx_msg(struct nss_vxlan_msg *nvm); - -/* - * nss_vxlan_log_rx_msg - * Logs a Vxlan message that is received from the NSS firmware. - */ -void nss_vxlan_log_rx_msg(struct nss_vxlan_msg *nvm); - -#endif /* __NSS_VXLAN_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_vxlan_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_vxlan_stats.c deleted file mode 100644 index 0559d0a2a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_vxlan_stats.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_stats.h" -#include "nss_vxlan_stats.h" -#include - -#define NSS_VXLAN_STATS_MAX_LINES (NSS_STATS_NODE_MAX + 32) - /**< Maximum number of lines for VXLAN statistics dump. */ -#define NSS_VXLAN_STATS_SIZE_PER_IF (NSS_STATS_MAX_STR_LENGTH * NSS_VXLAN_STATS_MAX_LINES) - /**< Total number of statistics per VXLAN interface. */ - -/* - * nss_vxlan_stats_read() - * Read vxlan node statiistics. - */ -static ssize_t nss_vxlan_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - struct nss_ctx_instance *nss_ctx = nss_vxlan_get_ctx(); - enum nss_dynamic_interface_type type; - ssize_t bytes_read = 0; - size_t len = 0, size; - uint32_t if_num; - char *buf; - - size = NSS_VXLAN_STATS_SIZE_PER_IF; - 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 VxLAN dynamic interface. - */ - for (if_num = 0; if_num < NSS_MAX_NET_INTERFACES; if_num++) { - if (if_num == NSS_VXLAN_INTERFACE) { - len += scnprintf(buf + len, size - len, "\nBase node if_num:%03u", if_num); - len += scnprintf(buf + len, size - len, "\n-------------------\n"); - len += nss_stats_fill_common_stats(if_num, NSS_STATS_SINGLE_INSTANCE, buf, len, size - len, "vxlan"); - continue; - } - - type = nss_dynamic_interface_get_type(nss_ctx, if_num); - switch (type) { - case NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_INNER: - len += scnprintf(buf + len, size - len, "\nInner if_num:%03u", if_num); - break; - - case NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_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, "vxlan"); - } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, buf, len); - kfree(buf); - return bytes_read; -} - -/* - * nss_vxlan_stats_sync() - * Update vxlan common node statistics. - */ -void nss_vxlan_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_vxlan_msg *nvm) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - struct nss_vxlan_stats_msg *msg_stats = &nvm->msg.stats; - uint64_t *if_stats; - - spin_lock_bh(&nss_top->stats_lock); - - /* - * Update common node stats - */ - if_stats = nss_top->stats_node[nvm->cm.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_vxlan_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(vxlan) - -/* - * nss_vxlan_stats_dentry_create() - * Create vxlan statistics debug entry. - */ -void nss_vxlan_stats_dentry_create(void) -{ - nss_stats_create_dentry("vxlan", &nss_vxlan_stats_ops); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_vxlan_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_vxlan_stats.h deleted file mode 100644 index b4748f416..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_vxlan_stats.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_VXLAN_STATS_H_ -#define _NSS_VXLAN_STATS_H_ - -/* - * nss_vxlan_stats_dentry_create - * Creates vxlan interface statistics debug entry. - */ -void nss_vxlan_stats_dentry_create(void); - -/* - * nss_vxlan_stats_sync - * Update vxlan common node statistics. - */ -void nss_vxlan_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_vxlan_msg *nvm); - -#endif /* _NSS_VXLAN_STATS_H_ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifi.c deleted file mode 100644 index 559d947c8..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifi.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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_stats.h" -#include "nss_wifi_log.h" - -/* - * nss_wifi_get_context() - * Get NSS context of Wifi. - */ -struct nss_ctx_instance *nss_wifi_get_context() -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; -} - -/* - * nss_wifi_handler() - * Handle NSS -> HLOS messages for wifi - */ -static void nss_wifi_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_wifi_msg *ntm = (struct nss_wifi_msg *)ncm; - void *ctx; - nss_wifi_msg_callback_t cb; - - nss_info("%px: NSS ->HLOS message for wifi\n", nss_ctx); - - BUG_ON(((ncm->interface < NSS_WIFI_INTERFACE0) || (ncm->interface > NSS_WIFI_INTERFACE2))); - - /* - * Trace messages. - */ - nss_wifi_log_rx_msg(ntm); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_WIFI_MAX_MSG) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Snoop messages for local driver and handle - */ - switch (ntm->cm.type) { - case NSS_WIFI_STATS_MSG: - /* - * To create the old API gmac statistics, we use the new extended GMAC stats. - */ - nss_wifi_stats_sync(nss_ctx, &ntm->msg.statsmsg, ncm->interface); - break; - } - - /* - * Update the callback and app_data for NOTIFY messages, wifi sends all notify messages - * to the same callback/app_data. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->wifi_msg_callback; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Do we have a call back - */ - if (!ncm->cb) { - nss_info("%px: cb null for wifi interface %d", nss_ctx, ncm->interface); - return; - } - - /* - * Get callback & context - */ - cb = (nss_wifi_msg_callback_t)ncm->cb; - ctx = nss_ctx->subsys_dp_register[ncm->interface].ndev; - - /* - * call wifi msg callback - */ - if (!ctx) { - nss_warning("%px: Event received for wifi interface %d before registration", nss_ctx, ncm->interface); - return; - } - - cb(ctx, ntm); -} - -/* - * nss_wifi_tx_msg - * Transmit a wifi message to NSS FW - */ -nss_tx_status_t nss_wifi_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_wifi_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace messages. - */ - nss_wifi_log_tx_msg(msg); - - if (ncm->type > NSS_WIFI_MAX_MSG) { - nss_warning("%px: wifi 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); -} - -/* - **************************************** - * Register/Unregister/Miscellaneous APIs - **************************************** - */ - -/* - * nss_register_wifi_if() - * Register Wifi with nss driver - */ -struct nss_ctx_instance *nss_register_wifi_if(uint32_t if_num, nss_wifi_callback_t wifi_callback, - nss_wifi_callback_t wifi_ext_callback, - nss_wifi_msg_callback_t event_callback, struct net_device *netdev, uint32_t features) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; - - nss_assert(nss_ctx); - nss_assert((if_num >= NSS_MAX_VIRTUAL_INTERFACES) && (if_num < NSS_MAX_NET_INTERFACES)); - - 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); - - nss_top_main.wifi_msg_callback = event_callback; - - return nss_ctx; -} - -/* - * nss_unregister_wifi_if() - * Unregister wifi with nss driver - */ -void nss_unregister_wifi_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]; - - nss_assert(nss_ctx); - nss_assert((if_num >= NSS_MAX_VIRTUAL_INTERFACES) && (if_num < NSS_MAX_NET_INTERFACES)); - - nss_ctx->nss_top->wifi_msg_callback = NULL; - nss_core_unregister_subsys_dp(nss_ctx, if_num); -} - -/* - * nss_wifi_register_handler() - * Register handle for notfication messages received on wifi interface - */ -void nss_wifi_register_handler(void ) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; - - nss_assert(nss_ctx); - - nss_info("nss_wifi_register_handler"); - - nss_core_register_handler(nss_ctx, NSS_WIFI_INTERFACE0, nss_wifi_handler, NULL); - nss_core_register_handler(nss_ctx, NSS_WIFI_INTERFACE1, nss_wifi_handler, NULL); - nss_core_register_handler(nss_ctx, NSS_WIFI_INTERFACE2, nss_wifi_handler, NULL); - - nss_wifi_stats_dentry_create(); -} - -EXPORT_SYMBOL(nss_wifi_get_context); -EXPORT_SYMBOL(nss_wifi_tx_msg); -EXPORT_SYMBOL(nss_register_wifi_if); -EXPORT_SYMBOL(nss_unregister_wifi_if); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_ext_vdev.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_ext_vdev.c deleted file mode 100644 index bb2723906..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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(); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_ext_vdev_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_ext_vdev_log.c deleted file mode 100644 index 7fd188860..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_ext_vdev_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_ext_vdev_log.h deleted file mode 100644 index a5c851055..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_ext_vdev_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_ext_vdev_stats.c deleted file mode 100644 index 493ca84b0..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_ext_vdev_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_ext_vdev_stats.h deleted file mode 100644 index 589e2c09e..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_log.c deleted file mode 100644 index 4d6b4c52d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_log.c +++ /dev/null @@ -1,806 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_wifi_log.c - * NSS WIFI logger file. - */ - -#include "nss_core.h" - -/* - * nss_wifi_log_message_types_str - * WIFI message strings - */ -static int8_t *nss_wifi_log_message_types_str[NSS_WIFI_MAX_MSG] __maybe_unused = { - "WIFI INIT MSG", - "WIFI POST RECV MSG", - "WIFI HTT INIT MSG", - "WIFI TX INIT MSG", - "WIFI RAW SEND MSG", - "WIFI MGMT SEND MSG", - "WIFI WDS PEER ADD MSG", - "WIFI WDS PEER DEL MSG", - "WIFI STOP MSG", - "WIFI RESET MSG", - "WIFI STATS MSG", - "WIFI PEER FREELIST APPEND MSG", - "WIFI RX REORDER ARRAY FREELIST APPEND MSG", - "WIFI SEND PEER MEMORY REQUEST MSG", - "WIFI SEND RRA MEMORY REQUEST MSG", - "WIFI FW STATS MSG", - "WIFI MONITOR FILTER SET MSG", - "WIFI PEER BS STATE MSG", - "WIFI MSDU TTL SET MSG", - "WIFI RX VOW EXTSTATS SET MSG", - "WIFI PKTLOG CFG MSG", - "WIFI ENABLE PERPKT TXSTATS MSG", - "WIFI IGMP MLD TOS OVERRIDE MSG", - "WIFI OL STATS CFG MSG", - "WIFI OL STATS MSG", - "WIFI TX QUEUE CFG MSG", - "WIFI TX MIN THRESHOLD CFG MSG", - "WIFI DBDC PROCESS ENABLE MSG", - "WIFI PRIMARY RADIO SET MSG", - "WIFI FORCE CLIENT MCAST TRAFFIC SET MSG", - "WIFI STORE OTHER PDEV STAVAP MSG", - "WIFI STA KICKOUT MSG", - "WIFI WNM PEER RX ACTIVITY MSG", - "WIFI PEER STATS MSG", - "WIFI WDS VENDOR MSG", - "WIFI TX CAPTURE SET MSG", - "WIFI ALWAYS PRIMARY SET MSG", - "WIFI FLUSH HTT CMD MSG", - "WIFI CMD MSG", - "WIFI ENABLE OL STATSV2 MSG", - "WIFI OL PEER TIME MSG", -}; - -/* - * nss_wifi_log_error_response_types_str - * Strings for error types for WIFI messages - */ -static int8_t *nss_wifi_log_error_response_types_str[NSS_WIFI_EMSG_MAX] __maybe_unused = { - "WIFI NO ERROR", - "WIFI UNKNOWN MSG", - "WIFI MGMT DLEN", - "WIFI MGMT SEND", - "WIFI CE INIT FAIL", - "WIFI PDEV INIT FAIL", - "WIFI HTT INIT FAIL", - "WIFI PEER ADD", - "WIFI WIFI START FAIL", - "WIFI STATE NOT RESET", - "WIFI STATE NOT INIT DONE", - "WIFI STATE NULL CE HANDLE", - "WIFI STATE NOT CE READY", - "WIFI STATE NOT HTT READY", - "WIFI FW STATS DLEN", - "WIFI FW STATS SEND", - "WIFI STATE TX INIT FAILED", - "WIFI IGMP MLD TOS OVERRIDE CFG", - "WIFI PDEV INVALID", - "WIFI OTHER PDEV STAVAP INVALID", - "WIFI HTT SEND FAIL", - "WIFI CE RING INIT", - "WIFI NOTIFY CB", - "WIFI PEERID INVALID", - "WIFI PEER INVALID", - "WIFI UNKNOWN CMD" -}; - -/* - * nss_wifi_log_init_msg() - * Log NSS WIFI Init message. - */ -static void nss_wifi_log_init_msg(struct nss_wifi_msg *ncm) -{ - struct nss_wifi_init_msg *nwim __maybe_unused = &ncm->msg.initmsg; - - nss_trace("%px: NSS WIFI Init Message:\n" - "WIFI Radio ID: %d\n" - "WIFI PCI Memory Address: %x\n" - "WIFI Target Type: %d\n" - "WIFI MU MIMO Enhancement Enable Flag: %d\n" - "WIFI Transmit Copy Engine Source Ring:\n" - "\tNumber of Entries: %d\n" - "\tNumber of Entries Mask: %x\n" - "\tInitial Software Index: %d\n" - "\tInitial Write Index: %d\n" - "\tInitial Hardware Index: %d\n" - "\tPhysical Address: %x\n" - "\tVirtual Address: %x\n" - "WIFI Transmit Copy Engine Dest Ring:\n" - "\tNumber of Entries: %d\n" - "\tNumber of Entries Mask: %x\n" - "\tInitial Software Index: %d\n" - "\tInitial Write Index: %d\n" - "\tInitial Hardware Index: %d\n" - "\tPhysical Address: %x\n" - "\tVirtual Address: %x\n" - "WIFI Transmit Control Address of PCIe Bar: %x\n" - "WIFI Receive Copy Engine Source Ring:\n" - "\tNumber of Entries: %d\n" - "\tNumber of Entries Mask: %x\n" - "\tInitial Software Index: %d\n" - "\tInitial Write Index: %d\n" - "\tInitial Hardware Index: %d\n" - "\tPhysical Address: %x\n" - "\tVirtual Address: %x\n" - "WIFI Receive Copy Engine Dest Ring:\n" - "\tNumber of Entries: %d\n" - "\tNumber of Entries Mask: %x\n" - "\tInitial Software Index: %d\n" - "\tInitial Write Index: %d\n" - "\tInitial Hardware Index: %d\n" - "\tPhysical Address: %x\n" - "\tVirtual Address: %x\n" - "WIFI Receive Control Address of PCIe Bar: %x\n" - "WIFI Bypass Network Process: %d", - nwim, nwim->radio_id, - nwim->pci_mem, nwim->target_type, - nwim->mu_mimo_enhancement_en, nwim->ce_tx_state.src_ring.nentries, - nwim->ce_tx_state.src_ring.nentries_mask, nwim->ce_tx_state.src_ring.sw_index, - nwim->ce_tx_state.src_ring.write_index, nwim->ce_tx_state.src_ring.hw_index, - nwim->ce_tx_state.src_ring.base_addr_CE_space, nwim->ce_tx_state.src_ring.base_addr_owner_space, - nwim->ce_tx_state.dest_ring.nentries, nwim->ce_tx_state.dest_ring.nentries_mask, - nwim->ce_tx_state.dest_ring.sw_index, nwim->ce_tx_state.dest_ring.write_index, - nwim->ce_tx_state.dest_ring.hw_index, nwim->ce_tx_state.dest_ring.base_addr_CE_space, - nwim->ce_tx_state.dest_ring.base_addr_owner_space, nwim->ce_tx_state.ctrl_addr, - nwim->ce_rx_state.src_ring.nentries, nwim->ce_rx_state.src_ring.nentries_mask, - nwim->ce_rx_state.src_ring.sw_index, nwim->ce_rx_state.src_ring.write_index, - nwim->ce_rx_state.src_ring.hw_index, nwim->ce_rx_state.src_ring.base_addr_CE_space, - nwim->ce_rx_state.src_ring.base_addr_owner_space, nwim->ce_rx_state.dest_ring.nentries, - nwim->ce_rx_state.dest_ring.nentries_mask, nwim->ce_rx_state.dest_ring.sw_index, - nwim->ce_rx_state.dest_ring.write_index, nwim->ce_rx_state.dest_ring.hw_index, - nwim->ce_rx_state.dest_ring.base_addr_CE_space, nwim->ce_rx_state.dest_ring.base_addr_owner_space, - nwim->ce_rx_state.ctrl_addr, nwim->bypass_nw_process); -} - -/* - * nss_wifi_log_stop_msg() - * Log NSS WIFI Init message. - */ -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("%px: NSS WIFI Init Message:\n" - "WIFI Radio ID: %d\n", - nwsm, nwsm->radio_id); -} - -/* - * nss_wifi_log_reset_msg() - * Log NSS WIFI Init message. - */ -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("%px: NSS WIFI Init Message:\n" - "WIFI Radio ID: %d\n", - nwrm, nwrm->radio_id); -} - -/* - * nss_wifi_log_htt_init_msg() - * Log NSS WIFI HTT Init message. - */ -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("%px: NSS WIFI HTT Init Message:\n" - "WIFI Radio ID: %d\n" - "WIFI Ring Size: %d\n" - "WIFI Fill Level: %d\n" - "WIFI MAC Hardware Ring Phy Address: %x\n" - "WIFI MAC Hardware Ring Virtual Address: %x\n" - "WIFI Hardware Ring Index Phy Address: %x\n" - "WIFI Hardware Ring Index Virtual Address: %x\n", - nwim, nwim->radio_id, - nwim->ringsize, nwim->fill_level, - nwim->paddrs_ringptr, nwim->paddrs_ringpaddr, - nwim->alloc_idx_paddr, nwim->alloc_idx_vaddr); -} - -/* - * nss_wifi_log_tx_init_msg() - * Log NSS TX HTT Init message. - */ -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("%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" - "WIFI MAC extenstion descriptor Address: %x\n" - "WIFI WLAN MAC extenstion descriptor size: %d\n" - "WIFI HTT Tx descriptor memory start virtual address: %x\n" - "WIFI HTT Tx descriptor memory base virtual address: %x\n" - "WIFI HTT Tx descriptor memory offset: %x\n" - "WIFI Firmware shared TID map: %x\n", - nwim, nwim->radio_id, - nwim->desc_pool_size, nwim->tx_desc_array, - nwim->wlanextdesc_addr, nwim->wlanextdesc_size, - nwim->htt_tx_desc_base_vaddr, nwim->htt_tx_desc_base_paddr, - nwim->htt_tx_desc_offset, nwim->pmap_addr); -} - -/* - * nss_wifi_log_rawsend_msg() - * Log NSS WIFI RAW Send message. - */ -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("%px: NSS WIFI RAW Send Message:\n" - "WIFI Radio ID: %d\n" - "WIFI Size of Raw Data: %d\n" - "WIFI Raw Data: %px", - nwrm, nwrm->radio_id, - nwrm->len, nwrm->array); -} - -/* - * nss_wifi_log_mgmtsend_msg() - * Log NSS WIFI Management Send message. - */ -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("%px: NSS WIFI Management Send Message:\n" - "WIFI Descriptor ID: %d\n" - "WIFI Size of Management Data: %d\n" - "WIFI Management Data: %px", - nwmm, nwmm->desc_id, - nwmm->len, nwmm->array); -} - -/* - * nss_wifi_log_wds_peer_msg() - * Log NSS WIFI WDS Peer message. - */ -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("%px: NSS WIFI WDS Peer Message:\n" - "WIFI Dest MAC: %pM\n" - "WIFI Peer MAC: %pM\n", - nwmm, nwmm->dest_mac, - nwmm->peer_mac); -} - -/* - * nss_wifi_log_peer_freelist_append_msg() - * Log NSS WIFI Create/Append Freelist message - */ -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("%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", - nwpm, nwpm->addr, - nwpm->length, nwpm->num_peers); -} - -/* - * nss_wifi_log_rx_reorder_array_freelist_append_msg() - * Log NSS WIFI RX Reorder Array Freelist message - */ -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("%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", - nwpm, nwpm->addr, - nwpm->length, nwpm->num_rra); -} - -/* - * nss_wifi_log_set_filter_msg() - * Log NSS WIFI Set Filter message - */ -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("%px: NSS WIFI Set Filter Message:\n" - "WIFI Filter Type: %dn", - nwfm, nwfm->filter_type); -} - -/* - * nss_wifi_log_peer_activity_msg() - * Log NSS WIFI Get Active Peer for Radio message - */ -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("%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, - nwpm->peer_id[0]); -} - -/* - * nss_wifi_rx_vow_extstats_set_msg() - * Log NSS WIFI VoW Extended Statistics Set Message. - */ -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("%px: NSS WIFI VoW Extended Statistics Set Message:\n" - "WIFI VoW Extended Statistics Enable:: %d\n", - nwpm, nwpm->vow_extstats_en); -} - -/* - * nss_wifi_log_pktlog_cfg_msg() - * Log NSS WIFI Packet Log Configuration Message. - */ -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("%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" - "WIFI Offset for the MSDU ID: %d\n", - nwpm, nwpm->enable, - nwpm->bufsize, nwpm->hdrsize, - nwpm->msdu_id_offset); -} - -/* - * nss_wifi_log_enable_perpkt_txstats_msg() - * Log NSS WIFI Enable TX Stats Message. - */ -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("%px: NSS WIFI Enable TX Stats Message:\n" - "WIFI TX Stats Enable Flag: %d\n", - nwpm, nwpm->perpkt_txstats_flag); -} - -/* - * nss_wifi_log_override_tos_msg() - * Log NSS WIFI Override TOS Message. - */ -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("%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, - nwpm->igmp_mld_ovride_tid_val); -} - -/* - * nss_wifi_log_ol_stats_cfg_msg() - * Log NSS WIFI Offload Stats Config Message. - */ -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("%px: NSS WIFI Enable/Disable Offload Stats Message:\n" - "WIFI enable/disable offload stats config: %d\n", - nwpm, nwpm->stats_cfg); -} - -/* - * nss_wifi_log_tx_queue_cfg_msg() - * Log NSS WIFI TX Queue Configuration message. - */ -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("%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); -} - -/* - * nss_wifi_log_tx_min_threshold_cfg() - * Log NSS WIFI TX Queue Min Threshold Configuration message. - */ -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("%px: NSS WIFI TX Queue Min Threshold Config Message:\n" - "WIFI TX Queue Min Threshold Value: %d\n", - nwpm, nwpm->min_threshold); -} - -/* - * nss_wifi_log_dbdc_process_enable_msg() - * Log NSS WIFI DBDC repeater process configuration. - */ -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("%px: NSS WIFI DBDC repeater process configuration:\n" - "WIFI DBDC Process Enable Flag: %d\n", - nwpm, nwpm->dbdc_process_enable); -} - -/* - * nss_wifi_log_primary_radio_set_msg() - * Log NSS WIFI Primary Radio Set message. - */ -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("%px: NSS WIFI Primary Radio Set Message:\n" - "WIFI Current Radio as Primary Radio Enable/Disable Flag: %d\n", - nwpm, nwpm->flag); -} - -/* - * nss_wifi_log_force_client_mcast_traffic_set_msg() - * Log NSS WIFI Force Multicat Traffic for Radio - */ -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("%px: NSS WIFI Force Multicat Traffic for Radio Message:\n" - "WIFI Radio Multicast Traffic Flag: %d\n", - nwpm, nwpm->flag); -} - -/* - * nss_wifi_log_store_other_pdev_stavap_msg() - * Log NSS WIFI Store Other Radio Station VAP Message. - */ -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("%px: NSS WIFI Store Other Radio Station VAP Message:\n" - "WIFI Station VAP Interface Number: %d\n", - nwpm, nwpm->stavap_ifnum); -} - -/* - * nss_wifi_log_sta_kickout_msg() - * Log NSS WIFI Station Kickout Message. - */ -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("%px: NSS WIFI Station Kickout Message:\n" - "WIFI PEER ID: %d\n", - nwpm, nwpm->peer_id); -} - -/* - * nss_wifi_log_wnm_peer_rx_activity() - * Log NSS WIFI RX Active State Information of Peer. - */ -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("%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); -} - -/* - * nss_wifi_log_wds_extn_peer_cfg_msg() - * Log NSS WIFI WDS Extension Enabled Configuraion Message. - */ -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("%px: NSS WIFI Extension Enabled Configuraion Message:\n" - "WIFI Peer MAC Address: %pM\n" - "WIFI WDS Flags: %d\n" - "WIFI Peer ID: %d\n", - nwpm, nwpm->mac_addr, nwpm->wds_flags, - nwpm->peer_id); -} - -/* - * nss_wifi_log_tx_capture_msg() - * Log NSS WIFI Enable TX Capture Message. - */ -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("%px: NSS WIFI Enable TX Capture Message:\n" - "WIFI TX Capture Enable Flag: %d\n", - nwpm, nwpm->tx_capture_enable); -} - -/* - * nss_wifi_log_always_primary_set_msg() - * Log NSS WIFI Always Set Current Radio Primary Message. - */ -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("%px: NSS WIFI Always Set Current Radio Primary Message:\n" - "WIFI Always Set Flag: %d\n", - nwpm, nwpm->flag); -} - -/* - * nss_wifi_log_cmd_msg() - * Log NSS WIFI PDEV Command Message. - */ -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("%px: NSS WIFI PDEV Command Message:\n" - "WIFI Type of Command: %d\n" - "WIFI Value of Command: %d\n", - nwpm, nwpm->cmd, nwpm->value); -} - -/* - * nss_wifi_log_enable_ol_statsv2_msg() - * Log NSS WIFI Enable Version 2 of TX/RX Stats - */ -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("%px: NSS WIFI Enable Version 2 of TX/RX Stats:\n" - "WIFI Enable Version 2 Stats: %d\n", - nwpm, nwpm->enable_ol_statsv2); -} - -/* - * nss_wifi_log_enable_ol_peer_time_msg() - * Log NSS WIFI Enable Per Peer Stats to Host - */ -static void nss_wifi_log_enable_ol_peer_time_msg(struct nss_wifi_msg *ncm) -{ - struct nss_wifi_ol_peer_time_msg *nwpm __maybe_unused = &ncm->msg.wopt_msg; - int32_t i; - - 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, - nwpm->tstats[0].peer_id); - /* - * Continuation of the log. - */ - nss_trace("WIFI TX Timestamp:\n"); - nss_trace("\tSum of sojourn for each packet:"); - for (i = 0; i < NSS_WIFI_TX_NUM_TOS_TIDS; i++) { - nss_trace("\t\t%d = %x", i, nwpm->tstats[0].sum[i].sum_tx); - } - nss_trace("\tNumber of MSDU per peer per TID:"); - for (i = 0; i < NSS_WIFI_TX_NUM_TOS_TIDS; i++) { - nss_trace("\t\t%d = %x", i, nwpm->tstats[0].sum[i].sum_msdus); - } - nss_trace("WIFI Exponential Weighted Average:"); - for (i = 0; i < NSS_WIFI_TX_NUM_TOS_TIDS; i++) { - nss_trace("\t%d = %d", i, nwpm->tstats[0].avg[i]); - } -} - -/* - * nss_wifi_log_verbose() - * Log message contents. - */ -static void nss_wifi_log_verbose(struct nss_wifi_msg *ncm) -{ - switch (ncm->cm.type) { - case NSS_WIFI_INIT_MSG: - nss_wifi_log_init_msg(ncm); - break; - - case NSS_WIFI_HTT_INIT_MSG: - nss_wifi_log_htt_init_msg(ncm); - break; - - case NSS_WIFI_TX_INIT_MSG: - nss_wifi_log_tx_init_msg(ncm); - break; - - case NSS_WIFI_RAW_SEND_MSG: - nss_wifi_log_rawsend_msg(ncm); - break; - - case NSS_WIFI_MGMT_SEND_MSG: - nss_wifi_log_mgmtsend_msg(ncm); - break; - - case NSS_WIFI_WDS_PEER_ADD_MSG: - nss_wifi_log_wds_peer_msg(ncm); - break; - - case NSS_WIFI_WDS_PEER_DEL_MSG: - nss_wifi_log_wds_peer_msg(ncm); - break; - - case NSS_WIFI_STOP_MSG: - nss_wifi_log_stop_msg(ncm); - break; - - case NSS_WIFI_RESET_MSG: - nss_wifi_log_reset_msg(ncm); - break; - - case NSS_WIFI_PEER_FREELIST_APPEND_MSG: - nss_wifi_log_peer_freelist_append_msg(ncm); - break; - - case NSS_WIFI_RX_REORDER_ARRAY_FREELIST_APPEND_MSG: - nss_wifi_log_rx_reorder_array_freelist_append_msg(ncm); - break; - - case NSS_WIFI_MONITOR_FILTER_SET_MSG: - nss_wifi_log_set_filter_msg(ncm); - break; - - case NSS_WIFI_PEER_BS_STATE_MSG: - nss_wifi_log_peer_activity_msg(ncm); - break; - - case NSS_WIFI_RX_VOW_EXTSTATS_SET_MSG: - nss_wifi_log_rx_vow_extstats_set_msg(ncm); - break; - - case NSS_WIFI_PKTLOG_CFG_MSG: - nss_wifi_log_pktlog_cfg_msg(ncm); - break; - - case NSS_WIFI_ENABLE_PERPKT_TXSTATS_MSG: - nss_wifi_log_enable_perpkt_txstats_msg(ncm); - break; - - case NSS_WIFI_IGMP_MLD_TOS_OVERRIDE_MSG: - nss_wifi_log_override_tos_msg(ncm); - break; - - case NSS_WIFI_OL_STATS_CFG_MSG: - nss_wifi_log_ol_stats_cfg_msg(ncm); - break; - - case NSS_WIFI_TX_QUEUE_CFG_MSG: - nss_wifi_log_tx_queue_cfg_msg(ncm); - break; - - case NSS_WIFI_TX_MIN_THRESHOLD_CFG_MSG: - nss_wifi_log_tx_min_threshold_cfg(ncm); - break; - - case NSS_WIFI_DBDC_PROCESS_ENABLE_MSG: - nss_wifi_log_dbdc_process_enable_msg(ncm); - break; - - case NSS_WIFI_PRIMARY_RADIO_SET_MSG: - nss_wifi_log_primary_radio_set_msg(ncm); - break; - - case NSS_WIFI_FORCE_CLIENT_MCAST_TRAFFIC_SET_MSG: - nss_wifi_log_force_client_mcast_traffic_set_msg(ncm); - break; - - case NSS_WIFI_STORE_OTHER_PDEV_STAVAP_MSG: - nss_wifi_log_store_other_pdev_stavap_msg(ncm); - break; - - case NSS_WIFI_STA_KICKOUT_MSG: - nss_wifi_log_sta_kickout_msg(ncm); - break; - - case NSS_WIFI_WNM_PEER_RX_ACTIVITY_MSG: - nss_wifi_log_wnm_peer_rx_activity(ncm); - break; - - case NSS_WIFI_WDS_VENDOR_MSG: - nss_wifi_log_wds_extn_peer_cfg_msg(ncm); - break; - - case NSS_WIFI_TX_CAPTURE_SET_MSG: - nss_wifi_log_tx_capture_msg(ncm); - break; - - case NSS_WIFI_ALWAYS_PRIMARY_SET_MSG: - nss_wifi_log_always_primary_set_msg(ncm); - break; - - case NSS_WIFI_CMD_MSG: - nss_wifi_log_cmd_msg(ncm); - break; - - case NSS_WIFI_ENABLE_OL_STATSV2_MSG: - nss_wifi_log_enable_ol_statsv2_msg(ncm); - break; - - case NSS_WIFI_OL_PEER_TIME_MSG: - nss_wifi_log_enable_ol_peer_time_msg(ncm); - break; - - case NSS_WIFI_FLUSH_HTT_CMD_MSG: - case NSS_WIFI_OL_STATS_MSG: - case NSS_WIFI_MSDU_TTL_SET_MSG: - case NSS_WIFI_PEER_STATS_MSG: - case NSS_WIFI_FW_STATS_MSG: - case NSS_WIFI_SEND_RRA_MEMORY_REQUEST_MSG: - case NSS_WIFI_STATS_MSG: - case NSS_WIFI_POST_RECV_MSG: - case NSS_WIFI_SEND_PEER_MEMORY_REQUEST_MSG: - /* - * No log for these valid messages. - */ - break; - - default: - nss_warning("%px: Invalid message type\n", ncm); - break; - } -} - -/* - * nss_wifi_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_wifi_log_tx_msg(struct nss_wifi_msg *ncm) -{ - if (ncm->cm.type >= NSS_WIFI_MAX_MSG) { - nss_warning("%px: Invalid message type\n", ncm); - return; - } - - 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); -} - -/* - * nss_wifi_log_rx_msg() - * Log messages received from FW. - */ -void nss_wifi_log_rx_msg(struct nss_wifi_msg *ncm) -{ - if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_wifi_log_verbose(ncm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_log.h deleted file mode 100644 index c47a62b3a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_LOG_H__ -#define __NSS_WIFI_LOG_H__ - -/* - * nss_WIFI_log.h - * NSS WIFI Log Header File - */ - -/* - * nss_WIFI_log_tx_msg - * Logs a WIFI message that is sent to the NSS firmware. - */ -void nss_wifi_log_tx_msg(struct nss_wifi_msg *ncm); - -/* - * nss_WIFI_log_rx_msg - * Logs a WIFI message that is received from the NSS firmware. - */ -void nss_wifi_log_rx_msg(struct nss_wifi_msg *ncm); - -#endif /* __NSS_WIFI_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mac_db.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mac_db.c deleted file mode 100644 index 5fb825a1a..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mac_db.c +++ /dev/null @@ -1,215 +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_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() - */ -struct nss_ctx_instance *nss_wifi_mac_db_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wmdb_handler_id]; -} -EXPORT_SYMBOL(nss_wifi_mac_db_get_context); - -/* - * nss_wifi_mac_db_pvt - * Private data structure - */ -static struct nss_wifi_mac_db_pvt { - struct semaphore sem; - struct completion complete; - int response; - void *cb; - void *app_data; -} wifi_mac_db_pvt; - -/* - * nss_wifi_mac_db_handler() - * Handle NSS -> HLOS messages for wifi_mac_db - */ -static void nss_wifi_mac_db_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_wifi_mac_db_msg *ntm = (struct nss_wifi_mac_db_msg *)ncm; - void *ctx; - nss_wifi_mac_db_msg_callback_t cb; - - 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 - */ - BUG_ON((ncm->interface != NSS_WIFI_MAC_DB_INTERFACE)); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_WIFI_MAC_DB_MAX_MSG) { - 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("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - - /* - * Update the callback and app_data for notify messages, wifi_mac_db sends all notify messages - * to the same callback/app_data. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->wifi_mac_db_msg_callback; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Do we have a call back - */ - if (!ncm->cb) { - nss_info("%px: cb null for wifi_mac_db interface %d", nss_ctx, ncm->interface); - return; - } - - /* - * Get callback & context - */ - cb = (nss_wifi_mac_db_msg_callback_t)ncm->cb; - ctx = nss_ctx->subsys_dp_register[ncm->interface].ndev; - - /* - * call wifi_mac_db msg callback - */ - if (!ctx) { - nss_warning("%px: Event received for wifi_mac_db interface %d before registration", nss_ctx, ncm->interface); - return; - } - - cb(ctx, ntm); -} - -/* - * nss_wifi_mac_db_tx_msg - * Transmit a wifi_mac_db message to NSS FW - * - * NOTE: The caller is expected to handle synchronous wait for message - * response if needed. - */ -nss_tx_status_t nss_wifi_mac_db_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_wifi_mac_db_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - if (ncm->type >= NSS_WIFI_MAC_DB_MAX_MSG) { - nss_warning("%px: wifi_mac_db message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - /* - * The interface number shall be one of the wifi_mac_db soc interfaces - */ - if ((ncm->interface != NSS_WIFI_MAC_DB_INTERFACE)) { - nss_warning("%px: tx request for interface that is not a wifi_mac_db: %d", nss_ctx, ncm->interface); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_wifi_mac_db_tx_msg); - -/* - **************************************** - * Register/Unregister/Miscellaneous APIs - **************************************** - */ - -/* - * nss_register_wifi_mac_db_if() - * Register wifi_mac_db with nss driver - */ -struct nss_ctx_instance *nss_register_wifi_mac_db_if(uint32_t if_num, nss_wifi_mac_db_callback_t wifi_mac_db_callback, - nss_wifi_mac_db_callback_t wifi_mac_db_ext_callback, - nss_wifi_mac_db_msg_callback_t event_callback, struct net_device *netdev, uint32_t features) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wmdb_handler_id]; - - /* - * The interface number shall be wifi_mac_db interface - */ - nss_assert(if_num == NSS_WIFI_MAC_DB_INTERFACE); - - 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); - - nss_top_main.wifi_mac_db_msg_callback = event_callback; - - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wmdb_handler_id]; -} -EXPORT_SYMBOL(nss_register_wifi_mac_db_if); - -/* - * nss_unregister_wifi_mac_db_if() - * Unregister wifi_mac_db with nss driver - */ -void nss_unregister_wifi_mac_db_if(uint32_t if_num) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wmdb_handler_id]; - - /* - * The interface number shall be wifi_mac_db interface - */ - nss_assert(if_num == NSS_WIFI_MAC_DB_INTERFACE); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_unregister_wifi_mac_db_if); - -/* - * nss_wifi_mac_db_register_handler() - * Register handle for notfication messages received on wifi mac db - */ -void nss_wifi_mac_db_register_handler(void) -{ - struct nss_ctx_instance *nss_ctx = - (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wmdb_handler_id]; - - nss_info("wifi_mac_db_register_handler"); - nss_core_register_handler(nss_ctx, NSS_WIFI_MAC_DB_INTERFACE, nss_wifi_mac_db_handler, NULL); - - sema_init(&wifi_mac_db_pvt.sem, 1); - init_completion(&wifi_mac_db_pvt.complete); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh.c deleted file mode 100644 index d4a6c0a1d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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"); - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_log.c deleted file mode 100644 index bf9ddc658..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_log.c +++ /dev/null @@ -1,368 +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 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_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; - - 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); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_log.h deleted file mode 100644 index a6c54368f..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_stats.c deleted file mode 100644 index 4cfa96a67..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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; - 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); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_stats.h deleted file mode 100644 index 0e3a11850..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_strings.c deleted file mode 100644 index 25f647323..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_strings.c +++ /dev/null @@ -1,276 +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} -}; - -/* - * 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} -}; - -/* - * 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} -}; - -/* - * 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; -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_mesh_strings.h deleted file mode 100644 index e858cbd05..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/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 */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_stats.c deleted file mode 100644 index 7a31b25b9..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_stats.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - ************************************************************************** - * 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. - * 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.h" -#include "nss_wifi_stats.h" - -/* - * nss_wifi_stats_str - * Wifi statistics strings. - */ -struct nss_stats_info nss_wifi_stats_str[NSS_WIFI_STATS_MAX] = { - {"rx_pkts" , 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}, - {"tx_pkts" , NSS_STATS_TYPE_COMMON}, - {"tx_drops" , NSS_STATS_TYPE_DROP}, - {"tx_transmit_completed" , NSS_STATS_TYPE_SPECIAL}, - {"tx_mgmt_received" , NSS_STATS_TYPE_SPECIAL}, - {"tx_mgmt_transmitted" , NSS_STATS_TYPE_SPECIAL}, - {"tx_mgmt_drops" , NSS_STATS_TYPE_DROP}, - {"tx_mgmt_completed" , NSS_STATS_TYPE_SPECIAL}, - {"tx_inv_peer_enq_cnt" , NSS_STATS_TYPE_SPECIAL}, - {"rx_inv_peer_rcv_cnt" , NSS_STATS_TYPE_SPECIAL}, - {"rx_pn_check_failed" , NSS_STATS_TYPE_DROP}, - {"rx_pkts_deliverd" , NSS_STATS_TYPE_SPECIAL}, - {"rx_bytes_delivered" , NSS_STATS_TYPE_SPECIAL}, - {"tx_bytes_completed" , NSS_STATS_TYPE_SPECIAL}, - {"rx_deliver_unaligned_drop_cnt" , NSS_STATS_TYPE_DROP}, - {"tidq_enqueue_cnt_0" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_enqueue_cnt_1" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_enqueue_cnt_2" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_enqueue_cnt_3" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_enqueue_cnt_4" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_enqueue_cnt_5" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_enqueue_cnt_6" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_enqueue_cnt_7" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_cnt_0" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_cnt_1" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_cnt_2" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_cnt_3" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_cnt_4" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_cnt_5" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_cnt_6" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_cnt_7" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_enqueue_fail_cnt_0" , NSS_STATS_TYPE_DROP}, - {"tidq_enqueue_fail_cnt_1" , NSS_STATS_TYPE_DROP}, - {"tidq_enqueue_fail_cnt_2" , NSS_STATS_TYPE_DROP}, - {"tidq_enqueue_fail_cnt_3" , NSS_STATS_TYPE_DROP}, - {"tidq_enqueue_fail_cnt_4" , NSS_STATS_TYPE_DROP}, - {"tidq_enqueue_fail_cnt_5" , NSS_STATS_TYPE_DROP}, - {"tidq_enqueue_fail_cnt_6" , NSS_STATS_TYPE_DROP}, - {"tidq_enqueue_fail_cnt_7" , NSS_STATS_TYPE_DROP}, - {"tidq_ttl_expire_cnt_0" , NSS_STATS_TYPE_DROP}, - {"tidq_ttl_expire_cnt_1" , NSS_STATS_TYPE_DROP}, - {"tidq_ttl_expire_cnt_2" , NSS_STATS_TYPE_DROP}, - {"tidq_ttl_expire_cnt_3" , NSS_STATS_TYPE_DROP}, - {"tidq_ttl_expire_cnt_4" , NSS_STATS_TYPE_DROP}, - {"tidq_ttl_expire_cnt_5" , NSS_STATS_TYPE_DROP}, - {"tidq_ttl_expire_cnt_6" , NSS_STATS_TYPE_DROP}, - {"tidq_ttl_expire_cnt_7" , NSS_STATS_TYPE_DROP}, - {"tidq_dequeue_req_cnt_0" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_req_cnt_1" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_req_cnt_2" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_req_cnt_3" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_req_cnt_4" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_req_cnt_5" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_req_cnt_6" , NSS_STATS_TYPE_SPECIAL}, - {"tidq_dequeue_req_cnt_7" , NSS_STATS_TYPE_SPECIAL}, - {"total_tidq_depth" , NSS_STATS_TYPE_SPECIAL}, - {"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} -}; - -uint64_t nss_wifi_stats[NSS_MAX_WIFI_RADIO_INTERFACES][NSS_WIFI_STATS_MAX]; /* WIFI statistics */ - -/* - * nss_wifi_stats_read() - * Read wifi statistics. - */ -static ssize_t nss_wifi_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - uint32_t i, id; - - /* - * Max output lines = #stats * NSS_MAX_CORES + - * Few output lines for banner printing + Number of Extra outputlines for future reference to add new stats. - */ - uint32_t max_output_lines = NSS_WIFI_STATS_MAX * NSS_MAX_WIFI_RADIO_INTERFACES + 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_WIFI_STATS_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, "wifi", NSS_STATS_SINGLE_CORE); - - for (id = 0; id < NSS_MAX_WIFI_RADIO_INTERFACES; id++) { - spin_lock_bh(&nss_top_main.stats_lock); - for (i = 0; (i < NSS_WIFI_STATS_MAX); i++) { - stats_shadow[i] = nss_wifi_stats[id][i]; - } - - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("wifi", NULL, id, nss_wifi_stats_str, stats_shadow, NSS_WIFI_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, strlen(lbuf)); - kfree(lbuf); - kfree(stats_shadow); - return bytes_read; -} - -/* - * nss_wifi_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(wifi) - -/* - * nss_wifi_stats_dentry_create() - * Create wifi statistics debug entry. - */ -void nss_wifi_stats_dentry_create(void) -{ - nss_stats_create_dentry("wifi", &nss_wifi_stats_ops); -} - -/* - * nss_wifi_stats_sync() - * Handle the syncing of WIFI stats. - */ -void nss_wifi_stats_sync(struct nss_ctx_instance *nss_ctx, - struct nss_wifi_stats_sync_msg *stats, uint16_t interface) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - uint32_t radio_id = interface - NSS_WIFI_INTERFACE0; - uint8_t i = 0; - - if (radio_id >= NSS_MAX_WIFI_RADIO_INTERFACES) { - nss_warning("%px: invalid interface: %d", nss_ctx, interface); - return; - } - - spin_lock_bh(&nss_top->stats_lock); - - /* - * Tx/Rx stats - */ - nss_wifi_stats[radio_id][NSS_WIFI_STATS_RX_PKTS] += stats->node_stats.rx_packets; - for (i = 0; i < NSS_MAX_NUM_PRI; i++) { - nss_wifi_stats[radio_id][NSS_WIFI_STATS_RX_QUEUE_0_DROPPED + i] += stats->node_stats.rx_dropped[i]; - } - nss_wifi_stats[radio_id][NSS_WIFI_STATS_TX_PKTS] += stats->node_stats.tx_packets; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_TX_DROPPED] += stats->tx_transmit_dropped; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_TX_COMPLETED] += stats->tx_transmit_completions; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_MGMT_RCV_CNT] += stats->tx_mgmt_rcv_cnt; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_MGMT_TX_PKTS] += stats->tx_mgmt_pkts; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_MGMT_TX_DROPPED] += stats->tx_mgmt_dropped; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_MGMT_TX_COMPLETIONS] += stats->tx_mgmt_completions; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_TX_INV_PEER_ENQUEUE_CNT] += stats->tx_inv_peer_enq_cnt; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_RX_INV_PEER_RCV_CNT] += stats->rx_inv_peer_rcv_cnt; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_RX_PN_CHECK_FAILED] += stats->rx_pn_check_failed; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_RX_DELIVERED] += stats->rx_pkts_deliverd; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_RX_BYTES_DELIVERED] += stats->rx_bytes_deliverd; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_TX_BYTES_COMPLETED] += stats->tx_bytes_transmit_completions; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_RX_DELIVER_UNALIGNED_DROP_CNT] += stats->rx_deliver_unaligned_drop_cnt; - - for (i = 0; i < NSS_WIFI_TX_NUM_TOS_TIDS; i++) { - nss_wifi_stats[radio_id][NSS_WIFI_STATS_TIDQ_ENQUEUE_CNT + i] += stats->tidq_enqueue_cnt[i]; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_TIDQ_DEQUEUE_CNT + i] += stats->tidq_dequeue_cnt[i]; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_TIDQ_ENQUEUE_FAIL_CNT + i] += stats->tidq_enqueue_fail_cnt[i]; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_TIDQ_TTL_EXPIRE_CNT + i] += stats->tidq_ttl_expire_cnt[i]; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_TIDQ_DEQUEUE_REQ_CNT + i] += stats->tidq_dequeue_req_cnt[i]; - } - - nss_wifi_stats[radio_id][NSS_WIFI_STATS_RX_HTT_FETCH_CNT] += stats->rx_htt_fetch_cnt; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_TOTAL_TIDQ_DEPTH] = stats->total_tidq_depth; - 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; - - spin_unlock_bh(&nss_top->stats_lock); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_stats.h deleted file mode 100644 index 782777777..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_stats.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - ****************************************************************************** - * 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_STATS_H -#define __NSS_WIFI_STATS_H - -/* - * wifi statistics - */ -enum nss_wifi_stats_types { - NSS_WIFI_STATS_RX_PKTS, - NSS_WIFI_STATS_RX_QUEUE_0_DROPPED, - NSS_WIFI_STATS_RX_QUEUE_1_DROPPED, - NSS_WIFI_STATS_RX_QUEUE_2_DROPPED, - NSS_WIFI_STATS_RX_QUEUE_3_DROPPED, - NSS_WIFI_STATS_TX_PKTS, - NSS_WIFI_STATS_TX_DROPPED, - NSS_WIFI_STATS_TX_COMPLETED, - NSS_WIFI_STATS_MGMT_RCV_CNT, - NSS_WIFI_STATS_MGMT_TX_PKTS, - NSS_WIFI_STATS_MGMT_TX_DROPPED, - NSS_WIFI_STATS_MGMT_TX_COMPLETIONS, - NSS_WIFI_STATS_TX_INV_PEER_ENQUEUE_CNT, - NSS_WIFI_STATS_RX_INV_PEER_RCV_CNT, - NSS_WIFI_STATS_RX_PN_CHECK_FAILED, - NSS_WIFI_STATS_RX_DELIVERED, - NSS_WIFI_STATS_RX_BYTES_DELIVERED, - NSS_WIFI_STATS_TX_BYTES_COMPLETED, - NSS_WIFI_STATS_RX_DELIVER_UNALIGNED_DROP_CNT, - NSS_WIFI_STATS_TIDQ_ENQUEUE_CNT, - NSS_WIFI_STATS_TIDQ_DEQUEUE_CNT = NSS_WIFI_STATS_TIDQ_ENQUEUE_CNT + 8, - NSS_WIFI_STATS_TIDQ_ENQUEUE_FAIL_CNT = NSS_WIFI_STATS_TIDQ_DEQUEUE_CNT + 8, - NSS_WIFI_STATS_TIDQ_TTL_EXPIRE_CNT = NSS_WIFI_STATS_TIDQ_ENQUEUE_FAIL_CNT + 8, - NSS_WIFI_STATS_TIDQ_DEQUEUE_REQ_CNT = NSS_WIFI_STATS_TIDQ_TTL_EXPIRE_CNT + 8, - NSS_WIFI_STATS_TOTAL_TIDQ_DEPTH = NSS_WIFI_STATS_TIDQ_DEQUEUE_REQ_CNT + 8, - NSS_WIFI_STATS_RX_HTT_FETCH_CNT, - NSS_WIFI_STATS_TOTAL_TIDQ_BYPASS_CNT, - NSS_WIFI_STATS_GLOBAL_Q_FULL_CNT, - NSS_WIFI_STATS_TIDQ_FULL_CNT, - NSS_WIFI_STATS_MAX, -}; - -/* - * wifi statistics APIs - */ -extern void nss_wifi_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_wifi_stats_sync_msg *stats, uint16_t interface); -extern void nss_wifi_stats_dentry_create(void); - -#endif /* __NSS_WIFI_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_vdev.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifi_vdev.c deleted file mode 100644 index 8f020b2a6..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifi_vdev.c +++ /dev/null @@ -1,379 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -#include "nss_tx_rx_common.h" - -/* - * nss_wifi_vdev_handler() - * Handle NSS -> HLOS messages for wifi_vdev - */ -static void nss_wifi_vdev_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - nss_wifi_vdev_msg_callback_t cb; - - 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)))); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_WIFI_VDEV_MAX_MSG) { - 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("%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; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * callback - */ - if (!nss_ctx->subsys_dp_register[ncm->interface].ndev) { - 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_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 callback? - */ - if (!ncm->cb) { - return; - } - - cb = (nss_wifi_vdev_msg_callback_t)ncm->cb; - cb((void *)ncm->app_data, ncm); -} - -/* - * nss_wifi_vdev_msg_init() - * Initialize wifi message. - */ -void nss_wifi_vdev_msg_init(struct nss_wifi_vdev_msg *nim, uint32_t if_num, uint32_t type, uint32_t len, - nss_wifi_vdev_msg_callback_t *cb, void *app_data) -{ - nss_cmn_msg_init(&nim->cm, if_num, type, len, (void *)cb, app_data); -} -EXPORT_SYMBOL(nss_wifi_vdev_msg_init); - -/* - * nss_wifi_vdev_base_tx_msg() - * Transmit a wifi vdev base message to NSSFW - */ -nss_tx_status_t nss_wifi_vdev_base_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_wifi_vdev_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - nss_trace("%px: Sending wifi vdev message on interface :%d", nss_ctx, ncm->interface); - - /* - * Sanity checks on the message - */ - - /* - * The interface number shall be wifi vdev base vap - */ - if (ncm->interface != NSS_VAP_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("%px: wifi vdev base 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); -} -EXPORT_SYMBOL(nss_wifi_vdev_base_tx_msg); - -/* - * nss_wifi_vdev_tx_msg() - * Transmit a wifi vdev message to NSSFW - */ -nss_tx_status_t nss_wifi_vdev_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_wifi_vdev_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - nss_trace("%px: Sending wifi vdev message on interface :%d", nss_ctx, ncm->interface); - - /* - * Sanity checks on the message - */ - - /* - * 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("%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("%px: wifi vdev 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); -} -EXPORT_SYMBOL(nss_wifi_vdev_tx_msg); - -/* - * nss_wifi_vdev_tx_msg_ext() - * Send special data packet with metadata for vap processing - */ -nss_tx_status_t nss_wifi_vdev_tx_msg_ext(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf) -{ - struct nss_wifi_vdev_msg *nm; - struct nss_cmn_msg *ncm; - nss_tx_status_t status; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { - 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("%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("%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("%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("%px: Unable to enqueue 'wifi vdev message'", nss_ctx); - return NSS_TX_FAILURE; - } - - nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); - - NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_CMD_REQ]); - -return status; -} -EXPORT_SYMBOL(nss_wifi_vdev_tx_msg_ext); - -/* - * nss_wifi_vdev_tx_buf - * Send data packet for vap processing - */ -nss_tx_status_t nss_wifi_vdev_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, uint32_t if_num) -{ - BUG_ON(((if_num < NSS_DYNAMIC_IF_START) || (if_num >= (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES)))); - - return nss_core_send_packet(nss_ctx, os_buf, if_num, H2N_BIT_FLAG_BUFFER_REUSABLE); -} -EXPORT_SYMBOL(nss_wifi_vdev_tx_buf); - -/* - * nss_wifi_vdev_set_next_hop() - */ -nss_tx_status_t nss_wifi_vdev_set_next_hop(struct nss_ctx_instance *ctx, int if_num, int next_hop) -{ - nss_tx_status_t status; - struct nss_wifi_vdev_msg *wifivdevmsg = kzalloc(sizeof(struct nss_wifi_vdev_msg), GFP_KERNEL); - struct nss_wifi_vdev_set_next_hop_msg *next_hop_msg = NULL; - - if (!wifivdevmsg) { - nss_warning("%px: Unable to allocate next hop message", ctx); - return NSS_TX_FAILURE; - } - - next_hop_msg = &wifivdevmsg->msg.next_hop; - - next_hop_msg->ifnumber = next_hop; - nss_wifi_vdev_msg_init(wifivdevmsg, if_num, NSS_WIFI_VDEV_SET_NEXT_HOP, sizeof(struct nss_wifi_vdev_set_next_hop_msg), NULL, NULL); - - status = nss_wifi_vdev_tx_msg(ctx, wifivdevmsg); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: Unable to send next hop message", ctx); - } - - kfree(wifivdevmsg); - return status; -} -EXPORT_SYMBOL(nss_wifi_vdev_set_next_hop); - -/* - * nss_wifi_vdev_base_set_next_hop() - */ -nss_tx_status_t nss_wifi_vdev_base_set_next_hop(struct nss_ctx_instance *ctx, int next_hop) -{ - nss_tx_status_t status; - struct nss_wifi_vdev_msg *wifivdevmsg = kzalloc(sizeof(struct nss_wifi_vdev_msg), GFP_KERNEL); - struct nss_wifi_vdev_set_next_hop_msg *next_hop_msg = NULL; - - if (!wifivdevmsg) { - nss_warning("%px: Unable to allocate next hop message", ctx); - return NSS_TX_FAILURE; - } - - next_hop_msg = &wifivdevmsg->msg.next_hop; - - next_hop_msg->ifnumber = next_hop; - nss_wifi_vdev_msg_init(wifivdevmsg, NSS_VAP_INTERFACE, NSS_WIFI_VDEV_SET_NEXT_HOP, sizeof(struct nss_wifi_vdev_set_next_hop_msg), NULL, NULL); - - status = nss_wifi_vdev_base_tx_msg(ctx, wifivdevmsg); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: Unable to send next hop message", ctx); - } - - kfree(wifivdevmsg); - return status; -} -EXPORT_SYMBOL(nss_wifi_vdev_base_set_next_hop); - -/* - * nss_wifi_vdev_set_peer_next_hop() - */ -nss_tx_status_t nss_wifi_vdev_set_peer_next_hop(struct nss_ctx_instance *ctx, uint32_t nss_if, uint8_t *addr, uint32_t next_hop_if) -{ - nss_tx_status_t status; - struct nss_wifi_vdev_msg *wifivdevmsg = kzalloc(sizeof(struct nss_wifi_vdev_msg), GFP_KERNEL); - struct nss_wifi_vdev_set_peer_next_hop_msg *peer_next_hop_msg = NULL; - - if (!wifivdevmsg) { - nss_warning("%px: Unable to allocate next hop message", ctx); - return NSS_TX_FAILURE; - } - - peer_next_hop_msg = &wifivdevmsg->msg.vdev_set_peer_next_hp; - memcpy(peer_next_hop_msg->peer_mac_addr, addr, ETH_ALEN); - - peer_next_hop_msg->if_num = next_hop_if; - nss_wifi_vdev_msg_init(wifivdevmsg, nss_if, NSS_WIFI_VDEV_SET_PEER_NEXT_HOP, - sizeof(struct nss_wifi_vdev_set_peer_next_hop_msg), NULL, NULL); - - status = nss_wifi_vdev_tx_msg(ctx, wifivdevmsg); - if (status != NSS_TX_SUCCESS) { - nss_warning("%px: Unable to send peer next hop message", ctx); - } - - kfree(wifivdevmsg); - return status; -} -EXPORT_SYMBOL(nss_wifi_vdev_set_peer_next_hop); - -/* - * nss_wifi_vdev_set_dp_type() - * Set the vap datapath type of the packet. - */ -bool nss_wifi_vdev_set_dp_type(struct nss_ctx_instance *nss_ctx, struct net_device *netdev, - uint32_t if_num, enum nss_wifi_vdev_dp_type dp_type) -{ - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - - 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("%px: Vap interface dp type could not be set as core is not initialized\n", nss_ctx); - return false; - } - - /* - * set the subsytem dp type for the Wi-Fi vdev - */ - nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, dp_type); - - return true; -} -EXPORT_SYMBOL(nss_wifi_vdev_set_dp_type); - -/* - *********************************** - * Register/Unregister/Miscellaneous APIs - *********************************** - */ - -/* - * nss_register_wifi_vdev_if() - */ -uint32_t nss_register_wifi_vdev_if(struct nss_ctx_instance *nss_ctx, - int32_t if_num, - nss_wifi_vdev_callback_t vdev_data_callback, - nss_wifi_vdev_ext_data_callback_t vdev_ext_data_callback, - nss_wifi_vdev_msg_callback_t vdev_event_callback, - 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); - - 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); - - return NSS_CORE_STATUS_SUCCESS; -} -EXPORT_SYMBOL(nss_register_wifi_vdev_if); - -/* - * nss_unregister_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); - - 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); -} -EXPORT_SYMBOL(nss_unregister_wifi_vdev_if); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifili.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifili.c deleted file mode 100644 index c1904e465..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifili.c +++ /dev/null @@ -1,670 +0,0 @@ -/* - ************************************************************************** - * Copyright (c) 2017-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_wifili_stats.h" -#include "nss_wifili_log.h" -#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 - * Private data structure - */ -static struct nss_wifili_pvt { - struct semaphore sem; - struct completion complete; - int response; - void *cb; - void *app_data; -} 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 - */ -static void nss_wifili_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) -{ - struct nss_wifili_msg *ntm = (struct nss_wifili_msg *)ncm; - void *ctx; - nss_wifili_msg_callback_t cb; - - 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) - && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE0) - && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE1))); - - /* - * Trace messages. - */ - nss_wifili_log_rx_msg(ntm); - - /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_WIFILI_MAX_MSG) { - 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)) && - 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; - } - - /* - * Snoop messages for local driver and handle - */ - switch (ntm->cm.type) { - case NSS_WIFILI_STATS_MSG: - /* - * Update WIFI driver statistics and send statistics notifications to the registered modules - */ - nss_wifili_stats_sync(nss_ctx, &ntm->msg.wlsoc_stats, ncm->interface); - nss_wifili_stats_notify(nss_ctx, ncm->interface); - break; - } - - /* - * Update the callback and app_data for notify messages, wifili sends all notify messages - * to the same callback/app_data. - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_ctx->nss_top->wifili_msg_callback; - } - - /* - * Log failures - */ - nss_core_log_msg_failures(nss_ctx, ncm); - - /* - * Do we have a call back - */ - if (!ncm->cb) { - nss_info("%px: cb null for wifili interface %d", nss_ctx, ncm->interface); - return; - } - - /* - * Get callback & context - */ - cb = (nss_wifili_msg_callback_t)ncm->cb; - ctx = nss_ctx->subsys_dp_register[ncm->interface].ndev; - - /* - * call wifili msg callback - */ - if (!ctx) { - nss_warning("%px: Event received for wifili interface %d before registration", nss_ctx, ncm->interface); - return; - } - - cb(ctx, ntm); -} - -/* - * nss_wifili_callback() - * Callback to handle the completion of NSS->HLOS messages. - */ -static void nss_wifili_callback(void *app_data, struct nss_wifili_msg *nvm) -{ - nss_wifili_msg_callback_t callback = (nss_wifili_msg_callback_t)wifili_pvt.cb; - void *data = wifili_pvt.app_data; - - wifili_pvt.response = NSS_TX_SUCCESS; - wifili_pvt.cb = NULL; - wifili_pvt.app_data = NULL; - - if (nvm->cm.response != NSS_CMN_RESPONSE_ACK) { - nss_warning("wifili error response %d\n", nvm->cm.response); - wifili_pvt.response = nvm->cm.response; - } - - if (callback) { - callback(data, nvm); - } - complete(&wifili_pvt.complete); -} - -/* - * nss_wifili_tx_msg - * Transmit a wifili message to NSS FW - * - * NOTE: The caller is expected to handle synchronous wait for message - * response if needed. - */ -nss_tx_status_t nss_wifili_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_wifili_msg *msg) -{ - struct nss_cmn_msg *ncm = &msg->cm; - - /* - * Trace messages. - */ - nss_wifili_log_tx_msg(msg); - - if (ncm->type >= NSS_WIFILI_MAX_MSG) { - nss_warning("%px: wifili message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - - /* - * The interface number shall be one of the wifili soc interfaces - */ - if ((ncm->interface != NSS_WIFILI_INTERNAL_INTERFACE) - && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE0) - && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE1)) { - nss_warning("%px: tx request for interface that is not a wifili: %d", nss_ctx, ncm->interface); - return NSS_TX_FAILURE; - } - - return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); -} -EXPORT_SYMBOL(nss_wifili_tx_msg); - -/* - * nss_wifili_tx_msg_sync() - * Transmit a wifili message to NSS firmware synchronously. - */ -nss_tx_status_t nss_wifili_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_wifili_msg *nvm) -{ - nss_tx_status_t status; - int ret = 0; - - down(&wifili_pvt.sem); - wifili_pvt.cb = (void *)nvm->cm.cb; - wifili_pvt.app_data = (void *)nvm->cm.app_data; - - nvm->cm.cb = (nss_ptr_t)nss_wifili_callback; - nvm->cm.app_data = (nss_ptr_t)NULL; - - status = nss_wifili_tx_msg(nss_ctx, nvm); - if (status != NSS_TX_SUCCESS) { - 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("%px: wifili msg tx failed due to timeout\n", nss_ctx); - wifili_pvt.response = NSS_TX_FAILURE; - } - - status = wifili_pvt.response; - up(&wifili_pvt.sem); - return status; -} -EXPORT_SYMBOL(nss_wifili_tx_msg_sync); - -/* - * nss_wifili_get_context() - */ -struct nss_ctx_instance *nss_wifili_get_context(void) -{ - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; -} -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) -{ - nss_if_num_t ifnum = -1; - uint32_t idx; - - /* - * 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; - } - - 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; - } - 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); - - return NSS_WIFILI_INVALID_SCHEME_ID; -} -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); - } - } -} - -/* - * nss_wifili_msg_init() - * Initialize nss_wifili_msg. - */ -void nss_wifili_msg_init(struct nss_wifili_msg *ncm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data) -{ - nss_cmn_msg_init(&ncm->cm, if_num, type, len, cb, app_data); -} -EXPORT_SYMBOL(nss_wifili_msg_init); - -/* - **************************************** - * Register/Unregister/Miscellaneous APIs - **************************************** - */ - -/* - * nss_register_wifili_if() - * Register wifili with nss driver - */ -struct nss_ctx_instance *nss_register_wifili_if(uint32_t if_num, nss_wifili_callback_t wifili_callback, - nss_wifili_callback_t wifili_ext_callback, - nss_wifili_msg_callback_t event_callback, struct net_device *netdev, uint32_t features) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; - - /* - * The interface number shall be wifili soc interface - */ - nss_assert((if_num == NSS_WIFILI_INTERNAL_INTERFACE) - || (if_num == NSS_WIFILI_EXTERNAL_INTERFACE0) - || (if_num == NSS_WIFILI_EXTERNAL_INTERFACE1)); - - 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); - - nss_top_main.wifili_msg_callback = event_callback; - - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; -} -EXPORT_SYMBOL(nss_register_wifili_if); - -/* - * nss_unregister_wifili_if() - * Unregister wifili with nss driver - */ -void nss_unregister_wifili_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]; - - /* - * The interface number shall be wifili soc interface - */ - nss_assert((if_num == NSS_WIFILI_INTERNAL_INTERFACE) - || (if_num == NSS_WIFILI_EXTERNAL_INTERFACE0) - || (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); - -/* - * nss_register_wifili_radio_if() - * Register wifili radio with nss driver - */ -struct nss_ctx_instance *nss_register_wifili_radio_if(uint32_t if_num, nss_wifili_callback_t wifili_callback, - nss_wifili_callback_t wifili_ext_callback, - nss_wifili_msg_callback_t event_callback, struct net_device *netdev, uint32_t features) -{ - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; - - /* - * 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 %px", if_num, netdev); - - nss_core_register_subsys_dp(nss_ctx, if_num, wifili_callback, wifili_ext_callback, NULL, netdev, features); - - return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; -} -EXPORT_SYMBOL(nss_register_wifili_radio_if); - -/* - * nss_unregister_wifili_radio_if() - * Unregister wifili radio with nss driver - */ -void nss_unregister_wifili_radio_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]; - - /* - * The interface number shall be wifili radio dynamic interface - */ - nss_assert(nss_is_dynamic_interface(if_num)); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); -} -EXPORT_SYMBOL(nss_unregister_wifili_radio_if); - -/* - * nss_wifili_register_handler() - * Register handle for notfication messages received on wifi interface - */ -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); - 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_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; - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifili_log.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifili_log.c deleted file mode 100644 index 7c679dfca..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifili_log.c +++ /dev/null @@ -1,553 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_wifili_log.c - * NSS WIFILI logger file. - */ - -#include "nss_core.h" - -/* - * nss_wifili_log_message_types_str - * WIFILI message strings - */ -static int8_t *nss_wifili_log_message_types_str[NSS_WIFILI_MAX_MSG] __maybe_unused = { - "WIFILI INIT MSG", - "WIFILI SOC RESET MSG", - "WIFILI PDEV INIT MSG", - "WIFILI PDEV DEINIT MSG", - "WIFILI START MSG", - "WIFILI STOP MSG", - "WIFILI PEER CREATE MSG", - "WIFILI PEER DELETE MSG", - "WIFILI SEND PEER MEMORY REQUEST MSG", - "WIFILI PEER FREELIST APPEND MSG", - "WIFILI STATS MSG", - "WIFILI WDS VENDOR MSG", - "WIFILI PEER STATS MSG", - "WIFILI WDS PEER ADD MSG", - "WIFILI WDS PEER DEL MSG", - "WIFILI WDS PEER MAP MSG", - "WIFILI WDS ACTIVE INFO MSG", - "WIFILI STATS CFG MSG", - "WIFILI TID REOQ SETUP MSG", - "WIFILI RADIO CMD MSG", - "WIFILI LINK DESC INFO MSG", - "WIFILI PEER SECURITY TYPE MSG", - "WIFILI PEER NAWDS ENABLE MSG", - "WIFILI RADIO BUF CFG", - "WIFILI DBDC REPEATER SET MSG", - "WIFILI DBDC REPEATER AST FLUSH MSG" -}; - -/* - * nss_wifili_log_error_response_types_str - * Strings for error types for WIFILI messages - */ -static int8_t *nss_wifili_log_error_response_types_str[NSS_WIFILI_EMSG_UNKNOWN] __maybe_unused = { - "WIFILI NO ERROR", - "WIFILI INIT FAIL IMPROPER STATE", - "WIFILI RINGS INIT FAIL", - "WIFILI PDEV INIT IMPROPER STATE FAIL", - "WIFILI PDEV INIT INVALID RADIOID FAIL", - "WIFILI PDEV TX IRQ ALLOC FAIL", - "WIFILI PDEV RESET INVALID RADIOID FAIL", - "WIFILI PDEV RESET PDEV NULL FAIL", - "WIFILI PDEV RESET IMPROPER STATE FAIL", - "WIFILI START IMPROPER STATE FAIL", - "WIFILI PEER CREATE FAIL", - "WIFILI PEER DELETE FAIL", - "WIFILI HASHMEM INIT FAIL", - "WIFILI PEER FREELIST APPEND FAIL", - "WIFILI PEER CREATE INVALID VDEVID FAIL", - "WIFILI PEER CREATE INVALID PEER ID FAIL", - "WIFILI PEER CREATE VDEV NULL FAIL", - "WIFILI PEER CREATE PDEV NULL FAIL", - "WIFILI PEER CREATE ALLOC FAIL", - "WIFILI PEER DELETE VAPID INVALID FAIL", - "WIFILI PEER DELETE INVALID PEERID FAIL", - "WIFILI PEER DELETE VDEV NULL FAIL", - "WIFILI PEER DELETE PDEV NULL FAIL", - "WIFILI PEER DELETE PEER NULL FAIL", - "WIFILI PEER DELETE PEER CORRUPTED FAIL", - "WIFILI PEER DUPLICATE AST INDEX PEER ID FAIL", - "WIFILI GROUP0 TIMER ALLOC FAIL", - "WIFILI INSUFFICIENT WT FAIL", - "WIFILI INVALID NUM TCL RING FAIL", - "WIFILI INVALID NUM REO DST RING FAIL", - "WIFILI HAL SRNG SOC ALLOC FAIL", - "WIFILI HAL SRNG INVALID RING INFO FAIL", - "WIFILI HAL SRNG TCL ALLOC FAIL", - "WIFILI HAL SRNG TXCOMP ALLOC FAIL", - "WIFILI HAL SRNG REODST ALLOC FAIL", - "WIFILI HAL SRNG REOREINJECT ALLOC FAIL", - "WIFILI HAL SRNG RXRELEASE ALLOC FAIL", - "WIFILI HAL SRNG RXEXCP ALLOC FAIL", - "WIFILI HAL TX MEMALLOC FAIL", - "WIFILI HAL TX INVLID POOL NUM FAIL", - "WIFILI HAL TX INVALID PAGE NUM FAIL", - "WIFILI HAL TX DESC MEM ALLOC FAIL", - "WIFILI HAL RX MEMALLOC FAIL", - "WIFILI PDEV RXDMA RING ALLOC FAIL", - "WIFILI NAWDSEN PEERID INVALID", - "WIFILI NAWDSEN PEER NULL", - "WIFILI NAWDSEN PEER CORRUPTED", - "WIFILI WDS PEER CFG FAIL", - "WIFILI RESET NO STOP", - "WIFILI HAL SRNG INVALID RING BASE FAIL", - "WIFILI PDEV RX INIT FAIL", - "WIFILI EMESG AST ADD FAIL", - "WIFILI EMESG AST REMOVE FAIL", - "WIFILI EMESG WDS ADD FAIL", - "WIFILI EMESG WDS REMOVE FAIL", - "WIFILI EMESG WDS MAP FAIL", - "WIFILI WDS INVALID PEERID FAIL", - "WIFILI WDS DUPLICATE AST INDEX PEER ID FAIL", - "WIFILI INVALID RADIO CMD", - "WIFILI INVALID RADIO IFNUM", - "WIFILI PEER SECURITY PEER NULL FAIL", - "WIFILI PEER SECURITY PEER CORRUPTED FAIL", - "WIFILI RADIO INVALID BUF CFG", -}; - -/* - * nss_wifili_log_wifili_hal_srng() - * Log NSS WIFILI HAL SRNG Information - */ -static void nss_wifili_log_wifili_hal_srng(struct nss_wifili_hal_srng_info *ring) -{ - int32_t i; - nss_trace("\tRing ID: %d\n" - "\tMAC ID: %d\n" - "\tRing base physical address: %x\n" - "\tNumber of entries: %d\n" - "\tFlags: %x\n" - "\tDirection: %d\n" - "\tEntry size: %d\n" - "\tLow Threshold: %d\n", - ring->ring_id, ring->mac_id, - ring->ring_base_paddr, ring->num_entries, - ring->flags, ring->ring_dir, - ring->entry_size, ring->low_threshold); - nss_trace("Ring Base Addresses:"); - for (i = 0; i < NSS_WIFILI_MAX_SRNG_REG_GROUPS_MSG; i++) { - nss_trace("\t%x", ring->hwreg_base[i]); - } -} - -/* - * nss_wifili_log_init_msg() - * Log NSS WIFILI Init message. - */ -static void nss_wifili_log_init_msg(struct nss_wifili_msg *nwm) -{ - struct nss_wifili_init_msg *nwim __maybe_unused = &nwm->msg.init; - int32_t i; - 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" - "WIFILI Number of Transmit Classifier data rings: %d\n" - "WIFILI Number of reorder rings: %d\n" - "WIFILI Flags for SoC initialization: %d\n" - "WIFILI Tx descriptor initialization number of software descriptors: %d" - "WIFILI Tx descriptor initialization number of software extended descriptors: %d" - "WIFILI Tx descriptor initialization number of descriptor pools: %d" - "WIFILI Tx descriptor initialization number of memory addresses: %d" - "WIFILI Tx descriptor initialization extended descriptor page number: %d" - "WIFILI Tx descriptor initialization number of software secriptors for second radio: %d" - "WIFILI Tx descriptor initialization number of software extended descriptors for second radio: %d", - nwim, nwim->hssm.dev_base_addr, - nwim->hssm.shadow_rdptr_mem_addr, nwim->hssm.shadow_wrptr_mem_addr, - nwim->num_tcl_data_rings, nwim->num_reo_dest_rings, - nwim->flags, nwim->wtdim.num_tx_desc, - nwim->wtdim.num_tx_desc_ext, nwim->wtdim.num_pool, - nwim->wtdim.num_memaddr, nwim->wtdim.ext_desc_page_num, - nwim->wtdim.num_tx_desc_2, nwim->wtdim.num_tx_desc_ext_2); - /* - * Continuation of the log. - */ - nss_trace("WIFILI Tx descriptor initialization memory start address and size:"); - for (i = 0; i < NSS_WIFILI_MAX_NUMBER_OF_PAGE_MSG; i++) { - nss_trace("\tPage[%d]: Addr: %x Size: %d", i, nwim->wtdim.memory_addr[i], nwim->wtdim.memory_size[i]); - } - nss_trace("WIFILI Transmit Classifier data ring Information:"); - for (i = 0; i < NSS_WIFILI_MAX_TCL_DATA_RINGS_MSG; i++) { - nss_wifili_log_wifili_hal_srng(&nwim->tcl_ring_info[i]); - } - nss_trace("WIFILI TX Completion Ring configuration information:"); - for (i = 0; i < NSS_WIFILI_MAX_TCL_DATA_RINGS_MSG; i++) { - nss_wifili_log_wifili_hal_srng(&nwim->tx_comp_ring[i]); - } - nss_trace("WIFILI Reorder destination ring configuration information:"); - for (i = 0; i < NSS_WIFILI_MAX_REO_DATA_RINGS_MSG; i++) { - nss_wifili_log_wifili_hal_srng(&nwim->reo_dest_ring[i]); - } - nss_trace("WIFILI Reorder exception ring configuration information:"); - nss_wifili_log_wifili_hal_srng(&nwim->reo_exception_ring); - nss_trace("WIFILI Reinject ring configuration information:"); - nss_wifili_log_wifili_hal_srng(&nwim->reo_reinject_ring); -} - -/* - * nss_wifili_log_pdev_init_msg() - * Log NSS WIFILI PDEV Init message. - */ -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("%px: NSS WIFILI PDEV Init Message:\n" - "WIFILI Radio ID: %x\n" - "WIFILI MAC Hardware Mode: %d\n" - "WIFILI Lower MAC ID: %x\n", - nwim, nwim->radio_id, - nwim->hwmode, nwim->lmac_id); - /* - * Continuation of the log. - */ - nss_trace("WIFILI Media Access Point ring information:"); - nss_wifili_log_wifili_hal_srng(&nwim->rxdma_ring); -} - -/* - * nss_wifili_log_pdev_init_msg() - * Log NSS WIFILI PDEV Deinit message. - */ -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("%px: NSS WIFILI PDEV Deinit Message:\n" - "WIFILI Interface Number: %d\n", - nwim, nwim->ifnum); -} - -/* - * nss_wifili_log_peer_msg() - * Log NSS WIFILI Peer message. - */ -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("%px: NSS WIFILI Peer Message:\n" - "WIFILI Peer MAC Address: %pM\n" - "WIFILI VAP ID: %d\n" - "WIFILI Peed ID: %d\n" - "WIFILI Hardware address search table index: %d\n" - "WIFILI NAWDS enabled for peer: %d\n" - "WIFILI peer memory adderss for NSS: %x\n", - nwim, nwim->peer_mac_addr, - nwim->vdev_id, nwim->peer_id, - nwim->hw_ast_idx, nwim->is_nawds, - nwim->nss_peer_mem); -} - -/* - * nss_wifili_log_peer_freelist_append_msg() - * Log NSS WIFILI Peer memory request message. - */ -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("%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", - nwim, nwim->addr, - nwim->length, nwim->num_peers); -} - -/* - * nss_wifili_log_wds_peer_msg() - * Log NSS WIFILI WDS Peer message. - */ -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("%px: NSS WIFILI WDS Peer Message:\n" - "WIFILI Destination MAC: %pM\n" - "WIFILI Peer MAC: %pM\n", - nwim, nwim->dest_mac, nwim->peer_mac); -} - -/* - * nss_wifili_log_wds_active_info_msg() - * Log NSS WIFILI WDS Active Info message. - */ -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("%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); -} - -/* - * nss_wifili_log_stats_cfg_msg() - * Log NSS WIFILI Stats Configuration Message. - */ -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("%px: NSS WIFILI Stats Config Message:\n" - "WIFILI Enable/Disable Config: %d\n", - nwim, nwim->cfg); -} - -/* - * nss_wifili_log_reo_tidq_msg() - * Log NSS WIFILI REO TIDQ Setup Message. - */ -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("%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); -} - -/* - * nss_wifili_log_radio_cfg_msg() - * Log NSS WIFILI Radio Command Message. - */ -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("%px: NSS WIFILI Radio Command Message:\n" - "WIFILI Radio Interface Number %d\n", - nwim, nwim->radio_if_num); -} - -/* - * nss_wifili_log_wds_extn_peer_cfg_msg() - * Log NSS WIFILI WDS vendor extension configuration message. - */ -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("%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", - nwim, nwim->peer_mac_addr, - nwim->wds_flags, nwim->peer_id); -} - -/* - * nss_wifili_log_soc_linkdesc_buf_info_msg() - * Log NSS WIFILI Link descriptor buffer address information. - */ -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("%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, - nwim->buffer_addr_high); -} - -/* - * nss_wifili_log_peer_security_msg() - * Log NSS WIFILI Peer Security Message. - */ -static void nss_wifili_log_peer_security_msg(struct nss_wifili_msg *nwm) -{ - struct nss_wifili_peer_security_type_msg *nwim __maybe_unused = &nwm->msg.securitymsg; - int32_t i; - nss_trace("%px: NSS WIFILI Peer Security Message:\n" - "WIFILI Peer ID: %d\n" - "WIFILI Packet Type: %d\n" - "WIFILI Security Type: %d\n", - nwim, nwim->peer_id, - nwim->pkt_type, nwim->security_type); - /* - * Continuation of the log. - */ - nss_trace("WIFILI MIC KEY:"); - for (i = 0; i < NSS_WIFILI_MIC_KEY_LEN; i++) { - nss_trace("\t%x", nwim->mic_key[i]); - } -} - -/* - * nss_wifili_log_peer_nawds_enable_msg() - * Log NSS WIFILI NAWDS enable for peer. - */ -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("%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); -} - -/* - * nss_wifili_log_dbdc_repeater_set_msg() - * Log NSS WIFILI DBDC Repeaster Enable Message - */ -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("%px: NSS WIFILI DBDC Repeater Enable Message:\n" - "WIFILI DBDC Enable Flag: %d\n", - nwim, nwim->is_dbdc_en); -} - -/* - * nss_wifili_log_verbose() - * Log message contents. - */ -static void nss_wifili_log_verbose(struct nss_wifili_msg *nwm) -{ - switch (nwm->cm.type) { - case NSS_WIFILI_INIT_MSG: - nss_wifili_log_init_msg(nwm); - break; - - case NSS_WIFILI_SOC_RESET_MSG: - break; - - case NSS_WIFILI_PDEV_INIT_MSG: - nss_wifili_log_pdev_init_msg(nwm); - break; - - case NSS_WIFILI_PDEV_DEINIT_MSG: - nss_wifili_log_pdev_deinit_msg(nwm); - break; - - case NSS_WIFILI_PEER_CREATE_MSG: - case NSS_WIFILI_PEER_DELETE_MSG: - nss_wifili_log_peer_msg(nwm); - break; - - case NSS_WIFILI_PEER_FREELIST_APPEND_MSG: - nss_wifili_log_peer_freelist_append_msg(nwm); - break; - - case NSS_WIFILI_WDS_VENDOR_MSG: - nss_wifili_log_wds_extn_peer_cfg_msg(nwm); - break; - - case NSS_WIFILI_WDS_PEER_ADD_MSG: - case NSS_WIFILI_WDS_PEER_DEL_MSG: - case NSS_WIFILI_WDS_PEER_MAP_MSG: - nss_wifili_log_wds_peer_msg(nwm); - break; - - case NSS_WIFILI_WDS_ACTIVE_INFO_MSG: - nss_wifili_log_wds_active_info_msg(nwm); - break; - - case NSS_WIFILI_STATS_CFG_MSG: - nss_wifili_log_stats_cfg_msg(nwm); - break; - - case NSS_WIFILI_TID_REOQ_SETUP_MSG: - nss_wifili_log_reo_tidq_msg(nwm); - break; - - case NSS_WIFILI_RADIO_CMD_MSG: - nss_wifili_log_radio_cfg_msg(nwm); - break; - - case NSS_WIFILI_LINK_DESC_INFO_MSG: - nss_wifili_log_soc_linkdesc_buf_info_msg(nwm); - break; - - case NSS_WIFILI_PEER_SECURITY_TYPE_MSG: - nss_wifili_log_peer_security_msg(nwm); - break; - - case NSS_WIFILI_PEER_NAWDS_ENABLE_MSG: - nss_wifili_log_peer_nawds_enable_msg(nwm); - break; - - case NSS_WIFILI_DBDC_REPEATER_SET_MSG: - nss_wifili_log_dbdc_repeater_set_msg(nwm); - break; - - case NSS_WIFILI_SOJOURN_STATS_MSG: - case NSS_DBDC_REPEATER_AST_FLUSH_MSG: - case NSS_WIFILI_SEND_PEER_MEMORY_REQUEST_MSG: - case NSS_WIFILI_PEER_STATS_MSG: - case NSS_WIFILI_RADIO_BUF_CFG: - case NSS_WIFILI_STATS_MSG: - case NSS_WIFILI_START_MSG: - case NSS_WIFILI_STOP_MSG: - /* - * No log for these valid messages. - */ - break; - - default: - nss_warning("%px: Invalid message type\n", nwm); - break; - } -} - -/* - * nss_wifili_log_tx_msg() - * Log messages transmitted to FW. - */ -void nss_wifili_log_tx_msg(struct nss_wifili_msg *nwm) -{ - if (nwm->cm.type >= NSS_WIFILI_MAX_MSG) { - nss_warning("%px: Invalid message type\n", nwm); - return; - } - - 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); -} - -/* - * nss_wifili_log_rx_msg() - * Log messages received from FW. - */ -void nss_wifili_log_rx_msg(struct nss_wifili_msg *nwm) -{ - if (nwm->cm.response >= NSS_CMN_RESPONSE_LAST) { - 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("%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("%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("%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]); - -verbose: - nss_wifili_log_verbose(nwm); -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifili_log.h b/feeds/ipq807x/qca-nss-drv/src/nss_wifili_log.h deleted file mode 100644 index a381ab6cf..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifili_log.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ****************************************************************************** - * 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. - * 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_WIFILI_LOG_H__ -#define __NSS_WIFILI_LOG_H__ - -/* - * nss_WIFILI_log.h - * NSS WIFILI Log Header File - */ - -/* - * nss_WIFILI_log_tx_msg - * Logs a WIFILI message that is sent to the NSS firmware. - */ -void nss_wifili_log_tx_msg(struct nss_wifili_msg *ncm); - -/* - * nss_WIFILI_log_rx_msg - * Logs a WIFILI message that is received from the NSS firmware. - */ -void nss_wifili_log_rx_msg(struct nss_wifili_msg *ncm); - -#endif /* __NSS_WIFILI_LOG_H__ */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifili_stats.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifili_stats.c deleted file mode 100644 index 6f983bcf5..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifili_stats.c +++ /dev/null @@ -1,512 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_wifili_stats.c - * NSS wifili statistics APIs - */ - -#include "nss_tx_rx_common.h" -#include "nss_core.h" -#include "nss_wifili_if.h" -#include "nss_wifili_stats.h" -#include "nss_wifili_strings.h" - -/* - * Declare atomic notifier data structure for statistics. - */ -ATOMIC_NOTIFIER_HEAD(nss_wifili_stats_notifier); - -/* - * Statistics structures - * The structure will hold the statistics for 3 SOCs. - */ -struct nss_wifili_soc_stats soc_stats[NSS_WIFILI_MAX_SOC_NUM]; - -/* - * nss_wifili_stats_read() - * Read wifili statistics - */ -static ssize_t nss_wifili_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - uint32_t i; - - /* - * max output lines = ((#stats + eight blank lines) * #WIFILI #STATS) + start/end tag + 3 blank - * + Number of Extra outputlines for future reference to add new stats - */ - uint32_t max_pdev = 0; - uint32_t max_output_lines; - size_t size_al = 0; - size_t size_wr = 0; - ssize_t bytes_read = 0; - char *lbuf = NULL; - uint32_t soc_idx; - struct nss_wifili_stats *stats_wifili = NULL; - - /* - * Max number of pdev depends on type of soc (Internal/Attached). - */ - for (soc_idx = 0; soc_idx < NSS_WIFILI_MAX_SOC_NUM; soc_idx++) { - max_pdev += soc_stats[soc_idx].soc_maxpdev; - } - - /* - * Max pdev cannot be null. - */ - if (unlikely(max_pdev == 0)) { - nss_warning("Cannot have max pdev zero "); - return 0; - } - - max_output_lines = (((NSS_WIFILI_STATS_MAX + 9) * max_pdev) + - NSS_WIFILI_STATS_WBM_MAX + NSS_STATS_EXTRA_OUTPUT_LINES); - - size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - - lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(lbuf == NULL)) { - nss_warning("Could not allocate memory for local statistics buffer"); - 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++) { - stats_wifili = &(soc_stats[soc_idx].stats_wifili); - for (i = 0; i < soc_stats[soc_idx].soc_maxpdev; i++) { - - spin_lock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("wifili", "txrx", i - , nss_wifili_strings_stats_txrx - , stats_wifili->stats_txrx[i] - , NSS_WIFILI_STATS_TXRX_MAX - , lbuf, size_wr, size_al); - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += scnprintf(lbuf + size_wr - , size_al - size_wr, "\n"); - - /* - * Filling TCL ring stats - */ - spin_lock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("wifili", "tcl ring", i - , nss_wifili_strings_stats_tcl - , stats_wifili->stats_tcl_ring[i] - , NSS_WIFILI_STATS_TCL_MAX - , lbuf, size_wr, size_al); - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += scnprintf(lbuf + size_wr - , size_al - size_wr, "\n"); - - /* - * Filling TCL comp stats - */ - spin_lock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("wifili", "tcl comp", i - , nss_wifili_strings_stats_tx_comp - , stats_wifili->stats_tx_comp[i] - , NSS_WIFILI_STATS_TX_DESC_FREE_MAX - , lbuf, size_wr, size_al); - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += scnprintf(lbuf + size_wr - , size_al - size_wr, "\n"); - - /* - * Filling reo ring stats - */ - spin_lock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("wifili", "reo ring", i - , nss_wifili_strings_stats_reo - , stats_wifili->stats_reo[i] - , NSS_WIFILI_STATS_REO_MAX - , lbuf, size_wr, size_al); - - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += scnprintf(lbuf + size_wr - , size_al - size_wr, "\n"); - - /* - * Filling TX SW Pool - */ - spin_lock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("wifili", "tx sw pool", i - , nss_wifili_strings_stats_txsw_pool - , stats_wifili->stats_tx_desc[i] - , NSS_WIFILI_STATS_TX_DESC_MAX - , lbuf, size_wr, size_al); - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += scnprintf(lbuf + size_wr - , size_al - size_wr, "\n"); - - /* - * Filling TX EXt SW Pool - */ - spin_lock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("wifili", "tx ext sw pool", i - , nss_wifili_strings_stats_ext_txsw_pool - , stats_wifili->stats_ext_tx_desc[i] - , NSS_WIFILI_STATS_EXT_TX_DESC_MAX - , lbuf, size_wr, size_al); - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += scnprintf(lbuf + size_wr - , size_al - size_wr, "\n"); - - /* - * Filling rxdma pool stats - */ - spin_lock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("wifili", "rxdma pool", i - , nss_wifili_strings_stats_rxdma_pool - , stats_wifili->stats_rx_desc[i] - , NSS_WIFILI_STATS_RX_DESC_MAX - , lbuf, size_wr, size_al); - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += scnprintf(lbuf + size_wr - , size_al - size_wr, "\n"); - - /* - * Filling rxdma ring stats - */ - spin_lock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("wifili", "rxdma ring", i - , nss_wifili_strings_stats_rxdma_ring - , stats_wifili->stats_rxdma[i] - , NSS_WIFILI_STATS_RXDMA_DESC_MAX - , lbuf, size_wr, size_al); - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += scnprintf(lbuf + size_wr - , size_al - size_wr, "\n"); - } - - /* - * Filling wbm ring stats - */ - spin_lock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("wifili", "wbm ring" - , NSS_STATS_SINGLE_INSTANCE - , nss_wifili_strings_stats_wbm - , stats_wifili->stats_wbm - , NSS_WIFILI_STATS_WBM_MAX - , lbuf, size_wr, size_al); - spin_unlock_bh(&nss_top_main.stats_lock); - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); - } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(lbuf); - - return bytes_read; -} - -/* - * wifili_stats_ops - */ -NSS_STATS_DECLARE_FILE_OPERATIONS(wifili); - -/* - * nss_wifili_stats_dentry_create() - * Create wifili statistics debug entry. - */ -void nss_wifili_stats_dentry_create(void) -{ - nss_stats_create_dentry("wifili", &nss_wifili_stats_ops); -} - -/* - * nss_wifili_stats_sync() - * Handle the syncing of WIFI stats. - */ -void nss_wifili_stats_sync(struct nss_ctx_instance *nss_ctx, - struct nss_wifili_stats_sync_msg *wlsoc_stats, uint16_t interface) -{ - struct nss_top_instance *nss_top = nss_ctx->nss_top; - struct nss_wifili_soc_stats *nwss = NULL; - struct nss_wifili_stats *stats = NULL; - struct nss_wifili_device_stats *devstats = &wlsoc_stats->stats; - uint32_t index; - - /* - * Max number of pdev depends on type of soc (Internal/Attached). - */ - switch (interface) { - case NSS_WIFILI_INTERNAL_INTERFACE: - nwss = &soc_stats[0]; - nwss->soc_maxpdev = NSS_WIFILI_MAX_PDEV_NUM_MSG; - break; - - case NSS_WIFILI_EXTERNAL_INTERFACE0: - nwss = &soc_stats[1]; - nwss->soc_maxpdev = NSS_WIFILI_SOC_ATTACHED_MAX_PDEV_NUM; - break; - - case NSS_WIFILI_EXTERNAL_INTERFACE1: - nwss = &soc_stats[2]; - nwss->soc_maxpdev = NSS_WIFILI_SOC_ATTACHED_MAX_PDEV_NUM; - break; - - default: - nss_warning("%px: Invalid wifili interface\n", nss_ctx); - return; - } - - /* - * Wifili statistics structure. - */ - stats = &(nwss->stats_wifili); - - spin_lock_bh(&nss_top->stats_lock); - - for (index = 0; index < nwss->soc_maxpdev; index++) { - /* - * Rx stats - */ - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_MSDU_ERROR] += - devstats->rx_data_stats[index].rx_msdu_err; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_INV_PEER_RCV] += - (devstats->rx_data_stats[index].rx_inv_peer + - devstats->rx_data_stats[index].rx_scatter_inv_peer); - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_WDS_SRCPORT_EXCEPTION] += - devstats->rx_data_stats[index].rx_wds_learn_send; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_WDS_SRCPORT_EXCEPTION_FAIL] += - devstats->rx_data_stats[index].rx_wds_learn_send_fail; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_DELIVERD] += - devstats->rx_data_stats[index].rx_deliver_cnt; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_DELIVER_DROPPED] += - devstats->rx_data_stats[index].rx_deliver_cnt_fail; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_INTRA_BSS_UCAST] += - devstats->rx_data_stats[index].rx_intra_bss_ucast_send; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_INTRA_BSS_UCAST_FAIL] += - devstats->rx_data_stats[index].rx_intra_bss_ucast_send_fail; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_INTRA_BSS_MCAST] += - devstats->rx_data_stats[index].rx_intra_bss_mcast_send; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_INTRA_BSS_MCAST_FAIL] += - devstats->rx_data_stats[index].rx_intra_bss_mcast_send_fail; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_SG_RCV_SEND] += - devstats->rx_data_stats[index].rx_sg_recv_send; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_SG_RCV_FAIL] += - devstats->rx_data_stats[index].rx_sg_recv_fail; - stats->stats_txrx[index][NSS_STATS_WIFILI_RX_MCAST_ECHO] += - devstats->rx_data_stats[index].rx_me_pkts; - stats->stats_txrx[index][NSS_STATS_WIFILI_RX_INV_TID] += - devstats->rx_data_stats[index].rx_inv_tid; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_FRAG_INV_SC] += - devstats->rx_data_stats[index].rx_frag_inv_sc; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_FRAG_INV_FC] += - devstats->rx_data_stats[index].rx_frag_inv_fc; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_FRAG_NON_FRAG] += - devstats->rx_data_stats[index].rx_non_frag_err; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_FRAG_RETRY] += - devstats->rx_data_stats[index].rx_repeat_fragno; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_FRAG_OOO] += - devstats->rx_data_stats[index].rx_ooo_frag; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_FRAG_OOO_SEQ] += - devstats->rx_data_stats[index].rx_ooo_frag_seq; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_FRAG_ALL_FRAG_RCV] += - devstats->rx_data_stats[index].rx_all_frag_rcv; - stats->stats_txrx[index][NSS_WIFILI_STATS_RX_FRAG_DELIVER] += - devstats->rx_data_stats[index].rx_frag_deliver; - - /* - * Tx stats - */ - stats->stats_txrx[index][NSS_WIFILI_STATS_TX_ENQUEUE] += - devstats->tx_data_stats[index].tx_enqueue_cnt; - stats->stats_txrx[index][NSS_WIFILI_STATS_TX_ENQUEUE_DROP] += - devstats->tx_data_stats[index].tx_enqueue_dropped; - stats->stats_txrx[index][NSS_WIFILI_STATS_TX_DEQUEUE] += - devstats->tx_data_stats[index].tx_dequeue_cnt; - stats->stats_txrx[index][NSS_WIFILI_STATS_TX_HW_ENQUEUE_FAIL] += - devstats->tx_data_stats[index].tx_send_fail_cnt; - stats->stats_txrx[index][NSS_WIFILI_STATS_TX_SENT_COUNT] += - devstats->tx_data_stats[index].tx_processed_pkt; - } - - /* - * update the tcl ring stats - */ - for (index = 0; index < NSS_WIFILI_MAX_TCL_DATA_RINGS_MSG; index++) { - stats->stats_tcl_ring[index][NSS_WIFILI_STATS_TCL_NO_HW_DESC] += - devstats->tcl_stats[index].tcl_no_hw_desc; - stats->stats_tcl_ring[index][NSS_WIFILI_STATS_TCL_RING_FULL] += - devstats->tcl_stats[index].tcl_ring_full; - stats->stats_tcl_ring[index][NSS_WIFILI_STATS_TCL_RING_SENT] += - devstats->tcl_stats[index].tcl_ring_sent; - } - - /* - * update the tcl comp stats - */ - for (index = 0; index < NSS_WIFILI_MAX_TCL_DATA_RINGS_MSG; index++) { - stats->stats_tx_comp[index][NSS_WIFILI_STATS_TX_DESC_FREE_INV_BUFSRC] += - devstats->txcomp_stats[index].invalid_bufsrc; - stats->stats_tx_comp[index][NSS_WIFILI_STATS_TX_DESC_FREE_INV_COOKIE] += - devstats->txcomp_stats[index].invalid_cookie; - stats->stats_tx_comp[index][NSS_WIFILI_STATS_TX_DESC_FREE_HW_RING_EMPTY] += - 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; - } - - /* - * update reo ring stats - */ - for (index = 0; index < NSS_WIFILI_MAX_REO_DATA_RINGS_MSG; index++) { - stats->stats_reo[index][NSS_WIFILI_STATS_REO_ERROR] += - devstats->rxreo_stats[index].ring_error; - stats->stats_reo[index][NSS_WIFILI_STATS_REO_REAPED] += - devstats->rxreo_stats[index].ring_reaped; - stats->stats_reo[index][NSS_WIFILI_STATS_REO_INV_COOKIE] += - devstats->rxreo_stats[index].invalid_cookie; - stats->stats_reo[index][NSS_WIFILI_STATS_REO_FRAG_RCV] += - devstats->rxreo_stats[index].defrag_reaped; - } - - /* - * update tx sw pool - */ - for (index = 0; index < NSS_WIFILI_MAX_TXDESC_POOLS_MSG; index++) { - stats->stats_tx_desc[index][NSS_WIFILI_STATS_TX_DESC_IN_USE] = - devstats->tx_sw_pool_stats[index].desc_alloc; - stats->stats_tx_desc[index][NSS_WIFILI_STATS_TX_DESC_ALLOC_FAIL] += - devstats->tx_sw_pool_stats[index].desc_alloc_fail; - stats->stats_tx_desc[index][NSS_WIFILI_STATS_TX_DESC_ALREADY_ALLOCATED] += - devstats->tx_sw_pool_stats[index].desc_already_allocated; - stats->stats_tx_desc[index][NSS_WIFILI_STATS_TX_DESC_INVALID_FREE] += - devstats->tx_sw_pool_stats[index].desc_invalid_free; - stats->stats_tx_desc[index][NSS_WIFILI_STATS_TX_DESC_FREE_SRC_FW] += - devstats->tx_sw_pool_stats[index].tx_rel_src_fw; - stats->stats_tx_desc[index][NSS_WIFILI_STATS_TX_DESC_FREE_COMPLETION] += - devstats->tx_sw_pool_stats[index].tx_rel_tx_desc; - stats->stats_tx_desc[index][NSS_WIFILI_STATS_TX_DESC_NO_PB] += - devstats->tx_sw_pool_stats[index].tx_rel_no_pb; - stats->stats_tx_desc[index][NSS_WIFILI_STATS_TX_QUEUELIMIT_DROP] += - devstats->tx_sw_pool_stats[index].tx_queue_limit_drop; - } - - /* - * update ext tx desc pool stats - */ - for (index = 0; index < NSS_WIFILI_MAX_TX_EXT_DESC_POOLS_MSG; index++) { - stats->stats_ext_tx_desc[index][NSS_WIFILI_STATS_EXT_TX_DESC_IN_USE] = - devstats->tx_ext_sw_pool_stats[index].desc_alloc; - stats->stats_ext_tx_desc[index][NSS_WIFILI_STATS_EXT_TX_DESC_ALLOC_FAIL] += - devstats->tx_ext_sw_pool_stats[index].desc_alloc_fail; - stats->stats_ext_tx_desc[index][NSS_WIFILI_STATS_EXT_TX_DESC_ALREADY_ALLOCATED] += - devstats->tx_ext_sw_pool_stats[index].desc_already_allocated; - stats->stats_ext_tx_desc[index][NSS_WIFILI_STATS_EXT_TX_DESC_INVALID_FREE] += - devstats->tx_ext_sw_pool_stats[index].desc_invalid_free; - } - - /* - * update rx desc pool stats - */ - for (index = 0; index < nwss->soc_maxpdev; index++) { - stats->stats_rx_desc[index][NSS_WIFILI_STATS_RX_DESC_NO_PB] += - devstats->rx_sw_pool_stats[index].rx_no_pb; - stats->stats_rx_desc[index][NSS_WIFILI_STATS_RX_DESC_ALLOC_FAIL] += - devstats->rx_sw_pool_stats[index].desc_alloc_fail; - stats->stats_rx_desc[index][NSS_WIFILI_STATS_RX_DESC_IN_USE] = - devstats->rx_sw_pool_stats[index].desc_alloc; - } - - /* - * update rx dma ring stats - */ - for (index = 0; index < nwss->soc_maxpdev; index++) { - stats->stats_rxdma[index][NSS_WIFILI_STATS_RXDMA_DESC_UNAVAILABLE] += - devstats->rxdma_stats[index].rx_hw_desc_unavailable; - stats->stats_rxdma[index][NSS_WIFILI_STATS_RXDMA_BUF_REPLENISHED] += - devstats->rxdma_stats[index].rx_buf_replenished; - } - - /* - * 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; - stats->stats_wbm[NSS_WIFILI_STATS_WBM_SRC_REO_CODE_NULLQ] += devstats->rxwbm_stats.err_src_reo_code_nullq; - stats->stats_wbm[NSS_WIFILI_STATS_WBM_SRC_REO_CODE_INV] += devstats->rxwbm_stats.err_src_reo_code_inv; - stats->stats_wbm[NSS_WIFILI_STATS_WBM_SRC_INV] += devstats->rxwbm_stats.err_src_invalid; - spin_unlock_bh(&nss_top->stats_lock); - return; -} - -/* - * nss_wifili_stats_notify() - * Sends notifications to the registered modules. - * - * Leverage NSS-FW statistics timing to update Netlink. - */ -void nss_wifili_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -{ - struct nss_wifili_stats_notification *wifili_stats; - uint32_t index = 0; - - wifili_stats = kzalloc(sizeof(struct nss_wifili_stats_notification), GFP_ATOMIC); - if (!wifili_stats) { - nss_warning("%px: Failed to allocate memory for wifili stats\n", nss_ctx); - return; - } - - wifili_stats->core_id = nss_ctx->id; - switch (if_num) { - case NSS_WIFILI_INTERNAL_INTERFACE: - index = 0; - break; - - case NSS_WIFILI_EXTERNAL_INTERFACE0: - index = 1; - break; - - case NSS_WIFILI_EXTERNAL_INTERFACE1: - index = 2; - break; - - default: - nss_warning("%px: Invalid wifili interface\n", nss_ctx); - goto done; - } - wifili_stats->if_num = if_num; - memcpy(&wifili_stats->stats, &soc_stats[index].stats_wifili, sizeof(wifili_stats->stats)); - atomic_notifier_call_chain(&nss_wifili_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)wifili_stats); - -done: - kfree(wifili_stats); - return; -} - -/* - * nss_wifili_stats_register_notifier() - * Registers statistics notifier. - */ -int nss_wifili_stats_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&nss_wifili_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_wifili_stats_register_notifier); - -/* - * nss_wifili_stats_unregister_notifier() - * Deregisters statistics notifier. - */ -int nss_wifili_stats_unregister_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_unregister(&nss_wifili_stats_notifier, nb); -} -EXPORT_SYMBOL(nss_wifili_stats_unregister_notifier); diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifili_stats.h b/feeds/ipq807x/qca-nss-drv/src/nss_wifili_stats.h deleted file mode 100644 index 9c073ce8d..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifili_stats.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - ************************************************************************** - * 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. - ************************************************************************** - */ - -/* - * nss_wifili_stats.h - * NSS wifili statistics header file. - */ - -#ifndef __NSS_WIFILI_STATS_H -#define __NSS_WIFILI_STATS_H - -#include "nss_core.h" -#include "nss_wifili_if.h" - -/* - * NSS wifili statistics APIs - */ -extern void nss_wifili_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); -extern void nss_wifili_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_wifili_stats_sync_msg *wlsoc_stats, uint16_t interface); -extern void nss_wifili_stats_dentry_create(void); - -#endif /* __NSS_WIFILI_STATS_H */ diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifili_strings.c b/feeds/ipq807x/qca-nss-drv/src/nss_wifili_strings.c deleted file mode 100644 index 3828221bd..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifili_strings.c +++ /dev/null @@ -1,366 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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" -#include "nss_wifili_strings.h" - -/* - * nss_wifili_strings_stats_txrx - * wifili txrx statistics - */ -struct nss_stats_info nss_wifili_strings_stats_txrx[NSS_WIFILI_STATS_TXRX_MAX] = { - {"rx_msdu_error" , NSS_STATS_TYPE_ERROR}, - {"rx_inv_peer_rcv" , NSS_STATS_TYPE_SPECIAL}, - {"rx_wds_srcport_exception" , NSS_STATS_TYPE_EXCEPTION}, - {"rx_wds_srcport_exception_fail" , NSS_STATS_TYPE_DROP}, - {"rx_deliverd" , NSS_STATS_TYPE_SPECIAL}, - {"rx_deliver_drops" , NSS_STATS_TYPE_DROP}, - {"rx_intra_bss_ucast" , NSS_STATS_TYPE_SPECIAL}, - {"rx_intra_bss_ucast_fail" , NSS_STATS_TYPE_DROP}, - {"rx_intra_bss_mcast" , NSS_STATS_TYPE_SPECIAL}, - {"rx_intra_bss_mcast_fail" , NSS_STATS_TYPE_DROP}, - {"rx_sg_rcv_send" , NSS_STATS_TYPE_SPECIAL}, - {"rx_sg_rcv_fail" , NSS_STATS_TYPE_DROP}, - {"rx_mcast_echo" , NSS_STATS_TYPE_SPECIAL}, - {"rx_inv_tid" , NSS_STATS_TYPE_SPECIAL}, - {"stats_rx_frag_inv_sc" , NSS_STATS_TYPE_SPECIAL}, - {"stats_rx_frag_inv_fc" , NSS_STATS_TYPE_SPECIAL}, - {"stats_rx_frag_non_frag" , NSS_STATS_TYPE_SPECIAL}, - {"stats_rx_frag_retry" , NSS_STATS_TYPE_SPECIAL}, - {"stats_rx_frag_ooo" , NSS_STATS_TYPE_SPECIAL}, - {"stats_rx_frag_ooo_seq" , NSS_STATS_TYPE_SPECIAL}, - {"stats_rx_frag_all_frag_rcv" , NSS_STATS_TYPE_SPECIAL}, - {"stats_rx_frag_deliver" , NSS_STATS_TYPE_SPECIAL}, - {"tx_enqueue" , NSS_STATS_TYPE_SPECIAL}, - {"tx_enqueue_drop" , NSS_STATS_TYPE_DROP}, - {"tx_dequeue" , NSS_STATS_TYPE_SPECIAL}, - {"tx_hw_enqueue_fail" , NSS_STATS_TYPE_DROP}, - {"tx_sent_count" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_wifili_strings_stats_tcl - * wifili tcl stats - */ -struct nss_stats_info nss_wifili_strings_stats_tcl[NSS_WIFILI_STATS_TCL_MAX] = { - {"tcl_no_hw_desc" , NSS_STATS_TYPE_SPECIAL}, - {"tcl_ring_full" , NSS_STATS_TYPE_SPECIAL}, - {"tcl_ring_sent" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_wifili_strings_stats_tx_comp - * 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} -}; - -/* - * nss_wifili_strings_stats_reo - * wifili tx reo stats - */ -struct nss_stats_info nss_wifili_strings_stats_reo[NSS_WIFILI_STATS_REO_MAX] = { - {"reo_error" , NSS_STATS_TYPE_ERROR}, - {"reo_reaped" , NSS_STATS_TYPE_SPECIAL}, - {"reo_inv_cookie" , NSS_STATS_TYPE_SPECIAL}, - {"stats_reo_frag_rcv" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_wifili_strings_stats_txsw_pool - * wifili tx desc stats - */ -struct nss_stats_info nss_wifili_strings_stats_txsw_pool[NSS_WIFILI_STATS_TX_DESC_MAX] = { - {"tx_desc_in_use" , NSS_STATS_TYPE_SPECIAL}, - {"tx_desc_alloc_fail" , NSS_STATS_TYPE_SPECIAL}, - {"tx_desc_already_allocated" , NSS_STATS_TYPE_SPECIAL}, - {"tx_desc_invalid_free" , NSS_STATS_TYPE_SPECIAL}, - {"tx_desc_free_src_fw" , NSS_STATS_TYPE_SPECIAL}, - {"tx_desc_free_completion" , NSS_STATS_TYPE_SPECIAL}, - {"tx_desc_no_pb" , NSS_STATS_TYPE_SPECIAL}, - {"tx_desc_queuelimit_drop" , NSS_STATS_TYPE_DROP} -}; - -/* - * nss_wifili_strings_stats_ext_txsw_pool - * wifili tx ext desc stats - */ -struct nss_stats_info nss_wifili_strings_stats_ext_txsw_pool[NSS_WIFILI_STATS_EXT_TX_DESC_MAX] = { - {"ext_tx_desc_in_use" , NSS_STATS_TYPE_SPECIAL}, - {"ext_tx_desc_alloc_fail" , NSS_STATS_TYPE_SPECIAL}, - {"ext_tx_desc_already_allocated" , NSS_STATS_TYPE_SPECIAL}, - {"ext_tx_desc_invalid_free" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_wifili_strings_stats_rxdma_pool - * wifili rx desc stats - */ -struct nss_stats_info nss_wifili_strings_stats_rxdma_pool[NSS_WIFILI_STATS_RX_DESC_MAX] = { - {"rx_desc_no_pb" , NSS_STATS_TYPE_SPECIAL}, - {"rx_desc_alloc_fail" , NSS_STATS_TYPE_SPECIAL}, - {"rx_desc_in_use" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_wifili_strings_stats_rxdma_ring - * wifili rx dma ring stats - */ -struct nss_stats_info nss_wifili_strings_stats_rxdma_ring[NSS_WIFILI_STATS_RXDMA_DESC_MAX] = { - {"rxdma_hw_desc_unavailable" , NSS_STATS_TYPE_SPECIAL}, - {"rxdma_buf_replenished" , NSS_STATS_TYPE_SPECIAL} -}; - -/* - * nss_wifili_strings_stats_wbm - * 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}, - {"wbm_src_reo_code_nullq" , NSS_STATS_TYPE_SPECIAL}, - {"wbm_src_reo_code_inv" , NSS_STATS_TYPE_ERROR}, - {"wbm_src_inv" , NSS_STATS_TYPE_ERROR} -}; - -/* - * nss_wifili_txrx_strings_read() - * Read wifili Tx Rx statistics names. - */ -static ssize_t nss_wifili_txrx_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_wifili_strings_stats_txrx, NSS_WIFILI_STATS_TXRX_MAX); -} - -/* - * nss_wifili_tcl_ring_strings_read() - * Read wifili TCL ring statistics names. - */ -static ssize_t nss_wifili_tcl_ring_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_wifili_strings_stats_tcl, NSS_WIFILI_STATS_TCL_MAX); -} - -/* - * nss_wifili_tcl_comp_strings_read() - * Read wifili TCL comp statistics names. - */ -static ssize_t nss_wifili_tcl_comp_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_wifili_strings_stats_tx_comp, NSS_WIFILI_STATS_TX_DESC_FREE_MAX); -} - -/* - * nss_wifili_reo_ring_strings_read() - * Read wifili reorder ring statistics names. - */ -static ssize_t nss_wifili_reo_ring_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_wifili_strings_stats_reo, NSS_WIFILI_STATS_REO_MAX); -} - -/* - * nss_wifili_tx_sw_strings_read() - * Read wifili Tx sw statistics names. - */ -static ssize_t nss_wifili_tx_sw_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_wifili_strings_stats_txsw_pool, NSS_WIFILI_STATS_TX_DESC_MAX); -} - -/* - * nss_wifili_tx_ext_sw_strings_read() - * Read wifili Tx ext sw statistics names. - */ -static ssize_t nss_wifili_tx_ext_sw_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_wifili_strings_stats_ext_txsw_pool, NSS_WIFILI_STATS_EXT_TX_DESC_MAX); -} - -/* - * nss_wifili_rx_dma_pool_strings_read() - * Read wifili Rx DMA pool statistics names. - */ -static ssize_t nss_wifili_rx_dma_pool_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_wifili_strings_stats_rxdma_pool, NSS_WIFILI_STATS_RX_DESC_MAX); -} - -/* - * nss_wifili_rx_dma_ring_strings_read() - * Read wifili Rx DMA ring statistics names. - */ -static ssize_t nss_wifili_rx_dma_ring_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_wifili_strings_stats_rxdma_ring, NSS_WIFILI_STATS_RXDMA_DESC_MAX); -} - -/* - * nss_wifili_wbm_ring_strings_read() - * Read wifili WBM ring statistics names. - */ -static ssize_t nss_wifili_wbm_ring_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -{ - return nss_strings_print(ubuf, sz, ppos, nss_wifili_strings_stats_wbm, NSS_WIFILI_STATS_WBM_MAX); -} - -/* - * nss_wifili_txrx_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifili_txrx); - -/* - * nss_wifili_tcl_ring_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifili_tcl_ring); - -/* - * nss_wifili_tcl_comp_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifili_tcl_comp); - -/* - * nss_wifili_reo_ring_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifili_reo_ring); - -/* - * nss_wifili_tx_sw_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifili_tx_sw); - -/* - * nss_wifili_tx_ext_sw_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifili_tx_ext_sw); - -/* - * nss_wifili_rx_dma_pool_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifili_rx_dma_pool); - -/* - * nss_wifili_rx_dma_ring_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifili_rx_dma_ring); - -/* - * nss_wifili_wbm_ring_strings_ops - */ -NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifili_wbm_ring); - -/* - * nss_wifili_strings_dentry_create() - * Create wifili statistics strings debug entry. - */ -void nss_wifili_strings_dentry_create(void) -{ - struct dentry *wifili_d = NULL; - struct dentry *wifili_txrx_d = NULL; - struct dentry *wifili_tcl_ring_d = NULL; - struct dentry *wifili_tcl_comp_d = NULL; - struct dentry *wifili_reo_ring_d = NULL; - struct dentry *wifili_tx_sw_d = NULL; - struct dentry *wifili_tx_ext_sw_d = NULL; - struct dentry *wifili_rx_dma_pool_d = NULL; - struct dentry *wifili_rx_dma_ring_d = NULL; - struct dentry *wifili_wbm_ring_d = NULL; - - if (!nss_top_main.strings_dentry) { - nss_warning("qca-nss-drv/strings is not present"); - return; - } - - wifili_d = debugfs_create_dir("wifili", nss_top_main.strings_dentry); - if (!wifili_d) { - nss_warning("Failed to create qca-nss-drv/strings/wifili directory"); - return; - } - - wifili_txrx_d = debugfs_create_file("txrx_str", 0400, wifili_d, &nss_top_main, &nss_wifili_txrx_strings_ops); - if (!wifili_txrx_d) { - nss_warning("Failed to create qca-nss-drv/strings/wifili/txrx_str file"); - debugfs_remove_recursive(wifili_d); - return; - } - - wifili_tcl_ring_d = debugfs_create_file("tcl_ring_str", 0400, wifili_d, &nss_top_main, &nss_wifili_tcl_ring_strings_ops); - if (!wifili_tcl_ring_d) { - nss_warning("Failed to create qca-nss-drv/strings/wifili/tcl_ring_str file"); - debugfs_remove_recursive(wifili_d); - return; - } - - wifili_tcl_comp_d = debugfs_create_file("tcl_comp_str", 0400, wifili_d, &nss_top_main, &nss_wifili_tcl_comp_strings_ops); - if (!wifili_tcl_comp_d) { - nss_warning("Failed to create qca-nss-drv/strings/wifili/tcl_comp_str file"); - debugfs_remove_recursive(wifili_d); - return; - } - - wifili_reo_ring_d = debugfs_create_file("reo_ring_str", 0400, wifili_d, &nss_top_main, &nss_wifili_reo_ring_strings_ops); - if (!wifili_reo_ring_d) { - nss_warning("Failed to create qca-nss-drv/strings/wifili/reo_ring_str file"); - debugfs_remove_recursive(wifili_d); - return; - } - - wifili_tx_sw_d = debugfs_create_file("tx_sw_str", 0400, wifili_d, &nss_top_main, &nss_wifili_tx_sw_strings_ops); - if (!wifili_tx_sw_d) { - nss_warning("Failed to create qca-nss-drv/strings/wifili/tx_sw_str file"); - debugfs_remove_recursive(wifili_d); - return; - } - - wifili_tx_ext_sw_d = debugfs_create_file("tx_ext_sw_str", 0400, wifili_d, &nss_top_main, &nss_wifili_tx_ext_sw_strings_ops); - if (!wifili_tx_ext_sw_d) { - nss_warning("Failed to create qca-nss-drv/strings/wifili/tx_ext_sw_str file"); - debugfs_remove_recursive(wifili_d); - return; - } - - wifili_rx_dma_pool_d = debugfs_create_file("rx_dma_pool_str", 0400, wifili_d, &nss_top_main, &nss_wifili_rx_dma_pool_strings_ops); - if (!wifili_rx_dma_pool_d) { - nss_warning("Failed to create qca-nss-drv/strings/wifili/rx_dma_pool_str file"); - debugfs_remove_recursive(wifili_d); - return; - } - - wifili_rx_dma_ring_d = debugfs_create_file("rx_dma_ring_str", 0400, wifili_d, &nss_top_main, &nss_wifili_rx_dma_ring_strings_ops); - if (!wifili_rx_dma_ring_d) { - nss_warning("Failed to create qca-nss-drv/strings/wifili/rx_dma_ring_str file"); - debugfs_remove_recursive(wifili_d); - return; - } - - wifili_wbm_ring_d = debugfs_create_file("wbm_ring_str", 0400, wifili_d, &nss_top_main, &nss_wifili_wbm_ring_strings_ops); - if (!wifili_wbm_ring_d) { - nss_warning("Failed to create qca-nss-drv/strings/wifili/wbm_ring_str file"); - debugfs_remove_recursive(wifili_d); - return; - } -} diff --git a/feeds/ipq807x/qca-nss-drv/src/nss_wifili_strings.h b/feeds/ipq807x/qca-nss-drv/src/nss_wifili_strings.h deleted file mode 100644 index 263d172f6..000000000 --- a/feeds/ipq807x/qca-nss-drv/src/nss_wifili_strings.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - ************************************************************************** - * 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 - * 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_WIFILI_STRINGS_H -#define __NSS_WIFILI_STRINGS_H - -/* - * Maximum string length: - * This should be equal to maximum string size of any stats - * inclusive of stats value - */ -#define NSS_WIFILI_STATS_MAX (NSS_WIFILI_STATS_TXRX_MAX + NSS_WIFILI_STATS_TCL_MAX + \ - NSS_WIFILI_STATS_TX_DESC_FREE_MAX + NSS_WIFILI_STATS_REO_MAX + \ - NSS_WIFILI_STATS_TX_DESC_MAX + NSS_WIFILI_STATS_EXT_TX_DESC_MAX + \ - NSS_WIFILI_STATS_RX_DESC_MAX + NSS_WIFILI_STATS_RXDMA_DESC_MAX) - -extern struct nss_stats_info nss_wifili_strings_stats_txrx[NSS_WIFILI_STATS_TXRX_MAX]; -extern struct nss_stats_info nss_wifili_strings_stats_tcl[NSS_WIFILI_STATS_TCL_MAX]; -extern struct nss_stats_info nss_wifili_strings_stats_tx_comp[NSS_WIFILI_STATS_TX_DESC_FREE_MAX]; -extern struct nss_stats_info nss_wifili_strings_stats_reo[NSS_WIFILI_STATS_REO_MAX]; -extern struct nss_stats_info nss_wifili_strings_stats_txsw_pool[NSS_WIFILI_STATS_TX_DESC_MAX]; -extern struct nss_stats_info nss_wifili_strings_stats_ext_txsw_pool[NSS_WIFILI_STATS_EXT_TX_DESC_MAX]; -extern struct nss_stats_info nss_wifili_strings_stats_rxdma_pool[NSS_WIFILI_STATS_RX_DESC_MAX]; -extern struct nss_stats_info nss_wifili_strings_stats_rxdma_ring[NSS_WIFILI_STATS_RXDMA_DESC_MAX]; -extern struct nss_stats_info nss_wifili_strings_stats_wbm[NSS_WIFILI_STATS_WBM_MAX]; - -extern void nss_wifili_strings_dentry_create(void); - -#endif /* __NSS_WIFILI_STRINGS_H */