1 /* $Id: xemac.c,v 1.1.1.1 2005/04/11 02:50:33 jack Exp $ */
2 /******************************************************************************
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
13 * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
14 * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
15 * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR STANDARD,
16 * XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION IS FREE
17 * FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE FOR
18 * OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
19 * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
20 * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY
21 * WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM
22 * CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND
23 * FITNESS FOR A PARTICULAR PURPOSE.
26 * Xilinx products are not intended for use in life support appliances,
27 * devices, or systems. Use in such applications is expressly prohibited.
30 * (c) Copyright 2002 Xilinx Inc.
31 * All rights reserved.
34 * You should have received a copy of the GNU General Public License along
35 * with this program; if not, write to the Free Software Foundation, Inc.,
36 * 675 Mass Ave, Cambridge, MA 02139, USA.
38 ******************************************************************************/
39 /*****************************************************************************/
44 * The XEmac driver. Functions in this file are the minimum required functions
45 * for this driver. See xemac.h for a detailed description of the driver.
48 * MODIFICATION HISTORY:
50 * Ver Who Date Changes
51 * ----- ---- -------- -----------------------------------------------
52 * 1.00a rpm 07/31/01 First release
53 * 1.00b rpm 02/20/02 Repartitioned files and functions
54 * 1.00b rpm 07/23/02 Removed the PHY reset from Initialize()
56 ******************************************************************************/
58 /***************************** Include Files *********************************/
60 #include "xbasic_types.h"
63 #include "xipif_v1_23_b.h" /* Uses v1.23b of the IPIF */
65 /************************** Constant Definitions *****************************/
67 /**************************** Type Definitions *******************************/
69 /***************** Macros (Inline Functions) Definitions *********************/
71 /************************** Function Prototypes ******************************/
73 static XStatus ConfigureDma(XEmac * InstancePtr);
74 static XStatus ConfigureFifo(XEmac * InstancePtr);
75 static void StubFifoHandler(void *CallBackRef);
76 static void StubErrorHandler(void *CallBackRef, XStatus ErrorCode);
77 static void StubSgHandler(void *CallBackRef, XBufDescriptor * BdPtr,
80 /************************** Variable Definitions *****************************/
82 /*****************************************************************************/
85 * Initialize a specific XEmac instance/driver. The initialization entails:
86 * - Initialize fields of the XEmac structure
87 * - Clear the Ethernet statistics for this device
88 * - Initialize the IPIF component with its register base address
89 * - Configure the FIFO components with their register base addresses.
90 * - If the device is configured with DMA, configure the DMA channel components
91 * with their register base addresses. At some later time, memory pools for
92 * the scatter-gather descriptor lists are to be passed to the driver.
93 * - Reset the Ethernet MAC
95 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
96 * @param DeviceId is the unique id of the device controlled by this XEmac
97 * instance. Passing in a device id associates the generic XEmac
98 * instance to a specific device, as chosen by the caller or application
103 * - XST_SUCCESS if initialization was successful
104 * - XST_DEVICE_IS_STARTED if the device has already been started
105 * - XST_DEVICE_NOT_FOUND if device configuration information was not found for
106 * a device with the supplied device ID.
112 ******************************************************************************/
114 XEmac_Initialize(XEmac * InstancePtr, u16 DeviceId)
117 XEmac_Config *ConfigPtr; /* configuration information */
119 XASSERT_NONVOID(InstancePtr != NULL);
122 * If the device is started, disallow the initialize and return a status
123 * indicating it is started. This allows the user to stop the device
124 * and reinitialize, but prevents a user from inadvertently initializing
126 if (InstancePtr->IsStarted == XCOMPONENT_IS_STARTED) {
127 return XST_DEVICE_IS_STARTED;
131 * Lookup the device configuration in the temporary CROM table. Use this
132 * configuration info down below when initializing this component.
134 ConfigPtr = XEmac_LookupConfig(DeviceId);
135 if (ConfigPtr == NULL) {
136 return XST_DEVICE_NOT_FOUND;
140 * Set some default values
142 InstancePtr->IsReady = 0;
143 InstancePtr->IsStarted = 0;
144 InstancePtr->IsDmaSg = ConfigPtr->HasSgDma;
145 InstancePtr->HasMii = ConfigPtr->HasMii;
146 InstancePtr->HasMulticastHash = FALSE;
148 /* Always default polled to false, let user configure this mode */
149 InstancePtr->IsPolled = FALSE;
150 InstancePtr->FifoRecvHandler = StubFifoHandler;
151 InstancePtr->FifoSendHandler = StubFifoHandler;
152 InstancePtr->ErrorHandler = StubErrorHandler;
153 InstancePtr->SgRecvHandler = StubSgHandler;
154 InstancePtr->SgSendHandler = StubSgHandler;
157 * Clear the statistics for this driver
159 XEmac_mClearStruct((u8 *) & InstancePtr->Stats, sizeof (XEmac_Stats));
162 * Initialize the device register base addresses
164 InstancePtr->BaseAddress = ConfigPtr->BaseAddress;
167 * Configure the send and receive FIFOs in the MAC
169 Result = ConfigureFifo(InstancePtr);
170 if (Result != XST_SUCCESS) {
175 * If the device is configured for scatter-gather DMA, configure the send
176 * and receive DMA channels in the MAC. This could return XST_NO_FEATURE.
178 if (InstancePtr->IsDmaSg) {
179 Result = ConfigureDma(InstancePtr);
180 if (Result != XST_SUCCESS) {
186 * Indicate the component is now ready to use. Note that this is done before
187 * we reset the device and the PHY below, which may seem a bit odd. The
188 * choice was made to move it here rather than remove the asserts in various
189 * functions (e.g., Reset() and all functions that it calls). Applications
190 * that use multiple threads, one to initialize the XEmac driver and one
191 * waiting on the IsReady condition could have a problem with this sequence.
193 InstancePtr->IsReady = XCOMPONENT_IS_READY;
196 * Reset the MAC to get it into its initial state. It is expected that
197 * device configuration by the user will take place after this
198 * initialization is done, but before the device is started.
200 XEmac_Reset(InstancePtr);
203 * Reset the PHY (assuming it supports the reset_n signal). This is the
204 * only time the driver resets the PHY.
206 * Removed 07/23/02 : Caused problems on some boards. Leave up to user to
207 * do this directly with PhyRead/PhyWrite functions.
209 * ControlReg = XIo_In32(InstancePtr->BaseAddress + XEM_ECR_OFFSET);
210 * ControlReg &= ~XEM_ECR_PHY_ENABLE_MASK;
211 * XIo_Out32(InstancePtr->BaseAddress + XEM_ECR_OFFSET, ControlReg);
212 * ControlReg |= XEM_ECR_PHY_ENABLE_MASK;
213 * XIo_Out32(InstancePtr->BaseAddress + XEM_ECR_OFFSET, ControlReg);
219 /*****************************************************************************/
222 * Start the Ethernet controller as follows:
223 * - If not in polled mode
224 * - Set the internal interrupt enable registers appropriately
225 * - Enable interrupts within the device itself. Note that connection of
226 * the driver's interrupt handler to the interrupt source (typically
227 * done using the interrupt controller component) is done by the higher
229 * - If the device is configured with DMA, start the DMA channels if the
230 * descriptor lists are not empty
231 * - Enable the transmitter
232 * - Enable the receiver
234 * The PHY is enabled after driver initialization. We assume the upper layer
235 * software has configured it and the EMAC appropriately before this function
238 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
242 * - XST_SUCCESS if the device was started successfully
243 * - XST_NO_CALLBACK if a callback function has not yet been registered using
244 * the SetxxxHandler function. This is required if in interrupt mode.
245 * - XST_DEVICE_IS_STARTED if the device is already started
246 * - XST_DMA_SG_NO_LIST if configured for scatter-gather DMA and a descriptor
247 * list has not yet been created for the send or receive channel.
251 * This function makes use of internal resources that are shared between the
252 * Start, Stop, and SetOptions functions. So if one task might be setting device
253 * options while another is trying to start the device, the user is required to
254 * provide protection of this shared data (typically using a semaphore).
256 ******************************************************************************/
258 XEmac_Start(XEmac * InstancePtr)
263 XASSERT_NONVOID(InstancePtr != NULL);
264 XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);
267 * If it is already started, return a status indicating so
269 if (InstancePtr->IsStarted == XCOMPONENT_IS_STARTED) {
270 return XST_DEVICE_IS_STARTED;
274 * If not polled, enable interrupts
276 if (!InstancePtr->IsPolled) {
278 * Verify that the callbacks have been registered, then enable
281 if (InstancePtr->IsDmaSg) {
282 if ((InstancePtr->SgRecvHandler == StubSgHandler) ||
283 (InstancePtr->SgSendHandler == StubSgHandler)) {
284 return XST_NO_CALLBACK;
287 /* Enable IPIF interrupts */
288 XIIF_V123B_WRITE_DIER(InstancePtr->BaseAddress,
289 XEM_IPIF_DMA_DFT_MASK |
290 XIIF_V123B_ERROR_MASK);
291 XIIF_V123B_WRITE_IIER(InstancePtr->BaseAddress,
292 XEM_EIR_DFT_SG_MASK);
294 /* Enable DMA interrupts */
295 XDmaChannel_SetIntrEnable(&InstancePtr->RecvChannel,
296 XEM_DMA_SG_INTR_MASK);
297 XDmaChannel_SetIntrEnable(&InstancePtr->SendChannel,
298 XEM_DMA_SG_INTR_MASK);
300 if ((InstancePtr->FifoRecvHandler == StubFifoHandler) ||
301 (InstancePtr->FifoSendHandler == StubFifoHandler)) {
302 return XST_NO_CALLBACK;
305 /* Enable IPIF interrupts */
306 XIIF_V123B_WRITE_DIER(InstancePtr->BaseAddress,
307 XEM_IPIF_FIFO_DFT_MASK |
308 XIIF_V123B_ERROR_MASK);
309 XIIF_V123B_WRITE_IIER(InstancePtr->BaseAddress,
310 XEM_EIR_DFT_FIFO_MASK);
313 /* Enable the global IPIF interrupt output */
314 XIIF_V123B_GINTR_ENABLE(InstancePtr->BaseAddress);
318 * Enable the transmitter, and receiver (do a read/modify/write to preserve
319 * current settings). There is no critical section here since this register
320 * is not modified during interrupt context.
322 ControlReg = XIo_In32(InstancePtr->BaseAddress + XEM_ECR_OFFSET);
323 ControlReg &= ~(XEM_ECR_XMIT_RESET_MASK | XEM_ECR_RECV_RESET_MASK);
324 ControlReg |= (XEM_ECR_XMIT_ENABLE_MASK | XEM_ECR_RECV_ENABLE_MASK);
326 XIo_Out32(InstancePtr->BaseAddress + XEM_ECR_OFFSET, ControlReg);
329 * If configured with scatter-gather DMA and not polled, restart the
330 * DMA channels in case there are buffers ready to be sent or received into.
331 * The DMA SgStart function uses data that can be modified during interrupt
332 * context, so a critical section is required here.
334 if ((InstancePtr->IsDmaSg) && (!InstancePtr->IsPolled)) {
335 XIIF_V123B_GINTR_DISABLE(InstancePtr->BaseAddress);
338 * The only error we care about is if the list has not yet been
339 * created, or on receive, if no buffer descriptors have been
340 * added yet (the list is empty). Other errors are benign at this point.
342 Result = XDmaChannel_SgStart(&InstancePtr->RecvChannel);
343 if ((Result == XST_DMA_SG_NO_LIST)
344 || (Result == XST_DMA_SG_LIST_EMPTY)) {
345 XIIF_V123B_GINTR_ENABLE(InstancePtr->BaseAddress);
349 Result = XDmaChannel_SgStart(&InstancePtr->SendChannel);
350 if (Result == XST_DMA_SG_NO_LIST) {
351 XIIF_V123B_GINTR_ENABLE(InstancePtr->BaseAddress);
356 * Indicate the device is started. Be sure to do this before we exit
357 * the critical section since starting the DMA channel may cause data
358 * to start flowing and interrupts to occur, but the SgRecv function in
359 * interrupt context requires the IsStarted flag to be set.
361 /* InstancePtr->IsStarted = XCOMPONENT_IS_STARTED; RPM */
363 XIIF_V123B_GINTR_ENABLE(InstancePtr->BaseAddress);
367 * Indicate that the device is started
369 InstancePtr->IsStarted = XCOMPONENT_IS_STARTED;
374 /*****************************************************************************/
377 * Stop the Ethernet MAC as follows:
378 * - If the device is configured with DMA, stop the DMA channels (wait for
379 * acknowledgment of stop)
380 * - Disable the transmitter and receiver
381 * - Disable interrupts if not in polled mode (the higher layer software is
382 * responsible for disabling interrupts at the interrupt controller)
384 * The PHY is left enabled after a Stop is called.
386 * If the device is configured for scatter-gather DMA, the DMA engine stops at
387 * the next buffer descriptor in its list. The remaining descriptors in the list
388 * are not removed, so anything in the list will be transmitted or received when
389 * the device is restarted. The side effect of doing this is that the last
390 * buffer descriptor processed by the DMA engine before stopping may not be the
391 * last descriptor in the Ethernet frame. So when the device is restarted, a
392 * partial frame (i.e., a bad frame) may be transmitted/received. This is only a
393 * concern if a frame can span multiple buffer descriptors, which is dependent
394 * on the size of the network buffers.
396 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
400 * - XST_SUCCESS if the device was stopped successfully
401 * - XST_DEVICE_IS_STOPPED if the device is already stopped
405 * This function makes use of internal resources that are shared between the
406 * Start, Stop, and SetOptions functions. So if one task might be setting device
407 * options while another is trying to start the device, the user is required to
408 * provide protection of this shared data (typically using a semaphore).
410 ******************************************************************************/
412 XEmac_Stop(XEmac * InstancePtr)
416 XASSERT_NONVOID(InstancePtr != NULL);
417 XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);
420 * If the device is already stopped, do nothing but return a status
423 if (InstancePtr->IsStarted != XCOMPONENT_IS_STARTED) {
424 return XST_DEVICE_IS_STOPPED;
428 * If configured for scatter-gather DMA, stop the DMA channels. Ignore
429 * the XST_DMA_SG_IS_STOPPED return code. There is a critical section
430 * here between SgStart and SgStop, and SgStart can be called in interrupt
431 * context, so disable interrupts while calling SgStop.
433 if (InstancePtr->IsDmaSg) {
434 XBufDescriptor *BdTemp; /* temporary descriptor pointer */
436 XIIF_V123B_GINTR_DISABLE(InstancePtr->BaseAddress);
438 (void) XDmaChannel_SgStop(&InstancePtr->SendChannel, &BdTemp);
439 (void) XDmaChannel_SgStop(&InstancePtr->RecvChannel, &BdTemp);
441 XIIF_V123B_GINTR_ENABLE(InstancePtr->BaseAddress);
445 * Disable the transmitter and receiver. There is no critical section
446 * here since this register is not modified during interrupt context.
448 ControlReg = XIo_In32(InstancePtr->BaseAddress + XEM_ECR_OFFSET);
449 ControlReg &= ~(XEM_ECR_XMIT_ENABLE_MASK | XEM_ECR_RECV_ENABLE_MASK);
450 XIo_Out32(InstancePtr->BaseAddress + XEM_ECR_OFFSET, ControlReg);
453 * If not in polled mode, disable interrupts for IPIF (includes MAC and
456 if (!InstancePtr->IsPolled) {
457 XIIF_V123B_GINTR_DISABLE(InstancePtr->BaseAddress);
460 InstancePtr->IsStarted = 0;
465 /*****************************************************************************/
468 * Reset the Ethernet MAC. This is a graceful reset in that the device is stopped
469 * first. Resets the DMA channels, the FIFOs, the transmitter, and the receiver.
470 * The PHY is not reset. Any frames in the scatter-gather descriptor lists will
471 * remain in the lists. The side effect of doing this is that after a reset and
472 * following a restart of the device, frames that were in the list before the
473 * reset may be transmitted or received. Reset must only be called after the
474 * driver has been initialized.
476 * The configuration after this reset is as follows:
478 * - Disabled transmitter and receiver
479 * - Enabled PHY (the PHY is not reset)
480 * - MAC transmitter does pad insertion, FCS insertion, and source address
482 * - MAC receiver does not strip padding or FCS
483 * - Interframe Gap as recommended by IEEE Std. 802.3 (96 bit times)
484 * - Unicast addressing enabled
485 * - Broadcast addressing enabled
486 * - Multicast addressing disabled (addresses are preserved)
487 * - Promiscuous addressing disabled
488 * - Default packet threshold and packet wait bound register values for
489 * scatter-gather DMA operation
490 * - MAC address of all zeros
492 * The upper layer software is responsible for re-configuring (if necessary)
493 * and restarting the MAC after the reset. Note that the PHY is not reset. After
494 * its initial reset during initialization of the MAC, PHY control is left to
495 * the upper layer software. Note also that driver statistics are not cleared
496 * on reset. It is up to the upper layer software to clear the statistics if
499 * When a reset is required due to an internal error, the driver notifies the
500 * upper layer software of this need through the ErrorHandler callback and
501 * specific status codes. The upper layer software is responsible for calling
502 * this Reset function and then re-configuring the device.
504 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
516 * The reset is accomplished by setting the IPIF reset register. This takes
517 * care of resetting all hardware blocks, including the MAC.
519 ******************************************************************************/
521 XEmac_Reset(XEmac * InstancePtr)
525 XASSERT_VOID(InstancePtr != NULL);
526 XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);
529 * Stop the device first
531 (void) XEmac_Stop(InstancePtr);
534 * Reset the entire IPIF at once. If we choose someday to reset each
535 * hardware block separately, the reset should occur in the direction of
536 * data flow. For example, for the send direction the reset order is DMA
537 * first, then FIFO, then the MAC transmitter.
539 XIIF_V123B_RESET(InstancePtr->BaseAddress);
542 * For now, configure the receiver to not strip off FCS and padding since
543 * this is not currently supported. In the future, just take the default
544 * and provide the option for the user to change this behavior.
546 ControlReg = XIo_In32(InstancePtr->BaseAddress + XEM_ECR_OFFSET);
547 ControlReg &= ~(XEM_ECR_RECV_STRIP_ENABLE_MASK);
548 XIo_Out32(InstancePtr->BaseAddress + XEM_ECR_OFFSET, ControlReg);
550 if (InstancePtr->IsDmaSg) {
552 * After reset, configure the scatter-gather DMA packet threshold and
553 * packet wait bound registers to default values. Ignore the return
554 * values of these functions since they only return error if the device
557 (void) XEmac_SetPktThreshold(InstancePtr, XEM_SEND,
558 XEM_SGDMA_DFT_THRESHOLD);
559 (void) XEmac_SetPktThreshold(InstancePtr, XEM_RECV,
560 XEM_SGDMA_DFT_THRESHOLD);
561 (void) XEmac_SetPktWaitBound(InstancePtr, XEM_SEND,
562 XEM_SGDMA_DFT_WAITBOUND);
563 (void) XEmac_SetPktWaitBound(InstancePtr, XEM_RECV,
564 XEM_SGDMA_DFT_WAITBOUND);
568 /*****************************************************************************/
571 * Set the MAC address for this driver/device. The address is a 48-bit value.
572 * The device must be stopped before calling this function.
574 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
575 * @param AddressPtr is a pointer to a 6-byte MAC address.
579 * - XST_SUCCESS if the MAC address was set successfully
580 * - XST_DEVICE_IS_STARTED if the device has not yet been stopped
586 ******************************************************************************/
588 XEmac_SetMacAddress(XEmac * InstancePtr, u8 * AddressPtr)
592 XASSERT_NONVOID(InstancePtr != NULL);
593 XASSERT_NONVOID(AddressPtr != NULL);
594 XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);
597 * The device must be stopped before setting the MAC address
599 if (InstancePtr->IsStarted == XCOMPONENT_IS_STARTED) {
600 return XST_DEVICE_IS_STARTED;
604 * Set the device station address high and low registers
606 MacAddr = (AddressPtr[0] << 8) | AddressPtr[1];
607 XIo_Out32(InstancePtr->BaseAddress + XEM_SAH_OFFSET, MacAddr);
609 MacAddr = (AddressPtr[2] << 24) | (AddressPtr[3] << 16) |
610 (AddressPtr[4] << 8) | AddressPtr[5];
612 XIo_Out32(InstancePtr->BaseAddress + XEM_SAL_OFFSET, MacAddr);
617 /*****************************************************************************/
620 * Get the MAC address for this driver/device.
622 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
623 * @param BufferPtr is an output parameter, and is a pointer to a buffer into
624 * which the current MAC address will be copied. The buffer must be at
635 ******************************************************************************/
637 XEmac_GetMacAddress(XEmac * InstancePtr, u8 * BufferPtr)
642 XASSERT_VOID(InstancePtr != NULL);
643 XASSERT_VOID(BufferPtr != NULL);
644 XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);
646 MacAddrHi = XIo_In32(InstancePtr->BaseAddress + XEM_SAH_OFFSET);
647 MacAddrLo = XIo_In32(InstancePtr->BaseAddress + XEM_SAL_OFFSET);
649 BufferPtr[0] = (u8) (MacAddrHi >> 8);
650 BufferPtr[1] = (u8) MacAddrHi;
651 BufferPtr[2] = (u8) (MacAddrLo >> 24);
652 BufferPtr[3] = (u8) (MacAddrLo >> 16);
653 BufferPtr[4] = (u8) (MacAddrLo >> 8);
654 BufferPtr[5] = (u8) MacAddrLo;
657 /******************************************************************************/
660 * Configure DMA (including scatter-gather) capabilities.
662 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
666 * - XST_SUCCESS if successful initialization of the packet FIFOs
672 ******************************************************************************/
674 ConfigureDma(XEmac * InstancePtr)
679 * Initialize the DMA channels with their base addresses. We assume
680 * scatter-gather DMA is the only possible configuration. Descriptor space
681 * will need to be set later by the upper layer.
683 Result = XDmaChannel_Initialize(&InstancePtr->RecvChannel,
684 InstancePtr->BaseAddress +
685 XEM_DMA_RECV_OFFSET);
686 if (Result != XST_SUCCESS) {
690 Result = XDmaChannel_Initialize(&InstancePtr->SendChannel,
691 InstancePtr->BaseAddress +
692 XEM_DMA_SEND_OFFSET);
697 /******************************************************************************/
700 * Configure the send and receive FIFO components with their base addresses
701 * and interrupt masks. Currently the base addresses are defined constants.
703 * @param InstancePtr is a pointer to the XEmac instance to be worked on.
707 * XST_SUCCESS if successful initialization of the packet FIFOs
713 ******************************************************************************/
715 ConfigureFifo(XEmac * InstancePtr)
720 * Return status from the packet FIFOs initialization is ignored since
721 * they always return success.
723 Result = XPacketFifoV100b_Initialize(&InstancePtr->RecvFifo,
724 InstancePtr->BaseAddress +
725 XEM_PFIFO_RXREG_OFFSET,
726 InstancePtr->BaseAddress +
727 XEM_PFIFO_RXDATA_OFFSET);
728 if (Result != XST_SUCCESS) {
732 Result = XPacketFifoV100b_Initialize(&InstancePtr->SendFifo,
733 InstancePtr->BaseAddress +
734 XEM_PFIFO_TXREG_OFFSET,
735 InstancePtr->BaseAddress +
736 XEM_PFIFO_TXDATA_OFFSET);
740 /******************************************************************************/
743 * This is a stub for the scatter-gather send and recv callbacks. The stub
744 * is here in case the upper layers forget to set the handlers.
746 * @param CallBackRef is a pointer to the upper layer callback reference
747 * @param BdPtr is a pointer to the first buffer descriptor in a list
748 * @param NumBds is the number of descriptors in the list.
758 ******************************************************************************/
760 StubSgHandler(void *CallBackRef, XBufDescriptor * BdPtr, u32 NumBds)
765 /******************************************************************************/
768 * This is a stub for the non-DMA send and recv callbacks. The stub is here in
769 * case the upper layers forget to set the handlers.
771 * @param CallBackRef is a pointer to the upper layer callback reference
781 ******************************************************************************/
783 StubFifoHandler(void *CallBackRef)
788 /******************************************************************************/
791 * This is a stub for the asynchronous error callback. The stub is here in
792 * case the upper layers forget to set the handler.
794 * @param CallBackRef is a pointer to the upper layer callback reference
795 * @param ErrorCode is the Xilinx error code, indicating the cause of the error
805 ******************************************************************************/
807 StubErrorHandler(void *CallBackRef, XStatus ErrorCode)
812 /*****************************************************************************/
815 * Lookup the device configuration based on the unique device ID. The table
816 * EmacConfigTable contains the configuration info for each device in the system.
818 * @param DeviceId is the unique device ID of the device being looked up.
822 * A pointer to the configuration table entry corresponding to the given
823 * device ID, or NULL if no match is found.
829 ******************************************************************************/
831 XEmac_LookupConfig(u16 DeviceId)
833 XEmac_Config *CfgPtr = NULL;
836 for (i = 0; i < XPAR_XEMAC_NUM_INSTANCES; i++) {
837 if (XEmac_ConfigTable[i].DeviceId == DeviceId) {
838 CfgPtr = &XEmac_ConfigTable[i];