From 5fc4a183478209faddd87a7b7eb37ba6efd524a7 Mon Sep 17 00:00:00 2001 From: Archit Gupta Date: Thu, 21 Sep 2023 15:52:29 -0700 Subject: [PATCH 1/3] Fix uninitialized variable in TM4C NetworkInterface.c --- .../portable/NetworkInterface/TM4C/NetworkInterface.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/portable/NetworkInterface/TM4C/NetworkInterface.c b/source/portable/NetworkInterface/TM4C/NetworkInterface.c index 9289e8a9a2..9613a89ac5 100644 --- a/source/portable/NetworkInterface/TM4C/NetworkInterface.c +++ b/source/portable/NetworkInterface/TM4C/NetworkInterface.c @@ -57,8 +57,8 @@ #include "NetworkInterface.h" #include "phyHandling.h" -#define BUFFER_SIZE ( ipTOTAL_ETHERNET_FRAME_SIZE + ipBUFFER_PADDING ) -#define BUFFER_SIZE_ROUNDED_UP ( ( BUFFER_SIZE + 7 ) & ~0x7UL ) +#define BUFFER_SIZE ( ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER + ipBUFFER_PADDING ) +#define BUFFER_SIZE_ROUNDED_UP ( ( BUFFER_SIZE + 7 ) & ~0x7UL ) #define PHY_PHYS_ADDR 0 #ifndef niEMAC_SYSCONFIG_HZ @@ -446,7 +446,7 @@ static BaseType_t _ethernet_mac_get( uint8_t * mac_address_bytes ) static void _dma_descriptors_init( void ) { uint32_t i; - size_t buffer_size_requested; + const size_t buffer_size_requested = ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER; NetworkBufferDescriptor_t * stack_descriptor; /* Initialize the TX DMA descriptors */ @@ -592,6 +592,7 @@ static BaseType_t _process_received_packet( void ) IPStackEvent_t event; BaseType_t result = pdTRUE; const TickType_t max_block_time = pdMS_TO_MIN_TICKS( 50 ); + const size_t buffer_size_requested = ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER; /* Go through the list of RX DMA descriptors */ for( i = 0; i < niEMAC_RX_DMA_DESC_COUNT; i++ ) @@ -665,7 +666,8 @@ static BaseType_t _process_received_packet( void ) } /* end if frame had error. In this case, give the buffer back to the DMA for the next RX */ /* Set up the DMA descriptor for the next receive transaction */ - dma_descriptor->ui32Count = DES1_RX_CTRL_CHAINED | ipTOTAL_ETHERNET_FRAME_SIZE; + dma_descriptor->ui32Count = DES1_RX_CTRL_CHAINED | ( ( buffer_size_requested << DES1_RX_CTRL_BUFF1_SIZE_S ) & DES1_RX_CTRL_BUFF1_SIZE_M ); + dma_descriptor->ui32CtrlStatus = DES0_RX_CTRL_OWN; _rx_descriptor_list.write++; From 86a82d53f5cba839159079ad0731c9b39f456338 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 22 Sep 2023 06:13:44 +0000 Subject: [PATCH 2/3] Uncrustify: triggered by comment. --- source/portable/NetworkInterface/TM4C/NetworkInterface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/portable/NetworkInterface/TM4C/NetworkInterface.c b/source/portable/NetworkInterface/TM4C/NetworkInterface.c index 9613a89ac5..70093feab8 100644 --- a/source/portable/NetworkInterface/TM4C/NetworkInterface.c +++ b/source/portable/NetworkInterface/TM4C/NetworkInterface.c @@ -57,8 +57,8 @@ #include "NetworkInterface.h" #include "phyHandling.h" -#define BUFFER_SIZE ( ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER + ipBUFFER_PADDING ) -#define BUFFER_SIZE_ROUNDED_UP ( ( BUFFER_SIZE + 7 ) & ~0x7UL ) +#define BUFFER_SIZE ( ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER + ipBUFFER_PADDING ) +#define BUFFER_SIZE_ROUNDED_UP ( ( BUFFER_SIZE + 7 ) & ~0x7UL ) #define PHY_PHYS_ADDR 0 #ifndef niEMAC_SYSCONFIG_HZ From 5f2fb1fed78a92efc2af4f63b19a36d173ef2b08 Mon Sep 17 00:00:00 2001 From: Monika Singh Date: Tue, 26 Sep 2023 05:08:25 +0000 Subject: [PATCH 3/3] Update macro --- source/portable/NetworkInterface/TM4C/NetworkInterface.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/portable/NetworkInterface/TM4C/NetworkInterface.c b/source/portable/NetworkInterface/TM4C/NetworkInterface.c index 70093feab8..5a5a4f1cd3 100644 --- a/source/portable/NetworkInterface/TM4C/NetworkInterface.c +++ b/source/portable/NetworkInterface/TM4C/NetworkInterface.c @@ -57,7 +57,8 @@ #include "NetworkInterface.h" #include "phyHandling.h" -#define BUFFER_SIZE ( ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER + ipBUFFER_PADDING ) +#define BUFFER_SIZE_WO_PADDING ( ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER ) +#define BUFFER_SIZE ( BUFFER_SIZE_WO_PADDING + ipBUFFER_PADDING ) #define BUFFER_SIZE_ROUNDED_UP ( ( BUFFER_SIZE + 7 ) & ~0x7UL ) #define PHY_PHYS_ADDR 0 @@ -446,7 +447,7 @@ static BaseType_t _ethernet_mac_get( uint8_t * mac_address_bytes ) static void _dma_descriptors_init( void ) { uint32_t i; - const size_t buffer_size_requested = ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER; + const size_t buffer_size_requested = BUFFER_SIZE_WO_PADDING; NetworkBufferDescriptor_t * stack_descriptor; /* Initialize the TX DMA descriptors */ @@ -592,7 +593,7 @@ static BaseType_t _process_received_packet( void ) IPStackEvent_t event; BaseType_t result = pdTRUE; const TickType_t max_block_time = pdMS_TO_MIN_TICKS( 50 ); - const size_t buffer_size_requested = ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER; + const size_t buffer_size_requested = BUFFER_SIZE_WO_PADDING; /* Go through the list of RX DMA descriptors */ for( i = 0; i < niEMAC_RX_DMA_DESC_COUNT; i++ )