Skip to content

Commit

Permalink
Increase TX descriptor count
Browse files Browse the repository at this point in the history
  • Loading branch information
VVESTM committed Jul 2, 2019
1 parent a8e14fb commit a0d5988
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions features/netsocket/emac-drivers/TARGET_STM_EMAC/stm32xx_emac.cpp
Expand Up @@ -80,7 +80,7 @@ __ALIGN_BEGIN uint8_t Tx_Buff[ETH_TXBUFNB][ETH_TX_BUF_SIZE] __ALIGN_END; /* Ethe
ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */
#pragma location=0x30040060
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */
#pragma location=0x30040200
#pragma location=0x30040400
uint8_t Rx_Buff[ETH_RX_DESC_CNT][ETH_MAX_PACKET_SIZE]; /* Ethernet Receive Buffers */

#elif defined ( __CC_ARM ) /* MDK ARM Compiler */
Expand Down Expand Up @@ -195,7 +195,7 @@ static void MPU_Config(void)
for ETH DMA descriptors */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x30040000;
MPU_InitStruct.Size = MPU_REGION_SIZE_256B;
MPU_InitStruct.Size = MPU_REGION_SIZE_1KB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
Expand Down Expand Up @@ -466,34 +466,34 @@ bool STM32_EMAC::link_out(emac_mem_buf_t *buf)
bool success = false;
uint32_t i = 0;
uint32_t frameLength = 0;
emac_mem_buf_t *q;
struct pbuf *q;
ETH_BufferTypeDef Txbuffer[ETH_TX_DESC_CNT];
HAL_StatusTypeDef status;
struct pbuf *p = NULL;
p = (struct pbuf *)buf;

/* Get exclusive access */
TXLockMutex.lock();

memset(Txbuffer, 0 , ETH_TX_DESC_CNT*sizeof(ETH_BufferTypeDef));

/* copy frame from pbufs to driver buffers */
for (q = buf; q != NULL; q = memory_manager->get_next(q)) {
for (q = p; q != NULL; q = q->next) {
if (i >= ETH_TX_DESC_CNT) {
printf("Error : ETH_TX_DESC_CNT not sufficient\n");
while(1); // just for debug...
goto error;
}

const uint32_t len = memory_manager->get_total_len(q);
Txbuffer[i].buffer = (uint8_t*)memory_manager->get_ptr(q);
Txbuffer[i].len = len;
frameLength += len;
Txbuffer[i].buffer = (uint8_t *)q->payload;
Txbuffer[i].len = q->len;
frameLength += q->len;

if (i > 0)
{
Txbuffer[i - 1].next = &Txbuffer[i];
}

if (memory_manager->get_next(q) == NULL)
if (q->next == NULL)
{
Txbuffer[i].next = NULL;
}
Expand All @@ -514,6 +514,8 @@ bool STM32_EMAC::link_out(emac_mem_buf_t *buf)

error:

//memory_manager->free(buf);

if (p->ref > 1) {
pbuf_free(p);
}
Expand Down
Expand Up @@ -199,7 +199,7 @@
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */

/* ########################### Ethernet Configuration ######################### */
#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */
#define ETH_TX_DESC_CNT 10 /* number of Ethernet Tx DMA descriptors */
#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */

#define ETH_MAC_ADDR0 ((uint8_t)0x02)
Expand Down

0 comments on commit a0d5988

Please sign in to comment.