Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Skptak authored Aug 29, 2023
2 parents 4ebf739 + 34148c3 commit c0780ba
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 43 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ set(FREERTOS_PLUS_TCP_NETWORK_IF_LIST
DRIVER_SAM
ESP32
KSZ8851SNL
LIBSLIRP
LPC17xx LPC18xx LPC54018
M487
MPS2_AN385
Expand Down Expand Up @@ -96,6 +97,7 @@ if(NOT FREERTOS_PLUS_TCP_NETWORK_IF IN_LIST FREERTOS_PLUS_TCP_NETWORK_IF_LIST )
" DRIVER_SAM Target: Driver SAM Tested: TODO\n"
" ESP32 Target: ESP-32 Tested: TODO\n"
" KSZ8851SNL Target: ksz8851snl Tested: TODO\n"
" LIBSLIRP Target: libslirp Tested: TODO\n"
" POSIX Target: linux/Posix\n"
" LPC17xx Target: LPC17xx Tested: TODO\n"
" LPC18xx Target: LPC18xx Tested: TODO\n"
Expand Down
18 changes: 8 additions & 10 deletions source/portable/NetworkInterface/DriverSAM/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,19 +728,19 @@ static BaseType_t prvGMACInit( NetworkInterface_t * pxInterface )
GMAC->GMAC_NCR |= GMAC_NCR_MPE;

memset( &gmac_option, '\0', sizeof( gmac_option ) );
gmac_option.uc_copy_all_frame = 0;
gmac_option.uc_no_boardcast = 0;
memcpy( gmac_option.uc_mac_addr,
pxEndPoint->xMACAddress.ucBytes,
sizeof( gmac_option.uc_mac_addr ) );
/* Note that 'gmac_option.uc_copy_all_frame' is false, do not copy all frames.
* And 'gmac_option.uc_no_boardcast' is false, meaning that broadcast is received.
* 'boardcast' is a typo. */
memcpy( gmac_option.uc_mac_addr, pxEndPoint->xMACAddress.ucBytes, sizeof( gmac_option.uc_mac_addr ) );

gs_gmac_dev.p_hw = GMAC;
gmac_dev_init( GMAC, &gs_gmac_dev, &gmac_option );

NVIC_SetPriority( GMAC_IRQn, configMAC_INTERRUPT_PRIORITY );
NVIC_EnableIRQ( GMAC_IRQn );

/* Clear the hash table for multicast MAC addresses. */
/* Clear the hash table for multicast MAC addresses.
* OR set both to ~0H to receive all multicast packets. */
GMAC->GMAC_HRB = 0U; /* Hash Register Bottom. */
GMAC->GMAC_HRT = 0U; /* Hash Register Top. */

Expand Down Expand Up @@ -1097,8 +1097,8 @@ static uint32_t prvEMACRxPoll( void )

if( xSendEventStructToIPTask( &xRxEvent, xBlockTime ) != pdTRUE )
{
/* xSendEventStructToIPTask() timed out. Release the descriptor.
*/
/* xSendEventStructToIPTask() timed out. Release the descriptor. */
FreeRTOS_printf( ( "prvEMACRxPoll: Can not queue a packet!\n" ) );
xRelease = pdTRUE;
}
}
Expand All @@ -1110,8 +1110,6 @@ static uint32_t prvEMACRxPoll( void )
* again. */
vReleaseNetworkBufferAndDescriptor( pxNextNetworkBufferDescriptor );
iptraceETHERNET_RX_EVENT_LOST();
FreeRTOS_printf(
( "prvEMACRxPoll: Can not queue return packet!\n" ) );
}

/* Now the buffer has either been passed to the IP-task,
Expand Down
39 changes: 23 additions & 16 deletions source/portable/NetworkInterface/DriverSAM/gmac_SAM.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,31 +641,40 @@ uint32_t gmac_dev_read( gmac_device_t * p_gmac_dev,
return GMAC_RX_NO_DATA;
}

/* Return the number of bytes received. */
*p_rcv_size = bytesLeft;

/* gmac_dev_poll has confirmed that there is a complete frame at
* the current position 'ul_rx_idx'
*/
nextIdx = p_gmac_dev->ul_rx_idx;

/* Read +2 bytes because buffers are aligned at -2 bytes */
bytesLeft = min( bytesLeft + 2, ( int32_t ) ul_frame_size );

#if( NETWORK_BUFFERS_CACHED != 0 ) && ( __DCACHE_PRESENT != 0 ) && \
defined( CONF_BOARD_ENABLE_CACHE )
SCB_InvalidateDCache();
#endif

#if ( NETWORK_BUFFERS_CACHED != 0 ) && ( __DCACHE_PRESENT != 0 ) && defined( CONF_BOARD_ENABLE_CACHE )
SCB_InvalidateDCache();
#endif

#if( ipconfigZERO_COPY_RX_DRIVER == 0 )
{
/* The frame will be copied in 1 or 2 memcpy's */
if( ( p_frame != NULL ) && ( bytesLeft != 0 ) )
{
const uint8_t * source;
int32_t left;
int32_t toCopy;
/* The frame will be copied in 1 or 2 memcpy's */
if( p_frame != NULL )
{
const uint8_t * source;
int32_t left;
int32_t toCopy;

source = gs_uc_rx_buffer + nextIdx * GMAC_RX_UNITSIZE;

/* The driver receives frames up to 1514 bytes long.
* The actual value of ul_frame_size is 1536, so the
* following test is not really necessary:
*/

source = gs_uc_rx_buffer + nextIdx * GMAC_RX_UNITSIZE;
left = bytesLeft;
toCopy = ( GMAC_RX_BUFFERS - nextIdx ) * GMAC_RX_UNITSIZE;
/* Read +2 bytes because buffers are aligned at -2 bytes */
left = min( bytesLeft + 2, ( int32_t ) ul_frame_size );
toCopy = ( GMAC_RX_BUFFERS - nextIdx ) * GMAC_RX_UNITSIZE;

if( toCopy > left )
{
Expand Down Expand Up @@ -717,8 +726,6 @@ uint32_t gmac_dev_read( gmac_device_t * p_gmac_dev,

p_gmac_dev->ul_rx_idx = nextIdx;

*p_rcv_size = bytesLeft;

return GMAC_OK;
}

Expand Down
29 changes: 12 additions & 17 deletions source/portable/NetworkInterface/NXP1060/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ static BaseType_t prvNXP1060_NetworkInterfaceInitialise(

if( xStatus != kStatus_Success )
{
if( !xFirstCall )
{
xTaskNotify( receiveTaskHandle, DRIVER_READY, eSetValueWithOverwrite );
}

break;
}
else
Expand All @@ -404,7 +409,7 @@ static BaseType_t prvNXP1060_NetworkInterfaceInitialise(
xTaskCreated = xTaskCreate( prvEMACHandlerTask,
"EMAC-Handler",
configMINIMAL_STACK_SIZE * 3,
NULL,
pxInterface,
configMAX_PRIORITIES - 1,
&receiveTaskHandle );

Expand Down Expand Up @@ -545,10 +550,7 @@ static void prvEMACHandlerTask( void * parameter )
if( ulTaskNotifyTake( pdTRUE, pdMS_TO_TICKS( 500 ) ) == pdFALSE )
{
/* No RX packets for a bit so check for a link. */
const IPStackEvent_t xNetworkEventDown = {
.eEventType = eNetworkDownEvent,
.pvData = NULL
};
const IPStackEvent_t xNetworkEventDown = { .eEventType = eNetworkDownEvent, .pvData = parameter };

do
{
Expand Down Expand Up @@ -616,21 +618,14 @@ static void prvEMACHandlerTask( void * parameter )
receiving = pdFALSE;
break;

case kStatus_ENET_RxFrameError: /* Received an error frame.
Read & drop it */
PRINTF( "RX Receive Error\n" );
ENET_ReadFrame( ethernetifLocal->base,
&( ethernetifLocal->handle ),
NULL,
0,
0,
NULL );
/* Not sure if a trace is required. The MAC had an
* error and needed to dump bytes */
case kStatus_ENET_RxFrameError: /* Received an error frame. Read & drop it */
FreeRTOS_printf( ( "RX Receive Error\n" ) );
ENET_ReadFrame( ethernetifLocal->base, &( ethernetifLocal->handle ), NULL, 0, 0, NULL );
/* Not sure if a trace is required. The MAC had an error and needed to dump bytes */
break;

default:
PRINTF( "RX Receive default" );
FreeRTOS_printf( ( "RX Receive default" ) );
break;
}
}
Expand Down

0 comments on commit c0780ba

Please sign in to comment.