1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

gnrc_netif: remove GNRC_NETIF_NUMOF macro

This commit is contained in:
Jose Alamos 2019-12-19 19:32:26 +01:00
parent 67ed9defbe
commit e451570219
21 changed files with 19 additions and 65 deletions

View File

@ -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))

View File

@ -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

View File

@ -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)

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -284,7 +284,7 @@ unsigned gnrc_netif_numof(void);
*/
static inline bool gnrc_netif_highlander(void)
{
return (GNRC_NETIF_NUMOF == 1);
return IS_ACTIVE(GNRC_NETIF_SINGLE);
}
/**

View File

@ -29,16 +29,6 @@
extern "C" {
#endif
/**
* @brief Maximum number of network interfaces
*
* @note Intentionally not calling it `GNRC_NETIF_NUMOF` to not require
* rewrites throughout the stack.
*/
#ifndef GNRC_NETIF_NUMOF
#define GNRC_NETIF_NUMOF (1)
#endif
/**
* @brief Default priority for network interface threads
*/

View File

@ -32,11 +32,12 @@
* Auto-Initialization
* -------------------
*
* If the application defines only one interface (`GNRC_NETIF_NUMOF == 1`),
* then RPL will be initialized on this interface.
* If the application defines only one interface (@ref gnrc_netif_highlander()
* returns true), then RPL will be initialized on this interface.
*
* If the application defines several interfaces (`GNRC_NETIF_NUMOF > 1`),
* then RPL will be initialized on the interface `GNRC_RPL_DEFAULT_NETIF`.
* If the application defines several interfaces (@ref gnrc_netif_highlander()
* returns false), then RPL will be initialized on the interface
* `GNRC_RPL_DEFAULT_NETIF`.
* Your application is responsible for setting `GNRC_RPL_DEFAULT_NETIF` to a
* valid interface PID, e.g. via `CFLAGS`.
*
@ -69,7 +70,7 @@
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* - Set interface for auto-initialization if more than one
* interface exists (`GNRC_NETIF_NUMOF > 1`)
* interface exists (@ref gnrc_netif_highlander() returns false)
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk}
* CFLAGS += -DGNRC_RPL_DEFAULT_NETIF=6
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -314,7 +314,7 @@
*
* sock_udp_ep_t remote;
* remote.port = DTLS_DEFAULT_PORT;
* remote.netif = gnrc_netif_iter(NULL)->pid; // only if GNRC_NETIF_NUMOF == 1
* remote.netif = gnrc_netif_iter(NULL)->pid; // only if gnrc_netif_highlander() returns true
*
* sock_dtls_t dtls_sock;
* sock_dtls_session_t session;
@ -380,7 +380,7 @@
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.c}
* sock_udp_ep_t remote;
* remote.port = DTLS_DEFAULT_PORT;
* remote.netif = gnrc_netif_iter(NULL)->pid; // only if GNRC_NETIF_NUMOF == 1
* remote.netif = gnrc_netif_iter(NULL)->pid; // only if gnrc_netif_highlander() returns true
*
* if (!ipv6_addr_from_str((ipv6_addr_t *)remote.addr.ipv6, SERVER_ADDR)) {
* puts("Error parsing destination address");

View File

@ -39,29 +39,21 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
static gnrc_netif_t _netifs[GNRC_NETIF_NUMOF];
static void _update_l2addr_from_dev(gnrc_netif_t *netif);
static void _configure_netdev(netdev_t *dev);
static void *_gnrc_netif_thread(void *args);
static void _event_cb(netdev_t *dev, netdev_event_t event);
int gnrc_netif_create(gnrc_netif_t *netif, char *stack, int stacksize, char priority,
const char *name, netdev_t *netdev,
const gnrc_netif_ops_t *ops)
const char *name, netdev_t *netdev, const gnrc_netif_ops_t *ops)
{
gnrc_netif_t *netif = NULL;
int res;
for (int i = 0; i < GNRC_NETIF_NUMOF; i++) {
if (_netifs[i].dev == netdev) {
return &_netifs[i];
}
if ((netif == NULL) && (_netifs[i].ops == NULL)) {
netif = &_netifs[i];
}
if (IS_ACTIVE(DEVELHELP) && IS_ACTIVE(GNRC_NETIF_SINGLE) && netif_iter(NULL)) {
LOG_WARNING("gnrc_netif: GNRC_NETIF_SINGLE set but more than one "
"interface is being registered.");
assert(netif_iter(NULL) == NULL);
}
assert(netif != NULL);
rmutex_init(&netif->mutex);
netif->ops = ops;
netif_register((netif_t*) netif);

View File

@ -35,13 +35,6 @@
#include "at86rf215.h"
#include "at86rf215_params.h"
/* If we don't have enough NETIFs configured, disable the sub-GHz band */
#if (GNRC_NETIF_NUMOF == 1) && IS_USED(MODULE_AT86RF215_SUBGHZ) && IS_USED(MODULE_AT86RF215_24GHZ)
#undef MODULE_AT86RF215_SUBGHZ
#undef USED_BANDS
#define USED_BANDS 1
#endif
/**
* @brief Define stack parameters for the MAC layer thread
* @{

View File

@ -371,7 +371,7 @@ static void _print_reply(_ping_data_t *data, gnrc_pktsnip_t *icmpv6,
data->num_recv++;
dupmsg += 7;
}
if ((GNRC_NETIF_NUMOF == 1) || (if_pid == KERNEL_PID_UNDEF) ||
if (gnrc_netif_highlander() || (if_pid == KERNEL_PID_UNDEF) ||
!ipv6_addr_is_link_local(from)) {
printf("%u bytes from %s: icmp_seq=%u ttl=%u",
(unsigned)icmpv6->size,

View File

@ -8,7 +8,6 @@ USEMODULE += ps
# the radio driver to test
USEMODULE += at86rf215
GNRC_NETIF_NUMOF ?= 2
# gnrc is a meta module including all required, basic gnrc networking modules
USEMODULE += gnrc

View File

@ -2,7 +2,6 @@ DEVELHELP := 1
include $(CURDIR)/../Makefile.tests_common
export TAP ?= tap0
GNRC_NETIF_NUMOF := 2
USEMODULE += auto_init_gnrc_netif
USEMODULE += gnrc_dhcpv6_client_6lbr

View File

@ -19,7 +19,6 @@ endif
USEMODULE += auto_init_gnrc_netif
# add dummy interface to test forwarding to smaller MTU
USEMODULE += netdev_test
GNRC_NETIF_NUMOF := 2
# Specify the mandatory networking modules for IPv6
USEMODULE += gnrc_ipv6_router_default
USEMODULE += gnrc_icmpv6_error

View File

@ -15,7 +15,6 @@ USEMODULE += od
CFLAGS += -DGNRC_IPV6_NIB_CONF_ARSM=0
CFLAGS += -DGNRC_IPV6_NIB_CONF_SLAAC=0
CFLAGS += -DGNRC_IPV6_NIB_CONF_NO_RTR_SOL=1
CFLAGS += -DGNRC_NETIF_NUMOF=4
CFLAGS += -DGNRC_NETIF_ADDRS_NUMOF=16
CFLAGS += -DGNRC_NETIF_GROUPS_NUMOF=8
CFLAGS += -DLOG_LEVEL=LOG_NONE

View File

@ -25,7 +25,7 @@
#include "od.h"
#include "test_utils/expect.h"
static netdev_test_t _devs[GNRC_NETIF_NUMOF];
static netdev_test_t _devs[NETIF_NUMOF];
netdev_t *ethernet_dev = (netdev_t *)&_devs[0];
netdev_t *ieee802154_dev = (netdev_t *)&_devs[1];
@ -179,7 +179,7 @@ void _tests_init(void)
_get_netdev_proto);
netdev_test_set_get_cb((netdev_test_t *)ieee802154_dev,
NETOPT_MAX_PDU_SIZE, _get_netdev_max_packet_size);
for (intptr_t i = SPECIAL_DEVS; i < GNRC_NETIF_NUMOF; i++) {
for (intptr_t i = SPECIAL_DEVS; i < NETIF_NUMOF; i++) {
devs[i - SPECIAL_DEVS] = (netdev_t *)&_devs[i];
netdev_test_setup(&_devs[i], (void *)i);
netdev_test_set_get_cb(&_devs[i], NETOPT_DEVICE_TYPE,

View File

@ -26,8 +26,9 @@
extern "C" {
#endif
#define NETIF_NUMOF (4)
#define SPECIAL_DEVS (2)
#define DEFAULT_DEVS_NUMOF (GNRC_NETIF_NUMOF - SPECIAL_DEVS)
#define DEFAULT_DEVS_NUMOF (NETIF_NUMOF - SPECIAL_DEVS)
#define GP1 (0x20U)
#define GP2 (0x01U)

View File

@ -28,8 +28,6 @@ USEMODULE += shell_commands
# boards
LOW_MEMORY_BOARDS := nucleo-f334r8
GNRC_NETIF_NUMOF := 2
# uncomment these to use ethos
#USEMODULE += stdio_ethos gnrc_uhcpc
#

View File

@ -9,9 +9,6 @@ USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
# Increase the number of network interfaces in case the board under test also provides a network interface
CFLAGS += -DGNRC_NETIF_NUMOF=2
# USB device vendor and product ID
# pid.codes test VID/PID, not globally unique
DEFAULT_VID = 1209