X-Git-Url: https://git.sur5r.net/?p=freertos;a=blobdiff_plain;f=FreeRTOS-Plus%2FSource%2FFreeRTOS-Plus-TCP%2Fportable%2FNetworkInterface%2FZynq%2Fx_emacpsif_dma.c;h=895564ca361ae9dc6804bca237b0a2759f908b68;hp=b81841dcfbd70e9ce4f0fd3a1a766d71ccc47822;hb=6b7a5cca0b93511acff5c89a812b28baa75c596a;hpb=42342da982283cded3223403ab6c47ed3dbfb749 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_dma.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_dma.c index b81841dcf..895564ca3 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_dma.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_dma.c @@ -1,5 +1,5 @@ /* -FreeRTOS+TCP V2.0.7 +FreeRTOS+TCP V2.0.11 Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -21,16 +21,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. http://aws.amazon.com/freertos http://www.FreeRTOS.org -*/ - -#include "Zynq/x_emacpsif.h" -#include "Zynq/x_topology.h" -#include "xstatus.h" - -#include "xparameters.h" -#include "xparameters_ps.h" -#include "xil_exception.h" -#include "xil_mmu.h" + */ #include "FreeRTOS.h" #include "task.h" @@ -43,6 +34,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "FreeRTOS_IP_Private.h" #include "NetworkBufferManagement.h" +#include "Zynq/x_emacpsif.h" +#include "Zynq/x_topology.h" +#include "xstatus.h" + +#include "xparameters.h" +#include "xparameters_ps.h" +#include "xil_exception.h" +#include "xil_mmu.h" + #include "uncached_memory.h" /* Two defines used to set or clear the EMAC interrupt */ @@ -201,7 +201,7 @@ BaseType_t xReturn; XStatus emacps_send_message(xemacpsif_s *xemacpsif, NetworkBufferDescriptor_t *pxBuffer, int iReleaseAfterSend ) { int head = xemacpsif->txHead; -int tail = xemacpsif->txTail; +//int tail = xemacpsif->txTail; int iHasSent = 0; uint32_t ulBaseAddress = xemacpsif->emacps.Config.BaseAddress; TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 5000u ); @@ -313,10 +313,7 @@ void emacps_recv_handler(void *arg) portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); } -static NetworkBufferDescriptor_t *ethMsg = NULL; -static NetworkBufferDescriptor_t *ethLast = NULL; - -static void passEthMessages( void ) +static void passEthMessages( NetworkBufferDescriptor_t *ethMsg ) { IPStackEvent_t xRxEvent; @@ -338,20 +335,50 @@ IPStackEvent_t xRxEvent; iptraceETHERNET_RX_EVENT_LOST(); FreeRTOS_printf( ( "passEthMessages: Can not queue return packet!\n" ) ); } - - ethMsg = ethLast = NULL; } +TickType_t ack_reception_delay = 10; + int emacps_check_rx( xemacpsif_s *xemacpsif ) { NetworkBufferDescriptor_t *pxBuffer, *pxNewBuffer; int rx_bytes; volatile int msgCount = 0; int head = xemacpsif->rxHead; +BaseType_t bHasDataPacket = pdFALSE; +NetworkBufferDescriptor_t *ethMsg = NULL; +NetworkBufferDescriptor_t *ethLast = NULL; /* There seems to be an issue (SI# 692601), see comments below. */ resetrx_on_no_rxdata(xemacpsif); + { + static int maxcount = 0; + int count = 0; + for( ;; ) + { + if( ( ( xemacpsif->rxSegments[ head ].address & XEMACPS_RXBUF_NEW_MASK ) == 0 ) || + ( pxDMA_rx_buffers[ head ] == NULL ) ) + { + break; + } + count++; + if( ++head == ipconfigNIC_N_RX_DESC ) + { + head = 0; + } + if( head == xemacpsif->rxHead ) + { + break; + } + } + if (maxcount < count) { + maxcount = count; + FreeRTOS_printf( ( "emacps_check_rx: %d packets\n", maxcount ) ); + } + head = xemacpsif->rxHead; + } + /* This FreeRTOS+TCP driver shall be compiled with the option "ipconfigUSE_LINKED_RX_MESSAGES" enabled. It allows the driver to send a chain of RX messages within one message to the IP-task. */ @@ -384,7 +411,10 @@ int head = xemacpsif->rxHead; rx_bytes = xemacpsif->rxSegments[ head ].flags & XEMACPS_RXBUF_LEN_MASK; pxBuffer->xDataLength = rx_bytes; - +if( rx_bytes > 60 ) +{ + bHasDataPacket = 1; +} if( ucIsCachedMemory( pxBuffer->pucEthernetBuffer ) != 0 ) { Xil_DCacheInvalidateRange( ( ( uint32_t )pxBuffer->pucEthernetBuffer ) - ipconfigPACKET_FILLER_SIZE, (unsigned)rx_bytes ); @@ -421,8 +451,11 @@ int head = xemacpsif->rxHead; addr |= XEMACPS_RXBUF_WRAP_MASK; } /* Clearing 'XEMACPS_RXBUF_NEW_MASK' 0x00000001 *< Used bit.. */ - xemacpsif->rxSegments[ head ].address = addr; xemacpsif->rxSegments[ head ].flags = 0; + xemacpsif->rxSegments[ head ].address = addr; + if (xemacpsif->rxSegments[ head ].address) { + // Just to read it + } } } @@ -435,7 +468,11 @@ int head = xemacpsif->rxHead; if( ethMsg != NULL ) { - passEthMessages( ); + if( bHasDataPacket == pdFALSE ) + { +// vTaskDelay( ack_reception_delay ); + } + passEthMessages( ethMsg ); } return msgCount; @@ -455,9 +492,9 @@ unsigned char *ucTxBuffer; xemacpsif->txSegments[ index ].address = ( uint32_t )ucTxBuffer; xemacpsif->txSegments[ index ].flags = XEMACPS_TXBUF_USED_MASK; #if( ipconfigZERO_COPY_TX_DRIVER != 0 ) - pxDMA_tx_buffers[ index ] = ( void* )NULL; + pxDMA_tx_buffers[ index ] = ( unsigned char * )NULL; #else - pxDMA_tx_buffers[ index ] = ( void* )( ucTxBuffer + TX_OFFSET ); + pxDMA_tx_buffers[ index ] = ( unsigned char * )( ucTxBuffer + TX_OFFSET ); #endif ucTxBuffer += xemacpsif->uTxUnitSize; } @@ -601,6 +638,7 @@ void resetrx_on_no_rxdata(xemacpsif_s *xemacpsif) tempcntr = XEmacPs_ReadReg( xemacpsif->emacps.Config.BaseAddress, XEMACPS_RXCNT_OFFSET ); if ( ( tempcntr == 0 ) && ( xemacpsif->last_rx_frms_cntr == 0 ) ) { +FreeRTOS_printf( ( "resetrx_on_no_rxdata: RESET~\n" ) ); regctrl = XEmacPs_ReadReg(xemacpsif->emacps.Config.BaseAddress, XEMACPS_NWCTRL_OFFSET); regctrl &= (~XEMACPS_NWCTRL_RXEN_MASK);