source: soft/giet_vm/giet_drivers/nic_driver.h @ 442

Last change on this file since 442 was 437, checked in by alain, 10 years ago

Introducing dynamic allocation of peripheral channel(TTY, NIC, TIM, CMA)
Removint the ICU driver : ICU component not supported anymore.
Removing the FBF driver.

File size: 8.5 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File     : nic_driver.h
3// Date     : 01/11/2013
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// The nic_driver.c and nic_driver.h files are part ot the GIET-VM nano-kernel.
8// This driver supports the vci_multi_nic component.
9//
10// It can exist only one network controller in the architecture, but this
11// component supports several channels.
12//
13// It can be accessed directly by software with memcpy(),
14// or it can be accessed through the vci_chbuf_dma component:
15// 
16// The '_nic_sync_write' and '_nic_sync_read' functions use a memcpy strategy to
17// implement the transfer between a data buffer (user space) and the NIC
18// buffer (kernel space). They are blocking until completion of the transfer.
19//
20// The _nic_cma_start() and _nic_cma_stop() functions use the VciChbufDma component
21// to transfer a flow of packets from the NIC RX hard chbuf (two containers)
22// to an user RX chbuf (two containers), and to transfer another flow of packets
23// from an user TX chbuf (two containers) to the NIC TX chbuf (two containers).
24// One NIC channel and two CMA channels must be allocated to the task
25// in the mapping_info data structure.
26//
27// All these access functions return -1 in case of error.
28//
29// The SEG_NIC_BASE address must be defined in the hard_config.h file.
30//////////////////////////////////////////////////////////////////////////////////
31
32#ifndef _GIET_NIC_DRIVERS_H_
33#define _GIET_NIC_DRIVERS_H_
34
35#include <giet_config.h>
36
37///////////////////////////////////////////////////////////////////////////////////
38//           Global Addressable Registers
39///////////////////////////////////////////////////////////////////////////////////
40
41enum SoclibMultiNicHyperviseurRegisters {
42    NIC_G_VIS                        = 0,   // bitfield : bit N = 0 -> channel N disabled
43    NIC_G_ON                         = 1,   // boolean : NIC component activated
44    NIC_G_NB_CHAN                    = 2,   // Number of channels present in this NIC (read only)
45    NIC_G_BC_ENABLE                  = 3,   // boolean : Enable Broadcast if non zero
46    NIC_G_TDM_ENABLE                 = 4,   // boolean : TDM Scheduler if non zero
47    NIC_G_TDM_PERIOD                 = 5,   // TDM time slot value
48    NIC_G_BYPASS_ENABLE              = 6,   // boolean : Enable bypass for TX packets
49    // alignment
50    NIC_G_MAC_4                      = 8,   // channel mac address 32 LSB bits array[8]
51    NIC_G_MAC_2                      = 16,  // channel mac address 16 MSB bits array[8]
52    // alignment
53    NIC_G_NPKT_RX_G2S_RECEIVED       = 32,  // number of packets received on GMII RX port
54    NIC_G_NPKT_RX_G2S_DISCARDED      = 33,  // number of RX packets discarded by RX_G2S FSM
55
56    NIC_G_NPKT_RX_DES_SUCCESS        = 34,  // number of RX packets transmited by RX_DES FSM
57    NIC_G_NPKT_RX_DES_TOO_SMALL      = 35,  // number of discarded too small RX packets (<60B)
58    NIC_G_NPKT_RX_DES_TOO_BIG        = 36,  // number of discarded too big RX packets (>1514B)
59    NIC_G_NPKT_RX_DES_MFIFO_FULL     = 37,  // number of discarded RX packets because fifo full
60    NIC_G_NPKT_RX_DES_CRC_FAIL       = 38,  // number of discarded RX packets because CRC32 failure
61
62    NIC_G_NPKT_RX_DISPATCH_RECEIVED  = 39,  // number of packets received by RX_DISPATCH FSM
63    NIC_G_NPKT_RX_DISPATCH_BROADCAST = 40,  // number of broadcast RX packets received
64    NIC_G_NPKT_RX_DISPATCH_DST_FAIL  = 41,  // number of discarded RX packets for DST MAC not found
65    NIC_G_NPKT_RX_DISPATCH_CH_FULL   = 42,  // number of discarded RX packets for channel full
66
67    NIC_G_NPKT_TX_DISPATCH_RECEIVED  = 43,  // number of packets received by TX_DISPATCH FSM
68    NIC_G_NPKT_TX_DISPATCH_TOO_SMALL = 44,  // number of discarded too small TX packets (<60B)
69    NIC_G_NPKT_TX_DISPATCH_TOO_BIG   = 45,  // number of discarded too big TX packets (>1514B)
70    NIC_G_NPKT_TX_DISPATCH_SRC_FAIL  = 46,  // number of discarded TX packets for SRC MAC failed
71    NIC_G_NPKT_TX_DISPATCH_BROADCAST = 47,  // number of broadcast TX packets received
72    NIC_G_NPKT_TX_DISPATCH_BYPASS    = 48,  // number of bypassed TX->RX packets
73    NIC_G_NPKT_TX_DISPATCH_TRANSMIT  = 49,  // number of transmit TX packets
74
75    NIC_CHANNEL_SPAN                 = 0x2000,
76};
77
78/////////////////////////////////////////////////////////////////////////////////////
79//            Channel Addressable Registers
80// A container descriptor has the following form:
81// LOW WORD  : 32 LSB bits of the container physical base address     
82// HIGH WORD : 16 MSB bits of the container physical base address + status (bit 31) 
83/////////////////////////////////////////////////////////////////////////////////////
84enum SoclibMultiNicChannelRegisters
85{
86    NIC_RX_DESC_LO_0          = 0,   // RX_0 descriptor low word         (Read/Write)
87    NIC_RX_DESC_HI_0          = 1,   // RX_0 descriptor high word        (Read/Write)
88    NIC_RX_DESC_LO_1          = 2,   // RX_1 descriptor low word         (Read/Write)
89    NIC_RX_DESC_HI_1          = 3,   // RX_1 descriptor high word        (Read/Write)
90    NIC_TX_DESC_LO_0          = 4,   // TX_0 descriptor low word         (Read/Write)
91    NIC_TX_DESC_HI_0          = 5,   // TX_0 descriptor high word        (Read/Write)
92    NIC_TX_DESC_LO_1          = 6,   // TX_1 descriptor low word         (Read/Write)
93    NIC_TX_DESC_HI_1          = 7,   // TX_1 descriptor high word        (Read/Write)
94    NIC_MAC_4                 = 8,   // channel mac address 32 LSB bits  (Read Only)
95    NIC_MAC_2                 = 9,   // channel mac address 16 LSB bits  (Read Only)
96    NIC_RX_RUN                = 10,  // RX packets can be received       (write_only)
97    NIC_TX_RUN                = 11,  // TX packets can be transmitted    (write_only)
98};
99
100
101////////////////////////////////////////////////////////////////////////////////////
102//              Chained Buffer Descriptor Structure
103////////////////////////////////////////////////////////////////////////////////////
104typedef struct nic_chbuf_s
105{
106    unsigned long long buf[GIET_CHBUF_NBUFS]; // array of buffer descriptors
107    unsigned int       buf_length;            // buffer length (bytes)
108    unsigned int       nb_buffers;            // actual number of buffers
109} nic_chbuf_t;
110
111///////////////////////////////////////////////////////////////////////////////////
112//              Initialization functions
113///////////////////////////////////////////////////////////////////////////////////
114
115extern int _nic_global_init( unsigned int channels,
116                             unsigned int vis,
117                             unsigned int bc_enable,
118                             unsigned int bypass_enable );
119
120extern int _nic_channel_init( unsigned int index,
121                              unsigned int mac4,
122                              unsigned int mac2 );
123
124///////////////////////////////////////////////////////////////////////////////////
125//              Blocking functions using a physical_memcpy()
126///////////////////////////////////////////////////////////////////////////////////
127
128extern int _nic_sync_receive( unsigned int       channel, 
129                              unsigned long long user_paddr );
130
131extern int _nic_sync_send( unsigned int       channel,
132                           unsigned long long user_paddr );
133
134///////////////////////////////////////////////////////////////////////////////////
135//              Non blocking functions using the chained buffer DMA
136///////////////////////////////////////////////////////////////////////////////////
137
138extern int _nic_cma_receive( unsigned int  nic_channel,
139                             unsigned int  cma_channel,
140                             nic_chbuf_t*  kernel_chbuf );
141
142extern int _nic_cma_send( unsigned int  nic_channel,
143                          unsigned int  cma_channel,
144                          nic_chbuf_t*  kernel_chbuf );
145
146///////////////////////////////////////////////////////////////////////////////////
147//              Interrupt Service Routines
148///////////////////////////////////////////////////////////////////////////////////
149
150extern void _nic_rx_isr( unsigned int irq_type,
151                         unsigned int irq_id,
152                         unsigned int channel );
153
154extern void _nic_tx_isr( unsigned int irq_type,
155                         unsigned int irq_id,
156                         unsigned int channel );
157
158
159
160#endif
161
162// Local Variables:
163// tab-width: 4
164// c-basic-offset: 4
165// c-file-offsets:((innamespace . 0)(inline-open . 0))
166// indent-tabs-mode: nil
167// End:
168// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
169
Note: See TracBrowser for help on using the repository browser.