]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/include/xemacps_bd.h
Add in the CORTEX_A53_64-bit_UltraScale_MPSoC demo application (a demo has been inclu...
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / include / xemacps_bd.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2010 - 2015 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34  *
35  * @file xemacps_bd.h
36  *
37  * This header provides operations to manage buffer descriptors in support
38  * of scatter-gather DMA.
39  *
40  * The API exported by this header defines abstracted macros that allow the
41  * user to read/write specific BD fields.
42  *
43  * <b>Buffer Descriptors</b>
44  *
45  * A buffer descriptor (BD) defines a DMA transaction. The macros defined by
46  * this header file allow access to most fields within a BD to tailor a DMA
47  * transaction according to user and hardware requirements.  See the hardware
48  * IP DMA spec for more information on BD fields and how they affect transfers.
49  *
50  * The XEmacPs_Bd structure defines a BD. The organization of this structure
51  * is driven mainly by the hardware for use in scatter-gather DMA transfers.
52  *
53  * <b>Performance</b>
54  *
55  * Limiting I/O to BDs can improve overall performance of the DMA channel.
56  *
57  * <pre>
58  * MODIFICATION HISTORY:
59  *
60  * Ver   Who  Date     Changes
61  * ----- ---- -------- -------------------------------------------------------
62  * 1.00a wsy  01/10/10 First release
63  * 2.1   srt  07/15/14 Add support for Zynq Ultrascale MP GEM specification
64  *                     and 64-bit changes.
65  * 3.0   kvn  02/13/15 Modified code for MISRA-C:2012 compliance.
66  * 3.0   hk   02/20/15 Added support for jumbo frames.
67  *                     Disable extended mode. Perform all 64 bit changes under
68  *                     check for arch64.
69  *
70  * </pre>
71  *
72  * ***************************************************************************
73  */
74
75 #ifndef XEMACPS_BD_H            /* prevent circular inclusions */
76 #define XEMACPS_BD_H            /* by using protection macros */
77
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81
82 /***************************** Include Files *********************************/
83
84 #include <string.h>
85 #include "xil_types.h"
86 #include "xil_assert.h"
87
88 /************************** Constant Definitions *****************************/
89
90 /**************************** Type Definitions *******************************/
91 #ifdef __aarch64__
92 /* Minimum BD alignment */
93 #define XEMACPS_DMABD_MINIMUM_ALIGNMENT  64U
94 #else
95 /* Minimum BD alignment */
96 #define XEMACPS_DMABD_MINIMUM_ALIGNMENT  4U
97 #endif
98
99 /**
100  * The XEmacPs_Bd is the type for buffer descriptors (BDs).
101  */
102 #define XEMACPS_BD_NUM_WORDS 2U
103 typedef UINTPTR XEmacPs_Bd[XEMACPS_BD_NUM_WORDS];
104
105
106 /***************** Macros (Inline Functions) Definitions *********************/
107
108 /*****************************************************************************/
109 /**
110  * Zero out BD fields
111  *
112  * @param  BdPtr is the BD pointer to operate on
113  *
114  * @return Nothing
115  *
116  * @note
117  * C-style signature:
118  *    void XEmacPs_BdClear(XEmacPs_Bd* BdPtr)
119  *
120  *****************************************************************************/
121 #define XEmacPs_BdClear(BdPtr)                                  \
122     memset((BdPtr), 0, sizeof(XEmacPs_Bd))
123
124 /****************************************************************************/
125 /**
126 *
127 * Read the given Buffer Descriptor word.
128 *
129 * @param    BaseAddress is the base address of the BD to read
130 * @param    Offset is the word offset to be read
131 *
132 * @return   The 32-bit value of the field
133 *
134 * @note
135 * C-style signature:
136 *    u32 XEmacPs_BdRead(UINTPTR BaseAddress, UINTPTR Offset)
137 *
138 *****************************************************************************/
139 #define XEmacPs_BdRead(BaseAddress, Offset)             \
140         (*(u32 *)((UINTPTR)((void*)(BaseAddress)) + (u32)(Offset)))
141
142 /****************************************************************************/
143 /**
144 *
145 * Write the given Buffer Descriptor word.
146 *
147 * @param    BaseAddress is the base address of the BD to write
148 * @param    Offset is the word offset to be written
149 * @param    Data is the 32-bit value to write to the field
150 *
151 * @return   None.
152 *
153 * @note
154 * C-style signature:
155 *    void XEmacPs_BdWrite(UINTPTR BaseAddress, UINTPTR Offset, UINTPTR Data)
156 *
157 *****************************************************************************/
158 #define XEmacPs_BdWrite(BaseAddress, Offset, Data)              \
159     (*(u32 *)((UINTPTR)(void*)(BaseAddress) + (u32)(Offset)) = (u32)(Data))
160
161 /*****************************************************************************/
162 /**
163  * Set the BD's Address field (word 0).
164  *
165  * @param  BdPtr is the BD pointer to operate on
166  * @param  Addr  is the value to write to BD's status field.
167  *
168  * @note :
169  *
170  * C-style signature:
171  *    void XEmacPs_BdSetAddressTx(XEmacPs_Bd* BdPtr, UINTPTR Addr)
172  *
173  *****************************************************************************/
174 #ifdef __aarch64__
175 #define XEmacPs_BdSetAddressTx(BdPtr, Addr)                        \
176     XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_OFFSET,            \
177                         (u32)((Addr) & ULONG64_LO_MASK));               \
178     XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_HI_OFFSET,         \
179         (u32)(((Addr) & ULONG64_HI_MASK) >> 32U));
180 #else
181 #define XEmacPs_BdSetAddressTx(BdPtr, Addr)                        \
182     XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_OFFSET, (u32)(Addr))
183 #endif
184
185 /*****************************************************************************/
186 /**
187  * Set the BD's Address field (word 0).
188  *
189  * @param  BdPtr is the BD pointer to operate on
190  * @param  Addr  is the value to write to BD's status field.
191  *
192  * @note : Due to some bits are mixed within recevie BD's address field,
193  *         read-modify-write is performed.
194  *
195  * C-style signature:
196  *    void XEmacPs_BdSetAddressRx(XEmacPs_Bd* BdPtr, UINTPTR Addr)
197  *
198  *****************************************************************************/
199 #ifdef __aarch64__
200 #define XEmacPs_BdSetAddressRx(BdPtr, Addr)                        \
201     XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_OFFSET,              \
202     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) &           \
203         ~XEMACPS_RXBUF_ADD_MASK) | ((u32)((Addr) & ULONG64_LO_MASK))));  \
204     XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_HI_OFFSET,         \
205         (u32)(((Addr) & ULONG64_HI_MASK) >> 32U));
206 #else
207 #define XEmacPs_BdSetAddressRx(BdPtr, Addr)                        \
208     XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_OFFSET,              \
209     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) &           \
210     ~XEMACPS_RXBUF_ADD_MASK) | (UINTPTR)(Addr)))
211 #endif
212
213 /*****************************************************************************/
214 /**
215  * Set the BD's Status field (word 1).
216  *
217  * @param  BdPtr is the BD pointer to operate on
218  * @param  Data  is the value to write to BD's status field.
219  *
220  * @note
221  * C-style signature:
222  *    void XEmacPs_BdSetStatus(XEmacPs_Bd* BdPtr, UINTPTR Data)
223  *
224  *****************************************************************************/
225 #define XEmacPs_BdSetStatus(BdPtr, Data)                           \
226     XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET,              \
227     XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) | (Data))
228
229
230 /*****************************************************************************/
231 /**
232  * Retrieve the BD's Packet DMA transfer status word (word 1).
233  *
234  * @param  BdPtr is the BD pointer to operate on
235  *
236  * @return Status word
237  *
238  * @note
239  * C-style signature:
240  *    u32 XEmacPs_BdGetStatus(XEmacPs_Bd* BdPtr)
241  *
242  * Due to the BD bit layout differences in transmit and receive. User's
243  * caution is required.
244  *****************************************************************************/
245 #define XEmacPs_BdGetStatus(BdPtr)                                 \
246     XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET)
247
248
249 /*****************************************************************************/
250 /**
251  * Get the address (bits 0..31) of the BD's buffer address (word 0)
252  *
253  * @param  BdPtr is the BD pointer to operate on
254  *
255  * @note
256  * C-style signature:
257  *    UINTPTR XEmacPs_BdGetBufAddr(XEmacPs_Bd* BdPtr)
258  *
259  *****************************************************************************/
260 #ifdef __aarch64__
261 #define XEmacPs_BdGetBufAddr(BdPtr)                               \
262     (XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) |            \
263         (XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_HI_OFFSET)) << 32U)
264 #else
265 #define XEmacPs_BdGetBufAddr(BdPtr)                               \
266     (XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET))
267 #endif
268
269 /*****************************************************************************/
270 /**
271  * Set transfer length in bytes for the given BD. The length must be set each
272  * time a BD is submitted to hardware.
273  *
274  * @param  BdPtr is the BD pointer to operate on
275  * @param  LenBytes is the number of bytes to transfer.
276  *
277  * @note
278  * C-style signature:
279  *    void XEmacPs_BdSetLength(XEmacPs_Bd* BdPtr, u32 LenBytes)
280  *
281  *****************************************************************************/
282 #define XEmacPs_BdSetLength(BdPtr, LenBytes)                       \
283     XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET,              \
284     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
285     ~XEMACPS_TXBUF_LEN_MASK) | (LenBytes)))
286
287
288
289 /*****************************************************************************/
290 /**
291  * Set transfer length in bytes for the given BD. The length must be set each
292  * time a BD is submitted to hardware.
293  *
294  * @param  BdPtr is the BD pointer to operate on
295  * @param  LenBytes is the number of bytes to transfer.
296  *
297  * @note
298  * C-style signature:
299  *    void XEmacPs_BdSetLength(XEmacPs_Bd* BdPtr, u32 LenBytes)
300  *
301  *****************************************************************************/
302 #define XEmacPs_BdSetLength(BdPtr, LenBytes)                       \
303     XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET,              \
304     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
305     ~XEMACPS_TXBUF_LEN_MASK) | (LenBytes)))
306
307
308 /*****************************************************************************/
309 /**
310  * Retrieve the BD length field.
311  *
312  * For Tx channels, the returned value is the same as that written with
313  * XEmacPs_BdSetLength().
314  *
315  * For Rx channels, the returned value is the size of the received packet.
316  *
317  * @param  BdPtr is the BD pointer to operate on
318  *
319  * @return Length field processed by hardware or set by
320  *         XEmacPs_BdSetLength().
321  *
322  * @note
323  * C-style signature:
324  *    UINTPTR XEmacPs_BdGetLength(XEmacPs_Bd* BdPtr)
325  *    XEAMCPS_RXBUF_LEN_MASK is same as XEMACPS_TXBUF_LEN_MASK.
326  *
327  *****************************************************************************/
328 #define XEmacPs_BdGetLength(BdPtr)                                 \
329     (XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &            \
330     XEMACPS_RXBUF_LEN_MASK)
331
332 /*****************************************************************************/
333 /**
334  * Retrieve the RX frame size.
335  *
336  * The returned value is the size of the received packet.
337  * This API supports jumbo frame sizes if enabled.
338  *
339  * @param  BdPtr is the BD pointer to operate on
340  *
341  * @return Length field processed by hardware or set by
342  *         XEmacPs_BdSetLength().
343  *
344  * @note
345  * C-style signature:
346  *    UINTPTR XEmacPs_GetRxFrameSize(XEmacPs* InstancePtr, XEmacPs_Bd* BdPtr)
347  *    RxBufMask is dependent on whether jumbo is enabled or not.
348  *
349  *****************************************************************************/
350 #define XEmacPs_GetRxFrameSize(InstancePtr, BdPtr)                   \
351     (XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &            \
352     (InstancePtr)->RxBufMask)
353
354 /*****************************************************************************/
355 /**
356  * Test whether the given BD has been marked as the last BD of a packet.
357  *
358  * @param  BdPtr is the BD pointer to operate on
359  *
360  * @return TRUE if BD represents the "Last" BD of a packet, FALSE otherwise
361  *
362  * @note
363  * C-style signature:
364  *    UINTPTR XEmacPs_BdIsLast(XEmacPs_Bd* BdPtr)
365  *
366  *****************************************************************************/
367 #define XEmacPs_BdIsLast(BdPtr)                                    \
368     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
369     XEMACPS_RXBUF_EOF_MASK)!=0U ? TRUE : FALSE)
370
371
372 /*****************************************************************************/
373 /**
374  * Tell the DMA engine that the given transmit BD marks the end of the current
375  * packet to be processed.
376  *
377  * @param  BdPtr is the BD pointer to operate on
378  *
379  * @note
380  * C-style signature:
381  *    void XEmacPs_BdSetLast(XEmacPs_Bd* BdPtr)
382  *
383  *****************************************************************************/
384 #define XEmacPs_BdSetLast(BdPtr)                                   \
385     (XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET,             \
386     XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) |             \
387     XEMACPS_TXBUF_LAST_MASK))
388
389
390 /*****************************************************************************/
391 /**
392  * Tell the DMA engine that the current packet does not end with the given
393  * BD.
394  *
395  * @param  BdPtr is the BD pointer to operate on
396  *
397  * @note
398  * C-style signature:
399  *    void XEmacPs_BdClearLast(XEmacPs_Bd* BdPtr)
400  *
401  *****************************************************************************/
402 #define XEmacPs_BdClearLast(BdPtr)                                 \
403     (XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET,             \
404     XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &             \
405     ~XEMACPS_TXBUF_LAST_MASK))
406
407
408 /*****************************************************************************/
409 /**
410  * Set this bit to mark the last descriptor in the receive buffer descriptor
411  * list.
412  *
413  * @param  BdPtr is the BD pointer to operate on
414  *
415  * @note
416  * C-style signature:
417  *    void XEmacPs_BdSetRxWrap(XEmacPs_Bd* BdPtr)
418  *
419  *****************************************************************************/
420 /*#define XEmacPs_BdSetRxWrap(BdPtr)                                 \
421     (XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_OFFSET,             \
422     XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) |             \
423     XEMACPS_RXBUF_WRAP_MASK))
424 */
425
426 /*****************************************************************************/
427 /**
428  * Determine the wrap bit of the receive BD which indicates end of the
429  * BD list.
430  *
431  * @param  BdPtr is the BD pointer to operate on
432  *
433  * @note
434  * C-style signature:
435  *    u8 XEmacPs_BdIsRxWrap(XEmacPs_Bd* BdPtr)
436  *
437  *****************************************************************************/
438 #define XEmacPs_BdIsRxWrap(BdPtr)                                  \
439     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) &           \
440     XEMACPS_RXBUF_WRAP_MASK)!=0U ? TRUE : FALSE)
441
442
443 /*****************************************************************************/
444 /**
445  * Sets this bit to mark the last descriptor in the transmit buffer
446  * descriptor list.
447  *
448  * @param  BdPtr is the BD pointer to operate on
449  *
450  * @note
451  * C-style signature:
452  *    void XEmacPs_BdSetTxWrap(XEmacPs_Bd* BdPtr)
453  *
454  *****************************************************************************/
455 /*#define XEmacPs_BdSetTxWrap(BdPtr)                                 \
456     (XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET,             \
457     XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) |             \
458     XEMACPS_TXBUF_WRAP_MASK))
459 */
460
461 /*****************************************************************************/
462 /**
463  * Determine the wrap bit of the transmit BD which indicates end of the
464  * BD list.
465  *
466  * @param  BdPtr is the BD pointer to operate on
467  *
468  * @note
469  * C-style signature:
470  *    u8 XEmacPs_BdGetTxWrap(XEmacPs_Bd* BdPtr)
471  *
472  *****************************************************************************/
473 #define XEmacPs_BdIsTxWrap(BdPtr)                                  \
474     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
475     XEMACPS_TXBUF_WRAP_MASK)!=0U ? TRUE : FALSE)
476
477
478 /*****************************************************************************/
479 /*
480  * Must clear this bit to enable the MAC to write data to the receive
481  * buffer. Hardware sets this bit once it has successfully written a frame to
482  * memory. Once set, software has to clear the bit before the buffer can be
483  * used again. This macro clear the new bit of the receive BD.
484  *
485  * @param  BdPtr is the BD pointer to operate on
486  *
487  * @note
488  * C-style signature:
489  *    void XEmacPs_BdClearRxNew(XEmacPs_Bd* BdPtr)
490  *
491  *****************************************************************************/
492 #define XEmacPs_BdClearRxNew(BdPtr)                                \
493     (XEmacPs_BdWrite((BdPtr), XEMACPS_BD_ADDR_OFFSET,             \
494     XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) &             \
495     ~XEMACPS_RXBUF_NEW_MASK))
496
497
498 /*****************************************************************************/
499 /**
500  * Determine the new bit of the receive BD.
501  *
502  * @param  BdPtr is the BD pointer to operate on
503  *
504  * @note
505  * C-style signature:
506  *    UINTPTR XEmacPs_BdIsRxNew(XEmacPs_Bd* BdPtr)
507  *
508  *****************************************************************************/
509 #define XEmacPs_BdIsRxNew(BdPtr)                                   \
510     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_ADDR_OFFSET) &           \
511     XEMACPS_RXBUF_NEW_MASK)!=0U ? TRUE : FALSE)
512
513
514 /*****************************************************************************/
515 /**
516  * Software sets this bit to disable the buffer to be read by the hardware.
517  * Hardware sets this bit for the first buffer of a frame once it has been
518  * successfully transmitted. This macro sets this bit of transmit BD to avoid
519  * confusion.
520  *
521  * @param  BdPtr is the BD pointer to operate on
522  *
523  * @note
524  * C-style signature:
525  *    void XEmacPs_BdSetTxUsed(XEmacPs_Bd* BdPtr)
526  *
527  *****************************************************************************/
528 #define XEmacPs_BdSetTxUsed(BdPtr)                                 \
529     (XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET,             \
530     XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) |             \
531     XEMACPS_TXBUF_USED_MASK))
532
533
534 /*****************************************************************************/
535 /**
536  * Software clears this bit to enable the buffer to be read by the hardware.
537  * Hardware sets this bit for the first buffer of a frame once it has been
538  * successfully transmitted. This macro clears this bit of transmit BD.
539  *
540  * @param  BdPtr is the BD pointer to operate on
541  *
542  * @note
543  * C-style signature:
544  *    void XEmacPs_BdClearTxUsed(XEmacPs_Bd* BdPtr)
545  *
546  *****************************************************************************/
547 #define XEmacPs_BdClearTxUsed(BdPtr)                               \
548     (XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET,             \
549     XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &             \
550     ~XEMACPS_TXBUF_USED_MASK))
551
552
553 /*****************************************************************************/
554 /**
555  * Determine the used bit of the transmit BD.
556  *
557  * @param  BdPtr is the BD pointer to operate on
558  *
559  * @note
560  * C-style signature:
561  *    UINTPTR XEmacPs_BdIsTxUsed(XEmacPs_Bd* BdPtr)
562  *
563  *****************************************************************************/
564 #define XEmacPs_BdIsTxUsed(BdPtr)                                  \
565     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
566     XEMACPS_TXBUF_USED_MASK)!=0U ? TRUE : FALSE)
567
568
569 /*****************************************************************************/
570 /**
571  * Determine if a frame fails to be transmitted due to too many retries.
572  *
573  * @param  BdPtr is the BD pointer to operate on
574  *
575  * @note
576  * C-style signature:
577  *    UINTPTR XEmacPs_BdIsTxRetry(XEmacPs_Bd* BdPtr)
578  *
579  *****************************************************************************/
580 #define XEmacPs_BdIsTxRetry(BdPtr)                                 \
581     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
582     XEMACPS_TXBUF_RETRY_MASK)!=0U ? TRUE : FALSE)
583
584
585 /*****************************************************************************/
586 /**
587  * Determine if a frame fails to be transmitted due to data can not be
588  * feteched in time or buffers are exhausted.
589  *
590  * @param  BdPtr is the BD pointer to operate on
591  *
592  * @note
593  * C-style signature:
594  *    UINTPTR XEmacPs_BdIsTxUrun(XEmacPs_Bd* BdPtr)
595  *
596  *****************************************************************************/
597 #define XEmacPs_BdIsTxUrun(BdPtr)                                  \
598     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
599     XEMACPS_TXBUF_URUN_MASK)!=0U ? TRUE : FALSE)
600
601
602 /*****************************************************************************/
603 /**
604  * Determine if a frame fails to be transmitted due to buffer is exhausted
605  * mid-frame.
606  *
607  * @param  BdPtr is the BD pointer to operate on
608  *
609  * @note
610  * C-style signature:
611  *    UINTPTR XEmacPs_BdIsTxExh(XEmacPs_Bd* BdPtr)
612  *
613  *****************************************************************************/
614 #define XEmacPs_BdIsTxExh(BdPtr)                                   \
615     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
616     XEMACPS_TXBUF_EXH_MASK)!=0U ? TRUE : FALSE)
617
618
619 /*****************************************************************************/
620 /**
621  * Sets this bit, no CRC will be appended to the current frame. This control
622  * bit must be set for the first buffer in a frame and will be ignored for
623  * the subsequent buffers of a frame.
624  *
625  * @param  BdPtr is the BD pointer to operate on
626  *
627  * @note
628  * This bit must be clear when using the transmit checksum generation offload,
629  * otherwise checksum generation and substitution will not occur.
630  *
631  * C-style signature:
632  *    UINTPTR XEmacPs_BdSetTxNoCRC(XEmacPs_Bd* BdPtr)
633  *
634  *****************************************************************************/
635 #define XEmacPs_BdSetTxNoCRC(BdPtr)                                \
636     (XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET,             \
637     XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) |             \
638     XEMACPS_TXBUF_NOCRC_MASK))
639
640
641 /*****************************************************************************/
642 /**
643  * Clear this bit, CRC will be appended to the current frame. This control
644  * bit must be set for the first buffer in a frame and will be ignored for
645  * the subsequent buffers of a frame.
646  *
647  * @param  BdPtr is the BD pointer to operate on
648  *
649  * @note
650  * This bit must be clear when using the transmit checksum generation offload,
651  * otherwise checksum generation and substitution will not occur.
652  *
653  * C-style signature:
654  *    UINTPTR XEmacPs_BdClearTxNoCRC(XEmacPs_Bd* BdPtr)
655  *
656  *****************************************************************************/
657 #define XEmacPs_BdClearTxNoCRC(BdPtr)                              \
658     (XEmacPs_BdWrite((BdPtr), XEMACPS_BD_STAT_OFFSET,             \
659     XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &             \
660     ~XEMACPS_TXBUF_NOCRC_MASK))
661
662
663 /*****************************************************************************/
664 /**
665  * Determine the broadcast bit of the receive BD.
666  *
667  * @param  BdPtr is the BD pointer to operate on
668  *
669  * @note
670  * C-style signature:
671  *    UINTPTR XEmacPs_BdIsRxBcast(XEmacPs_Bd* BdPtr)
672  *
673  *****************************************************************************/
674 #define XEmacPs_BdIsRxBcast(BdPtr)                                 \
675     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
676     XEMACPS_RXBUF_BCAST_MASK)!=0U ? TRUE : FALSE)
677
678
679 /*****************************************************************************/
680 /**
681  * Determine the multicast hash bit of the receive BD.
682  *
683  * @param  BdPtr is the BD pointer to operate on
684  *
685  * @note
686  * C-style signature:
687  *    UINTPTR XEmacPs_BdIsRxMultiHash(XEmacPs_Bd* BdPtr)
688  *
689  *****************************************************************************/
690 #define XEmacPs_BdIsRxMultiHash(BdPtr)                             \
691     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
692     XEMACPS_RXBUF_MULTIHASH_MASK)!=0U ? TRUE : FALSE)
693
694
695 /*****************************************************************************/
696 /**
697  * Determine the unicast hash bit of the receive BD.
698  *
699  * @param  BdPtr is the BD pointer to operate on
700  *
701  * @note
702  * C-style signature:
703  *    UINTPTR XEmacPs_BdIsRxUniHash(XEmacPs_Bd* BdPtr)
704  *
705  *****************************************************************************/
706 #define XEmacPs_BdIsRxUniHash(BdPtr)                               \
707     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
708     XEMACPS_RXBUF_UNIHASH_MASK)!=0U ? TRUE : FALSE)
709
710
711 /*****************************************************************************/
712 /**
713  * Determine if the received frame is a VLAN Tagged frame.
714  *
715  * @param  BdPtr is the BD pointer to operate on
716  *
717  * @note
718  * C-style signature:
719  *    UINTPTR XEmacPs_BdIsRxVlan(XEmacPs_Bd* BdPtr)
720  *
721  *****************************************************************************/
722 #define XEmacPs_BdIsRxVlan(BdPtr)                                  \
723     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
724     XEMACPS_RXBUF_VLAN_MASK)!=0U ? TRUE : FALSE)
725
726
727 /*****************************************************************************/
728 /**
729  * Determine if the received frame has Type ID of 8100h and null VLAN
730  * identifier(Priority tag).
731  *
732  * @param  BdPtr is the BD pointer to operate on
733  *
734  * @note
735  * C-style signature:
736  *    UINTPTR XEmacPs_BdIsRxPri(XEmacPs_Bd* BdPtr)
737  *
738  *****************************************************************************/
739 #define XEmacPs_BdIsRxPri(BdPtr)                                   \
740     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
741     XEMACPS_RXBUF_PRI_MASK)!=0U ? TRUE : FALSE)
742
743
744 /*****************************************************************************/
745 /**
746  * Determine if the received frame's Concatenation Format Indicator (CFI) of
747  * the frames VLANTCI field was set.
748  *
749  * @param  BdPtr is the BD pointer to operate on
750  *
751  * @note
752  * C-style signature:
753  *    UINTPTR XEmacPs_BdIsRxCFI(XEmacPs_Bd* BdPtr)
754  *
755  *****************************************************************************/
756 #define XEmacPs_BdIsRxCFI(BdPtr)                                   \
757     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
758     XEMACPS_RXBUF_CFI_MASK)!=0U ? TRUE : FALSE)
759
760
761 /*****************************************************************************/
762 /**
763  * Determine the End Of Frame (EOF) bit of the receive BD.
764  *
765  * @param  BdPtr is the BD pointer to operate on
766  *
767  * @note
768  * C-style signature:
769  *    UINTPTR XEmacPs_BdGetRxEOF(XEmacPs_Bd* BdPtr)
770  *
771  *****************************************************************************/
772 #define XEmacPs_BdIsRxEOF(BdPtr)                                   \
773     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
774     XEMACPS_RXBUF_EOF_MASK)!=0U ? TRUE : FALSE)
775
776
777 /*****************************************************************************/
778 /**
779  * Determine the Start Of Frame (SOF) bit of the receive BD.
780  *
781  * @param  BdPtr is the BD pointer to operate on
782  *
783  * @note
784  * C-style signature:
785  *    UINTPTR XEmacPs_BdGetRxSOF(XEmacPs_Bd* BdPtr)
786  *
787  *****************************************************************************/
788 #define XEmacPs_BdIsRxSOF(BdPtr)                                   \
789     ((XEmacPs_BdRead((BdPtr), XEMACPS_BD_STAT_OFFSET) &           \
790     XEMACPS_RXBUF_SOF_MASK)!=0U ? TRUE : FALSE)
791
792
793 /************************** Function Prototypes ******************************/
794
795 #ifdef __cplusplus
796 }
797 #endif
798
799 #endif /* end of protection macro */