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