]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/ATSAM4E/NetworkInterface.c
Sync FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP with the version in GitHub at (23665258ca...
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-TCP / portable / NetworkInterface / ATSAM4E / NetworkInterface.c
index 4b549b08435cb8b6a0fbcd42ffb25e4b0f00a5af..83c96a07c078c448f34e6d632b0537eeaa342b70 100644 (file)
@@ -1,28 +1,27 @@
 /*\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
+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
 /* Standard includes. */\r
 #include <stdint.h>\r
@@ -83,10 +82,6 @@ expansion. */
        #error Please define GMAC_USES_TX_CALLBACK as 1\r
 #endif\r
 \r
-#if( ipconfigZERO_COPY_RX_DRIVER != 0 )\r
-       #warning The EMAC of SAM4E has fixed-size RX buffers so ZERO_COPY_RX is not possible\r
-#endif\r
-\r
 /* Default the size of the stack used by the EMAC deferred handler task to 4x\r
 the size of the stack used by the idle task - but allow this to be overridden in\r
 FreeRTOSConfig.h as configMINIMAL_STACK_SIZE is a user definable constant. */\r
@@ -239,7 +234,7 @@ const TickType_t x5_Seconds = 5000UL;
                configASSERT( xTXDescriptorSemaphore );\r
        }\r
        /* When returning non-zero, the stack will become active and\r
-       start DHCP (in configured) */\r
+    start DHCP (in configured) */\r
        return ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0;\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -418,11 +413,11 @@ const TickType_t xShortTime = pdMS_TO_TICKS( 100UL );
 \r
                if ( xProtPacket->xTCPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE )\r
                {\r
-                       IPHeader_t *pxIPHeader = &( xProtPacket->xTCPPacket.xIPHeader );\r
+                       IPHeader_t *pxIPHeader = &(xProtPacket->xTCPPacket.xIPHeader);\r
 \r
                        /* Calculate the IP header checksum. */\r
                        pxIPHeader->usHeaderChecksum = 0x00;\r
-                       pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0u, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER );\r
+                       pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER );\r
                        pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum );\r
 \r
                        /* Calculate the TCP checksum for an outgoing packet. */\r
@@ -504,43 +499,15 @@ static IPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL };
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vCheckBuffersAndQueue( void )\r
-{\r
-static UBaseType_t uxLastMinBufferCount = 0;\r
-#if( ipconfigCHECK_IP_QUEUE_SPACE != 0 )\r
-       static UBaseType_t uxLastMinQueueSpace;\r
-#endif\r
-static UBaseType_t uxCurrentCount;\r
-\r
-       #if( ipconfigCHECK_IP_QUEUE_SPACE != 0 )\r
-       {\r
-               uxCurrentCount = uxGetMinimumIPQueueSpace();\r
-               if( uxLastMinQueueSpace != uxCurrentCount )\r
-               {\r
-                       /* The logging produced below may be helpful\r
-                       while tuning +TCP: see how many buffers are in use. */\r
-                       uxLastMinQueueSpace = uxCurrentCount;\r
-                       FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) );\r
-               }\r
-       }\r
-       #endif /* ipconfigCHECK_IP_QUEUE_SPACE */\r
-       uxCurrentCount = uxGetMinimumFreeNetworkBuffers();\r
-       if( uxLastMinBufferCount != uxCurrentCount )\r
-       {\r
-               /* The logging produced below may be helpful\r
-               while tuning +TCP: see how many buffers are in use. */\r
-               uxLastMinBufferCount = uxCurrentCount;\r
-               FreeRTOS_printf( ( "Network buffers: %lu lowest %lu\n",\r
-                       uxGetNumberOfFreeNetworkBuffers(), uxCurrentCount ) );\r
-       }\r
-\r
-}\r
-\r
 static void prvEMACHandlerTask( void *pvParameters )\r
 {\r
 TimeOut_t xPhyTime;\r
 TickType_t xPhyRemTime;\r
-UBaseType_t uxCount;\r
+UBaseType_t uxLastMinBufferCount = 0, uxCount;\r
+UBaseType_t uxCurrentCount;\r
+#if( ipconfigCHECK_IP_QUEUE_SPACE != 0 )\r
+       UBaseType_t uxLastMinQueueSpace;\r
+#endif\r
 #if( ipconfigZERO_COPY_TX_DRIVER != 0 )\r
        NetworkBufferDescriptor_t *pxBuffer;\r
 #endif\r
@@ -559,7 +526,28 @@ const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( EMAC_MAX_BLOCK_TIME_MS );
 \r
        for( ;; )\r
        {\r
-               vCheckBuffersAndQueue();\r
+               uxCurrentCount = uxGetMinimumFreeNetworkBuffers();\r
+               if( uxLastMinBufferCount != uxCurrentCount )\r
+               {\r
+                       /* The logging produced below may be helpful\r
+                       while tuning +TCP: see how many buffers are in use. */\r
+                       uxLastMinBufferCount = uxCurrentCount;\r
+                       FreeRTOS_printf( ( "Network buffers: %lu lowest %lu\n",\r
+                               uxGetNumberOfFreeNetworkBuffers(), uxCurrentCount ) );\r
+               }\r
+\r
+               #if( ipconfigCHECK_IP_QUEUE_SPACE != 0 )\r
+               {\r
+                       uxCurrentCount = uxGetMinimumIPQueueSpace();\r
+                       if( uxLastMinQueueSpace != uxCurrentCount )\r
+                       {\r
+                               /* The logging produced below may be helpful\r
+                               while tuning +TCP: see how many buffers are in use. */\r
+                               uxLastMinQueueSpace = uxCurrentCount;\r
+                               FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) );\r
+                       }\r
+               }\r
+               #endif /* ipconfigCHECK_IP_QUEUE_SPACE */\r
 \r
                if( ( ulISREvents & EMAC_IF_ALL_EVENT ) == 0 )\r
                {\r