Skip to content

Commit

Permalink
Update Zynq Ultrascale port for V4.x and Clean up (#1187)
Browse files Browse the repository at this point in the history
* Update Zynq Ultrascale port for V4.x

This is basically a merge of the previous port, the Zynq7000 port and
the port suggested by Pete Bone <[email protected]>.

* Use MAC hash table for IPv4 LLMNR

This is how it is supposed to be used.
Also the set of the multi-cast hash enable bit was missing.

* Use XEmacPs_DMABLengthUpdate() API

The same effect can be achieved but the code is simpler.

* Remove Zynq7000 support from Ultrascale port

There are already a lot of differences between Zynq and
xilinx_ultrascale port, so there is no need to keep compatibility.

* Add x_emac_map to xilinx_ultrascale port

This map makes sure the correct interrupt id is registered in the
interrupt controller.
E.g. 'XPAR_XEMACPS_0_BASEADDR' is Canonical for the first interface
and can be mapped to any of the GEMs. 'XPAR_XEMACPS_0_INTR' on the
other hand is fixed to GEM0. This is why this mapping is needed.

* Add Micrel PHY support to xilinx_ultrascale port

Authored-by:  Pete Bone  <[email protected] >

* Fix Zynq7000 EMAC MAC address setup

Set solicited-node addresses independent of LLMNR.
For mDNS set IPv4/6 MAC depending on ipconfigUSE_IPv6.

* Uncrustify

* Fix CI spelling errors

* Fix IPv4/6 preprocessor logic in Zynq/Ultrascale port

* Add missing return in xilinx_ultrascale/NetworkInterface.c

Co-authored-by: ActoryOu <[email protected]>

---------

Co-authored-by: Tony Josi <[email protected]>
Co-authored-by: ActoryOu <[email protected]>
  • Loading branch information
3 people authored Oct 3, 2024
1 parent 7c8f339 commit dd88502
Show file tree
Hide file tree
Showing 11 changed files with 959 additions and 398 deletions.
2 changes: 2 additions & 0 deletions .github/.cSpellWords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ DIVIDEBY
DIVIDEDBY
DLPSTATE
DMAARBITRATION
DMAB
DMABD
DMABMR
DMAC
Expand Down Expand Up @@ -1562,6 +1563,7 @@ x
xaxiemacif
XCOL
xemac
XEMACMAP
xemacps
XEMACPS
xemacpsp
Expand Down
88 changes: 54 additions & 34 deletions source/portable/NetworkInterface/Zynq/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,42 +254,56 @@ static BaseType_t xZynqNetworkInterfaceInitialise( NetworkInterface_t * pxInterf
/* Initialize the mac and set the MAC address at position 1. */
XEmacPs_SetMacAddress( pxEMAC_PS, ( void * ) pxEndPoint->xMACAddress.ucBytes, 1 );

#if ( ipconfigUSE_LLMNR == 1 )
#if ( ipconfigIS_ENABLED( ipconfigUSE_LLMNR ) )
{
/* Also add LLMNR multicast MAC address. */
#if ( ipconfigUSE_IPv6 == 0 )
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) )
{
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddress.ucBytes );
}
#else
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) */

#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) )
{
NetworkEndPoint_t * pxEndPoint;
NetworkInterface_t * pxInterface = pxMyInterfaces[ xEMACIndex ];
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddressIPv6.ucBytes );
}
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) ) */
}
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_LLMNR ) ) */

for( pxEndPoint = FreeRTOS_FirstEndPoint( pxInterface );
pxEndPoint != NULL;
pxEndPoint = FreeRTOS_NextEndPoint( pxInterface, pxEndPoint ) )
{
if( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED )
{
unsigned char ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 };
ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ];
ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ];
ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ];
XEmacPs_SetHash( pxEMAC_PS, ( void * ) ucMACAddress );
}
}
#if ( ipconfigIS_ENABLED( ipconfigUSE_MDNS ) )
{
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) )
{
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddress.ucBytes );
}
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) */

XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddressIPv6.ucBytes );
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) )
{
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddressIPv6.ucBytes );
}
#endif /* if ( ipconfigUSE_IPv6 == 0 ) */
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) ) */
}
#endif /* ipconfigUSE_LLMNR == 1 */
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_MDNS) ) */

#if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) )
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddress.ucBytes );
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddressIPv6.ucBytes );
#endif
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) )
{
/* set the solicited-node multicast address */
for( NetworkEndPoint_t * pxEndPointIter = FreeRTOS_FirstEndPoint( pxInterface );
pxEndPointIter != NULL;
pxEndPointIter = FreeRTOS_NextEndPoint( pxInterface, pxEndPointIter ) )
{
if( pxEndPointIter->bits.bIPv6 != pdFALSE_UNSIGNED )
{
unsigned char ucSsolicitedNodeMAC[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 };
ucSsolicitedNodeMAC[ 3 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 13 ];
ucSsolicitedNodeMAC[ 4 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 14 ];
ucSsolicitedNodeMAC[ 5 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 15 ];
XEmacPs_SetHash( pxEMAC_PS, ( void * ) ucSsolicitedNodeMAC );
}
}
}
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) ) */

pxEndPoint = FreeRTOS_NextEndPoint( pxInterface, pxEndPoint );

Expand Down Expand Up @@ -378,7 +392,8 @@ static BaseType_t xZynqNetworkInterfaceOutput( NetworkInterface_t * pxInterface,
* the protocol checksum to have a value of zero. */
pxPacket = ( ProtocolPacket_t * ) ( pxBuffer->pucEthernetBuffer );

#if ( ipconfigUSE_IPv6 != 0 )
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) )
{
ICMPPacket_IPv6_t * pxICMPPacket = ( ICMPPacket_IPv6_t * ) pxBuffer->pucEthernetBuffer;

if( ( pxPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv6_FRAME_TYPE ) &&
Expand All @@ -389,16 +404,21 @@ static BaseType_t xZynqNetworkInterfaceOutput( NetworkInterface_t * pxInterface,
* so for ICMP and other protocols it must be done manually. */
usGenerateProtocolChecksum( pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength, pdTRUE );
}
#endif
}
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) ) */

if( ( pxPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) &&
( pxPacket->xICMPPacket.xIPHeader.ucProtocol == ipPROTOCOL_ICMP ) )
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) )
{
/* The EMAC will calculate the checksum of the IP-header.
* It can only calculate protocol checksums of UDP and TCP,
* so for ICMP and other protocols it must be done manually. */
usGenerateProtocolChecksum( pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength, pdTRUE );
if( ( pxPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) &&
( pxPacket->xICMPPacket.xIPHeader.ucProtocol == ipPROTOCOL_ICMP ) )
{
/* The EMAC will calculate the checksum of the IP-header.
* It can only calculate protocol checksums of UDP and TCP,
* so for ICMP and other protocols it must be done manually. */
usGenerateProtocolChecksum( pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength, pdTRUE );
}
}
#endif /* ( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) ) */
}
#endif /* ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM */

Expand Down
Loading

0 comments on commit dd88502

Please sign in to comment.