meta-ampere: mtmitchell: Support host consoles logger

This commit supports phosphor-hostlogger in STREAM mode, to forward
the byte stream from obmc-console to rsyslog via the imuxsock module.
The logs can be obtained in /var/log/. The logs are rotated by
logrotate. The size threshold of cpu console is 256KB and the others are
64KB. Each log is polled every 1 minute to check if its file size
exceeds the threshold to rotate it to the new file. Each console can be
saved in up to 2 log files.

Tested (CPU console):

1. Change the mux of CPU console to BMC
    $ ampere_uartmux_ctrl.sh 1 2
2. Connect to CPU SOL console
     $ ssh root@<BMC_IP> -p 2200
3. Execute commands in the CPU SOL console
    => The console output on CPU SOL console will all be logged to
       /var/log/obmc-console-cpu.log
    => The log will be rotated to /var/log/obmc-console-cpu.log.1 if the
        original log file size exceeds 256KB every 1min poll

Signed-off-by: Chau Ly <chaul@amperecomputing.com>
Change-Id: I336bde09c4ef61ea68e05bef2c0b4e4298ea7959
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS0.conf b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS0.conf
new file mode 100644
index 0000000..e0c10a4
--- /dev/null
+++ b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS0.conf
@@ -0,0 +1,3 @@
+# SOCKET-ID is default to obmc-console
+MODE=stream
+STREAM_DST=/run/rsyslog/console/cpu
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS1.conf b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS1.conf
new file mode 100644
index 0000000..c2218e5
--- /dev/null
+++ b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS1.conf
@@ -0,0 +1,3 @@
+SOCKET_ID=ttyS1
+MODE=stream
+STREAM_DST=/run/rsyslog/console/mpro0
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS2.conf b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS2.conf
new file mode 100644
index 0000000..5d3cfb6
--- /dev/null
+++ b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS2.conf
@@ -0,0 +1,3 @@
+SOCKET_ID=ttyS2
+MODE=stream
+STREAM_DST=/run/rsyslog/console/atf
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS3.conf b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS3.conf
new file mode 100644
index 0000000..7c4f5e9
--- /dev/null
+++ b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS3.conf
@@ -0,0 +1,3 @@
+SOCKET_ID=ttyS3
+MODE=stream
+STREAM_DST=/run/rsyslog/console/secpro0
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS7.conf b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS7.conf
new file mode 100644
index 0000000..b811dcf
--- /dev/null
+++ b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS7.conf
@@ -0,0 +1,3 @@
+SOCKET_ID=ttyS7
+MODE=stream
+STREAM_DST=/run/rsyslog/console/mpro1
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS8.conf b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS8.conf
new file mode 100644
index 0000000..dfe25d3
--- /dev/null
+++ b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger/ttyS8.conf
@@ -0,0 +1,3 @@
+SOCKET_ID=ttyS8
+MODE=stream
+STREAM_DST=/run/rsyslog/console/secpro1
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger_%.bbappend b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger_%.bbappend
new file mode 100644
index 0000000..977f7cc
--- /dev/null
+++ b/meta-ampere/meta-mitchell/recipes-phosphor/hostlogger/phosphor-hostlogger_%.bbappend
@@ -0,0 +1,20 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
+SRC_URI:append = " \
+                file://ttyS0.conf \
+                file://ttyS1.conf \
+                file://ttyS2.conf \
+                file://ttyS3.conf \
+                file://ttyS7.conf \
+                file://ttyS8.conf \
+                "
+
+do_install:append() {
+
+          # Install the configurations
+          install -m 0755 -d ${D}${sysconfdir}/${BPN}
+          install -m 0644 ${WORKDIR}/*.conf ${D}${sysconfdir}/${BPN}/
+
+          # Remove upstream-provided default configuration
+          rm -f ${D}${sysconfdir}/${BPN}/ttyVUART0.conf
+}