Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,6 @@ include $(RIOTMAKE)/toolchain/$(TOOLCHAIN).inc.mk
# For more information, see http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
export CCACHE_CPP2=yes

# get number of interfaces straight before resolving dependencies
GNRC_NETIF_NUMOF ?= 1

ifneq ($(GNRC_NETIF_NUMOF),1)
CFLAGS += -DGNRC_NETIF_NUMOF=$(GNRC_NETIF_NUMOF)
endif

# handle removal of default modules
USEMODULE += $(filter-out $(DISABLE_MODULE), $(DEFAULT_MODULE))

Expand Down
4 changes: 3 additions & 1 deletion cpu/esp32/esp-eth/esp_eth_gnrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "esp_eth_netdev.h"
#include "net/gnrc/netif/ethernet.h"

static gnrc_netif_t _netif;

/** the only ESP32 Ethernet MAC (EMAC) device */
extern esp_eth_netdev_t _esp_eth_dev;

Expand All @@ -34,7 +36,7 @@ extern void esp_eth_setup(esp_eth_netdev_t* dev);
void auto_init_esp_eth(void)
{
esp_eth_setup(&_esp_eth_dev);
gnrc_netif_ethernet_create(_esp_eth_stack, ESP_ETH_STACKSIZE, ESP_ETH_PRIO,
gnrc_netif_ethernet_create(&_netif, _esp_eth_stack, ESP_ETH_STACKSIZE, ESP_ETH_PRIO,
"netif-esp-eth", (netdev_t *)&_esp_eth_dev);
}

Expand Down
9 changes: 5 additions & 4 deletions cpu/esp_common/esp-now/esp_now_gnrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,15 @@ static const gnrc_netif_ops_t _esp_now_ops = {
.set = gnrc_netif_set_from_netdev,
};

gnrc_netif_t *gnrc_netif_esp_now_create(char *stack, int stacksize, char priority,
char *name, netdev_t *dev)
int gnrc_netif_esp_now_create(gnrc_netif_t *netif, char *stack, int stacksize, char priority,
char *name, netdev_t *dev)
{
return gnrc_netif_create(stack, stacksize, priority, name, dev, &_esp_now_ops);
return gnrc_netif_create(netif, stack, stacksize, priority, name, dev, &_esp_now_ops);
}

/* device thread stack */
static char _esp_now_stack[ESP_NOW_STACKSIZE];
static gnrc_netif_t _netif;

void auto_init_esp_now(void)
{
Expand All @@ -212,7 +213,7 @@ void auto_init_esp_now(void)
if (!esp_now_dev) {
LOG_ERROR("[auto_init_netif] error initializing esp_now\n");
} else {
gnrc_netif_esp_now_create(_esp_now_stack, sizeof(_esp_now_stack),
gnrc_netif_esp_now_create(&_netif, _esp_now_stack, sizeof(_esp_now_stack),
ESP_NOW_PRIO,
"netif-esp-now",
&esp_now_dev->netdev);
Expand Down
8 changes: 6 additions & 2 deletions cpu/esp_common/esp-now/esp_now_gnrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ extern "C" {
/**
* @brief Creates the ESP-NOW network interface
* @see gnrc_netif_create
* @param [in] netif The interface. May not be `NULL`.
* @param [in] stack The stack for the network interface's thread.
* @param [in] stacksize Size of stack.
* @param [in] priority Priority for the network interface's thread.
* @param [in] name Name for the network interface. May be NULL.
* @param [in] dev Device for the interface.
*
* @return 0 on success
* @return negative number on error
*/
gnrc_netif_t *gnrc_netif_esp_now_create(char *stack, int stacksize, char priority,
char *name, netdev_t *dev);
int gnrc_netif_esp_now_create(gnrc_netif_t *netif, char *stack, int stacksize, char priority,
char *name, netdev_t *dev);

#ifdef __cplusplus
}
Expand Down
12 changes: 7 additions & 5 deletions cpu/esp_common/esp-wifi/esp_wifi_gnrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "esp_wifi_params.h"
#include "esp_wifi_netdev.h"

static gnrc_netif_t _netif;

/** the only ESP WiFi device */
extern esp_wifi_netdev_t _esp_wifi_dev;

Expand All @@ -36,14 +38,14 @@ extern void esp_wifi_setup (esp_wifi_netdev_t* dev);
void auto_init_esp_wifi (void)
{
esp_wifi_setup(&_esp_wifi_dev);
gnrc_netif_ethernet_create(_esp_wifi_stack, ESP_WIFI_STACKSIZE,
gnrc_netif_ethernet_create(&_netif, _esp_wifi_stack, ESP_WIFI_STACKSIZE,
#ifdef MODULE_ESP_NOW
ESP_WIFI_PRIO - 1,
ESP_WIFI_PRIO - 1,
#else
ESP_WIFI_PRIO,
ESP_WIFI_PRIO,
#endif
"netif-esp-wifi",
(netdev_t *)&_esp_wifi_dev);
"netif-esp-wifi",
(netdev_t *)&_esp_wifi_dev);
}

#else /* defined(MODULE_ESP_WIFI) && defined(MODULE_GNRC_NETIF_ETHERNET) */
Expand Down
3 changes: 2 additions & 1 deletion cpu/nrf5x_common/radio/nrfmin/nrfmin_gnrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
* @brief Allocate the stack for the GNRC netdev thread to run in
*/
static char stack[NRFMIN_GNRC_STACKSIZE];
static gnrc_netif_t _netif;

static int hdr_netif_to_nrfmin(nrfmin_hdr_t *nrfmin, gnrc_pktsnip_t *pkt)
{
Expand Down Expand Up @@ -184,6 +185,6 @@ void gnrc_nrfmin_init(void)
{
/* setup the NRFMIN driver */
nrfmin_setup();
gnrc_netif_create(stack, sizeof(stack), NRFMIN_GNRC_THREAD_PRIO, "nrfmin",
gnrc_netif_create(&_netif, stack, sizeof(stack), NRFMIN_GNRC_THREAD_PRIO, "nrfmin",
(netdev_t *)&nrfmin_dev, &gnrc_nrfmin_ops);
}
1 change: 0 additions & 1 deletion dist/tools/ethos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
To use, add

#
GNRC_NETIF_NUMOF := 2
USEMODULE += stdio_ethos gnrc_netdev
CFLAGS += '-DETHOS_UART=UART_DEV(0)' -DETHOS_BAUDRATE=115200

Expand Down
7 changes: 3 additions & 4 deletions drivers/cc1xxx_common/gnrc_netif_cc1xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,9 @@ static const gnrc_netif_ops_t cc1xxx_netif_ops = {
.set = gnrc_netif_set_from_netdev,
};

gnrc_netif_t *gnrc_netif_cc1xxx_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev)
int gnrc_netif_cc1xxx_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev)
{
return gnrc_netif_create(stack, stacksize, priority, name,
return gnrc_netif_create(netif, stack, stacksize, priority, name,
dev, &cc1xxx_netif_ops);
}
9 changes: 5 additions & 4 deletions drivers/include/cc1xxx_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ typedef struct netdev_radio_rx_info cc1xxx_rx_info_t;
/**
* @brief Creates a CC110x/CC1200 network interface
*
* @param[in] netif The interface. May not be `NULL`.
* @param[in] stack The stack for the network interface's thread.
* @param[in] stacksize Size of @p stack.
* @param[in] priority Priority for the network interface's thread.
Expand All @@ -123,11 +124,11 @@ typedef struct netdev_radio_rx_info cc1xxx_rx_info_t;
*
* @see @ref gnrc_netif_create()
*
* @return The network interface on success.
* @return 0 on success
* @return negative number on error
*/
gnrc_netif_t *gnrc_netif_cc1xxx_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev);
int gnrc_netif_cc1xxx_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev);

#ifdef __cplusplus
}
Expand Down
7 changes: 3 additions & 4 deletions drivers/xbee/gnrc_xbee.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,9 @@ static const gnrc_netif_ops_t _xbee_ops = {
.set = gnrc_netif_set_from_netdev,
};

gnrc_netif_t *gnrc_netif_xbee_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev)
int gnrc_netif_xbee_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev)
{
return gnrc_netif_create(stack, stacksize, priority, name,
return gnrc_netif_create(netif, stack, stacksize, priority, name,
dev, &_xbee_ops);
}
20 changes: 17 additions & 3 deletions drivers/xbee/include/gnrc_netif_xbee.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,23 @@
extern "C" {
#endif

gnrc_netif_t *gnrc_netif_xbee_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev);
/**
* @brief Creates an Xbee network interface
*
* @param[in] netif The interface. May not be `NULL`.
* @param[in] stack The stack for the network interface's thread.
* @param[in] stacksize Size of @p stack.
* @param[in] priority Priority for the network interface's thread.
* @param[in] name Name for the network interface. May be NULL.
* @param[in] dev Device for the interface.
*
* @see @ref gnrc_netif_create()
*
* @return 0 on success
* @return negative number on error
*/
int gnrc_netif_xbee_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev);

#ifdef __cplusplus
}
Expand Down
1 change: 0 additions & 1 deletion examples/gcoap/Makefile.slip
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ ifeq (,$(SLIP_BAUDRATE))
SLIP_BAUDRATE=115200
endif

GNRC_NETIF_NUMOF := 2
CFLAGS += -DSLIPDEV_PARAM_UART=$(SLIP_UART)
CFLAGS += -DSLIPDEV_PARAM_BAUDRATE=$(SLIP_BAUDRATE)

Expand Down
3 changes: 0 additions & 3 deletions examples/gnrc_border_router/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ else
USEMODULE += gnrc_uhcpc
endif

# Use two network interfaces
GNRC_NETIF_NUMOF := 2

# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
Expand Down
1 change: 0 additions & 1 deletion examples/gnrc_border_router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ has the following:

```make
ifeq (,$(filter native,$(BOARD)))
GNRC_NETIF_NUMOF := 2
USEMODULE += stdio_ethos
CFLAGS += '-DETHOS_UART=UART_DEV(0)' -DETHOS_BAUDRATE=115200
FEATURES_REQUIRED += periph_uart
Expand Down
4 changes: 4 additions & 0 deletions examples/gnrc_minimal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ CFLAGS += -DGNRC_PKTBUF_SIZE=512 -DCONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF=2 \
-DGNRC_NETIF_IPV6_GROUPS_NUMOF=2 -DGNRC_IPV6_NIB_NUMOF=1 \
-DGNRC_IPV6_NIB_OFFL_NUMOF=1 # be able to configure at least one route

# Enable single interface optimization. Set to 0 if more than one interface is
# present
CFLAGS += -DGNRC_NETIF_SINGLE=1

# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

Expand Down
1 change: 0 additions & 1 deletion examples/suit_update/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ CFLAGS += -DSUIT_MANIFEST_RESOURCE=\"$(SUIT_COAP_ROOT)/$(SUIT_NOTIFY_MANIFEST)\"
USE_ETHOS ?= 1

ifeq (1,$(USE_ETHOS))
GNRC_NETIF_NUMOF := 2
USEMODULE += stdio_ethos
USEMODULE += gnrc_uhcpc

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From 50b6cbc4acc9715626b55e838c3b317f6a891286 Mon Sep 17 00:00:00 2001
From: Jose Alamos <[email protected]>
Date: Wed, 25 Mar 2020 11:07:29 +0100
Subject: [PATCH] ccnl_core: add MAX_GNRC_NETIFS macro

---
src/ccnl-core/include/ccnl-defs.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/ccnl-core/include/ccnl-defs.h b/src/ccnl-core/include/ccnl-defs.h
index 879bbcfb..93d5af4b 100644
--- a/src/ccnl-core/include/ccnl-defs.h
+++ b/src/ccnl-core/include/ccnl-defs.h
@@ -36,10 +36,15 @@
/* assuming that all broadcast addresses consist of a sequence of equal octets */
#define CCNL_BROADCAST_OCTET 0xFF

+/* By default use only one GNRC interface */
+#ifndef MAX_GNRC_NETIFS
+#define MAX_GNRC_NETIFS (1)
+#endif
+
#if defined(CCNL_ARDUINO) || defined(CCNL_RIOT)
# if defined(CCNL_RIOT)
# include "net/gnrc/netif.h"
-# define CCNL_MAX_INTERFACES GNRC_NETIF_NUMOF
+# define CCNL_MAX_INTERFACES MAX_GNRC_NETIFS
# else
# define CCNL_MAX_INTERFACES 1
# endif
--
2.25.0

59 changes: 59 additions & 0 deletions pkg/ndn-riot/patches/0002-add-max-gnrc-netifs-macros.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
From 43da6ef67dea118695d6b1dd2542ce1f199956e8 Mon Sep 17 00:00:00 2001
From: Jose Alamos <[email protected]>
Date: Tue, 24 Mar 2020 14:29:26 +0100
Subject: [PATCH] ndn-riot: add MAX_GNRC_NETIFS macro

---
netif.c | 6 +++---
netif.h | 7 +++++++
2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/netif.c b/netif.c
index 5e24c6d..7e3edb9 100644
--- a/netif.c
+++ b/netif.c
@@ -29,12 +29,12 @@
#include <random.h>
#include <thread.h>

-static ndn_netif_t _netif_table[GNRC_NETIF_NUMOF];
+static ndn_netif_t _netif_table[MAX_GNRC_NETIFS];

void ndn_netif_auto_add(void)
{
/* initialize the netif table entry */
- for (int i = 0; i < GNRC_NETIF_NUMOF; ++i) {
+ for (int i = 0; i < MAX_GNRC_NETIFS; ++i) {
_netif_table[i].iface = KERNEL_PID_UNDEF;
}

@@ -99,7 +99,7 @@ static ndn_netif_t* _ndn_netif_find(kernel_pid_t iface)
{
if (iface == KERNEL_PID_UNDEF) return NULL;

- for (int i = 0; i < GNRC_NETIF_NUMOF; ++i) {
+ for (int i = 0; i < MAX_GNRC_NETIFS; ++i) {
if (_netif_table[i].iface == iface)
return &_netif_table[i];
}
diff --git a/netif.h b/netif.h
index 1e7fbdc..2175858 100644
--- a/netif.h
+++ b/netif.h
@@ -24,6 +24,13 @@

#include "encoding/block.h"

+/**
+ * @brief Max number of GNRC network interfaces
+ */
+#ifndef MAX_GNRC_NETIFS
+#define MAX_GNRC_NETIFS (1)
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
--
2.25.0

3 changes: 2 additions & 1 deletion pkg/nimble/netif/nimble_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ static int _on_gap_slave_evt(struct ble_gap_event *event, void *arg)
return 0;
}

static gnrc_netif_t _netif;
void nimble_netif_init(void)
{
int res;
Expand All @@ -537,7 +538,7 @@ void nimble_netif_init(void)
assert(res == 0);
(void)res;

gnrc_netif_create(_stack, sizeof(_stack), GNRC_NETIF_PRIO,
gnrc_netif_create(&_netif, _stack, sizeof(_stack), GNRC_NETIF_PRIO,
"nimble_netif", &_nimble_netdev_dummy, &_nimble_netif_ops);
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/nordic_softdevice_ble/src/gnrc_nordic_ble_6lowpan.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
static char _stack[(THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE)];

static gnrc_netif_t *_ble_netif = NULL;
static gnrc_netif_t _netif;

static uint8_t _sendbuf[BLE_SIXLOWPAN_MTU];

Expand Down Expand Up @@ -281,6 +282,6 @@ static netdev_t _ble_dummy_dev = {

void gnrc_nordic_ble_6lowpan_init(void)
{
gnrc_netif_create(_stack, sizeof(_stack), BLE_PRIO,
gnrc_netif_create(&_netif, _stack, sizeof(_stack), BLE_PRIO,
"ble", &_ble_dummy_dev, &_ble_ops);
}
Loading