@@ -202,27 +202,27 @@ bool LPC546XX_EMAC::low_level_init_successful()
202
202
AT_NONCACHEABLE_SECTION_ALIGN (static enet_rx_bd_struct_t rx_desc_start_addr[ENET_RX_RING_LEN], ENET_BUFF_ALIGNMENT);
203
203
AT_NONCACHEABLE_SECTION_ALIGN (static enet_tx_bd_struct_t tx_desc_start_addr[ENET_TX_RING_LEN], ENET_BUFF_ALIGNMENT);
204
204
205
+ /* prepare the buffer configuration. */
206
+ enet_buffer_config_t buffCfg = {
207
+ ENET_RX_RING_LEN,
208
+ ENET_TX_RING_LEN,
209
+ &tx_desc_start_addr[0 ],
210
+ &tx_desc_start_addr[0 ],
211
+ &rx_desc_start_addr[0 ],
212
+ &rx_desc_start_addr[ENET_RX_RING_LEN],
213
+ rx_ptr,
214
+ ENET_BuffSizeAlign (ENET_ETH_MAX_FLEN),
215
+ };
216
+
205
217
/* Create buffers for each receive BD */
206
218
for (i = 0 ; i < ENET_RX_RING_LEN; i++) {
207
- rx_buff[i] = memory_manager->alloc_heap (ENET_ETH_MAX_FLEN , ENET_BUFF_ALIGNMENT);
219
+ rx_buff[i] = memory_manager->alloc_heap (buffCfg. rxBuffSizeAlign , ENET_BUFF_ALIGNMENT);
208
220
if (NULL == rx_buff[i])
209
221
return false ;
210
222
211
223
rx_ptr[i] = (uint32_t )memory_manager->get_ptr (rx_buff[i]);
212
224
}
213
225
214
- /* prepare the buffer configuration. */
215
- enet_buffer_config_t buffCfg = {
216
- ENET_RX_RING_LEN,
217
- ENET_TX_RING_LEN,
218
- &tx_desc_start_addr[0 ],
219
- &tx_desc_start_addr[0 ],
220
- &rx_desc_start_addr[0 ],
221
- &rx_desc_start_addr[ENET_RX_RING_LEN],
222
- rx_ptr,
223
- ENET_ALIGN (ENET_ETH_MAX_FLEN, ENET_BUFF_ALIGNMENT),
224
- };
225
-
226
226
ENET_Init (ENET, &config, hwaddr, refClock);
227
227
228
228
/* Enable the tx & rx interrupt. */
@@ -266,7 +266,7 @@ emac_mem_buf_t *LPC546XX_EMAC::low_level_input()
266
266
update_read_buffer (bdPtr, NULL );
267
267
} else {
268
268
if (bdPtr->control & ENET_RXDESCRIP_WR_LD_MASK) {
269
- length = (bdPtr->control & ENET_RXDESCRIP_WR_PACKETLEN_MASK);
269
+ length = (bdPtr->control & ENET_RXDESCRIP_WR_PACKETLEN_MASK) - 4 ;
270
270
} else {
271
271
length = rxBdRing->rxBuffSizeAlign ;
272
272
}
@@ -276,7 +276,7 @@ emac_mem_buf_t *LPC546XX_EMAC::low_level_input()
276
276
memory_manager->set_len (p, length);
277
277
278
278
/* Attempt to queue new buffer */
279
- temp_rxbuf = memory_manager->alloc_heap (ENET_ETH_MAX_FLEN , ENET_BUFF_ALIGNMENT);
279
+ temp_rxbuf = memory_manager->alloc_heap (rxBdRing-> rxBuffSizeAlign , ENET_BUFF_ALIGNMENT);
280
280
if (NULL == temp_rxbuf) {
281
281
/* Re-queue the same buffer */
282
282
update_read_buffer (bdPtr, NULL );
0 commit comments