Merge "[qca-nss-drv] Added interface for unaligned trap statistics."
diff --git a/Makefile b/Makefile
index ee4273c..59d1a59 100644
--- a/Makefile
+++ b/Makefile
@@ -172,9 +172,9 @@
ccflags-y += -Werror
ifneq ($(findstring 3.4, $(KERNELVERSION)),)
-NSS_CCFLAGS = -DNSS_DT_SUPPORT=0 -DNSS_FW_DBG_SUPPORT=1 -DNSS_PM_SUPPORT=1 -DNSS_EMPTY_BUFFER_SIZE=1984
+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 -DNSS_EMPTY_BUFFER_SIZE=1984
+NSS_CCFLAGS = -DNSS_DT_SUPPORT=1 -DNSS_FW_DBG_SUPPORT=0 -DNSS_PM_SUPPORT=0
ccflags-y += -I$(obj)
endif
diff --git a/Makefile.fsm b/Makefile.fsm
index 566a7b7..15b75c7 100644
--- a/Makefile.fsm
+++ b/Makefile.fsm
@@ -116,6 +116,6 @@
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_EMPTY_BUFFER_SIZE=1984 -DNSS_PKT_STATS_ENABLED=1
+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/nss_hlos_if.h b/nss_hlos_if.h
index f1188d9..5314e1c 100644
--- a/nss_hlos_if.h
+++ b/nss_hlos_if.h
@@ -1,6 +1,6 @@
/*
**************************************************************************
- * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
+ * 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.
@@ -22,12 +22,31 @@
#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_DEFAULT_NUM_CONN 4096 /**< Default number of connections for each 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_MAX_TOTAL_NUM_CONN_IPV4_IPV6 8196 /**< MAX Connection shared between IPv4 and IPv6. */
-#define NSS_CONN_CFG_TIMEOUT 6000 /**< 6 sec timeout for connection cfg message. */
+#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 */
+#define NSS_MAX_TOTAL_NUM_CONN_IPV4_IPV6 1024 /* MAX Connection shared between IPv4 and IPv6 for low memory 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_MEM_PROFILE_LOW)
+#define NSS_EMPTY_BUFFER_SIZE 1792 /* Default buffer size for low profile. */
+#else
+#define NSS_EMPTY_BUFFER_SIZE 1984 /* Default buffer size for medium and high profile. */
+#endif
enum {
NSS_SUCCESS = 0,
diff --git a/nss_ipv4.c b/nss_ipv4.c
index ccd2a43..2693957 100644
--- a/nss_ipv4.c
+++ b/nss_ipv4.c
@@ -46,7 +46,7 @@
unsigned long cme_mem; /* Start address for connection match entry table */
} nss_ipv4_ct_info;
-int nss_ipv4_conn_cfg __read_mostly = NSS_DEFAULT_NUM_CONN;
+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];
diff --git a/nss_phys_if.c b/nss_phys_if.c
index 9038788..1257f03 100644
--- a/nss_phys_if.c
+++ b/nss_phys_if.c
@@ -1,6 +1,6 @@
/*
**************************************************************************
- * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all copies.
@@ -429,6 +429,15 @@
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_MEM_PROFILE_LOW
+ 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("%p: Phys If Change MTU, id:%d, mtu=%d\n", nss_ctx, if_num, mtu);
@@ -460,6 +469,14 @@
}
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_MEM_PROFILE_LOW
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;
/*
@@ -468,6 +485,10 @@
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())