axiethernet: xaxiethernet_mcdma_ping_req_example.c File Reference

| axiethernet Xilinx SDK Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Macros | Functions
xaxiethernet_mcdma_ping_req_example.c File Reference

## Overview

This file contains a Axi Ethernet MCDMA Ping request example in polled mode.

This example will generate a ping request for the specified IP address.

Note

The local IP address is set to 10.10.70.6. User needs to update LocalIpAddr variable with a free IP address based on the network on which this example is to be run.

The Destination IP address is set to 10.10.70.3. User needs to update DestIpAddress variable with any valid IP address based on the network on which this example is to be run.

The local MAC address is set to 0x000A35030201. User can update LocalMacAddr variable with a valid MAC address. The first three bytes contains the manufacture ID. 0x000A35 is XILINX manufacture ID.

This program will generate the specified number of ping request packets as defined in "NUM_OF_PING_REQ_PKTS".

This example got validated only for SGMII based design's.

Functional guide to example:

- SendArpReqFrame demonstrates the way to send the ARP request packets in the polling mode
- SendEchoReqFrame demonstrates the way to send the ICMP/ECHO request packets in the polling mode
- ProcessRecvFrame demonstrates the way to process the received packet. This function sends the echo request packet based on the ARP reply packet.

    MODIFICATION HISTORY:

    Ver   Who  Date     Changes

    5.5   adk               Initial Release

## Macros
#define | XAE_ETHER_PROTO_TYPE_IP 0x0800
| IP Protocol. More...
#define | XAE_ETHER_PROTO_TYPE_ARP 0x0806
| ARP Protocol. More...
#define | XAE_ETHER_PROTO_TYPE_VLAN 0x8100
| VLAN Tagged. More...
#define | XAE_ARP_PACKET_SIZE 28
| Max ARP packet size. More...
#define | XAE_HEADER_IP_LENGTH_OFFSET 16
| IP Length Offset. More...
#define | XAE_VLAN_TAG_SIZE 4
| VLAN Tag Size. More...

## Functions
int | AxiEthernetPingReqExample (XAxiEthernet *AxiEthernetInstancePtr, XMcdma *DmaInstancePtr, u16 AxiEthernetDeviceId, u16 AxiMcDmaDeviceId)
| The entry point for the AxiEthernet driver to ping request example in polled mode. More...
void | SendArpReqFrame (XAxiEthernet *AxiEthernetInstancePtr, XMcdma *DmaInstancePtr, u8 ChanId)
| This function will send a ARP request packet. More...
void | SendEchoReqFrame (XAxiEthernet *AxiEthernetInstancePtr, XMcdma *DmaInstancePtr, u8 ChanId)
| This function will send a Echo request packet. More...
int | ProcessRecvFrame (XAxiEthernet *AxiEthernetInstancePtr, XMcdma *DmaInstancePtr, u8 ChanId)
| This function will process the received packet. More...
int | main ()
| This function is the main function of the Ping Request example in polled mode. More...

## Macro Definition Documentation

#define XAE_ARP_PACKET_SIZE 28

Max ARP packet size.

#define XAE_ETHER_PROTO_TYPE_ARP 0x0806

ARP Protocol.

Referenced by ProcessRecvFrame(), and SendArpReqFrame().

#define XAE_ETHER_PROTO_TYPE_IP 0x0800

IP Protocol.

Referenced by ProcessRecvFrame(), SendArpReqFrame(), and SendEchoReqFrame().

#define XAE_ETHER_PROTO_TYPE_VLAN 0x8100

VLAN Tagged.

#define XAE_HEADER_IP_LENGTH_OFFSET 16

IP Length Offset.

#define XAE_VLAN_TAG_SIZE 4

VLAN Tag Size.

## Function Documentation

int AxiEthernetPingReqExample | ( | XAxiEthernet * | AxiEthernetInstancePtr,
|  | XMcdma * | DmaInstancePtr,
|  | u16 | AxiEthernetDeviceId,
|  | u16 | AxiMcDmaDeviceId
| ) |  |

The entry point for the AxiEthernet driver to ping request example in polled mode.

This function will generate specified number of request packets as defined in "NUM_OF_PING_REQ_PKTS.

Parameters

  AxiEthernetInstancePtr | is a pointer to the instance of the AxiEthernet component.
  DmaInstancePtr | is a pointer to the instance of the AXI MCDMA component.
  AxiEthernetDeviceId | is Device ID of the Axi Ethernet Device , typically XPAR_<AXIETHERNET_instance>_DEVICE_ID value from xparameters.h.
  AxiMcDmaDeviceId | is Device ID of the Axi DMAA Device , typically XPAR_<AXIMCDMA_instance>_DEVICE_ID value from xparameters.h.

Returns
  XST_FAILURE to indicate failure, otherwise it will return XST_SUCCESS.

Note
  AxiMcdma hardware must be initialized before initializing AxiEthernet. Since AxiMcdma reset line is connected to the AxiEthernet reset line, a reset of AxiMcdma hardware during its initialization would reset AxiEthernet.

References XAxiEthernet_Config::AxiDevType, XAxiEthernet_Config::BaseAddress, XAxiEthernet_Config::Enable_1588, ProcessRecvFrame(), SendArpReqFrame(), SendEchoReqFrame(), XAE_RECEIVER_ENABLE_OPTION, XAE_TRANSMITTER_ENABLE_OPTION, XAxiEthernet_CfgInitialize(), XAxiEthernet_LookupConfig(), XAxiEthernet_SetMacAddress(), XAxiEthernet_SetOptions(), and XAxiEthernet_Start().

Referenced by main().

int main | ( | void |  | ) |

This function is the main function of the Ping Request example in polled mode.

Parameters

  None. |

Returns
  XST_FAILURE to indicate failure, otherwise it will return XST_SUCCESS after sending specified number of packets as defined in "NUM_OF_PING_REQ_PKTS" .

Note
  None.

References AXIETHERNET_DEVICE_ID, and AxiEthernetPingReqExample().

int ProcessRecvFrame | ( | XAxiEthernet * | AxiEthernetInstancePtr,
|  | XMcdma * | DmaInstancePtr,
|  | u8 | ChanId
| ) |  |

This function will process the received packet.

This function sends the echo request packet based on the ARP reply packet.

Parameters

  AxiEthernetInstancePtr | is a pointer to the instance of the Axi Ethernet component.
  DmaInstancePtr | is a pointer to the instance of the Dma component.
  ChanId | is the MCDMA Channel number to be operate on.

Returns
  XST_SUCCESS is returned when an echo reply is received. Otherwise, XST_FAILURE is returned.

Note
  This assumes MAC does not strip padding or CRC.

References SendEchoReqFrame(), XAE_ETHER_PROTO_TYPE_ARP, and XAE_ETHER_PROTO_TYPE_IP.

Referenced by AxiEthernetPingReqExample().

void SendArpReqFrame | ( | XAxiEthernet * | AxiEthernetInstancePtr,
|  | XMcdma * | DmaInstancePtr,
|  | u8 | ChanId
| ) |  |

This function will send a ARP request packet.

Parameters

  AxiEthernetInstancePtr | is a pointer to the instance of the Axi Ethernet component.
  DmaInstancePtr | is a pointer to the instance of the Dma component.
  ChanId | is the MCDMA Channel number to be operate on.

Returns
  None.

Note
  None.

References XAE_ETHER_PROTO_TYPE_ARP, and XAE_ETHER_PROTO_TYPE_IP.

Referenced by AxiEthernetPingReqExample().

void SendEchoReqFrame | ( | XAxiEthernet * | AxiEthernetInstancePtr,
|  | XMcdma * | DmaInstancePtr,
|  | u8 | ChanId
| ) |  |

This function will send a Echo request packet.

Parameters

  AxiEthernetInstancePtr | is a pointer to the instance of the Axi Ethernet component.
  DmaInstancePtr | is a pointer to the instance of the Dma component.
  ChanId | is the MCDMA Channel number to be operate on.

Returns
  None.

Note
  None.

References XAE_ETHER_PROTO_TYPE_IP.

Referenced by AxiEthernetPingReqExample(), and ProcessRecvFrame().