-
Notifications
You must be signed in to change notification settings - Fork 2k
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
netdev_ieee802154: Use intermediate layer for mac header #9417
netdev_ieee802154: Use intermediate layer for mac header #9417
Conversation
This commit adds the option to use an intermediate format in communicating with netdev to isolate the device settings from the upper layers.
Effective impact on code size is an increase of around 184 bytes with gnrc_networking on a samr21-xpro |
For a better architecture, I think only ~200 bytes are a good sacrafice. |
But maybe put a |
Thanks, I was looking for a better name, but couldn't think of anything while implementing. |
Part of the L2 statistics are still handled in the gnrc_netif_ieee802154 code. |
uint8_t dst[IEEE802154_LONG_ADDRESS_LEN]; /**< Destination address */ | ||
uint8_t src_len; /**< Source address length */ | ||
uint8_t dst_len; /**< Destination address length */ | ||
} netdev_ieee802154_data_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data_hdr
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok!
uint8_t flags = (uint8_t)(state->flags & NETDEV_IEEE802154_SEND_MASK); | ||
le_uint16_t dev_pan = byteorder_btols(byteorder_htons(state->pan)); | ||
const uint8_t *dst, *src; | ||
netdev_ieee802154_data_t l2data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l2data_hdr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And ok!
@miri64 And another set of renaming commits :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more comment. But I think lwmac
and gomac
may need some changing as well. So I wait for the rest until you out of WIP.
* header using the device specific information. | ||
* | ||
* @param[in] dev network device descriptor | ||
* @param[in] iolist io vector list to send |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation?
* call data to upper network layers. | ||
*/ | ||
typedef struct { | ||
uint8_t src[IEEE802154_LONG_ADDRESS_LEN]; /**< source address */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency of capitalization with comments below?
} | ||
/* prepare iolist for netdev / mac layer */ | ||
iolist_t iolist = { | ||
.iol_next = (iolist_t *)list->iol_next, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cast shouldn't be necessary.
* @param[in] dev network device descriptor | ||
* @param[out] buf buffer to write into or NULL | ||
* @param[in] len maximum number of bytes to read | ||
* @param[out] info status information for the received packet. Might |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, since you decided for left aligned below, this one needs adaption as well ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! :)
@miri64 I've adapted both lwmac and gomach to also use the new netdev layer. |
@bergzand so no WIP anymore, and thus ready for review? If so, please change title ... |
Yup, ready for review, removed the tag from the title |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested for both "vanilla" GNRC and with both MAC protocols (using the gnrc_networking_mac
example). Vanilla works, MAC doesn't (can't ping other node).
Also the layering isn't really in place, since the send and receive functions are called hard-coded instead of the respective layer's netdev_t
driver operations.
* header using the device specific information. | ||
* | ||
* @param[in] dev network device descriptor | ||
* @param[in] iolist io vector list to send |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wager this parameter is expected to carry a netdev_ieee802154_mac_t
header as first element? Please document.
l2data_hdr->src_len = src_len; | ||
l2data_hdr->dst_len = dst_len; | ||
/* Remove the ieee802154 frame header */ | ||
memmove(pdu_start, pdu_start+mhr_len, res - mhr_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style comment: spaces around "+"
int netdev_ieee802154_send(netdev_t *dev, const iolist_t *list) | ||
{ | ||
netdev_ieee802154_t *netdev = (netdev_ieee802154_t *)dev; | ||
netdev_ieee802154_data_hdr_t *data = list->iol_base; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data_hdr
as a name helps to make the code below less confusing.
@@ -101,10 +93,10 @@ int _gnrc_lwmac_transmit(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt) | |||
res = csma_sender_csma_ca_send(dev, &iolist, &netif->mac.csma_conf); | |||
} | |||
else { | |||
res = dev->driver->send(dev, &iolist); | |||
res = netdev_ieee802154_send(dev, &iolist); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this still be the same and dev
pointing to the netdev_ieee802154_t
layer?
@@ -126,27 +125,23 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif) | |||
DEBUG("_recv_ieee802154: cannot allocate pktsnip.\n"); | |||
return NULL; | |||
} | |||
nread = dev->driver->recv(dev, pkt->data, bytes_expected, &rx_info); | |||
nread = netdev_ieee802154_recv(dev, pkt->data, bytes_expected, &rx_info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this still be the same and dev
pointing to the netdev_ieee802154_t
layer?
gnrc_pktsnip_t *pkt = NULL; | ||
int bytes_expected = dev->driver->recv(dev, NULL, 0, NULL); | ||
int bytes_expected = netdev_ieee802154_recv(dev, NULL, 0, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this still be the same and dev
pointing to the netdev_ieee802154_t
layer?
@@ -90,27 +81,23 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif) | |||
DEBUG("_recv_ieee802154: cannot allocate pktsnip.\n"); | |||
return NULL; | |||
} | |||
nread = dev->driver->recv(dev, pkt->data, bytes_expected, &rx_info); | |||
nread = netdev_ieee802154_recv(dev, pkt->data, bytes_expected, &rx_info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this still be the same and dev
pointing to the netdev_ieee802154_t
layer?
@@ -157,7 +145,7 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif) | |||
gnrc_pktbuf_realloc_data(pkt, nread); | |||
} else if (bytes_expected > 0) { | |||
DEBUG("_recv_ieee802154: received frame is too short\n"); | |||
dev->driver->recv(dev, NULL, bytes_expected, NULL); | |||
netdev_ieee802154_recv(dev, NULL, bytes_expected, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this still be the same and dev
pointing to the netdev_ieee802154_t
layer?
@@ -235,7 +216,7 @@ static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt) | |||
res = dev->driver->send(dev, &iolist); | |||
} | |||
#else | |||
res = dev->driver->send(dev, &iolist); | |||
res = netdev_ieee802154_send(dev, &iolist); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this still be the same and dev
pointing to the netdev_ieee802154_t
layer?
@@ -106,7 +107,7 @@ static int send_if_cca(netdev_t *device, iolist_t *iolist) | |||
/* if medium is clear, send the packet and return */ | |||
if (hwfeat == NETOPT_ENABLE) { | |||
DEBUG("csma: Radio medium available: sending packet.\n"); | |||
return device->driver->send(device, iolist); | |||
return netdev_ieee802154_send(device, iolist); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this still be the same and dev
pointing to the netdev_ieee802154_t
layer?
(I also can confirm that it is working in master). |
@miri64 Thank you for your review. My aim for this PR was to have a it as a preparation step for the layered approach. I first want to have gnrc_netif and netdev decoupled, as in, no direct access to netdev data by gnrc_netif. As a next step in a follow up I want to make the netdev_ieee802154 and netdev_eth a "proper" netdev layer with their own data structs containing a netdev_driver.
Whoops 😞 |
Why not introduce it here. |
@bergzand IMO it would be beneficial to show a clear description of your attempted software architecture (layering) incl. a drawing. As is it appears slightly unspecified. |
Do the schematics from #8198 answer your request? Mostly the diagram and accompanying posts here. This PRs and any PR related to this one such as #9330 slowly work to the architecture described there. |
Yes, possible. This would change the scope to not only this An implementation of a I have to see if I also require #9329 for this or that I have to statically allocate the new driver structs in auto_init. I'll open a new PR with the full changes for this in the next few days. |
I'm not sure I understand what kind of information you're looking for here. Is your question about the changes in this PR specific or more about the overall architecture that we're aiming at in the long run? If it is the last case, maybe we can move this discussion to #7736. Are you looking for a graphical explanation on how the different networking layers work together? So how the |
@bergzand it's not about me, it is the demand for a crystal clear layout of what is concepted here so that current work and future contributions can be measured against. From the start, netdev is an interface and the goal of making it multilayered sounds weird.
may help - and netdev++ was lacking this anyway. |
@tcschmidt I would like to continue this discussion in #7736 as it seems to be more about the overal changes to the netdev implementation than the specific changes in this PR |
@bergzand could we do a thorough practical evaluation of the performance impacts prior to progressing (e.g., like in https://arxiv.org/abs/1801.02833) ? I'm saying this after @PeterKietzmann and I have spent life-month of disclosing and debugging insufficiencies of previous versions of netdev ... |
@tcschmidt I really prefer to continue this discussion in #7736 as your questions appear to be more aimed at the overal idea of the layered approach to netdev. This PR is only a small part of the migration. |
@bergzand fine with me - even though my concern is related to code: We've learned that nice neaties in the code can completely mess up performance ... |
@miri64 I was thinking about how to remove the |
I think, except for the a major API change (where recv would get a list as a parameter) this would be the cleanest approach for the moment... |
(but maybe call it |
👍 |
Marked as WIP, since you seem to steer this into a different direction according to #7736 (comment). |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Contribution description
This PR splits the construction of the ieee802154 MAC header.
gnrc_netif_ieee802154
constructs a generic header with only the MAC addresses. The netdev_ieee802154 code then reformats it to a "proper" ieee802.15.4 MAC frame with the information from the device driver.Issues/PRs references
#9330 and part of the follow up work of #8198
WIP as the gomach and the lwmac still need to be adapted.