-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Zynq Ultrascale port for V4.x and Clean up #1187
Conversation
XEmacPs_SetOptions( pxEMAC_PS, XEMACPS_MULTICAST_OPTION ); | ||
#endif /* ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) */ | ||
|
||
/* In the Zynq7000 port the MAC-Address is stored on second endpoint here at position 4. Needed? */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the comment Zynq7000 does this here:
pxEndPoint = FreeRTOS_NextEndPoint( pxInterface, pxEndPoint );
if( pxEndPoint != NULL )
{
/* If there is a second end-point, store the MAC
* address at position 4.*/
XEmacPs_SetMacAddress( pxEMAC_PS, ( void * ) pxEndPoint->xMACAddress.ucBytes, 4 );
}
Do we also need this here?
source/portable/NetworkInterface/xilinx_ultrascale/NetworkInterface.c
Outdated
Show resolved
Hide resolved
source/portable/NetworkInterface/xilinx_ultrascale/NetworkInterface.c
Outdated
Show resolved
Hide resolved
source/portable/NetworkInterface/xilinx_ultrascale/NetworkInterface.c
Outdated
Show resolved
Hide resolved
@@ -173,7 +181,7 @@ static void emacps_handle_error( void * arg, | |||
if( ( ErrorWord & XEMACPS_RXSR_HRESPNOK_MASK ) != 0 ) | |||
{ | |||
last_err_msg = "Receive DMA error"; | |||
xNetworkInterfaceInitialise(); | |||
vInitialiseOnIndex( xEMACIndex ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure whether these are any good as vInitialiseOnIndex()
cannot be run again when it once ended up in xEMAC_Fatal
or xEMAC_Ready
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @StefanBalt, that is great work! Until now the UltraScale driver would only work with the older single-interface version. You made it standard and compliant with 4.x.x.
In a later stage, I will also test it in hardware.
pxEndPoint = FreeRTOS_NextEndPoint( pxInterface, pxEndPoint );
if( pxEndPoint != NULL )
{
/* If there is a second end-point, store the MAC
* address at position 4.*/
XEmacPs_SetMacAddress( pxEMAC_PS, ( void * ) pxEndPoint->xMACAddress.ucBytes, 4 );
}
You wrote:
Do we also need this here?
It needs to be worked out.
We can have multiple interfaces each with multiple endpoints, long with different MAC-addresses.
The peripheral has space for 4 primary MAC-addresses. All other addresses will be set in the hash table.
I wish that PR 1019 were already approved and merged. That will contain a method of setting the MAC-addresses in a proper way.
#if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) )
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddress.ucBytes ); /* why for IPv6? */
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MACAddressIPv6.ucBytes );
Why only add MDNS multicast MAC to hash table when ( ipconfigUSE_IPv6 != 0 )?
You are right, that is not correct.
Also setting the "Solicited-Node Multicast" addresses { 0x33, 0x33, 0xff, 0, 0, 0 };
only depends on ipconfigUSE_IPv6
and not on ipconfigUSE_LLMNR
.
/* allow reception of multicast addresses programmed into hash */
XEmacPs_SetOptions( pxEMAC_PS, XEMACPS_MULTICAST_OPTION );
These are also missing in the Zynq7000 port and most likely needed.
Should I add it?
I think so. The XEMACPS_MULTICAST_OPTION
refers to XEMACPS_NWCFG_MCASTHASHEN_MASK
, or MCAST (multicast) HASH (hash) EN (enable). That is indeed important.
/* Allow multicast address filtering */
if( ( Options & XEMACPS_MULTICAST_OPTION ) != 0x00000000U )
{
RegNewNetCfg |= XEMACPS_NWCFG_MCASTHASHEN_MASK;
}
But I cannot test it.
By enabling and playing with mDNS?
Is it really necessary to add ucMACAddress to all endpoints?
The global ucMACAddress
doesn't exists since release 4.x.
I would have thought XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddressIPv6.ucBytes ); would be sufficient.
I think so too.
Every Ethernet peripheral, or most of them, has two ways of setting a MAC-address:
Hash: when you add a MAC address whose calculated hash value is 12, then bit 12 in the hash table will get set. ( no news for most of you ). Emil Popov and me came up with this idea:
The first 4 ( MAC-addresses can be unhashed too: there will be 64 usage counters. When the counter reaches zero again, the hash value will be cleared. For the Ultrascale port, I am thinking of using the same method. |
This is basically a merge of the previous port, the Zynq7000 port and the port suggested by Pete Bone <[email protected]>.
This is how it is supposed to be used. Also the set of the multi-cast hash enable bit was missing.
The same effect can be achieved but the code is simpler.
There are already a lot of differences between Zynq and xilinx_ultrascale port, so there is no need to keep compatibility.
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.
Authored-by: Pete Bone <[email protected] >
Set solicited-node addresses independent of LLMNR. For mDNS set IPv4/6 MAC depending on ipconfigUSE_IPv6.
Ah youre'right the Zynq7000 port uses I noticed the promiscuous mode in the Zynq7000 port which is somewhat questionable as a default:
I meant I do not have a Zynq7000 at hand. I did test mDNS now for the Ultrascale. I do like the idea of sharing the MAC related code in Common, however I do not have the time to do it at the moment. My testing is complete for now here is what I did and what I think should still be tested:
|
Thanks for taking time to contribute to FreeRTOS+TCP. Can you help in fixing the CI checks:
Please let us know if you have questions or want us to take care of the CI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so far, Stefan for this PR. I don't have the time to test it, I hope you did.
It will still have some work to do, but let's wait for the multi-cast feature first.
XEmacPs_SetHash( pxEMAC_PS, ( void * ) ucMACAddress ); | ||
} | ||
} | ||
|
||
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddressIPv6.ucBytes ); | ||
} | ||
#endif /* if ( ipconfigUSE_IPv6 == 0 ) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above is not correct, think of this:
#if( ipconfigUSE_LLMNR == 1 )
{
#if( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) )
{
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddress.ucBytes );
}
#endif
#if( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) )
{
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddressIPv6.ucBytes );
}
#endif
}
#endif /* ipconfigUSE_LLMNR == 1 */
It means that LLMNR can be enabled for IPv4 and on IPv6 at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah of course IPv4 and v6 can be both enabled. Done
} | ||
#endif /* if ( ipconfigUSE_IPv6 == 0 ) */ | ||
} | ||
#endif /* ( ipconfigUSE_MDNS == 1 ) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and also here:
#if ( ipconfigIS_ENABLED( ipconfigUSE_MDNS ) )
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) )
{
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddress.ucBytes );
}
#endif
#if ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) )
{
XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MACAddressIPv6.ucBytes );
}
#endif
#endif /* ipconfigUSE_MDNS */
MDNS can also be active on both IP-versions.
usGenerateProtocolChecksum( pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength, pdTRUE ); | ||
} | ||
#endif /* ipconfigUSE_IPv6 */ | ||
|
||
if( ( pxPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The driver should not bother about IPv4 frames, unless ipconfigUSE_IPv4
is defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@StefanBalt Please feel free to let us know if you prefer us to make the suggested changes. |
Sure, I will push a fix (probably today). |
As mentioned earlier, I tested some of the features but not all (i.e. IPv6, DHCP and more than one physical interface missing). |
source/portable/NetworkInterface/xilinx_ultrascale/NetworkInterface.c
Outdated
Show resolved
Hide resolved
Co-authored-by: ActoryOu <[email protected]>
Description
This pull request introduces the V4.x port for the Xilinx Ultrascale, which basically merges the previous implementation, the Zynq7000 port and the suggestion by @pete-pjb here #1172
Key Changes:
I will provide inline comments on specific sections where I'm uncertain or need feedback.
Test Steps
I could only test a single interface with IPv4 so far. Junbo Frames and LLMNR also work fine.
I plan to test multiple interfaces on a Kria board I have at my hand soon.
Checklist:
Related Issue
#1172
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.