1 /******************************************************************************
3 * Copyright (C) 2010 - 2015 Xilinx, Inc. All rights reserved.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
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
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.
31 ******************************************************************************/
32 /****************************************************************************/
37 * The Xilinx Embedded Processor Block Ethernet driver.
39 * For a full description of XEMACPS features, please see the hardware spec.
40 * This driver supports the following features:
41 * - Memory mapped access to host interface registers
42 * - Statistics counter registers for RMON/MIB
43 * - API for interrupt driven frame transfers for hardware configured DMA
44 * - Virtual memory support
45 * - Unicast, broadcast, and multicast receive address filtering
46 * - Full and half duplex operation
47 * - Automatic PAD & FCS insertion and stripping
49 * - Support up to four 48bit addresses
50 * - Address checking for four specific 48bit addresses
51 * - VLAN frame support
52 * - Pause frame support
53 * - Large frame support up to 1536 bytes
56 * <b>Driver Description</b>
58 * The device driver enables higher layer software (e.g., an application) to
59 * communicate to the XEmacPs. The driver handles transmission and reception
60 * of Ethernet frames, as well as configuration and control. No pre or post
61 * processing of frame data is performed. The driver does not validate the
62 * contents of an incoming frame in addition to what has already occurred in
64 * A single device driver can support multiple devices even when those devices
65 * have significantly different configurations.
67 * <b>Initialization & Configuration</b>
69 * The XEmacPs_Config structure is used by the driver to configure itself.
70 * This configuration structure is typically created by the tool-chain based
71 * on hardware build properties.
73 * The driver instance can be initialized in
75 * - XEmacPs_CfgInitialize(InstancePtr, CfgPtr, EffectiveAddress): Uses a
76 * configuration structure provided by the caller. If running in a system
77 * with address translation, the provided virtual memory base address
78 * replaces the physical address present in the configuration structure.
80 * The device supports DMA only as current development plan. No FIFO mode is
81 * supported. The driver expects to start the DMA channels and expects that
82 * the user has set up the buffer descriptor lists.
84 * <b>Interrupts and Asynchronous Callbacks</b>
86 * The driver has no dependencies on the interrupt controller. When an
87 * interrupt occurs, the handler will perform a small amount of
88 * housekeeping work, determine the source of the interrupt, and call the
89 * appropriate callback function. All callbacks are registered by the user
92 * <b>Virtual Memory</b>
94 * All virtual to physical memory mappings must occur prior to accessing the
97 * For DMA transactions, user buffers supplied to the driver must be in terms
98 * of their physical address.
102 * The DMA engine uses buffer descriptors (BDs) to describe Ethernet frames.
103 * These BDs are typically chained together into a list the hardware follows
104 * when transferring data in and out of the packet buffers. Each BD describes
105 * a memory region containing either a full or partial Ethernet packet.
107 * Interrupt coalescing is not suppoted from this built-in DMA engine.
109 * This API requires the user to understand how the DMA operates. The
110 * following paragraphs provide some explanation, but the user is encouraged
111 * to read documentation in xemacps_bdring.h as well as study example code
112 * that accompanies this driver.
114 * The API is designed to get BDs to and from the DMA engine in the most
115 * efficient means possible. The first step is to establish a memory region
116 * to contain all BDs for a specific channel. This is done with
117 * XEmacPs_BdRingCreate(). This function sets up a BD ring that hardware will
118 * follow as BDs are processed. The ring will consist of a user defined number
119 * of BDs which will all be partially initialized. For example on the transmit
120 * channel, the driver will initialize all BDs' so that they are configured
121 * for transmit. The more fields that can be permanently setup at
122 * initialization, then the fewer accesses will be needed to each BD while
123 * the DMA engine is in operation resulting in better throughput and CPU
124 * utilization. The best case initialization would require the user to set
125 * only a frame buffer address and length prior to submitting the BD to the
128 * BDs move through the engine with the help of functions
129 * XEmacPs_BdRingAlloc(), XEmacPs_BdRingToHw(), XEmacPs_BdRingFromHw(),
130 * and XEmacPs_BdRingFree().
131 * All these functions handle BDs that are in place. That is, there are no
132 * copies of BDs kept anywhere and any BD the user interacts with is an actual
133 * BD from the same ring hardware accesses.
135 * BDs in the ring go through a series of states as follows:
136 * 1. Idle. The driver controls BDs in this state.
137 * 2. The user has data to transfer. XEmacPs_BdRingAlloc() is called to
138 * reserve BD(s). Once allocated, the user may setup the BD(s) with
139 * frame buffer address, length, and other attributes. The user controls
141 * 3. The user submits BDs to the DMA engine with XEmacPs_BdRingToHw. BDs
142 * in this state are either waiting to be processed by hardware, are in
143 * process, or have been processed. The DMA engine controls BDs in this
145 * 4. Processed BDs are retrieved with XEmacEpv_BdRingFromHw() by the
146 * user. Once retrieved, the user can examine each BD for the outcome of
147 * the DMA transfer. The user controls BDs in this state. After examining
148 * the BDs the user calls XEmacPs_BdRingFree() which places the BDs back
151 * Each of the four BD accessor functions operate on a set of BDs. A set is
152 * defined as a segment of the BD ring consisting of one or more BDs. The user
153 * views the set as a pointer to the first BD along with the number of BDs for
154 * that set. The set can be navigated by using macros XEmacPs_BdNext(). The
155 * user must exercise extreme caution when changing BDs in a set as there is
156 * nothing to prevent doing a mBdNext past the end of the set and modifying a
159 * XEmacPs_BdRingAlloc() + XEmacPs_BdRingToHw(), as well as
160 * XEmacPs_BdRingFromHw() + XEmacPs_BdRingFree() are designed to be used in
161 * tandem. The same BD set retrieved with BdRingAlloc should be the same one
162 * provided to hardware with BdRingToHw. Same goes with BdRingFromHw and
165 * <b>Alignment & Data Cache Restrictions</b>
167 * Due to the design of the hardware, all RX buffers, BDs need to be 4-byte
168 * aligned. Please reference xemacps_bd.h for cache related macros.
172 * - If frame buffers exist in cached memory, then they must be flushed
173 * prior to committing them to hardware.
177 * - If frame buffers exist in cached memory, then the cache must be
178 * invalidated for the memory region containing the frame prior to data
181 * Both cache invalidate/flush are taken care of in driver code.
183 * <b>Buffer Copying</b>
185 * The driver is designed for a zero-copy buffer scheme. That is, the driver
186 * will not copy buffers. This avoids potential throughput bottlenecks within
187 * the driver. If byte copying is required, then the transfer will take longer
190 * <b>Checksum Offloading</b>
192 * The Embedded Processor Block Ethernet can be configured to perform IP, TCP
193 * and UDP checksum offloading in both receive and transmit directions.
195 * IP packets contain a 16-bit checksum field, which is the 16-bit 1s
196 * complement of the 1s complement sum of all 16-bit words in the header.
197 * TCP and UDP packets contain a 16-bit checksum field, which is the 16-bit
198 * 1s complement of the 1s complement sum of all 16-bit words in the header,
199 * the data and a conceptual pseudo header.
201 * To calculate these checksums in software requires each byte of the packet
202 * to be read. For TCP and UDP this can use a large amount of processing power.
203 * Offloading the checksum calculation to hardware can result in significant
204 * performance improvements.
206 * The transmit checksum offload is only available to use DMA in packet buffer
207 * mode. This is because the complete frame to be transmitted must be read
208 * into the packet buffer memory before the checksum can be calculated and
209 * written to the header at the beginning of the frame.
211 * For IP, TCP or UDP receive checksum offload to be useful, the operating
212 * system containing the protocol stack must be aware that this offload is
213 * available so that it can make use of the fact that the hardware has verified
216 * When receive checksum offloading is enabled in the hardware, the IP header
217 * checksum is checked, where the packet meets the following criteria:
219 * 1. If present, the VLAN header must be four octets long and the CFI bit
221 * 2. Encapsulation must be RFC 894 Ethernet Type Encoding or RFC 1042 SNAP
224 * 4. IP header is of a valid length.
225 * 5. Good IP header checksum.
226 * 6. No IP fragmentation.
227 * 7. TCP or UDP packet.
229 * When an IP, TCP or UDP frame is received, the receive buffer descriptor
230 * gives an indication if the hardware was able to verify the checksums.
231 * There is also an indication if the frame had SNAP encapsulation. These
232 * indication bits will replace the type ID match indication bits when the
233 * receive checksum offload is enabled.
235 * If any of the checksums are verified incorrect by the hardware, the packet
236 * is discarded and the appropriate statistics counter incremented.
238 * <b>PHY Interfaces</b>
240 * RGMII 1.3 is the only interface supported.
244 * Asserts are used within all Xilinx drivers to enforce constraints on
245 * parameters. Asserts can be turned off on a system-wide basis by defining,
246 * at compile time, the NDEBUG identifier. By default, asserts are turned on
247 * and it is recommended that users leave asserts on during development. For
248 * deployment use -DNDEBUG compiler switch to remove assert code.
252 * Xilinx drivers are typically composed of two parts, one is the driver
253 * and the other is the adapter. The driver is independent of OS and processor
254 * and is intended to be highly portable. The adapter is OS-specific and
255 * facilitates communication between the driver and an OS.
256 * This driver is intended to be RTOS and processor independent. Any needs for
257 * dynamic memory management, threads or thread mutual exclusion, or cache
258 * control must be satisfied bythe layer above this driver.
261 * MODIFICATION HISTORY:
263 * Ver Who Date Changes
264 * ----- ---- -------- -------------------------------------------------------
265 * 1.00a wsy 01/10/10 First release
266 * 1.00a asa 11/21/11 The function XEmacPs_BdRingFromHwTx in file
267 * xemacps_bdring.c is modified. Earlier it was checking for
268 * "BdLimit"(passed argument) number of BDs for finding out
269 * which BDs are successfully processed. Now one more check
270 * is added. It looks for BDs till the current BD pointer
271 * reaches HwTail. By doing this processing time is saved.
272 * 1.00a asa 01/24/12 The function XEmacPs_BdRingFromHwTx in file
273 * xemacps_bdring.c is modified. Now start of packet is
274 * searched for returning the number of BDs processed.
275 * 1.02a asa 11/05/12 Added a new API for deleting an entry from the HASH
276 * registers. Added a new API to set the bust length.
277 * Added some new hash-defines.
278 * 1.03a asa 01/23/12 Fix for CR #692702 which updates error handling for
279 * Rx errors. Under heavy Rx traffic, there will be a large
280 * number of errors related to receive buffer not available.
281 * Because of a HW bug (SI #692601), under such heavy errors,
282 * the Rx data path can become unresponsive. To reduce the
283 * probabilities for hitting this HW bug, the SW writes to
284 * bit 18 to flush a packet from Rx DPRAM immediately. The
285 * changes for it are done in the function
286 * XEmacPs_IntrHandler.
287 * 1.05a asa 09/23/13 Cache operations on BDs are not required and hence
288 * removed. It is expected that all BDs are allocated in
289 * from uncached area.
290 * 1.06a asa 11/02/13 Changed the value for XEMACPS_RXBUF_LEN_MASK from 0x3fff
291 * to 0x1fff. This fixes the CR#744902.
292 * Made changes in example file xemacps_example.h to fix compilation
293 * issues with iarcc compiler.
294 * 2.0 adk 10/12/13 Updated as per the New Tcl API's
295 * 2.1 adk 11/08/14 Fixed the CR#811288. Changes are made in the driver tcl file.
296 * 2.1 bss 09/08/14 Modified driver tcl to fix CR#820349 to export phy
297 * address in xparameters.h when GMII to RGMII converter
299 * 2.1 srt 07/15/14 Add support for Zynq Ultrascale Mp GEM specification and 64-bit
301 * 2.2 adk 29/10/14 Fixed CR#827686 when PCS/PMA core is configured with
302 * 1000BASE-X mode export proper values to the xparameters.h
303 * file. Changes are made in the driver tcl file.
304 * 3.0 adk 08/1/15 Don't include gem in peripheral test when gem is
305 * configured with PCS/PMA Core. Changes are made in the
306 * test app tcl(CR:827686).
307 * 3.0 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
308 * 3.0 hk 03/18/15 Added support for jumbo frames. Increase AHB burst.
309 * Disable extended mode. Perform all 64 bit changes under
311 * Remove "used bit set" from TX error interrupt masks.
314 ****************************************************************************/
316 #ifndef XEMACPS_H /* prevent circular inclusions */
317 #define XEMACPS_H /* by using protection macros */
323 /***************************** Include Files ********************************/
325 #include "xil_types.h"
326 #include "xil_assert.h"
328 #include "xemacps_hw.h"
329 #include "xemacps_bd.h"
330 #include "xemacps_bdring.h"
332 /************************** Constant Definitions ****************************/
337 #define XEMACPS_DEVICE_NAME "xemacps"
338 #define XEMACPS_DEVICE_DESC "Xilinx PS 10/100/1000 MAC"
341 /** @name Configuration options
343 * Device configuration options. See the XEmacPs_SetOptions(),
344 * XEmacPs_ClearOptions() and XEmacPs_GetOptions() for information on how to
347 * The default state of the options are noted and are what the device and
348 * driver will be set to after calling XEmacPs_Reset() or
349 * XEmacPs_Initialize().
354 #define XEMACPS_PROMISC_OPTION 0x00000001U
355 /**< Accept all incoming packets.
356 * This option defaults to disabled (cleared) */
358 #define XEMACPS_FRAME1536_OPTION 0x00000002U
359 /**< Frame larger than 1516 support for Tx & Rx.
360 * This option defaults to disabled (cleared) */
362 #define XEMACPS_VLAN_OPTION 0x00000004U
363 /**< VLAN Rx & Tx frame support.
364 * This option defaults to disabled (cleared) */
366 #define XEMACPS_FLOW_CONTROL_OPTION 0x00000010U
367 /**< Enable recognition of flow control frames on Rx
368 * This option defaults to enabled (set) */
370 #define XEMACPS_FCS_STRIP_OPTION 0x00000020U
371 /**< Strip FCS and PAD from incoming frames. Note: PAD from VLAN frames is not
373 * This option defaults to enabled (set) */
375 #define XEMACPS_FCS_INSERT_OPTION 0x00000040U
376 /**< Generate FCS field and add PAD automatically for outgoing frames.
377 * This option defaults to disabled (cleared) */
379 #define XEMACPS_LENTYPE_ERR_OPTION 0x00000080U
380 /**< Enable Length/Type error checking for incoming frames. When this option is
381 * set, the MAC will filter frames that have a mismatched type/length field
382 * and if XEMACPS_REPORT_RXERR_OPTION is set, the user is notified when these
383 * types of frames are encountered. When this option is cleared, the MAC will
384 * allow these types of frames to be received.
386 * This option defaults to disabled (cleared) */
388 #define XEMACPS_TRANSMITTER_ENABLE_OPTION 0x00000100U
389 /**< Enable the transmitter.
390 * This option defaults to enabled (set) */
392 #define XEMACPS_RECEIVER_ENABLE_OPTION 0x00000200U
393 /**< Enable the receiver
394 * This option defaults to enabled (set) */
396 #define XEMACPS_BROADCAST_OPTION 0x00000400U
397 /**< Allow reception of the broadcast address
398 * This option defaults to enabled (set) */
400 #define XEMACPS_MULTICAST_OPTION 0x00000800U
401 /**< Allows reception of multicast addresses programmed into hash
402 * This option defaults to disabled (clear) */
404 #define XEMACPS_RX_CHKSUM_ENABLE_OPTION 0x00001000U
405 /**< Enable the RX checksum offload
406 * This option defaults to enabled (set) */
408 #define XEMACPS_TX_CHKSUM_ENABLE_OPTION 0x00002000U
409 /**< Enable the TX checksum offload
410 * This option defaults to enabled (set) */
412 #define XEMACPS_JUMBO_ENABLE_OPTION 0x00004000U
414 #define XEMACPS_DEFAULT_OPTIONS \
415 ((u32)XEMACPS_FLOW_CONTROL_OPTION | \
416 (u32)XEMACPS_FCS_INSERT_OPTION | \
417 (u32)XEMACPS_FCS_STRIP_OPTION | \
418 (u32)XEMACPS_BROADCAST_OPTION | \
419 (u32)XEMACPS_LENTYPE_ERR_OPTION | \
420 (u32)XEMACPS_TRANSMITTER_ENABLE_OPTION | \
421 (u32)XEMACPS_RECEIVER_ENABLE_OPTION | \
422 (u32)XEMACPS_RX_CHKSUM_ENABLE_OPTION | \
423 (u32)XEMACPS_TX_CHKSUM_ENABLE_OPTION)
425 /**< Default options set when device is initialized or reset */
428 /** @name Callback identifiers
430 * These constants are used as parameters to XEmacPs_SetHandler()
433 #define XEMACPS_HANDLER_DMASEND 1U
434 #define XEMACPS_HANDLER_DMARECV 2U
435 #define XEMACPS_HANDLER_ERROR 3U
438 /* Constants to determine the configuration of the hardware device. They are
439 * used to allow the driver to verify it can operate with the hardware.
441 #define XEMACPS_MDIO_DIV_DFT MDC_DIV_32 /**< Default MDIO clock divisor */
443 /* The next few constants help upper layers determine the size of memory
444 * pools used for Ethernet buffers and descriptor lists.
446 #define XEMACPS_MAC_ADDR_SIZE 6U /* size of Ethernet header */
448 #define XEMACPS_MTU 1500U /* max MTU size of Ethernet frame */
449 #define XEMACPS_MTU_JUMBO 10240U /* max MTU size of jumbo frame */
450 #define XEMACPS_HDR_SIZE 14U /* size of Ethernet header */
451 #define XEMACPS_HDR_VLAN_SIZE 18U /* size of Ethernet header with VLAN */
452 #define XEMACPS_TRL_SIZE 4U /* size of Ethernet trailer (FCS) */
453 #define XEMACPS_MAX_FRAME_SIZE (XEMACPS_MTU + XEMACPS_HDR_SIZE + \
455 #define XEMACPS_MAX_VLAN_FRAME_SIZE (XEMACPS_MTU + XEMACPS_HDR_SIZE + \
456 XEMACPS_HDR_VLAN_SIZE + XEMACPS_TRL_SIZE)
457 #define XEMACPS_MAX_VLAN_FRAME_SIZE_JUMBO (XEMACPS_MTU_JUMBO + XEMACPS_HDR_SIZE + \
458 XEMACPS_HDR_VLAN_SIZE + XEMACPS_TRL_SIZE)
460 /* DMACR Bust length hash defines */
462 #define XEMACPS_SINGLE_BURST 0x00000001
463 #define XEMACPS_4BYTE_BURST 0x00000004
464 #define XEMACPS_8BYTE_BURST 0x00000008
465 #define XEMACPS_16BYTE_BURST 0x00000010
468 /**************************** Type Definitions ******************************/
469 /** @name Typedefs for callback functions
471 * These callbacks are invoked in interrupt context.
475 * Callback invoked when frame(s) have been sent or received in interrupt
476 * driven DMA mode. To set the send callback, invoke XEmacPs_SetHandler().
478 * @param CallBackRef is user data assigned when the callback was set.
481 * See xemacps_hw.h for bitmasks definitions and the device hardware spec for
482 * further information on their meaning.
485 typedef void (*XEmacPs_Handler) (void *CallBackRef);
488 * Callback when an asynchronous error occurs. To set this callback, invoke
489 * XEmacPs_SetHandler() with XEMACPS_HANDLER_ERROR in the HandlerType
492 * @param CallBackRef is user data assigned when the callback was set.
493 * @param Direction defines either receive or transmit error(s) has occurred.
494 * @param ErrorWord definition varies with Direction
497 typedef void (*XEmacPs_ErrHandler) (void *CallBackRef, u8 Direction,
503 * This typedef contains configuration information for a device.
506 u16 DeviceId; /**< Unique ID of device */
507 UINTPTR BaseAddress;/**< Physical base address of IPIF registers */
512 * The XEmacPs driver instance data. The user is required to allocate a
513 * structure of this type for every XEmacPs device in the system. A pointer
514 * to a structure of this type is then passed to the driver API functions.
516 typedef struct XEmacPs_Instance {
517 XEmacPs_Config Config; /* Hardware configuration */
518 u32 IsStarted; /* Device is currently started */
519 u32 IsReady; /* Device is initialized and ready */
520 u32 Options; /* Current options word */
522 XEmacPs_BdRing TxBdRing; /* Transmit BD ring */
523 XEmacPs_BdRing RxBdRing; /* Receive BD ring */
525 XEmacPs_Handler SendHandler;
526 XEmacPs_Handler RecvHandler;
530 XEmacPs_ErrHandler ErrorHandler;
536 u32 MaxVlanFrameSize;
541 /***************** Macros (Inline Functions) Definitions ********************/
543 /****************************************************************************/
545 * Retrieve the Tx ring object. This object can be used in the various Ring
548 * @param InstancePtr is the DMA channel to operate on.
550 * @return TxBdRing attribute
554 * XEmacPs_BdRing XEmacPs_GetTxRing(XEmacPs *InstancePtr)
556 *****************************************************************************/
557 #define XEmacPs_GetTxRing(InstancePtr) ((InstancePtr)->TxBdRing)
559 /****************************************************************************/
561 * Retrieve the Rx ring object. This object can be used in the various Ring
564 * @param InstancePtr is the DMA channel to operate on.
566 * @return RxBdRing attribute
570 * XEmacPs_BdRing XEmacPs_GetRxRing(XEmacPs *InstancePtr)
572 *****************************************************************************/
573 #define XEmacPs_GetRxRing(InstancePtr) ((InstancePtr)->RxBdRing)
575 /****************************************************************************/
578 * Enable interrupts specified in <i>Mask</i>. The corresponding interrupt for
579 * each bit set to 1 in <i>Mask</i>, will be enabled.
581 * @param InstancePtr is a pointer to the instance to be worked on.
582 * @param Mask contains a bit mask of interrupts to enable. The mask can
583 * be formed using a set of bitwise or'd values.
586 * The state of the transmitter and receiver are not modified by this function.
588 * void XEmacPs_IntEnable(XEmacPs *InstancePtr, u32 Mask)
590 *****************************************************************************/
591 #define XEmacPs_IntEnable(InstancePtr, Mask) \
592 XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \
593 XEMACPS_IER_OFFSET, \
594 ((Mask) & XEMACPS_IXR_ALL_MASK));
596 /****************************************************************************/
599 * Disable interrupts specified in <i>Mask</i>. The corresponding interrupt for
600 * each bit set to 1 in <i>Mask</i>, will be enabled.
602 * @param InstancePtr is a pointer to the instance to be worked on.
603 * @param Mask contains a bit mask of interrupts to disable. The mask can
604 * be formed using a set of bitwise or'd values.
607 * The state of the transmitter and receiver are not modified by this function.
609 * void XEmacPs_IntDisable(XEmacPs *InstancePtr, u32 Mask)
611 *****************************************************************************/
612 #define XEmacPs_IntDisable(InstancePtr, Mask) \
613 XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \
614 XEMACPS_IDR_OFFSET, \
615 ((Mask) & XEMACPS_IXR_ALL_MASK));
617 /****************************************************************************/
620 * Enable interrupts specified in <i>Mask</i>. The corresponding interrupt for
621 * each bit set to 1 in <i>Mask</i>, will be enabled.
623 * @param InstancePtr is a pointer to the instance to be worked on.
624 * @param Mask contains a bit mask of interrupts to enable. The mask can
625 * be formed using a set of bitwise or'd values.
628 * The state of the transmitter and receiver are not modified by this function.
630 * void XEmacPs_IntQ1Enable(XEmacPs *InstancePtr, u32 Mask)
632 *****************************************************************************/
633 #define XEmacPs_IntQ1Enable(InstancePtr, Mask) \
634 XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \
635 XEMACPS_INTQ1_IER_OFFSET, \
636 ((Mask) & XEMACPS_INTQ1_IXR_ALL_MASK));
638 /****************************************************************************/
641 * Disable interrupts specified in <i>Mask</i>. The corresponding interrupt for
642 * each bit set to 1 in <i>Mask</i>, will be enabled.
644 * @param InstancePtr is a pointer to the instance to be worked on.
645 * @param Mask contains a bit mask of interrupts to disable. The mask can
646 * be formed using a set of bitwise or'd values.
649 * The state of the transmitter and receiver are not modified by this function.
651 * void XEmacPs_IntDisable(XEmacPs *InstancePtr, u32 Mask)
653 *****************************************************************************/
654 #define XEmacPs_IntQ1Disable(InstancePtr, Mask) \
655 XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \
656 XEMACPS_INTQ1_IDR_OFFSET, \
657 ((Mask) & XEMACPS_INTQ1_IXR_ALL_MASK));
659 /****************************************************************************/
662 * This macro triggers trasmit circuit to send data currently in TX buffer(s).
664 * @param InstancePtr is a pointer to the XEmacPs instance to be worked on.
670 * Signature: void XEmacPs_Transmit(XEmacPs *InstancePtr)
672 *****************************************************************************/
673 #define XEmacPs_Transmit(InstancePtr) \
674 XEmacPs_WriteReg((InstancePtr)->Config.BaseAddress, \
675 XEMACPS_NWCTRL_OFFSET, \
676 (XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \
677 XEMACPS_NWCTRL_OFFSET) | XEMACPS_NWCTRL_STARTTX_MASK))
679 /****************************************************************************/
682 * This macro determines if the device is configured with checksum offloading
683 * on the receive channel
685 * @param InstancePtr is a pointer to the XEmacPs instance to be worked on.
689 * Boolean TRUE if the device is configured with checksum offloading, or
694 * Signature: u32 XEmacPs_IsRxCsum(XEmacPs *InstancePtr)
696 *****************************************************************************/
697 #define XEmacPs_IsRxCsum(InstancePtr) \
698 ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \
699 XEMACPS_NWCFG_OFFSET) & XEMACPS_NWCFG_RXCHKSUMEN_MASK) != 0U \
702 /****************************************************************************/
705 * This macro determines if the device is configured with checksum offloading
706 * on the transmit channel
708 * @param InstancePtr is a pointer to the XEmacPs instance to be worked on.
712 * Boolean TRUE if the device is configured with checksum offloading, or
717 * Signature: u32 XEmacPs_IsTxCsum(XEmacPs *InstancePtr)
719 *****************************************************************************/
720 #define XEmacPs_IsTxCsum(InstancePtr) \
721 ((XEmacPs_ReadReg((InstancePtr)->Config.BaseAddress, \
722 XEMACPS_DMACR_OFFSET) & XEMACPS_DMACR_TCPCKSUM_MASK) != 0U \
725 /************************** Function Prototypes *****************************/
728 * Initialization functions in xemacps.c
730 LONG XEmacPs_CfgInitialize(XEmacPs *InstancePtr, XEmacPs_Config *CfgPtr,
731 UINTPTR EffectiveAddress);
732 void XEmacPs_Start(XEmacPs *InstancePtr);
733 void XEmacPs_Stop(XEmacPs *InstancePtr);
734 void XEmacPs_Reset(XEmacPs *InstancePtr);
735 void XEmacPs_SetQueuePtr(XEmacPs *InstancePtr, UINTPTR QPtr, u8 QueueNum,
739 * Lookup configuration in xemacps_sinit.c
741 XEmacPs_Config *XEmacPs_LookupConfig(u16 DeviceId);
744 * Interrupt-related functions in xemacps_intr.c
745 * DMA only and FIFO is not supported. This DMA does not support coalescing.
747 LONG XEmacPs_SetHandler(XEmacPs *InstancePtr, u32 HandlerType,
748 void *FuncPointer, void *CallBackRef);
749 void XEmacPs_IntrHandler(void *XEmacPsPtr);
752 * MAC configuration/control functions in XEmacPs_control.c
754 LONG XEmacPs_SetOptions(XEmacPs *InstancePtr, u32 Options);
755 LONG XEmacPs_ClearOptions(XEmacPs *InstancePtr, u32 Options);
756 u32 XEmacPs_GetOptions(XEmacPs *InstancePtr);
758 LONG XEmacPs_SetMacAddress(XEmacPs *InstancePtr, void *AddressPtr, u8 Index);
759 LONG XEmacPs_DeleteHash(XEmacPs *InstancePtr, void *AddressPtr);
760 void XEmacPs_GetMacAddress(XEmacPs *InstancePtr, void *AddressPtr, u8 Index);
762 LONG XEmacPs_SetHash(XEmacPs *InstancePtr, void *AddressPtr);
763 void XEmacPs_ClearHash(XEmacPs *InstancePtr);
764 void XEmacPs_GetHash(XEmacPs *InstancePtr, void *AddressPtr);
766 void XEmacPs_SetMdioDivisor(XEmacPs *InstancePtr,
767 XEmacPs_MdcDiv Divisor);
768 void XEmacPs_SetOperatingSpeed(XEmacPs *InstancePtr, u16 Speed);
769 u16 XEmacPs_GetOperatingSpeed(XEmacPs *InstancePtr);
770 LONG XEmacPs_PhyRead(XEmacPs *InstancePtr, u32 PhyAddress,
771 u32 RegisterNum, u16 *PhyDataPtr);
772 LONG XEmacPs_PhyWrite(XEmacPs *InstancePtr, u32 PhyAddress,
773 u32 RegisterNum, u16 PhyData);
774 LONG XEmacPs_SetTypeIdCheck(XEmacPs *InstancePtr, u32 Id_Check, u8 Index);
776 LONG XEmacPs_SendPausePacket(XEmacPs *InstancePtr);
777 void XEmacPs_DMABLengthUpdate(XEmacPs *InstancePtr, s32 BLength);
783 #endif /* end of protection macro */