]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/x_emacpsif_dma.c
Update version number in +TCP code.
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-TCP / portable / NetworkInterface / Zynq / x_emacpsif_dma.c
index 0cec48a90acba8e141feaa9d7e728e5b1736feab..895564ca361ae9dc6804bca237b0a2759f908b68 100644 (file)
@@ -1,39 +1,28 @@
 /*\r
- * FreeRTOS+TCP V2.0.1\r
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
- * this software and associated documentation files (the "Software"), to deal in\r
- * the Software without restriction, including without limitation the rights to\r
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
- * the Software, and to permit persons to whom the Software is furnished to do so,\r
- * subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included in all\r
- * copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- *\r
- * http://www.FreeRTOS.org\r
- * http://aws.amazon.com/freertos\r
- *\r
- * 1 tab == 4 spaces!\r
+FreeRTOS+TCP V2.0.11\r
+Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+this software and associated documentation files (the "Software"), to deal in\r
+the Software without restriction, including without limitation the rights to\r
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+the Software, and to permit persons to whom the Software is furnished to do so,\r
+subject to the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be included in all\r
+copies or substantial portions of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+\r
+ http://aws.amazon.com/freertos\r
+ http://www.FreeRTOS.org\r
  */\r
 \r
-#include "Zynq/x_emacpsif.h"\r
-#include "Zynq/x_topology.h"\r
-#include "xstatus.h"\r
-\r
-#include "xparameters.h"\r
-#include "xparameters_ps.h"\r
-#include "xil_exception.h"\r
-#include "xil_mmu.h"\r
-\r
 #include "FreeRTOS.h"\r
 #include "task.h"\r
 #include "timers.h"\r
 #include "FreeRTOS_IP_Private.h"\r
 #include "NetworkBufferManagement.h"\r
 \r
+#include "Zynq/x_emacpsif.h"\r
+#include "Zynq/x_topology.h"\r
+#include "xstatus.h"\r
+\r
+#include "xparameters.h"\r
+#include "xparameters_ps.h"\r
+#include "xil_exception.h"\r
+#include "xil_mmu.h"\r
+\r
 #include "uncached_memory.h"\r
 \r
 /* Two defines used to set or clear the EMAC interrupt */\r
@@ -203,7 +201,7 @@ BaseType_t xReturn;
 XStatus emacps_send_message(xemacpsif_s *xemacpsif, NetworkBufferDescriptor_t *pxBuffer, int iReleaseAfterSend )\r
 {\r
 int head = xemacpsif->txHead;\r
-int tail = xemacpsif->txTail;\r
+//int tail = xemacpsif->txTail;\r
 int iHasSent = 0;\r
 uint32_t ulBaseAddress = xemacpsif->emacps.Config.BaseAddress;\r
 TickType_t xBlockTimeTicks = pdMS_TO_TICKS( 5000u );\r
@@ -315,10 +313,7 @@ void emacps_recv_handler(void *arg)
        portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
 }\r
 \r
-static NetworkBufferDescriptor_t *ethMsg = NULL;\r
-static NetworkBufferDescriptor_t *ethLast = NULL;\r
-\r
-static void passEthMessages( void )\r
+static void passEthMessages( NetworkBufferDescriptor_t *ethMsg )\r
 {\r
 IPStackEvent_t xRxEvent;\r
 \r
@@ -340,20 +335,50 @@ IPStackEvent_t xRxEvent;
                iptraceETHERNET_RX_EVENT_LOST();\r
                FreeRTOS_printf( ( "passEthMessages: Can not queue return packet!\n" ) );\r
        }\r
-\r
-       ethMsg = ethLast = NULL;\r
 }\r
 \r
+TickType_t ack_reception_delay = 10;\r
+\r
 int emacps_check_rx( xemacpsif_s *xemacpsif )\r
 {\r
 NetworkBufferDescriptor_t *pxBuffer, *pxNewBuffer;\r
 int rx_bytes;\r
 volatile int msgCount = 0;\r
 int head = xemacpsif->rxHead;\r
+BaseType_t bHasDataPacket = pdFALSE;\r
+NetworkBufferDescriptor_t *ethMsg = NULL;\r
+NetworkBufferDescriptor_t *ethLast = NULL;\r
 \r
        /* There seems to be an issue (SI# 692601), see comments below. */\r
        resetrx_on_no_rxdata(xemacpsif);\r
 \r
+       {\r
+               static int maxcount = 0;\r
+               int count = 0;\r
+               for( ;; )\r
+               {\r
+                       if( ( ( xemacpsif->rxSegments[ head ].address & XEMACPS_RXBUF_NEW_MASK ) == 0 ) ||\r
+                               ( pxDMA_rx_buffers[ head ] == NULL ) )\r
+                       {\r
+                               break;\r
+                       }\r
+                       count++;\r
+                       if( ++head == ipconfigNIC_N_RX_DESC )\r
+                       {\r
+                               head = 0;\r
+                       }\r
+                       if( head == xemacpsif->rxHead )\r
+                       {\r
+                               break;\r
+                       }\r
+               }\r
+               if (maxcount < count) {\r
+                       maxcount = count;\r
+                       FreeRTOS_printf( ( "emacps_check_rx: %d packets\n", maxcount ) );\r
+               }\r
+               head = xemacpsif->rxHead;\r
+       }\r
+\r
        /* This FreeRTOS+TCP driver shall be compiled with the option\r
        "ipconfigUSE_LINKED_RX_MESSAGES" enabled.  It allows the driver to send a\r
        chain of RX messages within one message to the IP-task. */\r
@@ -386,7 +411,10 @@ int head = xemacpsif->rxHead;
                        rx_bytes = xemacpsif->rxSegments[ head ].flags & XEMACPS_RXBUF_LEN_MASK;\r
 \r
                        pxBuffer->xDataLength = rx_bytes;\r
-\r
+if( rx_bytes > 60 )\r
+{\r
+       bHasDataPacket = 1;\r
+}\r
                        if( ucIsCachedMemory( pxBuffer->pucEthernetBuffer ) != 0 )\r
                        {\r
                                Xil_DCacheInvalidateRange( ( ( uint32_t )pxBuffer->pucEthernetBuffer ) - ipconfigPACKET_FILLER_SIZE, (unsigned)rx_bytes );\r
@@ -423,8 +451,11 @@ int head = xemacpsif->rxHead;
                                        addr |= XEMACPS_RXBUF_WRAP_MASK;\r
                                }\r
                                /* Clearing 'XEMACPS_RXBUF_NEW_MASK'       0x00000001 *< Used bit.. */\r
-                               xemacpsif->rxSegments[ head ].address = addr;\r
                                xemacpsif->rxSegments[ head ].flags = 0;\r
+                               xemacpsif->rxSegments[ head ].address = addr;\r
+                               if (xemacpsif->rxSegments[ head ].address) {\r
+                                       // Just to read it\r
+                               }\r
                        }\r
                }\r
 \r
@@ -437,7 +468,11 @@ int head = xemacpsif->rxHead;
 \r
        if( ethMsg != NULL )\r
        {\r
-               passEthMessages( );\r
+               if( bHasDataPacket == pdFALSE )\r
+               {\r
+//                     vTaskDelay( ack_reception_delay );\r
+               }\r
+               passEthMessages( ethMsg );\r
        }\r
 \r
        return msgCount;\r
@@ -457,9 +492,9 @@ unsigned char *ucTxBuffer;
                xemacpsif->txSegments[ index ].address = ( uint32_t )ucTxBuffer;\r
                xemacpsif->txSegments[ index ].flags = XEMACPS_TXBUF_USED_MASK;\r
 #if( ipconfigZERO_COPY_TX_DRIVER != 0 )\r
-               pxDMA_tx_buffers[ index ] = ( void* )NULL;\r
+               pxDMA_tx_buffers[ index ] = ( unsigned char * )NULL;\r
 #else\r
-               pxDMA_tx_buffers[ index ] = ( void* )( ucTxBuffer + TX_OFFSET );\r
+               pxDMA_tx_buffers[ index ] = ( unsigned char * )( ucTxBuffer + TX_OFFSET );\r
 #endif\r
                ucTxBuffer += xemacpsif->uTxUnitSize;\r
        }\r
@@ -603,6 +638,7 @@ void resetrx_on_no_rxdata(xemacpsif_s *xemacpsif)
        tempcntr = XEmacPs_ReadReg( xemacpsif->emacps.Config.BaseAddress, XEMACPS_RXCNT_OFFSET );\r
        if ( ( tempcntr == 0 ) && ( xemacpsif->last_rx_frms_cntr == 0 ) )\r
        {\r
+FreeRTOS_printf( ( "resetrx_on_no_rxdata: RESET~\n" ) );\r
                regctrl = XEmacPs_ReadReg(xemacpsif->emacps.Config.BaseAddress,\r
                                XEMACPS_NWCTRL_OFFSET);\r
                regctrl &= (~XEMACPS_NWCTRL_RXEN_MASK);\r