source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/dma/7552/bdma_sharf.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 17.1 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2011, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bdma_sharf.h $
11 * $brcm_Revision: Hydra_Software_Devel/3 $
12 * $brcm_Date: 3/1/11 8:21a $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/dma/7440/bdma_sharf.h $
19 *
20 * Hydra_Software_Devel/3   3/1/11 8:21a vanessah
21 * SWBLURAY-24887: fix compile error for compile error. To be removed
22 * later
23 *
24 * Hydra_Software_Devel/2   2/2/11 10:30a vanessah
25 * SW7550-670: add Sharf DMA support
26 *
27 * Hydra_Software_Devel/2   12/11/07 10:58a syang
28 * PR 34606:  update sharf dma according to big rewriting of regular dma
29 * code / API
30 *
31 * Hydra_Software_Devel/1   3/19/07 4:27p syang
32 * PR 28171: init version
33 *
34 ***************************************************************************/
35#ifndef BDMA_SHARF_H__
36#define BDMA_SHARF_H__
37
38#include "bdma.h"          /* */
39
40#if 0
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46
47/**************************** Module Overview: *****************************
48SHARF memory dma engine is also represented by regular memory dma sub-module
49handle BDMA_Mem_Handle. The API functions and usage are exactly the same as
50regular memory dma, except that
51
52        o  Its BDMA_Mem_Handle sub-module handle should be created by
53           BDMA_Mem_Sharf_Create, rather than BDMA_Mem_Create; should be destoyed
54           by BDMA_Mem_Sharf_Destroy, rahtern than BDMA_Mem_Destroy.
55        o  BDMA_Mem_Sharf_Tran_SetCrypto should be used to configure the sharf SCRAM
56           operations, and BDMA_Mem_SetCrypto should not be used for sharf dma.
57        o  BDMA_Mem_Sharf_Tran_SetSgStartEnd should be used to set the start
58           point and/or end point of scatter-gather SCRAM.
59        o  BDMA_Mem_Sharf_Tran_SetDmaBlockInfo(_isr) are used to replace the
60           regular BDMA_Mem_Tran_SetDmaBlockInfo(_isr).
61
62bdma_sharf.h could be considered as part of bdma.h for sharf particularly.
63****************************************************************************/
64
65/***************************************************************************
66Summary:
67        This enumeration represents the sharf dma engines.
68
69Description:
70        BDMA_Sharf is an enumeration which represents the sharf dma engines.
71
72See Also:
73        BDMA_Mem_Sharf_Create
74***************************************************************************/
75typedef enum BDMA_Sharf
76{
77        BDMA_Sharf_e0,  /* sharf memory dma engine 0 */
78        BDMA_Sharf_e1,  /* sharf memory dma engine 1 */
79        BDMA_Sharf_eInvalid
80}
81BDMA_Sharf;
82
83/***************************************************************************
84Summary:
85        Creates a sub-module handle to sharf memory DMA engine.
86
87Description:
88        Once created, the handle to the unique memory DMA engine is required by
89        sharf memory DMA sub-module functions in order to configure the DMA engine
90        and perform DMA transfer.
91
92        This function also initializes the sub-module to default configure.
93
94        Refer to BDMA_Mem_Handle and BDMA_Mem_Create2 description for detailed
95        usage info.
96
97Input:
98        hDma - Handle to the BDMA module.
99        eEngine - The enum to identify the HW sharf memory dma engine.
100
101Output:
102        phMemDma - The created memory DMA sub-module handle. If failure
103        occurred phMemDma will holds NULL.
104
105Returns:
106        BERR_INVALID_PARAMETER - Invalid function parameters.
107        BERR_SUCCESS - Successfully created the handle.
108
109See Also:
110        BDMA_Mem_sharf_Destroy
111**************************************************************************/
112BERR_Code BDMA_Mem_Sharf_Create(
113        BDMA_Handle              hDma,
114        BDMA_Sharf               eEngine,
115        BDMA_Mem_Settings *      pSettings,
116        BDMA_Mem_Handle *        phMemDma );
117
118
119/***************************************************************************
120Summary:
121        Destroys the sub-module handle of the memory DMA engine.
122
123Description:
124        Once this function is called the sub-module handle can no longer be
125        used.
126
127        Memory DMA engine sub-module handle should be destroyed before closing
128        the main module handle BDMA_Handle by BDMA_Close.
129
130Input:
131        hMemDma - The memory DMA engine sub-module handle to destroy.
132
133Output:
134
135Returns:
136        BERR_INVALID_PARAMETER - hMemDma is not a valid memory DMA engine
137        sub-module handle.
138        BERR_SUCCESS - Successfully destroyed
139
140See Also:
141        BDMA_Mem_Sharf_Create
142**************************************************************************/
143BERR_Code BDMA_Mem_Sharf_Destroy(
144        BDMA_Mem_Handle       hMemDma );
145
146/***************************************************************************
147Summary:
148        This enumeration represents the possible SCRAM operations performed by
149        sharf dma engines.
150
151Description:
152        BDMA_SharfMode is an enumeration which represents the possible SCRAM
153        operations performed by sharf dma engines.
154
155See Also:
156        BDMA_Mem_Sharf_Tran_SetCrypto
157***************************************************************************/
158typedef enum BDMA_SharfMode
159{
160        BDMA_SharfMode_ePassThrough,
161        BDMA_SharfMode_eSha1,
162        BDMA_SharfMode_eAes128CbcDecrypt,
163        BDMA_SharfMode_eAes128CbcEncrypt,
164        BDMA_SharfMode_eCmac,
165        BDMA_SharfMode_eAes128EcbDecrypt,
166        BDMA_SharfMode_eAes128EcbEncrypt,
167        BDMA_SharfMode_eInvalid
168}
169BDMA_SharfMode;
170
171
172/***************************************************************************
173Summary:
174        Set sharf scram operation.
175
176Description:
177        During a DMA data transfer, sharf memory DMA engines could be configured
178        to perform different kind of SCRAM operations.
179
180        In the case that eSharfMode is BDMA_SharfMode_ePassThrough, the data will
181        pass through sharf without SCRAM operation.
182
183        If eSharfMode has other valid value, the specified SCRAM is performed by
184        sharf HW.
185
186        Further, when scatter-gather mode is enabled by bSgEnable, the dma engine
187        will treat the data stream section of a list of dma blocks as a whole for
188        SCRAM purpose. The stream section starts from the beginning of the block
189        marked as scatter-gather start point, and ends at the end of the block
190        marked as scatter-gather end point. bSgEnable and eSharfMode can not
191        change between the scatter-gather start point and end point.
192
193        When bUseBspKey is false, sharf uses the key wrapped in the head of the
194        scatter-gather data stream section, for the following data encrypt or
195        decrypt. if bUseBspKey is true, sharf uses the key supplied by Aegis
196        directly for data encrypt and decrypt, regardless of the state of key-
197        present set with BDMA_Mem_Sharf_Tran_SetSgStartEnd.
198
199        The sub-module maintains a current state of settings by this API function.
200        Each setting modifies the current state and is applied to the future
201        calls to BDMA_Mem_Tran_SetDmaBlockInfo(_isr), unless it is reset again.
202
203Input:
204        hTran - The transfer handle to set crypto.
205        BDMA_SharfMode - SCRAM operation mode.
206        bSgEnable - Whether enable scatter-gather SCRAM operation.
207        bUseBspKey - If it is true, sharf uses the key supplied by Aegis directly
208        (regardless of what BDMA_Mem_Sharf_Tran_SetSgStartEnd sets for key-present).
209        bCmp8LstByts - If it is true, sharf will use only the 8 least significant
210        bytes for digest comparing.
211Output:
212
213Returns:
214        BERR_SUCCESS - crypto setting is set successfully.
215        BERR_INVALID_PARAMETER - One of the input parameters is invalid.
216
217See Also:
218        BDMA_Mem_Sharf_Tran_SetSgStartEnd, BDMA_Mem_Sharf_Tran_SetSgStartEnd_isr,
219        BDMA_Mem_Tran_SetDmaBlockInfo, BDMA_Mem_Tran_SetDmaBlockInfo_isr
220****************************************************************************/
221BERR_Code BDMA_Mem_Sharf_Tran_SetCrypto(
222        BDMA_Mem_Tran_Handle     hTran,
223        BDMA_SharfMode           eSharfMode,
224        bool                     bSgEnable,
225        bool                     bUseBspKey,
226        bool                     bCmp8LstByts);
227
228/***************************************************************************
229Summary:
230        Set the start point and/or end point of scatter-gather.
231
232Description:
233        When SCRAM operation and scatter-gather mode are enabled, the sharf dma
234        engine will treat the data stream section of a list of dma blocks as a
235        whole for SCRAM purpose. The stream section starts from the beginning of
236        the block marked as scatter-gather start point, and ends at the end of
237        the block marked as scatter-gather end point.
238
239        This API function is used to mark the block with ID ulBlockId as scatter-
240        gather start and/or end point. It can also mark whether crypto key and/or
241        digest/MAC reference value is prepended into the data transferred by dma.
242
243Input:
244        hTran - The transfer handle to set block info.
245        ulBlockId - The block index in the block list of this transfer, it starts
246        from 0.
247        bStartSgScram - Whether this block is a scatter-gather start point.
248        bEndSgScram - Whether this block is a scatter-gather end point.
249        bKeyPresent - Whether crypto key is prepended into the data stream.
250        bDigestPresent - Whether digest reference value is prepended into the data
251        stream.
252Output:
253
254Returns:
255        BERR_SUCCESS - The block info is set successfully.
256        BERR_INVALID_PARAMETER - One of the input parameters is invalid.
257
258See Also:
259        BDMA_Mem_Sharf_Tran_SetCrypto, BDMA_Mem_Tran_SetDmaBlockInfo,
260        BDMA_Mem_Sharf_Tran_SetSgStartEnd_isr
261****************************************************************************/
262BERR_Code BDMA_Mem_Sharf_Tran_SetSgStartEnd(
263        BDMA_Mem_Tran_Handle     hTran,
264        uint32_t                 ulBlockId,
265        bool                     bStartSgScram,
266        bool                     bEndSgScram,
267        bool                     bKeyPresent,
268        bool                     bDigestPresent );
269
270/***************************************************************************
271Summary:
272        This enumeration represents the contexts sharf support.
273
274Description:
275        BDMA_Context is an enumeration which represents the contexts sharf support.
276
277See Also:
278        BDMA_Mem_Sharf_Tran_SetDmaBlockInfo, BDMA_Mem_Sharf_Tran_SetDmaBlockInfo_isr
279***************************************************************************/
280typedef enum BDMA_Context
281{
282        BDMA_Context_eSha0,       /* context 0 for sha op */
283        BDMA_Context_eSha1,       /* context 1 for sha op */
284        BDMA_Context_eSha2,       /* context 2 for sha op */
285        BDMA_Context_eAesOrCmac,  /* context for AES or CMAC */
286        BDMA_Context_eInvalid
287}
288BDMA_Context;
289
290/***************************************************************************
291Summary:
292        Set the block info for one block of a DMA transfer.
293
294Description:
295        In order to perform a DMA transfer, user first creates a transfer handle,
296        then uses it to set block info for each block, to start the DMA transfer,
297        and finally to get the transfer status. This API function is used to set
298        block info for one block.
299
300        ulBlockId is the index of the block, in the block list of the transfer
301        represented by hTran. It starts from 0. eContext is the context number
302        this block belongs to.
303
304        The source and destination address are in memory bus address space. They
305        are 28 bits unsigned integer number in 7038 chip. It is more likely that
306        they are converted from virtual memory mapped address using
307        BMEM_ConvertAddressToOffset and the virtual address is returned by
308        BMEM_AllocAligned or BMEM_Alloc.
309
310        Both addresses and block size are byte aligned. Max block size is
311        0xfff,ffff (16 MByte). Source and destination region overlap with
312        (ulSrcBusAddr < ulDstBusAddr < ulSrcBusAddr+ulBlockSize) is not allowed.
313
314        Encryption and decryption algorithms typically work on memory size of
315        multiple 8 bytes or 16 bytes, and certain residue mode clear termination
316        or OFB, might be used for the remaining bytes in the block.
317
318        Please notice that when a non-word-aligned source address is used, the
319        read endian determine which bytes to read in a 32 bits word.
320
321        The current state of read endian, swap mode and encrypt / decrypt setting
322        is used during the transfer of this block.
323
324        Please refer to the DMA module overview and BDMA_Mem_Handle for more
325        info on the usage of the memory DMA sub-module API functions.
326
327Input:
328        hTran - The transfer handle to set block info.
329        ulBlockId - The block index in the block list of this transfer, it starts
330        from 0.
331        eContext - The context number this block belongs to.
332        ulDstBusAddr - Destination address in memory bus address space.
333        ulSrcBusAddr - Source address in memory bus address space.
334        ulBlockSize - This block size in bytes.
335
336Output:
337
338Returns:
339        BERR_SUCCESS - The block info is set successfully.
340        BDMA_ERR_OVERLAP - Source and destination region overlap.
341        BDMA_ERR_SIZE_OUT_RANGE - ulBlockSize is 0 or bigger than 16 MByte.
342        BERR_INVALID_PARAMETER - One of the input parameters is invalid.
343
344See Also:
345        BDMA_Mem_Tran_Create2
346        BDMA_Mem_Tran_Start, BDMA_Mem_Tran_StartAndCallBack
347        BDMA_Mem_SetByteSwapMode, BDMA_Mem_SetCrypt
348        BDMA_Mem_Tran_SetDmaBlockInfo_isr
349****************************************************************************/
350BERR_Code BDMA_Mem_Sharf_Tran_SetDmaBlockInfo(
351        BDMA_Mem_Tran_Handle     hTran,
352        uint32_t                 ulBlockId,
353        BDMA_Context             eContext,
354        uint32_t                 ulDstBusAddr,
355        uint32_t                 ulSrcBusAddr,
356        uint32_t                 ulBlockSize );
357
358/***************************************************************************
359Summary:
360        Set sharf scram operation.
361
362Description:
363        This is the "_isr" version of BDMA_Mem_Sharf_Tran_SetCrypto. It is used
364        in interrupt handler or critical session. For more description refer to
365        BDMA_Mem_Sharf_Tran_SetCrypto.
366       
367Input:
368        hTran - The transfer handle to set crypto.
369        BDMA_SharfMode - SCRAM operation mode.
370        bSgEnable - Whether enable scatter-gather SCRAM operation.
371        bUseBspKey - If it is true, sharf uses the key supplied by Aegis directly
372        (regardless of what BDMA_Mem_Sharf_Tran_SetSgStartEnd sets for key-present).
373        bCmp8LstByts - If it is true, sharf will use only the 8 least significant
374        bytes for digest comparing.
375Output:
376
377Returns:
378        BERR_SUCCESS - crypto setting is set successfully.
379        BERR_INVALID_PARAMETER - One of the input parameters is invalid.
380
381See Also:
382        BDMA_Mem_Sharf_Tran_SetCrypto,
383        BDMA_Mem_Sharf_Tran_SetSgStartEnd, BDMA_Mem_Sharf_Tran_SetSgStartEnd_isr,
384        BDMA_Mem_Tran_SetDmaBlockInfo, BDMA_Mem_Tran_SetDmaBlockInfo_isr
385****************************************************************************/
386BERR_Code BDMA_Mem_Sharf_Tran_SetCrypto_isr(
387        BDMA_Mem_Tran_Handle     hTran,
388        BDMA_SharfMode           eSharfMode,
389        bool                     bSgEnable,
390        bool                     bUseBspKey,
391        bool                     bCmp8LstByts);
392
393/***************************************************************************
394Summary:
395        Set the start point and/or end point of scatter-gather.
396
397Description:
398        This is the "_isr" version of BDMA_Mem_Sharf_Tran_SetSgStartEnd. It is
399        used in interrupt handler or critical session. For more description refer
400        to BDMA_Mem_Sharf_Tran_SetSgStartEnd.
401
402Input:
403        hTran - The transfer handle to set block info.
404        ulBlockId - The block index in the block list of this transfer, it starts
405        from 0.
406        bStartSgScram - Whether this block is a scatter-gather start point.
407        bEndSgScram - Whether this block is a scatter-gather end point.
408        bKeyPresent - Whether crypto key is prepended into the data stream.
409        bDigestPresent - Whether digest reference value is prepended into the data
410        stream.
411Output:
412
413Returns:
414        BERR_SUCCESS - The block info is set successfully.
415        BERR_INVALID_PARAMETER - One of the input parameters is invalid.
416
417See Also:
418        BDMA_Mem_Sharf_Tran_SetCrypto, BDMA_Mem_Tran_SetDmaBlockInfo_isr,
419        BDMA_Mem_Sharf_Tran_SetSgStartEnd
420****************************************************************************/
421BERR_Code BDMA_Mem_Sharf_Tran_SetSgStartEnd_isr(
422        BDMA_Mem_Tran_Handle     hTran,
423        uint32_t                 ulBlockId,
424        bool                     bStartSgScram,
425        bool                     bEndSgScram,
426        bool                     bKeyPresent,
427        bool                     bDigestPresent );
428
429/***************************************************************************
430Summary:
431        Set the block info for one block of a DMA transfer.
432
433Description:
434        This is the "_isr" version of BDMA_Mem_Sharf_Tran_SetDmaBlockInfo. It is
435        used in interrupt handler or critical session. For more description refer
436        to BDMA_Mem_Sharf_Tran_SetDmaBlockInfo.
437
438Input:
439        hTran - The transfer handle to set block info.
440        ulBlockId - The block index in the block list of this transfer, it starts
441        from 0.
442        eContext - The context number this block belongs to.
443        ulDstBusAddr - Destination address in memory bus address space.
444        ulSrcBusAddr - Source address in memory bus address space.
445        ulBlockSize - This block size in bytes.
446
447Output:
448
449Returns:
450        BERR_SUCCESS - The block info is set successfully.
451        BDMA_ERR_OVERLAP - Source and destination region overlap.
452        BDMA_ERR_SIZE_OUT_RANGE - ulBlockSize is 0 or bigger than 16 MByte.
453        BERR_INVALID_PARAMETER - One of the input parameters is invalid.
454
455See Also:
456        BDMA_Mem_Tran_Create2
457        BDMA_Mem_Tran_Start, BDMA_Mem_Tran_StartAndCallBack
458        BDMA_Mem_SetByteSwapMode, BDMA_Mem_SetCrypt
459        BDMA_Mem_Tran_SetDmaBlockInfo_isr
460****************************************************************************/
461BERR_Code BDMA_Mem_Sharf_Tran_SetDmaBlockInfo_isr(
462        BDMA_Mem_Tran_Handle     hTran,
463        uint32_t                 ulBlockId,
464        BDMA_Context             eContext,
465        uint32_t                 ulDstBusAddr,
466        uint32_t                 ulSrcBusAddr,
467        uint32_t                 ulBlockSize );
468
469
470#ifdef __cplusplus
471}
472#endif
473#endif
474#endif /* #ifndef BDMA_SHARF_H__ */
475
476/* end of file */
Note: See TracBrowser for help on using the repository browser.