]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo_bsp/ps7_cortexa9_0/libsrc/emacps_v2_0/src/xemacps.h
827481edff11c32d09eae0034d1ea44e391024dc
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo_bsp / ps7_cortexa9_0 / libsrc / emacps_v2_0 / src / xemacps.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2010 - 2014 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.h
36 * @addtogroup emacps_v2_0
37 * @{
38 * @details
39  *
40  * The Xilinx Embedded Processor Block Ethernet driver.
41  *
42  * For a full description of XEMACPS features, please see the hardware spec.
43  * This driver supports the following features:
44  *   - Memory mapped access to host interface registers
45  *   - Statistics counter registers for RMON/MIB
46  *   - API for interrupt driven frame transfers for hardware configured DMA
47  *   - Virtual memory support
48  *   - Unicast, broadcast, and multicast receive address filtering
49  *   - Full and half duplex operation
50  *   - Automatic PAD & FCS insertion and stripping
51  *   - Flow control
52  *   - Support up to four 48bit addresses
53  *   - Address checking for four specific 48bit addresses
54  *   - VLAN frame support
55  *   - Pause frame support
56  *   - Large frame support up to 1536 bytes
57  *   - Checksum offload
58  *
59  * <b>Driver Description</b>
60  *
61  * The device driver enables higher layer software (e.g., an application) to
62  * communicate to the XEmacPs. The driver handles transmission and reception
63  * of Ethernet frames, as well as configuration and control. No pre or post
64  * processing of frame data is performed. The driver does not validate the
65  * contents of an incoming frame in addition to what has already occurred in
66  * hardware.
67  * A single device driver can support multiple devices even when those devices
68  * have significantly different configurations.
69  *
70  * <b>Initialization & Configuration</b>
71  *
72  * The XEmacPs_Config structure is used by the driver to configure itself.
73  * This configuration structure is typically created by the tool-chain based
74  * on hardware build properties.
75  *
76  * The driver instance can be initialized in
77  *
78  *   - XEmacPs_CfgInitialize(InstancePtr, CfgPtr, EffectiveAddress):  Uses a
79  *     configuration structure provided by the caller. If running in a system
80  *     with address translation, the provided virtual memory base address
81  *     replaces the physical address present in the configuration structure.
82  *
83  * The device supports DMA only as current development plan. No FIFO mode is
84  * supported. The driver expects to start the DMA channels and expects that
85  * the user has set up the buffer descriptor lists.
86  *
87  * <b>Interrupts and Asynchronous Callbacks</b>
88  *
89  * The driver has no dependencies on the interrupt controller. When an
90  * interrupt occurs, the handler will perform a small amount of
91  * housekeeping work, determine the source of the interrupt, and call the
92  * appropriate callback function. All callbacks are registered by the user
93  * level application.
94  *
95  * <b>Virtual Memory</b>
96  *
97  * All virtual to physical memory mappings must occur prior to accessing the
98  * driver API.
99  *
100  * For DMA transactions, user buffers supplied to the driver must be in terms
101  * of their physical address.
102  *
103  * <b>DMA</b>
104  *
105  * The DMA engine uses buffer descriptors (BDs) to describe Ethernet frames.
106  * These BDs are typically chained together into a list the hardware follows
107  * when transferring data in and out of the packet buffers. Each BD describes
108  * a memory region containing either a full or partial Ethernet packet.
109  *
110  * Interrupt coalescing is not suppoted from this built-in DMA engine.
111  *
112  * This API requires the user to understand how the DMA operates. The
113  * following paragraphs provide some explanation, but the user is encouraged
114  * to read documentation in xemacps_bdring.h as well as study example code
115  * that accompanies this driver.
116  *
117  * The API is designed to get BDs to and from the DMA engine in the most
118  * efficient means possible. The first step is to establish a  memory region
119  * to contain all BDs for a specific channel. This is done with
120  * XEmacPs_BdRingCreate(). This function sets up a BD ring that hardware will
121  * follow as BDs are processed. The ring will consist of a user defined number
122  * of BDs which will all be partially initialized. For example on the transmit
123  * channel, the driver will initialize all BDs' so that they are configured
124  * for transmit. The more fields that can be permanently setup at
125  * initialization, then the fewer accesses will be needed to each BD while
126  * the DMA engine is in operation resulting in better throughput and CPU
127  * utilization. The best case initialization would require the user to set
128  * only a frame buffer address and length prior to submitting the BD to the
129  * engine.
130  *
131  * BDs move through the engine with the help of functions
132  * XEmacPs_BdRingAlloc(), XEmacPs_BdRingToHw(), XEmacPs_BdRingFromHw(),
133  * and XEmacPs_BdRingFree().
134  * All these functions handle BDs that are in place. That is, there are no
135  * copies of BDs kept anywhere and any BD the user interacts with is an actual
136  * BD from the same ring hardware accesses.
137  *
138  * BDs in the ring go through a series of states as follows:
139  *   1. Idle. The driver controls BDs in this state.
140  *   2. The user has data to transfer. XEmacPs_BdRingAlloc() is called to
141  *      reserve BD(s). Once allocated, the user may setup the BD(s) with
142  *      frame buffer address, length, and other attributes. The user controls
143  *      BDs in this state.
144  *   3. The user submits BDs to the DMA engine with XEmacPs_BdRingToHw. BDs
145  *      in this state are either waiting to be processed by hardware, are in
146  *      process, or have been processed. The DMA engine controls BDs in this
147  *      state.
148  *   4. Processed BDs are retrieved with XEmacEpv_BdRingFromHw() by the
149  *      user. Once retrieved, the user can examine each BD for the outcome of
150  *      the DMA transfer. The user controls BDs in this state. After examining
151  *      the BDs the user calls XEmacPs_BdRingFree() which places the BDs back
152  *      into state 1.
153  *
154  * Each of the four BD accessor functions operate on a set of BDs. A set is
155  * defined as a segment of the BD ring consisting of one or more BDs. The user
156  * views the set as a pointer to the first BD along with the number of BDs for
157  * that set. The set can be navigated by using macros XEmacPs_BdNext(). The
158  * user must exercise extreme caution when changing BDs in a set as there is
159  * nothing to prevent doing a mBdNext past the end of the set and modifying a
160  * BD out of bounds.
161  *
162  * XEmacPs_BdRingAlloc() + XEmacPs_BdRingToHw(), as well as
163  * XEmacPs_BdRingFromHw() + XEmacPs_BdRingFree() are designed to be used in
164  * tandem. The same BD set retrieved with BdRingAlloc should be the same one
165  * provided to hardware with BdRingToHw. Same goes with BdRingFromHw and
166  * BdRIngFree.
167  *
168  * <b>Alignment & Data Cache Restrictions</b>
169  *
170  * Due to the design of the hardware, all RX buffers, BDs need to be 4-byte
171  * aligned. Please reference xemacps_bd.h for cache related macros.
172  *
173  * DMA Tx:
174  *
175  *   - If frame buffers exist in cached memory, then they must be flushed
176  *     prior to committing them to hardware.
177  *
178  * DMA Rx:
179  *
180  *   - If frame buffers exist in cached memory, then the cache must be
181  *     invalidated for the memory region containing the frame prior to data
182  *     access
183  *
184  * Both cache invalidate/flush are taken care of in driver code.
185  *
186  * <b>Buffer Copying</b>
187  *
188  * The driver is designed for a zero-copy buffer scheme. That is, the driver
189  * will not copy buffers. This avoids potential throughput bottlenecks within
190  * the driver. If byte copying is required, then the transfer will take longer
191  * to complete.
192  *
193  * <b>Checksum Offloading</b>
194  *
195  * The Embedded Processor Block Ethernet can be configured to perform IP, TCP
196  * and UDP checksum offloading in both receive and transmit directions.
197  *
198  * IP packets contain a 16-bit checksum field, which is the 16-bit 1s
199  * complement of the 1s complement sum of all 16-bit words in the header.
200  * TCP and UDP packets contain a 16-bit checksum field, which is the 16-bit
201  * 1s complement of the 1s complement sum of all 16-bit words in the header,
202  * the data and a conceptual pseudo header.
203  *
204  * To calculate these checksums in software requires each byte of the packet
205  * to be read. For TCP and UDP this can use a large amount of processing power.
206  * Offloading the checksum calculation to hardware can result in significant
207  * performance improvements.
208  *
209  * The transmit checksum offload is only available to use DMA in packet buffer
210  * mode. This is because the complete frame to be transmitted must be read
211  * into the packet buffer memory before the checksum can be calculated and
212  * written to the header at the beginning of the frame.
213  *
214  * For IP, TCP or UDP receive checksum offload to be useful, the operating
215  * system containing the protocol stack must be aware that this offload is
216  * available so that it can make use of the fact that the hardware has verified
217  * the checksum.
218  *
219  * When receive checksum offloading is enabled in the hardware, the IP header
220  * checksum is checked, where the packet meets the following criteria:
221  *
222  * 1. If present, the VLAN header must be four octets long and the CFI bit
223  *    must not be set.
224  * 2. Encapsulation must be RFC 894 Ethernet Type Encoding or RFC 1042 SNAP
225  *    encoding.
226  * 3. IP v4 packet.
227  * 4. IP header is of a valid length.
228  * 5. Good IP header checksum.
229  * 6. No IP fragmentation.
230  * 7. TCP or UDP packet.
231  *
232  * When an IP, TCP or UDP frame is received, the receive buffer descriptor
233  * gives an indication if the hardware was able to verify the checksums.
234  * There is also an indication if the frame had SNAP encapsulation. These
235  * indication bits will replace the type ID match indication bits when the
236  * receive checksum offload is enabled.
237  *
238  * If any of the checksums are verified incorrect by the hardware, the packet
239  * is discarded and the appropriate statistics counter incremented.
240  *
241  * <b>PHY Interfaces</b>
242  *
243  * RGMII 1.3 is the only interface supported.
244  *
245  * <b>Asserts</b>
246  *
247  * Asserts are used within all Xilinx drivers to enforce constraints on
248  * parameters. Asserts can be turned off on a system-wide basis by defining,
249  * at compile time, the NDEBUG identifier. By default, asserts are turned on
250  * and it is recommended that users leave asserts on during development. For
251  * deployment use -DNDEBUG compiler switch to remove assert code.
252  *
253  * @note
254  *
255  * Xilinx drivers are typically composed of two parts, one is the driver
256  * and the other is the adapter.  The driver is independent of OS and processor
257  * and is intended to be highly portable.  The adapter is OS-specific and
258  * facilitates communication between the driver and an OS.
259  * This driver is intended to be RTOS and processor independent. Any needs for
260  * dynamic memory management, threads or thread mutual exclusion, or cache
261  * control must be satisfied bythe layer above this driver.
262  *
263  * <pre>
264  * MODIFICATION HISTORY:
265  *
266  * Ver   Who  Date     Changes
267  * ----- ---- -------- -------------------------------------------------------
268  * 1.00a wsy  01/10/10 First release
269  * 1.00a asa  11/21/11 The function XEmacPs_BdRingFromHwTx in file
270  *                     xemacps_bdring.c is modified. Earlier it was checking for
271  *                     "BdLimit"(passed argument) number of BDs for finding out
272  *                     which BDs are successfully processed. Now one more check
273  *                     is added. It looks for BDs till the current BD pointer
274  *                     reaches HwTail. By doing this processing time is saved.
275  * 1.00a asa  01/24/12 The function XEmacPs_BdRingFromHwTx in file
276  *                     xemacps_bdring.c is modified. Now start of packet is
277  *                     searched for returning the number of BDs processed.
278  * 1.02a asa  11/05/12 Added a new API for deleting an entry from the HASH
279  *                     registers. Added a new API to set the bust length.
280  *                     Added some new hash-defines.
281  * 1.03a asa  01/23/12 Fix for CR #692702 which updates error handling for
282  *                     Rx errors. Under heavy Rx traffic, there will be a large
283  *                     number of errors related to receive buffer not available.
284  *                     Because of a HW bug (SI #692601), under such heavy errors,
285  *                     the Rx data path can become unresponsive. To reduce the
286  *                     probabilities for hitting this HW bug, the SW writes to
287  *                     bit 18 to flush a packet from Rx DPRAM immediately. The
288  *                     changes for it are done in the function
289  *                     XEmacPs_IntrHandler.
290  * 1.05a asa  09/23/13 Cache operations on BDs are not required and hence
291  *                     removed. It is expected that all BDs are allocated in
292  *                     from uncached area.
293  * 1.06a asa  11/02/13 Changed the value for XEMACPS_RXBUF_LEN_MASK from 0x3fff
294  *                              to 0x1fff. This fixes the CR#744902.
295  *                        Made changes in example file xemacps_example.h to fix compilation
296  *                        issues with iarcc compiler.
297  * 2.0   adk  10/12/13 Updated as per the New Tcl API's
298  * </pre>
299  *
300  ****************************************************************************/
301
302 #ifndef XEMACPS_H               /* prevent circular inclusions */
303 #define XEMACPS_H               /* by using protection macros */
304
305 #ifdef __cplusplus
306 extern "C" {
307 #endif
308
309 /***************************** Include Files ********************************/
310
311 #include "xil_types.h"
312 #include "xil_assert.h"
313 #include "xstatus.h"
314 #include "xemacps_hw.h"
315 #include "xemacps_bd.h"
316 #include "xemacps_bdring.h"
317
318 /************************** Constant Definitions ****************************/
319
320 /*
321  * Device information
322  */
323 #define XEMACPS_DEVICE_NAME     "xemacps"
324 #define XEMACPS_DEVICE_DESC     "Xilinx PS 10/100/1000 MAC"
325
326
327 /** @name Configuration options
328  *
329  * Device configuration options. See the XEmacPs_SetOptions(),
330  * XEmacPs_ClearOptions() and XEmacPs_GetOptions() for information on how to
331  * use options.
332  *
333  * The default state of the options are noted and are what the device and
334  * driver will be set to after calling XEmacPs_Reset() or
335  * XEmacPs_Initialize().
336  *
337  * @{
338  */
339
340 #define XEMACPS_PROMISC_OPTION               0x00000001
341 /**< Accept all incoming packets.
342  *   This option defaults to disabled (cleared) */
343
344 #define XEMACPS_FRAME1536_OPTION             0x00000002
345 /**< Frame larger than 1516 support for Tx & Rx.
346  *   This option defaults to disabled (cleared) */
347
348 #define XEMACPS_VLAN_OPTION                  0x00000004
349 /**< VLAN Rx & Tx frame support.
350  *   This option defaults to disabled (cleared) */
351
352 #define XEMACPS_FLOW_CONTROL_OPTION          0x00000010
353 /**< Enable recognition of flow control frames on Rx
354  *   This option defaults to enabled (set) */
355
356 #define XEMACPS_FCS_STRIP_OPTION             0x00000020
357 /**< Strip FCS and PAD from incoming frames. Note: PAD from VLAN frames is not
358  *   stripped.
359  *   This option defaults to enabled (set) */
360
361 #define XEMACPS_FCS_INSERT_OPTION            0x00000040
362 /**< Generate FCS field and add PAD automatically for outgoing frames.
363  *   This option defaults to disabled (cleared) */
364
365 #define XEMACPS_LENTYPE_ERR_OPTION           0x00000080
366 /**< Enable Length/Type error checking for incoming frames. When this option is
367  *   set, the MAC will filter frames that have a mismatched type/length field
368  *   and if XEMACPS_REPORT_RXERR_OPTION is set, the user is notified when these
369  *   types of frames are encountered. When this option is cleared, the MAC will
370  *   allow these types of frames to be received.
371  *
372  *   This option defaults to disabled (cleared) */
373
374 #define XEMACPS_TRANSMITTER_ENABLE_OPTION    0x00000100
375 /**< Enable the transmitter.
376  *   This option defaults to enabled (set) */
377
378 #define XEMACPS_RECEIVER_ENABLE_OPTION       0x00000200
379 /**< Enable the receiver
380  *   This option defaults to enabled (set) */
381
382 #define XEMACPS_BROADCAST_OPTION             0x00000400
383 /**< Allow reception of the broadcast address
384  *   This option defaults to enabled (set) */
385
386 #define XEMACPS_MULTICAST_OPTION             0x00000800
387 /**< Allows reception of multicast addresses programmed into hash
388  *   This option defaults to disabled (clear) */
389
390 #define XEMACPS_RX_CHKSUM_ENABLE_OPTION      0x00001000
391 /**< Enable the RX checksum offload
392  *   This option defaults to enabled (set) */
393
394 #define XEMACPS_TX_CHKSUM_ENABLE_OPTION      0x00002000
395 /**< Enable the TX checksum offload
396  *   This option defaults to enabled (set) */
397
398
399 #define XEMACPS_DEFAULT_OPTIONS                     \
400     (XEMACPS_FLOW_CONTROL_OPTION |                  \
401      XEMACPS_FCS_INSERT_OPTION |                    \
402      XEMACPS_FCS_STRIP_OPTION |                     \
403      XEMACPS_BROADCAST_OPTION |                     \
404      XEMACPS_LENTYPE_ERR_OPTION |                   \
405      XEMACPS_TRANSMITTER_ENABLE_OPTION |            \
406      XEMACPS_RECEIVER_ENABLE_OPTION |               \
407      XEMACPS_RX_CHKSUM_ENABLE_OPTION |              \
408      XEMACPS_TX_CHKSUM_ENABLE_OPTION)
409
410 /**< Default options set when device is initialized or reset */
411 /*@}*/
412
413 /** @name Callback identifiers
414  *
415  * These constants are used as parameters to XEmacPs_SetHandler()
416  * @{
417  */
418 #define XEMACPS_HANDLER_DMASEND 1
419 #define XEMACPS_HANDLER_DMARECV 2
420 #define XEMACPS_HANDLER_ERROR   3
421 /*@}*/
422
423 /* Constants to determine the configuration of the hardware device. They are
424  * used to allow the driver to verify it can operate with the hardware.
425  */
426 #define XEMACPS_MDIO_DIV_DFT    MDC_DIV_32 /**< Default MDIO clock divisor */
427
428 /* The next few constants help upper layers determine the size of memory
429  * pools used for Ethernet buffers and descriptor lists.
430  */
431 #define XEMACPS_MAC_ADDR_SIZE   6       /* size of Ethernet header */
432
433 #define XEMACPS_MTU             1500    /* max MTU size of Ethernet frame */
434 #define XEMACPS_HDR_SIZE        14      /* size of Ethernet header */
435 #define XEMACPS_HDR_VLAN_SIZE   18      /* size of Ethernet header with VLAN */
436 #define XEMACPS_TRL_SIZE        4       /* size of Ethernet trailer (FCS) */
437 #define XEMACPS_MAX_FRAME_SIZE       (XEMACPS_MTU + XEMACPS_HDR_SIZE + \
438         XEMACPS_TRL_SIZE)
439 #define XEMACPS_MAX_VLAN_FRAME_SIZE  (XEMACPS_MTU + XEMACPS_HDR_SIZE + \
440         XEMACPS_HDR_VLAN_SIZE + XEMACPS_TRL_SIZE)
441
442 /* DMACR Bust length hash defines */
443
444 #define XEMACPS_SINGLE_BURST    1
445 #define XEMACPS_4BYTE_BURST             4
446 #define XEMACPS_8BYTE_BURST             8
447 #define XEMACPS_16BYTE_BURST    16
448
449
450 /**************************** Type Definitions ******************************/
451 /** @name Typedefs for callback functions
452  *
453  * These callbacks are invoked in interrupt context.
454  * @{
455  */
456 /**
457  * Callback invoked when frame(s) have been sent or received in interrupt
458  * driven DMA mode. To set the send callback, invoke XEmacPs_SetHandler().
459  *
460  * @param CallBackRef is user data assigned when the callback was set.
461  *
462  * @note
463  * See xemacps_hw.h for bitmasks definitions and the device hardware spec for
464  * further information on their meaning.
465  *
466  */
467 typedef void (*XEmacPs_Handler) (void *CallBackRef);
468
469 /**
470  * Callback when an asynchronous error occurs. To set this callback, invoke
471  * XEmacPs_SetHandler() with XEMACPS_HANDLER_ERROR in the HandlerType
472  * paramter.
473  *
474  * @param CallBackRef is user data assigned when the callback was set.
475  * @param Direction defines either receive or transmit error(s) has occurred.
476  * @param ErrorWord definition varies with Direction
477  *
478  */
479 typedef void (*XEmacPs_ErrHandler) (void *CallBackRef, u8 Direction,
480                                      u32 ErrorWord);
481
482 /*@}*/
483
484 /**
485  * This typedef contains configuration information for a device.
486  */
487 typedef struct {
488         u16 DeviceId;   /**< Unique ID  of device */
489         u32 BaseAddress;/**< Physical base address of IPIF registers */
490 } XEmacPs_Config;
491
492
493 /**
494  * The XEmacPs driver instance data. The user is required to allocate a
495  * structure of this type for every XEmacPs device in the system. A pointer
496  * to a structure of this type is then passed to the driver API functions.
497  */
498 typedef struct XEmacPs {
499         XEmacPs_Config Config;  /* Hardware configuration */
500         u32 IsStarted;          /* Device is currently started */
501         u32 IsReady;            /* Device is initialized and ready */
502         u32 Options;            /* Current options word */
503
504         XEmacPs_BdRing TxBdRing;        /* Transmit BD ring */
505         XEmacPs_BdRing RxBdRing;        /* Receive BD ring */
506
507         XEmacPs_Handler SendHandler;
508         XEmacPs_Handler RecvHandler;
509         void *SendRef;
510         void *RecvRef;
511
512         XEmacPs_ErrHandler ErrorHandler;
513         void *ErrorRef;
514
515 } XEmacPs;
516
517
518 /***************** Macros (Inline Functions) Definitions ********************/
519
520 /****************************************************************************/
521 /**
522 * Retrieve the Tx ring object. This object can be used in the various Ring
523 * API functions.
524 *
525 * @param  InstancePtr is the DMA channel to operate on.
526 *
527 * @return TxBdRing attribute
528 *
529 * @note
530 * C-style signature:
531 *    XEmacPs_BdRing XEmacPs_GetTxRing(XEmacPs *InstancePtr)
532 *
533 *****************************************************************************/
534 #define XEmacPs_GetTxRing(InstancePtr) ((InstancePtr)->TxBdRing)
535
536 /****************************************************************************/
537 /**
538 * Retrieve the Rx ring object. This object can be used in the various Ring
539 * API functions.
540 *
541 * @param  InstancePtr is the DMA channel to operate on.
542 *
543 * @return RxBdRing attribute
544 *
545 * @note
546 * C-style signature:
547 *    XEmacPs_BdRing XEmacPs_GetRxRing(XEmacPs *InstancePtr)
548 *
549 *****************************************************************************/
550 #define XEmacPs_GetRxRing(InstancePtr) ((InstancePtr)->RxBdRing)
551
552 /****************************************************************************/
553 /**
554 *
555 * Enable interrupts specified in <i>Mask</i>. The corresponding interrupt for
556 * each bit set to 1 in <i>Mask</i>, will be enabled.
557 *
558 * @param InstancePtr is a pointer to the instance to be worked on.
559 * @param Mask contains a bit mask of interrupts to enable. The mask can
560 *        be formed using a set of bitwise or'd values.
561 *
562 * @note
563 * The state of the transmitter and receiver are not modified by this function.
564 * C-style signature
565 *     void XEmacPs_IntEnable(XEmacPs *InstancePtr, u32 Mask)
566 *
567 *****************************************************************************/
568 #define XEmacPs_IntEnable(InstancePtr, Mask)                            \
569         XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress,             \
570                 XEMACPS_IER_OFFSET,                                     \
571                 (Mask & XEMACPS_IXR_ALL_MASK));
572
573 /****************************************************************************/
574 /**
575 *
576 * Disable interrupts specified in <i>Mask</i>. The corresponding interrupt for
577 * each bit set to 1 in <i>Mask</i>, will be enabled.
578 *
579 * @param InstancePtr is a pointer to the instance to be worked on.
580 * @param Mask contains a bit mask of interrupts to disable. The mask can
581 *        be formed using a set of bitwise or'd values.
582 *
583 * @note
584 * The state of the transmitter and receiver are not modified by this function.
585 * C-style signature
586 *     void XEmacPs_IntDisable(XEmacPs *InstancePtr, u32 Mask)
587 *
588 *****************************************************************************/
589 #define XEmacPs_IntDisable(InstancePtr, Mask)                           \
590         XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress,             \
591                 XEMACPS_IDR_OFFSET,                                     \
592                 (Mask & XEMACPS_IXR_ALL_MASK));
593
594 /****************************************************************************/
595 /**
596 *
597 * This macro triggers trasmit circuit to send data currently in TX buffer(s).
598 *
599 * @param InstancePtr is a pointer to the XEmacPs instance to be worked on.
600 *
601 * @return
602 *
603 * @note
604 *
605 * Signature: void XEmacPs_Transmit(XEmacPs *InstancePtr)
606 *
607 *****************************************************************************/
608 #define XEmacPs_Transmit(InstancePtr)                              \
609         XEmacPs_WriteReg(InstancePtr->Config.BaseAddress,          \
610         XEMACPS_NWCTRL_OFFSET,                                     \
611         (XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,          \
612         XEMACPS_NWCTRL_OFFSET) | XEMACPS_NWCTRL_STARTTX_MASK))
613
614 /****************************************************************************/
615 /**
616 *
617 * This macro determines if the device is configured with checksum offloading
618 * on the receive channel
619 *
620 * @param InstancePtr is a pointer to the XEmacPs instance to be worked on.
621 *
622 * @return
623 *
624 * Boolean TRUE if the device is configured with checksum offloading, or
625 * FALSE otherwise.
626 *
627 * @note
628 *
629 * Signature: u32 XEmacPs_IsRxCsum(XEmacPs *InstancePtr)
630 *
631 *****************************************************************************/
632 #define XEmacPs_IsRxCsum(InstancePtr)                                     \
633         ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress,             \
634           XEMACPS_NWCFG_OFFSET) & XEMACPS_NWCFG_RXCHKSUMEN_MASK)         \
635           ? TRUE : FALSE)
636
637 /****************************************************************************/
638 /**
639 *
640 * This macro determines if the device is configured with checksum offloading
641 * on the transmit channel
642 *
643 * @param InstancePtr is a pointer to the XEmacPs instance to be worked on.
644 *
645 * @return
646 *
647 * Boolean TRUE if the device is configured with checksum offloading, or
648 * FALSE otherwise.
649 *
650 * @note
651 *
652 * Signature: u32 XEmacPs_IsTxCsum(XEmacPs *InstancePtr)
653 *
654 *****************************************************************************/
655 #define XEmacPs_IsTxCsum(InstancePtr)                                     \
656         ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress,              \
657           XEMACPS_DMACR_OFFSET) & XEMACPS_DMACR_TCPCKSUM_MASK)           \
658           ? TRUE : FALSE)
659
660 /************************** Function Prototypes *****************************/
661
662 /*
663  * Initialization functions in xemacps.c
664  */
665 int XEmacPs_CfgInitialize(XEmacPs *InstancePtr, XEmacPs_Config *CfgPtr,
666                            u32 EffectiveAddress);
667 void XEmacPs_Start(XEmacPs *InstancePtr);
668 void XEmacPs_Stop(XEmacPs *InstancePtr);
669 void XEmacPs_Reset(XEmacPs *InstancePtr);
670
671 /*
672  * Lookup configuration in xemacps_sinit.c
673  */
674 XEmacPs_Config *XEmacPs_LookupConfig(u16 DeviceId);
675
676 /*
677  * Interrupt-related functions in xemacps_intr.c
678  * DMA only and FIFO is not supported. This DMA does not support coalescing.
679  */
680 int XEmacPs_SetHandler(XEmacPs *InstancePtr, u32 HandlerType,
681                         void *FuncPtr, void *CallBackRef);
682 void XEmacPs_IntrHandler(void *InstancePtr);
683
684 /*
685  * MAC configuration/control functions in XEmacPs_control.c
686  */
687 int XEmacPs_SetOptions(XEmacPs *InstancePtr, u32 Options);
688 int XEmacPs_ClearOptions(XEmacPs *InstancePtr, u32 Options);
689 u32 XEmacPs_GetOptions(XEmacPs *InstancePtr);
690
691 int XEmacPs_SetMacAddress(XEmacPs *InstancePtr, void *AddressPtr, u8 Index);
692 void XEmacPs_GetMacAddress(XEmacPs *InstancePtr, void *AddressPtr, u8 Index);
693
694 int XEmacPs_SetHash(XEmacPs *InstancePtr, void *AddressPtr);
695 void XEmacPs_ClearHash(XEmacPs *InstancePtr);
696 void XEmacPs_GetHash(XEmacPs *InstancePtr, void *AddressPtr);
697
698 void XEmacPs_SetMdioDivisor(XEmacPs *InstancePtr,
699                                 XEmacPs_MdcDiv Divisor);
700 void XEmacPs_SetOperatingSpeed(XEmacPs *InstancePtr, u16 Speed);
701 u16 XEmacPs_GetOperatingSpeed(XEmacPs *InstancePtr);
702 int XEmacPs_PhyRead(XEmacPs *InstancePtr, u32 PhyAddress,
703                      u32 RegisterNum, u16 *PhyDataPtr);
704 int XEmacPs_PhyWrite(XEmacPs *InstancePtr, u32 PhyAddress,
705                       u32 RegisterNum, u16 PhyData);
706 int XEmacPs_SetTypeIdCheck(XEmacPs *InstancePtr, u32 Id_Check, u8 Index);
707
708 int XEmacPs_SendPausePacket(XEmacPs *InstancePtr);
709 void XEmacPs_DMABLengthUpdate(XEmacPs *InstancePtr, int BLength);
710
711 #ifdef __cplusplus
712 }
713 #endif
714
715 #endif /* end of protection macro */
716 /** @} */