Changes between Version 8 and Version 9 of mnc_driver


Ignore:
Timestamp:
Jan 3, 2017, 1:39:27 PM (7 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • mnc_driver

    v8 v9  
    3030The RX/TX queues (and the associated kernel threads) are physically distributed on various clusters, using a round robin policy (modulo the number of clusters).
    3131
    32 The actual number of channels is defined by the NB_NIC_CHANNELS parameter in the ''hard_config.h'' file, and
    33 the SEG_NIC_BASE address must be defined in the hard_config.h file.
     32The actual number of channels  NB_NIC_CHANNELS parameter, and the segment SEG_NIC_BASE address must be defined'' in the hard_config.h'' file.
    3433
    3534The addressable registers map is defined [source:soft/giet_vm/giet_drivers/mnc_driver.h here].
     35
     36== __TX/RX queues __ ==
     37
     38The following structure defines the chained buffer descriptor, used by the MNC driver to  implement both the NIC_RX_QUEUE and NIC_TX_QUEUE. Each buffer is a 4K bytes container containing a variable number of packets. All containers are allocated in the same cluster.
     39
     40{{{
     41typedef struct nic_chbuf_s
     42{
     43    unsigned long long desc[NIC_CHBUF_DEPTH]; 
     44    unsigned int *     cont[NIC_CHBUF_DEPTH]; 
     45    unsigned int       full[NIC_CHBUF_DEPTH]; 
     46    unsigned int       cont_id;               
     47    unsigned int       pkt_id;               
     48    unsigned int       word_id;             
     49    unsigned int       timeout;             
     50}
     51nic_chbuf_t;
     52}}}
     53
     54 The chbuf descriptor contains:
     55 * an array of container pointers '''cont[]''', used by the kernel thread to access the packets contained in the containers.
     56 * an array of set/reset Boolean '''full[]''', used by both the kernel thread and by the hardware FSM for lock-less synchronisation.
     57 * an array of containers descriptors '''desc[]''', containing the physical addresses of the full[i] and cont[i] variables, is used by the NIC FSM.
     58 * the '''cont_id''' variable defines the current container for the kernel thread.
     59 * the '''pkt_id''' variable defines the current packet index for the kernel thread.
     60 * the '''word_id''' variable defines the current word index for the kernel thread.
     61 * the '''timeout''' variable defines the number of timeout checks for the kernel thread.
     62
     63The container descriptor is a 64 bits containing three fields:
     64 * the 26 LSB bits contain bits[31:6] of the status physical address.
     65 * the 26 following bits contain bits[31:6] of the buffer physical address.
     66 * the 12 MSB bits contain the common address extension.
     67
     68Three hardware parameters can be redefined if required. 
     69#define   NIC_CHBUF_DEPTH    4      // number of containers
     70#define   NIC_CHBUF_WIDTH    4096   // single container size (bytes)
     71#define   NIC_CHBUF_TIMEOUT  10     // max number of retry for a TX-CHBUF
    3672
    3773== __Access Functions__ ==
    3874
    3975 === 1) void  '''_mnc_init'''( ) ===
    40 This function allocates memory for the RX_CHBUF and TX_CHBUF implementing the RX and TX queues for all channels. It uses a round-robin policy, to distribute one CHBUF
    41 per cluster if the number of clusters is larger than 2 * NB_NIC_CHANNELS. It initialises both the CHBUF descriptors,
     76This function allocates memory for the RX_CHBUF and TX_CHBUF implementing the RX and TX queues for all channels. It uses a round-robin policy, to distribute one CHBUF per cluster if the number of clusters is larger than 2 * NB_NIC_CHANNELS. It initialises both the CHBUF descriptors,
    4277and the hardware NIC registers.
    4378
    44  === 2) unsigned int  '''_mnc_writable'''( unsigned int channel,  unsigned int length ) ===
     79 === 2) unsigned int  '''_mnc_tx_writable'''( unsigned int channel,  unsigned int length ) ===
    4580This function returns a Boolean indicating if an Ethernet packet of a given length can be stored in the TX queue defined by the channel argument.
    4681The internal state of the queue (write pointer) can be modified if required.
     
    4984 * return a non-zero value if packet can be written / return zero if queue is full.
    5085
    51  === 3) unsigned int '''_mnc_readable'''( unsigned int channel , unsigned int * src_ip , unsigned int * src_port , unsigned int * dst_ip , unsigned int * dst_port , unsigned int * length ) ===
     86 === 3) void '''_mnc_tx_timeout( unsigned int channel ) ===
     87This function implements a watch dog for the TX-QUEUE associated to a given channel: It must be periodically called to check that TX packets are not waiting indefinitely in a partially filled container. If the container state has not been modified after NIC_CHBUF_TIMEOUT checks, it releases the current
     88container to the NIC hardware.
     89
     90 === 4) void  '''_mnc_tx_write'''( unsigned int channel ,  char * buffer , unsigned int length ) ===
     91This function writes an Ethernet packet in the TX queue defined by the channel argument. It should be called after the _mnc_writable() function.
     92 * '''channel''' : channel index
     93 * '''buffer''' : pointer on buffer containing packet
     94 * '''length''' : Ethernet packet length (bytes)
     95
     96 === 5) unsigned int '''_mnc_rx_readable'''( unsigned int channel , unsigned int * src_ip , unsigned int * src_port , unsigned int * dst_ip , unsigned int * dst_port , unsigned int * length ) ===
    5297This function returns a Boolean indicating if an Ethernet packet is available in the RX queue defined by the channel argument. It also returns various informations contained in the IP and TCP/UDP headers. The internal state of the queue (read pointer) can be modified if required.
    5398 * '''channel''' : channel index
     
    59104 * return a non-zero value if packet can be read / return zero if queue is empty.
    60105                         
    61  === 4) void  '''_mnc_write'''( unsigned int channel ,  char * buffer , unsigned int length ) ===
    62 This function writes an Ethernet packet in the TX queue defined by the channel argument. It should be called after the _mnc_writable() function.
    63  * '''channel''' : channel index
    64  * '''buffer''' : pointer on buffer containing packet
    65  * '''length''' : Ethernet packet length (bytes)
    66 
    67  === 5) void  '''_mnc_read'''( unsigned int channel , char * buffer ) ===
     106 === 6) void  '''_mnc_rx_read'''( unsigned int channel , char * buffer ) ===
    68107This function read an Ethernet packet from the RX queue defined by the channel argument. It should be called after the _mnc_readable() function.
    69108 * '''channel''' : channel index
    70109 * '''buffer''' : pointer on buffer containing packet
    71110
    72  === 6) void  '''_mnc_set_global_register'''( unsigned int index , unsigned int value ) ===
     111 === 7) void  '''_mnc_set_global_register'''( unsigned int index , unsigned int value ) ===
    73112This function set a given value in a given NIC global register.
    74113 * '''index''' : register index
    75114 * '''value''' : value to be written
    76115
    77  === 7) unsigned int  '''_mnc_get_global_register'''( unsigned int index ) ===
     116 === 8) unsigned int  '''_mnc_get_global_register'''( unsigned int index ) ===
    78117This function returns the value contained in a given NIC global register.
    79118 * '''index''' : register index
     
    82121== __ Interrupt Service Routines__ ==
    83122
    84  === 8) void  '''_mnc_rx_isr'''( unsigned int irq_type,  unsigned int irq_id,  unsigned int channel ) ===
     123 === 1) void  '''_mnc_rx_isr'''( unsigned int irq_type,  unsigned int irq_id,  unsigned int channel ) ===
    85124This Interrupt Service Routine  handles IRQs from a NIC_RX channel.
    86125
    87  === 9) void  '''_mnc_tx_isr'''( unsigned int irq_type,  unsigned int irq_id,  unsigned int channel ) ===
     126 === 2) void  '''_mnc_tx_isr'''( unsigned int irq_type,  unsigned int irq_id,  unsigned int channel ) ===
    88127This Interrupt Service Routine  handles IRQs from a NIC_TX channel.