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

Last change on this file since 450 was 448, checked in by alain, 10 years ago

Simplifying the NIC and CMA drivers.
Complex functionnalities have been moved to the sys_handler.c file.

File size: 7.2 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//              Initialization functions
103///////////////////////////////////////////////////////////////////////////////////
104
105extern int _nic_global_init( unsigned int channels,
106                             unsigned int vis,
107                             unsigned int bc_enable,
108                             unsigned int bypass_enable );
109
110extern int _nic_channel_start( unsigned int channel,
111                               unsigned int is_rx,
112                               unsigned int mac4,
113                               unsigned int mac2 );
114
115extern int _nic_channel_stop( unsigned int channel,
116                              unsigned int is_rx );
117
118
119///////////////////////////////////////////////////////////////////////////////////
120//              Interrupt Service Routines
121///////////////////////////////////////////////////////////////////////////////////
122
123extern void _nic_rx_isr( unsigned int irq_type,
124                         unsigned int irq_id,
125                         unsigned int channel );
126
127extern void _nic_tx_isr( unsigned int irq_type,
128                         unsigned int irq_id,
129                         unsigned int channel );
130
131
132
133#endif
134
135// Local Variables:
136// tab-width: 4
137// c-basic-offset: 4
138// c-file-offsets:((innamespace . 0)(inline-open . 0))
139// indent-tabs-mode: nil
140// End:
141// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
142
Note: See TracBrowser for help on using the repository browser.