Skip to content

Commit

Permalink
axiethernet: Add axiethernet mcdma examples
Browse files Browse the repository at this point in the history
This patch adds below examples in the driver which supports
axiethernet mcdma configuration.
--> Polled mode example
--> Interrupt example
--> Ping Request example

This patch also updates the test app tcl to support mcdma use cases.

Signed-off-by: Kedareswara rao Appana <appanad@xilinx.com>

Acked-by: Harini Katakam <harinik@xilinx.com>
  • Loading branch information
kedareswararao authored and vdubakul committed Sep 15, 2017
1 parent 60104ac commit 2ad67e6
Show file tree
Hide file tree
Showing 12 changed files with 5,334 additions and 14 deletions.
@@ -0,0 +1,49 @@
/******************************************************************************
*
* Copyright (C) 2010 - 2014 Xilinx, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/

#include "xstatus.h"
#include "xil_types.h"

#include "xparameters.h"

#ifdef XPAR_INTC_0_DEVICE_ID
#define INTC XIntc
#else
#define INTC XScuGic
#endif

int AxiEthernetSgDmaIntrExample(INTC * IntcInstancePtr,
XAxiEthernet * AxiEthernetInstancePtr,
XMcdma * DmaInstancePtr,
u16 AxiEthernetDeviceId,
u16 AxiDmaDeviceId,
u16 AxiEthernetIntrId);
114 changes: 111 additions & 3 deletions XilinxProcessorIPLib/drivers/axiethernet/data/axiethernet_tapp.tcl
Expand Up @@ -66,6 +66,10 @@ proc gen_include_files {swproj mhsinst} {
append inc_file_lines " axiethernet_header.h"
append inc_file_lines " axiethernet_fifo_intr_header.h"
}
if {$dmaType == 2} {
append inc_file_lines " xmcdma.h"
append inc_file_lines " axiethernet_mcdma_intr_header.h"
}
if {$dmaType == 3} {
append inc_file_lines " xaxidma.h"
append inc_file_lines " axiethernet_intr_header.h"
Expand Down Expand Up @@ -95,7 +99,9 @@ proc gen_src_files {swproj mhsinst} {
set inc_file_lines {examples/xaxiethernet_example.h examples/xaxiethernet_example_polled.c examples/xaxiethernet_example_util.c examples/xaxiethernet_example_intr_fifo.c data/axiethernet_header.h data/axiethernet_fifo_intr_header.h}
} elseif {$dmaType == 3} {
set inc_file_lines {examples/xaxiethernet_example.h examples/xaxiethernet_example_util.c examples/xaxiethernet_example_intr_sgdma.c data/axiethernet_intr_header.h}
}
} elseif {$dmaType == 2} {
set inc_file_lines {examples/xaxiethernet_example.h examples/xaxiethernet_example_util.c examples/xaxiethernet_example_intr_mcdma.c data/axiethernet_mcdma_intr_header.h}
}
} else {
if {$dmaType == 1} {
set inc_file_lines {examples/xaxiethernet_example.h examples/xaxiethernet_example_polled.c examples/xaxiethernet_example_util.c data/axiethernet_header.h}
Expand Down Expand Up @@ -142,6 +148,13 @@ proc gen_init_code {swproj mhsinst} {
"
}

#MCDMA
if {$dmaType == 2} {
append decl "
static XMcdma ${ipname}_Mcdma;
"
}

set inc_file_lines $decl
return $inc_file_lines
}
Expand Down Expand Up @@ -174,6 +187,9 @@ proc gen_testfunc_call {swproj mhsinst} {
set dma_deviceid [get_dma_info $mhsinst "id"]
set dma_ipname [get_dma_info $mhsinst "name"]

set mcdma_deviceid [get_mcdma_info $mhsinst "id"]
set mcdma_ipname [get_mcdma_info $mhsinst "name"]

if {$ifintr == 1} {
set intr_pin_name [get_pins -of_objects [get_cells -hier $ipname] INTERRUPT]
set intcname [::hsi::utils::get_connected_intr_cntrl $ipname $intr_pin_name]
Expand All @@ -185,7 +201,7 @@ proc gen_testfunc_call {swproj mhsinst} {
if { $dma == 1 } {
set type "Fifo"
}
if { $dma == 3 } {
if { $dma == 3 || $dma == 2} {
set type "SgDma"
}

Expand Down Expand Up @@ -299,6 +315,43 @@ proc gen_testfunc_call {swproj mhsinst} {
}
# END: FIFO & INTERRUPT

# BEGIN: MCDMA & INTERRUPT
if { $dma == 2} {
set dmaDriverInst "${ipname}_Mcdma"
append testfunc_call "
{
int Status;
"

if {${hasStdout} == 1} {
append testfunc_call "
print(\"\\r\\nRunning AxiEthernet${type}IntrExample() for ${ipname}...\\r\\n\");
"
}

append testfunc_call "
Status = AxiEthernet${type}IntrExample(&${intcvar}, &${ipname}_AxiEthernet,
&${dmaDriverInst},
${deviceid},
${mcdma_deviceid},
${intr_id});
"

if {${hasStdout} == 1} {
append testfunc_call "
if (Status == 0) {
print(\"AxiEthernet Interrupt Test PASSED.\\r\\n\");
}
else {
print(\"AxiEthernet Interrupt Test FAILED.\\r\\n\");
}
"
}

append testfunc_call "
}"
}
# END: MCDMA & INTERRUPT
# BEGIN: DMA & INTERRUPT
if {$dma == 3} {
# DMA
Expand Down Expand Up @@ -420,14 +473,69 @@ proc get_dma_info {mhsinst type} {
}
}

proc get_mcdma_info {mhsinst type} {
set ipinst_list [get_cells -hier $mhsinst "*"]

set p2p_busifs_i [get_intf_pins -of_objects $mhsinst -filter "TYPE==INITIATOR"]
# Add p2p periphs
foreach p2p_busif $p2p_busifs_i {
set busif_name [string toupper [get_property NAME $p2p_busif]]
set conn_busif_handle [::hsi::utils::get_connected_intf $mhsinst $busif_name]
if { [string compare -nocase $conn_busif_handle ""] == 0} {
continue
} else {
# if there is a single match, we know if it is FIFO or DMA
# no need for further iterations
set conn_busif_name [get_property NAME $conn_busif_handle]
set target_periph [get_cells -of_objects $conn_busif_handle]
set target_periph_type [get_property IP_NAME $target_periph]
if { [string compare -nocase $target_periph_type "tri_mode_ethernet_mac"] == 0 } {
continue
}
set target_periph_name [string toupper [get_property NAME $target_periph]]
set instName [get_property NAME $target_periph]
## If Chiscope is connected b/w DMA/FIFO and Ethernet
if {[llength $target_periph] > 1} {
foreach peri_name $target_periph {
set target_periph_type [get_property IP_NAME $peri_name]
set instName [get_property NAME $peri_name]
if {[string compare -nocase $target_periph_type "axi_mcdma"] == 0} {
if {[string compare -nocase $type "id"] == 0} {
set deviceid [::hsi::utils::get_ip_param_name $peri_name "DEVICE_ID"]
return $deviceid
}
if {[string compare -nocase $type "name"] == 0} {
return $instName
}
}
}

}
if {[string compare -nocase $target_periph_type "axi_mcdma"] == 0} {
if {[string compare -nocase $type "id"] == 0} {
set deviceid [::hsi::utils::get_ip_param_name $target_periph "DEVICE_ID"]
return $deviceid
}
if {[string compare -nocase $type "name"] == 0} {
return $instName
}
}
}
}
}

proc get_dma_type {mhsinst} {

set dma_deviceid [get_dma_info $mhsinst "id"]
set mcdma_deviceid [get_mcdma_info $mhsinst "id"]

if { $dma_deviceid != "" } {
if { $mcdma_deviceid != "" } {
set dma 2
} elseif { $dma_deviceid != "" } {
set dma 3
} else {
set dma 1
}

return $dma
}
3 changes: 3 additions & 0 deletions XilinxProcessorIPLib/drivers/axiethernet/examples/index.html
Expand Up @@ -15,6 +15,9 @@ <h1> Example Applications for the driver axiethernet_v4_2 </h1>
<li>xaxiethernet_example_intr_fifo.c <a href="xaxiethernet_example_intr_fifo.c">(source)</a> </li>
<li>xaxiethernet_example_intr_sgdma.c <a href="xaxiethernet_example_intr_sgdma.c">(source)</a> </li>
<li>xaxiethernet_example_polled.c <a href="xaxiethernet_example_polled.c">(source)</a> </li>
<li>xaxiethernet_example_mcdma_poll.c <a href="xaxiethernet_example_mcdma_poll.c">(source)</a> </li>
<li>xaxiethernet_example_intr_mcdma.c <a href="xaxiethernet_example_intr_mcdma.c">(source)</a> </li>
<li>xaxienet_mcdma_ping_req_example.c <a href="xaxienet_mcdma_ping_req_example.c">(source)</a> </li>
<li>xaxiethernet_example_util.c <a href="xaxiethernet_example_util.c">(source)</a> </li>
</ul>
<p><font face="Times New Roman" color="#800000">Copyright � 1995-2014 Xilinx, Inc. All rights reserved.</font></p>
Expand Down
29 changes: 25 additions & 4 deletions XilinxProcessorIPLib/drivers/axiethernet/examples/readme.txt
Expand Up @@ -55,7 +55,28 @@ frame construction.

For details, see xaxiethernet_example_util.c.

@section ex7 xaxiethernet_example.h
@section ex7 xaxiethernet_example_mcdma_poll.c
Contains an example on how to use the XAxietherent driver directly.
This example shows how to use Axi Ethernet with MCDMA in polled mode
to send and receive frames.

For details, see xaxiethernet_example_mcdma_poll.c.

@section ex8 xaxiethernet_example_intr_mcdma.c
Contains an example on how to use the XAxietherent driver directly.
This example shows how to use Axi Ethernet with MCDMA in interrupt mode
to send and receive frames.

For details, see xaxiethernet_example_intr_mcdma.c.

@section ex9 xaxiethernet_mcdma_ping_req_example.c
Contains an example on how to use the XAxietherent driver directly.
This example shows how to use Axi Ethernet with MCDMA in polled mode
to send ping request's.

For details, see xaxiethernet_mcdma_ping_req_example.c.

@section ex10 xaxiethernet_example.h
This headerfile defines common data types, prototypes, and includes the proper
headers for use with the Axi Ethernet examples.

Expand All @@ -70,10 +91,10 @@ For details, see xaxiethernet_example.h.

@subsection IMPORTANT NOTES:
- Included HW features are critical as to which examples will run properly.
- The device connected to the AXI4-Stream interface (AXIFIFO or AXIDMA)
- The device connected to the AXI4-Stream interface (AXIFIFO or AXIDMA or AXI MCDMA)
of the AxiEthernet must be initialized before AxiEthernet initialization.
Since the reset line of AXIFIFO or AXIDMA is connected to the reset line
of AxiEthernet, AXIDMA/AXIFIFO initialization would reset AxiEthernet.
Since the reset line of AXIFIFO or AXIDMA or AXI MCDMA is connected to the reset line
of AxiEthernet, AXIDMA/AXIFIFO/AXI MCDMA initialization would reset AxiEthernet.
AxiEthernet hardware initialization routines in the AxiEthernet driver do
not reset the AxiEthernet hardware.
*/
Expand Up @@ -67,6 +67,7 @@
/************************** Constant Definitions ****************************/
#define AXIETHERNET_LOOPBACK_SPEED 100 /* 100Mb/s for Mii */
#define AXIETHERNET_LOOPBACK_SPEED_1G 1000 /* 1000Mb/s for GMii */
#define AXIETHERNET_LOOPBACK_SPEED_2p5G 2500 /* 2p5G for 2.5G MAC */
#define AXIETHERNET_PHY_DELAY_SEC 4 /*
* Amount of time to delay waiting on
* PHY to reset.
Expand All @@ -76,6 +77,7 @@
* Maximum number of multicast ethernet
* mac addresses.
*/
#define NUM_PACKETS 50

/***************** Macros (Inline Functions) Definitions *********************/

Expand All @@ -86,7 +88,7 @@
* Define an aligned data type for an ethernet frame. This declaration is
* specific to the GNU compiler
*/
typedef unsigned char EthernetFrame[XAE_MAX_JUMBO_FRAME_SIZE] __attribute__ ((aligned(64)));
typedef unsigned char EthernetFrame[NUM_PACKETS * XAE_MAX_JUMBO_FRAME_SIZE] __attribute__ ((aligned(64)));


/************************** Function Prototypes *****************************/
Expand Down Expand Up @@ -122,5 +124,6 @@ int AxiEtherentConfigureTIPhy(XAxiEthernet *AxiEthernetInstancePtr,
/************************** Variable Definitions ****************************/

extern char AxiEthernetMAC[]; /* Local MAC address */

extern volatile int Padding;
extern volatile int ExternalLoopback;
#endif /* XAXIETHERNET_EXAMPLE_H */
Expand Up @@ -140,6 +140,8 @@ static volatile int DeviceErrors; /* Num of errors detected in
static volatile int FrameDataErrors; /* Num of times frame data check
* failed
*/
volatile int Padding; /* For 1588 Packets we need to pad 8 bytes time stamp value */
volatile int ExternalLoopback; /* Variable for External loopback */
XAxiEthernet AxiEthernetInstance;
XLlFifo FifoInstance;

Expand Down

0 comments on commit 2ad67e6

Please sign in to comment.