Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

radios: Remove default radio flags from init #10355

Closed
Closed
2 changes: 1 addition & 1 deletion cpu/cc2538/radio/cc2538_rf.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static const init_pair_t init_table[] = {
{&RFCORE_XREG_CSPT, 0xff },
{&RFCORE_XREG_MDMCTRL0, 0x85 },
{&RFCORE_XREG_FSCTRL, 0x55 },
{&RFCORE_XREG_FRMCTRL0, AUTOCRC | AUTOACK },
{&RFCORE_XREG_FRMCTRL0, AUTOCRC },
{&RFCORE_XREG_FRMCTRL1, 0x00 },
{&RFCORE_XREG_SRCMATCH, 0x00 },
{&RFCORE_XREG_FIFOPCTRL, CC2538_RF_MAX_DATA_LEN },
Expand Down
7 changes: 0 additions & 7 deletions drivers/at86rf2xx/at86rf2xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ void at86rf2xx_reset(at86rf2xx_t *dev)
at86rf2xx_set_chan(dev, AT86RF2XX_DEFAULT_CHANNEL);
/* set default TX power */
at86rf2xx_set_txpower(dev, AT86RF2XX_DEFAULT_TXPOWER);
/* set default options */
at86rf2xx_set_option(dev, AT86RF2XX_OPT_AUTOACK, true);
at86rf2xx_set_option(dev, AT86RF2XX_OPT_CSMA, true);

static const netopt_enable_t enable = NETOPT_ENABLE;
netdev_ieee802154_set(&dev->netdev, NETOPT_ACK_REQ,
&enable, sizeof(enable));

/* enable safe mode (protect RX FIFO until reading data starts) */
at86rf2xx_reg_write(dev, AT86RF2XX_REG__TRX_CTRL_2,
Expand Down
4 changes: 0 additions & 4 deletions drivers/cc2420/cc2420.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ int cc2420_init(cc2420_t *dev)
cc2420_set_chan(dev, CC2420_CHAN_DEFAULT);
cc2420_set_txpower(dev, CC2420_TXPOWER_DEFAULT);

/* set default options */
cc2420_set_option(dev, CC2420_OPT_AUTOACK, true);
cc2420_set_option(dev, CC2420_OPT_CSMA, true);

/* change default RX bandpass filter to 1.3uA (as recommended) */
reg = cc2420_reg_read(dev, CC2420_REG_RXCTRL1);
reg |= CC2420_RXCTRL1_RXBPF_LOCUR;
Expand Down
2 changes: 0 additions & 2 deletions drivers/kw2xrf/kw2xrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ void kw2xrf_reset_phy(kw2xrf_t *dev)

kw2xrf_set_rx_watermark(dev, 1);

kw2xrf_set_option(dev, KW2XRF_OPT_AUTOACK, true);
kw2xrf_set_option(dev, KW2XRF_OPT_ACK_REQ, true);
kw2xrf_set_option(dev, KW2XRF_OPT_AUTOCCA, true);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the AUTOCCA flag here as it has a slightly different meaning than the CSMA netopt. It also has its own netopt option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative could be to try setting csma first, and if that fails, try to set autocca. What do you think of this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment the kw2xrf is the only radio using the NETOPT_AUTOCCA option, so I'd rather leave it to a follow up PR if we want this change.

I was thinking, if we combine this CCA feature with some exponential back off timer, we effectively have CSMA right? Would this be something that we want to have for this radio?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can copy the behavior from kw41zrf. I did exactly what you describe in order to provide csma for that radio.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone else will have to provide the PR. I don't have the hardware and have no interest in the kw2xdrf

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone else will have to provide the PR. I don't have the hardware and have no interest in the kw2xdrf

Same for me to be honest

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we're all short in time but we (HAW Hamburg) have certain interest in that radio so it might be us to do the follow-up. @gebart, @bergzand could you please open a feature request issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PeterKietzmann I opened #10364 as a reminder


kw2xrf_set_power_mode(dev, KW2XRF_AUTODOZE);
Expand Down
2 changes: 0 additions & 2 deletions drivers/mrf24j40/mrf24j40.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ void mrf24j40_reset(mrf24j40_t *dev)
/* set default options */
mrf24j40_set_option(dev, IEEE802154_FCF_PAN_COMP, true);
mrf24j40_set_option(dev, NETDEV_IEEE802154_SRC_MODE_LONG, true);
mrf24j40_set_option(dev, NETDEV_IEEE802154_ACK_REQ, true);
mrf24j40_set_option(dev, MRF24J40_OPT_CSMA, true);

/* go into RX state */
mrf24j40_reset_tasks(dev);
Expand Down
19 changes: 19 additions & 0 deletions pkg/emb6/contrib/netdev/emb6_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "msg.h"
#include "net/netdev.h"
#include "net/ieee802154.h"

#include "evproc.h"
#include "emb6.h"
Expand Down Expand Up @@ -116,6 +117,24 @@ static void _configure_netdev(void)
if (res < 0) {
DEBUG("emb6: enable NETOPT_RX_END_IRQ failed: %d\n", res);
}
if (IEEE802154_DEFAULT_ENABLE_ACK_REQ) {
res = _dev->driver->set(_dev, NETOPT_ACK_REQ, &enable, sizeof(enable));
if (res < 0) {
DEBUG("gnrc_netif: enable ACK requests failed: %d\n", res);
}
}
if (IEEE802154_DEFAULT_ENABLE_AUTOACK) {
res = _dev->driver->set(_dev, NETOPT_AUTOACK, &enable, sizeof(enable));
if (res < 0) {
DEBUG("gnrc_netif: enable auto ACK failed: %d\n", res);
}
}
if (IEEE802154_DEFAULT_ENABLE_CSMA) {
res = _dev->driver->set(_dev, NETOPT_CSMA, &enable, sizeof(enable));
if (res < 0) {
DEBUG("gnrc_netif: enable CSMA failed: %d\n", res);
}
}
}

int emb6_netdev_setup(netdev_t *dev)
Expand Down
27 changes: 27 additions & 0 deletions pkg/lwip/contrib/netdev/lwip_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,31 @@ static err_t _ieee802154_link_output(struct netif *netif, struct pbuf *p);
static void _event_cb(netdev_t *dev, netdev_event_t event);
static void *_event_loop(void *arg);

#ifdef MODULE_LWIP_SIXLOWPAN
static void _configure_netdev_802154(netdev_t *dev)
{
static const netopt_enable_t enable = NETOPT_ENABLE;
if (IEEE802154_DEFAULT_ENABLE_ACK_REQ) {
int res = dev->driver->set(dev, NETOPT_ACK_REQ, &enable, sizeof(enable));
if (res < 0) {
DEBUG("gnrc_netif: enable ACK requests failed: %d\n", res);
}
}
if (IEEE802154_DEFAULT_ENABLE_AUTOACK) {
int res = dev->driver->set(dev, NETOPT_AUTOACK, &enable, sizeof(enable));
if (res < 0) {
DEBUG("gnrc_netif: enable auto ACK failed: %d\n", res);
}
}
if (IEEE802154_DEFAULT_ENABLE_CSMA) {
int res = dev->driver->set(dev, NETOPT_CSMA, &enable, sizeof(enable));
if (res < 0) {
DEBUG("gnrc_netif: enable CSMA failed: %d\n", res);
}
}
}
#endif /* MODULE_LWIP_SIXLOWPAN */

static void _configure_netdev(netdev_t *dev)
{
/* Enable RX-complete interrupts */
Expand Down Expand Up @@ -132,6 +157,8 @@ err_t lwip_netdev_init(struct netif *netif)
{
u16_t val;
ip6_addr_t *addr;

_configure_netdev_802154(netdev);
if (netdev->driver->get(netdev, NETOPT_NID, &val,
sizeof(val)) < 0) {
return ERR_IF;
Expand Down
24 changes: 24 additions & 0 deletions pkg/openthread/contrib/netdev/openthread_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@ void otTaskletsSignalPending(otInstance *aInstance) {
(void) aInstance;
}

static void _configure_netdev_ieee802154(netdev_t *dev)
{
static const netopt_enable_t enable = NETOPT_ENABLE;

/* Always enable ACK_REQ and AUTOACK for Openthread */
int res = dev->driver->set(dev, NETOPT_ACK_REQ, &enable, sizeof(enable));
if (res < 0) {
DEBUG("gnrc_netif: enable ACK requests failed: %d\n", res);
}
res = dev->driver->set(dev, NETOPT_AUTOACK, &enable, sizeof(enable));
if (res < 0) {
DEBUG("gnrc_netif: enable auto ACK failed: %d\n", res);
}

if (IEEE802154_DEFAULT_ENABLE_CSMA) {
int res = dev->driver->set(dev, NETOPT_CSMA, &enable, sizeof(enable));
if (res < 0) {
DEBUG("gnrc_netif: enable CSMA failed: %d\n", res);
}
}
}

static void *_openthread_event_loop(void *arg) {
(void)arg;
_pid = thread_getpid();
Expand Down Expand Up @@ -170,6 +192,8 @@ int openthread_netdev_init(char *stack, int stacksize, char priority,
netdev->driver->set(netdev, NETOPT_TX_END_IRQ, &enable, sizeof(enable));
netdev->driver->set(netdev, NETOPT_RX_END_IRQ, &enable, sizeof(enable));

_configure_netdev_ieee802154(netdev);

_pid = thread_create(stack, stacksize,
priority, THREAD_CREATE_STACKTEST,
_openthread_event_loop, NULL, name);
Expand Down
12 changes: 12 additions & 0 deletions sys/include/net/ieee802154.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ extern const uint8_t ieee802154_addr_bcast[IEEE802154_ADDR_BCAST_LEN];
#ifndef IEEE802154_DEFAULT_TXPOWER
#define IEEE802154_DEFAULT_TXPOWER (0) /* in dBm */
#endif

#ifndef IEEE802154_DEFAULT_ENABLE_ACK_REQ
#define IEEE802154_DEFAULT_ENABLE_ACK_REQ (1)
#endif

#ifndef IEEE802154_DEFAULT_ENABLE_AUTOACK
#define IEEE802154_DEFAULT_ENABLE_AUTOACK (1)
#endif

#ifndef IEEE802154_DEFAULT_ENABLE_CSMA
#define IEEE802154_DEFAULT_ENABLE_CSMA (1)
#endif
/** @} */

/**
Expand Down
27 changes: 27 additions & 0 deletions sys/net/gnrc/netif/gnrc_netif_ieee802154.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
#endif

#ifdef MODULE_NETDEV_IEEE802154
static void _init(gnrc_netif_t *netif);
static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt);
static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif);

static const gnrc_netif_ops_t ieee802154_ops = {
.init = _init,
.send = _send,
.recv = _recv,
.get = gnrc_netif_get_from_netdev,
Expand Down Expand Up @@ -74,6 +76,31 @@ static gnrc_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
return snip;
}

static void _init(gnrc_netif_t *netif)
{
/* Enable compile time default settings in the driver */
static const netopt_enable_t enable = NETOPT_ENABLE;
netdev_t *dev = netif->dev;
if (IEEE802154_DEFAULT_ENABLE_ACK_REQ) {
int res = dev->driver->set(dev, NETOPT_ACK_REQ, &enable, sizeof(enable));
if (res < 0) {
DEBUG("gnrc_netif: enable ACK requests failed: %d\n", res);
}
}
if (IEEE802154_DEFAULT_ENABLE_AUTOACK) {
int res = dev->driver->set(dev, NETOPT_AUTOACK, &enable, sizeof(enable));
if (res < 0) {
DEBUG("gnrc_netif: enable auto ACK failed: %d\n", res);
}
}
if (IEEE802154_DEFAULT_ENABLE_CSMA) {
int res = dev->driver->set(dev, NETOPT_CSMA, &enable, sizeof(enable));
if (res < 0) {
DEBUG("gnrc_netif: enable CSMA failed: %d\n", res);
}
}
}

static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
{
netdev_t *dev = netif->dev;
Expand Down