############################################################### # WARPLab UDP Transport # Copyright 2015 Mango Communications # Distributed under the WARP license (http://warpproject.org/license) ############################################################### #uses "xillib.tcl" # NOTE: # In order to use the WARP UDP transport library, the Ethernet instances # within the design need to have either "ETH_A" or "ETH_B" somewhere in the # instance name. Due to some limitations with the Xilinx TCL generation # capabilities this script cannot pass instance names up to the MLD file to # be displayed as parameter names. Therefore, this driver has two parameters: # 1) ETH_A_uses_library # 2) ETH_B_uses_library # that are used to control if a given Ethernet instance is controlled by the # WARP UDP transport library. If an instance is not controlled by this library, # then the library will not allocate buffers or control structures in order to # minimize code and data space of this library. # # This library will complain if: # 1) There are more than two Ethernet instances, but will complete and # allocate buffers and control structures for all instances # 2) If none of the Ethernet instances contain either "ETH_A" or "ETH_B". # In this case, the *_uses_library parameters will be ignored and # buffers and control structures will be allocated for all instances # 3) If the *_uses_library parameter is set to '1' and the corresponding # "ETH_*" doesn't exist, then the driver will error out, except in # the situation of case 2) above. # set num_ethernet_instances 0 ############################################################### # Gets all Ethernet Peripherals from the MHS file # # @param MHS Handle - Handle to MHS file # # @return List of Ethernet Peripherals that contain "ETH_A" or "ETH_B" in the name # # @note This method will also increment the global variable: # num_ethernet_instances # ############################################################### proc get_ethernet_peripherals {mhs_handle} { global num_ethernet_instances set ip_instance_list [xget_hw_ipinst_handle $mhs_handle "*"] set num_ethernet_instances 0 set ethernet_peripheral_list {} foreach peripheral $ip_instance_list { set peripheral_type [xget_hw_value $peripheral] set peripheral_name [xget_value $peripheral "name"] if { $peripheral_type == "axi_ethernet" } { # Increment global variable for later use incr num_ethernet_instances if {[regexp -nocase {eth_a} $peripheral_name]} { # If the list already contains elements, insert "ETH_A" first if {[llength $ethernet_peripheral_list] > 0} { set ethernet_peripheral_list [linsert $ethernet_peripheral_list 0 $peripheral] } else { lappend ethernet_peripheral_list $peripheral } } elseif {[regexp -nocase {eth_b} $peripheral_name]} { lappend ethernet_peripheral_list $peripheral } else { lappend ethernet_peripheral_list $peripheral } } } return $ethernet_peripheral_list } ############################################################### # Gets all Ethernet Interface Peripherals from the MHS file # # @param MHS Handle - Handle to MHS file # @param Instance Handle - Handle to Ethernet instance # # @return Instance Handle - Handle to Interface instance or None # ############################################################### proc get_ethernet_interface_peripheral {mhs_handle instance_handle} { set bus_interface_list [xget_hw_busifs_by_subproperty $instance_handle "BUS_TYPE" "INITIATOR"] foreach bus_interface $bus_interface_list { set bus_name [string toupper [xget_hw_value $bus_interface]] set bus_interface_handle [xget_hw_connected_busifs_handle $mhs_handle $bus_name "TARGET"] if { [string compare -nocase $bus_interface_handle ""] == 0} { continue } else { set bus_interface_name [xget_hw_name $bus_interface_handle] set target_peripheral [xget_hw_parent_handle $bus_interface_handle] set target_type [xget_hw_value $target_peripheral] set target_name [string toupper [xget_hw_name $target_peripheral]] return $target_peripheral } } return } ############################################################### # Open files # # @param File Name # @param Description # # @return Instance Handle - Handle to file # ############################################################### proc open_file {filename description} { set file_handle [open $filename w] # Add the WARP Header to the file puts $file_handle "/** @file $filename" puts $file_handle " * @brief $description" puts $file_handle " *" puts $file_handle " * @copyright Copyright 2015, Mango Communications. All rights reserved." puts $file_handle " * Distributed under the WARP license (http://warpproject.org/license)" puts $file_handle " *" puts $file_handle " * @author Chris Hunter (chunter \[at\] mangocomm.com)" puts $file_handle " * @author Patrick Murphy (murphpo \[at\] mangocomm.com)" puts $file_handle " * @author Erik Welsh (welsh \[at\] mangocomm.com)" puts $file_handle " */" puts $file_handle "" return $file_handle } proc open_src_file {filename description} { set expanded_filename [file join "./src/" $filename] return [open_file $expanded_filename $description] } ############################################################### # Main method to generate WARP UDP Transport files # # @param Library Handle # # @return None # ############################################################### proc generate {lib_handle} { global num_ethernet_instances # From the library handle, get the Ethernet instances out of the MHS file set sw_proc_handle [xget_processor] set hw_proc_handle [xget_handle $sw_proc_handle "IPINST"] set mhs_handle [xget_hw_parent_handle $hw_proc_handle] set ethernet_instance_list [get_ethernet_peripherals $mhs_handle] # Error checking if {$num_ethernet_instances == 0} { error "Invalid configuration: No Ethernet instances found." "" "mdt_error" return } # Initialize variables for loop set ethernet_instance_num 0 set use_names 0 set interface_type_list {} set ignore_list {} # Initialize files set config_c_file [open_src_file "WARP_ip_udp_config.c" "WARP IP/UDP Library (Config)"] set config_h_file [open_src_file "WARP_ip_udp_config.h" "WARP IP/UDP Library (Config)"] set device_h_file [open_src_file "WARP_ip_udp_device.h" "WARP IP/UDP Library (Device)"] # Get library parameters set eth_a_uses_library [xget_value $lib_handle "PARAMETER" "ETH_A_uses_library"] set eth_b_uses_library [xget_value $lib_handle "PARAMETER" "ETH_B_uses_library"] set eth_buffer_size [xget_value $lib_handle "PARAMETER" "eth_buffer_size"] set num_rx_buffers [xget_value $lib_handle "PARAMETER" "num_rx_buffers"] set num_tx_buffers [xget_value $lib_handle "PARAMETER" "num_tx_buffers"] set num_tx_descriptors [xget_value $lib_handle "PARAMETER" "num_tx_descriptors"] set num_arp_entries [xget_value $lib_handle "PARAMETER" "num_arp_entries"] set num_udp_sockets [xget_value $lib_handle "PARAMETER" "num_udp_sockets"] set eth_default_speed [xget_value $lib_handle "PARAMETER" "eth_default_speed"] # Check Ethernet instances and instance names # 1) There are more than two Ethernet instances, but will complete and allocate buffers and control # structures for all instances # 2) If none of the Ethernet instances contain either "ETH_A" or "ETH_B". In this case, the # *_uses_library parameters will be ignored and buffers and control structures will be allocated # for all instances # 3) If the *_uses_library parameter is set to '1' and the corresponding "ETH_*" doesn't exist, # then the driver will error out, except in the situation of case 2) above. # if {$num_ethernet_instances > 2} { puts "\# --------------------------------------" puts "\# WARP UDP Transport WARNING:" puts "\# More than 2 Ethernet instances." puts "\# Ignoring ETH_*_uses_library parameters." puts "\# --------------------------------------" incr use_names } else { set eth_a_exists 0 set eth_b_exists 0 foreach inst $ethernet_instance_list { set inst_name [string toupper [xget_hw_name $inst]] if { [regexp -nocase {eth_a} $inst_name] } { incr eth_a_exists } if { [regexp -nocase {eth_b} $inst_name] } { incr eth_b_exists } } if { $eth_a_exists == 0 && $eth_b_exists == 0 } { puts "\# --------------------------------------" puts "\# WARP UDP Transport WARNING:" puts "\# No Ethernet instances contain either \"ETH_A\" or \"ETH_B\"." puts "\# Ignoring ETH_*_uses_library parameters." puts "\# --------------------------------------" } else { if { $eth_a_uses_library == 1 && $eth_a_exists == 0 } { error "Invalid configuration: ETH_A does not exist but required by library." "" "mdt_error" return } if { $eth_b_uses_library == 1 && $eth_b_exists == 0 } { error "Invalid configuration: ETH_B does not exist but required by library." "" "mdt_error" return } } } # Print the file headers of the generated files print_config_h_file_header $config_h_file $eth_buffer_size $num_tx_buffers $num_tx_descriptors $num_arp_entries $num_udp_sockets print_config_c_file_header $config_c_file print_device_h_file_header $device_h_file # Print the Ethernet device specific body elements of the generated files foreach instance $ethernet_instance_list { set instance_type [xget_hw_value $instance] set instance_name [string toupper [xget_hw_name $instance]] set ignore 0 # Check if we should ignore this Ethernet instance # NOTE: This implementation relies on the fact that all the checks above passed # if {[regexp -nocase {eth_a} $instance_name] && $eth_a_uses_library == 0} { incr ignore } if {[regexp -nocase {eth_b} $instance_name] && $eth_b_uses_library == 0} { incr ignore } # Check that this is an "axi_ethernet" type peripheral if {[string compare -nocase $instance_type "axi_ethernet"] == 0} { # Determine the interface attached to the axi_ethernet set inf_inst [get_ethernet_interface_peripheral $mhs_handle $instance] if {[llength $inf_inst] != 0} { set inf_inst_type [xget_hw_value $inf_inst] set inf_inst_name [string toupper [xget_hw_name $inf_inst]] lappend inf_type_list $inf_inst_type lappend ignore_list $ignore switch $inf_inst_type { "axi_dma" { print_config_h_file_body $config_h_file $ethernet_instance_num $instance_name $inf_inst_name $num_rx_buffers $eth_default_speed $ignore print_config_c_file_body $config_c_file $ethernet_instance_num $ignore print_device_h_file_body $device_h_file $ethernet_instance_num $instance_name $ignore } "default" { error "Unable to handle AXI connections for interfaces of type $inf_inst_type. Some common causes are 1. The AXI4 Stream interface of the AXI Ethernet is left unconnected. 2. The Ethernet instance is connected to an AXI FIFO. 3. A custom peripheral is connected to the AXI interface. The WARP UDP Transport has been designed for use with the AXI DMA peripheral only." "" "mdt_error" } } } else { if {$ignore != 0} { print_config_h_file_body $config_h_file $ethernet_instance_num $instance_name $inf_inst_name $num_rx_buffers $eth_default_speed $ignore print_config_c_file_body $config_c_file $ethernet_instance_num $ignore print_device_h_file_body $device_h_file $ethernet_instance_num $instance_name $ignore } else { error "Unable to find AXI interface for $inst_name. Some common causes are 1. The AXI4 Stream interface of the AXI Ethernet is left unconnected. 2. The Ethernet instance is connected to an AXI FIFO. 3. A custom peripheral is connected to the AXI interface. The WARP UDP Transport has been designed for use with the AXI DMA peripheral only." "" "mdt_error" } } } else { error "$inst_name is not a AXI Ethernet core. The WARP UDP Transport can work only with AXI Ethernet." "" "mdt_error" } # increment the instance number for the next iteration of the for loop incr ethernet_instance_num } # Print the footer for the generated files print_config_h_file_footer $config_h_file print_config_c_file_footer $config_c_file $inf_type_list $ignore_list print_device_h_file_footer $device_h_file # Close the generated files close $config_h_file close $config_c_file close $device_h_file } ############################################################### # Methods to print the config header file # # @param Varies # # @return None # ############################################################### proc print_config_h_file_header {file_handle eth_buffer_size num_tx_buffers num_tx_descriptors num_arp_entries num_udp_sockets} { puts $file_handle "" puts $file_handle "\#ifndef WARP_IP_UDP_CONFIG_H" puts $file_handle "\#define WARP_IP_UDP_CONFIG_H" puts $file_handle "" puts $file_handle "" puts $file_handle "/***************************** Include Files *********************************/" puts $file_handle "" puts $file_handle "// Xilinx / Standard library includes" puts $file_handle "\#include " puts $file_handle "" puts $file_handle "" puts $file_handle "/*************************** Constant Definitions ****************************/" puts $file_handle "" puts $file_handle "// Global Defines" puts $file_handle "\#define WARP_IP_UDP_BD_ALIGNMENT XAXIDMA_BD_MINIMUM_ALIGNMENT // Buffer Descriptor alignment" puts $file_handle "\#define WARP_IP_UDP_BUFFER_ALIGNMENT 0x40 // Buffer alignment (64 byte boundary)" puts $file_handle "" puts $file_handle "// Define global DMA constants" puts $file_handle "\#define WARP_IP_UDP_TXBD_CNT $num_tx_descriptors // Number of TX buffer descriptors (per instance)" puts $file_handle "" puts $file_handle "// Define UDP connections" puts $file_handle "\#define WARP_IP_UDP_NUM_SOCKETS $num_udp_sockets // Number of UDP sockets (global pool)" puts $file_handle "\#define WARP_IP_UDP_NUM_ARP_ENTRIES $num_arp_entries // Number of ARP entries (global pool)" puts $file_handle "" puts $file_handle "// Define global Ethernet constants" puts $file_handle [format "\#define WARP_IP_UDP_ETH_BUF_SIZE ((%s + 31) & 0xFFFFFFE0) // Align parameter to a 32 byte boundary" $eth_buffer_size] puts $file_handle "\#define WARP_IP_UDP_ETH_NUM_SEND_BUF $num_tx_buffers // Number Ethernet transmit buffers (global pool)" puts $file_handle "\#define WARP_IP_UDP_ETH_RX_BUF_ALIGNMENT 4 // Alignment of packet within the RX buffer" puts $file_handle "\#define WARP_IP_UDP_ETH_TX_BUF_ALIGNMENT 0 // Alignment of packet within the TX buffer" puts $file_handle "" } proc print_config_h_file_body {file_handle inst_num inst_name inf_name num_rx_buffers eth_default_speed ignore} { puts $file_handle "" puts $file_handle "/************************* Ethernet $inst_num Definitions ****************************/" puts $file_handle "" puts $file_handle "// Ethernet device $inst_num" if { $ignore == 0 } { puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_MAC_DEVICE_ID XPAR_%s_DEVICE_ID // Internal name from xparameters.h" $inst_num $inst_name] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_INF_DEVICE_ID XPAR_%s_DEVICE_ID // Internal name from xparameters.h" $inst_num $inf_name] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_DEFAULT_SPEED %s" $inst_num $eth_default_speed] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_NUM_RECV_BUF %s" $inst_num $num_rx_buffers] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_RXBD_CNT WARP_IP_UDP_ETH_%s_NUM_RECV_BUF // Number of RX descriptors to use" $inst_num $inst_num] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_TXBD_CNT WARP_IP_UDP_TXBD_CNT // Number of TX descriptors to use" $inst_num] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_RXBD_SPACE_BYTES (XAxiDma_BdRingMemCalc(WARP_IP_UDP_BD_ALIGNMENT, WARP_IP_UDP_ETH_%s_RXBD_CNT))" $inst_num $inst_num] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_TXBD_SPACE_BYTES (XAxiDma_BdRingMemCalc(WARP_IP_UDP_BD_ALIGNMENT, WARP_IP_UDP_ETH_%s_TXBD_CNT))" $inst_num $inst_num] puts $file_handle "" } else { puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_MAC_DEVICE_ID 0" $inst_num] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_INF_DEVICE_ID 0" $inst_num] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_DEFAULT_SPEED 1000" $inst_num] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_NUM_RECV_BUF 0" $inst_num] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_RXBD_CNT 0 // Number of RX descriptors to use" $inst_num] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_TXBD_CNT 0 // Number of TX descriptors to use" $inst_num] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_RXBD_SPACE_BYTES 0" $inst_num] puts $file_handle [format "\#define WARP_IP_UDP_ETH_%s_TXBD_SPACE_BYTES 0" $inst_num] puts $file_handle "" } } proc print_config_h_file_footer {file_handle} { puts $file_handle "" puts $file_handle "/*********************** Global Variable Definitions *************************/" puts $file_handle "" puts $file_handle "" puts $file_handle "" puts $file_handle "/*************************** Function Prototypes *****************************/" puts $file_handle "" puts $file_handle "// Initialization functions" puts $file_handle "void eth_init_device_info(u32 eth_dev_num);" puts $file_handle "" puts $file_handle "\#endif // WARP_IP_UDP_CONFIG_H_" puts $file_handle "" } ############################################################### # Methods to print the config file source # # @param Library Handle # # @return None # ############################################################### proc print_config_c_file_header {file_handle} { puts $file_handle "" puts $file_handle "// NOTE: Many data structures in the WARP IP/UDP Library must be accessible to DMAs" puts $file_handle "// and other system level masters. Therefore, we have put those variables in their" puts $file_handle "// own linker section, \".eth_data\", so that it is easy to put that section into an " puts $file_handle "// appropriate memory within the system." puts $file_handle "//" puts $file_handle "// This will require custom modification of the linker script since the Xilinx SDK" puts $file_handle "// can not detect these section headers ahead of time so that they can be placed as " puts $file_handle "// part of the GUI section placement." puts $file_handle "//" puts $file_handle "" puts $file_handle "" puts $file_handle "/***************************** Include Files *********************************/" puts $file_handle "" puts $file_handle "// Xilinx / Standard library includes" puts $file_handle "\#include " puts $file_handle "\#include " puts $file_handle "\#include " puts $file_handle "\#include " puts $file_handle "" puts $file_handle "// Xilinx Hardware includes" puts $file_handle "\#include " puts $file_handle "\#include " puts $file_handle "" puts $file_handle "// WARP IP/UDP Library includes" puts $file_handle "\#include \"WARP_ip_udp.h\"" puts $file_handle "\#include \"WARP_ip_udp_internal.h\"" puts $file_handle "" } proc print_config_c_file_body {file_handle inst_num ignore} { puts $file_handle "" puts $file_handle "/************************* Ethernet $inst_num Definitions ****************************/" puts $file_handle "" puts $file_handle "// Variables for ETH $inst_num" if { $ignore == 0 } { puts $file_handle [format "XAxiEthernet ETH_%s_instance;" $inst_num] puts $file_handle [format "XAxiDma ETH_%s_dma_instance;" $inst_num] puts $file_handle "" puts $file_handle "// Aligned memory segments to be used for buffer descriptors" puts $file_handle "// NOTE: Memory for the buffer descriptors must be accessible by the DMA" puts $file_handle "//" puts $file_handle [format "u8 ETH_%s_rx_bd_space\[WARP_IP_UDP_ETH_%s_RXBD_SPACE_BYTES\] __attribute__ ((aligned(WARP_IP_UDP_BD_ALIGNMENT))) __attribute__ ((section (\".eth_data\")));" $inst_num $inst_num] puts $file_handle [format "u8 ETH_%s_tx_bd_space\[WARP_IP_UDP_ETH_%s_TXBD_SPACE_BYTES\] __attribute__ ((aligned(WARP_IP_UDP_BD_ALIGNMENT))) __attribute__ ((section (\".eth_data\")));" $inst_num $inst_num] puts $file_handle "" puts $file_handle "// Memory allocations for buffers" puts $file_handle "// NOTE: Memory for the buffer data must be accessible by the DMA" puts $file_handle "//" puts $file_handle [format "warp_ip_udp_buffer ETH_%s_recv_buffers\[WARP_IP_UDP_ETH_%s_NUM_RECV_BUF\];" $inst_num $inst_num] puts $file_handle [format "u32 ETH_%s_recv_buffer\[WARP_IP_UDP_ETH_%s_NUM_RECV_BUF * (WARP_IP_UDP_ETH_BUF_SIZE >> 2)\] __attribute__ ((aligned(WARP_IP_UDP_BUFFER_ALIGNMENT))) __attribute__ ((section (\".eth_data\")));" $inst_num $inst_num] puts $file_handle "" } else { puts $file_handle "// NONE - WARP IP/UDP library configured to ignore ETH $inst_num" puts $file_handle "" puts $file_handle "// Aligned memory segments to be used for buffer descriptors" puts $file_handle "//" puts $file_handle "// NONE - WARP IP/UDP library configured to ignore ETH $inst_num" puts $file_handle "" puts $file_handle "// Memory allocations for buffers" puts $file_handle "//" puts $file_handle "// NONE - WARP IP/UDP library configured to ignore ETH $inst_num" puts $file_handle "" } } proc print_config_c_file_footer {file_handle inf_type_list ignore_list} { set inst_num 0 puts $file_handle "" puts $file_handle "/*************************** Variable Definitions ****************************/" puts $file_handle "" puts $file_handle "// Ethernet device structure" puts $file_handle "ethernet_device eth_device\[WARP_IP_UDP_NUM_ETH_DEVICES\];" puts $file_handle "" puts $file_handle "" puts $file_handle "/******************************** Functions **********************************/" puts $file_handle "" puts $file_handle "/*****************************************************************************/" puts $file_handle "/**" puts $file_handle " * Initialize the information about the Ethernet device" puts $file_handle " *" puts $file_handle " * @param eth_dev_num - Ethernet device number" puts $file_handle " *" puts $file_handle " * @return None" puts $file_handle " *" puts $file_handle " ******************************************************************************/" puts $file_handle "" puts $file_handle "void eth_init_device_info(u32 eth_dev_num) \{" puts $file_handle "" puts $file_handle " int i;" puts $file_handle " u32 temp;" puts $file_handle "" puts $file_handle " // Initialize Ethernet device" puts $file_handle " switch (eth_dev_num) \{" foreach inf_type $inf_type_list { set ignore [lindex $ignore_list $inst_num] puts $file_handle [format " case WARP_IP_UDP_ETH_%s:" $inst_num] if { $ignore == 0 } { puts $file_handle " eth_device\[eth_dev_num\].initialized = 1;" } else { puts $file_handle " eth_device\[eth_dev_num\].initialized = 0;" } switch $inf_type { "axi_dma" { if { $ignore == 0 } { puts $file_handle [format " eth_device\[eth_dev_num\].eth_id = WARP_IP_UDP_ETH_%s_MAC_DEVICE_ID;" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].eth_ptr = Ð_%s_instance;" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].eth_cfg_ptr = (void *) XAxiEthernet_LookupConfig(WARP_IP_UDP_ETH_%s_MAC_DEVICE_ID);" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].dma_id = WARP_IP_UDP_ETH_%s_INF_DEVICE_ID;" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].dma_ptr = Ð_%s_dma_instance;" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].dma_cfg_ptr = (void *) XAxiDma_LookupConfig(WARP_IP_UDP_ETH_%s_INF_DEVICE_ID);" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].dma_rx_ring_ptr = (void *) XAxiDma_GetRxRing(Ð_%s_dma_instance);" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].dma_rx_bd_ptr = Ð_%s_rx_bd_space;" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].dma_rx_bd_cnt = WARP_IP_UDP_ETH_%s_RXBD_CNT;" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].dma_tx_ring_ptr = (void *) XAxiDma_GetTxRing(Ð_%s_dma_instance);" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].dma_tx_bd_ptr = Ð_%s_tx_bd_space;" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].dma_tx_bd_cnt = WARP_IP_UDP_ETH_%s_TXBD_CNT;" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].padding = 0;" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].num_recv_buffers = WARP_IP_UDP_ETH_%s_NUM_RECV_BUF;" $inst_num] puts $file_handle [format " eth_device\[eth_dev_num\].recv_buffers = ETH_%s_recv_buffers;" $inst_num] } else { puts $file_handle " eth_device\[eth_dev_num\].eth_id = 0;" puts $file_handle " eth_device\[eth_dev_num\].eth_ptr = NULL;" puts $file_handle " eth_device\[eth_dev_num\].eth_cfg_ptr = NULL;" puts $file_handle " eth_device\[eth_dev_num\].dma_id = 0;" puts $file_handle " eth_device\[eth_dev_num\].dma_ptr = NULL;" puts $file_handle " eth_device\[eth_dev_num\].dma_cfg_ptr = NULL;" puts $file_handle " eth_device\[eth_dev_num\].dma_rx_ring_ptr = NULL;" puts $file_handle " eth_device\[eth_dev_num\].dma_rx_bd_ptr = NULL;" puts $file_handle " eth_device\[eth_dev_num\].dma_rx_bd_cnt = 0;" puts $file_handle " eth_device\[eth_dev_num\].dma_tx_ring_ptr = NULL;" puts $file_handle " eth_device\[eth_dev_num\].dma_tx_bd_ptr = NULL;" puts $file_handle " eth_device\[eth_dev_num\].dma_tx_bd_cnt = 0;" puts $file_handle " eth_device\[eth_dev_num\].padding = 0;" puts $file_handle " eth_device\[eth_dev_num\].num_recv_buffers = 0;" puts $file_handle " eth_device\[eth_dev_num\].recv_buffers = NULL;" } } "default" { error "Unable to handle AXI connections for target type $inf_type. Some common causes are 1. The AXI4 Stream interface of the AXI Ethernet is left unconnected. 2. The Ethernet instance is connected to an AXI FIFO. 3. A custom peripheral is connected to the AXI interface. The WARP UDP Transport has been designed for use with the AXI DMA peripheral only." "" "mdt_error" } } puts $file_handle "" puts $file_handle " bzero(eth_device\[eth_dev_num\].hw_addr, ETH_MAC_ADDR_LEN);" puts $file_handle " bzero(eth_device\[eth_dev_num\].ip_addr, IP_ADDR_LEN);" if { $ignore == 0 } { puts $file_handle "" puts $file_handle " // Initialize the buffers for the device" puts $file_handle " // NOTE: For the receive buffers, they are all being used by the library and cannot be allocated" puts $file_handle " //" puts $file_handle [format " for (i = 0; i < WARP_IP_UDP_ETH_%s_NUM_RECV_BUF; i++) \{" $inst_num] puts $file_handle [format " temp = (u32)(((u8*)(Ð_%s_recv_buffer) + (i * (WARP_IP_UDP_ETH_BUF_SIZE)) + WARP_IP_UDP_ETH_RX_BUF_ALIGNMENT));" $inst_num] puts $file_handle "" puts $file_handle " //xil_printf(\"temp_%d = 0x%08x, full buff size = %d, Ð_0_recv_buffer = 0x%08x\\n\", i, temp, sizeof(ETH_0_recv_buffer), Ð_0_recv_buffer);" puts $file_handle "" puts $file_handle [format " ETH_%s_recv_buffers\[i\].state = WARP_IP_UDP_BUFFER_IN_USE;" $inst_num] puts $file_handle [format " ETH_%s_recv_buffers\[i\].max_size = WARP_IP_UDP_ETH_BUF_SIZE;" $inst_num] puts $file_handle [format " ETH_%s_recv_buffers\[i\].size = 0;" $inst_num] puts $file_handle [format " ETH_%s_recv_buffers\[i\].data = (u8 *) temp;" $inst_num] puts $file_handle [format " ETH_%s_recv_buffers\[i\].offset = (u8 *) temp;" $inst_num] puts $file_handle [format " ETH_%s_recv_buffers\[i\].length = 0;" $inst_num] puts $file_handle [format " ETH_%s_recv_buffers\[i\].descriptor = NULL;" $inst_num] puts $file_handle " \}" } puts $file_handle " break;" puts $file_handle "" incr inst_num } puts $file_handle " default:" puts $file_handle " xil_printf(\" **** ERROR: Ethernet device %d not configured in hardware.\", (eth_dev_num + 1));" puts $file_handle " break;" puts $file_handle " \}" puts $file_handle "\}" puts $file_handle "" } ############################################################### # Methods to print the device file header # # @param Library Handle # # @return None # ############################################################### proc print_device_h_file_header {file_handle } { global num_ethernet_instances puts $file_handle "" puts $file_handle "\#ifndef WARP_IP_UDP_DEVICE_H_" puts $file_handle "\#define WARP_IP_UDP_DEVICE_H_" puts $file_handle "" puts $file_handle "" puts $file_handle "/***************************** Include Files *********************************/" puts $file_handle "" puts $file_handle "/*************************** Constant Definitions ****************************/" puts $file_handle "" puts $file_handle "// Global Defines" puts $file_handle "\#define WARP_IP_UDP_NUM_ETH_DEVICES $num_ethernet_instances" puts $file_handle "" } proc print_device_h_file_body {file_handle inst_num inst_name ignore} { puts $file_handle "" puts $file_handle "/************************* Ethernet $inst_num Definitions ****************************/" puts $file_handle "" puts $file_handle "// Ethernet device $inst_num" puts $file_handle "\#define WARP_IP_UDP_ETH_$inst_num $inst_num // Internal name of Ethernet device" puts $file_handle "\#define $inst_name WARP_IP_UDP_ETH_$inst_num // External name of Ethernet device" puts $file_handle "" } proc print_device_h_file_footer {file_handle} { puts $file_handle "" puts $file_handle "/*********************** Global Variable Definitions *************************/" puts $file_handle "" puts $file_handle "" puts $file_handle "/*************************** Function Prototypes *****************************/" puts $file_handle "" puts $file_handle "" puts $file_handle "\#endif // WARP_IP_UDP_DEVICE_H_" puts $file_handle "" }