AM64x MCU+ SDK  10.00.00
udma_ring.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018-2021 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
48 #ifndef UDMA_RING_H_
49 #define UDMA_RING_H_
50 
51 /* ========================================================================== */
52 /* Include Files */
53 /* ========================================================================== */
54 
55 /* None */
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 /* ========================================================================== */
62 /* Macros & Typedefs */
63 /* ========================================================================== */
64 
69 #define UDMA_RING_INVALID ((uint16_t) TISCI_MSG_VALUE_RM_NULL_RING_TYPE)
70 
74 #define UDMA_RING_ANY ((uint16_t) 0xFFFEU)
75 
79 #define UDMA_RING_VIRTID_INVALID ((uint16_t) 0xFFFFU)
80 
82 #define UDMA_RING_SIZE_CHECK_SKIP (0xABDCABCDU)
83 
87 #define UDMA_RING_ORDERID_MAX (0x0FU)
88 
101 #define UDMA_RING_ES_4BYTES ((uint8_t) 0x00U)
102 
103 #define UDMA_RING_ES_8BYTES ((uint8_t) 0x01U)
104 
105 #define UDMA_RING_ES_16BYTES ((uint8_t) 0x02U)
106 
107 #define UDMA_RING_ES_32BYTES ((uint8_t) 0x03U)
108 
109 #define UDMA_RING_ES_64BYTES ((uint8_t) 0x04U)
110 
111 #define UDMA_RING_ES_128BYTES ((uint8_t) 0x05U)
112 
113 #define UDMA_RING_ES_256BYTES ((uint8_t) 0x06U)
114 
116 /* ========================================================================== */
117 /* Structure Declarations */
118 /* ========================================================================== */
119 
123 typedef struct
124 {
125  void *ringMem;
132  uint32_t ringMemSize;
139  uint8_t mode;
141  uint16_t virtId;
143  uint32_t elemCnt;
147  uint8_t elemSize;
150  uint8_t orderId;
153  uint8_t asel;
161  uint32_t mappedRingGrp;
170  uint32_t mappedChNum;
183 } Udma_RingPrms;
184 
185 /* ========================================================================== */
186 /* Function Declarations */
187 /* ========================================================================== */
188 
207 int32_t Udma_ringAlloc(Udma_DrvHandle drvHandle,
208  Udma_RingHandle ringHandle,
209  uint16_t ringNum,
210  const Udma_RingPrms *ringPrms);
211 
222 int32_t Udma_ringFree(Udma_RingHandle ringHandle);
223 
254 int32_t Udma_ringAttach(Udma_DrvHandle drvHandle,
255  Udma_RingHandle ringHandle,
256  uint16_t ringNum);
257 
271 int32_t Udma_ringDetach(Udma_RingHandle ringHandle);
272 
301 int32_t Udma_ringQueueRaw(Udma_RingHandle ringHandle, uint64_t phyDescMem);
302 
339 int32_t Udma_ringDequeueRaw(Udma_RingHandle ringHandle, uint64_t *phyDescMem);
340 
364 int32_t Udma_ringFlushRaw(Udma_RingHandle ringHandle, uint64_t *phyDescMem);
365 
392 void Udma_ringPrime(Udma_RingHandle ringHandle, uint64_t phyDescMem);
393 
422 void Udma_ringPrimeRead(Udma_RingHandle ringHandle, uint64_t *phyDescMem);
423 
451 void Udma_ringSetDoorBell(Udma_RingHandle ringHandle, int32_t count);
452 
461 uint16_t Udma_ringGetNum(Udma_RingHandle ringHandle);
462 
474 
485 uint32_t Udma_ringGetMode(Udma_RingHandle ringHandle);
486 
498 
516 
534 
551 uint32_t Udma_ringGetWrIdx(Udma_RingHandle ringHandle);
552 
569 uint32_t Udma_ringGetRdIdx(Udma_RingHandle ringHandle);
570 
571 /*
572  * Structure Init functions
573  */
581 
582 /* ========================================================================== */
583 /* Static Function Definitions */
584 /* ========================================================================== */
585 
586 /* None */
587 
588 /* ========================================================================== */
589 /* Internal/Private Structure Declarations */
590 /* ========================================================================== */
591 
595 typedef struct Udma_RingObject_t
596 {
597  uintptr_t rsv[30U];
600 
601 #ifdef __cplusplus
602 }
603 #endif
604 
605 #endif /* #ifndef UDMA_RING_H_ */
606 
Udma_ringDequeueRaw
int32_t Udma_ringDequeueRaw(Udma_RingHandle ringHandle, uint64_t *phyDescMem)
UDMA dequeue descriptor from a ring - raw version (Takes all physical pointers).
Udma_ringPrime
void Udma_ringPrime(Udma_RingHandle ringHandle, uint64_t phyDescMem)
UDMA prime descriptor to a exposed/"RING" mode ring - raw version (Takes all physical pointers)....
Udma_RingPrms
UDMA ring parameters.
Definition: udma_ring.h:124
Udma_ringAttach
int32_t Udma_ringAttach(Udma_DrvHandle drvHandle, Udma_RingHandle ringHandle, uint16_t ringNum)
UDMA ring attach API. This API is used to attach to an already allocated and configured ring....
count
uint32_t count
Definition: tisci_rm_ra.h:6
Udma_RingObject
Opaque UDMA ring object.
Definition: udma_ring.h:596
Udma_ringGetElementCnt
uint32_t Udma_ringGetElementCnt(Udma_RingHandle ringHandle)
Returns the ring element count which is passed during ring alloc.
Udma_RingPrms::mappedRingGrp
uint32_t mappedRingGrp
Definition: udma_ring.h:161
Udma_ringGetMode
uint32_t Udma_ringGetMode(Udma_RingHandle ringHandle)
Returns the ring mode which is configured during ring alloc.
Udma_ringGetReverseRingOcc
uint32_t Udma_ringGetReverseRingOcc(Udma_RingHandle ringHandle)
Returns the reverse ring occupancy.
UdmaRingPrms_init
void UdmaRingPrms_init(Udma_RingPrms *ringPrms)
Udma_RingPrms structure init function.
Udma_RingHandle
void * Udma_RingHandle
UDMA ring handle.
Definition: udma_types.h:71
Udma_RingPrms::mode
uint8_t mode
Definition: udma_ring.h:139
Udma_ringQueueRaw
int32_t Udma_ringQueueRaw(Udma_RingHandle ringHandle, uint64_t phyDescMem)
UDMA queue descriptor to a ring - raw version (Takes all physical pointers)
Udma_ringFlushRaw
int32_t Udma_ringFlushRaw(Udma_RingHandle ringHandle, uint64_t *phyDescMem)
UDMA dequeue descriptor from a ring when UDMA channel is disabled - raw version (Takes all physical p...
Udma_ringGetWrIdx
uint32_t Udma_ringGetWrIdx(Udma_RingHandle ringHandle)
Returns the ring write index value.
Udma_ringGetNum
uint16_t Udma_ringGetNum(Udma_RingHandle ringHandle)
Returns the ring number allocated for this ring.
Udma_RingPrms::elemSize
uint8_t elemSize
Definition: udma_ring.h:147
Udma_RingPrms::mappedChNum
uint32_t mappedChNum
Definition: udma_ring.h:170
Udma_ringSetDoorBell
void Udma_ringSetDoorBell(Udma_RingHandle ringHandle, int32_t count)
UDMA ring API to set the doorbell in exposed/"RING" mode ring. This will commit the previously primed...
Udma_RingPrms::ringMemSize
uint32_t ringMemSize
Definition: udma_ring.h:132
Udma_RingPrms::virtId
uint16_t virtId
Definition: udma_ring.h:141
Udma_ringPrimeRead
void Udma_ringPrimeRead(Udma_RingHandle ringHandle, uint64_t *phyDescMem)
UDMA read descriptor from a exposed/"RING" mode ring - raw version (Reads physical pointers)....
Udma_ringDetach
int32_t Udma_ringDetach(Udma_RingHandle ringHandle)
UDMA detach ring API.
Udma_DrvHandle
void * Udma_DrvHandle
UDMA driver handle.
Definition: udma_types.h:65
Udma_RingPrms::orderId
uint8_t orderId
Definition: udma_ring.h:150
Udma_ringGetRdIdx
uint32_t Udma_ringGetRdIdx(Udma_RingHandle ringHandle)
Returns the ring read index value.
Udma_ringGetMemPtr
void * Udma_ringGetMemPtr(Udma_RingHandle ringHandle)
Returns the ring memory pointer which is passed during ring alloc.
Udma_ringAlloc
int32_t Udma_ringAlloc(Udma_DrvHandle drvHandle, Udma_RingHandle ringHandle, uint16_t ringNum, const Udma_RingPrms *ringPrms)
UDMA ring allocation and configuration API.
Udma_RingPrms::elemCnt
uint32_t elemCnt
Definition: udma_ring.h:143
Udma_ringFree
int32_t Udma_ringFree(Udma_RingHandle ringHandle)
UDMA free ring.
Udma_RingPrms::ringMem
void * ringMem
Definition: udma_ring.h:125
Udma_ringGetForwardRingOcc
uint32_t Udma_ringGetForwardRingOcc(Udma_RingHandle ringHandle)
Returns the forward ring occupancy.
Udma_RingPrms::asel
uint8_t asel
Definition: udma_ring.h:153