[][openwrt][mt7988][tops][TOPS Alpha release]

[Description]
Add alpha version of TOPS(tunnel offload processor system) and tops-tool
package.

TOPS package supports tunnel protocol HW offload. The support offload
tunnel protocols for Alpha version are L2oGRE and L2TPv2.
Notice that, TOPS only guarantees that inner packets are TCP. It is still
unstable for UDP inner packet flow.

tops-tool package provides several debug features such as logger, coredump
for TOPS.

[Release-log]
N/A

Change-Id: Iab6e4a89bebbe42c967f28e0c9e9c0611673f354
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7852683
diff --git a/feed/tops-tool/src/tops-tool.c b/feed/tops-tool/src/tops-tool.c
new file mode 100644
index 0000000..32ab579
--- /dev/null
+++ b/feed/tops-tool/src/tops-tool.c
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2023 MediaTek Inc. All Rights Reserved.
+ *
+ * Author: Alvin Kuo <Alvin.Kuo@mediatek.com>
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "dump.h"
+
+static void print_usage(void)
+{
+	printf("Usage:\n");
+	printf(" tops-tool [CMD] [DUMP_DIR]\n");
+	printf(" [CMD] are:\n");
+	printf("    save_dump   save dump data as file in directory [DUMP_DIR]\n");
+	printf(" [DUMP_DIR] is directory of dump file\n");
+}
+
+static int verify_parameters(int argc,
+			     char *argv[])
+{
+	char *cmd;
+
+	if (argc < 2) {
+		fprintf(stderr, DUMP_LOG_FMT("missing cmd\n"));
+		return -EINVAL;
+	}
+
+	cmd = argv[1];
+	if (!strncmp(cmd, "save_dump", 9)) {
+		if (argc < 3) {
+			fprintf(stderr, DUMP_LOG_FMT("too few parameters\n"));
+			return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	int ret = 0;
+	char *cmd;
+
+	ret = verify_parameters(argc, argv);
+	if (ret) {
+		print_usage();
+		goto error;
+	}
+
+	cmd = argv[1];
+	if (!strncmp(cmd, "save_dump", 9)) {
+		ret = tops_save_dump_data(argv[2]);
+		if (ret) {
+			fprintf(stderr,
+				DUMP_LOG_FMT("cmd %s: save dump data fail(%d)\n"),
+					     cmd, ret);
+			goto error;
+		}
+	} else {
+		fprintf(stderr, DUMP_LOG_FMT("unsupported cmd %s\n"), cmd);
+		goto error;
+	}
+
+error:
+	return ret;
+}