Skip to content

Commit

Permalink
Merge branch 'main' into dev-stm32
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-josi-aws authored Oct 10, 2024
2 parents f737291 + cad1f75 commit adfb1d1
Show file tree
Hide file tree
Showing 30 changed files with 1,127 additions and 474 deletions.
2 changes: 2 additions & 0 deletions .github/.cSpellWords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ DIVIDEBY
DIVIDEDBY
DLPSTATE
DMAARBITRATION
DMAB
DMABD
DMABMR
DMAC
Expand Down Expand Up @@ -1577,6 +1578,7 @@ x
xaxiemacif
XCOL
xemac
XEMACMAP
xemacps
XEMACPS
xemacpsp
Expand Down
2 changes: 1 addition & 1 deletion source/FreeRTOS_ARP.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress,
if( pxEndPoint != NULL )
{
/* For multi-cast, use the first IPv4 end-point. */
memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) );
( void ) memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) );
*( ppxEndPoint ) = pxEndPoint;
eReturn = eARPCacheHit;
}
Expand Down
56 changes: 30 additions & 26 deletions source/FreeRTOS_DNS.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,41 +63,45 @@ const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc }
/** @brief The IPv6 link-scope multicast MAC address */
const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } };

#if ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
/** @brief The IPv6 link-scope multicast address */
const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6 =
{
{ /* ff02::1:3 */
0xff, 0x02,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x01,
0x00, 0x03,
}
};
const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6 =
{
{ /* ff02::1:3 */
0xff, 0x02,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x01,
0x00, 0x03,
}
};
#endif /* ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */

/** @brief The MAC address used for MDNS. */
const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } };

/** @brief The IPv6 multicast DNS MAC address. */
const MACAddress_t xMDNS_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } };

#if ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
/** @brief multicast DNS IPv6 address */
const IPv6_Address_t ipMDNS_IP_ADDR_IPv6 =
{
{ /* ff02::fb */
0xff, 0x02,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0xfb,
}
};
const IPv6_Address_t ipMDNS_IP_ADDR_IPv6 =
{
{ /* ff02::fb */
0xff, 0x02,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0xfb,
}
};
#endif /* ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */

/* Exclude the entire file if DNS is not enabled. */
#if ( ipconfigUSE_DNS != 0 )
Expand Down
4 changes: 2 additions & 2 deletions source/FreeRTOS_IP.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ BaseType_t FreeRTOS_IPInit_Multi( void )
{
static StaticTask_t xIPTaskBuffer;
static StackType_t xIPTaskStack[ ipconfigIP_TASK_STACK_SIZE_WORDS ];
xIPTaskHandle = xTaskCreateStatic( prvIPTask,
xIPTaskHandle = xTaskCreateStatic( &prvIPTask,
"IP-Task",
ipconfigIP_TASK_STACK_SIZE_WORDS,
NULL,
Expand All @@ -997,7 +997,7 @@ BaseType_t FreeRTOS_IPInit_Multi( void )
}
#else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
{
xReturn = xTaskCreate( prvIPTask,
xReturn = xTaskCreate( &prvIPTask,
"IP-task",
ipconfigIP_TASK_STACK_SIZE_WORDS,
NULL,
Expand Down
4 changes: 1 addition & 3 deletions source/FreeRTOS_IPv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,7 @@ enum eFrameProcessingResult prvAllowIPPacketIPv4( const struct xIP_PACKET * cons
( FreeRTOS_FindEndPointOnIP_IPv4( ulDestinationIPAddress ) == NULL ) &&
/* Is it an IPv4 broadcast address x.x.x.255 ? */
( ( FreeRTOS_ntohl( ulDestinationIPAddress ) & 0xffU ) != 0xffU ) &&
( xIsIPv4Multicast( ulDestinationIPAddress ) == pdFALSE ) &&
/* Or (during DHCP negotiation) we have no IP-address yet? */
( FreeRTOS_IsNetworkUp() != pdFALSE ) )
( xIsIPv4Multicast( ulDestinationIPAddress ) == pdFALSE ) )
{
/* Packet is not for this node, release it */
eReturn = eReleaseBuffer;
Expand Down
1 change: 0 additions & 1 deletion source/FreeRTOS_Routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ struct xIPv6_Couple
#endif
{
if( ( ulIPAddress == 0U ) ||
( pxEndPoint->ipv4_settings.ulIPAddress == 0U ) ||
( pxEndPoint->ipv4_settings.ulIPAddress == ulIPAddress ) )
{
break;
Expand Down
32 changes: 20 additions & 12 deletions source/FreeRTOS_TCP_State_Handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@
{
/* Peer is requesting to stop, see if we're really finished. */
xMayClose = pdTRUE;
ulIntermediateResult = ulSequenceNumber + ulReceiveLength - pxTCPWindow->rx.ulCurrentSequenceNumber;
lDistance = ( int32_t ) ulIntermediateResult;

/* Checks are only necessary if we haven't sent a FIN yet. */
if( pxSocket->u.xTCP.bits.bFinSent == pdFALSE_UNSIGNED )
Expand All @@ -601,22 +603,28 @@
( int ) bRxComplete,
( int ) bTxDone ) );
xMayClose = pdFALSE;
}
else
{
ulIntermediateResult = ulSequenceNumber + ulReceiveLength - pxTCPWindow->rx.ulCurrentSequenceNumber;
lDistance = ( int32_t ) ulIntermediateResult;

if( lDistance > 1 )
/* This action is necessary to ensure proper handling of any subsequent packets that
* may arrive after the refused FIN packet. Note that we only update it when the sequence
* of FIN packet is correct. Otherwise, we wait for re-transmission. */
if( lDistance <= 1 )
{
FreeRTOS_debug_printf( ( "Refusing FIN: Rx not complete %d (cur %u high %u)\n",
( int ) lDistance,
( unsigned ) ( pxTCPWindow->rx.ulCurrentSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber ),
( unsigned ) ( pxTCPWindow->rx.ulHighestSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber ) ) );

xMayClose = pdFALSE;
pxTCPWindow->rx.ulCurrentSequenceNumber = pxTCPWindow->rx.ulFINSequenceNumber + 1U;
}
}
else if( lDistance > 1 )
{
FreeRTOS_debug_printf( ( "Refusing FIN: Rx not complete %d (cur %u high %u)\n",
( int ) lDistance,
( unsigned ) ( pxTCPWindow->rx.ulCurrentSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber ),
( unsigned ) ( pxTCPWindow->rx.ulHighestSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber ) ) );

xMayClose = pdFALSE;
}
else
{
/* Empty else marker. */
}
}

if( xTCPWindowLoggingLevel > 0 )
Expand Down
8 changes: 6 additions & 2 deletions source/include/FreeRTOS_DNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ extern const MACAddress_t xLLMNR_MacAddress;
/* The LLMNR IPv6 MAC address is 33:33:00:01:00:03 */
extern const MACAddress_t xLLMNR_MacAddressIPv6;

#if ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
/* The LLMNR IPv6 address is ff02::1:3 */
extern const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6;
extern const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6;
#endif /* ( ( ipconfigUSE_LLMNR != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */

/* The MDNS MAC address is 01:00:5e:00:00:fc */
extern const MACAddress_t xMDNS_MacAddress;
Expand All @@ -61,8 +63,10 @@ extern const MACAddress_t xMDNS_MacAddressIPv6;
/* Guarantee backward compatibility. */
#define xMDNS_MACAddressIPv6 xMDNS_MacAddressIPv6

#if ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
/* The MDNS IPv6 address is ff02::1:3 */
extern const IPv6_Address_t ipMDNS_IP_ADDR_IPv6;
extern const IPv6_Address_t ipMDNS_IP_ADDR_IPv6;
#endif /* ( ( ipconfigUSE_MDNS != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */

/** @brief While doing integration tests, it is necessary to influence the choice
* between DNS/IPv4 and DNS/IPv4. Depending on this, a DNS server will be
Expand Down
10 changes: 6 additions & 4 deletions source/portable/NetworkInterface/ATSAM4E/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
static BaseType_t xGMACWaitLS( TickType_t xMaxTime );

#if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 1 ) && ( ipconfigHAS_TX_CRC_OFFLOADING == 0 )
void vGMACGenerateChecksum( uint8_t * apBuffer );
void vGMACGenerateChecksum( uint8_t * pucBuffer,
size_t uxLength );
#endif

/*
Expand Down Expand Up @@ -405,9 +406,10 @@ static BaseType_t xGMACWaitLS( TickType_t xMaxTime )

/*#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 1 ) && ( ipconfigHAS_TX_CRC_OFFLOADING == 0 ) */

void vGMACGenerateChecksum( uint8_t * apBuffer )
void vGMACGenerateChecksum( uint8_t * pucBuffer,
size_t uxLength )
{
ProtocolPacket_t * xProtPacket = ( ProtocolPacket_t * ) apBuffer;
ProtocolPacket_t * xProtPacket = ( ProtocolPacket_t * ) pucBuffer;

if( xProtPacket->xTCPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE )
{
Expand All @@ -419,7 +421,7 @@ void vGMACGenerateChecksum( uint8_t * apBuffer )
pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum );

/* Calculate the TCP checksum for an outgoing packet. */
usGenerateProtocolChecksum( ( uint8_t * ) apBuffer, pdTRUE );
usGenerateProtocolChecksum( ( uint8_t * ) pucBuffer, uxLength, pdTRUE );
}
}

Expand Down
5 changes: 3 additions & 2 deletions source/portable/NetworkInterface/ATSAM4E/gmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,8 @@ uint32_t gmac_dev_read( gmac_device_t * p_gmac_dev,
}


extern void vGMACGenerateChecksum( uint8_t * apBuffer );
extern void vGMACGenerateChecksum( uint8_t * pucBuffer,
size_t uxLength );

/**
* \brief Send ulLength bytes from pcFrom. This copies the buffer to one of the
Expand Down Expand Up @@ -715,7 +716,7 @@ uint32_t gmac_dev_write( gmac_device_t * p_gmac_dev,
memcpy( ( void * ) p_tx_td->addr, p_buffer, ul_size );
}
#endif /* ipconfigZERO_COPY_TX_DRIVER */
vGMACGenerateChecksum( ( uint8_t * ) p_tx_td->addr );
vGMACGenerateChecksum( ( uint8_t * ) p_tx_td->addr, ( size_t ) ul_size );
}

#if ( GMAC_USES_TX_CALLBACK != 0 )
Expand Down
42 changes: 34 additions & 8 deletions source/portable/NetworkInterface/ATSAME5x/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
static uint8_t ucLLMNR_MAC_address[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC };
#endif

/* Check if the raw Ethernet frame is ICMP */
static BaseType_t isICMP( const NetworkBufferDescriptor_t * pxDescriptor );

/* Receive task refresh time */
#define RECEIVE_BLOCK_TIME_MS 100

Expand Down Expand Up @@ -272,14 +275,41 @@ BaseType_t xATSAM5x_NetworkInterfaceInitialise( NetworkInterface_t * pxInterface
return xATSAM5x_PHYGetLinkStatus( NULL );
}

/* Check if the raw Ethernet frame is ICMP */
static BaseType_t isICMP( const NetworkBufferDescriptor_t * pxDescriptor )
{
BaseType_t xReturn = pdFALSE;

const IPPacket_t * pkt = ( const IPPacket_t * ) pxDescriptor->pucEthernetBuffer;

if( pkt->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE )
{
if( pkt->xIPHeader.ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP )
{
xReturn = pdTRUE;
}
}

#if ipconfigUSE_IPv6 != 0
else if( pkt->xEthernetHeader.usFrameType == ipIPv6_FRAME_TYPE )
{
ICMPPacket_IPv6_t * icmp6 = ( ICMPPacket_IPv6_t * ) pxDescriptor->pucEthernetBuffer;

if( icmp6->xIPHeader.ucNextHeader == ipPROTOCOL_ICMP_IPv6 )
{
xReturn = pdTRUE;
}
}
#endif
return xReturn;
}

static void prvEMACDeferredInterruptHandlerTask( void * pvParameters )
{
NetworkBufferDescriptor_t * pxBufferDescriptor;
size_t xBytesReceived = 0, xBytesRead = 0;

uint16_t xICMPChecksumResult = ipCORRECT_CRC;
const IPPacket_t * pxIPPacket;


/* Used to indicate that xSendEventStructToIPTask() is being called because
Expand Down Expand Up @@ -336,15 +366,13 @@ static void prvEMACDeferredInterruptHandlerTask( void * pvParameters )
{
/* the Atmel SAM GMAC peripheral does not support hardware CRC offloading for ICMP packets.
* It must therefore be implemented in software. */
pxIPPacket = ( IPPacket_t const * ) pxBufferDescriptor->pucEthernetBuffer;

if( pxIPPacket->xIPHeader.ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP )
if( isICMP( pxBufferDescriptor ) == pdTRUE )
{
xICMPChecksumResult = usGenerateProtocolChecksum( pxBufferDescriptor->pucEthernetBuffer, pxBufferDescriptor->xDataLength, pdFALSE );
}
else
{
xICMPChecksumResult = ipCORRECT_CRC; /* Reset the result value in case this is not an ICMP packet. */
xICMPChecksumResult = ipCORRECT_CRC; /* Checksum already verified by GMAC */
}
}
#endif /* if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 1 ) */
Expand Down Expand Up @@ -440,9 +468,7 @@ BaseType_t xATSAM5x_NetworkInterfaceOutput( NetworkInterface_t * pxInterface,
{
/* the Atmel SAM GMAC peripheral does not support hardware CRC offloading for ICMP packets.
* It must therefore be implemented in software. */
const IPPacket_t * pxIPPacket = ( IPPacket_t const * ) pxDescriptor->pucEthernetBuffer;

if( pxIPPacket->xIPHeader.ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP )
if( isICMP( pxDescriptor ) == pdTRUE )
{
( void ) usGenerateProtocolChecksum( pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength, pdTRUE );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static BaseType_t xPHY_Write( BaseType_t xAddress,
uint32_t ulValue );

#if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 1 ) && ( ipconfigHAS_TX_CRC_OFFLOADING == 0 )
void vGMACGenerateChecksum( uint8_t * apBuffer,
void vGMACGenerateChecksum( uint8_t * pucBuffer,
size_t uxLength );
#endif

Expand Down
2 changes: 1 addition & 1 deletion source/portable/NetworkInterface/DriverSAM/gmac_SAM.h
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@

/* The SAM4E has problems offloading checksums for transmission.
* The SAME70 does not set the CRC for ICMP packets (ping). */
extern void vGMACGenerateChecksum( uint8_t * apBuffer,
extern void vGMACGenerateChecksum( uint8_t * pucBuffer,
size_t uxLength );

/*/ @cond 0 */
Expand Down
2 changes: 1 addition & 1 deletion source/portable/NetworkInterface/RX/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of
* this software. By using this software, you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* https://www.renesas.com/en/document/oth/disclaimer8
*
* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion source/portable/NetworkInterface/RX/ether_callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of
* this software. By using this software, you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* https://www.renesas.com/en/document/oth/disclaimer8
*
* Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
Expand Down
Loading

0 comments on commit adfb1d1

Please sign in to comment.