18817e1bfSRafal Jaworowski /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 48817e1bfSRafal Jaworowski * Copyright (C) 2009-2011 Semihalf. 58817e1bfSRafal Jaworowski * All rights reserved. 68817e1bfSRafal Jaworowski * 78817e1bfSRafal Jaworowski * Redistribution and use in source and binary forms, with or without 88817e1bfSRafal Jaworowski * modification, are permitted provided that the following conditions 98817e1bfSRafal Jaworowski * are met: 108817e1bfSRafal Jaworowski * 1. Redistributions of source code must retain the above copyright 118817e1bfSRafal Jaworowski * notice, this list of conditions and the following disclaimer. 128817e1bfSRafal Jaworowski * 2. Redistributions in binary form must reproduce the above copyright 138817e1bfSRafal Jaworowski * notice, this list of conditions and the following disclaimer in the 148817e1bfSRafal Jaworowski * documentation and/or other materials provided with the distribution. 158817e1bfSRafal Jaworowski * 168817e1bfSRafal Jaworowski * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 178817e1bfSRafal Jaworowski * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 188817e1bfSRafal Jaworowski * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 198817e1bfSRafal Jaworowski * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 208817e1bfSRafal Jaworowski * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 218817e1bfSRafal Jaworowski * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 228817e1bfSRafal Jaworowski * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 238817e1bfSRafal Jaworowski * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 248817e1bfSRafal Jaworowski * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 258817e1bfSRafal Jaworowski * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 268817e1bfSRafal Jaworowski * SUCH DAMAGE. 278817e1bfSRafal Jaworowski */ 288817e1bfSRafal Jaworowski 298817e1bfSRafal Jaworowski #ifndef _DEV_CESA_H_ 308817e1bfSRafal Jaworowski #define _DEV_CESA_H_ 318817e1bfSRafal Jaworowski 328817e1bfSRafal Jaworowski /* Maximum number of queued requests */ 338817e1bfSRafal Jaworowski #define CESA_REQUESTS 256 348817e1bfSRafal Jaworowski 358817e1bfSRafal Jaworowski /* 368817e1bfSRafal Jaworowski * CESA is able to process data only in CESA SRAM, which is quite small (2 kB). 378817e1bfSRafal Jaworowski * We have to fit a packet there, which contains SA descriptor, keys, IV 388817e1bfSRafal Jaworowski * and data to be processed. Every request must be converted into chain of 398817e1bfSRafal Jaworowski * packets and each packet can hold about 1.75 kB of data. 408817e1bfSRafal Jaworowski * 418817e1bfSRafal Jaworowski * To process each packet we need at least 1 SA descriptor and at least 4 TDMA 428817e1bfSRafal Jaworowski * descriptors. However there are cases when we use 2 SA and 8 TDMA descriptors 438817e1bfSRafal Jaworowski * per packet. Number of used TDMA descriptors can increase beyond given values 448817e1bfSRafal Jaworowski * if data in the request is fragmented in physical memory. 458817e1bfSRafal Jaworowski * 468817e1bfSRafal Jaworowski * The driver uses preallocated SA and TDMA descriptors pools to get best 478817e1bfSRafal Jaworowski * performace. Size of these pools should match expected request size. Example: 488817e1bfSRafal Jaworowski * 498817e1bfSRafal Jaworowski * Expected average request size: 1.5 kB (Ethernet MTU) 508817e1bfSRafal Jaworowski * Packets per average request: (1.5 kB / 1.75 kB) = 1 518817e1bfSRafal Jaworowski * SA decriptors per average request (worst case): 1 * 2 = 2 528817e1bfSRafal Jaworowski * TDMA desctiptors per average request (worst case): 1 * 8 = 8 538817e1bfSRafal Jaworowski * 548817e1bfSRafal Jaworowski * More TDMA descriptors should be allocated, if data fragmentation is expected 558817e1bfSRafal Jaworowski * (for example while processing mbufs larger than MCLBYTES). The driver may use 568817e1bfSRafal Jaworowski * 2 additional TDMA descriptors per each discontinuity in the physical data 578817e1bfSRafal Jaworowski * layout. 588817e1bfSRafal Jaworowski */ 598817e1bfSRafal Jaworowski 608817e1bfSRafal Jaworowski /* Values below are optimized for requests containing about 1.5 kB of data */ 618817e1bfSRafal Jaworowski #define CESA_SA_DESC_PER_REQ 2 628817e1bfSRafal Jaworowski #define CESA_TDMA_DESC_PER_REQ 8 638817e1bfSRafal Jaworowski 648817e1bfSRafal Jaworowski #define CESA_SA_DESCRIPTORS (CESA_SA_DESC_PER_REQ * CESA_REQUESTS) 658817e1bfSRafal Jaworowski #define CESA_TDMA_DESCRIPTORS (CESA_TDMA_DESC_PER_REQ * CESA_REQUESTS) 668817e1bfSRafal Jaworowski 678817e1bfSRafal Jaworowski /* Useful constants */ 681e964f8aSZbigniew Bodek #define CESA_HMAC_TRUNC_LEN 12 698817e1bfSRafal Jaworowski #define CESA_MAX_FRAGMENTS 64 708817e1bfSRafal Jaworowski #define CESA_SRAM_SIZE 2048 718817e1bfSRafal Jaworowski 728817e1bfSRafal Jaworowski /* 738817e1bfSRafal Jaworowski * CESA_MAX_HASH_LEN is maximum length of hash generated by CESA. 74b07df6e5SZbigniew Bodek * As CESA supports MD5, SHA1 and SHA-256 this equals to 32 bytes. 758817e1bfSRafal Jaworowski */ 76b07df6e5SZbigniew Bodek #define CESA_MAX_HASH_LEN 32 778817e1bfSRafal Jaworowski #define CESA_MAX_KEY_LEN 32 788817e1bfSRafal Jaworowski #define CESA_MAX_IV_LEN 16 798817e1bfSRafal Jaworowski #define CESA_MAX_HMAC_BLOCK_LEN 64 808817e1bfSRafal Jaworowski #define CESA_MAX_MKEY_LEN CESA_MAX_HMAC_BLOCK_LEN 818817e1bfSRafal Jaworowski #define CESA_MAX_PACKET_SIZE (CESA_SRAM_SIZE - CESA_DATA(0)) 828817e1bfSRafal Jaworowski #define CESA_MAX_REQUEST_SIZE 65535 838817e1bfSRafal Jaworowski 848817e1bfSRafal Jaworowski /* Locking macros */ 858817e1bfSRafal Jaworowski #define CESA_LOCK(sc, what) mtx_lock(&(sc)->sc_ ## what ## _lock) 868817e1bfSRafal Jaworowski #define CESA_UNLOCK(sc, what) mtx_unlock(&(sc)->sc_ ## what ## _lock) 878817e1bfSRafal Jaworowski #define CESA_LOCK_ASSERT(sc, what) \ 888817e1bfSRafal Jaworowski mtx_assert(&(sc)->sc_ ## what ## _lock, MA_OWNED) 898817e1bfSRafal Jaworowski 908817e1bfSRafal Jaworowski /* Registers read/write macros */ 9122c7a031SZbigniew Bodek #define CESA_REG_READ(sc, reg) \ 9222c7a031SZbigniew Bodek bus_read_4((sc)->sc_res[RES_CESA_REGS], (reg)) 9322c7a031SZbigniew Bodek #define CESA_REG_WRITE(sc, reg, val) \ 9422c7a031SZbigniew Bodek bus_write_4((sc)->sc_res[RES_CESA_REGS], (reg), (val)) 9522c7a031SZbigniew Bodek 9622c7a031SZbigniew Bodek #define CESA_TDMA_READ(sc, reg) \ 9722c7a031SZbigniew Bodek bus_read_4((sc)->sc_res[RES_TDMA_REGS], (reg)) 9822c7a031SZbigniew Bodek #define CESA_TDMA_WRITE(sc, reg, val) \ 9922c7a031SZbigniew Bodek bus_write_4((sc)->sc_res[RES_TDMA_REGS], (reg), (val)) 1008817e1bfSRafal Jaworowski 1018817e1bfSRafal Jaworowski /* Generic allocator for objects */ 1028817e1bfSRafal Jaworowski #define CESA_GENERIC_ALLOC_LOCKED(sc, obj, pool) do { \ 1038817e1bfSRafal Jaworowski CESA_LOCK(sc, pool); \ 1048817e1bfSRafal Jaworowski \ 1058817e1bfSRafal Jaworowski if (STAILQ_EMPTY(&(sc)->sc_free_ ## pool)) \ 1068817e1bfSRafal Jaworowski obj = NULL; \ 1078817e1bfSRafal Jaworowski else { \ 1088817e1bfSRafal Jaworowski obj = STAILQ_FIRST(&(sc)->sc_free_ ## pool); \ 1098817e1bfSRafal Jaworowski STAILQ_REMOVE_HEAD(&(sc)->sc_free_ ## pool, \ 1108817e1bfSRafal Jaworowski obj ## _stq); \ 1118817e1bfSRafal Jaworowski } \ 1128817e1bfSRafal Jaworowski \ 1138817e1bfSRafal Jaworowski CESA_UNLOCK(sc, pool); \ 1148817e1bfSRafal Jaworowski } while (0) 1158817e1bfSRafal Jaworowski 1168817e1bfSRafal Jaworowski #define CESA_GENERIC_FREE_LOCKED(sc, obj, pool) do { \ 1178817e1bfSRafal Jaworowski CESA_LOCK(sc, pool); \ 1188817e1bfSRafal Jaworowski STAILQ_INSERT_TAIL(&(sc)->sc_free_ ## pool, obj, \ 1198817e1bfSRafal Jaworowski obj ## _stq); \ 1208817e1bfSRafal Jaworowski CESA_UNLOCK(sc, pool); \ 1218817e1bfSRafal Jaworowski } while (0) 1228817e1bfSRafal Jaworowski 1238817e1bfSRafal Jaworowski /* CESA SRAM offset calculation macros */ 1248817e1bfSRafal Jaworowski #define CESA_SA_DATA(member) \ 1258817e1bfSRafal Jaworowski (sizeof(struct cesa_sa_hdesc) + offsetof(struct cesa_sa_data, member)) 1268817e1bfSRafal Jaworowski #define CESA_DATA(offset) \ 1278817e1bfSRafal Jaworowski (sizeof(struct cesa_sa_hdesc) + sizeof(struct cesa_sa_data) + offset) 1288817e1bfSRafal Jaworowski 12922c7a031SZbigniew Bodek /* CESA memory and IRQ resources */ 13022c7a031SZbigniew Bodek enum cesa_res_type { 13122c7a031SZbigniew Bodek RES_TDMA_REGS, 13222c7a031SZbigniew Bodek RES_CESA_REGS, 13322c7a031SZbigniew Bodek RES_CESA_IRQ, 13422c7a031SZbigniew Bodek RES_CESA_NUM 13522c7a031SZbigniew Bodek }; 13622c7a031SZbigniew Bodek 1378817e1bfSRafal Jaworowski struct cesa_tdma_hdesc { 1388817e1bfSRafal Jaworowski uint16_t cthd_byte_count; 1398817e1bfSRafal Jaworowski uint16_t cthd_flags; 1408817e1bfSRafal Jaworowski uint32_t cthd_src; 1418817e1bfSRafal Jaworowski uint32_t cthd_dst; 1428817e1bfSRafal Jaworowski uint32_t cthd_next; 1438817e1bfSRafal Jaworowski }; 1448817e1bfSRafal Jaworowski 1458817e1bfSRafal Jaworowski struct cesa_sa_hdesc { 1468817e1bfSRafal Jaworowski uint32_t cshd_config; 1478817e1bfSRafal Jaworowski uint16_t cshd_enc_src; 1488817e1bfSRafal Jaworowski uint16_t cshd_enc_dst; 1498817e1bfSRafal Jaworowski uint32_t cshd_enc_dlen; 1508817e1bfSRafal Jaworowski uint32_t cshd_enc_key; 1518817e1bfSRafal Jaworowski uint16_t cshd_enc_iv; 1528817e1bfSRafal Jaworowski uint16_t cshd_enc_iv_buf; 1538817e1bfSRafal Jaworowski uint16_t cshd_mac_src; 1548817e1bfSRafal Jaworowski uint16_t cshd_mac_total_dlen; 1558817e1bfSRafal Jaworowski uint16_t cshd_mac_dst; 1568817e1bfSRafal Jaworowski uint16_t cshd_mac_dlen; 1578817e1bfSRafal Jaworowski uint16_t cshd_mac_iv_in; 1588817e1bfSRafal Jaworowski uint16_t cshd_mac_iv_out; 1598817e1bfSRafal Jaworowski }; 1608817e1bfSRafal Jaworowski 1618817e1bfSRafal Jaworowski struct cesa_sa_data { 1628817e1bfSRafal Jaworowski uint8_t csd_key[CESA_MAX_KEY_LEN]; 1638817e1bfSRafal Jaworowski uint8_t csd_iv[CESA_MAX_IV_LEN]; 1648817e1bfSRafal Jaworowski uint8_t csd_hiv_in[CESA_MAX_HASH_LEN]; 1658817e1bfSRafal Jaworowski uint8_t csd_hiv_out[CESA_MAX_HASH_LEN]; 1668817e1bfSRafal Jaworowski uint8_t csd_hash[CESA_MAX_HASH_LEN]; 1678817e1bfSRafal Jaworowski }; 1688817e1bfSRafal Jaworowski 1698817e1bfSRafal Jaworowski struct cesa_dma_mem { 1708817e1bfSRafal Jaworowski void *cdm_vaddr; 1718817e1bfSRafal Jaworowski bus_addr_t cdm_paddr; 1728817e1bfSRafal Jaworowski bus_dma_tag_t cdm_tag; 1738817e1bfSRafal Jaworowski bus_dmamap_t cdm_map; 1748817e1bfSRafal Jaworowski }; 1758817e1bfSRafal Jaworowski 1768817e1bfSRafal Jaworowski struct cesa_tdma_desc { 1778817e1bfSRafal Jaworowski struct cesa_tdma_hdesc *ctd_cthd; 1788817e1bfSRafal Jaworowski bus_addr_t ctd_cthd_paddr; 1798817e1bfSRafal Jaworowski 1808817e1bfSRafal Jaworowski STAILQ_ENTRY(cesa_tdma_desc) ctd_stq; 1818817e1bfSRafal Jaworowski }; 1828817e1bfSRafal Jaworowski 1838817e1bfSRafal Jaworowski struct cesa_sa_desc { 1848817e1bfSRafal Jaworowski struct cesa_sa_hdesc *csd_cshd; 1858817e1bfSRafal Jaworowski bus_addr_t csd_cshd_paddr; 1868817e1bfSRafal Jaworowski 1878817e1bfSRafal Jaworowski STAILQ_ENTRY(cesa_sa_desc) csd_stq; 1888817e1bfSRafal Jaworowski }; 1898817e1bfSRafal Jaworowski 1908817e1bfSRafal Jaworowski struct cesa_session { 1918817e1bfSRafal Jaworowski uint32_t cs_config; 1928817e1bfSRafal Jaworowski unsigned int cs_ivlen; 1938817e1bfSRafal Jaworowski unsigned int cs_hlen; 1948817e1bfSRafal Jaworowski unsigned int cs_mblen; 1958817e1bfSRafal Jaworowski uint8_t cs_key[CESA_MAX_KEY_LEN]; 1968817e1bfSRafal Jaworowski uint8_t cs_aes_dkey[CESA_MAX_KEY_LEN]; 1978817e1bfSRafal Jaworowski uint8_t cs_hiv_in[CESA_MAX_HASH_LEN]; 1988817e1bfSRafal Jaworowski uint8_t cs_hiv_out[CESA_MAX_HASH_LEN]; 1998817e1bfSRafal Jaworowski }; 2008817e1bfSRafal Jaworowski 2018817e1bfSRafal Jaworowski struct cesa_request { 2028817e1bfSRafal Jaworowski struct cesa_sa_data *cr_csd; 2038817e1bfSRafal Jaworowski bus_addr_t cr_csd_paddr; 2048817e1bfSRafal Jaworowski struct cryptop *cr_crp; 2058817e1bfSRafal Jaworowski struct cesa_session *cr_cs; 2068817e1bfSRafal Jaworowski bus_dmamap_t cr_dmap; 2078817e1bfSRafal Jaworowski int cr_dmap_loaded; 2088817e1bfSRafal Jaworowski 2098817e1bfSRafal Jaworowski STAILQ_HEAD(, cesa_tdma_desc) cr_tdesc; 2108817e1bfSRafal Jaworowski STAILQ_HEAD(, cesa_sa_desc) cr_sdesc; 2118817e1bfSRafal Jaworowski 2128817e1bfSRafal Jaworowski STAILQ_ENTRY(cesa_request) cr_stq; 2138817e1bfSRafal Jaworowski }; 2148817e1bfSRafal Jaworowski 2158817e1bfSRafal Jaworowski struct cesa_packet { 2168817e1bfSRafal Jaworowski STAILQ_HEAD(, cesa_tdma_desc) cp_copyin; 2178817e1bfSRafal Jaworowski STAILQ_HEAD(, cesa_tdma_desc) cp_copyout; 2188817e1bfSRafal Jaworowski unsigned int cp_size; 2198817e1bfSRafal Jaworowski unsigned int cp_offset; 2208817e1bfSRafal Jaworowski }; 2218817e1bfSRafal Jaworowski 2228817e1bfSRafal Jaworowski struct cesa_softc { 2238817e1bfSRafal Jaworowski device_t sc_dev; 2248817e1bfSRafal Jaworowski int32_t sc_cid; 22581526b83SWojciech Macek uint32_t sc_soc_id; 22622c7a031SZbigniew Bodek struct resource *sc_res[RES_CESA_NUM]; 2278817e1bfSRafal Jaworowski void *sc_icookie; 2288817e1bfSRafal Jaworowski bus_dma_tag_t sc_data_dtag; 2298817e1bfSRafal Jaworowski int sc_error; 2308817e1bfSRafal Jaworowski int sc_tperr; 231e9e2a7c1SMarcin Wojtas uint8_t sc_cesa_engine_id; 2328817e1bfSRafal Jaworowski 2338817e1bfSRafal Jaworowski struct mtx sc_sc_lock; 2348817e1bfSRafal Jaworowski int sc_blocked; 2358817e1bfSRafal Jaworowski 2368817e1bfSRafal Jaworowski /* TDMA descriptors pool */ 2378817e1bfSRafal Jaworowski struct mtx sc_tdesc_lock; 2388817e1bfSRafal Jaworowski struct cesa_tdma_desc sc_tdesc[CESA_TDMA_DESCRIPTORS]; 2398817e1bfSRafal Jaworowski struct cesa_dma_mem sc_tdesc_cdm; 2408817e1bfSRafal Jaworowski STAILQ_HEAD(, cesa_tdma_desc) sc_free_tdesc; 2418817e1bfSRafal Jaworowski 2428817e1bfSRafal Jaworowski /* SA descriptors pool */ 2438817e1bfSRafal Jaworowski struct mtx sc_sdesc_lock; 2448817e1bfSRafal Jaworowski struct cesa_sa_desc sc_sdesc[CESA_SA_DESCRIPTORS]; 2458817e1bfSRafal Jaworowski struct cesa_dma_mem sc_sdesc_cdm; 2468817e1bfSRafal Jaworowski STAILQ_HEAD(, cesa_sa_desc) sc_free_sdesc; 2478817e1bfSRafal Jaworowski 2488817e1bfSRafal Jaworowski /* Requests pool */ 2498817e1bfSRafal Jaworowski struct mtx sc_requests_lock; 2508817e1bfSRafal Jaworowski struct cesa_request sc_requests[CESA_REQUESTS]; 2518817e1bfSRafal Jaworowski struct cesa_dma_mem sc_requests_cdm; 2528817e1bfSRafal Jaworowski STAILQ_HEAD(, cesa_request) sc_free_requests; 2538817e1bfSRafal Jaworowski STAILQ_HEAD(, cesa_request) sc_ready_requests; 2548817e1bfSRafal Jaworowski STAILQ_HEAD(, cesa_request) sc_queued_requests; 2558817e1bfSRafal Jaworowski 2568817e1bfSRafal Jaworowski struct mtx sc_sessions_lock; 2578817e1bfSRafal Jaworowski 2588817e1bfSRafal Jaworowski /* CESA SRAM Address */ 2595188e3ccSZbigniew Bodek bus_addr_t sc_sram_base_pa; 2607ae99f80SJohn Baldwin void *sc_sram_base_va; 2615188e3ccSZbigniew Bodek bus_size_t sc_sram_size; 2628817e1bfSRafal Jaworowski }; 2638817e1bfSRafal Jaworowski 2648817e1bfSRafal Jaworowski struct cesa_chain_info { 2658817e1bfSRafal Jaworowski struct cesa_softc *cci_sc; 2668817e1bfSRafal Jaworowski struct cesa_request *cci_cr; 2678817e1bfSRafal Jaworowski uint32_t cci_config; 2688817e1bfSRafal Jaworowski int cci_error; 2698817e1bfSRafal Jaworowski }; 2708817e1bfSRafal Jaworowski 2718817e1bfSRafal Jaworowski /* CESA descriptors flags definitions */ 2728817e1bfSRafal Jaworowski #define CESA_CTHD_OWNED (1 << 15) 2738817e1bfSRafal Jaworowski 2748817e1bfSRafal Jaworowski #define CESA_CSHD_MAC (0 << 0) 2758817e1bfSRafal Jaworowski #define CESA_CSHD_ENC (1 << 0) 2768817e1bfSRafal Jaworowski #define CESA_CSHD_MAC_AND_ENC (2 << 0) 2778817e1bfSRafal Jaworowski #define CESA_CSHD_ENC_AND_MAC (3 << 0) 2788817e1bfSRafal Jaworowski #define CESA_CSHD_OP_MASK (3 << 0) 2798817e1bfSRafal Jaworowski 2808817e1bfSRafal Jaworowski #define CESA_CSHD_MD5 (4 << 4) 2818817e1bfSRafal Jaworowski #define CESA_CSHD_SHA1 (5 << 4) 282b07df6e5SZbigniew Bodek #define CESA_CSHD_SHA2_256 (1 << 4) 2831e964f8aSZbigniew Bodek #define CESA_CSHD_MD5_HMAC (6 << 4) 2841e964f8aSZbigniew Bodek #define CESA_CSHD_SHA1_HMAC (7 << 4) 285b07df6e5SZbigniew Bodek #define CESA_CSHD_SHA2_256_HMAC (3 << 4) 2861e964f8aSZbigniew Bodek 2871e964f8aSZbigniew Bodek #define CESA_CSHD_96_BIT_HMAC (1 << 7) 2888817e1bfSRafal Jaworowski 2898817e1bfSRafal Jaworowski #define CESA_CSHD_DES (1 << 8) 2908817e1bfSRafal Jaworowski #define CESA_CSHD_3DES (2 << 8) 2918817e1bfSRafal Jaworowski #define CESA_CSHD_AES (3 << 8) 2928817e1bfSRafal Jaworowski 2938817e1bfSRafal Jaworowski #define CESA_CSHD_DECRYPT (1 << 12) 2948817e1bfSRafal Jaworowski #define CESA_CSHD_CBC (1 << 16) 2958817e1bfSRafal Jaworowski #define CESA_CSHD_3DES_EDE (1 << 20) 2968817e1bfSRafal Jaworowski 2978817e1bfSRafal Jaworowski #define CESA_CSH_AES_KLEN_128 (0 << 24) 2988817e1bfSRafal Jaworowski #define CESA_CSH_AES_KLEN_192 (1 << 24) 2998817e1bfSRafal Jaworowski #define CESA_CSH_AES_KLEN_256 (2 << 24) 3008817e1bfSRafal Jaworowski #define CESA_CSH_AES_KLEN_MASK (3 << 24) 3018817e1bfSRafal Jaworowski 3028817e1bfSRafal Jaworowski #define CESA_CSHD_FRAG_FIRST (1 << 30) 303c8aef31dSEitan Adler #define CESA_CSHD_FRAG_LAST (2U << 30) 304c8aef31dSEitan Adler #define CESA_CSHD_FRAG_MIDDLE (3U << 30) 3058817e1bfSRafal Jaworowski 3068817e1bfSRafal Jaworowski /* CESA registers definitions */ 30722c7a031SZbigniew Bodek #define CESA_ICR 0x0E20 3088817e1bfSRafal Jaworowski #define CESA_ICR_ACCTDMA (1 << 7) 3098817e1bfSRafal Jaworowski #define CESA_ICR_TPERR (1 << 12) 3108817e1bfSRafal Jaworowski 31122c7a031SZbigniew Bodek #define CESA_ICM 0x0E24 3128817e1bfSRafal Jaworowski #define CESA_ICM_ACCTDMA CESA_ICR_ACCTDMA 3138817e1bfSRafal Jaworowski #define CESA_ICM_TPERR CESA_ICR_TPERR 3148817e1bfSRafal Jaworowski 3158817e1bfSRafal Jaworowski /* CESA TDMA registers definitions */ 3168817e1bfSRafal Jaworowski #define CESA_TDMA_ND 0x0830 3178817e1bfSRafal Jaworowski 3188817e1bfSRafal Jaworowski #define CESA_TDMA_CR 0x0840 3198817e1bfSRafal Jaworowski #define CESA_TDMA_CR_DBL128 (4 << 0) 3208817e1bfSRafal Jaworowski #define CESA_TDMA_CR_ORDEN (1 << 4) 3218817e1bfSRafal Jaworowski #define CESA_TDMA_CR_SBL128 (4 << 6) 3228817e1bfSRafal Jaworowski #define CESA_TDMA_CR_NBS (1 << 11) 3238817e1bfSRafal Jaworowski #define CESA_TDMA_CR_ENABLE (1 << 12) 3248817e1bfSRafal Jaworowski #define CESA_TDMA_CR_FETCHND (1 << 13) 3258817e1bfSRafal Jaworowski #define CESA_TDMA_CR_ACTIVE (1 << 14) 326b07df6e5SZbigniew Bodek #define CESA_TDMA_NUM_OUTSTAND (2 << 16) 327b07df6e5SZbigniew Bodek 3288817e1bfSRafal Jaworowski #define CESA_TDMA_ECR 0x08C8 3298817e1bfSRafal Jaworowski #define CESA_TDMA_ECR_MISS (1 << 0) 3308817e1bfSRafal Jaworowski #define CESA_TDMA_ECR_DOUBLE_HIT (1 << 1) 3318817e1bfSRafal Jaworowski #define CESA_TDMA_ECR_BOTH_HIT (1 << 2) 3328817e1bfSRafal Jaworowski #define CESA_TDMA_ECR_DATA_ERROR (1 << 3) 3338817e1bfSRafal Jaworowski 3348817e1bfSRafal Jaworowski #define CESA_TDMA_EMR 0x08CC 3358817e1bfSRafal Jaworowski #define CESA_TDMA_EMR_MISS CESA_TDMA_ECR_MISS 3368817e1bfSRafal Jaworowski #define CESA_TDMA_EMR_DOUBLE_HIT CESA_TDMA_ECR_DOUBLE_HIT 3378817e1bfSRafal Jaworowski #define CESA_TDMA_EMR_BOTH_HIT CESA_TDMA_ECR_BOTH_HIT 3388817e1bfSRafal Jaworowski #define CESA_TDMA_EMR_DATA_ERROR CESA_TDMA_ECR_DATA_ERROR 3398817e1bfSRafal Jaworowski 3408817e1bfSRafal Jaworowski /* CESA SA registers definitions */ 34122c7a031SZbigniew Bodek #define CESA_SA_CMD 0x0E00 3428817e1bfSRafal Jaworowski #define CESA_SA_CMD_ACTVATE (1 << 0) 343b07df6e5SZbigniew Bodek #define CESA_SA_CMD_SHA2 (1 << 31) 344b07df6e5SZbigniew Bodek 34522c7a031SZbigniew Bodek #define CESA_SA_DPR 0x0E04 3468817e1bfSRafal Jaworowski 34722c7a031SZbigniew Bodek #define CESA_SA_CR 0x0E08 3488817e1bfSRafal Jaworowski #define CESA_SA_CR_WAIT_FOR_TDMA (1 << 7) 3498817e1bfSRafal Jaworowski #define CESA_SA_CR_ACTIVATE_TDMA (1 << 9) 3508817e1bfSRafal Jaworowski #define CESA_SA_CR_MULTI_MODE (1 << 11) 3518817e1bfSRafal Jaworowski 35222c7a031SZbigniew Bodek #define CESA_SA_SR 0x0E0C 3538817e1bfSRafal Jaworowski #define CESA_SA_SR_ACTIVE (1 << 0) 3548817e1bfSRafal Jaworowski 355e9e2a7c1SMarcin Wojtas #define CESA_TDMA_SIZE 0x1000 356e9e2a7c1SMarcin Wojtas #define CESA_CESA_SIZE 0x1000 357e9e2a7c1SMarcin Wojtas #define CESA0_TDMA_ADDR 0x90000 358e9e2a7c1SMarcin Wojtas #define CESA0_CESA_ADDR 0x9D000 359e9e2a7c1SMarcin Wojtas #define CESA1_TDMA_ADDR 0x92000 360e9e2a7c1SMarcin Wojtas #define CESA1_CESA_ADDR 0x9F000 3618817e1bfSRafal Jaworowski #endif 362