/* ****************************************************************************** * SOURCE FILE * * Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: Sec4Driver.h,v $ $Revision: 1.7.12.1 $ * $Source: /home/interpeak/CVSRoot/ipfreescale/sec4/Sec4Driver.h,v $ * $Author: jsheng $ * $State: Exp $ $Locker: $ * * INTERPEAK_COPYRIGHT_STRING ****************************************************************************** */ /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** */ /**************************************************************************** * Sec4Driver.h - Private/local include file for SEC4 security driver * Based on Sec2Driver.h for SEC2 security driver **************************************************************************** * Copyright (c) 2003, 2004 Freescale Semiconductor * All Rights Reserved. Proprietary and Confidential. * * NOTICE: The information contained in this file is proprietary * to Freescale Semiconductor, and is being made available to * Freescale's customers under strict license agreements. * Use or disclosure of this information is permissible only * under the terms of the existing license agreement. ***************************************************************************/ /* Revision History: * 1.0 Mar 11,2011 Based on Sec2Driver.h v1.2 * 1.1 Added IPSec using shared descriptors and queue interface */ #ifndef SEC4DRIVER_H #define SEC4DRIVER_H /* assume VXWORKS */ #include "iosLib.h" #include "msgQLib.h" #include "semLib.h" #include "signal.h" #ifdef _WRS_CONFIG_WRHV_GUEST #include #endif /* _WRS_CONFIG_WRHV_GUEST */ #define IVEC_TO_INUM(intVec) ((int) (intVec)) #define INUM_TO_IVEC(intNum) ((VOIDFUNCPTR *) (intNum)) #define __vpa(pa) (pa) #include "Sec4.h" #define VERSION "1.1" #define SEC4_DEVNAME "sec4" /* Name for Processing Complete task */ #define SEC4_PC_TASKNAME "tSEC4_pc" /* Interrupt for Job queues of the SEC4 */ #ifdef _WRS_CONFIG_BSP_FSL_P1010_RDB #define INUM_SEC4_BASE (12 + 29) /* Job queue 0 in SEC4 core is wired to #29 within the P1010 */ #elif defined(_WRS_CONFIG_BSP_FSL_P4080_DS) || defined(_WRS_CONFIG_BSP_WRSBCP4080) #define INUM_SEC4_BASE (16 + 72) /* Job queue 0 in SEC4 core is wired to #72 within the P4080 */ #define INUM_SEC4_JQ0 (INUM_SEC4_BASE) #define INUM_SEC4_JQ1 (INUM_SEC4_BASE + 1) #define INUM_SEC4_JQ2 (INUM_SEC4_BASE + 2) #define INUM_SEC4_JQ3 (INUM_SEC4_BASE + 3) #endif #ifdef _WRS_CONFIG_WRHV_GUEST /* When we are on top of a hypervisor, this can't be extracted by sysGetPeripheralBase() */ /* This address should correspond to the CCSBAR */ #define PERIPHERAL_BASE (0xFE000000ULL) #endif /* Define an offset from the peripheral base register where the core */ /* should be located relative to */ #ifdef _WRS_CONFIG_BSP_FSL_P1010_RDB #define SEC4X_BASE_OFFSET (0x00030000) #elif defined(_WRS_CONFIG_BSP_FSL_P4080_DS) || defined(_WRS_CONFIG_BSP_WRSBCP4080) #define SEC4X_BASE_OFFSET (0x00300000) #endif /* Offset relative to SEC4X_BASE_OFFSET for job queues */ #define SEC4X_JQ_BASE_SIZE (0x1000) #define SEC4X_JQ0_BASE_OFFSET (0x1000) #define SEC4X_JQ1_BASE_OFFSET (SEC4X_JQ0_BASE_OFFSET + (1 * SEC4X_JQ_BASE_SIZE)) #define SEC4X_JQ2_BASE_OFFSET (SEC4X_JQ0_BASE_OFFSET + (2 * SEC4X_JQ_BASE_SIZE)) #define SEC4X_JQ3_BASE_OFFSET (SEC4X_JQ0_BASE_OFFSET + (3 * SEC4X_JQ_BASE_SIZE)) #define SEC4X_NOOF_JOB_QUEUES (4) /* Offset relative to SEC4X_BASE_OFFSET for queue interface */ #define SEC4X_QI_BASE_OFFSET (0x00007000) /* SEC 4 Job Queue ID */ #define SEC4X_JQ0_ID (0) #define SEC4X_JQ1_ID (1) #define SEC4X_JQ2_ID (2) #define SEC4X_JQ3_ID (3) /* Maximum number of cores using SEC4 */ #define SEC4_MAXNOOF_CORES (7) /* Spin lock IDs to protect shared between cores objects */ #ifdef SEC4_USE_QI #define SEC4_SA_CACHE_SPINLOCK_ID (3) #endif #ifdef SEC4_USE_SHARED_JOB_QUEUE #define SEC4_SH_JQ_SPINLOCK_ID (4) #endif /* Default IPsec SA cache size (may be altered during run-time) */ #define SEC4_IPSEC_NOOF_SA_CACHE_ENTRIES_DEFAULT (256) /* * Debug message type enabler switches for SEC4DebugLevel: * DBGTXT_SETRQ - all messages from request setups * DBGTXT_SVCRQ - all messages from request servicing * DBGTXT_INITDEV - all messages from initialization * DBGTXT_DESCSHOW - content of each DPD before it's queued * DBGTXT_INFO - general driver information messages */ #ifdef DEBUG #define DBGTXT_SETRQ ((unsigned long)0x00000001) #define DBGTXT_SVCRQ ((unsigned long)0x00000002) #define DBGTXT_INITDEV ((unsigned long)0x00000004) #define DBGTXT_DESCSHOW ((unsigned long)0x00000008) #define DBGTXT_INFO ((unsigned long)0x00000010) #define DBGTXT_INTERPEAK ((unsigned long)0x00000020) #define DBGTXT_ERROR ((unsigned long)0x00000040) extern unsigned long SEC4DebugLevel; #define SEC4Dump(LEVEL,STRING) \ do { \ unsigned long _level = (LEVEL); \ if ((_level == 0)||(SEC4DebugLevel & _level)) { \ printf STRING; \ } \ } while (0) #define SEC4DbgDo(LEVEL,FUNCTION) \ do { \ unsigned long _level = (LEVEL); \ if ((_level == 0)||(SEC4DebugLevel & _level)) { \ FUNCTION; \ } \ } while (0) #else #define SEC4Dump(LEVEL,STRING) #define SEC4DbgDo(LEVEL,FUNCTION) #endif #define IOLockJobEnqueue() (void) semTake(JobEnqueueSemId, WAIT_FOREVER) #define IOUnLockJobEnqueue() (void) semGive(JobEnqueueSemId) #define IO_STATUS int /*! \def PROCESSING_COMPLETE_PRIORITY \brief #ProcessingComplete() Task priority */ #define PROCESSING_COMPLETE_PRIORITY (3) /*! \def PROCESSING_COMPLETE_STACKSIZE \brief #ProcessingComplete() Task stack size */ /* #define PROCESSING_COMPLETE_STACKSIZE (2048) */ #define PROCESSING_COMPLETE_STACKSIZE (4096) #ifdef SEC4_POLLED_MODE /*! \def POLL_COMPLETE_PRIORITY \brief #PollComplete() Task priority */ #define POLL_COMPLETE_PRIORITY (3) /*! \def POLL_COMPLETE_STACKSIZE \brief #PollComplete() Task stack size */ #define POLL_COMPLETE_STACKSIZE (4096) #endif /* SEC4 core values as presented in version register (SECVID) */ #define SEC4_COREID (0x00000a10) typedef struct completed_job{ int jobStatus; GENERIC_REQ *req; } COMPLETED_JOB; /* SEC4_GLOBAL A definition used to control allocation and referencing of global variables. When the definition is not set it is considered to be used as a reference (extern is prepended). When the definition is set (to nothing) it is considered to be allocating the global variable. This is done in one place only. In init.c */ #ifndef SEC4_GLOBAL #define SEC4_GLOBAL extern #endif /*! \var SEM_ID JobEnqueueSemId \brief A global variable which is used as a mutual exclusion semaphore for enqueueing jobs to the SEC4 engine. The variable is not used directly. It used by calling #IOLockJobEnqueue() to lock and #IOUnLockJobEnqueue() to unlock. */ SEC4_GLOBAL SEM_ID JobEnqueueSemId; /* The queue identifier is used to queue register values read by the ISR (#InterruptServiceRoutine()) to the deferred interrupt process routine (#ProcessingComplete()) */ SEC4_GLOBAL MSG_Q_ID IsrMsgQId; /* OS's identification of the device*/ SEC4_GLOBAL int driverNum; /*! \var DEV_HDR vxworksDrvDev \brief Used in driver startup. */ SEC4_GLOBAL DEV_HDR vxworksDrvDev; /* coremask holds the core ID register for version/feature control */ SEC4_GLOBAL unsigned long coremask; /* Register driver and it's handlers with the OS */ IO_STATUS IORegisterDriver(void); /* Set up internal driver semaphores */ void IOInitSemaphores(void); /* Initialize driver queues */ IO_STATUS IOInitQs(uint16_t size); /* Enable/Disable the hardware interrupt */ IO_STATUS IOConnectInterrupt(void); void IODisconnectInterrupt(void); /* Open a new connection to this driver */ int SEC4Open(DEV_HDR *, int, int); /* Close a connection to this driver */ int SEC4Close(int); /* Request a driver operation*/ int SEC4_ioctl(int, register int, register void *); /* Driver's top level ISR handler */ void InterruptServiceRoutine(t_Handle h_App, void* p_JobDesc, t_Handle h_Context, uint32_t jobStatus); /* ISR's Deferred processing (bottom half) handler */ extern void ProcessingComplete(void); #ifdef SEC4_POLLED_MODE extern void PollComplete(void); #endif /* Take a user request, build a job descriptor, and submit it for processing */ int ProcessRequest(GENERIC_REQ *req, int callingTaskId); /* Get current values of SEC4 status registers. */ int GetStatus(STATUS_REQ *pStatus, int callingTaskId); #ifdef SEC4_USE_QI int SEC4_ipsec_esp_encrypt(uint16_t sa_index, uint8_t *buf, uint16_t inOffset, uint16_t pktlen, uint16_t outOffset, uint8_t poolId); int SEC4_ipsec_esp_decrypt(uint16_t sa_index, uint8_t *buf, uint16_t inOffset, uint16_t pktlen, uint16_t outOffset, uint8_t poolId); void SEC4_qportal_set(void *qportal); void SEC4_bportal_set(void *bportal, uint32_t poolId); void SEC4_qman_enqueue_fqix_base_set(uint32_t ixBase); void SEC4_qman_dequeue_fqix_set(uint32_t ixBaseEncrypt, uint32_t ixBaseDecrypt); int SEC4_populate_sa(uint32_t spi, uint8_t ipsecVer, uint8_t proto, e_IpsecAuthenAlg authAlg, e_IpsecCryptoAlg cryptoAlg, uint8_t *authKey, uint8_t authKeySize, uint8_t *cryptoKey, uint8_t cryptoKeySize, uint8_t *iv, uint16_t sa_index, int enc); void SEC4_ipsec_set_sa_cache_size(uint32_t noofEntries); void SEC4_ipsec_set_shm(void *p, uint32_t size); #endif /* SEC4_USE_QI */ #endif /* SEC4DRIVER_H */