[][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.c b/package-21.02/kernel/crypto-eip/src/ddk/slad/adapter_init.c
new file mode 100644
index 0000000..ef08853
--- /dev/null
+++ b/package-21.02/kernel/crypto-eip/src/ddk/slad/adapter_init.c
@@ -0,0 +1,413 @@
+/* adapter_init.c
+ *
+ * Adapter module responsible for adapter initialization tasks.
+ *
+ */
+
+/*****************************************************************************
+* Copyright (c) 2011-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
+
+// Runtime Power Management Device Macros API
+#include "rpm_device_macros.h" // RPM_*
+
+// 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;
+
+#ifdef ADAPTER_GLOBAL_BOARDCTRL_SUPPORT_ENABLE
+static Device_Handle_t Adapter_Device_BOARDCTRL;
+#endif
+
+static int Device_IRQ;
+
+/*----------------------------------------------------------------------------
+ * Forward declarations
+ */
+
+static int
+AdapterLib_EIP197_Resume(void * p);
+
+#ifdef ADAPTER_GLOBAL_RPM_EIP197_DEVICE_ID
+static int
+AdapterLib_EIP197_Suspend(void * p);
+#endif // ADAPTER_GLOBAL_RPM_EIP197_DEVICE_ID
+
+#ifdef ADAPTER_PEC_INTERRUPTS_ENABLE
+#ifdef ADAPTER_GLOBAL_RPM_EIP201_DEVICE_ID
+static int
+AdapterLib_EIP201_Resume(void * p);
+#endif
+#endif
+
+
+/*----------------------------------------------------------------------------
+ * AdapterLib_EIP197_Resume
+ *
+ */
+static int
+AdapterLib_EIP197_Resume(void * p)
+{
+ IDENTIFIER_NOT_USED(p);
+
+ // FPGA board specific functionality
+#ifdef ADAPTER_GLOBAL_BOARDCTRL_SUPPORT_ENABLE
+ {
+#ifdef ADAPTER_GLOBAL_FPGA_HW_RESET_ENABLE
+ LOG_INFO("%s: reset FPGA\n", __func__);
+ // Perform HW Reset for the EIP-197 FPGA board
+ Device_Write32(Adapter_Device_BOARDCTRL, 0x2000, 0);
+ Device_Write32(Adapter_Device_BOARDCTRL, 0x2000, 0xFFFFFFFF);
+ Device_Write32(Adapter_Device_BOARDCTRL, 0x2000, 0);
+#endif // ADAPTER_GLOBAL_FPGA_HW_RESET_ENABLE
+ }
+#endif // ADAPTER_GLOBAL_BOARDCTRL_SUPPORT_ENABLE
+
+ return 0; // success
+}
+
+
+#ifdef ADAPTER_GLOBAL_RPM_EIP197_DEVICE_ID
+/*----------------------------------------------------------------------------
+ * AdapterLib_EIP197_Suspend
+ *
+ */
+static int
+AdapterLib_EIP197_Suspend(void * p)
+{
+ IDENTIFIER_NOT_USED(p);
+
+ // FPGA board specific functionality
+#ifdef ADAPTER_GLOBAL_BOARDCTRL_SUPPORT_ENABLE
+ {
+#ifdef ADAPTER_GLOBAL_FPGA_HW_RESET_ENABLE
+ LOG_INFO("%s: reset FPGA\n", __func__);
+ // Perform HW Reset for the EIP-197 FPGA board
+ Device_Write32(Adapter_Device_BOARDCTRL, 0x2000, 0);
+ Device_Write32(Adapter_Device_BOARDCTRL, 0x2000, 0xFFFFFFFF);
+ Device_Write32(Adapter_Device_BOARDCTRL, 0x2000, 0);
+#endif // ADAPTER_GLOBAL_FPGA_HW_RESET_ENABLE
+ }
+#endif // ADAPTER_GLOBAL_BOARDCTRL_SUPPORT_ENABLE
+
+ return 0; // success
+}
+#endif // ADAPTER_GLOBAL_RPM_EIP197_DEVICE_ID
+
+
+#ifdef ADAPTER_PEC_INTERRUPTS_ENABLE
+#ifdef ADAPTER_GLOBAL_RPM_EIP201_DEVICE_ID
+/*----------------------------------------------------------------------------
+ * AdapterLib_EIP201_Resume
+ *
+ */
+static int
+AdapterLib_EIP201_Resume(void * p)
+{
+ IDENTIFIER_NOT_USED(p);
+
+ return Adapter_Interrupts_Resume();
+}
+#endif
+#endif
+
+
+/*----------------------------------------------------------------------------
+ * 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;
+
+#ifdef ADAPTER_GLOBAL_BOARDCTRL_SUPPORT_ENABLE
+ Adapter_Device_BOARDCTRL = Device_Find("BOARD_CTRL");
+ if (Adapter_Device_BOARDCTRL == NULL)
+ {
+ LOG_CRIT("Adapter_Init: Failed to locate BOARD_CTRL\n");
+ Device_UnInitialize();
+ return false;
+ }
+#endif // ADAPTER_GLOBAL_BOARDCTRL_SUPPORT_ENABLE
+
+ if (!DMAResource_Init())
+ {
+ Device_UnInitialize();
+ return false;
+ }
+
+ if (RPM_DEVICE_INIT_START_MACRO(ADAPTER_GLOBAL_RPM_EIP197_DEVICE_ID,
+ AdapterLib_EIP197_Suspend,
+ AdapterLib_EIP197_Resume)
+ != RPM_SUCCESS)
+ {
+ DMAResource_UnInit();
+ Device_UnInitialize();
+ return false;
+ }
+
+ AdapterLib_EIP197_Resume(NULL);
+
+ (void)RPM_DEVICE_INIT_STOP_MACRO(ADAPTER_GLOBAL_RPM_EIP197_DEVICE_ID);
+
+#ifdef ADAPTER_PEC_INTERRUPTS_ENABLE
+ {
+ int res;
+
+ if (RPM_DEVICE_INIT_START_MACRO(ADAPTER_GLOBAL_RPM_EIP201_DEVICE_ID,
+ NULL, // Suspend callback not used
+ AdapterLib_EIP201_Resume)
+ != RPM_SUCCESS)
+ {
+ DMAResource_UnInit();
+ Device_UnInitialize();
+ return false;
+ }
+
+ res = Adapter_Interrupts_Init(Device_IRQ);
+
+ (void)RPM_DEVICE_INIT_STOP_MACRO(ADAPTER_GLOBAL_RPM_EIP201_DEVICE_ID);
+
+ if (res < 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
+ if (RPM_DEVICE_UNINIT_START_MACRO(ADAPTER_GLOBAL_RPM_EIP201_DEVICE_ID,
+ true) == RPM_SUCCESS)
+ {
+ Adapter_Interrupts_UnInit(Device_IRQ);
+ (void)RPM_DEVICE_UNINIT_STOP_MACRO(ADAPTER_GLOBAL_RPM_EIP201_DEVICE_ID);
+ }
+#endif
+
+ (void)RPM_DEVICE_UNINIT_START_MACRO(ADAPTER_GLOBAL_RPM_EIP197_DEVICE_ID, false);
+ (void)RPM_DEVICE_UNINIT_STOP_MACRO(ADAPTER_GLOBAL_RPM_EIP197_DEVICE_ID);
+
+ 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
+
+#ifdef ADAPTER_GLOBAL_BOARDCTRL_SUPPORT_ENABLE
+ REPORT_SET(ADAPTER_GLOBAL_BOARDCTRL_SUPPORT_ENABLE);
+#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);
+ REPORT_STR(RPM_DEVICE_CAPABILITIES_STR_MACRO);
+}
+
+
+/* end of file adapter_init.c */