Changes between Initial Version and Version 1 of Component/Vci Ethernet


Ignore:
Timestamp:
Sep 26, 2012, 5:23:00 PM (12 years ago)
Author:
becoulet
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Component/Vci Ethernet

    v1 v1  
     1[wiki:Component SocLib Components General Index]
     2
     3= !VciEthernet =
     4
     5== Functional Description ==
     6
     7This component is an network controller which enables connecting embedded software running in the simulator to real ethernet networks outside the simulation.
     8
     9Ethernet frames are relayed using an ethernet tap device on the host operating system. Such virtual ethernet device can be bridged to a physical interface so that the VciEthernet component is able to receive and transmit real world packets and access the internet.
     10
     11The controller has a built-in DMA engine and separate RX and TX packet FIFOs.
     12
     13The TX FIFO must be filled by the software with size and address of packets to send. When a packet has been processed, it must be popped from the FIFO. The RX FIFO is filled by the software with size and address of buffers ready to store incoming packets. When a packet has been received, it can be popped from the FIFO. The maximum size of the FIFOs must not be exceeded by pushing too many entries without first popping the processing results.
     14
     15A DMA transfer starts as soon as some packets are pushed in the TX FIFO or an incoming packets is available and some buffers are free in the RX FIFO. An interrupt can be triggered when a TX or RX operation is completed.
     16
     17The device is controlled by accessing a few memory mapped registers:
     18
     19  * `ETHERNET_TX_SIZE` (write): Used to set the size of the packet to send, must be set before pushing the address in the TX FIFO.
     20
     21  * `ETHERNET_TX_FIFO` (write): Push address and size of packet to send on TX FIFO.
     22
     23  * `ETHERNET_TX_FIFO` (read): Pop the status of sent packet from the TX FIFO. Contains 0 if no completed TX packet is available in the FIFO. A value of 1 indicates a successfully transmitted packet and other values are error codes.
     24
     25  * `ETHERNET_RX_SIZE` (write): Used to set the size of RX buffer, must be set before pushing the address in the FIFO.
     26
     27  * `ETHERNET_RX_SIZE` (read): Contains the actual size of the received packet, this register can be read before popping the associated status from the FIFO.
     28
     29  * `ETHERNET_RX_FIFO` (write): Used to push address and size of a new buffer on the RX FIFO.
     30
     31  * `ETHERNET_RX_FIFO` (read): Pop the status of received packet from the RX FIFO. Contains 0 if no completed RX packet is available in the FIFO. A value of 1 indicates a successfully received packet and other values are error codes.
     32
     33  * `ETHERNET_STATUS` (read): Contains device status flags. Bit 0 indicate if the link is up. Bit 1 is set if a completed TX operation can be popped from the TX FIFO and Bit 2 is set if a completed RX packet can be popped from the RX FIFO.
     34
     35  * `ETHERNET_CTRL` (write): Perform device control operations. Setting bit 0 resets the device and disable interrupts. Setting bit 1 enables the TX done interrupt, setting bit 2 enables the RX done interrupt and setting bit 3 enables the link status changed interrupt.
     36
     37  * `ETHERNET_FIFO_SIZE` (read): Contain maximum size of the TX & RX FIFOs.
     38
     39  * `ETHERNET_MAC_LOW` and ETHERNET_MAC_HIGH (read): Contain the device MAC address.
     40
     41== Using the virtal tap device ==
     42
     43To be able to create a virtual ethernet device on the host operating system, the SoCLib simulator which contains the VciEthernet component must be granted some privileges. There is no need to run the simulation as root, instead you can setup some special privileges for the simulator. Under GNU/Linux this can be done by running:
     44
     45{{{
     46sudo setcap cap_net_admin=eip ./simulator
     47}}}
     48This command must be executed again if you generate a new executable.
     49
     50Once the simulation as started, the tap device associated with the VciEthernet component is down and so is the link status reported by the VciEthernet component inside the simulation. This can be changed by setting the interface up:
     51
     52{{{
     53sudo ifconfig soclib0 up
     54}}}
     55It's likely that the host operating system will start sending probing packets on this interface and these packets will be received inside the simulation provided that the embedded operating system has properly configured the VciEthernet device.
     56
     57You can then bridge the `soclib0` interface with a real interface like `eht0` for instance:
     58
     59{{{
     60sudo brctl addbr br0
     61
     62sudo brctl addif br0 soclib0
     63sudo brctl addif br0 eth0
     64
     65sudo ifconfig br0 up
     66}}}
     67
     68== Component definition & usage ==
     69
     70source:trunk/soclib/soclib/module/connectivity_component/vci_ethernet/caba/metadata/vci_ethernet.sd
     71
     72See [wiki:SoclibCc/VciParameters SoclibCc/VciParameters]
     73{{{
     74Uses( 'vci_ethernet', **vci_parameters )
     75}}}
     76
     77== CABA  Implementation ==
     78
     79=== CABA sources ===
     80
     81 * interface : source:trunk/soclib/soclib/module/connectivity_component/vci_ethernet/caba/source/include/vci_ethernet.h
     82 * registers : source:trunk/soclib/soclib/module/connectivity_component/vci_ethernet/include/soclib/ethernet.h
     83 * implementation : source:trunk/soclib/soclib/module/connectivity_component/vci_ethernet/caba/source/src/vci_ethernet.cpp
     84
     85=== CABA Constructor parameters ===
     86
     87{{{
     88VciEthernet(
     89     sc_module_name name,   //  Component Name
     90     const soclib::common::MappingTable &mt, // MappingTable
     91     const soclib::common::IntTab &srcid,    // Initiator index
     92     const soclib::common::IntTab &tgtid,    // Target index
     93     const std::string &if_name = "soclib0"); // host os tap interface name
     94}}}
     95
     96=== CABA Ports ===
     97
     98 * '''p_resetn''' : Global system reset
     99 * '''p_clk''' : Global system clock
     100 * '''p_vci_target''' : The VCI target port
     101 * '''p_vci_initiator''' : The VCI initiator port
     102 * '''p_irq''' : Interrupt port
     103