Changes between Version 8 and Version 9 of mnc_driver
- Timestamp:
- Jan 3, 2017, 1:39:27 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
mnc_driver
v8 v9 30 30 The RX/TX queues (and the associated kernel threads) are physically distributed on various clusters, using a round robin policy (modulo the number of clusters). 31 31 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. 32 The actual number of channels NB_NIC_CHANNELS parameter, and the segment SEG_NIC_BASE address must be defined'' in the hard_config.h'' file. 34 33 35 34 The addressable registers map is defined [source:soft/giet_vm/giet_drivers/mnc_driver.h here]. 35 36 == __TX/RX queues __ == 37 38 The 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 {{{ 41 typedef 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 } 51 nic_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 63 The 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 68 Three 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 36 72 37 73 == __Access Functions__ == 38 74 39 75 === 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, 76 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 per cluster if the number of clusters is larger than 2 * NB_NIC_CHANNELS. It initialises both the CHBUF descriptors, 42 77 and the hardware NIC registers. 43 78 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 ) === 45 80 This 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. 46 81 The internal state of the queue (write pointer) can be modified if required. … … 49 84 * return a non-zero value if packet can be written / return zero if queue is full. 50 85 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 ) === 87 This 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 88 container to the NIC hardware. 89 90 === 4) void '''_mnc_tx_write'''( unsigned int channel , char * buffer , unsigned int length ) === 91 This 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 ) === 52 97 This 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. 53 98 * '''channel''' : channel index … … 59 104 * return a non-zero value if packet can be read / return zero if queue is empty. 60 105 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 ) === 68 107 This function read an Ethernet packet from the RX queue defined by the channel argument. It should be called after the _mnc_readable() function. 69 108 * '''channel''' : channel index 70 109 * '''buffer''' : pointer on buffer containing packet 71 110 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 ) === 73 112 This function set a given value in a given NIC global register. 74 113 * '''index''' : register index 75 114 * '''value''' : value to be written 76 115 77 === 7) unsigned int '''_mnc_get_global_register'''( unsigned int index ) ===116 === 8) unsigned int '''_mnc_get_global_register'''( unsigned int index ) === 78 117 This function returns the value contained in a given NIC global register. 79 118 * '''index''' : register index … … 82 121 == __ Interrupt Service Routines__ == 83 122 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 ) === 85 124 This Interrupt Service Routine handles IRQs from a NIC_RX channel. 86 125 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 ) === 88 127 This Interrupt Service Routine handles IRQs from a NIC_TX channel.