fixes wrong allocation in mnrs network driver
This commit is contained in:
@@ -930,11 +930,14 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac){
|
|||||||
bit_size = get_ethmac_mac_rx(ethmac);
|
bit_size = get_ethmac_mac_rx(ethmac);
|
||||||
word_size = (bit_size+31)/32;
|
word_size = (bit_size+31)/32;
|
||||||
byte_size = (bit_size+7)/8;
|
byte_size = (bit_size+7)/8;
|
||||||
if(word_size<4){
|
if(word_size<4)
|
||||||
|
{
|
||||||
set_ethmac_mac_intr_rx_data_avail_intr_enable(ethmac, 1);
|
set_ethmac_mac_intr_rx_data_avail_intr_enable(ethmac, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for( i = 0;i < 4;i++){
|
// read the first 14 bytes to get from and to mac (6bytes each) and the frame type/length
|
||||||
|
for( i = 0;i < 4;i++)
|
||||||
|
{
|
||||||
while(!get_ethmac_mac_ctrl_rx_pending(ethmac))
|
while(!get_ethmac_mac_ctrl_rx_pending(ethmac))
|
||||||
;
|
;
|
||||||
// be carefull of unaligned accesses
|
// be carefull of unaligned accesses
|
||||||
@@ -945,12 +948,13 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac){
|
|||||||
to_mac.nx_mac_address_lsw=(buffer[2]<<24) + (buffer[3]<<16) + (buffer[4]<<8) + buffer[5];
|
to_mac.nx_mac_address_lsw=(buffer[2]<<24) + (buffer[3]<<16) + (buffer[4]<<8) + buffer[5];
|
||||||
from_mac.nx_mac_address_msw=(buffer[6]<<8) + buffer[7];
|
from_mac.nx_mac_address_msw=(buffer[6]<<8) + buffer[7];
|
||||||
from_mac.nx_mac_address_lsw=(buffer[8]<<24) + (buffer[9]<<16) + (buffer[10]<<8) + buffer[11];
|
from_mac.nx_mac_address_lsw=(buffer[8]<<24) + (buffer[9]<<16) + (buffer[10]<<8) + buffer[11];
|
||||||
// _tx_thread_context_save();
|
// find the diver instance belonging to our ethmac
|
||||||
for(i=0; i<NX_MAX_MNRS_INTERFACES; ++i)
|
for(i=0; i<NX_MAX_MNRS_INTERFACES; ++i)
|
||||||
if(nx_mnrs_driver[i].ethmac == ethmac) {
|
if(nx_mnrs_driver[i].ethmac == ethmac)
|
||||||
|
{
|
||||||
ip_ptr = nx_mnrs_driver[i].nx_mnrs_driver_ip_ptr;
|
ip_ptr = nx_mnrs_driver[i].nx_mnrs_driver_ip_ptr;
|
||||||
status = nx_packet_allocate(ip_ptr->nx_ip_default_packet_pool,
|
status = nx_packet_allocate(ip_ptr->nx_ip_default_packet_pool,
|
||||||
&packet_ptr, word_size*4 /*NX_RECEIVE_PACKET*/, NX_NO_WAIT);
|
&packet_ptr, NX_RECEIVE_PACKET, NX_NO_WAIT);
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
packet_ptr = NX_NULL;
|
packet_ptr = NX_NULL;
|
||||||
@@ -964,8 +968,9 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac){
|
|||||||
{
|
{
|
||||||
data = nx_mnrs_receive_buffer;
|
data = nx_mnrs_receive_buffer;
|
||||||
}
|
}
|
||||||
/* read the data from the rx buffer */
|
/* read the data from the rx buffer into the packet pointer or our frame buffer */
|
||||||
memcpy(data, buffer, 16);
|
memcpy(data, buffer, 16);
|
||||||
|
/* now get the remaining bytes from the ethmac peripheral */
|
||||||
for( i = 4;i < word_size;i++){
|
for( i = 4;i < word_size;i++){
|
||||||
while(!get_ethmac_mac_ctrl_rx_pending(ethmac))
|
while(!get_ethmac_mac_ctrl_rx_pending(ethmac))
|
||||||
;
|
;
|
||||||
@@ -1049,7 +1054,6 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac){
|
|||||||
nx_packet_release(packet_ptr);
|
nx_packet_release(packet_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// _tx_thread_context_restore();
|
|
||||||
set_ethmac_mac_intr_rx_data_avail_intr_enable(ethmac, 1);
|
set_ethmac_mac_intr_rx_data_avail_intr_enable(ethmac, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user