ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
c6_join_net.c File Reference

NetX Duo IP bring-up over the C6 link: DHCP lease + ICMP reachability. More...

#include <stdint.h>
#include <string.h>
#include "c6_join.h"
#include "nx_api.h"
#include "nx_ether_driver_c6.h"
#include "nxd_dhcp_client.h"
#include "ra8_c6link.h"
#include "ra8_err.h"
#include "tx_api.h"
Include dependency graph for c6_join_net.c:

Go to the source code of this file.

Enumerations

enum  c6_join_net_size_t : uint32_t {
  k_c6_join_pkt_payload = 1568U ,
  k_c6_join_pool_bytes = 40960U ,
  k_c6_join_ip_stack = 2048U ,
  k_c6_join_arp_bytes = 1040U ,
  k_c6_join_ip_prio = 3U ,
  k_c6_join_ping_len = 12U
}
 Static sizing for the NetX Duo objects this app owns. More...

Functions

static UINT priv_net_create_ip (void)
static UINT priv_net_dhcp (c6_join_lease_t *out)
static bool priv_net_ping (uint32_t gateway)
ra8_err_t c6_join_net_up (ra8_c6link_t *link, const ra8_c6link_mac_t *mac, c6_join_lease_t *out)
 Bring the IP layer up over the associated C6 link and prove traffic.

Variables

static NX_PACKET_POOL s_pool
 NetX packet pool control block.
static uint8_t s_pool_mem [k_c6_join_pool_bytes]
 Packet-pool backing store.
static NX_IP s_ip
 NetX IP instance driven over the C6 link.
static uint8_t s_ip_stack [k_c6_join_ip_stack]
 NetX IP helper-thread stack.
static uint8_t s_arp_cache [k_c6_join_arp_bytes]
 ARP cache backing store.
static NX_DHCP s_dhcp
 NetX DHCP client control block.
static char s_ping_payload [k_c6_join_ping_len] = "ra8-c6-ping"
 Fixed ICMP echo payload.
static CHAR s_pool_name [] = "c6_join_pool"
 Mutable pool name (NetX takes CHAR*).
static CHAR s_ip_name [] = "c6_join_ip"
 Mutable IP-instance name.
static CHAR s_dhcp_name [] = "c6_join_dhcp"
 Mutable DHCP-client name.

Detailed Description

NetX Duo IP bring-up over the C6 link: DHCP lease + ICMP reachability.

Tag
[Ring 6 / APP] {World: S}

Implements c6_join_net_up. Once the C6 station has associated, this creates the NetX Duo packet pool and IP instance on top of nx_ether_driver_c6, enables ARP / UDP / ICMP, runs the vendored DHCP client to a bound lease, and pings the leased gateway. All of it is the host side of the stack: the C6 is a pure L2 bridge, so DHCP, ARP and ICMP are answered by the RA8, not the co-processor.

The heavy NetX objects are file-scope statics because this image has no heap (NASA Power of 10 Rule 3). c6_join_net_up runs exactly once, on the application worker thread.

Since
0.1.0

Definition in file c6_join_net.c.

Enumeration Type Documentation

◆ c6_join_net_size_t

enum c6_join_net_size_t : uint32_t

Static sizing for the NetX Duo objects this app owns.

Sized for full 1514-octet Ethernet frames plus DHCP and ICMP working set, with a comfortable packet count so a DHCP retransmit never starves ARP.

Invariant
k_c6_join_pkt_payload is at least a full Ethernet frame plus the two-octet alignment slide the driver applies.
k_c6_join_pool_bytes holds several k_c6_join_pkt_payload packets.
Example:
static uint8_t pool[k_c6_join_pool_bytes];
@ k_c6_join_pool_bytes
Packet-pool backing store, in octets.
Definition c6_join_net.c:53
See also
c6_join_net_up
Since
0.1.0
Enumerator
k_c6_join_pkt_payload 

Per-packet payload, in octets.

k_c6_join_pool_bytes 

Packet-pool backing store, in octets.

k_c6_join_ip_stack 

NetX IP helper-thread stack, in octets.

k_c6_join_arp_bytes 

ARP cache backing store, in octets.

k_c6_join_ip_prio 

NetX IP helper-thread priority.

k_c6_join_ping_len 

ICMP echo payload length, in octets.

Definition at line 51 of file c6_join_net.c.

Function Documentation

◆ c6_join_net_up()

ra8_err_t c6_join_net_up ( ra8_c6link_t * link,
const ra8_c6link_mac_t * mac,
c6_join_lease_t * out )

Bring the IP layer up over the associated C6 link and prove traffic.

Binds nx_ether_driver_c6 to link, hands it the station MAC, creates the NetX Duo packet pool and IP instance, enables ARP / UDP / ICMP, runs the DHCP client to a bound lease, then pings the gateway. It performs no ra8_c6link calls itself after nx_ip_create – from that point the driver's RX worker owns the wire – so the caller must not poll the link directly once this runs.

Parameters
[in]linkOpen, associated C6 link handle; must be non-null.
[in]macStation MAC read with ra8_c6link_wifi_mac; must be non-null.
[out]outLease and reachability result; must be non-null.
Returns
ra8_err_t Error code.
Return values
k_ra8_okA lease was obtained; out->ping_ok reports reachability.
k_ra8_err_null_ptrlink, mac or out was null.
k_ra8_err_not_initializedA NetX object could not be created.
k_ra8_err_timeoutNo DHCP lease arrived within the budget.
Precondition
The station has associated (k_ra8_c6link_event_sta_connected seen).
The ThreadX kernel is running and NetX has been system-initialised.
Postcondition
On success out holds a non-zero address; on failure out is cleared.
After this returns the C6 link is owned by the driver's RX worker.
Note
Not thread-safe; runs once on the application worker thread.
Warning
Blocks up to k_c6_join_dhcp_wait_ms waiting for the lease.
Example:
c6_join_lease_t lease = {};
(void)c6_join_net_up(&s_link, &mac, &lease);
static ra8_c6link_t s_link
Definition c6_cam_app.c:44
ra8_err_t c6_join_net_up(ra8_c6link_t *link, const ra8_c6link_mac_t *mac, c6_join_lease_t *out)
Bring the IP layer up over the associated C6 link and prove traffic.
struct c6_join_lease c6_join_lease_t
See also
nx_ether_driver_c6
Since
0.1.0

Definition at line 173 of file c6_join_net.c.

References c6_join_lease::gateway, k_ra8_err_not_initialized, k_ra8_err_null_ptr, k_ra8_err_timeout, k_ra8_ok, nx_ether_driver_c6_bind(), nx_ether_driver_c6_set_mac(), ra8_c6link_mac::octet, c6_join_lease::ping_ok, priv_net_create_ip(), priv_net_dhcp(), and priv_net_ping().

Referenced by c6_join_phase_ip().

◆ priv_net_create_ip()

UINT priv_net_create_ip ( void )
static

◆ priv_net_dhcp()

◆ priv_net_ping()

bool priv_net_ping ( uint32_t gateway)
static

Variable Documentation

◆ s_arp_cache

uint8_t s_arp_cache[k_c6_join_arp_bytes]
static

ARP cache backing store.

Since
0.1.0

Definition at line 69 of file c6_join_net.c.

◆ s_dhcp

NX_DHCP s_dhcp
static

NetX DHCP client control block.

Since
0.1.0

Definition at line 71 of file c6_join_net.c.

◆ s_dhcp_name

CHAR s_dhcp_name[] = "c6_join_dhcp"
static

Mutable DHCP-client name.

Since
0.1.0

Definition at line 79 of file c6_join_net.c.

◆ s_ip

NX_IP s_ip
static

NetX IP instance driven over the C6 link.

Since
0.1.0

Definition at line 65 of file c6_join_net.c.

◆ s_ip_name

CHAR s_ip_name[] = "c6_join_ip"
static

Mutable IP-instance name.

Since
0.1.0

Definition at line 77 of file c6_join_net.c.

◆ s_ip_stack

uint8_t s_ip_stack[k_c6_join_ip_stack]
static

NetX IP helper-thread stack.

Since
0.1.0

Definition at line 67 of file c6_join_net.c.

◆ s_ping_payload

char s_ping_payload[k_c6_join_ping_len] = "ra8-c6-ping"
static

Fixed ICMP echo payload.

Since
0.1.0

Definition at line 73 of file c6_join_net.c.

Referenced by priv_net_ping().

◆ s_pool

NX_PACKET_POOL s_pool
static

NetX packet pool control block.

Since
0.1.0

Definition at line 61 of file c6_join_net.c.

◆ s_pool_mem

uint8_t s_pool_mem[k_c6_join_pool_bytes]
static

Packet-pool backing store.

Since
0.1.0

Definition at line 63 of file c6_join_net.c.

◆ s_pool_name

CHAR s_pool_name[] = "c6_join_pool"
static

Mutable pool name (NetX takes CHAR*).

Since
0.1.0

Definition at line 75 of file c6_join_net.c.