ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
nx_ether_driver_ra8_eth.c
Go to the documentation of this file.
1
33
35
36#include <stdint.h>
37#include <string.h>
38
39#include "nx_api.h"
40#include "nx_arp.h"
41#include "nx_ip.h"
42#include "ra8_attributes.h"
43#include "ra8_err.h"
44#include "ra8_eth.h"
45#include "tx_api.h"
46
47#ifndef NX_DISABLE_IPV4
48#include "nx_rarp.h"
49#endif
50
81
94
112
117typedef enum : uint8_t {
120
139
156
169
181static UCHAR s_ra8_eth_open;
182
194static UCHAR s_link_up;
195
209
221static uint8_t s_local_mac_user_set;
222
223/* nx_ether_driver_ra8_eth_set_mac -- see header for full description. */
224void nx_ether_driver_ra8_eth_set_mac(const uint8_t mac[6])
225{
226 if (mac == nullptr) {
227 return;
228 }
229 for (uint8_t i = 0U; i < (uint8_t)k_nx_ra8_eth_mac_len; ++i) {
230 s_local_mac[i] = mac[i];
231 }
233}
234
252typedef struct {
253 uint32_t dispatch_total;
254 uint32_t init_total;
255 uint32_t enable_total;
256 uint32_t send_total;
257 uint32_t rx_total;
258 uint32_t status_total;
259 uint32_t last_cmd;
266
279
298
301static NX_IP* s_rx_ip = NX_NULL;
302static NX_INTERFACE* s_rx_iface = NX_NULL;
303static uint8_t s_rx_thread_made = 0U;
304
323
341RA8_INTERNAL static void internal_spawn_rx_worker(NX_IP* ip, NX_INTERFACE* iface)
342{
343 static CHAR s_thread_name[] = {'r', 'a', '8', '_', 'e', 't', 'h', '_', 'r', 'x', '\0'};
344 if (s_rx_thread_made != 0U) {
345 return;
346 }
347 s_rx_ip = ip;
348 s_rx_iface = iface;
352 0,
353 (VOID*)s_rx_thread_stack,
359 if (t == TX_SUCCESS) {
360 s_rx_thread_made = 1U;
361 }
362}
363
377
378typedef enum : uint16_t {
382
403RA8_INTERNAL static void internal_dispatch_to_netx(NX_PACKET* pkt)
404{
405 if (pkt->nx_packet_length < (ULONG)k_nx_ra8_eth_hdr_bytes) {
406 (void)nx_packet_release(pkt);
407 return;
408 }
409 const UCHAR* p = (const UCHAR*)pkt->nx_packet_prepend_ptr;
410 const uint16_t et = (uint16_t)(((uint16_t)p[k_nx_ra8_eth_etype_off] << 8) |
411 (uint16_t)p[(uint16_t)k_nx_ra8_eth_etype_off + 1U]);
412 pkt->nx_packet_prepend_ptr = pkt->nx_packet_prepend_ptr + (ULONG)k_nx_ra8_eth_hdr_bytes;
413 pkt->nx_packet_length = pkt->nx_packet_length - (ULONG)k_nx_ra8_eth_hdr_bytes;
414 if (et == (uint16_t)k_nx_ra8_eth_ethertype_ipv4) {
415 _nx_ip_packet_deferred_receive(s_rx_ip, pkt);
416 return;
417 }
418#ifndef NX_DISABLE_IPV4
419 if (et == (uint16_t)k_nx_ra8_eth_ethertype_arp) {
420 _nx_arp_packet_deferred_receive(s_rx_ip, pkt);
421 return;
422 }
423 if (et == (uint16_t)k_nx_ra8_eth_ethertype_rarp) {
424 _nx_rarp_packet_deferred_receive(s_rx_ip, pkt);
425 return;
426 }
427#endif
428 (void)nx_packet_release(pkt);
429}
430
446{
447 NX_PACKET_POOL* pool = s_rx_ip->nx_ip_default_packet_pool;
448 if (pool == NX_NULL) {
449 return;
450 }
451 while (1) {
452 uint32_t got = 0U;
453 ra8_err_t err = ra8_eth_read(s_rx_staging, (uint32_t)sizeof(s_rx_staging), &got);
454 if (err != k_ra8_ok) {
455 break;
456 }
457 if (got == 0U) {
458 break;
459 }
460 NX_PACKET* pkt = NX_NULL;
461 UINT a = nx_packet_allocate(pool, &pkt, NX_RECEIVE_PACKET, NX_NO_WAIT);
462 if (a != NX_SUCCESS) {
463 continue;
464 }
465 if (pkt == NX_NULL) {
466 continue;
467 }
468 /* Slide prepend by 2 bytes so the IP header lands 4-byte aligned
469 * after the driver strips the 14-byte ethernet header. NetX's IP
470 * receive path word-accesses the IP header and silently drops
471 * misaligned frames on Cortex-M parts. */
472 pkt->nx_packet_prepend_ptr = pkt->nx_packet_prepend_ptr + 2U;
473 pkt->nx_packet_append_ptr = pkt->nx_packet_prepend_ptr;
474 UINT app = nx_packet_data_append(pkt, (VOID*)s_rx_staging, (ULONG)got, pool, (ULONG)NX_NO_WAIT);
475 if (app != NX_SUCCESS) {
476 (void)nx_packet_release(pkt);
477 continue;
478 }
479 pkt->nx_packet_ip_interface = s_rx_iface;
481 g_nx_ether_diag.rx_total += 1U;
482 }
483}
484
501{
502 (void)arg;
503 while (1) {
504 if (s_rx_ip != NX_NULL) {
505 if (s_ra8_eth_open != 0U) {
507 }
508 }
510 }
511}
512
513/* Pull the 6-byte MAC out of the NetX interface descriptor -- see implementation for details. */
514RA8_INTERNAL static void internal_unpack_mac(const NX_INTERFACE* iface, uint8_t* mac)
515{
516 ULONG msw = iface->nx_interface_physical_address_msw;
517 ULONG lsw = iface->nx_interface_physical_address_lsw;
528}
529
530/* Linearise a (possibly-chained) NX_PACKET into the staging buffer -- see implementation for details. */
531RA8_INTERNAL static UCHAR
532internal_packet_to_buffer(const NX_PACKET* packet, uint8_t* dst, uint32_t cap, uint32_t* out_len)
533{
534 uint32_t total = 0U;
535 const NX_PACKET* cur = packet;
536 while (cur != NX_NULL) {
537 const uint8_t* seg = (const uint8_t*)cur->nx_packet_prepend_ptr;
538 uint32_t seg_len = (uint32_t)(cur->nx_packet_append_ptr - cur->nx_packet_prepend_ptr);
539 if ((total + seg_len) > cap) {
540 return 0U;
541 }
542 /* Copy payload bytes into the linear staging buffer. */
543 (void)memcpy((void*)(dst + total), (const void*)seg, (size_t)seg_len);
544 total += seg_len;
545#ifndef NX_DISABLE_PACKET_CHAIN
546 cur = cur->nx_packet_next;
547#else
548 cur = NX_NULL;
549#endif
550 }
551 *out_len = total;
552 return 1U;
553}
554
555/* Handle ``NX_LINK_INITIALIZE``: capture MAC + open the NIC -- see implementation for details. */
556RA8_INTERNAL static void internal_handle_init(NX_IP_DRIVER* req)
557{
558 NX_INTERFACE* iface = req->nx_ip_driver_interface;
559 if (iface == NX_NULL) {
560 g_nx_ether_diag.init_iface_null_hits += 1U;
561 req->nx_ip_driver_status = NX_NOT_SUCCESSFUL;
562 return;
563 }
564 /* Prefer the app-supplied MAC from nx_ether_driver_ra8_eth_set_mac.
565 * If the app did not call it, fall back to the interface struct
566 * (typically zero during INITIALIZE -- nx_ip_create fires this
567 * callback BEFORE the app can call
568 * nx_ip_interface_physical_address_set). */
569 if (s_local_mac_user_set == 0U) {
571 }
572 /* Push the MAC into the interface struct so NetX subsystems that
573 * read it later (ARP, sender-MAC stamping) see the right value. */
574 {
575 ULONG msw =
578 ULONG lsw =
583 iface->nx_interface_physical_address_msw = msw;
584 iface->nx_interface_physical_address_lsw = lsw;
585 }
586
587 /* EK-RA8D2 wires its RJ45 to ETHA1 / RMAC1 -- channel 0 is unused
588 * on this board. Bench-confirmed: with channel=0 the GWCA goes
589 * to OPERATION and ra8_eth_open reports k_ra8_ok but the on-silicon
590 * MRGFCE/MTGFCE counters on RMAC1 stay zero because frames go to
591 * the unwired ETHA0/RMAC0 port instead. Issue #1 trail. */
592 ra8_eth_cfg_t cfg = {
593 .mac_address = {0U, 0U, 0U, 0U, 0U, 0U},
594 .channel = 1U,
595 .num_tx_descriptors = 0U,
596 .num_rx_descriptors = 0U,
597 .buffer_size = 0U,
598 };
599 (void)memcpy((void*)cfg.mac_address, (const void*)s_local_mac, (size_t)k_nx_ra8_eth_mac_len);
600
601 ra8_err_t err = ra8_eth_open(&cfg);
602 g_nx_ether_diag.init_ra8_eth_open_err = (uint32_t)err;
603 if (err != k_ra8_ok) {
604 req->nx_ip_driver_status = NX_NOT_SUCCESSFUL;
605 return;
606 }
607 s_ra8_eth_open = 1U;
608 /* Advertise NetX's framing capabilities for this interface. */
609 iface->nx_interface_ip_mtu_size = (ULONG)k_nx_ra8_eth_mtu;
610 iface->nx_interface_address_mapping_needed = NX_TRUE;
611
612 internal_spawn_rx_worker(req->nx_ip_driver_ptr, iface);
613 req->nx_ip_driver_status = NX_SUCCESS;
614}
615
616/* Handle ``NX_LINK_UNINITIALIZE``: close the NIC -- see implementation for details. */
617RA8_INTERNAL static void internal_handle_uninit(NX_IP_DRIVER* req)
618{
619 if (s_ra8_eth_open != 0U) {
620 (void)ra8_eth_close();
621 s_ra8_eth_open = 0U;
622 }
623 s_link_up = 0U;
624 req->nx_ip_driver_status = NX_SUCCESS;
625}
626
648{
649 if (cmd == NX_LINK_ARP_SEND) {
650 return (uint16_t)k_nx_ra8_eth_ethertype_arp;
651 }
652 if (cmd == NX_LINK_ARP_RESPONSE_SEND) {
653 return (uint16_t)k_nx_ra8_eth_ethertype_arp;
654 }
655 if (cmd == NX_LINK_RARP_SEND) {
656 return (uint16_t)k_nx_ra8_eth_ethertype_rarp;
657 }
658 return (uint16_t)k_nx_ra8_eth_ethertype_ipv4;
659}
660
681RA8_INTERNAL static void internal_handle_send(NX_IP_DRIVER* req)
682{
683 NX_PACKET* pkt = req->nx_ip_driver_packet;
684 if (pkt == NX_NULL || s_ra8_eth_open == 0U || s_link_up == 0U) {
685 if (pkt != NX_NULL) {
686 (void)nx_packet_transmit_release(pkt);
687 }
688 req->nx_ip_driver_status = NX_NOT_SUCCESSFUL;
689 return;
690 }
691
692 /* Build the 14-byte ethernet header in the staging buffer from the
693 * destination MAC NetX puts in nx_ip_driver_physical_address_msw/lsw,
694 * our local MAC, and the ethertype derived from the dispatch cmd.
695 * NetX hands the link driver the L3 payload only -- the header is
696 * the driver's responsibility (per `nx_arp_packet_send` and the
697 * reference NetX driver). */
698 const ULONG msw = req->nx_ip_driver_physical_address_msw;
699 const ULONG lsw = req->nx_ip_driver_physical_address_lsw;
700 const uint16_t et = internal_ethertype_for_cmd(req->nx_ip_driver_command);
718 (uint8_t)((et >> (uint16_t)k_nx_ra8_eth_msw_shift_byte0) & (uint16_t)k_nx_ra8_eth_byte_mask);
720
721 uint32_t body_len = 0U;
724 (uint32_t)sizeof(s_tx_staging) - (uint32_t)k_nx_ra8_eth_hdr_bytes,
725 &body_len) == 0U) {
726 (void)nx_packet_transmit_release(pkt);
727 req->nx_ip_driver_status = NX_NOT_SUCCESSFUL;
728 return;
729 }
730 uint32_t len = body_len + (uint32_t)k_nx_ra8_eth_hdr_bytes;
731
732 /* Pad runt frames up to the 802.3 minimum. */
733 if (len < (uint32_t)k_nx_ra8_eth_min_frame) {
734 (void)memset((void*)(s_tx_staging + len), 0, (size_t)((uint32_t)k_nx_ra8_eth_min_frame - len));
735 len = (uint32_t)k_nx_ra8_eth_min_frame;
736 }
737
739 (void)nx_packet_transmit_release(pkt);
740 req->nx_ip_driver_status = (err == k_ra8_ok) ? (UINT)NX_SUCCESS : (UINT)NX_NOT_SUCCESSFUL;
741}
742
764RA8_INTERNAL static void internal_handle_deferred_rx(NX_IP_DRIVER* req)
765{
766 NX_IP* ip_ptr = req->nx_ip_driver_ptr;
767 if (ip_ptr == NX_NULL || s_ra8_eth_open == 0U) {
768 req->nx_ip_driver_status = NX_NOT_SUCCESSFUL;
769 return;
770 }
771
772 /* The default packet pool lives off the IP control block; NetX
773 * expects RX-side allocation to come from it. */
774 NX_PACKET_POOL* pool = ip_ptr->nx_ip_default_packet_pool;
775 if (pool == NX_NULL) {
776 req->nx_ip_driver_status = NX_NOT_SUCCESSFUL;
777 return;
778 }
779
780 /* Drain the descriptor ring. ra8_eth_read returns k_ra8_err_no_data
781 * when the ring is empty -- that is the loop exit. */
782 while (1) {
783 uint32_t got = 0U;
784 ra8_err_t err = ra8_eth_read(s_rx_staging, (uint32_t)sizeof(s_rx_staging), &got);
785 if (err != k_ra8_ok || got == 0U) {
786 break;
787 }
788 NX_PACKET* pkt = NX_NULL;
789 UINT a = nx_packet_allocate(pool, &pkt, NX_RECEIVE_PACKET, NX_NO_WAIT);
790 if (a != NX_SUCCESS || pkt == NX_NULL) {
791 /* Packet pool exhausted; drop the frame and keep draining. */
792 continue;
793 }
794 /* Append the bytes (this also bumps nx_packet_length). */
795 UINT app = nx_packet_data_append(pkt, (VOID*)s_rx_staging, (ULONG)got, pool, (ULONG)NX_NO_WAIT);
796 if (app != NX_SUCCESS) {
797 (void)nx_packet_release(pkt);
798 continue;
799 }
800 pkt->nx_packet_ip_interface = req->nx_ip_driver_interface;
802 }
803 req->nx_ip_driver_status = NX_SUCCESS;
804}
805
806/* Handle ``NX_LINK_GET_STATUS``: report the PHY link bit -- see implementation for details. */
807RA8_INTERNAL static void internal_handle_get_status(NX_IP_DRIVER* req)
808{
809 if (req->nx_ip_driver_return_ptr == NX_NULL) {
810 req->nx_ip_driver_status = NX_NOT_SUCCESSFUL;
811 return;
812 }
813 ra8_eth_link_t link = {.link_up = 0U, .speed_mbps = 0U, .full_duplex = 0U, .bmsr = 0U};
814 if (s_ra8_eth_open == 0U) {
815 *(req->nx_ip_driver_return_ptr) = (ULONG)NX_FALSE;
816 req->nx_ip_driver_status = NX_SUCCESS;
817 return;
818 }
819 ra8_err_t err = ra8_eth_link_status(&link);
820 if (err != k_ra8_ok) {
821 *(req->nx_ip_driver_return_ptr) = (ULONG)NX_FALSE;
822 req->nx_ip_driver_status = NX_NOT_SUCCESSFUL;
823 return;
824 }
825 *(req->nx_ip_driver_return_ptr) = (link.link_up != 0U) ? (ULONG)NX_TRUE : (ULONG)NX_FALSE;
826 req->nx_ip_driver_status = NX_SUCCESS;
827}
828
851RA8_INTERNAL static void internal_set_link_state(NX_IP_DRIVER* driver_req, UCHAR link_up)
852{
853 s_link_up = link_up;
854 driver_req->nx_ip_driver_status = NX_SUCCESS;
855 if (driver_req->nx_ip_driver_interface != NX_NULL) {
856 driver_req->nx_ip_driver_interface->nx_interface_link_up = (link_up != 0U) ? NX_TRUE : NX_FALSE;
857 }
858}
859
860/* Nx ether driver ra eth -- see implementation for details. */
861void nx_ether_driver_ra8_eth(NX_IP_DRIVER* driver_req)
862{
863 /* NetX never invokes the driver with NULL but mirror the upstream
864 * nx_link reference driver and guard anyway. */
865 if (driver_req == NX_NULL) {
866 return;
867 }
868
869 g_nx_ether_diag.dispatch_total += 1U;
870 g_nx_ether_diag.last_cmd = (uint32_t)driver_req->nx_ip_driver_command;
871
872 switch (driver_req->nx_ip_driver_command) {
873 case NX_LINK_INITIALIZE:
874 g_nx_ether_diag.init_total += 1U;
875 internal_handle_init(driver_req);
876 g_nx_ether_diag.init_last_status = (uint32_t)driver_req->nx_ip_driver_status;
877 break;
878 case NX_LINK_ENABLE:
879 g_nx_ether_diag.enable_total += 1U;
880 g_nx_ether_diag.enable_last_link_up = 1U;
881 internal_set_link_state(driver_req, 1U);
882 break;
883 case NX_LINK_DISABLE:
884 g_nx_ether_diag.enable_last_link_up = 0U;
885 internal_set_link_state(driver_req, 0U);
886 break;
887 case NX_LINK_PACKET_SEND:
888 case NX_LINK_PACKET_BROADCAST:
889 case NX_LINK_ARP_SEND:
890 case NX_LINK_ARP_RESPONSE_SEND:
891 case NX_LINK_RARP_SEND:
892 g_nx_ether_diag.send_total += 1U;
893 internal_handle_send(driver_req);
894 g_nx_ether_diag.send_last_status = (uint32_t)driver_req->nx_ip_driver_status;
895 break;
896 case NX_LINK_DEFERRED_PROCESSING:
897 g_nx_ether_diag.rx_total += 1U;
898 internal_handle_deferred_rx(driver_req);
899 break;
900 case NX_LINK_GET_STATUS:
901 g_nx_ether_diag.status_total += 1U;
902 internal_handle_get_status(driver_req);
903 break;
904 case NX_LINK_UNINITIALIZE:
905 internal_handle_uninit(driver_req);
906 break;
907 case NX_LINK_MULTICAST_JOIN:
908 case NX_LINK_MULTICAST_LEAVE:
909 case NX_LINK_INTERFACE_ATTACH:
910 case NX_LINK_INTERFACE_DETACH:
911 case NX_LINK_SET_PHYSICAL_ADDRESS:
912 driver_req->nx_ip_driver_status = NX_SUCCESS;
913 break;
914 default:
915 driver_req->nx_ip_driver_status = NX_NOT_SUCCESSFUL;
916 break;
917 }
918}
static CHAR s_thread_name[]
Definition main.c:212
static uint8_t s_local_mac[k_nx_c6_mac_len]
Station MAC stamped on transmitted frames.
static void internal_rx_worker_entry(ULONG arg)
RX poll worker entry: pump the link so received frames reach NetX.
static uint8_t s_link_up
NX_LINK_ENABLE mirror.
static NX_INTERFACE * s_rx_iface
Interface the receive path tags frames with.
static NX_IP * s_rx_ip
IP the receive path pushes frames into.
static uint8_t s_tx_staging[k_nx_c6_max_frame]
Linear transmit frame buffer.
@ k_nx_ra8_eth_etype_off
Nx RA8 Ethernet etype off.
@ k_nx_ra8_eth_hdr_bytes
Nx RA8 Ethernet hdr bytes.
static void internal_handle_deferred_rx(NX_IP_DRIVER *req)
Handle NX_LINK_DEFERRED_PROCESSING: drain RX into NetX.
static void internal_rx_worker_entry(ULONG arg)
RX-poll worker entry.
nx_ra8_eth_worker_t
Sizing constants for the RX-poll worker thread.
@ k_nx_ra8_eth_worker_priority
Nx RA8 Ethernet worker priority.
@ k_nx_ra8_eth_worker_period_ticks
Nx RA8 Ethernet worker period ticks.
@ k_nx_ra8_eth_worker_stack_bytes
Nx RA8 Ethernet worker stack bytes.
static void internal_spawn_rx_worker(NX_IP *ip, NX_INTERFACE *iface)
Spawn the RX-poll worker thread once, idempotent.
static void internal_handle_get_status(NX_IP_DRIVER *req)
static void internal_handle_uninit(NX_IP_DRIVER *req)
nx_ra8_eth_ethertype_t
Ethernet II EtherType constants in host byte order.
@ k_nx_ra8_eth_ethertype_rarp
RARP frame.
@ k_nx_ra8_eth_ethertype_arp
ARP frame.
@ k_nx_ra8_eth_ethertype_ipv4
IPv4 frame.
@ k_nx_ra8_eth_ethertype_ipv6
IPv6 frame.
nx_ra8_eth_hdr_offset_t
Byte offsets of the fields in the 14-byte Ethernet header that internal_handle_send stages into s_tx_...
@ k_nx_ra8_eth_hdr_src_mac_byte3
Source MAC octet 3.
@ k_nx_ra8_eth_hdr_ethertype_lo
EtherType low octet.
@ k_nx_ra8_eth_hdr_ethertype_hi
EtherType high octet.
@ k_nx_ra8_eth_hdr_src_mac_byte1
Source MAC octet 1.
@ k_nx_ra8_eth_hdr_src_mac_byte4
Source MAC octet 4.
@ k_nx_ra8_eth_hdr_src_mac_byte5
Source MAC octet 5.
static void internal_set_link_state(NX_IP_DRIVER *driver_req, UCHAR link_up)
Apply an ENABLE/DISABLE state change to the link mirror and NetX iface.
nx_ra8_eth_constants_t
Compile-time constants for the NetX Duo <-> ra8_eth bridge.
@ k_nx_ra8_eth_max_frame
Largest 802.3 frame we forward.
@ k_nx_ra8_eth_mtu
Capped MTU.
@ k_nx_ra8_eth_min_frame
Smallest 802.3 frame.
@ k_nx_ra8_eth_phys_addr_len
Reported to NX_LINK_FACTORY_*.
@ k_nx_ra8_eth_phys_msw_shift
Bytes-per-byte shift for MAC msw.
@ k_nx_ra8_eth_mac_len
Length of an Ethernet MAC.
static void internal_rx_drain(void)
Drain the GWCA RX ring and push every frame into NetX.
static uint8_t s_rx_staging[k_nx_ra8_eth_max_frame]
Contiguous RX staging buffer.
static void internal_handle_send(NX_IP_DRIVER *req)
Handle NX_LINK_PACKET_SEND / ARP_SEND / ARP_RESPONSE_SEND / RARP_SEND.
nx_ra8_eth_byte_mask_t
Low-octet mask used when extracting bytes from packed words.
@ k_nx_ra8_eth_byte_mask
Keep the least-significant octet.
static uint8_t s_rx_thread_stack[k_nx_ra8_eth_worker_stack_bytes]
static void internal_handle_init(NX_IP_DRIVER *req)
nx_ra8_eth_mac_byte_idx_t
Indices into the local 6-byte MAC array.
@ k_nx_ra8_eth_mac_byte_2
Nx RA8 Ethernet MAC byte 2.
@ k_nx_ra8_eth_mac_byte_3
Nx RA8 Ethernet MAC byte 3.
@ k_nx_ra8_eth_mac_byte_4
Nx RA8 Ethernet MAC byte 4.
@ k_nx_ra8_eth_mac_byte_0
Nx RA8 Ethernet MAC byte 0.
@ k_nx_ra8_eth_mac_byte_5
Nx RA8 Ethernet MAC byte 5.
@ k_nx_ra8_eth_mac_byte_1
Nx RA8 Ethernet MAC byte 1.
static UCHAR s_ra8_eth_open
Latched flag: has ra8_eth_open been called for this interface?
static uint16_t internal_ethertype_for_cmd(UINT cmd)
Pick the ethernet ethertype for a NetX driver SEND command.
nx_ra8_eth_mac_word_shift_t
Bit shifts that pack the 6 MAC bytes into NetX's msw/lsw words.
@ k_nx_ra8_eth_lsw_shift_byte3
Nx RA8 Ethernet lsw shift byte3.
@ k_nx_ra8_eth_lsw_shift_byte2
Nx RA8 Ethernet lsw shift byte2.
@ k_nx_ra8_eth_lsw_shift_byte4
Nx RA8 Ethernet lsw shift byte4.
@ k_nx_ra8_eth_lsw_shift_byte5
Nx RA8 Ethernet lsw shift byte5.
@ k_nx_ra8_eth_msw_shift_byte0
Nx RA8 Ethernet msw shift byte0.
static UCHAR internal_packet_to_buffer(const NX_PACKET *packet, uint8_t *dst, uint32_t cap, uint32_t *out_len)
static uint8_t s_rx_thread_made
void nx_ether_driver_ra8_eth_set_mac(const uint8_t mac[6])
Install the local MAC address used by the driver at NX_LINK_INITIALIZE.
static void internal_dispatch_to_netx(NX_PACKET *pkt)
Dispatch a received frame into NetX by ethertype.
static TX_THREAD s_rx_thread
void nx_ether_driver_ra8_eth(NX_IP_DRIVER *driver_req)
NetX Duo network-driver entry point bridging onto ra8_eth_*.
static uint8_t s_local_mac_user_set
Flag indicating whether the app supplied a MAC via the pre-init seam.
volatile nx_ether_diag_t g_nx_ether_diag
Diagnostic counters readable via JLink.
static void internal_unpack_mac(const NX_INTERFACE *iface, uint8_t *mac)
NetX Duo network driver shim that bridges onto the RA8 ra8_eth HAL.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Ethernet Switch Module (ESWM) + frame TX/RX driver.
ra8_err_t ra8_eth_close(void)
Close the NIC: gate clocks and idle the descriptor rings.
Definition ra8_eth.c:799
ra8_err_t ra8_eth_write(const uint8_t *buf, uint32_t len)
Transmit a frame through the GWCA TX queue.
Definition ra8_eth.c:825
ra8_err_t ra8_eth_link_status(ra8_eth_link_t *out_status)
Query the PHY link state via MIIM (RMAC MDIO Clause-22).
ra8_err_t ra8_eth_open(const ra8_eth_cfg_t *cfg)
Open the NIC: bring up the controller stack and the descriptor rings.
Definition ra8_eth.c:756
ra8_err_t ra8_eth_read(uint8_t *buf, uint32_t max_len, uint32_t *got_len)
Pop the next received frame from the RX descriptor ring.
Definition ra8_eth.c:845
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
unsigned int UINT
ThreadX-compatible unsigned int (host stub).
#define TX_SUCCESS
#define tx_thread_create
#define tx_thread_sleep
#define TX_NO_TIME_SLICE
char CHAR
ThreadX-compatible CHAR (host stub).
#define TX_AUTO_START
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
Opaque thread stand-in for the host build.
Bench-readable diagnostic counters for the NetX link driver.
uint32_t send_last_status
Last NetX status internal_handle_send set.
uint32_t last_cmd
Most recent driver command code.
uint32_t rx_total
NX_LINK_DEFERRED_PROCESSING dispatches.
uint32_t enable_last_link_up
1 = last set_link_state was UP.
uint32_t init_iface_null_hits
Times INITIALIZE saw a NULL interface.
uint32_t init_total
NX_LINK_INITIALIZE dispatches.
uint32_t enable_total
NX_LINK_ENABLE dispatches.
uint32_t init_ra8_eth_open_err
Last ra8_eth_open return code.
uint32_t send_total
NX_LINK_PACKET_SEND/_BROADCAST dispatches.
uint32_t init_last_status
Last NetX status internal_handle_init set.
uint32_t dispatch_total
total dispatches into the driver.
uint32_t status_total
NX_LINK_GET_STATUS dispatches.
Per-channel NIC configuration.
Definition ra8_eth.h:228
uint8_t mac_address[6]
Local MAC address (octets 0..5).
Definition ra8_eth.h:229