Skip to content

Commit a349c11

Browse files
author
Mika Leppänen
committed
Updated VK_RZ_A1H mac for lwip 2.0 and IPv6.
1 parent c61973c commit a349c11

File tree

1 file changed

+40
-24
lines changed
  • features/net/FEATURE_IPV4/lwip-interface/lwip-eth/arch/TARGET_VK_RZ_A1H

1 file changed

+40
-24
lines changed

features/net/FEATURE_IPV4/lwip-interface/lwip-eth/arch/TARGET_VK_RZ_A1H/rza1_emac.c

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "lwip/opt.h"
22
#include "lwip/tcpip.h"
33
#include "netif/etharp.h"
4+
#include "lwip/ethip6.h"
45
#include "mbed_interface.h"
56
#include "ethernet_api.h"
67
#include "ethernetext_api.h"
@@ -15,13 +16,17 @@ static sys_sem_t recv_ready_sem; /* receive ready semaphore */
1516
/* function */
1617
static void rza1_recv_task(void *arg);
1718
static void rza1_phy_task(void *arg);
18-
static err_t rza1_etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr);
19+
#if LWIP_IPV4
20+
static err_t rza1_etharp_output_ipv4(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr);
21+
#endif
22+
#if LWIP_IPV6
23+
static err_t rza1_etharp_output_ipv6(struct netif *netif, struct pbuf *q, const ip6_addr_t *ipaddr);
24+
#endif
1925
static err_t rza1_low_level_output(struct netif *netif, struct pbuf *p);
2026
static void rza1_recv_callback(void);
2127

2228
static void rza1_recv_task(void *arg) {
2329
struct netif *netif = (struct netif*)arg;
24-
struct eth_hdr *ethhdr;
2530
u16_t recv_size;
2631
struct pbuf *p;
2732
int cnt;
@@ -34,24 +39,10 @@ static void rza1_recv_task(void *arg) {
3439
p = pbuf_alloc(PBUF_RAW, recv_size, PBUF_RAM);
3540
if (p != NULL) {
3641
(void)ethernet_read((char *)p->payload, p->len);
37-
ethhdr = p->payload;
38-
switch (htons(ethhdr->type)) {
39-
case ETHTYPE_IP:
40-
case ETHTYPE_ARP:
41-
#if PPPOE_SUPPORT
42-
case ETHTYPE_PPPOEDISC:
43-
case ETHTYPE_PPPOE:
44-
#endif /* PPPOE_SUPPORT */
45-
/* full packet send to tcpip_thread to process */
46-
if (netif->input(p, netif) != ERR_OK) {
47-
/* Free buffer */
48-
pbuf_free(p);
49-
}
50-
break;
51-
default:
52-
/* Return buffer */
53-
pbuf_free(p);
54-
break;
42+
/* full packet send to tcpip_thread to process */
43+
if (netif->input(p, netif) != ERR_OK) {
44+
/* Free buffer */
45+
pbuf_free(p);
5546
}
5647
}
5748
} else {
@@ -94,14 +85,27 @@ static void rza1_phy_task(void *arg) {
9485
}
9586
}
9687

97-
static err_t rza1_etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr) {
88+
#if LWIP_IPV4
89+
static err_t rza1_etharp_output_ipv4(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr) {
9890
/* Only send packet is link is up */
9991
if (netif->flags & NETIF_FLAG_LINK_UP) {
10092
return etharp_output(netif, q, ipaddr);
10193
}
10294

10395
return ERR_CONN;
10496
}
97+
#endif
98+
99+
#if LWIP_IPV6
100+
static err_t rza1_etharp_output_ipv6(struct netif *netif, struct pbuf *q, const ip6_addr_t *ipaddr) {
101+
/* Only send packet is link is up */
102+
if (netif->flags & NETIF_FLAG_LINK_UP) {
103+
return ethip6_output(netif, q, ipaddr);
104+
}
105+
106+
return ERR_CONN;
107+
}
108+
#endif
105109

106110
static err_t rza1_low_level_output(struct netif *netif, struct pbuf *p) {
107111
struct pbuf *q;
@@ -150,13 +154,19 @@ err_t eth_arch_enetif_init(struct netif *netif)
150154
#else
151155
mbed_mac_address((char *)netif->hwaddr);
152156
#endif
153-
netif->hwaddr_len = ETHARP_HWADDR_LEN;
157+
netif->hwaddr_len = ETH_HWADDR_LEN;
154158

155159
/* maximum transfer unit */
156160
netif->mtu = 1500;
157161

158162
/* device capabilities */
159-
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP;
163+
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET;
164+
#ifdef LWIP_IGMP
165+
netif->flags |= NETIF_FLAG_IGMP;
166+
#endif
167+
#if LWIP_IPV6_MLD
168+
netif->flags |= NETIF_FLAG_MLD6;
169+
#endif
160170

161171
#if LWIP_NETIF_HOSTNAME
162172
/* Initialize interface hostname */
@@ -166,7 +176,13 @@ err_t eth_arch_enetif_init(struct netif *netif)
166176
netif->name[0] = 'e';
167177
netif->name[1] = 'n';
168178

169-
netif->output = rza1_etharp_output;
179+
#if LWIP_IPV4
180+
netif->output = rza1_etharp_output_ipv4;
181+
#endif
182+
#if LWIP_IPV6
183+
netif->output_ip6 = rza1_etharp_output_ipv6;
184+
#endif
185+
170186
netif->linkoutput = rza1_low_level_output;
171187

172188
/* Initialize the hardware */

0 commit comments

Comments
 (0)