/////////////////////////////////////////////////////////////////////////////////// // File : nic_driver.c // Date : 23/05/2013 // Author : alain greiner // Copyright (c) UPMC-LIP6 /////////////////////////////////////////////////////////////////////////////////// // The nic_driver.c and nic_driver.h files are part ot the GIET-VM nano-kernel. // This driver supports the vci_multi_nic component. // // It can exist only one network controller in the architecture, but this // component supports several channels. // // It can be accessed directly by software with memcpy(), // or it can be accessed through the vci_chbuf_dma component: // // The '_nic_sync_write' and '_nic_sync_read' functions use a memcpy strategy to // implement the transfer between a data buffer (user space) and the NIC // buffer (kernel space). They are blocking until completion of the transfer. // // The _nic_cma_*_init() and _nic_cma_stop() functions use the VciChbufDma component // to transfer a flow of packets from the NIC RX hard chbuf (two containers) // to an user RX chbuf (two containers), and to transfer another flow of packets // from an user TX chbuf (two containers) to the NIC TX chbuf (two containers). // One NIC channel and two CMA channels must be allocated to the task // in the mapping_info data structure. ////////////////////////////////////////////////////////////////////////////////// #include #include #include #if !defined(GIET_USE_IOMMU) # error: You must define GIET_USE_IOMMU in the giet_config.h file #endif #if !defined(NB_NIC_CHANNELS) # error: You must define NB_NIC_CHANNELS in the hard_config.h file #endif #if ( NB_NIC_CHANNELS > 8 ) # error: NB_NIC_CHANNELS cannot be larger than 8 #endif #if !defined(NB_CMA_CHANNELS) # error: You must define NB_CMA_CHANNELS in the hard_config.h file #endif #if ( NB_CMA_CHANNELS > 8 ) # error: NB_CMA_CHANNELS cannot be larger than 8 #endif #if !defined( USE_IOB ) # error: You must define USE_IOB in the hard_config.h file #endif #define in_unckdata __attribute__((section (".unckdata"))) ////////////////////////////////////////////////////////////////////////////////// // _nic_sync_write() // Transfer data from an memory buffer to the NIC device using a memcpy. // - buffer : base address of the memory buffer. // - length : number of bytes to be transfered. ////////////////////////////////////////////////////////////////////////////////// unsigned int _nic_sync_write( const void* buffer, unsigned int length ) { _puts("[GIET ERROR] _nic_sync_write function not implemented\n"); _exit(); // unsigned char* nic_address = (unsigned char *) &seg_nic_base; // memcpy((void *) nic_address, (void *) buffer, length); return 0; } ////////////////////////////////////////////////////////////////////////////////// // _nic_sync_read() // Transfer data from the NIC device to a memory buffer using a memcpy. // - buffer : base address of the memory buffer. // - length : number of bytes to be transfered. ////////////////////////////////////////////////////////////////////////////////// unsigned int _nic_sync_read( const void* buffer, unsigned int length ) { _puts("[GIET ERROR] _nic_sync_read function not implemented\n"); _exit(); // unsigned char* nic_address = (unsigned char *) &seg_nic_base; // memcpy((void *) buffer, (void *) nic_address, length); return 0; } ////////////////////////////////////////////////////////////////////////////////// // _nic_cma_start() // Returns 0 if success, > 0 if error. ////////////////////////////////////////////////////////////////////////////////// unsigned int _nic_cma_start( ) { _puts("[GIET ERROR] _nic_cma_start function not implemented\n"); _exit(); // unsigned char* nic_address = (unsigned char *) &seg_nic_base; return 0; } ////////////////////////////////////////////////////////////////////////////////// // _nic_cma_stop() // Returns 0 if success, > 0 if error. ////////////////////////////////////////////////////////////////////////////////// unsigned int _nic_cma_stop() { _puts("[GIET ERROR] _nic_cma_stop function not implemented\n"); _exit(); // unsigned char* nic_address = (unsigned char *) &seg_nic_base; return 0; } // Local Variables: // tab-width: 4 // c-basic-offset: 4 // c-file-offsets:((innamespace . 0)(inline-open . 0)) // indent-tabs-mode: nil // End: // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4