aps3_eth_driver.c
Go to the documentation of this file.
1 /**
2  * @file aps3_eth_driver.c
3  * @brief Cortus APS3 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.0
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL NIC_TRACE_LEVEL
33 
34 //Dependencies
35 #include <machine/sfradr.h>
36 #include <machine/sfradr_eth.h>
37 #include <machine/ethernet.h>
38 #include <machine/ic.h>
39 #undef _ETHERNET_H
40 #include "core/net.h"
42 #include "debug.h"
43 
44 //Transmit buffer
45 #define txBuffer ((uint8_t *) SFRADR_ETH_TX_MEM_BOTTOM_AD)
46 //Receive buffer
47 #define rxBuffer ((uint8_t *) SFRADR_ETH_RX_MEM_BOTTOM_AD)
48 
49 //Transmit DMA descriptors
50 #define txDmaDesc ((Aps3TxDmaDesc *) (SFRADR_ETH_TX_MEM_BOTTOM_AD + \
51  APS3_ETH_TX_BUFFER_COUNT * APS3_ETH_TX_BUFFER_SIZE))
52 
53 //Receive DMA descriptors
54 #define rxDmaDesc ((Aps3RxDmaDesc *) (SFRADR_ETH_RX_MEM_BOTTOM_AD + \
55  APS3_ETH_RX_BUFFER_COUNT * APS3_ETH_RX_BUFFER_SIZE))
56 
57 //Underlying network interface
58 static NetInterface *nicDriverInterface;
59 
60 
61 /**
62  * @brief Cortus APS3 Ethernet MAC driver
63  **/
64 
66 {
68  ETH_MTU,
79  TRUE,
80  TRUE,
81  TRUE,
82  FALSE
83 };
84 
85 
86 /**
87  * @brief Cortus APS3 Ethernet MAC initialization
88  * @param[in] interface Underlying network interface
89  * @return Error code
90  **/
91 
93 {
94  error_t error;
95 
96  //Debug message
97  TRACE_INFO("Initializing Cortus APS3 Ethernet MAC...\r\n");
98 
99  //Save underlying network interface
100  nicDriverInterface = interface;
101 
102  //Adjust MDC clock range
103  eth_miim->miim_clock_divider = 32;
104 
105  //Valid Ethernet PHY or switch driver?
106  if(interface->phyDriver != NULL)
107  {
108  //Ethernet PHY initialization
109  error = interface->phyDriver->init(interface);
110  }
111  else if(interface->switchDriver != NULL)
112  {
113  //Ethernet switch initialization
114  error = interface->switchDriver->init(interface);
115  }
116  else
117  {
118  //The interface is not properly configured
119  error = ERROR_FAILURE;
120  }
121 
122  //Any error to report?
123  if(error)
124  {
125  return error;
126  }
127 
128  //Reset Ethernet MAC peripheral
129  eth_mac->sw_reset = 1;
130 
131  //Set the MAC address of the station
132  eth_mac->addr_low = interface->macAddr.w[0] | (interface->macAddr.w[1] << 16);
133  eth_mac->addr_high = interface->macAddr.w[2];
134 
135  //Initialize hash table
136  eth_mac->hash_filter_low = 0;
137  eth_mac->hash_filter_high = 0;
138 
139  //Configure the receive filter
140  eth_mac->unicast = 1;
141  eth_mac->multicast = 0;
142  eth_mac->broadcast = 1;
143  eth_mac->hash = 1;
144  eth_mac->exact_addr = 1;
145 
146  //Default duplex mode
147  eth_mac->full_duplex = 0;
148 
149  //Automatic padding and CRC generation
150  eth_mac->no_padding = 0;
151  eth_mac->crc_disable = 0;
152 
153  //Set the maximum frame length
154  eth_mac->max_frame_size = APS3_ETH_RX_BUFFER_SIZE;
155 
156  //Set transmit and receive thresholds
157  eth_tx->tx_threshold = 0;
158  eth_rx->rx_threshold = 0;
159 
160  //Disable indefinite deferral
161  eth_mac->indefinite_deferral = 0;
162  //Number of attempts to transmit a frame before aborting
163  eth_mac->max_deferral = 15;
164 
165  //Use default collision window (112 half-octets)
166  eth_mac->collision_window = 111;
167  //Maximum Number of Collisions
168  eth_mac->max_collision = 15;
169 
170  //Automatic backoff on collision
171  eth_mac->no_backoff = 0;
172 
173  //Use the default interframe gap (24 half-octets or 96 bits)
174  eth_mac->interframe_gap = 23;
175 
176  //Initialize DMA descriptor lists
177  aps3EthInitDmaDesc(interface);
178 
179  //Configure TX interrupts
180  eth_tx->tx_irq_mask = TX_IRQ_MASK_MEMORY_AVAILABLE;
181  //Configure RX interrupts
182  eth_rx->rx_irq_mask = RX_IRQ_MASK_FRAME_READY;
183 
184  //Configure TX interrupt priority
185  irq[IRQ_ETH_TX].ipl = APS3_ETH_IRQ_PRIORITY;
186  //Configure RX interrupt priority
187  irq[IRQ_ETH_RX].ipl = APS3_ETH_IRQ_PRIORITY;
188 
189  //Enable transmission and reception
190  eth_tx->tx_enable = 1;
191  eth_rx->rx_enable = 1;
192 
193  //Accept any packets from the upper layer
194  osSetEvent(&interface->nicTxEvent);
195 
196  //Successful initialization
197  return NO_ERROR;
198 }
199 
200 
201 /**
202  * @brief Initialize DMA descriptor lists
203  * @param[in] interface Underlying network interface
204  **/
205 
207 {
208  uint_t i;
209 
210  //Initialize TX DMA descriptor list
211  for(i = 0; i < APS3_ETH_TX_BUFFER_COUNT; i++)
212  {
213  //Transmit buffer address
214  txDmaDesc[i].addr = (uint32_t) txBuffer + (APS3_ETH_TX_BUFFER_SIZE * i);
215  //Transmit buffer size
216  txDmaDesc[i].size = 0;
217  //Transmit status
218  txDmaDesc[i].status = 0;
219  }
220 
221  //Initialize RX DMA descriptor list
222  for(i = 0; i < APS3_ETH_RX_BUFFER_COUNT; i++)
223  {
224  //Receive buffer address
225  rxDmaDesc[i].addr = (uint32_t) rxBuffer + (APS3_ETH_RX_BUFFER_SIZE * i);
226  //Receive buffer size
227  rxDmaDesc[i].size = 0;
228  //Receive status
229  rxDmaDesc[i].status = 0;
230  }
231 
232  //Start location of the TX descriptor list
233  eth_tx->tx_desc_base_addr = (uint32_t) txDmaDesc;
234  //Number of TX descriptors
235  eth_tx->tx_desc_number = APS3_ETH_TX_BUFFER_COUNT - 1;
236 
237  //Start location of the RX descriptor list
238  eth_rx->rx_desc_base_addr = (uint32_t) rxDmaDesc;
239  //Number of RX descriptors
240  eth_rx->rx_desc_number = APS3_ETH_RX_BUFFER_COUNT - 1;
241 }
242 
243 
244 /**
245  * @brief Cortus APS3 Ethernet MAC timer handler
246  *
247  * This routine is periodically called by the TCP/IP stack to handle periodic
248  * operations such as polling the link state
249  *
250  * @param[in] interface Underlying network interface
251  **/
252 
253 void aps3EthTick(NetInterface *interface)
254 {
255  //Valid Ethernet PHY or switch driver?
256  if(interface->phyDriver != NULL)
257  {
258  //Handle periodic operations
259  interface->phyDriver->tick(interface);
260  }
261  else if(interface->switchDriver != NULL)
262  {
263  //Handle periodic operations
264  interface->switchDriver->tick(interface);
265  }
266  else
267  {
268  //Just for sanity
269  }
270 }
271 
272 
273 /**
274  * @brief Enable interrupts
275  * @param[in] interface Underlying network interface
276  **/
277 
279 {
280  //Enable Ethernet MAC interrupts
281  irq[IRQ_ETH_TX].ien = 1;
282  irq[IRQ_ETH_RX].ien = 1;
283 
284  //Valid Ethernet PHY or switch driver?
285  if(interface->phyDriver != NULL)
286  {
287  //Enable Ethernet PHY interrupts
288  interface->phyDriver->enableIrq(interface);
289  }
290  else if(interface->switchDriver != NULL)
291  {
292  //Enable Ethernet switch interrupts
293  interface->switchDriver->enableIrq(interface);
294  }
295  else
296  {
297  //Just for sanity
298  }
299 }
300 
301 
302 /**
303  * @brief Disable interrupts
304  * @param[in] interface Underlying network interface
305  **/
306 
308 {
309  //Disable Ethernet MAC interrupts
310  irq[IRQ_ETH_TX].ien = 0;
311  irq[IRQ_ETH_RX].ien = 0;
312 
313  //Valid Ethernet PHY or switch driver?
314  if(interface->phyDriver != NULL)
315  {
316  //Disable Ethernet PHY interrupts
317  interface->phyDriver->disableIrq(interface);
318  }
319  else if(interface->switchDriver != NULL)
320  {
321  //Disable Ethernet switch interrupts
322  interface->switchDriver->disableIrq(interface);
323  }
324  else
325  {
326  //Just for sanity
327  }
328 }
329 
330 
331 /**
332  * @brief Ethernet MAC transmit interrupt service routine
333  **/
334 
336 {
337  bool_t flag;
338 
339  //Interrupt service routine prologue
340  osEnterIsr();
341 
342  //This flag will be set if a higher priority task must be woken
343  flag = FALSE;
344 
345  //Check interrupt flag
346  if((eth_tx->tx_status & TX_IRQ_MASK_MEMORY_AVAILABLE) != 0)
347  {
348  //Disable TX interrupts
349  eth_tx->tx_irq_mask = 0;
350 
351  //Check whether the TX buffer is available for writing
352  if(eth_tx->tx_desc_status == 0)
353  {
354  //Notify the TCP/IP stack that the transmitter is ready to send
355  flag = osSetEventFromIsr(&nicDriverInterface->nicTxEvent);
356  }
357  }
358 
359  //Interrupt service routine epilogue
360  osExitIsr(flag);
361 }
362 
363 
364 /**
365  * @brief Ethernet MAC receive interrupt service routine
366  **/
367 
369 {
370  bool_t flag;
371 
372  //Interrupt service routine prologue
373  osEnterIsr();
374 
375  //This flag will be set if a higher priority task must be woken
376  flag = FALSE;
377 
378  //Disable RX interrupts
379  eth_rx->rx_irq_mask = 0;
380 
381  //Set event flag
382  nicDriverInterface->nicEvent = TRUE;
383  //Notify the TCP/IP stack of the event
384  flag = osSetEventFromIsr(&netEvent);
385 
386  //Interrupt service routine epilogue
387  osExitIsr(flag);
388 }
389 
390 
391 /**
392  * @brief Cortus APS3 Ethernet MAC event handler
393  * @param[in] interface Underlying network interface
394  **/
395 
397 {
398  error_t error;
399 
400  //Packet received?
401  if((eth_rx->rx_status & RX_IRQ_MASK_FRAME_READY) != 0)
402  {
403  //Process all pending packets
404  do
405  {
406  //Read incoming packet
407  error = aps3EthReceivePacket(interface);
408 
409  //No more data in the receive buffer?
410  } while(error != ERROR_BUFFER_EMPTY);
411  }
412 
413  //Re-enable RX interrupts
414  eth_rx->rx_irq_mask = RX_IRQ_MASK_FRAME_READY;
415 }
416 
417 
418 /**
419  * @brief Send a packet
420  * @param[in] interface Underlying network interface
421  * @param[in] buffer Multi-part buffer containing the data to send
422  * @param[in] offset Offset to the first data byte
423  * @param[in] ancillary Additional options passed to the stack along with
424  * the packet
425  * @return Error code
426  **/
427 
429  const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
430 {
431  uint_t i;
432  size_t length;
433 
434  //Retrieve the length of the packet
435  length = netBufferGetLength(buffer) - offset;
436 
437  //Check the frame length
439  {
440  //The transmitter can accept another packet
441  osSetEvent(&interface->nicTxEvent);
442  //Report an error
443  return ERROR_INVALID_LENGTH;
444  }
445 
446  //Make sure the current buffer is available for writing
447  if(eth_tx->tx_desc_status)
448  {
449  //Re-enable TX interrupts
450  eth_tx->tx_irq_mask = TX_IRQ_MASK_MEMORY_AVAILABLE;
451  //Report an error
452  return ERROR_FAILURE;
453  }
454 
455  //Get the index of the current descriptor
456  i = eth_tx->tx_desc_produce;
457 
458  //Copy user data to the transmit buffer
459  netBufferRead((uint8_t *) txDmaDesc[i].addr, buffer, offset, length);
460  //Write the number of bytes to send
461  txDmaDesc[i].size = length;
462 
463  //Start transmission
464  eth_tx->tx_sw_done = 1;
465 
466  //Check whether the next buffer is available for writing
467  if(!eth_tx->tx_desc_status)
468  {
469  //The transmitter can accept another packet
470  osSetEvent(&interface->nicTxEvent);
471  }
472  else
473  {
474  //Re-enable TX interrupts
475  eth_tx->tx_irq_mask = TX_IRQ_MASK_MEMORY_AVAILABLE;
476  }
477 
478  //Data successfully written
479  return NO_ERROR;
480 }
481 
482 
483 /**
484  * @brief Receive a packet
485  * @param[in] interface Underlying network interface
486  * @return Error code
487  **/
488 
490 {
491  error_t error;
492  uint_t i;
493  size_t n;
494  NetRxAncillary ancillary;
495 
496  //Current buffer available for reading?
497  if(eth_rx->rx_desc_status == 0)
498  {
499  //Point to the current descriptor
500  i = eth_rx->rx_desc_consume;
501 
502  //Make sure no error occurred
503  if((rxDmaDesc[i].status & RX_DESC_RECEIVE_ERROR) == 0)
504  {
505  //Retrieve the length of the frame
506  n = rxDmaDesc[i].size;
507  //Limit the number of data to read
509 
510  //Additional options can be passed to the stack along with the packet
511  ancillary = NET_DEFAULT_RX_ANCILLARY;
512 
513  //Pass the packet to the upper layer
514  nicProcessPacket(interface, (uint8_t *) rxDmaDesc[i].addr, n,
515  &ancillary);
516 
517  //Valid packet received
518  error = NO_ERROR;
519  }
520  else
521  {
522  //The received packet contains an error
523  error = ERROR_INVALID_PACKET;
524  }
525 
526  //The frame has been has been processed by the software
527  //and is no longer needed
528  eth_rx->rx_sw_done = 1;
529  }
530  else
531  {
532  //No more data in the receive buffer
533  error = ERROR_BUFFER_EMPTY;
534  }
535 
536  //Return status code
537  return error;
538 }
539 
540 
541 /**
542  * @brief Configure MAC address filtering
543  * @param[in] interface Underlying network interface
544  * @return Error code
545  **/
546 
548 {
549  uint_t i;
550  uint_t k;
551  uint32_t crc;
552  uint32_t hashTable[2];
553  MacFilterEntry *entry;
554 
555  //Debug message
556  TRACE_DEBUG("Updating MAC filter...\r\n");
557 
558  //Set the MAC address of the station
559  eth_mac->addr_low = interface->macAddr.w[0] | (interface->macAddr.w[1] << 16);
560  eth_mac->addr_high = interface->macAddr.w[2];
561 
562  //Clear hash table
563  hashTable[0] = 0;
564  hashTable[1] = 0;
565 
566  //The MAC address filter contains the list of MAC addresses to accept
567  //when receiving an Ethernet frame
568  for(i = 0; i < MAC_ADDR_FILTER_SIZE; i++)
569  {
570  //Point to the current entry
571  entry = &interface->macAddrFilter[i];
572 
573  //Valid entry?
574  if(entry->refCount > 0)
575  {
576  //Compute CRC over the current MAC address
577  crc = aps3EthCalcCrc(&entry->addr, sizeof(MacAddr));
578  //Calculate the corresponding index in the table
579  k = (crc >> 23) & 0x3F;
580  //Update hash table contents
581  hashTable[k / 32] |= (1 << (k % 32));
582  }
583  }
584 
585  //Disable transmission and reception
586  eth_tx->tx_enable = 0;
587  eth_rx->rx_enable = 0;
588 
589  //Write the hash table
590  eth_mac->hash_filter_low = hashTable[0];
591  eth_mac->hash_filter_high = hashTable[1];
592 
593  //Debug message
594  TRACE_DEBUG(" hash_filter_low = %08" PRIX32 "\r\n", hashTable[0]);
595  TRACE_DEBUG(" hash_filter_high = %08" PRIX32 "\r\n", hashTable[1]);
596 
597  //Re-enable transmission and reception
598  eth_tx->tx_enable = 1;
599  eth_rx->rx_enable = 1;
600 
601  //Successful processing
602  return NO_ERROR;
603 }
604 
605 
606 /**
607  * @brief Adjust MAC configuration parameters for proper operation
608  * @param[in] interface Underlying network interface
609  * @return Error code
610  **/
611 
613 {
614  //Disable transmission and reception
615  eth_tx->tx_enable = 0;
616  eth_rx->rx_enable = 0;
617 
618  //Half-duplex or full-duplex mode?
619  if(interface->duplexMode == NIC_FULL_DUPLEX_MODE)
620  {
621  eth_mac->full_duplex = 1;
622  }
623  else
624  {
625  eth_mac->full_duplex = 0;
626  }
627 
628  //Re-enable transmission and reception
629  eth_tx->tx_enable = 1;
630  eth_rx->rx_enable = 1;
631 
632  //Successful processing
633  return NO_ERROR;
634 }
635 
636 
637 /**
638  * @brief Write PHY register
639  * @param[in] opcode Access type (2 bits)
640  * @param[in] phyAddr PHY address (5 bits)
641  * @param[in] regAddr Register address (5 bits)
642  * @param[in] data Register value
643  **/
644 
645 void aps3EthWritePhyReg(uint8_t opcode, uint8_t phyAddr,
646  uint8_t regAddr, uint16_t data)
647 {
648  //Valid opcode?
649  if(opcode == SMI_OPCODE_WRITE)
650  {
651  //Wait for the MII management module to be ready
652  while(!eth_miim->miim_status)
653  {
654  }
655 
656  //PHY address
657  eth_miim->miim_phy_addr = phyAddr;
658  //Register address
659  eth_miim->miim_phy_register_addr = regAddr;
660  //Data to be written in the PHY register
661  eth_miim->miim_data = data;
662 
663  //Start a write operation
664  eth_miim->miim_read_write = 0;
665  //Wait for the write to complete
666  while(!eth_miim->miim_status)
667  {
668  }
669  }
670  else
671  {
672  //The MAC peripheral only supports standard Clause 22 opcodes
673  }
674 }
675 
676 
677 /**
678  * @brief Read PHY register
679  * @param[in] opcode Access type (2 bits)
680  * @param[in] phyAddr PHY address (5 bits)
681  * @param[in] regAddr Register address (5 bits)
682  * @return Register value
683  **/
684 
685 uint16_t aps3EthReadPhyReg(uint8_t opcode, uint8_t phyAddr,
686  uint8_t regAddr)
687 {
688  uint16_t data;
689 
690  //Valid opcode?
691  if(opcode == SMI_OPCODE_READ)
692  {
693  //Wait for the MII management module to be ready
694  while(!eth_miim->miim_status)
695  {
696  }
697 
698  //PHY address
699  eth_miim->miim_phy_addr = phyAddr;
700  //Register address
701  eth_miim->miim_phy_register_addr = regAddr;
702 
703  //Start a read operation
704  eth_miim->miim_read_write = 1;
705  //Wait for the read to complete
706  while(!eth_miim->miim_status)
707  {
708  }
709 
710  //Get register value
711  data = eth_miim->miim_data;
712  }
713  else
714  {
715  //The MAC peripheral only supports standard Clause 22 opcodes
716  data = 0;
717  }
718 
719  //Return the value of the PHY register
720  return data;
721 }
722 
723 
724 /**
725  * @brief CRC calculation
726  * @param[in] data Pointer to the data over which to calculate the CRC
727  * @param[in] length Number of bytes to process
728  * @return Resulting CRC value
729  **/
730 
731 uint32_t aps3EthCalcCrc(const void *data, size_t length)
732 {
733  uint_t i;
734  uint_t j;
735  uint32_t crc;
736  const uint8_t *p;
737 
738  //Point to the data over which to calculate the CRC
739  p = (uint8_t *) data;
740  //CRC preset value
741  crc = 0xFFFFFFFF;
742 
743  //Loop through data
744  for(i = 0; i < length; i++)
745  {
746  //Update CRC value
747  crc ^= p[i];
748 
749  //The message is processed bit by bit
750  for(j = 0; j < 8; j++)
751  {
752  //Update CRC value
753  if((crc & 0x01) != 0)
754  {
755  crc = (crc >> 1) ^ 0xEDB88320;
756  }
757  else
758  {
759  crc = crc >> 1;
760  }
761  }
762  }
763 
764  //Return CRC value
765  return ~crc;
766 }
error_t aps3EthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
#define txDmaDesc
uint16_t aps3EthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
void aps3EthTxIrqHandler(void)
Ethernet MAC transmit interrupt service routine.
#define rxBuffer
void aps3EthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.
error_t aps3EthReceivePacket(NetInterface *interface)
Receive a packet.
void aps3EthRxIrqHandler(void)
Ethernet MAC receive interrupt service routine.
error_t aps3EthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
const NicDriver aps3EthDriver
Cortus APS3 Ethernet MAC driver.
uint32_t aps3EthCalcCrc(const void *data, size_t length)
CRC calculation.
void aps3EthEventHandler(NetInterface *interface)
Cortus APS3 Ethernet MAC event handler.
#define txBuffer
#define rxDmaDesc
void aps3EthDisableIrq(NetInterface *interface)
Disable interrupts.
error_t aps3EthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
void aps3EthInitDmaDesc(NetInterface *interface)
Initialize DMA descriptor lists.
error_t aps3EthInit(NetInterface *interface)
Cortus APS3 Ethernet MAC initialization.
void aps3EthTick(NetInterface *interface)
Cortus APS3 Ethernet MAC timer handler.
void aps3EthEnableIrq(NetInterface *interface)
Enable interrupts.
Cortus APS3 Ethernet MAC driver.
#define APS3_ETH_RX_BUFFER_COUNT
#define APS3_ETH_TX_BUFFER_COUNT
#define APS3_ETH_IRQ_PRIORITY
#define APS3_ETH_RX_BUFFER_SIZE
#define APS3_ETH_TX_BUFFER_SIZE
#define RX_DESC_RECEIVE_ERROR
#define TX_IRQ_MASK_MEMORY_AVAILABLE
#define RX_IRQ_MASK_FRAME_READY
unsigned int uint_t
Definition: compiler_port.h:50
int bool_t
Definition: compiler_port.h:53
Debugging facilities.
#define TRACE_DEBUG(...)
Definition: debug.h:107
#define TRACE_INFO(...)
Definition: debug.h:95
uint8_t n
uint8_t opcode
Definition: dns_common.h:188
error_t
Error codes.
Definition: error.h:43
@ ERROR_BUFFER_EMPTY
Definition: error.h:141
@ NO_ERROR
Success.
Definition: error.h:44
@ ERROR_INVALID_PACKET
Definition: error.h:140
@ ERROR_INVALID_LENGTH
Definition: error.h:111
@ ERROR_FAILURE
Generic error code.
Definition: error.h:45
#define ETH_MTU
Definition: ethernet.h:116
uint8_t data[]
Definition: ethernet.h:222
MacAddr
Definition: ethernet.h:195
#define MAC_ADDR_FILTER_SIZE
Definition: ethernet.h:95
uint16_t regAddr
Ipv4Addr addr
Definition: nbns_common.h:123
uint8_t p
Definition: ndp.h:300
TCP/IP stack core.
#define NetInterface
Definition: net.h:36
#define netEvent
Definition: net_legacy.h:196
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
Definition: net_mem.c:297
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:674
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
Definition: net_misc.c:101
#define NetRxAncillary
Definition: net_misc.h:40
#define NetTxAncillary
Definition: net_misc.h:36
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
Definition: nic.c:391
#define SMI_OPCODE_WRITE
Definition: nic.h:66
@ NIC_TYPE_ETHERNET
Ethernet interface.
Definition: nic.h:83
#define SMI_OPCODE_READ
Definition: nic.h:67
@ NIC_FULL_DUPLEX_MODE
Definition: nic.h:125
#define MIN(a, b)
Definition: os_port.h:63
#define TRUE
Definition: os_port.h:50
#define FALSE
Definition: os_port.h:46
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
#define osEnterIsr()
#define osExitIsr(flag)
MAC filter table entry.
Definition: ethernet.h:262
MacAddr addr
MAC address.
Definition: ethernet.h:263
uint_t refCount
Reference count for the current entry.
Definition: ethernet.h:264
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
NIC driver.
Definition: nic.h:283
uint8_t length
Definition: tcp.h:368