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