1 / 22

Ethernet Driver Changes

Ethernet Driver Changes. for NET+OS V5.1. Design Changes. Resides in bspdevicesethernet directory. Source code broken into more C files. Native driver code is separated from the TCP/IP stack and the operating system. Global variables are combined in one structure. Added a transmit task.

Download Presentation

Ethernet Driver Changes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ethernet Driver Changes for NET+OS V5.1

  2. Design Changes • Resides in bsp\devices\ethernet directory. • Source code broken into more C files. • Native driver code is separated from the TCP/IP stack and the operating system. • Global variables are combined in one structure. • Added a transmit task.

  3. Hardware related Changes • Added support for NS7520 chip. • Added transmitter lockup detection and reset. • The driver supports multiple receive DMA channels. • Mii.c identifies PHY address dynamically. • Both MAC and EFE run in half-duplex.

  4. Driver Header Files • h\efe_def.h - Ethernet driver public API, and statistics • bsp\mii.h - MII public API • In bsp\devices\ethernet directory: • eth.h - Internal Ethernet definitions

  5. Driver C Files • eth_init.c - Initialization routines • eth_reset.c - Hardware initialization • eth_dma.c - DMA related routines • eth_isr.c - Interrupt service routines • eth_mcast.c - Multicast routines

  6. Driver C Files • eth_recv.c - Receive task and related routines • eth_send.c - Transmit task and related routines • eth_watchdog.c – Code to reset receiver and transmitter lockups

  7. Driver C Files • eth_os.c - Code dependant on the OS eth_stack.c - Code dependant on the TCP/IP stack • mii.c - MII routines

  8. NS7520 Support • NS7520 has a different MAC. • Ethernet register addresses and layout have changed. • Most of the chip revision support is in eth_reset.c and mii.c.

  9. Transmitter Lockup Reset • Reset function - eth_reset_tx • The eth_tx_complete in the transmit thread detects the lockup condition. • Lockup condition - transmit complete interrupt has not cleared the Full bit in the DMA buffer descriptor.

  10. Half – Duplex operation • Full duplex for EFE causes transmit under-runs, which cause transmitter lockups. • MAC and EFE duplex is set to the same value. • ETH_NEGOTIATE_100MB_FULLD is defined to 0 is mii.h.

  11. Other MII changes • MII tries to identify PHY on different addresses. • After reading the status, mii.c clears the status bit in the MII Command Register, because NS7520 hardware does not do it.

  12. Multiple receive DMA channels #define ETH_RX_CHANNELS 1 #define ETH_MAX_RXA_DESCRIPTORS 64 #define ETH_MAX_RXB_DESCRIPTORS 1 #define ETH_MAX_RXC_DESCRIPTORS 1 #define ETH_MAX_RXD_DESCRIPTORS 1 Change ETH_RX_CHANNELS and number of buffer descriptors for channels B, C, and D to run more than one receive channel.

  13. Multiple receive DMA channels #define ETH_MAX_PACKET_LENGTH 1518 #define ETH_RX_PACKET_SIZEA 64 #define ETH_RX_PACKET_SIZEB 128 #define ETH_RX_PACKET_SIZEC 256 #define ETH_RX_PACKET_SIZED ETH_MAX_PACKET_LENGTH • Last DMA channel always receives maximum size packets. • BSP is compiled to use 1 receive DMA channel

  14. DMA Buffer Descriptors • They are made global for debug purposes. • DMA buffer descriptors are defined in eth_dma.c. • / * Transmit DMA Buffer descriptor ring */ fb_buffer_desc_t eth_tx_buffer_descriptors[ETH_MAX_TX_DESCRIPTORS];

  15. DMA Buffer Descriptors / * Receive DMA Buffer descriptors rings for channels A, B, C, and D */ fb_buffer_desc_t eth_rxa_buffer_descriptors[ETH_MAX_RXA_DESCRIPTORS]; • fb_buffer_desc_t eth_rxb_buffer_descriptors[ETH_MAX_RXB_DESCRIPTORS]; • fb_buffer_desc_t eth_rxc_buffer_descriptors[ETH_MAX_RXC_DESCRIPTORS]; • fb_buffer_desc_t eth_rxd_buffer_descriptors[ETH_MAX_RXD_DESCRIPTORS];

  16. DMA Buffer Descriptors /* Array Pointers to Receive DMA Buffer descriptor rings for channels A, B, C, and D */ fb_buffer_desc_t *eth_rx_buffer_descriptors[] = • { • eth_rxa_buffer_descriptors, • eth_rxb_buffer_descriptors, • eth_rxc_buffer_descriptors, • eth_rxd_buffer_descriptors • };

  17. Sending Packets • Packets are transmitted from application threads and the Ethernet transmit thread. • TCP/IP stack owns device transmit queues. • TCP/IP stack calls driver’s transmit routines in critical section.

  18. Transmit Task • Transmit DMA ISR wakes up the transmit thread. • The transmit thread calls eth_restart in a loop. • eth_restart calls a stack function to free the transmitted packet, and send the next queued packet.

  19. eth.h • eth.h explains what definitions are BSP configurable. • eth.h defines ethData structure. • Driver modules use and a global pointer: ethData *eth_datap.

  20. typedef struct • { • void *pnetdev; /* pointer to TCP/IP stack device data */ • unsigned int min_packet_len; /* minimum packet length */ • unsigned int max_packet_len[ETH_RX_CHANNELS]; /*minimum packet length*/ • char state; /* drive state */ • char efe_mii_100; /* 1 = 100Mb, 0 = 10 Mb */ • char mac_fulld; /* MAC is running full duplex */ • char efe_fulld; /* EFE is running full duplex */ • char pna_mode; /* TRUE = pNa mode is set */ • char loopback; /* loopback mode */ • char rx_reset_in_progress; /* receiver reset in progress */ int rx_bd_index[ETH_RX_CHANNELS]; /* Receive DMA software index */ • int tx_bd_head; /* Transmit DMA head index */ • int tx_bd_tail; /* Transmit DMA tail index */ • char mac_addr[ETH_MAC_ADDR_SIZE]; /* MAC adddress */ • ethFunction recv_task; /* receive task function pointer */ • ethFunction xmit_task; /* transmit task function pointer */ • ethFunction watchdog; /* watchdog function pointer */ • } ethData;

  21. eth_os.c • eth_init_os_services allocates memory and creates threads, timers, event flags, etc. without starting them. • eth_start_os_services starts threads, timers. eth_stop_os_services stops threads, timers. • eth_task_wake wakes up a driver thread. • eth_task_sleep suspends a driver thread until it’s waken up by eth_task_wake.

  22. eth_stack.c • Provides a glue layer between the driver and TCP/IP stack. • The only file to include stack headers. • Handles everything about struct m.

More Related