Skip to content
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 STM32Hxx port to use HW MAC hashtable filter #970

Merged
merged 26 commits into from
Oct 12, 2023
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
47610b8
fix
tony-josi-aws Jul 13, 2023
e3f4288
MAC filter updated for DAD and IPv6 all nodes multicast
tony-josi-aws Jul 13, 2023
6a66c11
add more comments
tony-josi-aws Jul 14, 2023
e020d04
fix formatting
tony-josi-aws Jul 14, 2023
221472e
fix comments
tony-josi-aws Jul 14, 2023
c463e55
fix review comments
tony-josi-aws Jul 14, 2023
38c2135
fix formatting
tony-josi-aws Jul 14, 2023
7721d8d
update review comments
tony-josi-aws Jul 14, 2023
596ccb4
Merge branch 'main' into stm32h_build_fix
tony-josi-aws Jul 14, 2023
061765f
enable multicast packets in MAC
tony-josi-aws Jul 15, 2023
38fe1a0
use multi cast MAC filter
tony-josi-aws Jul 16, 2023
5ef2ebf
fix formatting
tony-josi-aws Jul 16, 2023
3901d06
Merge branch 'main' of github.com:FreeRTOS/FreeRTOS-Plus-TCP into stm…
tony-josi-aws Jul 16, 2023
78730b2
update naming and comments
tony-josi-aws Jul 17, 2023
5527097
update comments and formatting
tony-josi-aws Jul 17, 2023
2cdab6e
rename function
tony-josi-aws Jul 17, 2023
5e92042
fix formatting
tony-josi-aws Jul 17, 2023
dd05299
Merge branch 'main' into stm32h_build_fix
tony-josi-aws Aug 9, 2023
94caa57
Merge branch 'main' of github.com:FreeRTOS/FreeRTOS-Plus-TCP into stm…
tony-josi-aws Sep 7, 2023
5d94945
fix spell check
tony-josi-aws Sep 7, 2023
3f875b4
Uncrustify: triggered by comment
actions-user Sep 7, 2023
17a6b37
Merge branch 'main' into stm32h_build_fix
tony-josi-aws Sep 10, 2023
fb1787d
Merge branch 'main' into stm32h_build_fix
tony-josi-aws Sep 19, 2023
806073a
Merge branch 'main' into stm32h_build_fix
tony-josi-aws Oct 4, 2023
4430896
Merge branch 'main' into stm32h_build_fix
tony-josi-aws Oct 10, 2023
9f40349
Merge branch 'main' into stm32h_build_fix
tony-josi-aws Oct 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 96 additions & 99 deletions source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,15 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt
xTxConfig.Attributes = ETH_TX_PACKETS_FEATURES_CRCPAD;

#if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 )
{
/*xTxConfig.ChecksumCtrl = ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC; */
xTxConfig.Attributes |= ETH_TX_PACKETS_FEATURES_CSUM;
xTxConfig.ChecksumCtrl = ETH_DMATXNDESCRF_CIC_IPHDR_PAYLOAD_INSERT_PHDR_CALC;
}
{
/*xTxConfig.ChecksumCtrl = ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC; */
xTxConfig.Attributes |= ETH_TX_PACKETS_FEATURES_CSUM;
xTxConfig.ChecksumCtrl = ETH_DMATXNDESCRF_CIC_IPHDR_PAYLOAD_INSERT_PHDR_CALC;
}
#else
{
xTxConfig.ChecksumCtrl = ETH_CHECKSUM_DISABLE;
}
{
xTxConfig.ChecksumCtrl = ETH_CHECKSUM_DISABLE;
}
#endif
xTxConfig.CRCPadCtrl = ETH_CRC_PAD_INSERT;

Expand All @@ -389,14 +389,14 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt
uint8_t * pucBuffer;

#if ( ipconfigZERO_COPY_RX_DRIVER != 0 )
{
pucBuffer = pucGetRXBuffer( ETH_RX_BUF_SIZE );
configASSERT( pucBuffer != NULL );
}
{
pucBuffer = pucGetRXBuffer( ETH_RX_BUF_SIZE );
configASSERT( pucBuffer != NULL );
}
#else
{
pucBuffer = Rx_Buff[ uxIndex ];
}
{
pucBuffer = Rx_Buff[ uxIndex ];
}
#endif

HAL_ETH_DescAssignMemory( &( xEthHandle ), uxIndex, pucBuffer, NULL );
Expand Down Expand Up @@ -467,14 +467,11 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt
}

#if ( ipconfigUSE_IPv6 != 0 )
{
if( xMACEntry <= ( BaseType_t ) ETH_MAC_ADDRESS3 )
{
/* Allow traffic destined to IPv6 all nodes multicast MAC 33:33:00:00:00:01 */
const uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 };
prvSetMAC_HashFilter( &xEthHandle, ucMACAddress );
}
}
#endif /* ( ipconfigUSE_IPv6 != 0 ) */

/* Initialize the MACB and set all PHY properties */
Expand Down Expand Up @@ -622,23 +619,23 @@ static BaseType_t xSTM32H_NetworkInterfaceOutput( NetworkInterface_t * pxInterfa
/* Memory barrier: Make sure that the data written to the packet buffer got written. */
__DSB();

/* Get exclusive access to the TX process.
/* Get exclusive accces to the TX process.
tony-josi-aws marked this conversation as resolved.
Show resolved Hide resolved
* Both the IP-task and the EMAC task will work on the TX process. */
if( xSemaphoreTake( xTransmissionMutex, xBlockTimeTicks ) != pdFAIL )
{
#if ( ipconfigZERO_COPY_TX_DRIVER != 0 )
{
/* Do not release the buffer. */
xReleaseAfterSend = pdFALSE;
}
{
/* Do not release the buffer. */
xReleaseAfterSend = pdFALSE;
}
#else
{
memcpy( pucTXBuffer, pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength );
{
memcpy( pucTXBuffer, pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength );

/* A memory barrier to make sure that the outgoing packets has been written
* to the physical memory. */
__DSB();
}
/* A memory barrier to make sure that the outgoing packets has been written
* to the physical memory. */
__DSB();
}
#endif /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */

if( HAL_ETH_Transmit_IT( &( xEthHandle ), &( xTxConfig ) ) == HAL_OK )
Expand Down Expand Up @@ -729,13 +726,13 @@ static void prvEthernetUpdateConfig( BaseType_t xForce )
MACConf.Speed = speed;
HAL_ETH_SetMACConfig( &( xEthHandle ), &( MACConf ) );
#if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM != 0 )
{
MACConf.ChecksumOffload = ENABLE;
}
{
MACConf.ChecksumOffload = ENABLE;
}
#else
{
MACConf.ChecksumOffload = DISABLE;
}
{
MACConf.ChecksumOffload = DISABLE;
}
#endif /* ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM != 0 ) */

/* Restart MAC interface */
Expand Down Expand Up @@ -773,30 +770,30 @@ static BaseType_t prvNetworkInterfaceInput( void )
xReturn++;

#if ( ipconfigZERO_COPY_RX_DRIVER != 0 )
{
/* Reserve the maximum length for the next reception. */
uxLength = ETH_RX_BUF_SIZE;

if( data_buffer.buffer != NULL )
{
pxReceivedBuffer = pxPacketBuffer_to_NetworkBuffer( data_buffer.buffer );
#if ( ipconfigTCP_IP_SANITY != 0 )
/* Reserve the maximum length for the next reception. */
uxLength = ETH_RX_BUF_SIZE;

if( data_buffer.buffer != NULL )
{
configASSERT( bIsValidNetworkDescriptor( pxReceivedBuffer ) != 0 );
pxReceivedBuffer = pxPacketBuffer_to_NetworkBuffer( data_buffer.buffer );
#if ( ipconfigTCP_IP_SANITY != 0 )
{
configASSERT( bIsValidNetworkDescriptor( pxReceivedBuffer ) != 0 );
}
#endif
}
#endif
}

if( pxReceivedBuffer == NULL )
{
FreeRTOS_printf( ( "Strange: no descriptor received\n" ) );
if( pxReceivedBuffer == NULL )
{
FreeRTOS_printf( ( "Strange: no descriptor received\n" ) );
}
}
}
#else /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */
{
/* Reserve the length of the packet that was just received. */
uxLength = uxDataLength;
}
{
/* Reserve the length of the packet that was just received. */
uxLength = uxDataLength;
}
#endif /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */

pxBufferDescriptor = pxGetNetworkBufferWithDescriptor( uxLength, 0u );
Expand All @@ -809,33 +806,33 @@ static BaseType_t prvNetworkInterfaceInput( void )
}

#if ( ipconfigZERO_COPY_RX_DRIVER != 0 )
{
if( pxBufferDescriptor == NULL )
{
/* Can not receive this packet. Buffer will be re-used. */
pxReceivedBuffer = NULL;
}
else if( pxReceivedBuffer != NULL )
{
pxReceivedBuffer->xDataLength = uxDataLength;
}
else
{
/* Allocating a new buffer failed. */
if( pxBufferDescriptor == NULL )
{
/* Can not receive this packet. Buffer will be re-used. */
pxReceivedBuffer = NULL;
}
else if( pxReceivedBuffer != NULL )
{
pxReceivedBuffer->xDataLength = uxDataLength;
}
else
{
/* Allocating a new buffer failed. */
}
}
}
#else /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */
{
if( pxBufferDescriptor != NULL )
{
pxReceivedBuffer = pxBufferDescriptor;
/* The copy method. */
memcpy( pxReceivedBuffer->pucEthernetBuffer, data_buffer.buffer, uxDataLength );
pxReceivedBuffer->xDataLength = uxDataLength;
/* Make sure that the descriptor isn't used any more. */
pxBufferDescriptor = NULL;
if( pxBufferDescriptor != NULL )
{
pxReceivedBuffer = pxBufferDescriptor;
/* The copy method. */
memcpy( pxReceivedBuffer->pucEthernetBuffer, data_buffer.buffer, uxDataLength );
pxReceivedBuffer->xDataLength = uxDataLength;
/* Make sure that the descriptor isn't used any more. */
pxBufferDescriptor = NULL;
}
}
}
#endif /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */

{
Expand Down Expand Up @@ -1095,36 +1092,36 @@ static void prvEMACHandlerTask( void * pvParameters )
BaseType_t xResult = 0;

#if ( ipconfigHAS_PRINTF != 0 )
{
size_t uxUsed;
size_t uxOwnCount;
{
size_t uxUsed;
size_t uxOwnCount;

/* Call a function that monitors resources: the amount of free network
* buffers and the amount of free space on the heap. See FreeRTOS_IP.c
* for more detailed comments. */
vPrintResourceStats();
/* Call a function that monitors resources: the amount of free network
* buffers and the amount of free space on the heap. See FreeRTOS_IP.c
* for more detailed comments. */
vPrintResourceStats();

/* Some more statistics: number of free descriptors. */
uxUsed = ETH_TX_DESC_CNT - uxSemaphoreGetCount( xTXDescriptorSemaphore );
/* Some more statistics: number of free descriptors. */
uxUsed = ETH_TX_DESC_CNT - uxSemaphoreGetCount( xTXDescriptorSemaphore );

if( uxTXDescriptorsUsed < uxUsed )
{
uxTXDescriptorsUsed = uxUsed;
FreeRTOS_printf( ( "TX descriptors %u/%u\n",
uxTXDescriptorsUsed,
ETH_TX_DESC_CNT ) );
}
if( uxTXDescriptorsUsed < uxUsed )
{
uxTXDescriptorsUsed = uxUsed;
FreeRTOS_printf( ( "TX descriptors %u/%u\n",
uxTXDescriptorsUsed,
ETH_TX_DESC_CNT ) );
}

uxOwnCount = uxGetOwnCount( &( xEthHandle ) );
uxOwnCount = uxGetOwnCount( &( xEthHandle ) );

if( uxRXDescriptorsUsed > uxOwnCount )
{
uxRXDescriptorsUsed = uxOwnCount;
FreeRTOS_printf( ( "RX descriptors %u/%u\n",
uxRXDescriptorsUsed,
ETH_RX_DESC_CNT ) );
if( uxRXDescriptorsUsed > uxOwnCount )
{
uxRXDescriptorsUsed = uxOwnCount;
FreeRTOS_printf( ( "RX descriptors %u/%u\n",
uxRXDescriptorsUsed,
ETH_RX_DESC_CNT ) );
}
}
}
#endif /* ( ipconfigHAS_PRINTF != 0 ) */

ulTaskNotifyTake( pdFALSE, ulMaxBlockTime );
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.