XilinxProcessorIPLib/drivers/axiethernet/examples/xaxiethernet_mcdma_ping_req_example.c
void SendEchoReqFrame(XAxiEthernet *AxiEthernetInstancePtr,
	              XMcdma *DmaInstancePtr, u8 ChanId)
{
	u16 *TempPtr;
	u16 *TxFramePtr;
	UINTPTR BufAddr;
	u16 CheckSum;
	int Index, i;

	FramesTx = 0;
	TxFramePtr = (u16 *)(UINTPTR)GetBufAddr();
	BufAddr = (UINTPTR) TxFramePtr;

	if (Padding) {
		for (i = 0 ; i < 4; i++)
			*TxFramePtr++ = 0;
	}

	/*
	 * Add Destination MAC Address.
	 */
	Index = MAC_ADDR_LEN;
	while (Index--) {
		*(TxFramePtr + Index) = *(DestMacAddr + Index);
	}

	/*
	 * Add Source MAC Address.
	 */
	Index = MAC_ADDR_LEN;
	TempPtr = (u16 *)LocalMacAddr;
	while (Index--) {
		*(TxFramePtr + (Index + SRC_MAC_ADDR_LOC )) =
							*(TempPtr + Index);
	}

	/*
	 * Add IP header information.
	 */
	Index = IP_START_LOC;
	while (Index--) {
		*(TxFramePtr + (Index + ETHER_PROTO_TYPE_LOC )) =
				Xil_Htons(*(IpHeaderInfo + Index));
	}

	/*
	 * Add Source IP address.
	 */
	Index = IP_ADDR_LEN;
	TempPtr = (u16 *)LocalIpAddress;
	while (Index--) {
		*(TxFramePtr + (Index + IP_REQ_SRC_IP_LOC )) =
						*(TempPtr + Index);
	}

	/*
	 * Add Destination IP address.
	 */
	Index = IP_ADDR_LEN;
	TempPtr = (u16 *)DestIpAddress;
	while (Index--) {
		*(TxFramePtr + (Index + IP_REQ_DEST_IP_LOC )) =
						*(TempPtr + Index);
	}

	/*
	 * Checksum is calculated for IP field and added in the frame.
	 */
	CheckSum = CheckSumCalculation((u16 *)BufAddr, IP_START_LOC + 4,
							IP_HEADER_LEN);
	CheckSum = ~CheckSum;
	*(TxFramePtr + IP_CHECKSUM_LOC) = Xil_Htons(CheckSum);

	/*
	 * Add echo field information.
	 */
	*(TxFramePtr + ICMP_ECHO_FIELD_LOC) = Xil_Htons(XAE_ETHER_PROTO_TYPE_IP);

	/*
	 * Checksum value is initialized to zeros.
	 */
	*(TxFramePtr + ICMP_DATA_LEN) = 0x0000;

	/*
	 * Add identifier and sequence number to the frame.
	 */
	*(TxFramePtr + ICMP_IDEN_FIELD_LOC) = (IDEN_NUM);
	*(TxFramePtr + (ICMP_IDEN_FIELD_LOC + 1)) = Xil_Htons((u16)(++SeqNum));

	/*
	 * Add known data to the frame.
	 */
	Index = ICMP_KNOWN_DATA_LEN;
	while (Index--) {
		*(TxFramePtr + (Index + ICMP_KNOWN_DATA_LOC)) =
				Xil_Htons(*(IcmpData + Index));
	}

	/*
	 * Checksum is calculated for Data Field and added in the frame.
	 */
	CheckSum = CheckSumCalculation((u16 *)BufAddr, ICMP_DATA_START_LOC + 4,
						ICMP_DATA_FIELD_LEN );
	CheckSum = ~CheckSum;
	*(TxFramePtr + ICMP_DATA_CHECKSUM_LOC) = Xil_Htons(CheckSum);

	/*
	 * Transmit the Frame.
	 */
	XAxienet_Send(AxiEthernetInstancePtr, DmaInstancePtr, ChanId, BufAddr, ICMP_PKT_SIZE);
	while (1) {
		CheckTxDmaResult(DmaInstancePtr);
		if (FramesTx)
			break;
	}
}
/*****************************************************************************/
/**
*
* This function will send a Echo request packet.
*
* @param	AxiEthernetInstancePtr is a pointer to the instance of the
*		Axi Ethernet component.
* @param	DmaInstancePtr is a pointer to the instance of the Dma
*		component.
* @param	ChanId is the MCDMA Channel number to be operate on.
*
* @return	None.
*
* @note		None.
*
******************************************************************************/
This function will send a Echo request packet.
This function will send a Echo request packet .
void SendEchoReqFrame(XAxiEthernet *AxiEthernetInstancePtr,
	              XMcdma *DmaInstancePtr, u8 ChanId)
{
	u16 *TempPtr;
	u16 *TxFramePtr;
	UINTPTR BufAddr;
	u16 CheckSum;
	int Index, i;
	FramesTx = 0;
	TxFramePtr = (u16 *)(UINTPTR)GetBufAddr();
	BufAddr = (UINTPTR) TxFramePtr;
	if (Padding) {
		for (i = 0 ; i < 4; i++)
			*TxFramePtr++ = 0;
	}
	Index = MAC_ADDR_LEN;
	while (Index--) {
		*(TxFramePtr + Index) = *(DestMacAddr + Index);
	}
	Index = MAC_ADDR_LEN;
	TempPtr = (u16 *)LocalMacAddr;
	while (Index--) {
		*(TxFramePtr + (Index + SRC_MAC_ADDR_LOC )) =
							*(TempPtr + Index);
	}
	Index = IP_START_LOC;
	while (Index--) {
		*(TxFramePtr + (Index + ETHER_PROTO_TYPE_LOC )) =
				Xil_Htons(*(IpHeaderInfo + Index));
	}
	Index = IP_ADDR_LEN;
	TempPtr = (u16 *)LocalIpAddress;
	while (Index--) {
		*(TxFramePtr + (Index + IP_REQ_SRC_IP_LOC )) =
						*(TempPtr + Index);
	}
	Index = IP_ADDR_LEN;
	TempPtr = (u16 *)DestIpAddress;
	while (Index--) {
		*(TxFramePtr + (Index + IP_REQ_DEST_IP_LOC )) =
						*(TempPtr + Index);
	}
	CheckSum = CheckSumCalculation((u16 *)BufAddr, IP_START_LOC + 4,
							IP_HEADER_LEN);
	CheckSum = ~CheckSum;
	*(TxFramePtr + IP_CHECKSUM_LOC) = Xil_Htons(CheckSum);
	*(TxFramePtr + ICMP_ECHO_FIELD_LOC) = Xil_Htons(XAE_ETHER_PROTO_TYPE_IP);
	*(TxFramePtr + ICMP_DATA_LEN) = 0x0000;
	*(TxFramePtr + ICMP_IDEN_FIELD_LOC) = (IDEN_NUM);
	*(TxFramePtr + (ICMP_IDEN_FIELD_LOC + 1)) = Xil_Htons((u16)(++SeqNum));
	Index = ICMP_KNOWN_DATA_LEN;
	while (Index--) {
		*(TxFramePtr + (Index + ICMP_KNOWN_DATA_LOC)) =
				Xil_Htons(*(IcmpData + Index));
	}
	CheckSum = CheckSumCalculation((u16 *)BufAddr, ICMP_DATA_START_LOC + 4,
						ICMP_DATA_FIELD_LEN );
	CheckSum = ~CheckSum;
	*(TxFramePtr + ICMP_DATA_CHECKSUM_LOC) = Xil_Htons(CheckSum);
	XAxienet_Send(AxiEthernetInstancePtr, DmaInstancePtr, ChanId, BufAddr, ICMP_PKT_SIZE);
	while (1) {
		CheckTxDmaResult(DmaInstancePtr);
		if (FramesTx)
			break;
	}
}
void SendEchoReqFrame ( XAxiEthernet * AxiEthernetInstancePtr , XMcdma * DmaInstancePtr , u8 ChanId ) { u16 * TempPtr ; u16 * TxFramePtr ; UINTPTR BufAddr ; u16 CheckSum ; int Index , i ; FramesTx = 0 ; TxFramePtr = ( u16 * ) ( UINTPTR ) GetBufAddr ( ) ; BufAddr = ( UINTPTR ) TxFramePtr ; if ( Padding ) { for ( i = 0 ; i < 4 ; i ++ ) * TxFramePtr ++ = 0 ; } Index = MAC_ADDR_LEN ; while ( Index -- ) { * ( TxFramePtr + Index ) = * ( DestMacAddr + Index ) ; } Index = MAC_ADDR_LEN ; TempPtr = ( u16 * ) LocalMacAddr ; while ( Index -- ) { * ( TxFramePtr + ( Index + SRC_MAC_ADDR_LOC ) ) = * ( TempPtr + Index ) ; } Index = IP_START_LOC ; while ( Index -- ) { * ( TxFramePtr + ( Index + ETHER_PROTO_TYPE_LOC ) ) = Xil_Htons ( * ( IpHeaderInfo + Index ) ) ; } Index = IP_ADDR_LEN ; TempPtr = ( u16 * ) LocalIpAddress ; while ( Index -- ) { * ( TxFramePtr + ( Index + IP_REQ_SRC_IP_LOC ) ) = * ( TempPtr + Index ) ; } Index = IP_ADDR_LEN ; TempPtr = ( u16 * ) DestIpAddress ; while ( Index -- ) { * ( TxFramePtr + ( Index + IP_REQ_DEST_IP_LOC ) ) = * ( TempPtr + Index ) ; } CheckSum = CheckSumCalculation ( ( u16 * ) BufAddr , IP_START_LOC + 4 , IP_HEADER_LEN ) ; CheckSum = ~ CheckSum ; * ( TxFramePtr + IP_CHECKSUM_LOC ) = Xil_Htons ( CheckSum ) ; * ( TxFramePtr + ICMP_ECHO_FIELD_LOC ) = Xil_Htons ( XAE_ETHER_PROTO_TYPE_IP ) ; * ( TxFramePtr + ICMP_DATA_LEN ) = 0x0000 ; * ( TxFramePtr + ICMP_IDEN_FIELD_LOC ) = ( IDEN_NUM ) ; * ( TxFramePtr + ( ICMP_IDEN_FIELD_LOC + 1 ) ) = Xil_Htons ( ( u16 ) ( ++ SeqNum ) ) ; Index = ICMP_KNOWN_DATA_LEN ; while ( Index -- ) { * ( TxFramePtr + ( Index + ICMP_KNOWN_DATA_LOC ) ) = Xil_Htons ( * ( IcmpData + Index ) ) ; } CheckSum = CheckSumCalculation ( ( u16 * ) BufAddr , ICMP_DATA_START_LOC + 4 , ICMP_DATA_FIELD_LEN ) ; CheckSum = ~ CheckSum ; * ( TxFramePtr + ICMP_DATA_CHECKSUM_LOC ) = Xil_Htons ( CheckSum ) ; XAxienet_Send ( AxiEthernetInstancePtr , DmaInstancePtr , ChanId , BufAddr , ICMP_PKT_SIZE ) ; while ( 1 ) { CheckTxDmaResult ( DmaInstancePtr ) ; if ( FramesTx ) break ; } }
This function will send a Echo request packet.
This function will send a Echo request packet .
/*
	 * Add Destination MAC Address.
	 */ /*
	 * Add Source MAC Address.
	 */ /*
	 * Add IP header information.
	 */ /*
	 * Add Source IP address.
	 */ /*
	 * Add Destination IP address.
	 */ /*
	 * Checksum is calculated for IP field and added in the frame.
	 */ /*
	 * Add echo field information.
	 */ /*
	 * Checksum value is initialized to zeros.
	 */ /*
	 * Add identifier and sequence number to the frame.
	 */ /*
	 * Add known data to the frame.
	 */ /*
	 * Checksum is calculated for Data Field and added in the frame.
	 */ /*
	 * Transmit the Frame.
	 */