Changes between Version 1 and Version 2 of nic_device_api

Jan 26, 2020, 7:41:37 PM (3 years ago)



  • nic_device_api

    v1 v2  
    1 = TBD =
     1= NIC device API =
     5== __A) General principles__ ==
     8This device provide access to an external generic Gigabit Ethernet network controller. It assume that the NIC hardware peripheral has a DMA capability, and can access two packets queues in kernel memory for sent (TX) and received (RX) packets. Packets are (Ethernet/IPV4).
     10The NIC device is handling two (infinite) streams of packets to or from the network. It is the driver responsibility to move the RX packets from the NIC to the RX queue, and the TX packets from the TX queue to the NIC.
     12AS the RX and TX queues are independant, there is one NIC-RX device descriptor to handle RX packets, and another NIC-TX device descriptor to handle TX packets. In order to improve throughput, the hardware NIC controller can (optionnally) implements multiple (N) channels:
     13 * The RX channels are indexed by an hash key derived from the source IP address.
     14 * The TX channels are indexed by an hash key derived from the destination IP address.
     15These 2*N chdev descriptors, and 2*N associated server threads, are distributed in  clusters.
     16The  2*N server threads implement the protocols stack. The RX server threads block and deschedule when the RX queue is empty. The TX server threads block and deschedule when the TX queue is full.
     18It is the driver responsibily to re-activate a blocked server thread when the queue state is modified: not full for TX, or not empty for RX.
     20The WTI mailboxes used by the driver ro receive events from the NIC hardware (available RX packet, or free TX slot, for a given channel), must be statically allocated during the kernel initialisation phase, and must be routed to the cluster containing the associated device descriptor and server thread.
     22 Finally, the generic NIC device "kernel" API defines four command types, that are detailed in section C.
     23 * '''READABLE''' : returns true if at least one RX paquet is available in RX queue.
     24 * '''WRITABLE : returns true if at least one empty slot is available in TX queue.
     25 * '''READ'''     : consume one packet from the RX queue.
     26 * '''WRITE'''    : produce one packet to the TX queue.
     28All RX or TX paquets are sent or received in standard 2 Kbytes kernel buffers, that are dynamically allocated by the protocols stack. The structure ''pkd_t'' defining a packet descriptor contains the buffer pointer and the actual Ethernet packet length in bytes.
     30The actual TX an RX queues structures depends on the hardware NIC implementation, and must be defined by the driver code.
     32To access the various drivers, the NIC device defines a lower-level "driver" API, that is detailed in section D below.
     34All NIC device structures and access functions are defined in the [  dev_nic.c] et [ dev_nic.h] files.