refactor(smc_fuzz): performance enhancement

Add the ability to return integer rather than string from fuzzer
function. This will improve performance especially for larger fuzz
based testing. This will work in tandem with the changes to the CI where
the script flows provide additional support for the change. Modifications
to the device tree files have been made to prevent name clashes with
the function names.

Change-Id: I95aaf23c95943f944d5837e2a8440514aafd6dde
Signed-off-by: mardyk01 <mark.dykes@arm.com>
diff --git a/smc_fuzz/dts/sdei.dts b/smc_fuzz/dts/sdei.dts
index 2418916..a8199e1 100644
--- a/smc_fuzz/dts/sdei.dts
+++ b/smc_fuzz/dts/sdei.dts
@@ -15,31 +15,31 @@
 		bias = <30>;
 		sdei_version {
 			bias = <30>;
-			functionname = "sdei_version";
+			functionname = "sdei_version_funcid";
 		};
 		sdei_pe_unmask {
 			bias = <30>;
-			functionname = "sdei_pe_unmask";
+			functionname = "sdei_pe_unmask_funcid";
 		};
 		sdei_pe_mask {
 			bias = <30>;
-			functionname = "sdei_pe_mask";
+			functionname = "sdei_pe_mask_funcid";
 		};
 		sdei_event_status {
 			bias = <30>;
-			functionname = "sdei_event_status";
+			functionname = "sdei_event_status_funcid";
 		};
 		sdei_event_signal {
 			bias = <30>;
-			functionname = "sdei_event_signal";
+			functionname = "sdei_event_signal_funcid";
 		};
 		sdei_private_reset {
 			bias = <30>;
-			functionname = "sdei_private_reset";
+			functionname = "sdei_private_reset_funcid";
 		};
 		sdei_shared_reset {
 			bias = <30>;
-			functionname = "sdei_shared_reset";
+			functionname = "sdei_shared_reset_funcid";
 		};
 	};
 
diff --git a/smc_fuzz/dts/top.dts b/smc_fuzz/dts/top.dts
index bda77d6..4d37c7e 100644
--- a/smc_fuzz/dts/top.dts
+++ b/smc_fuzz/dts/top.dts
@@ -20,50 +20,50 @@
 		bias = <30>;
 		sdei_version {
 			bias = <30>;
-			functionname = "sdei_version";
+			functionname = "sdei_version_funcid";
 		};
 		sdei_pe_unmask {
 			bias = <30>;
-			functionname = "sdei_pe_unmask";
+			functionname = "sdei_pe_unmask_funcid";
 		};
 		sdei_pe_mask {
 			bias = <30>;
-			functionname = "sdei_pe_mask";
+			functionname = "sdei_pe_mask_funcid";
 		};
 		sdei_event_status {
 			bias = <30>;
-			functionname = "sdei_event_status";
+			functionname = "sdei_event_status_funcid";
 		};
 		sdei_event_signal {
 			bias = <30>;
-			functionname = "sdei_event_signal";
+			functionname = "sdei_event_signal_funcid";
 		};
 		sdei_private_reset {
 			bias = <30>;
-			functionname = "sdei_private_reset";
+			functionname = "sdei_private_reset_funcid";
 		};
 		sdei_shared_reset {
 			bias = <30>;
-			functionname = "sdei_shared_reset";
+			functionname = "sdei_shared_reset_funcid";
 		};
 	};
 	tsp {
 		bias = <30>;
 		tsp_add_op {
 			bias = <30>;
-			functionname = "tsp_add_op";
+			functionname = "tsp_add_op_funcid";
 		};
 		tsp_sub_op {
 			bias = <30>;
-			functionname = "tsp_sub_op";
+			functionname = "tsp_sub_op_funcid";
 		};
 		tsp_mul_op {
 			bias = <30>;
-			functionname = "tsp_mul_op";
+			functionname = "tsp_mul_op_funcid";
 		};
 		tsp_div_op {
 			bias = <30>;
-			functionname = "tsp_div_op";
+			functionname = "tsp_div_op_funcid";
 		};
 	};
 };
diff --git a/smc_fuzz/include/fifo3d.h b/smc_fuzz/include/fifo3d.h
index c04567c..95ebb4a 100644
--- a/smc_fuzz/include/fifo3d.h
+++ b/smc_fuzz/include/fifo3d.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -18,22 +18,28 @@
 	char ***nnfifo;
 	char ***fnamefifo;
 	int **biasfifo;
+	int **fidfifo;
 	int col;
 	int curr_col;
 	int *row;
 };
 
 /*
- * Push function name string into raw data structure
+ * Push function name string into the raw data structure
  */
 void push_3dfifo_fname(struct fifo3d *f3d, char *fname);
 
 /*
- * Push bias value into raw data structure
+ * Push bias value into the raw data structure
  */
 void push_3dfifo_bias(struct fifo3d *f3d, int bias);
 
 /*
+ * Push id for function value into the raw data structure
+ */
+void push_3dfifo_fid(struct fifo3d *f3d, int id);
+
+/*
  * Create new column and/or row for raw data structure for newly
  * found node from device tree
  */
diff --git a/smc_fuzz/include/nfifo.h b/smc_fuzz/include/nfifo.h
new file mode 100644
index 0000000..cef07da
--- /dev/null
+++ b/smc_fuzz/include/nfifo.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2024, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+#ifndef NFIFO_H
+#define NFIFO_H
+
+#define CMP_SUCCESS 0
+#define NFIFO_Q_THRESHOLD 10
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "smcmalloc.h"
+
+struct nfifo {
+	char **lnme;
+	int nent;
+	int thent;
+};
+
+void nfifoinit(struct nfifo *nf, struct memmod *mmod);
+void pushnme(char *nme, struct nfifo *nf, struct memmod *mmod);
+char *readnme(int ent, struct nfifo *nf, struct memmod *mmod);
+int searchnme(char *nme, struct nfifo *nf, struct memmod *mmod);
+void printent(struct nfifo *nf);
+
+#endif /* NFIFO_H */
diff --git a/smc_fuzz/include/sdei_fuzz_helper.h b/smc_fuzz/include/sdei_fuzz_helper.h
index 71d462d..cf4ddd1 100644
--- a/smc_fuzz/include/sdei_fuzz_helper.h
+++ b/smc_fuzz/include/sdei_fuzz_helper.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -11,6 +11,29 @@
 #include <tftf_lib.h>
 #include <timer.h>
 
-void tftf_test_sdei_noarg(int64_t (*sdei_func)(void), char *);
+#ifndef sdei_version_funcid
+#define sdei_version_funcid 0
+#endif
+#ifndef sdei_pe_unmask_funcid
+#define sdei_pe_unmask_funcid 0
+#endif
+#ifndef sdei_pe_mask_funcid
+#define sdei_pe_mask_funcid 0
+#endif
+#ifndef sdei_event_status_funcid
+#define sdei_event_status_funcid 0
+#endif
+#ifndef sdei_event_signal_funcid
+#define sdei_event_signal_funcid 0
+#endif
+#ifndef sdei_private_reset_funcid
+#define sdei_private_reset_funcid 0
+#endif
+#ifndef sdei_shared_reset_funcid
+#define sdei_shared_reset_funcid 0
+#endif
+
+
+void tftf_test_sdei_noarg(int64_t (*sdei_func)(void), char *funcstr);
 void tftf_test_sdei_singlearg(int64_t (*sdei_func)(uint64_t), char *funcstr);
-void run_sdei_fuzz(char *);
+void run_sdei_fuzz(int funcid);
diff --git a/smc_fuzz/include/smcmalloc.h b/smc_fuzz/include/smcmalloc.h
index 129e07c..fe134bf 100644
--- a/smc_fuzz/include/smcmalloc.h
+++ b/smc_fuzz/include/smcmalloc.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -11,7 +11,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "fifo3d.h"
 
 #define TOTALMEMORYSIZE (0x10000)
 #define BLKSPACEDIV (4)
diff --git a/smc_fuzz/include/tsp_fuzz_helper.h b/smc_fuzz/include/tsp_fuzz_helper.h
index 444d54b..019ee68 100644
--- a/smc_fuzz/include/tsp_fuzz_helper.h
+++ b/smc_fuzz/include/tsp_fuzz_helper.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -11,5 +11,18 @@
 #include <tftf_lib.h>
 #include <timer.h>
 
-void tftf_test_tsp_smc(uint64_t tsp_id, char *);
-void run_tsp_fuzz(char *);
+#ifndef tsp_add_op_funcid
+#define tsp_add_op_funcid 0
+#endif
+#ifndef tsp_sub_op_funcid
+#define tsp_sub_op_funcid 0
+#endif
+#ifndef tsp_mul_op_funcid
+#define tsp_mul_op_funcid 0
+#endif
+#ifndef tsp_div_op_funcid
+#define tsp_div_op_funcid 0
+#endif
+
+void tftf_test_tsp_smc(uint64_t tsp_id, char *funcstr);
+void run_tsp_fuzz(int funcid);
diff --git a/smc_fuzz/src/fifo3d.c b/smc_fuzz/src/fifo3d.c
index 119b26c..0b99907 100644
--- a/smc_fuzz/src/fifo3d.c
+++ b/smc_fuzz/src/fifo3d.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -27,7 +27,7 @@
 #endif
 
 /*
- * Push function name string into raw data structure
+ * Push function name string into the data structure from device tree file
  */
 void push_3dfifo_fname(struct fifo3d *f3d, char *fname)
 {
@@ -36,7 +36,7 @@
 }
 
 /*
- * Push bias value into raw data structure
+ * Push bias value into data structure from device tree file
  */
 void push_3dfifo_bias(struct fifo3d *f3d, int bias)
 {
@@ -44,14 +44,36 @@
 }
 
 /*
+ * Push function id value into data structure from device tree file
+ */
+void push_3dfifo_fid(struct fifo3d *f3d, int id)
+{
+	f3d->fidfifo[f3d->col - 1][f3d->row[f3d->col - 1] - 1] = id;
+}
+
+
+/*
  * Create new column and/or row for raw data structure for newly
- * found node from device tree
+ * found node from device tree.  The fifo has four elements that reflect
+ * values obtained from the device tree for each node read.  This preserves
+ * the hierarchy found in that file so it can be utilized in construction of
+ * the smc nodes structure for final use in randomly calling the SMC functions.
+ * This is essentially a bias tree in final form.
  */
 void push_3dfifo_col(struct fifo3d *f3d, char *entry, struct memmod *mmod)
 {
+
+/*
+ * four elements required:
+ * 1. node name as a string
+ * 2. function name as a string
+ * 3. bias value as an integer
+ * 4. id value as an integer
+ */
 	char ***tnnfifo;
 	char ***tfnamefifo;
 	int **tbiasfifo;
+	int **tfidfifo;
 
 	if (f3d->col == f3d->curr_col) {
 		f3d->col++;
@@ -76,15 +98,17 @@
 		f3d->row[f3d->col - 1] = 1;
 
 		/*
-		 * Create new raw data memory
+		 * Start node creation for reading of device tree file
 		 */
 		tnnfifo = GENMALLOC(f3d->col * sizeof(char **));
 		tfnamefifo = GENMALLOC(f3d->col * sizeof(char **));
 		tbiasfifo = GENMALLOC((f3d->col) * sizeof(int *));
+		tfidfifo = GENMALLOC((f3d->col) * sizeof(int *));
 		for (unsigned int i = 0U; (int)i < f3d->col; i++) {
 			tnnfifo[i] = GENMALLOC(f3d->row[i] * sizeof(char *));
 			tfnamefifo[i] = GENMALLOC(f3d->row[i] * sizeof(char *));
 			tbiasfifo[i] = GENMALLOC((f3d->row[i]) * sizeof(int));
+			tfidfifo[i] = GENMALLOC((f3d->row[i]) * sizeof(int));
 			for (unsigned int j = 0U; (int)j < f3d->row[i]; j++) {
 				tnnfifo[i][j] = GENMALLOC(1 * sizeof(char[MAX_NAME_CHARS]));
 				tfnamefifo[i][j] =
@@ -95,6 +119,7 @@
 					strlcpy(tfnamefifo[i][j],
 						f3d->fnamefifo[i][j], MAX_NAME_CHARS);
 					tbiasfifo[i][j] = f3d->biasfifo[i][j];
+					tfidfifo[i][j] = f3d->fidfifo[i][j];
 				}
 			}
 		}
@@ -107,6 +132,7 @@
 		strlcpy(tfnamefifo[f3d->col - 1][f3d->row[f3d->col - 1] - 1],
 			"none", MAX_NAME_CHARS);
 		tbiasfifo[f3d->col - 1][f3d->row[f3d->col - 1] - 1] = 0;
+		tfidfifo[f3d->col - 1][f3d->row[f3d->col - 1] - 1] = 0;
 
 		/*
 		 * Free the old raw data structres
@@ -119,11 +145,13 @@
 			GENFREE(f3d->nnfifo[i]);
 			GENFREE(f3d->fnamefifo[i]);
 			GENFREE(f3d->biasfifo[i]);
+			GENFREE(f3d->fidfifo[i]);
 		}
 		if (f3d->col > 1) {
 			GENFREE(f3d->nnfifo);
 			GENFREE(f3d->fnamefifo);
 			GENFREE(f3d->biasfifo);
+			GENFREE(f3d->fidfifo);
 		}
 
 		/*
@@ -132,6 +160,7 @@
 		f3d->nnfifo = tnnfifo;
 		f3d->fnamefifo = tfnamefifo;
 		f3d->biasfifo = tbiasfifo;
+		f3d->fidfifo = tfidfifo;
 	}
 	if (f3d->col != f3d->curr_col) {
 		/*
@@ -141,15 +170,17 @@
 		f3d->row[f3d->col - 1]++;
 
 		/*
-		 * Create new raw data memory
+		 * Create new node form device tree file
 		 */
 		tnnfifo = GENMALLOC(f3d->col * sizeof(char **));
 		tfnamefifo = GENMALLOC(f3d->col * sizeof(char **));
 		tbiasfifo = GENMALLOC((f3d->col) * sizeof(int *));
+		tfidfifo = GENMALLOC((f3d->col) * sizeof(int *));
 		for (unsigned int i = 0U; (int)i < f3d->col; i++) {
 			tnnfifo[i] = GENMALLOC(f3d->row[i] * sizeof(char *));
 			tfnamefifo[i] = GENMALLOC(f3d->row[i] * sizeof(char *));
 			tbiasfifo[i] = GENMALLOC((f3d->row[i]) * sizeof(int));
+			tfidfifo[i] = GENMALLOC((f3d->row[i]) * sizeof(int));
 			for (unsigned int j = 0U; (int)j < f3d->row[i]; j++) {
 				tnnfifo[i][j] = GENMALLOC(1 * sizeof(char[MAX_NAME_CHARS]));
 				tfnamefifo[i][j] =
@@ -160,6 +191,7 @@
 					strlcpy(tfnamefifo[i][j],
 						f3d->fnamefifo[i][j], MAX_NAME_CHARS);
 					tbiasfifo[i][j] = f3d->biasfifo[i][j];
+					tfidfifo[i][j] = f3d->fidfifo[i][j];
 				}
 			}
 		}
@@ -172,6 +204,7 @@
 		strlcpy(tfnamefifo[f3d->col - 1][f3d->row[f3d->col - 1] - 1],
 			"none", MAX_NAME_CHARS);
 		tbiasfifo[f3d->col - 1][f3d->row[f3d->col - 1] - 1] = 0;
+		tfidfifo[f3d->col - 1][f3d->row[f3d->col - 1] - 1] = 0;
 
 		/*
 		 * Free the old raw data structres
@@ -187,10 +220,12 @@
 			GENFREE(f3d->nnfifo[i]);
 			GENFREE(f3d->fnamefifo[i]);
 			GENFREE(f3d->biasfifo[i]);
+			GENFREE(f3d->fidfifo[i]);
 		}
 		GENFREE(f3d->nnfifo);
 		GENFREE(f3d->fnamefifo);
 		GENFREE(f3d->biasfifo);
+		GENFREE(f3d->fidfifo);
 
 		/*
 		 * Point to new data
@@ -198,5 +233,6 @@
 		f3d->nnfifo = tnnfifo;
 		f3d->fnamefifo = tfnamefifo;
 		f3d->biasfifo = tbiasfifo;
+		f3d->fidfifo = tfidfifo;
 	}
 }
diff --git a/smc_fuzz/src/nfifo.c b/smc_fuzz/src/nfifo.c
new file mode 100644
index 0000000..b4a021c
--- /dev/null
+++ b/smc_fuzz/src/nfifo.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2024, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/*
+ * FIFO for matching strings to integers
+ */
+
+#include "nfifo.h"
+
+#ifdef SMC_FUZZ_TMALLOC
+#define GENMALLOC(x)	malloc((x))
+#define GENFREE(x)	free((x))
+#else
+#define GENMALLOC(x)	smcmalloc((x), mmod)
+#define GENFREE(x)	smcfree((x), mmod)
+#endif
+
+/*
+ * Initialization of FIFO
+ */
+void nfifoinit(struct nfifo *nf, struct memmod *mmod)
+{
+	nf->nent = 0;
+	nf->thent = NFIFO_Q_THRESHOLD;
+	nf->lnme = GENMALLOC(nf->thent * sizeof(char *));
+}
+
+/*
+ * push string to FIFO for automatic numerical assignment
+ */
+void pushnme(char *nme, struct nfifo *nf, struct memmod *mmod)
+{
+	char **tnme;
+
+	if (searchnme(nme, nf, mmod) == -1) {
+		if (nf->nent >= nf->thent) {
+			nf->thent += NFIFO_Q_THRESHOLD;
+			tnme = GENMALLOC(nf->thent * sizeof(char *));
+			for (unsigned int x = 0; x < nf->nent; x++) {
+				tnme[x] = GENMALLOC(1 * sizeof(char[MAX_NAME_CHARS]));
+				strlcpy(tnme[x], nf->lnme[x], MAX_NAME_CHARS);
+			}
+			tnme[nf->nent] = GENMALLOC(1 * sizeof(char[MAX_NAME_CHARS]));
+			strlcpy(tnme[nf->nent], nme, MAX_NAME_CHARS);
+			for (unsigned int x = 0; x < nf->nent; x++) {
+				GENFREE(nf->lnme[x]);
+			}
+			GENFREE(nf->lnme);
+			nf->lnme = tnme;
+		} else {
+			nf->lnme[nf->nent] = GENMALLOC(1 * sizeof(char[MAX_NAME_CHARS]));
+			strlcpy(nf->lnme[nf->nent], nme, MAX_NAME_CHARS);
+		}
+		nf->nent++;
+	}
+}
+
+/*
+ * Find name associated with numercal designation
+ */
+char *readnme(int ent, struct nfifo *nf, struct memmod *mmod)
+{
+	return nf->lnme[ent];
+}
+
+/*
+ * Search FIFO for integer given an input string returns -1
+ * if not found
+ */
+int searchnme(char *nme, struct nfifo *nf, struct memmod *mmod)
+{
+	for (unsigned int x = 0; x < nf->nent; x++) {
+		if (strcmp(nf->lnme[x], nme) == CMP_SUCCESS) {
+			return (x + 1);
+		}
+	}
+	return -1;
+}
+
+/*
+ * Print of all elements of FIFO string and associated integer
+ */
+void printent(struct nfifo *nf)
+{
+	for (unsigned int x = 0; x < nf->nent; x++) {
+		printf("nfifo entry %s has value %d\n", nf->lnme[x], x);
+	}
+}
diff --git a/smc_fuzz/src/randsmcmod.c b/smc_fuzz/src/randsmcmod.c
index 7bedf81..a86feb6 100644
--- a/smc_fuzz/src/randsmcmod.c
+++ b/smc_fuzz/src/randsmcmod.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -9,6 +9,7 @@
 #include <drivers/arm/private_timer.h>
 #include <events.h>
 #include "fifo3d.h"
+#include "nfifo.h"
 #include <libfdt.h>
 
 #include <plat_topology.h>
@@ -16,7 +17,7 @@
 #include <tftf_lib.h>
 
 extern char _binary___dtb_start[];
-extern void runtestfunction(char *funcstr);
+extern void runtestfunction(int funcid);
 
 struct memmod tmod __aligned(65536) __section("smcfuzz");
 static int cntndarray;
@@ -119,13 +120,14 @@
 	int *biases;				 // Biases of the individual nodes
 	int *biasarray;				 // Array of biases across all nodes
 	char **snames;				 // String that is unique to the SMC call called in test
+	int *snameid;				 // ID that is unique to the SMC call called in test
 	struct rand_smc_node *treenodes;	 // Selection of nodes that are farther down in the tree
-						// that reference further rand_smc_node objects
+						 // that reference further rand_smc_node objects
 	int *norcall;				// Specifies whether a particular node is a leaf node or tree node
-	int entries;				// Number of nodes in object
-	int biasent;				// Number that gives the total number of entries in biasarray
-						// based on all biases of the nodes
-	char **nname;				// Array of node names
+	int entries;				 // Number of nodes in object
+	int biasent;				 // Number that gives the total number of entries in biasarray
+						 // based on all biases of the nodes
+	char **nname;				 // Array of node names
 };
 
 
@@ -156,6 +158,9 @@
 	int cntndarray;
 	struct rand_smc_node nrnode;
 	struct rand_smc_node *tndarray;
+	struct nfifo nf;
+
+	nfifoinit(&nf, mmod);
 
 	f3d.col = 0;
 	f3d.curr_col = 0;
@@ -166,9 +171,6 @@
 
 	fhdptr = (struct fdt_header *)_binary___dtb_start;
 
-	if (fdt_check_header((void *)fhdptr) != 0) {
-		printf("ERROR, not device tree compliant\n");
-	}
 	fhd = *fhdptr;
 	cntndarray = 0;
 	nrnode.entries = 0;
@@ -244,6 +246,8 @@
 			if (strcmp(cset, "functionname") == 0) {
 				pullstringdt(&dtb, dtb_beg, 0, cset);
 				push_3dfifo_fname(&f3d, cset);
+				pushnme(cset, &nf, mmod);
+				push_3dfifo_fid(&f3d, searchnme(cset, &nf, mmod));
 				leafnode = 1;
 				if (bias_count == 0U) {
 					bintnode = 1U;
@@ -279,6 +283,7 @@
 				for (unsigned int j = 0U; (int)j < cntndarray; j++) {
 					tndarray[j].biases = GENMALLOC(ndarray[j].entries * sizeof(int));
 					tndarray[j].snames = GENMALLOC(ndarray[j].entries * sizeof(char *));
+					tndarray[j].snameid = GENMALLOC(ndarray[j].entries * sizeof(int));
 					tndarray[j].norcall = GENMALLOC(ndarray[j].entries * sizeof(int));
 					tndarray[j].nname = GENMALLOC(ndarray[j].entries * sizeof(char *));
 					tndarray[j].treenodes = GENMALLOC(ndarray[j].entries * sizeof(struct rand_smc_node));
@@ -286,6 +291,7 @@
 					for (unsigned int i = 0U; (int)i < ndarray[j].entries; i++) {
 						tndarray[j].snames[i] = GENMALLOC(1 * sizeof(char[MAX_NAME_CHARS]));
 						strlcpy(tndarray[j].snames[i], ndarray[j].snames[i], MAX_NAME_CHARS);
+						tndarray[j].snameid[i] = ndarray[j].snameid[i];
 						tndarray[j].nname[i] = GENMALLOC(1 * sizeof(char[MAX_NAME_CHARS]));
 						strlcpy(tndarray[j].nname[i], ndarray[j].nname[i], MAX_NAME_CHARS);
 						tndarray[j].biases[i] = ndarray[j].biases[i];
@@ -303,6 +309,7 @@
 				}
 				tndarray[cntndarray].biases = GENMALLOC(f3d.row[f3d.col + 1] * sizeof(int));
 				tndarray[cntndarray].snames = GENMALLOC(f3d.row[f3d.col + 1] * sizeof(char *));
+				tndarray[cntndarray].snameid = GENMALLOC(f3d.row[f3d.col + 1] * sizeof(int));
 				tndarray[cntndarray].norcall = GENMALLOC(f3d.row[f3d.col + 1] * sizeof(int));
 				tndarray[cntndarray].nname = GENMALLOC(f3d.row[f3d.col + 1] * sizeof(char *));
 				tndarray[cntndarray].treenodes = GENMALLOC(f3d.row[f3d.col + 1] * sizeof(struct rand_smc_node));
@@ -313,9 +320,11 @@
 				 */
 				int cntbias = 0;
 				int bias_count = 0;
+
 				for (unsigned int j = 0U; (int)j < f3d.row[f3d.col + 1]; j++) {
 					tndarray[cntndarray].snames[j] = GENMALLOC(1 * sizeof(char[MAX_NAME_CHARS]));
 					strlcpy(tndarray[cntndarray].snames[j], f3d.fnamefifo[f3d.col + 1][j], MAX_NAME_CHARS);
+					tndarray[cntndarray].snameid[j] = f3d.fidfifo[f3d.col + 1][j];
 					tndarray[cntndarray].nname[j] = GENMALLOC(1 * sizeof(char[MAX_NAME_CHARS]));
 					strlcpy(tndarray[cntndarray].nname[j], f3d.nnfifo[f3d.col + 1][j], MAX_NAME_CHARS);
 					tndarray[cntndarray].biases[j] = f3d.biasfifo[f3d.col + 1][j];
@@ -355,6 +364,7 @@
 						GENFREE(ndarray[j].norcall);
 						GENFREE(ndarray[j].biasarray);
 						GENFREE(ndarray[j].snames);
+						GENFREE(ndarray[j].snameid);
 						GENFREE(ndarray[j].nname);
 						GENFREE(ndarray[j].treenodes);
 					}
@@ -377,6 +387,7 @@
 				GENFREE(f3d.nnfifo[f3d.col + 1]);
 				GENFREE(f3d.fnamefifo[f3d.col + 1]);
 				GENFREE(f3d.biasfifo[f3d.col + 1]);
+				GENFREE(f3d.fidfifo[f3d.col + 1]);
 				f3d.curr_col -= 1;
 			}
 		}
@@ -393,16 +404,17 @@
 				GENFREE(f3d.nnfifo[i]);
 				GENFREE(f3d.fnamefifo[i]);
 				GENFREE(f3d.biasfifo[i]);
+				GENFREE(f3d.fidfifo[i]);
 			}
 			GENFREE(f3d.nnfifo);
 			GENFREE(f3d.fnamefifo);
 			GENFREE(f3d.biasfifo);
+			GENFREE(f3d.fidfifo);
 			GENFREE(f3d.row);
 			dtdone = 1;
 		}
 	}
 
-
 	*casz = cntndarray;
 	return ndarray;
 }
@@ -445,9 +457,6 @@
 	return TEST_RESULT_SUCCESS;
 }
 
-/*
- * Declaration of single fuzzing instance(seed based)
- */
 test_result_t smc_fuzzing_instance(uint32_t seed)
 {
 	struct rand_smc_node *tlnode;
@@ -479,11 +488,13 @@
 	for (unsigned int i = 0U; i < SMC_FUZZ_CALLS_PER_INSTANCE; i++) {
 		tlnode = &ndarray[cntndarray - 1];
 		int nd = 0;
+
 		while (nd == 0) {
 			int nch = rand()%tlnode->biasent;
 			int selent = tlnode->biasarray[nch];
+
 			if (tlnode->norcall[selent] == 0) {
-				runtestfunction(tlnode->snames[selent]);
+				runtestfunction(tlnode->snameid[selent]);
 				nd = 1;
 			} else {
 				tlnode = &tlnode->treenodes[selent];
@@ -493,9 +504,6 @@
 	return TEST_RESULT_SUCCESS;
 }
 
-/*
- * free memory after fuzzing is complete
- */
 test_result_t smc_fuzzing_deinit(void)
 {
 	/*
@@ -511,6 +519,7 @@
 			GENFREE(ndarray[j].norcall);
 			GENFREE(ndarray[j].biasarray);
 			GENFREE(ndarray[j].snames);
+			GENFREE(ndarray[j].snameid);
 			GENFREE(ndarray[j].nname);
 			GENFREE(ndarray[j].treenodes);
 		}
@@ -521,7 +530,7 @@
 }
 
 /*
- * Execute fuzzing module
+ * Top of SMC fuzzing module
  */
 test_result_t smc_fuzzer_execute(void)
 {
@@ -576,14 +585,11 @@
 	return result;
 }
 
-/*
- * Top level of fuzzing module
- */
 test_result_t smc_fuzzing_top(void)
 {
 	test_result_t result = TEST_RESULT_SUCCESS;
-
 	init_smc_fuzzing();
+
 #ifdef MULTI_CPU_SMC_FUZZER
 	u_register_t lead_mpid, target_mpid;
 	int cpu_node;
diff --git a/smc_fuzz/src/runtestfunction_helpers.c b/smc_fuzz/src/runtestfunction_helpers.c
index b9fa794..c3b2cca 100644
--- a/smc_fuzz/src/runtestfunction_helpers.c
+++ b/smc_fuzz/src/runtestfunction_helpers.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -11,8 +11,8 @@
 /*
  * Invoke the SMC call based on the function name specified.
  */
-void runtestfunction(char *funcstr)
+void runtestfunction(int funcid)
 {
-	run_sdei_fuzz(funcstr);
-	run_tsp_fuzz(funcstr);
+	run_sdei_fuzz(funcid);
+	run_tsp_fuzz(funcid);
 }
diff --git a/smc_fuzz/src/sdei_fuzz_helper.c b/smc_fuzz/src/sdei_fuzz_helper.c
index cb634dc..1d22335 100644
--- a/smc_fuzz/src/sdei_fuzz_helper.c
+++ b/smc_fuzz/src/sdei_fuzz_helper.c
@@ -1,11 +1,15 @@
 /*
- * Copyright (c) 2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2023-2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
+#include <fuzz_names.h>
 #include <sdei_fuzz_helper.h>
 
+/*
+ * SDEI function that has no arguments
+ */
 void tftf_test_sdei_noarg(int64_t (*sdei_func)(void), char *funcstr)
 {
 		int64_t ret = (*sdei_func)();
@@ -15,6 +19,9 @@
 		}
 }
 
+/*
+ * SDEI function that has single argument
+ */
 void tftf_test_sdei_singlearg(int64_t (*sdei_func)(uint64_t), char *funcstr)
 {
 		int64_t ret = (*sdei_func)(0);
@@ -24,28 +31,30 @@
 		}
 }
 
-
-void run_sdei_fuzz(char *funcstr)
+/*
+ * SDEI function called from fuzzer
+ */
+void run_sdei_fuzz(int funcid)
 {
-	if (strcmp(funcstr, "sdei_version") == CMP_SUCCESS) {
+	if (funcid == sdei_version_funcid) {
 		long long ret = sdei_version();
 
 		if (ret != MAKE_SDEI_VERSION(1, 0, 0)) {
 			tftf_testcase_printf("Unexpected SDEI version: 0x%llx\n",
 					     ret);
 		}
-	} else if (strcmp(funcstr, "sdei_pe_unmask") == CMP_SUCCESS) {
-		tftf_test_sdei_noarg(sdei_pe_unmask, "sdei_pe_unmask");
-	} else if (strcmp(funcstr, "sdei_pe_mask") == CMP_SUCCESS) {
+	} else if (funcid == sdei_pe_unmask_funcid) {
+		tftf_test_sdei_noarg(sdei_pe_unmask, "sdei_pe_unmuask");
+	} else if (funcid == sdei_pe_mask_funcid) {
 		tftf_test_sdei_noarg(sdei_pe_mask, "sdei_pe_mask");
-	} else if (strcmp(funcstr, "sdei_event_status") == CMP_SUCCESS) {
+	} else if (funcid == sdei_event_status_funcid) {
 		tftf_test_sdei_singlearg((int64_t (*)(uint64_t))sdei_event_status,
 		"sdei_event_status");
-	} else if (strcmp(funcstr, "sdei_event_signal") == CMP_SUCCESS) {
+	} else if (funcid == sdei_event_signal_funcid) {
 		tftf_test_sdei_singlearg(sdei_event_signal, "sdei_event_signal");
-	} else if (strcmp(funcstr, "sdei_private_reset") == CMP_SUCCESS) {
+	} else if (funcid == sdei_private_reset_funcid) {
 		tftf_test_sdei_noarg(sdei_private_reset, "sdei_private_reset");
-	} else if (strcmp(funcstr, "sdei_shared_reset") == CMP_SUCCESS) {
+	} else if (funcid == sdei_shared_reset_funcid) {
 		tftf_test_sdei_noarg(sdei_shared_reset, "sdei_shared_reset");
 	}
 }
diff --git a/smc_fuzz/src/tsp_fuzz_helper.c b/smc_fuzz/src/tsp_fuzz_helper.c
index c6ed219..610fae0 100644
--- a/smc_fuzz/src/tsp_fuzz_helper.c
+++ b/smc_fuzz/src/tsp_fuzz_helper.c
@@ -1,10 +1,14 @@
 /*
- * Copyright (c) 2023, Arm Limited. All rights reserved.
+ * Copyright (c) 2024, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
+#include <fuzz_names.h>
 #include <tsp_fuzz_helper.h>
 
+/*
+ * Generic TSP based function call for math operations
+ */
 void tftf_test_tsp_smc(uint64_t tsp_id, char *funcstr)
 {
 		uint64_t fn_identifier = TSP_FAST_FID(tsp_id);
@@ -22,15 +26,18 @@
 		}
 }
 
-void run_tsp_fuzz(char *funcstr)
+/*
+ * TSP function called from fuzzer
+ */
+void run_tsp_fuzz(int funcid)
 {
-	if (strcmp(funcstr, "tsp_add_op") == CMP_SUCCESS) {
+	if (funcid == tsp_add_op_funcid) {
 		tftf_test_tsp_smc(TSP_ADD, "tsp_add_op");
-	} else if (strcmp(funcstr, "tsp_sub_op") == CMP_SUCCESS) {
+	} else if (funcid == tsp_sub_op_funcid) {
 		tftf_test_tsp_smc(TSP_SUB, "tsp_sub_op");
-	} else if (strcmp(funcstr, "tsp_mul_op") == CMP_SUCCESS) {
+	} else if (funcid == tsp_mul_op_funcid) {
 		tftf_test_tsp_smc(TSP_MUL, "tsp_mul_op");
-	} else if (strcmp(funcstr, "tsp_div_op") == CMP_SUCCESS) {
+	} else if (funcid == tsp_div_op_funcid) {
 		tftf_test_tsp_smc(TSP_DIV, "tsp_div_op");
 	}
 }