[][openwrt][mt7988][crypto][EIP197 DDK Porting]

[Description]
Add eip197 DDK(Driver Development Kit) and firmware
to eip197 package(crypto-eip)

eip197 DDK v5.6.1
eip197b-iew firmware v3.5

[Release-log]
N/A

Change-Id: I662327ecfbdac69742bf0b50362d7c28fc06372b
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7895272
diff --git a/package-21.02/kernel/crypto-eip/src/ddk/slad/adapter_init_pec.c b/package-21.02/kernel/crypto-eip/src/ddk/slad/adapter_init_pec.c
new file mode 100644
index 0000000..4bcb88e
--- /dev/null
+++ b/package-21.02/kernel/crypto-eip/src/ddk/slad/adapter_init_pec.c
@@ -0,0 +1,265 @@
+/* adapter_init_pec.c
+ *
+ * Adapter module responsible for Adapter PEC initialization tasks.
+ *
+ */
+
+/*****************************************************************************
+* Copyright (c) 2012-2022 by Rambus, Inc. and/or its subsidiaries.
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 2 of the License, or
+* any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*****************************************************************************/
+
+/*----------------------------------------------------------------------------
+ * This module implements (provides) the following interface(s):
+ */
+
+#include "adapter_init.h"
+
+
+/*----------------------------------------------------------------------------
+ * This module uses (requires) the following interface(s):
+ */
+
+// Top-level Adapter configuration
+#include "cs_adapter.h"
+
+#ifdef ADAPTER_PEC_INTERRUPTS_ENABLE
+#include "adapter_interrupts.h" // Adapter_Interrupts_Init,
+                                // Adapter_Interrupts_UnInit
+#endif
+
+// Logging API
+#include "log.h"            // LOG_*
+
+// Driver Framework Device API
+#include "device_mgmt.h"    // Device_Initialize, Device_UnInitialize
+#include "device_rw.h"      // Device_Read32, Device_Write32
+
+// Driver Framework DMAResource API
+#include "dmares_mgmt.h"    // DMAResource_Init, DMAResource_UnInit
+
+// Driver Framework C Library API
+#include "clib.h"           // memcpy, ZEROINIT
+
+// Driver Framework Basic Definitions API
+#include "basic_defs.h"     // bool, true, false
+
+
+/*----------------------------------------------------------------------------
+ * Local variables
+ */
+
+static bool Adapter_IsInitialized = false;
+static int Device_IRQ;
+
+
+/*----------------------------------------------------------------------------
+ * Forward declarations
+ */
+
+
+/*----------------------------------------------------------------------------
+ * Adapter_Init
+ *
+ * Return Value
+ *     true   Success
+ *     false  Failure (fatal!)
+ */
+bool
+Adapter_Init(void)
+{
+    Device_IRQ = -1;
+
+    if (Adapter_IsInitialized != false)
+    {
+        LOG_WARN("Adapter_Init: Already initialized\n");
+        return true;
+    }
+
+    // trigger first-time initialization of the adapter
+    if (Device_Initialize(&Device_IRQ) < 0)
+        return false;
+
+    if (!DMAResource_Init())
+    {
+        Device_UnInitialize();
+        return false;
+    }
+
+#ifdef ADAPTER_PEC_INTERRUPTS_ENABLE
+    if (Adapter_Interrupts_Init(Device_IRQ) < 0)
+    {
+        LOG_CRIT("Adapter_Init: Adapter_Interrupts_Init failed\n");
+        DMAResource_UnInit();
+        Device_UnInitialize();
+        return false;
+    }
+#endif
+
+    Adapter_IsInitialized = true;
+
+    return true;    // success
+}
+
+
+/*----------------------------------------------------------------------------
+ * Adapter_UnInit
+ */
+void
+Adapter_UnInit(void)
+{
+    if (!Adapter_IsInitialized)
+    {
+        LOG_WARN("Adapter_UnInit: Adapter is not initialized\n");
+        return;
+    }
+
+    Adapter_IsInitialized = false;
+
+    DMAResource_UnInit();
+
+#ifdef ADAPTER_PEC_INTERRUPTS_ENABLE
+    Adapter_Interrupts_UnInit(Device_IRQ);
+#endif
+
+    Device_UnInitialize();
+}
+
+
+/*----------------------------------------------------------------------------
+ * Adapter_Report_Build_Params
+ */
+void
+Adapter_Report_Build_Params(void)
+{
+    // This function is dependent on config file cs_adapter.h.
+    // Please update this when Config file for Adapter is changed.
+    Log_FormattedMessage("Adapter build configuration of %s:\n",
+        ADAPTER_VERSION_STRING);
+
+#define REPORT_SET(_X) \
+    Log_FormattedMessage("\t" #_X "\n")
+
+#define REPORT_STR(_X) \
+    Log_FormattedMessage("\t" #_X ": %s\n", _X)
+
+#define REPORT_INT(_X) \
+    Log_FormattedMessage("\t" #_X ": %d\n", _X)
+
+#define REPORT_HEX32(_X) \
+    Log_FormattedMessage("\t" #_X ": 0x%08X\n", _X)
+
+#define REPORT_EQ(_X, _Y) \
+    Log_FormattedMessage("\t" #_X " == " #_Y "\n")
+
+#define REPORT_EXPL(_X, _Y) \
+    Log_FormattedMessage("\t" #_X _Y "\n")
+
+    // Adapter PEC
+#ifdef ADAPTER_PEC_DBG
+    REPORT_SET(ADAPTER_PEC_DBG);
+#endif
+
+#ifdef ADAPTER_PEC_STRICT_ARGS
+    REPORT_SET(ADAPTER_PEC_STRICT_ARGS);
+#endif
+
+#ifdef ADAPTER_PEC_ENABLE_SCATTERGATHER
+    REPORT_SET(ADAPTER_PEC_ENABLE_SCATTERGATHER);
+#endif
+
+#ifdef ADAPTER_PEC_SEPARATE_RINGS
+    REPORT_SET(ADAPTER_PEC_SEPARATE_RINGS);
+#else
+    REPORT_EXPL(ADAPTER_PEC_SEPARATE_RINGS, " is NOT set => Overlapping");
+#endif
+
+#ifdef ADAPTER_PEC_ARMRING_ENABLE_SWAP
+    REPORT_SET(ADAPTER_PEC_ARMRING_ENABLE_SWAP);
+#endif
+
+    REPORT_INT(ADAPTER_PEC_DEVICE_COUNT);
+    REPORT_INT(ADAPTER_PEC_MAX_PACKETS);
+    REPORT_INT(ADAPTER_MAX_PECLOGICDESCR);
+    REPORT_INT(ADAPTER_PEC_MAX_SAS);
+    REPORT_INT(ADAPTER_DESCRIPTORDONETIMEOUT);
+    REPORT_INT(ADAPTER_DESCRIPTORDONECOUNT);
+
+#ifdef ADAPTER_REMOVE_BOUNCEBUFFERS
+    REPORT_EXPL(ADAPTER_REMOVE_BOUNCEBUFFERS, " is SET => Bounce DISABLED");
+#else
+    REPORT_EXPL(ADAPTER_REMOVE_BOUNCEBUFFERS, " is NOT set => Bounce ENABLED");
+#endif
+
+#ifdef ADAPTER_EIP202_INTERRUPTS_ENABLE
+    REPORT_EXPL(ADAPTER_EIP202_INTERRUPTS_ENABLE,
+            " is SET => Interrupts ENABLED");
+#else
+    REPORT_EXPL(ADAPTER_EIP202_INTERRUPTS_ENABLE,
+            " is NOT set => Interrupts DISABLED");
+#endif
+
+#ifdef ADAPTER_PCL_ENABLE
+    REPORT_SET(ADAPTER_PCL_ENABLE);
+    REPORT_INT(ADAPTER_PCL_FLOW_HASH_ENTRIES_COUNT);
+#endif
+
+#ifdef ADAPTER_64BIT_HOST
+    REPORT_EXPL(ADAPTER_64BIT_HOST,
+                " is SET => addresses are 64-bit");
+#else
+    REPORT_EXPL(ADAPTER_64BIT_HOST,
+                " is NOT set => addresses are 32-bit");
+#endif
+
+#ifdef ADAPTER_64BIT_DEVICE
+    REPORT_EXPL(ADAPTER_64BIT_DEVICE,
+                " is SET => full 64-bit DMA addresses usable");
+#else
+    REPORT_EXPL(ADAPTER_64BIT_DEVICE,
+                " is NOT set => DMA addresses must be below 4GB");
+#endif
+
+#ifdef ADAPTER_DMARESOURCE_BANKS_ENABLE
+    REPORT_SET(ADAPTER_DMARESOURCE_BANKS_ENABLE);
+#endif
+
+    // Adapter Global Classification Control
+#ifdef ADAPTER_CS_TIMER_PRESCALER
+    REPORT_INT(ADAPTER_CS_TIMER_PRESCALER);
+#endif
+
+    // Log
+    Log_FormattedMessage("Logging:\n");
+
+#if (LOG_SEVERITY_MAX == LOG_SEVERITY_INFO)
+    REPORT_EQ(LOG_SEVERITY_MAX, LOG_SEVERITY_INFO);
+#elif (LOG_SEVERITY_MAX == LOG_SEVERITY_WARNING)
+    REPORT_EQ(LOG_SEVERITY_MAX, LOG_SEVERITY_W_A_R_N_I_N_G);
+#elif (LOG_SEVERITY_MAX == LOG_SEVERITY_CRITICAL)
+    REPORT_EQ(LOG_SEVERITY_MAX, LOG_SEVERITY_CRITICAL);
+#else
+    REPORT_EXPL(LOG_SEVERITY_MAX, " - Unknown (not info/warn/crit)");
+#endif
+
+    // Adapter other
+    Log_FormattedMessage("Other:\n");
+    REPORT_STR(ADAPTER_DRIVER_NAME);
+    REPORT_STR(ADAPTER_LICENSE);
+    REPORT_HEX32(ADAPTER_INTERRUPTS_TRACEFILTER);
+}
+
+
+/* end of file adapter_init_pec.c */