Merge "[qca-ssdk]: Support uci set for "debug module_func set""
diff --git a/include/shell_lib/shell_io.h b/include/shell_lib/shell_io.h
index 98059ac..c6812b7 100755
--- a/include/shell_lib/shell_io.h
+++ b/include/shell_lib/shell_io.h
@@ -457,5 +457,9 @@
 cmd_data_check_fieldop(char *cmdstr, fal_acl_field_op_t def, fal_acl_field_op_t * val);
 
 #endif
+sw_error_t
+cmd_data_check_module(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size);
+sw_error_t
+cmd_data_check_func_ctrl(char *cmd_str, void * val, a_uint32_t size);
 #endif
 
diff --git a/src/ref/ref_uci.c b/src/ref/ref_uci.c
index f644b95..48c7147 100755
--- a/src/ref/ref_uci.c
+++ b/src/ref/ref_uci.c
@@ -11567,6 +11567,49 @@
 }
 #endif
 
+static int
+parse_debug_module_func(struct switch_val *val)
+{
+	struct switch_ext *switch_ext_p, *ext_value_p;
+	int rv = 0;
+
+	switch_ext_p = val->value.ext_val;
+	while (switch_ext_p) {
+		ext_value_p = switch_ext_p;
+
+		if (!strcmp(ext_value_p->option_name, "name")) {
+			switch_ext_p = switch_ext_p->next;
+			continue;
+		} else if (!strcmp(ext_value_p->option_name, "module")) {
+			val_ptr[0] = (char*)ext_value_p->option_value;
+		} else if (!strcmp(ext_value_p->option_name, "bitmap0")) {
+			val_ptr[1] = (char*)ext_value_p->option_value;
+		} else if (!strcmp(ext_value_p->option_name, "bitmap1")) {
+			val_ptr[2] = (char*)ext_value_p->option_value;
+		} else if (!strcmp(ext_value_p->option_name, "bitmap2")) {
+			val_ptr[3] = (char*)ext_value_p->option_value;
+		} else {
+			rv = -1;
+			break;
+		}
+
+		parameter_length++;
+		switch_ext_p = switch_ext_p->next;
+	}
+
+	return rv;
+}
+
+static int
+parse_debug(const char *command_name, struct switch_val *val)
+{
+	int rv = -1;
+	if (!strcmp(command_name, "Module_func")) {
+		rv = parse_debug_module_func(val);
+	}
+	return rv;
+}
+
 static int name_transfer(char *name, char *module, char *cmd)
 {
         char *p;
@@ -11723,6 +11766,8 @@
 #ifdef IN_VSI
 		rv = parse_vsi(command_name, val);
 #endif
+	} else if(!strcmp(module_name, "Debug")) {
+		rv = parse_debug(command_name, val);
 	}
 
 	if(!rv) {
diff --git a/src/shell_lib/shell_config.c b/src/shell_lib/shell_config.c
index d91123e..94f2dbd 100755
--- a/src/shell_lib/shell_config.c
+++ b/src/shell_lib/shell_config.c
@@ -1292,6 +1292,12 @@
 };
 #endif
 
+struct sub_cmd_des_t g_debug_des[] =
+{
+	{"module_func", "set", SW_API_MODULE_FUNC_CTRL_SET, NULL},
+	{NULL, NULL, 0, NULL},/*end of desc*/
+};
+
 struct cmd_des_t gcmd_des[] =
 {
     /*port ctrl*/
@@ -1492,6 +1498,9 @@
         "ctrlpkt", g_ctrlpkt_des,
     },
 #endif
+    {
+	"debug", g_debug_des,
+    },
 
     {NULL, NULL} /*end of desc*/
 };
diff --git a/src/shell_lib/shell_io.c b/src/shell_lib/shell_io.c
index cb2d54a..3ba7244 100755
--- a/src/shell_lib/shell_io.c
+++ b/src/shell_lib/shell_io.c
@@ -210,8 +210,8 @@
     SW_TYPE_DEF(SW_CABLESTATUS, NULL, NULL),
     SW_TYPE_DEF(SW_CABLELEN, NULL, NULL),
     SW_TYPE_DEF(SW_SSDK_CFG, NULL, NULL),
-    SW_TYPE_DEF(SW_MODULE, NULL, NULL),
-    SW_TYPE_DEF(SW_FUNC_CTRL, NULL, NULL),
+    SW_TYPE_DEF(SW_MODULE, (param_check_t)cmd_data_check_module, NULL),
+    SW_TYPE_DEF(SW_FUNC_CTRL, (param_check_t)cmd_data_check_func_ctrl, NULL),
 #ifdef IN_PORTCONTROL
     SW_TYPE_DEF(SW_HDRMODE, cmd_data_check_hdrmode, NULL),
 #endif
@@ -13900,3 +13900,91 @@
     return SW_OK;
 }
 #endif
+
+sw_error_t
+cmd_data_check_module(char *cmd_str, a_uint32_t * arg_val, a_uint32_t size)
+{
+	if (cmd_str == NULL)
+		return SW_BAD_PARAM;
+
+	if (!strcasecmp(cmd_str, "acl")) {
+		*arg_val = FAL_MODULE_ACL;
+	} else if (!strcasecmp(cmd_str, "vsi")) {
+		*arg_val = FAL_MODULE_VSI;
+	} else if (!strcasecmp(cmd_str, "ip")) {
+		*arg_val = FAL_MODULE_IP;
+	} else if (!strcasecmp(cmd_str, "flow")) {
+		*arg_val = FAL_MODULE_FLOW;
+	} else if (!strcasecmp(cmd_str, "qm")) {
+		*arg_val = FAL_MODULE_QM;
+	} else if (!strcasecmp(cmd_str, "qos")) {
+		*arg_val = FAL_MODULE_QOS;
+	} else if (!strcasecmp(cmd_str, "bm")) {
+		*arg_val = FAL_MODULE_BM;
+	} else if (!strcasecmp(cmd_str, "servcode")) {
+		*arg_val = FAL_MODULE_SERVCODE;
+	} else if (!strcasecmp(cmd_str, "rsshash")) {
+		*arg_val = FAL_MODULE_RSS_HASH;
+	} else if (!strcasecmp(cmd_str, "pppoe")) {
+		*arg_val = FAL_MODULE_PPPOE;
+	} else if (!strcasecmp(cmd_str, "portctrl")) {
+		*arg_val = FAL_MODULE_PORTCTRL;
+	} else if (!strcasecmp(cmd_str, "shaper")) {
+		*arg_val = FAL_MODULE_SHAPER;
+	} else if (!strcasecmp(cmd_str, "mib")) {
+		*arg_val = FAL_MODULE_MIB;
+	} else if (!strcasecmp(cmd_str, "mirror")) {
+		*arg_val = FAL_MODULE_MIRROR;
+	} else if (!strcasecmp(cmd_str, "fdb")) {
+		*arg_val = FAL_MODULE_FDB;
+	} else if (!strcasecmp(cmd_str, "stp")) {
+		*arg_val = FAL_MODULE_STP;
+	} else if (!strcasecmp(cmd_str, "sec")) {
+		*arg_val = FAL_MODULE_SEC;
+	} else if (!strcasecmp(cmd_str, "trunk")) {
+		*arg_val = FAL_MODULE_TRUNK;
+	} else if (!strcasecmp(cmd_str, "portvlan")) {
+		*arg_val = FAL_MODULE_PORTVLAN;
+	} else if (!strcasecmp(cmd_str, "ctrlpkt")) {
+		*arg_val = FAL_MODULE_CTRLPKT;
+	} else if (!strcasecmp(cmd_str, "policer")) {
+		*arg_val = FAL_MODULE_POLICER;
+	}
+	else
+	{
+		return SW_BAD_VALUE;
+	}
+
+	return SW_OK;
+}
+
+sw_error_t
+cmd_data_check_func_ctrl(char *cmd_str, void * val, a_uint32_t size)
+{
+	sw_error_t rv;
+	fal_func_ctrl_t entry;
+
+	aos_mem_zero(&entry, sizeof (fal_func_ctrl_t));
+
+	rv = __cmd_data_check_complex("bitmap0", "0",
+			"usage: the format is HEX \n", cmd_data_check_uint32,
+			&(entry.bitmap[0]), sizeof (a_uint32_t));
+	if (rv)
+		return rv;
+
+	rv = __cmd_data_check_complex("bitmap1", "0",
+			"usage: the format is HEX \n", cmd_data_check_uint32,
+			&(entry.bitmap[1]), sizeof (a_uint32_t));
+	if (rv)
+		return rv;
+
+	rv = __cmd_data_check_complex("bitmap2", "0",
+			"usage: the format is HEX \n", cmd_data_check_uint32,
+			&(entry.bitmap[2]), sizeof (a_uint32_t));
+	if (rv)
+		return rv;
+
+	*(fal_func_ctrl_t *)val = entry;
+
+	return SW_OK;
+}