RTEMS: bsps/arm/atsam/include/libchip/include/gmacd.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
gmacd.h
Go to the documentation of this file.
1/* ---------------------------------------------------------------------------- */
2/* Atmel Microcontroller Software Support */
3/* SAM Software Package License */
4/* ---------------------------------------------------------------------------- */
5/* Copyright (c) 2015, Atmel Corporation */
6/* */
7/* All rights reserved. */
8/* */
9/* Redistribution and use in source and binary forms, with or without */
10/* modification, are permitted provided that the following condition is met: */
11/* */
12/* - Redistributions of source code must retain the above copyright notice, */
13/* this list of conditions and the disclaimer below. */
14/* */
15/* Atmel's name may not be used to endorse or promote products derived from */
16/* this software without specific prior written permission. */
17/* */
18/* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */
19/* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
20/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
21/* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */
22/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
23/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
24/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
25/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
26/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
27/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
28/* ---------------------------------------------------------------------------- */
29
60#ifndef _GMACD_H_
61#define _GMACD_H_
62
63/*---------------------------------------------------------------------------
64 * Headers
65 *---------------------------------------------------------------------------*/
66
67#include "chip.h"
68
69
70/*---------------------------------------------------------------------------
71 * Definitions
72 *---------------------------------------------------------------------------*/
79#define GMACD_OK 0
80#define GMACD_TX_BUSY 1
81#define GMACD_RX_NULL 1
83#define GMACD_SIZE_TOO_SMALL 2
85#define GMACD_PARAM 3
87#define GMACD_NOT_INITIALIZED 4
92/* Should be a power of 2.
93 - Buffer Length to store the timestamps of 1588 event messages
94*/
95#define EFRS_BUFFER_LEN (1u)
96
97/*---------------------------------------------------------------------------
98* Types
99*---------------------------------------------------------------------------*/
103typedef enum ptpMsgType_t {
104 SYNC_MSG_TYPE = 0,
105 DELAY_REQ_MSG_TYPE = 1,
106 PDELAY_REQ_TYPE = 2,
107 PDELAY_RESP_TYPE = 3,
108 FOLLOW_UP_MSG_TYPE = 8,
109 DELAY_RESP_MSG_TYPE = 9
110} ptpMsgType;
111
112
113
115 typedef void (*fGmacdTransferCallback)(uint32_t status);
117 typedef void (*fGmacdWakeupCallback)(void);
119 typedef void (*fGmacdTxPtpEvtCallBack) (ptpMsgType msg, uint32_t sec, \
120 uint32_t nanosec, uint16_t seqId);
121
125 typedef struct _GmacSG {
126 uint32_t size;
127 void *pBuffer;
128} sGmacSG;
129
133 typedef struct _GmacSGList {
134 uint32_t len;
135 sGmacSG *sg;
136} sGmacSGList;
137
141 typedef struct _GmacQueueDriver {
142 uint8_t *pTxBuffer;
144 uint8_t *pRxBuffer;
145
147 sGmacRxDescriptor *pRxD;
149 sGmacTxDescriptor *pTxD;
150
152 fGmacdTransferCallback fRxCb;
154 fGmacdWakeupCallback fWakupCb;
156 fGmacdTransferCallback *fTxCbList;
157
159 fGmacdTxPtpEvtCallBack fTxPtpEvtCb;
160
162 uint16_t wRxListSize;
164 uint16_t wRxI;
165
167 uint16_t wTxListSize;
169 uint16_t wTxHead;
171 uint16_t wTxTail;
172
174 uint8_t bWakeupThreshold;
175
177 uint16_t wTxBufferSize;
178 uint16_t wRxBufferSize;
179
180} sGmacQd;
181
185 typedef struct _GmacDriver {
186
188 Gmac *pHw;
190 uint8_t bId;
192 sGmacQd queueList[NUM_GMAC_QUEUES];
193} sGmacd;
194
198 typedef struct _GmacInit {
199 uint32_t bIsGem: 1;
200 uint32_t reserved: 31;
201
202 uint8_t bDmaBurstLength;
203
205 uint8_t *pRxBuffer;
208 sGmacRxDescriptor *pRxD;
211 uint16_t wRxBufferSize;
212 uint16_t wRxSize;
217 uint8_t *pTxBuffer;
220 sGmacTxDescriptor *pTxD;
222 uint16_t wTxBufferSize;
224 uint16_t wTxSize;
225
226 fGmacdTransferCallback *pTxCb;
227} sGmacInit;
233/*---------------------------------------------------------------------------
234 * GMAC Exported functions
235 *---------------------------------------------------------------------------*/
236
237extern void GMACD_Handler(sGmacd *pGmacd , gmacQueList_t queIdx);
238
239extern void GMACD_Init(sGmacd *pGmacd,
240 Gmac *pHw,
241 uint8_t bID,
242 uint8_t enableCAF,
243 uint8_t enableNBC);
244
245extern uint8_t GMACD_InitTransfer(sGmacd *pGmacd,
246 const sGmacInit *pInit, gmacQueList_t queIdx);
247
248extern void GMACD_Reset(sGmacd *pGmacd);
249
250extern uint8_t GMACD_SendSG(sGmacd *pGmacd,
251 const sGmacSGList *sgl,
252 fGmacdTransferCallback fTxCb,
253 gmacQueList_t queIdx);
254
255extern uint8_t GMACD_Send(sGmacd *pGmacd,
256 void *pBuffer,
257 uint32_t size,
258 fGmacdTransferCallback fTxCb,
259 gmacQueList_t queIdx);
260
261extern uint32_t GMACD_TxLoad(sGmacd *pGmacd, gmacQueList_t queIdx);
262
263extern uint8_t GMACD_Poll(sGmacd *pGmacd,
264 uint8_t *pFrame,
265 uint32_t frameSize,
266 uint32_t *pRcvSize,
267 gmacQueList_t queIdx);
268
269extern void GMACD_SetRxCallback(sGmacd *pGmacd, fGmacdTransferCallback
270 fRxCb, gmacQueList_t queIdx);
271
272extern uint8_t GMACD_SetTxWakeupCallback(sGmacd *pGmacd,
273 fGmacdWakeupCallback fWakeup,
274 uint8_t bThreshold,
275 gmacQueList_t queIdx);
276
277extern void GMACD_TxPtpEvtMsgCBRegister (sGmacd *pGmacd,
278 fGmacdTxPtpEvtCallBack pTxPtpEvtCb,
279 gmacQueList_t queIdx);
280
283#endif // #ifndef _GMACD_H_
GMACD_SetTxWakeupCallback
uint8_t GMACD_SetTxWakeupCallback(sGmacd *pGmacd, fGmacdWakeupCallback fWakeup, uint8_t bThreshold, gmacQueList_t queIdx)
Definition: gmacd.c:1038
GMACD_TxLoad
uint32_t GMACD_TxLoad(sGmacd *pGmacd, gmacQueList_t queIdx)
Definition: gmacd.c:868
GMACD_Send
uint8_t GMACD_Send(sGmacd *pGmacd, void *pBuffer, uint32_t size, fGmacdTransferCallback fTxCb, gmacQueList_t queIdx)
Send a packet with GMAC. If the packet size is larger than transfer buffer size error returned....
Definition: gmacd.c:815
GMACD_SetRxCallback
void GMACD_SetRxCallback(sGmacd *pGmacd, fGmacdTransferCallback fRxCb, gmacQueList_t queIdx)
Registers pRxCb callback. Callback will be invoked after the next received frame. When GMAC_Poll() re...
Definition: gmacd.c:1006
GMACD_InitTransfer
uint8_t GMACD_InitTransfer(sGmacd *pGmacd, const sGmacInit *pInit, gmacQueList_t queIdx)
Definition: gmacd.c:551
GMACD_SendSG
uint8_t GMACD_SendSG(sGmacd *pGmacd, const sGmacSGList *sgl, fGmacdTransferCallback fTxCb, gmacQueList_t queIdx)
Send a frame split into buffers. If the frame size is larger than transfer buffer size error returned...
Definition: gmacd.c:705
GMACD_Handler
void GMACD_Handler(sGmacd *pGmacd, gmacQueList_t queIdx)
GMAC Interrupt handler.
Definition: gmacd.c:336
GMACD_Init
void GMACD_Init(sGmacd *pGmacd, Gmac *pHw, uint8_t bID, uint8_t enableCAF, uint8_t enableNBC)
Initialize the GMAC with the Gmac controller address.
Definition: gmacd.c:486
GMACD_Poll
uint8_t GMACD_Poll(sGmacd *pGmacd, uint8_t *pFrame, uint32_t frameSize, uint32_t *pRcvSize, gmacQueList_t queIdx)
Receive a packet with GMAC. If not enough buffer for the packet, the remaining data is lost but right...
Definition: gmacd.c:885
GMACD_Reset
void GMACD_Reset(sGmacd *pGmacd)
Definition: gmacd.c:679
fGmacdWakeupCallback
void(* fGmacdWakeupCallback)(void)
Definition: gmacd.h:117
sGmacSGList
struct _GmacSGList sGmacSGList
sGmacd
struct _GmacDriver sGmacd
fGmacdTransferCallback
void(* fGmacdTransferCallback)(uint32_t status)
Definition: gmacd.h:115
sGmacSG
struct _GmacSG sGmacSG
sGmacQd
struct _GmacQueueDriver sGmacQd
fGmacdTxPtpEvtCallBack
void(* fGmacdTxPtpEvtCallBack)(ptpMsgType msg, uint32_t sec, uint32_t nanosec, uint16_t seqId)
Definition: gmacd.h:119
sGmacInit
struct _GmacInit sGmacInit
Gmac
Definition: component_gmac.h:55
_GmacDriver
Definition: gmacd.h:185
_GmacDriver::queueList
sGmacQd queueList[NUM_GMAC_QUEUES]
Definition: gmacd.h:192
_GmacDriver::bId
uint8_t bId
Definition: gmacd.h:190
_GmacDriver::pHw
Gmac * pHw
Definition: gmacd.h:188
_GmacInit
Definition: gmacd.h:198
_GmacInit::wTxBufferSize
uint16_t wTxBufferSize
Definition: gmacd.h:222
_GmacInit::pRxD
sGmacRxDescriptor * pRxD
Definition: gmacd.h:208
_GmacInit::wRxBufferSize
uint16_t wRxBufferSize
Definition: gmacd.h:211
_GmacInit::wTxSize
uint16_t wTxSize
Definition: gmacd.h:224
_GmacInit::pTxD
sGmacTxDescriptor * pTxD
Definition: gmacd.h:220
_GmacInit::pRxBuffer
uint8_t * pRxBuffer
Definition: gmacd.h:205
_GmacInit::wRxSize
uint16_t wRxSize
Definition: gmacd.h:212
_GmacInit::pTxBuffer
uint8_t * pTxBuffer
Definition: gmacd.h:217
_GmacQueueDriver
Definition: gmacd.h:141
_GmacQueueDriver::pTxD
sGmacTxDescriptor * pTxD
Definition: gmacd.h:149
_GmacQueueDriver::fRxCb
fGmacdTransferCallback fRxCb
Definition: gmacd.h:152
_GmacQueueDriver::wTxTail
uint16_t wTxTail
Definition: gmacd.h:171
_GmacQueueDriver::fTxPtpEvtCb
fGmacdTxPtpEvtCallBack fTxPtpEvtCb
Definition: gmacd.h:159
_GmacQueueDriver::pRxBuffer
uint8_t * pRxBuffer
Definition: gmacd.h:144
_GmacQueueDriver::wTxListSize
uint16_t wTxListSize
Definition: gmacd.h:167
_GmacQueueDriver::wTxBufferSize
uint16_t wTxBufferSize
Definition: gmacd.h:177
_GmacQueueDriver::wRxI
uint16_t wRxI
Definition: gmacd.h:164
_GmacQueueDriver::pRxD
sGmacRxDescriptor * pRxD
Definition: gmacd.h:147
_GmacQueueDriver::fTxCbList
fGmacdTransferCallback * fTxCbList
Definition: gmacd.h:156
_GmacQueueDriver::wRxListSize
uint16_t wRxListSize
Definition: gmacd.h:162
_GmacQueueDriver::wTxHead
uint16_t wTxHead
Definition: gmacd.h:169
_GmacQueueDriver::fWakupCb
fGmacdWakeupCallback fWakupCb
Definition: gmacd.h:154
_GmacQueueDriver::bWakeupThreshold
uint8_t bWakeupThreshold
Definition: gmacd.h:174
_GmacRxDescriptor
Definition: gmac.h:172
_GmacSGList
Definition: gmacd.h:133
_GmacSG
Definition: gmacd.h:125
_GmacTxDescriptor
Definition: gmac.h:210
msg
Definition: b1553brm.c:75