]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Labs/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/Zynq/NetworkInterface.c
Sync FreeRTOS-Labs -CLI -TCP -Trace with the version in FreeRTOS-Plus.
[freertos] / FreeRTOS-Labs / Source / FreeRTOS-Plus-TCP / portable / NetworkInterface / Zynq / NetworkInterface.c
index b13b115714c206ea4fbfce98b591be0fb3b2df67..1c11976cbcec7779ed97ef48964cc7a25bcdd9d9 100644 (file)
@@ -1,27 +1,27 @@
 /*\r
- * FreeRTOS+TCP 191100 experimental\r
- * Copyright (C) 2018 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
+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
 /* Provided memory configured as uncached. */\r
 #include "uncached_memory.h"\r
 \r
-#ifndef niEMAC_HANDLER_TASK_PRIORITY\r
-       #define niEMAC_HANDLER_TASK_PRIORITY    configMAX_PRIORITIES - 1\r
+#ifndef        BMSR_LINK_STATUS\r
+       #define BMSR_LINK_STATUS            0x0004UL\r
 #endif\r
 \r
-#define niBMSR_LINK_STATUS         0x0004UL\r
-\r
 #ifndef        PHY_LS_HIGH_CHECK_TIME_MS\r
        /* Check if the LinkSStatus in the PHY is still high after 15 seconds of not\r
        receiving packets. */\r
@@ -190,7 +188,7 @@ const TickType_t xWaitLinkDelay = pdMS_TO_TICKS( 7000UL ), xWaitRelinkDelay = pd
                possible priority to ensure the interrupt handler can return directly\r
                to it.  The task's handle is stored in xEMACTaskHandle so interrupts can\r
                notify the task when there is something to process. */\r
-               xTaskCreate( prvEMACHandlerTask, "EMAC", configEMAC_TASK_STACK_SIZE, NULL, niEMAC_HANDLER_TASK_PRIORITY, &xEMACTaskHandle );\r
+               xTaskCreate( prvEMACHandlerTask, "EMAC", configEMAC_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xEMACTaskHandle );\r
        }\r
        else\r
        {\r
@@ -208,27 +206,7 @@ const TickType_t xWaitLinkDelay = pdMS_TO_TICKS( 7000UL ), xWaitRelinkDelay = pd
 \r
 BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxBuffer, BaseType_t bReleaseAfterSend )\r
 {\r
-       #if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 )\r
-       {\r
-       ProtocolPacket_t *pxPacket;\r
-\r
-               /* If the peripheral must calculate the checksum, it wants\r
-               the protocol checksum to have a value of zero. */\r
-               pxPacket = ( ProtocolPacket_t * ) ( pxBuffer->pucEthernetBuffer );\r
-               if( pxPacket->xICMPPacket.xIPHeader.ucProtocol == ipPROTOCOL_ICMP )\r
-               {\r
-               IPHeader_t *pxIPHeader = &( pxPacket->xUDPPacket.xIPHeader );\r
-\r
-                       pxPacket->xICMPPacket.xICMPHeader.usChecksum = ( uint16_t )0u;\r
-                       pxIPHeader->usHeaderChecksum = 0u;\r
-                       pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0UL, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ipSIZE_OF_IPv4_HEADER );\r
-                       pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum );\r
-\r
-                       usGenerateProtocolChecksum( (uint8_t*)&( pxPacket->xUDPPacket ), pxBuffer->xDataLength, pdTRUE );\r
-               }\r
-       }\r
-       #endif /* ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM */\r
-       if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) != 0 )\r
+       if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 )\r
        {\r
                iptraceNETWORK_INTERFACE_TRANSMIT();\r
                emacps_send_message( &xEMACpsif, pxBuffer, bReleaseAfterSend );\r
@@ -271,7 +249,7 @@ BaseType_t xReturn;
                }\r
                ulPHYLinkStatus = ulReadMDIO( PHY_REG_01_BMSR );\r
 \r
-               if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) != 0 )\r
+               if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 )\r
                {\r
                        xReturn = pdTRUE;\r
                        break;\r
@@ -303,7 +281,7 @@ BaseType_t xGetPhyLinkStatus( void )
 {\r
 BaseType_t xReturn;\r
 \r
-       if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) == 0 )\r
+       if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) == 0 )\r
        {\r
                xReturn = pdFALSE;\r
        }\r
@@ -320,12 +298,11 @@ static void prvEMACHandlerTask( void *pvParameters )
 {\r
 TimeOut_t xPhyTime;\r
 TickType_t xPhyRemTime;\r
+UBaseType_t uxLastMinBufferCount = 0;\r
 UBaseType_t uxCurrentCount;\r
 BaseType_t xResult = 0;\r
 uint32_t xStatus;\r
 const TickType_t ulMaxBlockTime = pdMS_TO_TICKS( 100UL );\r
-UBaseType_t uxLastMinBufferCount = 0;\r
-UBaseType_t uxCurrentBufferCount = 0;\r
 \r
        /* Remove compiler warnings about unused parameters. */\r
        ( void ) pvParameters;\r
@@ -339,14 +316,14 @@ UBaseType_t uxCurrentBufferCount = 0;
 \r
        for( ;; )\r
        {\r
-               uxCurrentBufferCount = uxGetMinimumFreeNetworkBuffers();\r
-               if( uxLastMinBufferCount != uxCurrentBufferCount )\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 = uxCurrentBufferCount;\r
+                       uxLastMinBufferCount = uxCurrentCount;\r
                        FreeRTOS_printf( ( "Network buffers: %lu lowest %lu\n",\r
-                               uxGetNumberOfFreeNetworkBuffers(), uxCurrentBufferCount ) );\r
+                               uxGetNumberOfFreeNetworkBuffers(), uxCurrentCount ) );\r
                }\r
 \r
                #if( ipconfigCHECK_IP_QUEUE_SPACE != 0 )\r
@@ -395,22 +372,19 @@ UBaseType_t uxCurrentBufferCount = 0;
                        vTaskSetTimeOutState( &xPhyTime );\r
                        xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS );\r
                        xResult = 0;\r
-                       /* Indicate that the Link Status is high, so that\r
-                       xNetworkInterfaceOutput() can send packets. */\r
-                       ulPHYLinkStatus |= niBMSR_LINK_STATUS;\r
                }\r
                else if( xTaskCheckForTimeOut( &xPhyTime, &xPhyRemTime ) != pdFALSE )\r
                {\r
                        xStatus = ulReadMDIO( PHY_REG_01_BMSR );\r
 \r
-                       if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) != ( xStatus & niBMSR_LINK_STATUS ) )\r
+                       if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != ( xStatus & BMSR_LINK_STATUS ) )\r
                        {\r
                                ulPHYLinkStatus = xStatus;\r
-                               FreeRTOS_printf( ( "prvEMACHandlerTask: PHY LS now %d\n", ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) != 0 ) );\r
+                               FreeRTOS_printf( ( "prvEMACHandlerTask: PHY LS now %d\n", ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 ) );\r
                        }\r
 \r
                        vTaskSetTimeOutState( &xPhyTime );\r
-                       if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) != 0 )\r
+                       if( ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0 )\r
                        {\r
                                xPhyRemTime = pdMS_TO_TICKS( PHY_LS_HIGH_CHECK_TIME_MS );\r
                        }\r