From f3a9b8c83daff43cab4d4166768d0c5b98829276 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Fri, 19 Nov 2021 10:59:55 +0100 Subject: [PATCH] net: l2: Add symbols for custom IEEE802154 L2 Define a custom IEEE802154 based L2. The user can then use those symbols to implement their own 802.15.4 based L2, based on those symbols, w/o a need to modify the Zephyr tree. Signed-off-by: Robert Lubos --- drivers/ieee802154/ieee802154_nrf5.c | 6 +++++- include/net/net_l2.h | 8 ++++++++ subsys/net/l2/Kconfig | 13 +++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/ieee802154/ieee802154_nrf5.c b/drivers/ieee802154/ieee802154_nrf5.c index 83b620cfc91..fbf74d351b9 100644 --- a/drivers/ieee802154/ieee802154_nrf5.c +++ b/drivers/ieee802154/ieee802154_nrf5.c @@ -1080,9 +1080,13 @@ static struct ieee802154_radio_api nrf5_radio_api = { #define L2 OPENTHREAD_L2 #define L2_CTX_TYPE NET_L2_GET_CTX_TYPE(OPENTHREAD_L2) #define MTU 1280 +#elif defined(CONFIG_NET_L2_CUSTOM_IEEE802154) +#define L2 CUSTOM_IEEE802154_L2 +#define L2_CTX_TYPE NET_L2_GET_CTX_TYPE(CUSTOM_IEEE802154_L2) +#define MTU CONFIG_NET_L2_CUSTOM_IEEE802154_MTU #endif -#if defined(CONFIG_NET_L2_IEEE802154) || defined(CONFIG_NET_L2_OPENTHREAD) +#if defined(CONFIG_NET_L2_PHY_IEEE802154) NET_DEVICE_INIT(nrf5_154_radio, CONFIG_IEEE802154_NRF5_DRV_NAME, nrf5_init, NULL, &nrf5_data, &nrf5_radio_cfg, CONFIG_IEEE802154_NRF5_INIT_PRIO, diff --git a/include/net/net_l2.h b/include/net/net_l2.h index 515249f0be2..6af004b5ac4 100644 --- a/include/net/net_l2.h +++ b/include/net/net_l2.h @@ -132,6 +132,14 @@ NET_L2_DECLARE_PUBLIC(CANBUS_RAW_L2); NET_L2_DECLARE_PUBLIC(CANBUS_L2); #endif /* CONFIG_NET_L2_CANBUS */ +#ifdef CONFIG_NET_L2_CUSTOM_IEEE802154 +#ifndef CUSTOM_IEEE802154_L2 +#define CUSTOM_IEEE802154_L2 CUSTOM_IEEE802154 +#endif +#define CUSTOM_IEEE802154_L2_CTX_TYPE void* +NET_L2_DECLARE_PUBLIC(CUSTOM_IEEE802154_L2); +#endif /* CONFIG_NET_L2_CUSTOM_IEEE802154 */ + #define NET_L2_INIT(_name, _recv_fn, _send_fn, _enable_fn, _get_flags_fn) \ const STRUCT_SECTION_ITERABLE(net_l2, \ NET_L2_GET_NAME(_name)) = { \ diff --git a/subsys/net/l2/Kconfig b/subsys/net/l2/Kconfig index afa522dac17..03455efb237 100644 --- a/subsys/net/l2/Kconfig +++ b/subsys/net/l2/Kconfig @@ -81,6 +81,19 @@ source "subsys/net/l2/ieee802154/Kconfig" source "subsys/net/l2/openthread/Kconfig" +config NET_L2_CUSTOM_IEEE802154 + bool "Enable custom IEEE802154 L2" + select NET_L2_PHY_IEEE802154 + help + Enable custom IEEE802154 based L2. Zephyr does not provide + implementation for this L2 - users can implement their own L2 using + this symbols, on top of the IEEE802154 radio driver. + +config NET_L2_CUSTOM_IEEE802154_MTU + int "MTU for the custom IEEE802154 L2" + depends on NET_L2_CUSTOM_IEEE802154 + default 127 + source "subsys/net/l2/canbus/Kconfig" config NET_L2_WIFI_MGMT