wiki:nic_driver

Version 4 (modified by alain, 10 years ago) (diff)

--

GIET-VM / NIC Driver

The nic_driver.c and nic_driver.h files define the NIC driver.

This component is a multi-channels, giga-bit Ethernet network controller. It is an external, non replicated peripheral.

  • The _nic_sync_send() and _nic_sync_receive() functions use a physical_memcpy() to transfer data between a single container (4 Kbytes buffer) in user space and the NIC internal chained buffer. They are blocking until completion of the transfer. One NIC channel must be allocated to the calling task in the mapping.

  • The _nic_cma_start_send() and _nic_cma_start_receive() functions use the vci_chbuf_dma component to transfer a flow of packets between a chained buffer in kernel space and the NIC internal chained buffer. They are non blocking. One NIC channel and two CMA channels (TX and RX) must be allocated to the calling task in the mapping.

The SEG_NIC_BASE address and the NB_NIC_CHANNELS parameter must be defined in the hard_config.h file.

The addressable registers map is defined here.

WARNING : The CMA functions are not implemented yet.

Initialization Functions

void _nic_global_init( unsigned int channels, unsigned int vis, unsigned int bc_enable, unsigned int bypass_enable )

This function initializes the NIC global registers.

  • channels : number of active channels
  • vis : bit vector(one bit per active channel)
  • bc_enable : broadcast packets accepted if non zero
  • bypass_enable : TX -> RX bypass supported if non zero

This function is used only by the boot code.

void _nic_channel_init( unsigned int index, unsigned int mac4, unsigned int mac2 )

This function initializes the NIC registers for a given channel.

  • index : channel index
  • mac4 : 32 LSB bits of the MAC address.
  • mac2 : 16 MSB bits of the MAC address.

This function is used only by the boot code.

Functions using a physical_memcpy

void _nic_sync_send( void* vbase )

This blocking function uses a physical_memcpy() to transfer one container (4 Kbytes) from a single user buffer to the NIC channel allocated to the calling task. The vbase argument is the user buffer virtual base address.

void _nic_sync_receive( void* vbase )

This blocking function uses a physical_memcpy() to transfer one container (4 Kbytes) from the NIC channel allocated to the calling task, to a single user buffer. The vbase argument is the user buffer virtual base address.

Functions using the chained buffer DMA

void _nic_cma_start_send( )

To be defined...

void _nic_cma_stop_send( )

To be defined...

void _nic_cma_start_receive( )

To be defined...

void _nic_cma_stop_receive( )

To be defined...

Interrupt Service Routines

void _nic_rx_isr( unsigned int irq_type, unsigned int irq_id, unsigned int channel )

This interrupt Service Routine handles IRQs from a NIC_RX channel.

void _nic_tx_isr( unsigned int irq_type, unsigned int irq_id, unsigned int channel )

This interrupt Service Routine handles IRQs from a NIC_TX channel.