From 28c14404d2765d5cd83baf397e1c92f8ae1db39a Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Tue, 3 Feb 2026 22:55:54 +0100 Subject: [PATCH] adds ThreadX clang-format settings and applies it to maceth driver --- .clang-format | 10 + .vscode/settings.json | 2 +- port/moonlight/mnrs_network_driver.c | 890 ++++++++++++++------------- 3 files changed, 474 insertions(+), 428 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..2ed2f24 --- /dev/null +++ b/.clang-format @@ -0,0 +1,10 @@ +BasedOnStyle: Microsoft +BinPackArguments: false +BinPackParameters: false +AlignAfterOpenBracket: DontAlign +AlignConsecutiveMacros: true +AlignConsecutiveAssignments: true +IndentCaseLabels: true +PointerAlignment: Left +BraceWrapping: + AfterCaseLabel: true \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 8d9d923..53cc08f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,7 +6,7 @@ "comment": "clang-format" } ], - "editor.formatOnSave": false, + "editor.formatOnSave": true, "clangd.arguments": [ "--pretty", "--background-index", diff --git a/port/moonlight/mnrs_network_driver.c b/port/moonlight/mnrs_network_driver.c index c0da155..323ed9e 100644 --- a/port/moonlight/mnrs_network_driver.c +++ b/port/moonlight/mnrs_network_driver.c @@ -38,9 +38,8 @@ extern int register_irq_handler(unsigned irq_num, void (*handler)()); /* Define the Link MTU. Note this is not the same as the IP MTU. The Link MTU includes the addition of the Physical Network header (usually Ethernet). This should be larger than the IP instance MTU by the size of the physical header. */ -#define NX_LINK_MTU 1514 -#define NX_MAX_PACKET_SIZE 1536 - +#define NX_LINK_MTU 1514 +#define NX_MAX_PACKET_SIZE 1536 /* Define Ethernet address format. This is prepended to the incoming IP and ARP/RARP messages. The frame beginning is 14 bytes, but for speed @@ -67,10 +66,9 @@ extern int register_irq_handler(unsigned irq_num, void (*handler)()); /* For the ethernet driver, physical addresses are allocated starting at the preset value and then incremented before the next allocation. */ -// Locally Administered Addresses that can be assigned by network, range is 02-00-00 to 02-00-5E -const ULONG mnrs_mac_address_msw = 0x0200; -const ULONG mnrs_mac_address_lsw = 0x00334450; - +// Locally Administered Addresses that can be assigned by network, range is 02-00-00 to 02-00-5E +const ULONG mnrs_mac_address_msw = 0x0200; +const ULONG mnrs_mac_address_lsw = 0x00334450; /* Define driver prototypes. */ @@ -98,7 +96,7 @@ typedef struct MAC_ADDRESS_STRUCT the actual driver being used. */ typedef struct _nx_mnrs_network_driver_instance_type { - UINT nx_mnrs_network_driver_in_use; + UINT nx_mnrs_network_driver_in_use; UINT nx_mnrs_network_driver_id; @@ -171,14 +169,14 @@ static _nx_mnrs_network_driver_instance_type nx_mnrs_driver[NX_MAX_PHYSICAL_INTE /* resulting in version 6.4.0 */ /* */ /**************************************************************************/ -VOID _nx_mnrs_network_driver(NX_IP_DRIVER *driver_req_ptr) +VOID _nx_mnrs_network_driver(NX_IP_DRIVER* driver_req_ptr) { -UINT i = 0; -NX_IP *ip_ptr; -NX_PACKET *packet_ptr; -NX_INTERFACE *interface_ptr; -UINT interface_index; -USHORT ether_type; + UINT i = 0; + NX_IP* ip_ptr; + NX_PACKET* packet_ptr; + NX_INTERFACE* interface_ptr; + UINT interface_index; + USHORT ether_type; #ifndef NX_ENABLE_VLAN ULONG *ethernet_frame_ptr; #endif /* NX_ENABLE_VLAN */ @@ -200,9 +198,12 @@ ULONG *ethernet_frame_ptr; /* Obtain the index number of the network interface. */ interface_index = interface_ptr -> nx_interface_index; /* Find out the driver interface if the driver command is not ATTACH. */ - if(driver_req_ptr->nx_ip_driver_command != NX_LINK_INTERFACE_ATTACH) { - for(i = 0; i < NX_MAX_PHYSICAL_INTERFACES; i++) { - if(nx_mnrs_driver[i].nx_mnrs_network_driver_in_use == 0) { + if (driver_req_ptr->nx_ip_driver_command != NX_LINK_INTERFACE_ATTACH) + { + for (i = 0; i < NX_MAX_PHYSICAL_INTERFACES; i++) + { + if (nx_mnrs_driver[i].nx_mnrs_network_driver_in_use == 0) + { continue; } if (nx_mnrs_driver[i].nx_mnrs_driver_ip_ptr != ip_ptr) @@ -214,400 +215,420 @@ ULONG *ethernet_frame_ptr; break; } } - if(i == NX_MAX_PHYSICAL_INTERFACES) { + if (i == NX_MAX_PHYSICAL_INTERFACES) + { driver_req_ptr->nx_ip_driver_status = NX_INVALID_INTERFACE; return; } } /* Process according to the driver request type in the IP control block. */ - switch (driver_req_ptr -> nx_ip_driver_command) + switch (driver_req_ptr->nx_ip_driver_command) { - case NX_LINK_INTERFACE_ATTACH: - { - /* Find an available driver instance to attach the interface. */ - for(i = 0; i < NX_MAX_PHYSICAL_INTERFACES; i++) { - if(nx_mnrs_driver[i].nx_mnrs_network_driver_in_use == 0) { - break; + case NX_LINK_INTERFACE_ATTACH: + { + /* Find an available driver instance to attach the interface. */ + for (i = 0; i < NX_MAX_PHYSICAL_INTERFACES; i++) + { + if (nx_mnrs_driver[i].nx_mnrs_network_driver_in_use == 0) + { + break; + } } - } - /* An available entry is found. */ - if(i < NX_MAX_PHYSICAL_INTERFACES) { - /* Set the IN USE flag.*/ - nx_mnrs_driver[i].nx_mnrs_network_driver_in_use = 1; - nx_mnrs_driver[i].nx_mnrs_network_driver_id = i; - /* Record the interface attached to the IP instance. */ - nx_mnrs_driver[i].nx_mnrs_driver_interface_ptr = interface_ptr; - /* Record the IP instance. */ - nx_mnrs_driver[i].nx_mnrs_driver_ip_ptr = ip_ptr; - /* store the mac address */ - nx_mnrs_driver[i].nx_mnrs_driver_mac_address.nx_mac_address_msw = mnrs_mac_address_msw; - nx_mnrs_driver[i].nx_mnrs_driver_mac_address.nx_mac_address_lsw = mnrs_mac_address_lsw + i; - /* Record the peripheral address */ - switch(i) { - case 0: - nx_mnrs_driver[i].ethmac = ethmac0; - break; + /* An available entry is found. */ + if (i < NX_MAX_PHYSICAL_INTERFACES) + { + /* Set the IN USE flag.*/ + nx_mnrs_driver[i].nx_mnrs_network_driver_in_use = 1; + nx_mnrs_driver[i].nx_mnrs_network_driver_id = i; + /* Record the interface attached to the IP instance. */ + nx_mnrs_driver[i].nx_mnrs_driver_interface_ptr = interface_ptr; + /* Record the IP instance. */ + nx_mnrs_driver[i].nx_mnrs_driver_ip_ptr = ip_ptr; + /* store the mac address */ + nx_mnrs_driver[i].nx_mnrs_driver_mac_address.nx_mac_address_msw = mnrs_mac_address_msw; + nx_mnrs_driver[i].nx_mnrs_driver_mac_address.nx_mac_address_lsw = mnrs_mac_address_lsw + i; + /* Record the peripheral address */ + switch (i) + { + case 0: + nx_mnrs_driver[i].ethmac = ethmac0; + break; #if defined(ethmac1) - case 1: - nx_mnrs_driver[i].ethmac = ethmac1; - break; + case 1: + nx_mnrs_driver[i].ethmac = ethmac1; + break; #endif #if defined(ethmac2) - case 2: - nx_mnrs_driver[i].ethmac = ethmac2; + case 2: + nx_mnrs_driver[i].ethmac = ethmac2; #endif #if defined(ethmac3) - case 2: - nx_mnrs_driver[i].ethmac = ethmac3; + case 2: + nx_mnrs_driver[i].ethmac = ethmac3; #endif - default: + default: + } + } + else + { + driver_req_ptr->nx_ip_driver_status = NX_INVALID_INTERFACE; } - } - else - { - driver_req_ptr -> nx_ip_driver_status = NX_INVALID_INTERFACE; - } - break; - } - case NX_LINK_INTERFACE_DETACH: - { - /* Zero out the driver instance. */ - memset(&(nx_mnrs_driver[i]), 0, sizeof(_nx_mnrs_network_driver_instance_type)); - break; - } - case NX_LINK_INITIALIZE: - { - /* Device driver shall initialize the Ethernet Controller here. */ -#ifdef NX_DEBUG - printf("NetX MNRS ETH Driver Initialization - %s\n", ip_ptr -> nx_ip_name); - printf(" IP Address =%08X\n", ip_ptr -> nx_ip_address); -#endif - // enable TX & RX path - set_ethmac_mac_ctrl(nx_mnrs_driver[i].ethmac, - get_ethmac_mac_ctrl(nx_mnrs_driver[i].ethmac) & ~(ETHMAC_MAC_CTRL_TX_FLUSH(1)| ETHMAC_MAC_CTRL_RX_FLUSH(1))); - register_irq_handler(ETH0_IRQ, &_nx_mnrs_eth_recv_packet_eth0); - register_irq_handler(ETH1_IRQ, &_nx_mnrs_eth_recv_packet_eth1); - csr_read_set_bits_mie(1< nx_interface_link_up = NX_TRUE; -#ifdef NX_DEBUG - printf("NetX MNRS ETH Driver Link Enabled - %s\n", ip_ptr -> nx_ip_name); -#endif - break; - } - case NX_LINK_DISABLE: - { - /* Process driver link disable. This command indicates the IP layer - is not going to transmit any IP datagrams, nor does it expect any - IP datagrams from the interface. Therefore after processing this command, - the device driver shall not send any incoming packets to the IP - layer. Optionally the device driver may turn off the interface. */ - // set_ethmac_int_ctrl_reg_tx_free_intr_enable(nx_mnrs_driver[i].ethmac, 0); - set_ethmac_mac_intr_rx_data_avail_intr_enable(nx_mnrs_driver[i].ethmac, 0); - /* In the MNRS ETH driver, just clear the enabled flag. */ - interface_ptr -> nx_interface_link_up = NX_FALSE; -#ifdef NX_DEBUG - printf("NetX MNRS ETH Driver Link Disabled - %s\n", ip_ptr -> nx_ip_name); -#endif - break; - } - case NX_LINK_PACKET_SEND: - case NX_LINK_PACKET_BROADCAST: - case NX_LINK_ARP_SEND: - case NX_LINK_ARP_RESPONSE_SEND: - case NX_LINK_RARP_SEND: - { - /* - The IP stack sends down a data packet for transmission. - The device driver needs to prepend a MAC header, and fill in the - Ethernet frame type (assuming Ethernet protocol for network transmission) - based on the type of packet being transmitted. - - The following sequence illustrates this process. - */ - /* Place the ethernet frame at the front of the packet. */ - packet_ptr = driver_req_ptr -> nx_ip_driver_packet; - /* Get Ethernet type. */ - if (driver_req_ptr -> nx_ip_driver_command == NX_LINK_ARP_SEND) - { - ether_type = NX_ETHERNET_ARP; - } - else if (driver_req_ptr -> nx_ip_driver_command == NX_LINK_ARP_RESPONSE_SEND) - { - ether_type = NX_ETHERNET_ARP; - } - else if (driver_req_ptr -> nx_ip_driver_command == NX_LINK_RARP_SEND) - { - ether_type = NX_ETHERNET_RARP; - } - else if (packet_ptr -> nx_packet_ip_version == 4) - { - ether_type = NX_ETHERNET_IP; - } - else - { - ether_type = NX_ETHERNET_IPV6; - } -#ifdef NX_ENABLE_VLAN - /* Add Ethernet header. */ - if (nx_link_ethernet_header_add(ip_ptr, - driver_req_ptr -> nx_ip_driver_interface -> nx_interface_index, packet_ptr, - driver_req_ptr -> nx_ip_driver_physical_address_msw, - driver_req_ptr -> nx_ip_driver_physical_address_lsw, - (UINT)ether_type)) - { - /* Release the packet. */ - nx_packet_transmit_release(packet_ptr); break; } + case NX_LINK_INTERFACE_DETACH: + { + /* Zero out the driver instance. */ + memset(&(nx_mnrs_driver[i]), 0, sizeof(_nx_mnrs_network_driver_instance_type)); + break; + } + case NX_LINK_INITIALIZE: + { + /* Device driver shall initialize the Ethernet Controller here. */ +#ifdef NX_DEBUG + printf("NetX MNRS ETH Driver Initialization - %s\n", ip_ptr->nx_ip_name); + printf(" IP Address =%08X\n", ip_ptr->nx_ip_address); +#endif + // enable TX & RX path + set_ethmac_mac_ctrl(nx_mnrs_driver[i].ethmac, + get_ethmac_mac_ctrl(nx_mnrs_driver[i].ethmac) & + ~(ETHMAC_MAC_CTRL_TX_FLUSH(1) | ETHMAC_MAC_CTRL_RX_FLUSH(1))); + register_irq_handler(ETH0_IRQ, &_nx_mnrs_eth_recv_packet_eth0); + register_irq_handler(ETH1_IRQ, &_nx_mnrs_eth_recv_packet_eth1); + csr_read_set_bits_mie(1 << ETH0_IRQ | 1 << ETH1_IRQ); + set_ethmac_mac_intr_rx_data_avail_intr_enable(nx_mnrs_driver[i].ethmac, 1); + /* Once the Ethernet controller is initialized, the driver needs to + configure the NetX Interface Control block, as outlined below. */ + + /* The nx_interface_ip_mtu_size should be the MTU for the IP payload. + For regular Ethernet, the IP MTU is 1500. */ + nx_ip_interface_mtu_set(ip_ptr, interface_index, (NX_LINK_MTU - NX_ETHERNET_SIZE)); + /* Set the physical address (MAC address) of this IP instance. */ + /* For this MNRS ETH driver, the MAC address is constructed by + incrementing a base lsw value, to simulate multiple nodes on the + ethernet. */ + nx_ip_interface_physical_address_set(ip_ptr, + interface_index, + nx_mnrs_driver[i].nx_mnrs_driver_mac_address.nx_mac_address_msw, + nx_mnrs_driver[i].nx_mnrs_driver_mac_address.nx_mac_address_lsw, + NX_FALSE); + /* Indicate to the IP software that IP to physical mapping is required. */ + nx_ip_interface_address_mapping_configure(ip_ptr, interface_index, NX_TRUE); + break; + } + case NX_LINK_UNINITIALIZE: + { + // disable TX & RX path + set_ethmac_mac_intr_rx_data_avail_intr_enable(nx_mnrs_driver[i].ethmac, 0); + csr_read_clr_bits_mie(1 << ETH0_IRQ | 1 << ETH1_IRQ); + register_irq_handler(ETH0_IRQ, NULL); + register_irq_handler(ETH1_IRQ, NULL); + // set_ethmac_mac_ctrl_tx_flush(nx_mnrs_driver[i].ethmac, 1); + // set_ethmac_mac_ctrl_rx_flush(nx_mnrs_driver[i].ethmac, 1); + set_ethmac_mac_ctrl(nx_mnrs_driver[i].ethmac, + get_ethmac_mac_ctrl(nx_mnrs_driver[i].ethmac) | ETHMAC_MAC_CTRL_TX_FLUSH(1) | + ETHMAC_MAC_CTRL_RX_FLUSH(1)); + /* Zero out the driver instance. */ + memset(&(nx_mnrs_driver[i]), 0, sizeof(_nx_mnrs_network_driver_instance_type)); + break; + } + case NX_LINK_ENABLE: + { + /* Process driver link enable. An Ethernet driver shall enable the + transmit and reception logic. Once the IP stack issues the + LINK_ENABLE command, the stack may start transmitting IP packets. */ + // set_ethmac_int_ctrl_reg_tx_free_intr_enable(nx_mnrs_driver[i].ethmac, 1); + set_ethmac_mac_intr_rx_data_avail_intr_enable(nx_mnrs_driver[i].ethmac, 1); + /* In the MNRS ETH driver, just set the enabled flag. */ + interface_ptr->nx_interface_link_up = NX_TRUE; +#ifdef NX_DEBUG + printf("NetX MNRS ETH Driver Link Enabled - %s\n", ip_ptr->nx_ip_name); +#endif + break; + } + case NX_LINK_DISABLE: + { + /* Process driver link disable. This command indicates the IP layer + is not going to transmit any IP datagrams, nor does it expect any + IP datagrams from the interface. Therefore after processing this command, + the device driver shall not send any incoming packets to the IP + layer. Optionally the device driver may turn off the interface. */ + // set_ethmac_int_ctrl_reg_tx_free_intr_enable(nx_mnrs_driver[i].ethmac, 0); + set_ethmac_mac_intr_rx_data_avail_intr_enable(nx_mnrs_driver[i].ethmac, 0); + /* In the MNRS ETH driver, just clear the enabled flag. */ + interface_ptr->nx_interface_link_up = NX_FALSE; +#ifdef NX_DEBUG + printf("NetX MNRS ETH Driver Link Disabled - %s\n", ip_ptr->nx_ip_name); +#endif + break; + } + case NX_LINK_PACKET_SEND: + case NX_LINK_PACKET_BROADCAST: + case NX_LINK_ARP_SEND: + case NX_LINK_ARP_RESPONSE_SEND: + case NX_LINK_RARP_SEND: + { + /* + The IP stack sends down a data packet for transmission. + The device driver needs to prepend a MAC header, and fill in the + Ethernet frame type (assuming Ethernet protocol for network transmission) + based on the type of packet being transmitted. + + The following sequence illustrates this process. + */ + /* Place the ethernet frame at the front of the packet. */ + packet_ptr = driver_req_ptr->nx_ip_driver_packet; + /* Get Ethernet type. */ + if (driver_req_ptr->nx_ip_driver_command == NX_LINK_ARP_SEND) + { + ether_type = NX_ETHERNET_ARP; + } + else if (driver_req_ptr->nx_ip_driver_command == NX_LINK_ARP_RESPONSE_SEND) + { + ether_type = NX_ETHERNET_ARP; + } + else if (driver_req_ptr->nx_ip_driver_command == NX_LINK_RARP_SEND) + { + ether_type = NX_ETHERNET_RARP; + } + else if (packet_ptr->nx_packet_ip_version == 4) + { + ether_type = NX_ETHERNET_IP; + } + else + { + ether_type = NX_ETHERNET_IPV6; + } +#ifdef NX_ENABLE_VLAN + /* Add Ethernet header. */ + if (nx_link_ethernet_header_add(ip_ptr, + driver_req_ptr->nx_ip_driver_interface->nx_interface_index, + packet_ptr, + driver_req_ptr->nx_ip_driver_physical_address_msw, + driver_req_ptr->nx_ip_driver_physical_address_lsw, + (UINT)ether_type)) + { + /* Release the packet. */ + nx_packet_transmit_release(packet_ptr); + break; + } #else - /* Adjust the prepend pointer. */ - packet_ptr -> nx_packet_prepend_ptr = packet_ptr -> nx_packet_prepend_ptr - NX_ETHERNET_SIZE; - /* Adjust the packet length. */ - packet_ptr -> nx_packet_length = packet_ptr -> nx_packet_length + NX_ETHERNET_SIZE; - /* Setup the ethernet frame pointer to build the ethernet frame. Backup another 2 - bytes to get 32-bit word alignment. */ - /*lint -e{927} -e{826} suppress cast of pointer to pointer, since it is necessary */ - ethernet_frame_ptr = (ULONG *)(packet_ptr -> nx_packet_prepend_ptr - 2); - /* Build the ethernet frame. */ - *ethernet_frame_ptr = driver_req_ptr -> nx_ip_driver_physical_address_msw; - *(ethernet_frame_ptr + 1) = driver_req_ptr -> nx_ip_driver_physical_address_lsw; - *(ethernet_frame_ptr + 2) = (interface_ptr -> nx_interface_physical_address_msw << 16) | - (interface_ptr -> nx_interface_physical_address_lsw >> 16); - *(ethernet_frame_ptr + 3) = (interface_ptr -> nx_interface_physical_address_lsw << 16) | ether_type; - /* Endian swapping if NX_LITTLE_ENDIAN is defined. */ - NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr)); - NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr + 1)); - NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr + 2)); - NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr + 3)); + /* Adjust the prepend pointer. */ + packet_ptr->nx_packet_prepend_ptr = packet_ptr->nx_packet_prepend_ptr - NX_ETHERNET_SIZE; + /* Adjust the packet length. */ + packet_ptr->nx_packet_length = packet_ptr->nx_packet_length + NX_ETHERNET_SIZE; + /* Setup the ethernet frame pointer to build the ethernet frame. Backup another 2 + bytes to get 32-bit word alignment. */ + /*lint -e{927} -e{826} suppress cast of pointer to pointer, since it is necessary */ + ethernet_frame_ptr = (ULONG*)(packet_ptr->nx_packet_prepend_ptr - 2); + /* Build the ethernet frame. */ + *ethernet_frame_ptr = driver_req_ptr->nx_ip_driver_physical_address_msw; + *(ethernet_frame_ptr + 1) = driver_req_ptr->nx_ip_driver_physical_address_lsw; + *(ethernet_frame_ptr + 2) = (interface_ptr->nx_interface_physical_address_msw << 16) | + (interface_ptr->nx_interface_physical_address_lsw >> 16); + *(ethernet_frame_ptr + 3) = (interface_ptr->nx_interface_physical_address_lsw << 16) | ether_type; + /* Endian swapping if NX_LITTLE_ENDIAN is defined. */ + NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr)); + NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr + 1)); + NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr + 2)); + NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr + 3)); #endif /* NX_ENABLE_VLAN */ #ifdef NX_DEBUG_PACKET - printf("NetX MNRS ETH Driver Packet Send - %s\n", ip_ptr -> nx_ip_name); + printf("NetX MNRS ETH Driver Packet Send - %s\n", ip_ptr->nx_ip_name); #endif - /* At this point, the packet is a complete Ethernet frame, ready to be transmitted. - The driver shall call the actual Ethernet transmit routine and put the packet - on the wire. + /* At this point, the packet is a complete Ethernet frame, ready to be transmitted. + The driver shall call the actual Ethernet transmit routine and put the packet + on the wire. - In this example, the MNRS ETH network transmit routine is called. */ - _nx_mnrs_network_driver_output(packet_ptr, i); - break; - } + In this example, the MNRS ETH network transmit routine is called. */ + _nx_mnrs_network_driver_output(packet_ptr, i); + break; + } #ifdef NX_ENABLE_VLAN - case NX_LINK_RAW_PACKET_SEND: - { - /* Send raw packet out directly. */ - _nx_mnrs_network_driver_output(driver_req_ptr -> nx_ip_driver_packet, i); - break; - } + case NX_LINK_RAW_PACKET_SEND: + { + /* Send raw packet out directly. */ + _nx_mnrs_network_driver_output(driver_req_ptr->nx_ip_driver_packet, i); + break; + } #endif /* NX_ENABLE_VLAN */ - case NX_LINK_MULTICAST_JOIN: - { - UINT mcast_index; - /* The IP layer issues this command to join a multicast group. Note that - multicast operation is required for IPv6. - - On a typically Ethernet controller, the driver computes a hash value based - on MAC address, and programs the hash table. - - It is likely the driver also needs to maintain an internal MAC address table. - Later if a multicast address is removed, the driver needs - to reprogram the hash table based on the remaining multicast MAC addresses. */ - - /* The following procedure only applies to our MNRS ETH network driver, which manages - multicast MAC addresses by a simple look up table. */ - for (mcast_index = 0; mcast_index < NX_MNRS_DRIVER_MAX_MCAST_ADDRESSES; mcast_index++) + case NX_LINK_MULTICAST_JOIN: { - if (nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_msw == 0 && - nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_lsw == 0) + UINT mcast_index; + /* The IP layer issues this command to join a multicast group. Note that + multicast operation is required for IPv6. + + On a typically Ethernet controller, the driver computes a hash value based + on MAC address, and programs the hash table. + + It is likely the driver also needs to maintain an internal MAC address table. + Later if a multicast address is removed, the driver needs + to reprogram the hash table based on the remaining multicast MAC addresses. */ + + /* The following procedure only applies to our MNRS ETH network driver, which manages + multicast MAC addresses by a simple look up table. */ + for (mcast_index = 0; mcast_index < NX_MNRS_DRIVER_MAX_MCAST_ADDRESSES; mcast_index++) { - nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_msw = driver_req_ptr -> nx_ip_driver_physical_address_msw; - nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_lsw = driver_req_ptr -> nx_ip_driver_physical_address_lsw; - break; + if (nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_msw == 0 && + nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_lsw == 0) + { + nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_msw = + driver_req_ptr->nx_ip_driver_physical_address_msw; + nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_lsw = + driver_req_ptr->nx_ip_driver_physical_address_lsw; + break; + } } - } - if (mcast_index == NX_MNRS_DRIVER_MAX_MCAST_ADDRESSES) - { - driver_req_ptr -> nx_ip_driver_status = NX_NO_MORE_ENTRIES; - } - break; - } - case NX_LINK_MULTICAST_LEAVE: - { - UINT mcast_index; - /* The IP layer issues this command to remove a multicast MAC address from the - receiving list. A device driver shall properly remove the multicast address - from the hash table, so the hardware does not receive such traffic. Note that - in order to reprogram the hash table, the device driver may have to keep track of - current active multicast MAC addresses. */ - - /* The following procedure only applies to our MNRS ETH network driver, which manages - multicast MAC addresses by a simple look up table. */ - for (mcast_index = 0; mcast_index < NX_MNRS_DRIVER_MAX_MCAST_ADDRESSES; mcast_index++) - { - if (nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_msw == driver_req_ptr -> nx_ip_driver_physical_address_msw && - nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_lsw == driver_req_ptr -> nx_ip_driver_physical_address_lsw) + if (mcast_index == NX_MNRS_DRIVER_MAX_MCAST_ADDRESSES) { - nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_msw = 0; - nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_lsw = 0; - break; + driver_req_ptr->nx_ip_driver_status = NX_NO_MORE_ENTRIES; } + break; } - if (mcast_index == NX_MNRS_DRIVER_MAX_MCAST_ADDRESSES) + case NX_LINK_MULTICAST_LEAVE: { - driver_req_ptr -> nx_ip_driver_status = NX_ENTRY_NOT_FOUND; - } - break; - } - case NX_LINK_GET_STATUS: - { - /* Return the link status in the supplied return pointer. */ - *(driver_req_ptr -> nx_ip_driver_return_ptr) = ip_ptr -> nx_ip_interface[0].nx_interface_link_up; - break; - } - case NX_LINK_GET_SPEED: - { - /* Return the link's line speed in the supplied return pointer. Unsupported feature. */ - *(driver_req_ptr -> nx_ip_driver_return_ptr) = 0; - break; - } - case NX_LINK_GET_DUPLEX_TYPE: - { - /* Return the link's line speed in the supplied return pointer. Unsupported feature. */ - *(driver_req_ptr -> nx_ip_driver_return_ptr) = 0; - break; - } - case NX_LINK_GET_ERROR_COUNT: - { - /* Return the link's line speed in the supplied return pointer. Unsupported feature. */ - *(driver_req_ptr -> nx_ip_driver_return_ptr) = 0; - break; - } - case NX_LINK_GET_RX_COUNT: - { - /* Return the link's line speed in the supplied return pointer. Unsupported feature. */ - *(driver_req_ptr -> nx_ip_driver_return_ptr) = 0; - break; - } - case NX_LINK_GET_TX_COUNT: - { - /* Return the link's line speed in the supplied return pointer. Unsupported feature. */ - *(driver_req_ptr -> nx_ip_driver_return_ptr) = 0; - break; - } - case NX_LINK_GET_ALLOC_ERRORS: - { - /* Return the link's line speed in the supplied return pointer. Unsupported feature. */ - *(driver_req_ptr -> nx_ip_driver_return_ptr) = 0; - break; - } - case NX_LINK_GET_INTERFACE_TYPE: - { - /* Return the link's interface type in the supplied return pointer. Unsupported feature. */ - *(driver_req_ptr -> nx_ip_driver_return_ptr) = NX_INTERFACE_TYPE_UNKNOWN; - break; - } - case NX_LINK_DEFERRED_PROCESSING: - { - /* Driver defined deferred processing. This is typically used to defer interrupt - processing to the thread level. + UINT mcast_index; + /* The IP layer issues this command to remove a multicast MAC address from the + receiving list. A device driver shall properly remove the multicast address + from the hash table, so the hardware does not receive such traffic. Note that + in order to reprogram the hash table, the device driver may have to keep track of + current active multicast MAC addresses. */ - A typical use case of this command is: - On receiving an Ethernet frame, the RX ISR does not process the received frame, - but instead records such an event in its internal data structure, and issues - a notification to the IP stack (the driver sends the notification to the IP - helping thread by calling "_nx_ip_driver_deferred_processing()". When the IP stack - gets a notification of a pending driver deferred process, it calls the - driver with the NX_LINK_DEFERRED_PROCESSING command. The driver shall complete - the pending receive process. - */ - - /* The MNRS ETH driver doesn't require a deferred process so it breaks out of - the switch case. */ - break; - } - case NX_LINK_SET_PHYSICAL_ADDRESS: - { - /* Find an driver instance to attach the interface. */ - for(i = 0; i < NX_MAX_PHYSICAL_INTERFACES; i++) { - if(nx_mnrs_driver[i].nx_mnrs_driver_interface_ptr == interface_ptr) { - break; + /* The following procedure only applies to our MNRS ETH network driver, which manages + multicast MAC addresses by a simple look up table. */ + for (mcast_index = 0; mcast_index < NX_MNRS_DRIVER_MAX_MCAST_ADDRESSES; mcast_index++) + { + if (nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_msw == + driver_req_ptr->nx_ip_driver_physical_address_msw && + nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_lsw == + driver_req_ptr->nx_ip_driver_physical_address_lsw) + { + nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_msw = 0; + nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_lsw = 0; + break; + } } + if (mcast_index == NX_MNRS_DRIVER_MAX_MCAST_ADDRESSES) + { + driver_req_ptr->nx_ip_driver_status = NX_ENTRY_NOT_FOUND; + } + break; } - /* An available entry is found. */ - if(i < NX_MAX_PHYSICAL_INTERFACES) { - /* Set the physical address. */ - nx_mnrs_driver[i].nx_mnrs_driver_mac_address.nx_mac_address_msw = driver_req_ptr -> nx_ip_driver_physical_address_msw; - nx_mnrs_driver[i].nx_mnrs_driver_mac_address.nx_mac_address_lsw = driver_req_ptr -> nx_ip_driver_physical_address_lsw; - } - else + case NX_LINK_GET_STATUS: { - driver_req_ptr -> nx_ip_driver_status = NX_INVALID_INTERFACE; + /* Return the link status in the supplied return pointer. */ + *(driver_req_ptr->nx_ip_driver_return_ptr) = ip_ptr->nx_ip_interface[0].nx_interface_link_up; + break; + } + case NX_LINK_GET_SPEED: + { + /* Return the link's line speed in the supplied return pointer. Unsupported feature. */ + *(driver_req_ptr->nx_ip_driver_return_ptr) = 0; + break; + } + case NX_LINK_GET_DUPLEX_TYPE: + { + /* Return the link's line speed in the supplied return pointer. Unsupported feature. */ + *(driver_req_ptr->nx_ip_driver_return_ptr) = 0; + break; + } + case NX_LINK_GET_ERROR_COUNT: + { + /* Return the link's line speed in the supplied return pointer. Unsupported feature. */ + *(driver_req_ptr->nx_ip_driver_return_ptr) = 0; + break; + } + case NX_LINK_GET_RX_COUNT: + { + /* Return the link's line speed in the supplied return pointer. Unsupported feature. */ + *(driver_req_ptr->nx_ip_driver_return_ptr) = 0; + break; + } + case NX_LINK_GET_TX_COUNT: + { + /* Return the link's line speed in the supplied return pointer. Unsupported feature. */ + *(driver_req_ptr->nx_ip_driver_return_ptr) = 0; + break; + } + case NX_LINK_GET_ALLOC_ERRORS: + { + /* Return the link's line speed in the supplied return pointer. Unsupported feature. */ + *(driver_req_ptr->nx_ip_driver_return_ptr) = 0; + break; + } + case NX_LINK_GET_INTERFACE_TYPE: + { + /* Return the link's interface type in the supplied return pointer. Unsupported feature. */ + *(driver_req_ptr->nx_ip_driver_return_ptr) = NX_INTERFACE_TYPE_UNKNOWN; + break; + } + case NX_LINK_DEFERRED_PROCESSING: + { + /* Driver defined deferred processing. This is typically used to defer interrupt + processing to the thread level. + + A typical use case of this command is: + On receiving an Ethernet frame, the RX ISR does not process the received frame, + but instead records such an event in its internal data structure, and issues + a notification to the IP stack (the driver sends the notification to the IP + helping thread by calling "_nx_ip_driver_deferred_processing()". When the IP stack + gets a notification of a pending driver deferred process, it calls the + driver with the NX_LINK_DEFERRED_PROCESSING command. The driver shall complete + the pending receive process. + */ + + /* The MNRS ETH driver doesn't require a deferred process so it breaks out of + the switch case. */ + break; + } + case NX_LINK_SET_PHYSICAL_ADDRESS: + { + /* Find an driver instance to attach the interface. */ + for (i = 0; i < NX_MAX_PHYSICAL_INTERFACES; i++) + { + if (nx_mnrs_driver[i].nx_mnrs_driver_interface_ptr == interface_ptr) + { + break; + } + } + /* An available entry is found. */ + if (i < NX_MAX_PHYSICAL_INTERFACES) + { + /* Set the physical address. */ + nx_mnrs_driver[i].nx_mnrs_driver_mac_address.nx_mac_address_msw = + driver_req_ptr->nx_ip_driver_physical_address_msw; + nx_mnrs_driver[i].nx_mnrs_driver_mac_address.nx_mac_address_lsw = + driver_req_ptr->nx_ip_driver_physical_address_lsw; + } + else + { + driver_req_ptr->nx_ip_driver_status = NX_INVALID_INTERFACE; + } + break; } - break; - } #ifdef NX_ENABLE_INTERFACE_CAPABILITY - case NX_INTERFACE_CAPABILITY_GET: - { - /* Return the capability of the Ethernet controller speed in the supplied return pointer. Unsupported feature. */ - *(driver_req_ptr -> nx_ip_driver_return_ptr) = 0; - break; - } - case NX_INTERFACE_CAPABILITY_SET: - { - /* Set the capability of the Ethernet controller. Unsupported feature. */ - break; - } + case NX_INTERFACE_CAPABILITY_GET: + { + /* Return the capability of the Ethernet controller speed in the supplied return pointer. Unsupported + * feature. */ + *(driver_req_ptr->nx_ip_driver_return_ptr) = 0; + break; + } + case NX_INTERFACE_CAPABILITY_SET: + { + /* Set the capability of the Ethernet controller. Unsupported feature. */ + break; + } #endif /* NX_ENABLE_INTERFACE_CAPABILITY */ - default: - /* Invalid driver request. */ + default: + /* Invalid driver request. */ - /* Return the unhandled command status. */ - driver_req_ptr -> nx_ip_driver_status = NX_UNHANDLED_COMMAND; + /* Return the unhandled command status. */ + driver_req_ptr->nx_ip_driver_status = NX_UNHANDLED_COMMAND; #ifdef NX_DEBUG - printf("NetX MNRS ETH Driver Received invalid request - %s\n", ip_ptr -> nx_ip_name); + printf("NetX MNRS ETH Driver Received invalid request - %s\n", ip_ptr->nx_ip_name); #endif - break; + break; } } @@ -660,9 +681,9 @@ ULONG *ethernet_frame_ptr; /* resulting in version 6.4.0 */ /* */ /**************************************************************************/ -void _nx_mnrs_network_driver_output(NX_PACKET *packet_ptr, UINT interface_instance_id) +void _nx_mnrs_network_driver_output(NX_PACKET* packet_ptr, UINT interface_instance_id) { -UINT old_threshold = 0; + UINT old_threshold = 0; #ifdef NX_DEBUG_PACKET UCHAR *ptr; @@ -683,7 +704,7 @@ UINT i, j; printf("%02X ", *ptr++); i = 0; - for (j = 0; j < (packet_ptr -> nx_packet_length - NX_ETHERNET_SIZE); j++) + for (j = 0; j < (packet_ptr->nx_packet_length - NX_ETHERNET_SIZE); j++) { printf("%02X", *ptr++); i++; @@ -702,8 +723,9 @@ UINT i, j; #ifdef NX_ENABLE_VLAN /* Release the packet. */ nx_link_packet_transmitted(nx_mnrs_driver[interface_instance_id].nx_mnrs_driver_ip_ptr, - nx_mnrs_driver[interface_instance_id].nx_mnrs_driver_interface_ptr -> nx_interface_index, - packet_ptr, NX_NULL); + nx_mnrs_driver[interface_instance_id].nx_mnrs_driver_interface_ptr->nx_interface_index, + packet_ptr, + NX_NULL); #else /* Remove the Ethernet header. In real hardware environments, this is typically done after a transmit complete interrupt. */ @@ -770,21 +792,23 @@ UINT i, j; /* resulting in version 6.4.0 */ /* */ /**************************************************************************/ -void _nx_mnrs_network_driver_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr, UINT interface_instance_id) +void _nx_mnrs_network_driver_receive(NX_IP* ip_ptr, NX_PACKET* packet_ptr, UINT interface_instance_id) { -UINT packet_type; + UINT packet_type; #ifdef NX_ENABLE_VLAN nx_link_ethernet_packet_received(ip_ptr, - nx_mnrs_driver[interface_instance_id].nx_mnrs_driver_interface_ptr -> nx_interface_index, - packet_ptr, NX_NULL); + nx_mnrs_driver[interface_instance_id].nx_mnrs_driver_interface_ptr->nx_interface_index, + packet_ptr, + NX_NULL); #else /* Pickup the packet header to determine where the packet needs to be sent. */ - packet_type = (((UINT)(*(packet_ptr -> nx_packet_prepend_ptr + 12))) << 8) | - ((UINT)(*(packet_ptr -> nx_packet_prepend_ptr + 13))); + packet_type = (((UINT)(*(packet_ptr->nx_packet_prepend_ptr + 12))) << 8) | + ((UINT)(*(packet_ptr->nx_packet_prepend_ptr + 13))); /* Setup interface pointer. */ - packet_ptr -> nx_packet_address.nx_packet_interface_ptr = nx_mnrs_driver[interface_instance_id].nx_mnrs_driver_interface_ptr; + packet_ptr->nx_packet_address.nx_packet_interface_ptr = + nx_mnrs_driver[interface_instance_id].nx_mnrs_driver_interface_ptr; /* Route the incoming packet according to its ethernet type. */ /* The MNRS ETH driver accepts both IPv4 and IPv6 frames. */ if ((packet_type == NX_ETHERNET_IP) || (packet_type == NX_ETHERNET_IPV6)) @@ -842,32 +866,37 @@ UINT packet_type; #endif /* NX_ENABLE_VLAN */ } -UINT _nx_mnrs_eth_send_packet(NX_PACKET *packet_ptr, volatile ethmac_t* ethmac){ -ULONG size = 0; -UCHAR *data; -UINT i; -ULONG buffer; -ULONG words; +UINT _nx_mnrs_eth_send_packet(NX_PACKET* packet_ptr, volatile ethmac_t* ethmac) +{ + ULONG size = 0; + UCHAR* data; + UINT i; + ULONG buffer; + ULONG words; /* Make sure the data length is less than MTU. */ - if (packet_ptr -> nx_packet_length > NX_MAX_PACKET_SIZE) + if (packet_ptr->nx_packet_length > NX_MAX_PACKET_SIZE) { return NX_NOT_SUCCESSFUL; } /* get data pointer to be transmitted. */ - data = packet_ptr -> nx_packet_prepend_ptr; - size = packet_ptr -> nx_packet_length; - words = (size+3)/4; - while(get_ethmac_mac_ctrl_tx_ready(ethmac) == 0) + data = packet_ptr->nx_packet_prepend_ptr; + size = packet_ptr->nx_packet_length; + words = (size + 3) / 4; + while (get_ethmac_mac_ctrl_tx_ready(ethmac) == 0) ; - set_ethmac_mac_tx(ethmac, size*8); - for(i=0; inx_mac_address_msw && - nx_mnrs_driver[i].nx_mnrs_driver_mac_address.nx_mac_address_lsw == mac_addr -> nx_mac_address_lsw) + nx_mnrs_driver[i].nx_mnrs_driver_mac_address.nx_mac_address_lsw == mac_addr->nx_mac_address_lsw) { return 1; } return 0; } -UINT mcast_mac_addr_hit_idx(UINT i, MAC_ADDRESS*mac_addr) { +UINT mcast_mac_addr_hit_idx(UINT i, MAC_ADDRESS* mac_addr) +{ UINT mcast_index; for (mcast_index = 0; mcast_index < NX_MNRS_DRIVER_MAX_MCAST_ADDRESSES; mcast_index++) { - if (nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_msw == mac_addr->nx_mac_address_msw && - nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_lsw == mac_addr -> nx_mac_address_lsw) + if (nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_msw == + mac_addr->nx_mac_address_msw && + nx_mnrs_driver[i].nx_mnrs_driver_mcast_address[mcast_index].nx_mac_address_lsw == + mac_addr->nx_mac_address_lsw) { return i; } @@ -899,7 +932,8 @@ UINT mcast_mac_addr_hit_idx(UINT i, MAC_ADDRESS*mac_addr) { } static UCHAR nx_mnrs_receive_buffer[NX_MAX_PACKET_SIZE]; -VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac) { +VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac) +{ UINT bits_received; UINT words_to_read; UINT i, j; @@ -914,12 +948,12 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac) { set_ethmac_mac_intr_rx_data_avail_intr_enable(ethmac, 0); bits_received = get_ethmac_mac_rx(ethmac); - words_to_read = (bits_received+31)/32; - if(words_to_read<4) + words_to_read = (bits_received + 31) / 32; + if (words_to_read < 4) { - for(j = 0;j < words_to_read;j++) + for (j = 0; j < words_to_read; j++) { - while(!get_ethmac_mac_ctrl_rx_pending(ethmac)) + while (!get_ethmac_mac_ctrl_rx_pending(ethmac)) ; // be carefull of unaligned accesses since data is 2byte aligned word = get_ethmac_mac_rx(ethmac); @@ -929,18 +963,18 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac) { return; } // find the diver instance belonging to our ethmac - for(i=0; inx_ip_default_packet_pool, - &packet_ptr, NX_RECEIVE_PACKET, NX_NO_WAIT); + status = nx_packet_allocate(ip_ptr->nx_ip_default_packet_pool, &packet_ptr, NX_RECEIVE_PACKET, NX_NO_WAIT); if (status) { packet_ptr = NX_NULL; - data = nx_mnrs_receive_buffer; + data = nx_mnrs_receive_buffer; } - else if(ip_ptr->nx_ip_default_packet_pool->nx_packet_pool_payload_size >= (NX_LINK_MTU + 2)) + else if (ip_ptr->nx_ip_default_packet_pool->nx_packet_pool_payload_size >= (NX_LINK_MTU + 2)) { data = packet_ptr->nx_packet_prepend_ptr + 2; } @@ -949,15 +983,15 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac) { data = nx_mnrs_receive_buffer; } /* now get the remaining bytes from the ethmac peripheral */ - for(j = 0;j < words_to_read;j++) + for (j = 0; j < words_to_read; j++) { - while(!get_ethmac_mac_ctrl_rx_pending(ethmac)) + while (!get_ethmac_mac_ctrl_rx_pending(ethmac)) ; // be carefull of unaligned accesses since data is 2byte aligned word = get_ethmac_mac_rx(ethmac); memcpy(data + j * sizeof(UINT), &word, sizeof(UINT)); } - if(packet_ptr == NX_NULL) + if (packet_ptr == NX_NULL) { /* No packet available. Drop it and continue. */ return; @@ -965,11 +999,11 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac) { /* Make sure IP header is 4-byte aligned. */ packet_ptr->nx_packet_prepend_ptr += 2; packet_ptr->nx_packet_append_ptr += 2; - if(data == nx_mnrs_receive_buffer) + if (data == nx_mnrs_receive_buffer) { /* Copy data into packet. */ - status = nx_packet_data_append(packet_ptr, (VOID *)data, bytes_received, - ip_ptr -> nx_ip_default_packet_pool, NX_NO_WAIT); + status = nx_packet_data_append( + packet_ptr, (VOID*)data, bytes_received, ip_ptr->nx_ip_default_packet_pool, NX_NO_WAIT); if (status) { nx_packet_release(packet_ptr); @@ -989,15 +1023,17 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac) { set_ethmac_mac_intr_rx_data_avail_intr_enable(ethmac, 1); } -VOID _nx_mnrs_eth_recv_packet_eth0(VOID) { - if(get_ethmac_mac_ctrl_rx_pending(ethmac0)) +VOID _nx_mnrs_eth_recv_packet_eth0(VOID) +{ + if (get_ethmac_mac_ctrl_rx_pending(ethmac0)) { _nx_mnrs_eth_recv_packet(0, ethmac0); } } -VOID _nx_mnrs_eth_recv_packet_eth1(VOID) { - if(get_ethmac_mac_ctrl_rx_pending(ethmac1)) +VOID _nx_mnrs_eth_recv_packet_eth1(VOID) +{ + if (get_ethmac_mac_ctrl_rx_pending(ethmac1)) { _nx_mnrs_eth_recv_packet(1, ethmac1); }