a2fxxxm3_eth_driver.c
Go to the documentation of this file.
1 /**
2  * @file a2fxxxm3_eth_driver.c
3  * @brief SmartFusion (A2FxxxM3) Ethernet MAC driver
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL NIC_TRACE_LEVEL
33 
34 //Dependencies
35 #include "a2fxxxm3.h"
36 #include "drivers/mss_ethernet_mac/mss_ethernet_mac_regs.h"
37 #include "drivers/mss_ethernet_mac/mss_ethernet_mac_desc.h"
38 #include "core/net.h"
40 #include "debug.h"
41 
42 //Underlying network interface
43 static NetInterface *nicDriverInterface;
44 
45 //IAR EWARM compiler?
46 #if defined(__ICCARM__)
47 
48 //Transmit buffer
49 #pragma data_alignment = 4
51 //Receive buffer
52 #pragma data_alignment = 4
54 //Transmit DMA descriptors
55 #pragma data_alignment = 4
57 //Receive DMA descriptors
58 #pragma data_alignment = 4
60 
61 //Keil MDK-ARM or GCC compiler?
62 #else
63 
64 //Transmit buffer
66  __attribute__((aligned(4)));
67 //Receive buffer
69  __attribute__((aligned(4)));
70 //Transmit DMA descriptors
72  __attribute__((aligned(4)));
73 //Receive DMA descriptors
75  __attribute__((aligned(4)));
76 
77 #endif
78 
79 //Pointer to the current TX DMA descriptor
80 static A2fxxxm3TxDmaDesc *txCurDmaDesc;
81 //Pointer to the current RX DMA descriptor
82 static A2fxxxm3RxDmaDesc *rxCurDmaDesc;
83 
84 
85 /**
86  * @brief A2FxxxM3 Ethernet MAC driver
87  **/
88 
90 {
92  ETH_MTU,
103  TRUE,
104  TRUE,
105  TRUE,
106  FALSE
107 };
108 
109 
110 /**
111  * @brief A2FxxxM3 Ethernet MAC initialization
112  * @param[in] interface Underlying network interface
113  * @return Error code
114  **/
115 
117 {
118  error_t error;
119 
120  //Debug message
121  TRACE_INFO("Initializing A2FxxxM3 Ethernet MAC...\r\n");
122 
123  //Save underlying network interface
124  nicDriverInterface = interface;
125 
126  //Perform a software reset
127  MAC->CSR0 |= CSR0_SWR_MASK;
128  //Wait for the reset to complete
129  while((MAC->CSR0 & CSR0_SWR_MASK) != 0)
130  {
131  }
132 
133  //Valid Ethernet PHY or switch driver?
134  if(interface->phyDriver != NULL)
135  {
136  //Ethernet PHY initialization
137  error = interface->phyDriver->init(interface);
138  }
139  else if(interface->switchDriver != NULL)
140  {
141  //Ethernet switch initialization
142  error = interface->switchDriver->init(interface);
143  }
144  else
145  {
146  //The interface is not properly configured
147  error = ERROR_FAILURE;
148  }
149 
150  //Any error to report?
151  if(error)
152  {
153  return error;
154  }
155 
156  //Enable store and forward mode
157  MAC->CSR6 |= CSR6_SF_MASK;
158 
159  //Initialize DMA descriptor lists
160  a2fxxxm3EthInitDmaDesc(interface);
161 
162  //Enable the desired Ethernet interrupts
163  MAC->CSR7 |= CSR7_NIE_MASK | CSR7_RIE_MASK | CSR7_TIE_MASK;
164 
165  //Set priority grouping (5 bits for pre-emption priority, no bits for subpriority)
166  NVIC_SetPriorityGrouping(A2FXXXM3_ETH_IRQ_PRIORITY_GROUPING);
167 
168  //Configure Ethernet interrupt priority
169  NVIC_SetPriority(EthernetMAC_IRQn, NVIC_EncodePriority(A2FXXXM3_ETH_IRQ_PRIORITY_GROUPING,
171 
172  //Enable transmission and reception
173  MAC->CSR6 |= CSR6_ST_MASK | CSR6_SR_MASK;
174 
175  //Set MAC address
176  error = a2fxxxm3EthSendSetup(interface);
177  //Any error to report?
178  if(error)
179  {
180  return error;
181  }
182 
183  //Accept any packets from the upper layer
184  osSetEvent(&interface->nicTxEvent);
185 
186  //Successful initialization
187  return NO_ERROR;
188 }
189 
190 
191 /**
192  * @brief Initialize DMA descriptor lists
193  * @param[in] interface Underlying network interface
194  **/
195 
197 {
198  uint_t i;
199 
200  //Initialize TX DMA descriptor list
201  for(i = 0; i < A2FXXXM3_ETH_TX_BUFFER_COUNT; i++)
202  {
203  //The descriptor is initially owned by the user
204  txDmaDesc[i].tdes0 = 0;
205  //Use chain structure rather than ring structure
206  txDmaDesc[i].tdes1 = TDES1_TCH;
207  //Transmit buffer address
208  txDmaDesc[i].tdes2 = (uint32_t) txBuffer[i];
209  //Next descriptor address
210  txDmaDesc[i].tdes3 = (uint32_t) &txDmaDesc[i + 1];
211  }
212 
213  //The last descriptor is chained to the first entry
214  txDmaDesc[i - 1].tdes3 = (uint32_t) &txDmaDesc[0];
215  //Point to the very first descriptor
216  txCurDmaDesc = &txDmaDesc[0];
217 
218  //Initialize RX DMA descriptor list
219  for(i = 0; i < A2FXXXM3_ETH_RX_BUFFER_COUNT; i++)
220  {
221  //The descriptor is initially owned by the DMA
222  rxDmaDesc[i].rdes0 = RDES0_OWN;
223  //Use chain structure rather than ring structure
224  rxDmaDesc[i].rdes1 = RDES1_RCH | (A2FXXXM3_ETH_RX_BUFFER_SIZE & RDES1_RBS1_MASK);
225  //Receive buffer address
226  rxDmaDesc[i].rdes2 = (uint32_t) rxBuffer[i];
227  //Next descriptor address
228  rxDmaDesc[i].rdes3 = (uint32_t) &rxDmaDesc[i + 1];
229  }
230 
231  //The last descriptor is chained to the first entry
232  rxDmaDesc[i - 1].rdes3 = (uint32_t) &rxDmaDesc[0];
233  //Point to the very first descriptor
234  rxCurDmaDesc = &rxDmaDesc[0];
235 
236  //Start location of the TX descriptor list
237  MAC->CSR4 = (uint32_t) txDmaDesc;
238  //Start location of the RX descriptor list
239  MAC->CSR3 = (uint32_t) rxDmaDesc;
240 }
241 
242 
243 /**
244  * @brief A2FxxxM3 Ethernet MAC timer handler
245  *
246  * This routine is periodically called by the TCP/IP stack to handle periodic
247  * operations such as polling the link state
248  *
249  * @param[in] interface Underlying network interface
250  **/
251 
253 {
254  //Valid Ethernet PHY or switch driver?
255  if(interface->phyDriver != NULL)
256  {
257  //Handle periodic operations
258  interface->phyDriver->tick(interface);
259  }
260  else if(interface->switchDriver != NULL)
261  {
262  //Handle periodic operations
263  interface->switchDriver->tick(interface);
264  }
265  else
266  {
267  //Just for sanity
268  }
269 }
270 
271 
272 /**
273  * @brief Enable interrupts
274  * @param[in] interface Underlying network interface
275  **/
276 
278 {
279  //Enable Ethernet MAC interrupts
280  NVIC_EnableIRQ(EthernetMAC_IRQn);
281 
282  //Valid Ethernet PHY or switch driver?
283  if(interface->phyDriver != NULL)
284  {
285  //Enable Ethernet PHY interrupts
286  interface->phyDriver->enableIrq(interface);
287  }
288  else if(interface->switchDriver != NULL)
289  {
290  //Enable Ethernet switch interrupts
291  interface->switchDriver->enableIrq(interface);
292  }
293  else
294  {
295  //Just for sanity
296  }
297 }
298 
299 
300 /**
301  * @brief Disable interrupts
302  * @param[in] interface Underlying network interface
303  **/
304 
306 {
307  //Disable Ethernet MAC interrupts
308  NVIC_DisableIRQ(EthernetMAC_IRQn);
309 
310  //Valid Ethernet PHY or switch driver?
311  if(interface->phyDriver != NULL)
312  {
313  //Disable Ethernet PHY interrupts
314  interface->phyDriver->disableIrq(interface);
315  }
316  else if(interface->switchDriver != NULL)
317  {
318  //Disable Ethernet switch interrupts
319  interface->switchDriver->disableIrq(interface);
320  }
321  else
322  {
323  //Just for sanity
324  }
325 }
326 
327 
328 /**
329  * @brief A2FxxxM3 Ethernet MAC interrupt service routine
330  **/
331 
333 {
334  bool_t flag;
335  uint32_t status;
336 
337  //Interrupt service routine prologue
338  osEnterIsr();
339 
340  //This flag will be set if a higher priority task must be woken
341  flag = FALSE;
342 
343  //Read interrupt status register
344  status = MAC->CSR5;
345 
346  //Packet transmitted?
347  if((status & CSR5_TI_MASK) != 0)
348  {
349  //Clear TI interrupt flag
350  MAC->CSR5 = CSR5_TI_MASK;
351 
352  //Check whether the TX buffer is available for writing
353  if((txCurDmaDesc->tdes0 & TDES0_OWN) == 0)
354  {
355  //Notify the TCP/IP stack that the transmitter is ready to send
356  flag |= osSetEventFromIsr(&nicDriverInterface->nicTxEvent);
357  }
358  }
359 
360  //Packet received?
361  if((status & CSR5_RI_MASK) != 0)
362  {
363  //Clear RI interrupt flag
364  MAC->CSR5 = CSR5_RI_MASK;
365 
366  //Set event flag
367  nicDriverInterface->nicEvent = TRUE;
368  //Notify the TCP/IP stack of the event
369  flag |= osSetEventFromIsr(&netEvent);
370  }
371 
372  //Clear NIS interrupt flag
373  MAC->CSR5 = CSR5_NIS_MASK;
374 
375  //Interrupt service routine epilogue
376  osExitIsr(flag);
377 }
378 
379 
380 /**
381  * @brief A2FxxxM3 Ethernet MAC event handler
382  * @param[in] interface Underlying network interface
383  **/
384 
386 {
387  error_t error;
388 
389  //Process all pending packets
390  do
391  {
392  //Read incoming packet
393  error = a2fxxxm3EthReceivePacket(interface);
394 
395  //No more data in the receive buffer?
396  } while(error != ERROR_BUFFER_EMPTY);
397 }
398 
399 
400 /**
401  * @brief Send a setup frame
402  * @param[in] interface Underlying network interface
403  * @return Error code
404  **/
405 
407 {
408  A2fxxxm3HashTableSetupFrame *setupFrame;
409 
410  //Make sure the current buffer is available for writing
411  if((txCurDmaDesc->tdes0 & TDES0_OWN) != 0)
412  {
413  return ERROR_FAILURE;
414  }
415 
416  //Point to the buffer where to format the setup frame
417  setupFrame = (A2fxxxm3HashTableSetupFrame *) txCurDmaDesc->tdes2;
418 
419  //Clear contents
420  osMemset(setupFrame, 0, sizeof(A2fxxxm3HashTableSetupFrame));
421 
422  //Set MAC address
423  setupFrame->physicalAddr[0] = interface->macAddr.w[0];
424  setupFrame->physicalAddr[1] = interface->macAddr.w[1];
425  setupFrame->physicalAddr[2] = interface->macAddr.w[2];
426 
427  //Write the number of bytes to send
428  txCurDmaDesc->tdes1 = sizeof(A2fxxxm3HashTableSetupFrame) & TDES1_TBS1_MASK;
429  //The SET flag indicates that this is a setup frame descriptor
430  txCurDmaDesc->tdes1 |= TDES1_SET | TDES1_TCH | TDES1_FT0;
431  //Give the ownership of the descriptor to the DMA
432  txCurDmaDesc->tdes0 |= TDES0_OWN;
433 
434  //Instruct the DMA to poll the transmit descriptor list
435  MAC->CSR1 = 1;
436 
437  //Point to the next descriptor in the list
438  txCurDmaDesc = (A2fxxxm3TxDmaDesc *) txCurDmaDesc->tdes3;
439 
440  //Data successfully written
441  return NO_ERROR;
442 }
443 
444 
445 /**
446  * @brief Send a packet
447  * @param[in] interface Underlying network interface
448  * @param[in] buffer Multi-part buffer containing the data to send
449  * @param[in] offset Offset to the first data byte
450  * @param[in] ancillary Additional options passed to the stack along with
451  * the packet
452  * @return Error code
453  **/
454 
456  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
457 {
458  size_t length;
459 
460  //Retrieve the length of the packet
461  length = netBufferGetLength(buffer) - offset;
462 
463  //Check the frame length
465  {
466  //The transmitter can accept another packet
467  osSetEvent(&interface->nicTxEvent);
468  //Report an error
469  return ERROR_INVALID_LENGTH;
470  }
471 
472  //Make sure the current buffer is available for writing
473  if((txCurDmaDesc->tdes0 & TDES0_OWN) != 0)
474  {
475  return ERROR_FAILURE;
476  }
477 
478  //Copy user data to the transmit buffer
479  netBufferRead((uint8_t *) txCurDmaDesc->tdes2, buffer, offset, length);
480 
481  //Write the number of bytes to send
482  txCurDmaDesc->tdes1 = length & TDES1_TBS1_MASK;
483  //Set LS and FS flags as the data fits in a single buffer
484  txCurDmaDesc->tdes1 |= TDES1_IC | TDES1_LS | TDES1_FS | TDES1_TCH;
485  //Give the ownership of the descriptor to the DMA
486  txCurDmaDesc->tdes0 |= TDES0_OWN;
487 
488  //Instruct the DMA to poll the transmit descriptor list
489  MAC->CSR1 = 1;
490 
491  //Point to the next descriptor in the list
492  txCurDmaDesc = (A2fxxxm3TxDmaDesc *) txCurDmaDesc->tdes3;
493 
494  //Check whether the next buffer is available for writing
495  if((txCurDmaDesc->tdes0 & TDES0_OWN) == 0)
496  {
497  //The transmitter can accept another packet
498  osSetEvent(&interface->nicTxEvent);
499  }
500 
501  //Data successfully written
502  return NO_ERROR;
503 }
504 
505 
506 /**
507  * @brief Receive a packet
508  * @param[in] interface Underlying network interface
509  * @return Error code
510  **/
511 
513 {
514  error_t error;
515  size_t n;
516  NetRxAncillary ancillary;
517 
518  //Current buffer available for reading?
519  if((rxCurDmaDesc->rdes0 & RDES0_OWN) == 0)
520  {
521  //FS and LS flags should be set
522  if((rxCurDmaDesc->rdes0 & RDES0_FS) != 0 &&
523  (rxCurDmaDesc->rdes0 & RDES0_LS) != 0)
524  {
525  //Make sure no error occurred
526  if((rxCurDmaDesc->rdes0 & RDES0_ES) == 0)
527  {
528  //Retrieve the length of the frame
529  n = (rxCurDmaDesc->rdes0 >> RDES0_FL_OFFSET) & RDES0_FL_MASK;
530  //Limit the number of data to read
532 
533  //Additional options can be passed to the stack along with the packet
534  ancillary = NET_DEFAULT_RX_ANCILLARY;
535 
536  //Pass the packet to the upper layer
537  nicProcessPacket(interface, (uint8_t *) rxCurDmaDesc->rdes2, n,
538  &ancillary);
539 
540  //Valid packet received
541  error = NO_ERROR;
542  }
543  else
544  {
545  //The received packet contains an error
546  error = ERROR_INVALID_PACKET;
547  }
548  }
549  else
550  {
551  //The packet is not valid
552  error = ERROR_INVALID_PACKET;
553  }
554 
555  //Give the ownership of the descriptor back to the DMA
556  rxCurDmaDesc->rdes0 = RDES0_OWN;
557  //Point to the next descriptor in the list
558  rxCurDmaDesc = (A2fxxxm3RxDmaDesc *) rxCurDmaDesc->rdes3;
559  }
560  else
561  {
562  //No more data in the receive buffer
563  error = ERROR_BUFFER_EMPTY;
564  }
565 
566  //Instruct the DMA to poll the receive descriptor list
567  MAC->CSR2 = 1;
568 
569  //Return status code
570  return error;
571 }
572 
573 
574 /**
575  * @brief Configure MAC address filtering
576  * @param[in] interface Underlying network interface
577  * @return Error code
578  **/
579 
581 {
582  uint_t i;
583  bool_t acceptMulticast;
584 
585  //This flag will be set if multicast addresses should be accepted
586  acceptMulticast = FALSE;
587 
588  //The MAC address filter contains the list of MAC addresses to accept
589  //when receiving an Ethernet frame
590  for(i = 0; i < MAC_ADDR_FILTER_SIZE; i++)
591  {
592  //Valid entry?
593  if(interface->macAddrFilter[i].refCount > 0)
594  {
595  //Accept multicast addresses
596  acceptMulticast = TRUE;
597  //We are done
598  break;
599  }
600  }
601 
602  //Enable or disable the reception of multicast frames
603  if(acceptMulticast)
604  {
605  MAC->CSR6 |= CSR6_PM_MASK;
606  }
607  else
608  {
609  MAC->CSR6 &= ~CSR6_PM_MASK;
610  }
611 
612  //Successful processing
613  return NO_ERROR;
614 }
615 
616 
617 /**
618  * @brief Adjust MAC configuration parameters for proper operation
619  * @param[in] interface Underlying network interface
620  * @return Error code
621  **/
622 
624 {
625  //Stop transmission
626  while(((MAC->CSR5 & CSR5_TS_MASK) >> CSR5_TS_SHIFT) != CSR5_TS_STOPPED)
627  MAC->CSR6 &= ~CSR6_ST_MASK;
628 
629  //Stop reception
630  while(((MAC->CSR5 & CSR5_RS_MASK) >> CSR5_RS_SHIFT) != CSR5_RS_STOPPED)
631  MAC->CSR6 &= ~CSR6_SR_MASK;
632 
633  //10BASE-T or 100BASE-TX operation mode?
634  if(interface->linkSpeed == NIC_LINK_SPEED_100MBPS)
635  {
636  MAC->CSR6 |= CSR6_TTM_MASK;
637  }
638  else
639  {
640  MAC->CSR6 &= ~CSR6_TTM_MASK;
641  }
642 
643  //Half-duplex or full-duplex mode?
644  if(interface->duplexMode == NIC_FULL_DUPLEX_MODE)
645  {
646  MAC->CSR6 |= CSR6_FD_MASK;
647  }
648  else
649  {
650  MAC->CSR6 &= ~CSR6_FD_MASK;
651  }
652 
653  //Restart transmission and reception
654  MAC->CSR6 |= CSR6_ST_MASK | CSR6_SR_MASK;
655 
656  //Successful processing
657  return NO_ERROR;
658 }
659 
660 
661 /**
662  * @brief Write PHY register
663  * @param[in] opcode Access type (2 bits)
664  * @param[in] phyAddr PHY address (5 bits)
665  * @param[in] regAddr Register address (5 bits)
666  * @param[in] data Register value
667  **/
668 
669 void a2fxxxm3EthWritePhyReg(uint8_t opcode, uint8_t phyAddr,
670  uint8_t regAddr, uint16_t data)
671 {
672  //Synchronization pattern
674  //Start of frame
676  //Set up a write operation
678  //Write PHY address
679  a2fxxxm3EthWriteSmi(phyAddr, 5);
680  //Write register address
682  //Turnaround
684  //Write register value
686  //Release MDIO
688 }
689 
690 
691 /**
692  * @brief Read PHY register
693  * @param[in] opcode Access type (2 bits)
694  * @param[in] phyAddr PHY address (5 bits)
695  * @param[in] regAddr Register address (5 bits)
696  * @return Register value
697  **/
698 
699 uint16_t a2fxxxm3EthReadPhyReg(uint8_t opcode, uint8_t phyAddr,
700  uint8_t regAddr)
701 {
702  uint16_t data;
703 
704  //Synchronization pattern
706  //Start of frame
708  //Set up a read operation
710  //Write PHY address
711  a2fxxxm3EthWriteSmi(phyAddr, 5);
712  //Write register address
714  //Turnaround to avoid contention
716  //Read register value
717  data = a2fxxxm3EthReadSmi(16);
718  //Force the PHY to release the MDIO pin
720 
721  //Return PHY register contents
722  return data;
723 }
724 
725 
726 /**
727  * @brief SMI write operation
728  * @param[in] data Raw data to be written
729  * @param[in] length Number of bits to be written
730  **/
731 
733 {
734  //Skip the most significant bits since they are meaningless
735  data <<= 32 - length;
736 
737  //Configure MDIO as an output
738  MAC->CSR9 |= CSR9_MDEN_MASK;
739 
740  //Write the specified number of bits
741  while(length--)
742  {
743  //Write MDIO
744  if((data & 0x80000000) != 0)
745  {
746  MAC->CSR9 |= CSR9_MDO_MASK;
747  }
748  else
749  {
750  MAC->CSR9 &= ~CSR9_MDO_MASK;
751  }
752 
753  //Assert MDC
754  usleep(1);
755  MAC->CSR9 |= CSR9_MDC_MASK;
756  //Deassert MDC
757  usleep(1);
758  MAC->CSR9 &= ~CSR9_MDC_MASK;
759 
760  //Rotate data
761  data <<= 1;
762  }
763 }
764 
765 
766 /**
767  * @brief SMI read operation
768  * @param[in] length Number of bits to be read
769  * @return Data resulting from the MDIO read operation
770  **/
771 
773 {
774  uint32_t data = 0;
775 
776  //Configure MDIO as an input
777  MAC->CSR9 &= ~CSR9_MDEN_MASK;
778 
779  //Read the specified number of bits
780  while(length--)
781  {
782  //Rotate data
783  data <<= 1;
784 
785  //Assert MDC
786  MAC->CSR9 |= CSR9_MDC_MASK;
787  usleep(1);
788  //Deassert MDC
789  MAC->CSR9 &= ~CSR9_MDC_MASK;
790  usleep(1);
791 
792  //Check MDIO state
793  if((MAC->CSR9 & CSR9_MDI_MASK) != 0)
794  {
795  data |= 0x01;
796  }
797  }
798 
799  //Return the received data
800  return data;
801 }
802 
803 
804 /**
805  * @brief CRC calculation
806  * @param[in] data Pointer to the data over which to calculate the CRC
807  * @param[in] length Number of bytes to process
808  * @return Resulting CRC value
809  **/
810 
811 uint32_t a2fxxxm3EthCalcCrc(const void *data, size_t length)
812 {
813  uint_t i;
814  uint_t j;
815  uint32_t crc;
816  const uint8_t *p;
817 
818  //Point to the data over which to calculate the CRC
819  p = (uint8_t *) data;
820  //CRC preset value
821  crc = 0xFFFFFFFF;
822 
823  //Loop through data
824  for(i = 0; i < length; i++)
825  {
826  //Update CRC value
827  crc ^= p[i];
828 
829  //The message is processed bit by bit
830  for(j = 0; j < 8; j++)
831  {
832  //Update CRC value
833  if((crc & 0x01) != 0)
834  {
835  crc = (crc >> 1) ^ 0xEDB88320;
836  }
837  else
838  {
839  crc = crc >> 1;
840  }
841  }
842  }
843 
844  //Return CRC value
845  return crc;
846 }
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
#define usleep(delay)
Definition: os_port.h:303
void EthernetMAC_IRQHandler(void)
A2FxxxM3 Ethernet MAC interrupt service routine.
uint8_t opcode
Definition: dns_common.h:188
error_t a2fxxxm3EthReceivePacket(NetInterface *interface)
Receive a packet.
int bool_t
Definition: compiler_port.h:53
#define netEvent
Definition: net_legacy.h:196
@ NIC_FULL_DUPLEX_MODE
Definition: nic.h:125
size_t netBufferRead(void *dest, const NetBuffer *src, size_t srcOffset, size_t length)
Read data from a multi-part buffer.
Definition: net_mem.c:690
#define A2FXXXM3_ETH_IRQ_SUB_PRIORITY
uint8_t p
Definition: ndp.h:300
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
#define MAC_ADDR_FILTER_SIZE
Definition: ethernet.h:95
#define TRUE
Definition: os_port.h:50
uint8_t data[]
Definition: ethernet.h:222
void a2fxxxm3EthWriteSmi(uint32_t data, uint_t length)
SMI write operation.
#define SMI_TA
Definition: nic.h:68
error_t a2fxxxm3EthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
void a2fxxxm3EthEnableIrq(NetInterface *interface)
Enable interrupts.
#define SMI_START
Definition: nic.h:64
uint32_t a2fxxxm3EthReadSmi(uint_t length)
SMI read operation.
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
Definition: nic.c:392
#define osExitIsr(flag)
#define A2FXXXM3_ETH_TX_BUFFER_SIZE
void a2fxxxm3EthInitDmaDesc(NetInterface *interface)
Initialize DMA descriptor lists.
#define FALSE
Definition: os_port.h:46
error_t
Error codes.
Definition: error.h:43
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
Definition: net_misc.c:104
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
error_t a2fxxxm3EthSendSetup(NetInterface *interface)
Send a setup frame.
#define txBuffer
#define NetRxAncillary
Definition: net_misc.h:40
@ ERROR_INVALID_PACKET
Definition: error.h:140
#define NetInterface
Definition: net.h:36
@ ERROR_INVALID_LENGTH
Definition: error.h:111
@ ERROR_BUFFER_EMPTY
Definition: error.h:141
#define NetTxAncillary
Definition: net_misc.h:36
uint16_t a2fxxxm3EthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
#define TRACE_INFO(...)
Definition: debug.h:95
uint8_t length
Definition: tcp.h:368
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
Definition: net_mem.c:297
const NicDriver a2fxxxm3EthDriver
A2FxxxM3 Ethernet MAC driver.
void a2fxxxm3EthDisableIrq(NetInterface *interface)
Disable interrupts.
#define MIN(a, b)
Definition: os_port.h:63
#define rxBuffer
#define A2FXXXM3_ETH_RX_BUFFER_SIZE
#define A2FXXXM3_ETH_RX_BUFFER_COUNT
uint16_t regAddr
void a2fxxxm3EthEventHandler(NetInterface *interface)
A2FxxxM3 Ethernet MAC event handler.
#define ETH_MTU
Definition: ethernet.h:116
uint8_t n
#define osEnterIsr()
Transmit DMA descriptor.
SmartFusion (A2FxxxM3) Ethernet MAC driver.
Hash table setup frame.
#define rxDmaDesc
uint32_t a2fxxxm3EthCalcCrc(const void *data, size_t length)
CRC calculation.
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
#define txDmaDesc
@ NIC_LINK_SPEED_100MBPS
Definition: nic.h:112
void a2fxxxm3EthTick(NetInterface *interface)
A2FxxxM3 Ethernet MAC timer handler.
#define SMI_SYNC
Definition: nic.h:63
unsigned int uint_t
Definition: compiler_port.h:50
#define osMemset(p, value, length)
Definition: os_port.h:135
TCP/IP stack core.
NIC driver.
Definition: nic.h:286
#define CSR9_MDEN_MASK
void a2fxxxm3EthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
error_t a2fxxxm3EthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
#define A2FXXXM3_ETH_IRQ_PRIORITY_GROUPING
error_t a2fxxxm3EthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
error_t a2fxxxm3EthInit(NetInterface *interface)
A2FxxxM3 Ethernet MAC initialization.
Receive DMA descriptor.
@ NO_ERROR
Success.
Definition: error.h:44
Debugging facilities.
#define A2FXXXM3_ETH_IRQ_GROUP_PRIORITY
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83
#define A2FXXXM3_ETH_TX_BUFFER_COUNT