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

Last change on this file since 595 was 481, checked in by alain, 10 years ago

1) The NIC, IOC, DMA and HBA drivers have been adapted to support the new _v2p_translate() function prototype (returns void).
2) The _mmc_inval() and _mmc_sync() functions does not use anymore the hard lock in the MMC, but use a soft spin_lock.
3) The NIC driver does not use anymore the GIET_NIC_BUFSIZE, GIET_NIC_NBUFS, and GIET_NIC_TIMEOUT parameters (removed from giet_config.h file).
4) The NIC driver registers map has been modified to support 64 bytes buffer descriptors for chained buffers.

File size: 7.7 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
[481]80// A buffer descriptor occupies 64 bytes, but only 8 bytes (two 32 bits words) are useful:
81// LOW WORD   contains the 32 LSB bits of the buffer paddr               
82// HIGH WORD  contains the 16 MSB bits of the buffer paddr, plus status (bit 31)
83//////////////////////////////////////////////////////////////////////////////////////////////
84
[295]85enum SoclibMultiNicChannelRegisters
86{
87    NIC_RX_DESC_LO_0          = 0,   // RX_0 descriptor low word         (Read/Write)
88    NIC_RX_DESC_HI_0          = 1,   // RX_0 descriptor high word        (Read/Write)
[481]89    NIC_RX_DESC_LO_1          = 16,  // RX_1 descriptor low word         (Read/Write)
90    NIC_RX_DESC_HI_1          = 17,  // RX_1 descriptor high word        (Read/Write)
91    NIC_TX_DESC_LO_0          = 32,  // TX_0 descriptor low word         (Read/Write)
92    NIC_TX_DESC_HI_0          = 33,  // TX_0 descriptor high word        (Read/Write)
93    NIC_TX_DESC_LO_1          = 48,  // TX_1 descriptor low word         (Read/Write)
94    NIC_TX_DESC_HI_1          = 49,  // TX_1 descriptor high word        (Read/Write)
95    NIC_MAC_4                 = 64,  // channel mac address 32 LSB bits  (Read Only)
96    NIC_MAC_2                 = 65,  // channel mac address 16 LSB bits  (Read Only)
97    NIC_RX_RUN                = 66,  // RX packets can be received       (write_only)
98    NIC_TX_RUN                = 67,  // TX packets can be transmitted    (write_only)
[295]99};
100
[437]101
[295]102///////////////////////////////////////////////////////////////////////////////////
[437]103//              Initialization functions
[258]104///////////////////////////////////////////////////////////////////////////////////
105
[456]106extern unsigned int _nic_get_channel_register( unsigned int channel,
107                                               unsigned int index );
[258]108
[456]109extern void _nic_set_channel_register( unsigned int channel,
110                                       unsigned int index,
111                                       unsigned int value );
112
113extern unsigned int _nic_get_global_register( unsigned int index );
114
115extern void _nic_set_global_register( unsigned int index,
116                                      unsigned int value );
117
118extern int _nic_global_init( unsigned int bc_enable,
119                             unsigned int bypass_enable,
120                             unsigned int tdm_enable,
121                             unsigned int tdm_period );
122
[448]123extern int _nic_channel_start( unsigned int channel,
124                               unsigned int is_rx,
125                               unsigned int mac4,
126                               unsigned int mac2 );
[258]127
[448]128extern int _nic_channel_stop( unsigned int channel,
129                              unsigned int is_rx );
[258]130
131
[437]132///////////////////////////////////////////////////////////////////////////////////
133//              Interrupt Service Routines
134///////////////////////////////////////////////////////////////////////////////////
135
[295]136extern void _nic_rx_isr( unsigned int irq_type,
137                         unsigned int irq_id,
138                         unsigned int channel );
139
140extern void _nic_tx_isr( unsigned int irq_type,
141                         unsigned int irq_id,
142                         unsigned int channel );
143
[258]144
145
146#endif
147
148// Local Variables:
149// tab-width: 4
150// c-basic-offset: 4
151// c-file-offsets:((innamespace . 0)(inline-open . 0))
152// indent-tabs-mode: nil
153// End:
154// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
155
Note: See TracBrowser for help on using the repository browser.