diff --git a/sys/net/gnrc/netif/gnrc_netif_ethernet.c b/sys/net/gnrc/netif/gnrc_netif_ethernet.c index a5b0be4038c4b4b67f4e8f7a1d3d8a580c9aac8a..7aafc78808346bd52b92159b1981791e58e37caf 100644 --- a/sys/net/gnrc/netif/gnrc_netif_ethernet.c +++ b/sys/net/gnrc/netif/gnrc_netif_ethernet.c @@ -135,26 +135,22 @@ static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt) hdr.dst[0], hdr.dst[1], hdr.dst[2], hdr.dst[3], hdr.dst[4], hdr.dst[5]); - size_t n; - payload = gnrc_pktbuf_get_iovec(pkt, &n); /* use payload as temporary - * variable */ - res = -ENOBUFS; - if (payload != NULL) { - pkt = payload; /* reassign for later release; vec_snip is prepended to pkt */ - struct iovec *vector = (struct iovec *)pkt->data; - vector[0].iov_base = (char *)&hdr; - vector[0].iov_len = sizeof(ethernet_hdr_t); + iolist_t iolist = { + .iol_next = (iolist_t *)payload, + .iol_base = &hdr, + .iol_len = sizeof(ethernet_hdr_t) + }; + #ifdef MODULE_NETSTATS_L2 - if ((netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_BROADCAST) || - (netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_MULTICAST)) { - dev->stats.tx_mcast_count++; - } - else { - dev->stats.tx_unicast_count++; - } -#endif - res = dev->driver->send(dev, vector, n); + if ((netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_BROADCAST) || + (netif_hdr->flags & GNRC_NETIF_HDR_FLAGS_MULTICAST)) { + dev->stats.tx_mcast_count++; } + else { + dev->stats.tx_unicast_count++; + } +#endif + res = dev->driver->send(dev, &iolist); gnrc_pktbuf_release(pkt); diff --git a/sys/net/gnrc/netif/gnrc_netif_ieee802154.c b/sys/net/gnrc/netif/gnrc_netif_ieee802154.c index a482c64c1154708c10f38e6d318b49194fd9de27..f72f6ff1d4849c40288aa27c467a6c9ec652bf10 100644 --- a/sys/net/gnrc/netif/gnrc_netif_ieee802154.c +++ b/sys/net/gnrc/netif/gnrc_netif_ieee802154.c @@ -168,10 +168,9 @@ static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt) netdev_t *dev = netif->dev; netdev_ieee802154_t *state = (netdev_ieee802154_t *)netif->dev; gnrc_netif_hdr_t *netif_hdr; - gnrc_pktsnip_t *vec_snip; const uint8_t *src, *dst = NULL; int res = 0; - size_t n, src_len, dst_len; + size_t src_len, dst_len; uint8_t mhr[IEEE802154_MAX_HDR_LEN]; uint8_t flags = (uint8_t)(state->flags & NETDEV_IEEE802154_SEND_MASK); le_uint16_t dev_pan = byteorder_btols(byteorder_htons(state->pan)); @@ -211,38 +210,34 @@ static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt) DEBUG("_send_ieee802154: Error preperaring frame\n"); return -EINVAL; } - /* prepare packet for sending */ - vec_snip = gnrc_pktbuf_get_iovec(pkt, &n); - if (vec_snip != NULL) { - struct iovec *vector; - - pkt = vec_snip; /* reassign for later release; vec_snip is prepended to pkt */ - vector = (struct iovec *)pkt->data; - vector[0].iov_base = mhr; - vector[0].iov_len = (size_t)res; + + /* prepare iolist for netdev / mac layer */ + iolist_t iolist = { + .iol_next = (iolist_t *)pkt->next, + .iol_base = mhr, + .iol_len = (size_t)res + }; + #ifdef MODULE_NETSTATS_L2 if (netif_hdr->flags & - (GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) { - netif->dev->stats.tx_mcast_count++; - } - else { - netif->dev->stats.tx_unicast_count++; - } + (GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST)) { + netif->dev->stats.tx_mcast_count++; + } + else { + netif->dev->stats.tx_unicast_count++; + } #endif #ifdef MODULE_GNRC_MAC - if (netif->mac.mac_info & GNRC_NETIF_MAC_INFO_CSMA_ENABLED) { - res = csma_sender_csma_ca_send(dev, vector, n, &netif->mac.csma_conf); - } - else { - res = dev->driver->send(dev, vector, n); - } -#else - res = dev->driver->send(dev, vector, n); -#endif + if (netif->mac.mac_info & GNRC_NETIF_MAC_INFO_CSMA_ENABLED) { + res = csma_sender_csma_ca_send(dev, &iolist, &netif->mac.csma_conf); } else { - return -ENOBUFS; + res = dev->driver->send(dev, &iolist); } +#else + res = dev->driver->send(dev, &iolist); +#endif + /* release old data */ gnrc_pktbuf_release(pkt); return res; diff --git a/sys/net/gnrc/netif/gnrc_netif_raw.c b/sys/net/gnrc/netif/gnrc_netif_raw.c index 53be2147cf1d19de00d90b98cf62e6b24ad61ab7..cc8760b4ce7cef2c5cdb23af59b03526c0f3ac30 100644 --- a/sys/net/gnrc/netif/gnrc_netif_raw.c +++ b/sys/net/gnrc/netif/gnrc_netif_raw.c @@ -92,27 +92,20 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif) static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt) { - gnrc_pktsnip_t *vector; int res = -ENOBUFS; - size_t n; if (pkt->type == GNRC_NETTYPE_NETIF) { /* we don't need the netif snip: remove it */ pkt = gnrc_pktbuf_remove_snip(pkt, pkt); } - /* prepare packet for sending */ - vector = gnrc_pktbuf_get_iovec(pkt, &n); - if (vector != NULL) { - /* reassign for later release; vector is prepended to pkt */ - pkt = vector; - struct iovec *v = (struct iovec *)vector->data; - netdev_t *dev = netif->dev; + + netdev_t *dev = netif->dev; #ifdef MODULE_NETSTATS_L2 - dev->stats.tx_unicast_count++; + dev->stats.tx_unicast_count++; #endif - res = dev->driver->send(dev, v, n); - } + + res = dev->driver->send(dev, (iolist_t *)pkt); /* release old data */ gnrc_pktbuf_release(pkt); return res; diff --git a/tests/gnrc_netif/common.c b/tests/gnrc_netif/common.c index 7d0bf93ce08dc380a42fc3171ebc30f033299c8a..5a29d29391982954e473bda7669f0c1c5c2fb6b2 100644 --- a/tests/gnrc_netif/common.c +++ b/tests/gnrc_netif/common.c @@ -37,8 +37,7 @@ static msg_t _main_msg_queue[MSG_QUEUE_SIZE]; static uint8_t tmp_buffer[ETHERNET_DATA_LEN]; static size_t tmp_buffer_bytes = 0; -static int _dump_send_packet(netdev_t *netdev, const struct iovec *vector, - int count) +static int _dump_send_packet(netdev_t *netdev, const iolist_t *iolist) { int res; @@ -55,13 +54,13 @@ static int _dump_send_packet(netdev_t *netdev, const struct iovec *vector, printf("unknown "); } puts("device:"); - for (int i = 0; i < count; i++) { - if ((tmp_buffer_bytes + vector[i].iov_len) > ETHERNET_DATA_LEN) { + for (const iolist_t *iol = iolist; iol; iol = iol->iol_next) { + size_t len = iol->iol_len; + if ((tmp_buffer_bytes + len) > ETHERNET_DATA_LEN) { return -ENOBUFS; } - memcpy(&tmp_buffer[tmp_buffer_bytes], vector[i].iov_base, - vector[i].iov_len); - tmp_buffer_bytes += vector[i].iov_len; + memcpy(&tmp_buffer[tmp_buffer_bytes], iol->iol_base, len); + tmp_buffer_bytes += len; } od_hex_dump(tmp_buffer, tmp_buffer_bytes, OD_WIDTH_DEFAULT); res = (int)tmp_buffer_bytes;