Skip to content

Commit c8e5c49

Browse files
committed
Decouple from Ethernet, introduce "l2"
1 parent c129897 commit c8e5c49

File tree

48 files changed

+1863
-973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1863
-973
lines changed

mongoose.c

Lines changed: 825 additions & 424 deletions
Large diffs are not rendered by default.

mongoose.h

Lines changed: 108 additions & 59 deletions
Large diffs are not rendered by default.

src/drivers/cmsis.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ static bool cmsis_init(struct mg_tcpip_if *ifp) {
3535
mac->PowerControl(ARM_POWER_FULL);
3636
if (cap.mac_address) { // driver provides MAC address
3737
mac->GetMacAddress(&addr);
38-
memcpy(ifp->mac, &addr, sizeof(ifp->mac));
38+
memcpy(ifp->l2addr.mac, &addr, sizeof(ifp->l2addr.mac));
3939
} else { // we provide MAC address
40-
memcpy(&addr, ifp->mac, sizeof(addr));
40+
memcpy(&addr, ifp->l2addr.mac, sizeof(addr));
4141
mac->SetMacAddress(&addr);
4242
}
4343
phy->PowerControl(ARM_POWER_FULL);

src/drivers/cyw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static bool mg_tcpip_driver_cyw_init(struct mg_tcpip_if *ifp) {
4343
s_mask = ifp->mask;
4444
s_link = s_auth = s_join = false;
4545
ifp->pfn = wifi_cb;
46-
if (!cyw_init(ifp->mac)) return false;
46+
if (!cyw_init(ifp->l2addr.mac)) return false;
4747

4848
if (wifi->apmode) {
4949
return mg_wifi_ap_start(wifi);

src/drivers/cyw.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ struct mg_tcpip_driver_cyw_data {
3939
mif_.driver = &mg_tcpip_driver_cyw; \
4040
mif_.driver_data = &driver_data_; \
4141
mif_.recv_queue.size = 8192; \
42-
mif_.mac[0] = 2; /* MAC read from OTP at driver init */ \
42+
mif_.l2addr.mac[0] = 2; /* MAC read from OTP at driver init */ \
4343
mg_tcpip_init(mgr, &mif_); \
44-
MG_INFO(("Driver: cyw, MAC: %M", mg_print_mac, mif_.mac)); \
44+
MG_INFO(("Driver: cyw, MAC: %M", mg_print_mac, mif_.l2addr.mac)); \
4545
} while (0)
4646

4747
#endif

src/drivers/imxrt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ static bool mg_tcpip_driver_imxrt_init(struct mg_tcpip_if *ifp) {
109109
ENET->TDSR = (uint32_t) (uintptr_t) s_txdesc;
110110
ENET->MRBR[0] = ETH_PKT_SIZE; // Same size for RX/TX buffers
111111
// MAC address filtering (bytes in reversed order)
112-
ENET->PAUR = ((uint32_t) ifp->mac[4] << 24U) | (uint32_t) ifp->mac[5] << 16U;
113-
ENET->PALR = (uint32_t) (ifp->mac[0] << 24U) |
114-
((uint32_t) ifp->mac[1] << 16U) |
115-
((uint32_t) ifp->mac[2] << 8U) | ifp->mac[3];
112+
ENET->PAUR = ((uint32_t) ifp->l2addr.mac[4] << 24U) | (uint32_t) ifp->l2addr.mac[5] << 16U;
113+
ENET->PALR = (uint32_t) (ifp->l2addr.mac[0] << 24U) |
114+
((uint32_t) ifp->l2addr.mac[1] << 16U) |
115+
((uint32_t) ifp->l2addr.mac[2] << 8U) | ifp->l2addr.mac[3];
116116
ENET->ECR = MG_BIT(8) | MG_BIT(1); // Little-endian CPU, Enable
117117
ENET->EIMR = MG_BIT(25); // Set interrupt mask
118118
ENET->RDAR = MG_BIT(24); // Receive Descriptors have changed

src/drivers/imxrt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ struct mg_tcpip_driver_imxrt_data {
4141
mif_.gw = MG_TCPIP_GW; \
4242
mif_.driver = &mg_tcpip_driver_imxrt; \
4343
mif_.driver_data = &driver_data_; \
44-
MG_SET_MAC_ADDRESS(mif_.mac); \
44+
MG_SET_MAC_ADDRESS(mif_.l2addr.mac); \
4545
mg_tcpip_init(mgr, &mif_); \
46-
MG_INFO(("Driver: imxrt, MAC: %M", mg_print_mac, mif_.mac)); \
46+
MG_INFO(("Driver: imxrt, MAC: %M", mg_print_mac, mif_.l2addr.mac)); \
4747
} while (0)
4848

4949
#endif

src/drivers/nxp_wifi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ struct mg_tcpip_driver_nxp_wifi_data {
2020
mif_.driver = &mg_tcpip_driver_nxp_wifi; \
2121
mif_.driver_data = &driver_data_; \
2222
mif_.recv_queue.size = 8192; \
23-
mif_.mac[0] = 2; /* MAC read from OTP at driver init */ \
23+
mif_.l2addr.mac[0] = 2; /* MAC read from OTP at driver init */ \
2424
mg_tcpip_init(mgr, &mif_); \
25-
MG_INFO(("Driver: nxp wifi, MAC: %M", mg_print_mac, mif_.mac)); \
25+
MG_INFO(("Driver: nxp wifi, MAC: %M", mg_print_mac, mif_.l2addr.mac)); \
2626
} while (0)
2727

2828
#endif

src/drivers/pico-w.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ static bool mg_tcpip_driver_pico_w_init(struct mg_tcpip_if *ifp) {
3535
return false; // initialize async_context and WiFi chip
3636
if (wifi->apmode && wifi->apssid != NULL) {
3737
if (!mg_wifi_ap_start(wifi)) return false;
38-
cyw43_wifi_get_mac(&cyw43_state, CYW43_ITF_STA, ifp->mac); // same MAC
38+
cyw43_wifi_get_mac(&cyw43_state, CYW43_ITF_STA, ifp->l2addr.mac); // same MAC
3939
} else {
4040
cyw43_arch_enable_sta_mode();
41-
cyw43_wifi_get_mac(&cyw43_state, CYW43_ITF_STA, ifp->mac);
41+
cyw43_wifi_get_mac(&cyw43_state, CYW43_ITF_STA, ifp->l2addr.mac);
4242
if (wifi->ssid != NULL) {
4343
return mg_wifi_connect(wifi);
4444
} else {

src/drivers/pico-w.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ struct mg_tcpip_driver_pico_w_data {
2222
mif_.driver = &mg_tcpip_driver_pico_w; \
2323
mif_.driver_data = &driver_data_; \
2424
mif_.recv_queue.size = 8192; \
25-
mif_.mac[0] = 2; /* MAC read from OTP at driver init */ \
25+
mif_.l2addr.mac[0] = 2; /* MAC read from OTP at driver init */ \
2626
mg_tcpip_init(mgr, &mif_); \
27-
MG_INFO(("Driver: pico-w, MAC: %M", mg_print_mac, mif_.mac)); \
27+
MG_INFO(("Driver: pico-w, MAC: %M", mg_print_mac, mif_.l2addr.mac)); \
2828
} while (0)
2929

3030
#endif

0 commit comments

Comments
 (0)