Ethernet driver changes
Download
1 / 22

Ethernet Driver Changes - PowerPoint PPT Presentation


  • 54 Views
  • Uploaded on

Ethernet Driver Changes. for NET+OS V5.1. 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.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Ethernet Driver Changes' - tavorian-ayden


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Ethernet driver changes

Ethernet Driver Changes

for NET+OS V5.1


Design changes
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.


Hardware related changes
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.


Driver header files
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


Driver c files
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


Driver c files1
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


Driver c files2
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


Ns7520 support
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.


Transmitter lockup reset
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.


Half duplex operation
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.


Other mii changes
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.


Multiple receive dma channels
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.


Multiple receive dma channels1
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


Dma buffer descriptors
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];


Dma buffer descriptors1
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];


Dma buffer descriptors2
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

  • };


Sending packets
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.


Transmit task
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.


Eth h
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.


Ethernet driver changes

  • 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;


Eth os c
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.


Eth stack c
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.