31 | | two memory mapped software FIFOs, implemented as chained buffers. |
32 | | Each slot in these FIFOs is a 4 Kbytes container. The number of containers, |
33 | | defining the queue depth, is a software defined parameter. |
| 39 | two memory mapped software queues, called chained buffers, and defined by the ''nic_chbuf_s'' C structure. The number of containers, defining the queue depth, is a software defined parameter. |
| 40 | The physical addresses are used by the hardware NIC DMA engines. |
| 41 | {{{ |
| 42 | struct nic_chbuf_s |
| 43 | { |
| 44 | uint32_t wid; /*! current container write index */ |
| 45 | uint32_t rid; /*! current container read index */ |
| 46 | uint64_t cont_pad[SOCLIB_NIC_CHBUF_DEPTH]; /*! containers physical base addresses */ |
| 47 | uint32_t * cont_ptr[SOCLIB_NIC_CHBUF_DEPTH]; /*! containers virtual base addresses */ |
| 48 | } |
| 49 | }}} |
35 | | The container is handled as an array of 32 bits word, with the following format: |
36 | | |
37 | | The first 45 words (180 bytes) define the fixed-format container header : |
38 | | || word0 || NB_WORDS || NB_PACKETS || |
39 | | || word1 || PLEN[0] || PLEN[1] || |
40 | | || ... || ... || ... || |
41 | | || word44 || PLEN[86] || PLEN[87] || |
42 | | |
43 | | * NB_PACKETS is the actual number of packets in the container. |
44 | | * NB_WORDS is the number of useful words in the container. |
45 | | * PLEN[i] is the number of bytes for packet[i]. |
46 | | |
47 | | The packets are stored in the (1024 - 45) following words (3916 bytes), |
48 | | and the packets are word-aligned. |
49 | | |
50 | | For the DMA engines, a container has only two states (full or empty), defined |
51 | | by one single bit, called the container "status" (1 for full / 0 for empty). |
52 | | To access both the container status, and the data contained in the container, the DMA |
53 | | engines use two physical addresses, that are packed in a 64 bits ''container descriptor'': |
54 | | * desc[25:0] contain bits[31:6] of the "status" physical address. |
55 | | * desc[51:26] contain bits[31:6] of the "buffer" physical address. |
56 | | * desc[63:52] contain bits[43:32] of the physical address, common for "status" and "buffer". |
| 51 | Each container contain one single Ethernet Packet. |
| 52 | The ''nic_cont_s'' C structure contains a 2040 bytes data buffer, the actual packet length, and |
| 53 | the container state : full (owned by the reader) / empty (owned by the writer). |
| 54 | Thist state variable is used as a SET/RESET flip-flop to synchronize the software server thread, and the hardware NIC DMA engine. |
| 55 | struct nic_cont_s |
| 56 | {{{ |
| 57 | { |
| 58 | uint8_t buf[2040]; /*! Ethernet packet (42 to 2040 bytes */ |
| 59 | uint32_t length; /*! actual packet length in bytes */ |
| 60 | uint32_t state; /*! zero == empty / non zero == full */ |
| 61 | } |
| 62 | }}} |