gnrc_lwmac: port to gnrc_netif2#7895
gnrc_lwmac: port to gnrc_netif2#7895miri64 merged 1 commit intoRIOT-OS:gnrc_netif2_integration/masterfrom
Conversation
|
@miri64 Hi, Martine, can I bother you for help correcting the initialization? I get a wrong idea about it. |
sys/include/net/gnrc/lwmac/lwmac.h
Outdated
| const char *name, gnrc_netdev_t *dev); | ||
| gnrc_netif2_t *gnrc_lwmac_init(char *stack, int stacksize, char priority, | ||
| const char *name, netdev_t *dev, | ||
| const gnrc_netif2_ops_t *ops); |
There was a problem hiding this comment.
The ops-parameter shouldn't be needed here (just use a static definition in your c-file)
sys/include/net/gnrc/netif2/mac.h
Outdated
| * support on-chip CSMA and this flag is set for requiring CSMA transmission, | ||
| * then, the device will run software CSMA using `csma_sender` APIs. | ||
| */ | ||
| #define GNRC_NETDEV_MAC_INFO_CSMA_ENABLED (0x0100U) |
There was a problem hiding this comment.
For all: GNRC_NETIF2 instead of GNRC_NETDEV ;-)
sys/include/net/gnrc/netif2.h
Outdated
| netif->mac.mac_info &= ~GNRC_NETDEV_MAC_INFO_TX_FEEDBACK_MASK; | ||
| netif->mac.mac_info |= (uint16_t)(txf & GNRC_NETDEV_MAC_INFO_TX_FEEDBACK_MASK); | ||
| } | ||
| #endif |
There was a problem hiding this comment.
These function belong into the net/gnrc/mac/mac.h header.
| _update_l2addr_from_dev(netif); | ||
| } | ||
|
|
||
| ////////netif2 |
| netif->mac.lwmac.system_start_time_ticks = rtt_get_counter(); | ||
| netif->mac.lwmac.last_radio_on_time_ticks = netif->mac.lwmac.system_start_time_ticks; | ||
| netif->mac.lwmac.awake_duration_sum_ticks = 0; | ||
| netif->mac.lwmac.lwmac_info |= GNRC_LWMAC_RADIO_IS_ON; |
There was a problem hiding this comment.
All of the lwmac-related code can go into gnrc_netif2_ops_t::init() so you don't need the thread anymore.
There was a problem hiding this comment.
Hi, Martine, what do you mean I don't need the thread anymore? Do you mean, (after I implemented ops-parameters with LwMAC features), there will be no LwMAC thread anymore (and there will be only the thread that created in sys/net/gnrc/netif2/gnrc_netif2.c), ?
There was a problem hiding this comment.
So, is the idea like this: LwMAC should be ported to the thread created in sys/net/gnrc/netif2/gnrc_netif2.c (the thread, maybe the real MAC thread then?), with replacement of the ops-parameters (like _init(), _send...) of my own LwMAC implementation?
There was a problem hiding this comment.
Yes. That is one of the main features of gnrc_netif2, to simplify MAC porting and to avoid code duplication ;-).
There was a problem hiding this comment.
(you've done this this is just not as visible in the diff so everything alright here ;-))
| _lwmac_thread, (void *)netif, name); | ||
| (void)res; | ||
| assert(res > 0); | ||
| return netif; |
There was a problem hiding this comment.
Just call gnrc_netif2_create() with your ops struct here.
| puts("init lwmac"); | ||
| return gnrc_lwmac_init(stack, stacksize, priority, "at86rf2xx-lwmac", dev, | ||
| &ieee802154_ops); | ||
| #else |
| if (netif->mac_info & GNRC_NETDEV_MAC_INFO_CSMA_ENABLED) { | ||
| res = csma_sender_csma_ca_send(dev, vector, n, &netif->csma_conf); | ||
| if (netif->mac.mac_info & GNRC_NETDEV_MAC_INFO_CSMA_ENABLED) { | ||
| res = csma_sender_csma_ca_send(dev, vector, n, &netif->mac.csma_conf); |
sys/net/gnrc/netif2/gnrc_netif2.c
Outdated
| #endif | ||
| if (netif->ops->init) { | ||
| netif->ops->init(netif); | ||
| puts("inti device"); |
There was a problem hiding this comment.
Sorry, this is just for debug, forget to remove it.. :-P Will remove!
sys/net/gnrc/netif2/gnrc_netif2.c
Outdated
| DEBUG("gnrc_netif2: GNRC_NETAPI_MSG_TYPE_GET received. opt=%s\n", | ||
| opt->opt); | ||
| #endif | ||
| puts("get!!"); |
There was a problem hiding this comment.
I think this is debug output ;-)
|
Sorry, Martine, 😅 I know there are some mess in this PR . I just did a quick porting (and some debug runing) to see if my way of porting (and understanding) is corrent. Will clean out all the mess myself of cause. You don't have to focus on those debuging mess now. ;-) |
|
Hi, Martine, I don't know I understand it corrently, but do I still need to use |
|
Adapted, should be closer to the way it is expected to be. |
Do it with an |
miri64
left a comment
There was a problem hiding this comment.
Tested successfully with tests/lwmac (I'm not sure examples/gnrc_networking_mac can work at the moment so I did not bother testing it for now), but some (minor) issues still left.
| AT86RF2XX_MAC_STACKSIZE, | ||
| AT86RF2XX_MAC_PRIO, "at86rf2xx-lwmac", | ||
| (netdev_t *)&at86rf2xx_devs[i]); | ||
| #else |
There was a problem hiding this comment.
Move this into the #ifdef MODULE_GNRC_NETIF2 below, please
| #else | ||
| int res = gnrc_netdev_ieee802154_init(&gnrc_adpt[i], | ||
| (netdev_ieee802154_t *)&at86rf2xx_devs[i]); | ||
|
|
sys/include/net/gnrc/lwmac/lwmac.h
Outdated
| * @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. | ||
| * @param[in] ops Operations for the LWMAC network interface. |
sys/include/net/gnrc/lwmac/lwmac.h
Outdated
| * @param[in] name name of the thread housing the LWMAC instance | ||
| * @param[in] dev netdev device, needs to be already initialized | ||
| * @note If @ref DEVELHELP is defined netif_params_t::name is used as the | ||
| * name of the network interface's thread. |
| * (e.g. empty payload with Ethernet). | ||
| * @return Any negative error code reported by gnrc_netif2_t::dev. | ||
| */ | ||
| int _gnrc_lwmac_transmit(gnrc_netif2_t *netif, gnrc_pktsnip_t *pkt); |
There was a problem hiding this comment.
(optional) since the function name starts with a _: Maybe add @internal tag to the doc?
There was a problem hiding this comment.
How about I just change this function to gnrc_lwmac_transmit()??
There was a problem hiding this comment.
Added @internal tag to the doc.
| netif->mac.lwmac.system_start_time_ticks = rtt_get_counter(); | ||
| netif->mac.lwmac.last_radio_on_time_ticks = netif->mac.lwmac.system_start_time_ticks; | ||
| netif->mac.lwmac.awake_duration_sum_ticks = 0; | ||
| netif->mac.lwmac.lwmac_info |= GNRC_LWMAC_RADIO_IS_ON; |
There was a problem hiding this comment.
(you've done this this is just not as visible in the diff so everything alright here ;-))
|
Addressed new comments~ |
miri64
left a comment
There was a problem hiding this comment.
Changes look all good now. This might be merged before the actual GNRC integration of gnrc_netif2 ^^: ACK
|
OK~ Thanks! Martine!~ Could you wait a minute before trigger the merge button. I want to pope all the LWMAC codes through uncrustify, to tackle potential remaining coding style issues~ Also, I need to squash. ^^ |
|
Sure! Squash is necessary anyway ;-) |
|
Also: checkout some whitespace issues, that Murdock found. |
OK, I suppose uncrustify will do the job. :-) |
|
Poped through uncrustify, squash immediately. |
ce74a9b to
c554d30
Compare
|
Squashed!~ ;-) |
|
Everything looks OK now, let's go for merge?~ 😃 |
|
Yapp |
Port LwMAC protocol to netif2.