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

Last change on this file since 687 was 613, checked in by bellefin, 9 years ago

NIC driver: update the channel registers of the NIC component (add the status variable and change the descriptor structure)

File size: 8.3 KB
RevLine 
[258]1///////////////////////////////////////////////////////////////////////////////////
2// File     : nic_driver.h
3// Date     : 01/11/2013
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
[437]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//////////////////////////////////////////////////////////////////////////////////
[258]31
32#ifndef _GIET_NIC_DRIVERS_H_
33#define _GIET_NIC_DRIVERS_H_
34
[437]35#include <giet_config.h>
36
[258]37///////////////////////////////////////////////////////////////////////////////////
[437]38//           Global Addressable Registers
[295]39///////////////////////////////////////////////////////////////////////////////////
40
[456]41enum SoclibMultiNicHyperRegisters {
[295]42    NIC_G_VIS                        = 0,   // bitfield : bit N = 0 -> channel N disabled
43    NIC_G_ON                         = 1,   // boolean : NIC component activated
[456]44    NIC_G_NB_CHAN                    = 2,   // Number of channels (read only)
[295]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)
[456]59    NIC_G_NPKT_RX_DES_MFIFO_FULL     = 37,  // number of discarded RX packets fifo full
60    NIC_G_NPKT_RX_DES_CRC_FAIL       = 38,  // number of discarded RX packets CRC32 failure
[295]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
[456]64    NIC_G_NPKT_RX_DISPATCH_DST_FAIL  = 41,  // number of discarded RX packets DST MAC not found
[295]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)
[456]70    NIC_G_NPKT_TX_DISPATCH_SRC_FAIL  = 46,  // number of discarded TX packets SRC MAC failed
[295]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
[481]78//////////////////////////////////////////////////////////////////////////////////////////////
[437]79//            Channel Addressable Registers
[613]80// A buffer descriptor occupies 8 bytes (two 32 bits words):
81// - the 26 LSB bits of LOW WORD contain bits[31:6] of the buffer satus paddr
82// - bits[31:26] of LOW WORD and bits[19:0] of HIGH WORD contain bits[31:6] of the buffer paddr
83// - the 12 MSB bits of HIGH WORD contain the common address extension of the buffer and its status
84// The buffer status occupies 64 bytes but only the last bit is useful (1 for full and 0 for empty)
85// The buffer address and its status address must be 64 bytes aligned (bits[5:0] equal to 0)
86///////////////////////////////////////////////////////////////////////////////////////////////
[481]87
[295]88enum SoclibMultiNicChannelRegisters
89{
[613]90    NIC_RX_STS_0              = 0,   // RX_0 status (full or empty)      (Read/Write)
91    NIC_RX_STS_1              = 16,  // RX_1 status (full or empty)      (Read/Write)
92    NIC_TX_STS_0              = 32,  // TX_0 status (full or empty)      (Read/Write)
93    NIC_TX_STS_1              = 48,  // TX_1 status (full or empty)      (Read/Write)
94    NIC_RX_DESC_LO_0          = 64,  // RX_0 descriptor low word         (Read/Write)
95    NIC_RX_DESC_HI_0          = 65,  // RX_0 descriptor high word        (Read/Write)
96    NIC_RX_DESC_LO_1          = 66,  // RX_1 descriptor low word         (Read/Write)
97    NIC_RX_DESC_HI_1          = 67,  // RX_1 descriptor high word        (Read/Write)
98    NIC_TX_DESC_LO_0          = 68,  // TX_0 descriptor low word         (Read/Write)
99    NIC_TX_DESC_HI_0          = 69,  // TX_0 descriptor high word        (Read/Write)
100    NIC_TX_DESC_LO_1          = 70,  // TX_1 descriptor low word         (Read/Write)
101    NIC_TX_DESC_HI_1          = 71,  // TX_1 descriptor high word        (Read/Write)
102    NIC_MAC_4                 = 72,  // channel mac address 32 LSB bits  (Read Only)
103    NIC_MAC_2                 = 73,  // channel mac address 16 LSB bits  (Read Only)
104    NIC_RX_RUN                = 74,  // RX packets can be received       (write_only)
105    NIC_TX_RUN                = 75,  // TX packets can be transmitted    (write_only)
[295]106};
107
[437]108
[295]109///////////////////////////////////////////////////////////////////////////////////
[437]110//              Initialization functions
[258]111///////////////////////////////////////////////////////////////////////////////////
112
[456]113extern unsigned int _nic_get_channel_register( unsigned int channel,
114                                               unsigned int index );
[258]115
[456]116extern void _nic_set_channel_register( unsigned int channel,
117                                       unsigned int index,
118                                       unsigned int value );
119
120extern unsigned int _nic_get_global_register( unsigned int index );
121
122extern void _nic_set_global_register( unsigned int index,
123                                      unsigned int value );
124
125extern int _nic_global_init( unsigned int bc_enable,
126                             unsigned int bypass_enable,
127                             unsigned int tdm_enable,
128                             unsigned int tdm_period );
129
[448]130extern int _nic_channel_start( unsigned int channel,
131                               unsigned int is_rx,
132                               unsigned int mac4,
133                               unsigned int mac2 );
[258]134
[448]135extern int _nic_channel_stop( unsigned int channel,
136                              unsigned int is_rx );
[258]137
138
[437]139///////////////////////////////////////////////////////////////////////////////////
140//              Interrupt Service Routines
141///////////////////////////////////////////////////////////////////////////////////
142
[295]143extern void _nic_rx_isr( unsigned int irq_type,
144                         unsigned int irq_id,
145                         unsigned int channel );
146
147extern void _nic_tx_isr( unsigned int irq_type,
148                         unsigned int irq_id,
149                         unsigned int channel );
150
[258]151
152
153#endif
154
155// Local Variables:
156// tab-width: 4
157// c-basic-offset: 4
158// c-file-offsets:((innamespace . 0)(inline-open . 0))
159// indent-tabs-mode: nil
160// End:
161// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
162
Note: See TracBrowser for help on using the repository browser.