pkg/lwip: update to use iolists

This commit is contained in:
Kaspar Schleiser 2018-01-18 14:52:38 +01:00
parent 1faa845d8e
commit 403faf2314
3 changed files with 25 additions and 16 deletions

View File

@ -185,15 +185,24 @@ static err_t _eth_link_output(struct netif *netif, struct pbuf *p)
pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
#endif
LL_COUNT(p, q, count);
struct iovec pkt[count];
iolist_t iolist[count];
/* make last point to the last entry of iolist[] */
iolist_t *last = &iolist[count];
last--;
for (q = p, count = 0; q != NULL; q = q->next, count++) {
pkt[count].iov_base = q->payload;
pkt[count].iov_len = (size_t)q->len;
iolist_t *iol = &iolist[count];
iol->iol_next = (iol == last) ? NULL : &iolist[count + 1];
iol->iol_base = q->payload;
iol->iol_len = (size_t)q->len;
}
#if ETH_PAD_SIZE
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
#endif
return (netdev->driver->send(netdev, pkt, count) > 0) ? ERR_OK : ERR_BUF;
return (netdev->driver->send(netdev, iolist) > 0) ? ERR_OK : ERR_BUF;
}
#endif
@ -202,12 +211,12 @@ static err_t _ieee802154_link_output(struct netif *netif, struct pbuf *p)
{
LWIP_ASSERT("p->next == NULL", p->next == NULL);
netdev_t *netdev = (netdev_t *)netif->state;
struct iovec pkt = {
.iov_base = p->payload,
.iov_len = (p->len - IEEE802154_FCS_LEN), /* FCS is written by driver */
iolist_t pkt = {
.iol_base = p->payload,
.iol_len = (p->len - IEEE802154_FCS_LEN), /* FCS is written by driver */
};
return (netdev->driver->send(netdev, &pkt, 1) > 0) ? ERR_OK : ERR_BUF;
return (netdev->driver->send(netdev, &pkt) > 0) ? ERR_OK : ERR_BUF;
}
#endif

View File

@ -141,16 +141,16 @@ static int _netdev_recv(netdev_t *dev, char *buf, int len, void *info)
return res;
}
static int _netdev_send(netdev_t *dev, const struct iovec *vector, int count)
static int _netdev_send(netdev_t *dev, const iolist_t *iolist)
{
msg_t done = { .type = _SEND_DONE };
unsigned offset = 0;
(void)dev;
mutex_lock(&_netdev_buffer_mutex);
for (int i = 0; i < count; i++) {
memcpy(&_netdev_buffer[offset], vector[i].iov_base, vector[i].iov_len);
offset += vector[i].iov_len;
for (; iolist; iolist = iolist->iol_next) {
memcpy(&_netdev_buffer[offset], iolist->iol_base, iolist->iol_len);
offset += iolist->iol_len;
if (offset > sizeof(_netdev_buffer)) {
mutex_unlock(&_netdev_buffer_mutex);
return -ENOBUFS;

View File

@ -143,16 +143,16 @@ static int _netdev_recv(netdev_t *dev, char *buf, int len, void *info)
return res;
}
static int _netdev_send(netdev_t *dev, const struct iovec *vector, int count)
static int _netdev_send(netdev_t *dev, const iolist_t *iolist)
{
msg_t done = { .type = _SEND_DONE };
unsigned offset = 0;
(void)dev;
mutex_lock(&_netdev_buffer_mutex);
for (int i = 0; i < count; i++) {
memcpy(&_netdev_buffer[offset], vector[i].iov_base, vector[i].iov_len);
offset += vector[i].iov_len;
for (; iolist; iolist = iolist->iol_next) {
memcpy(&_netdev_buffer[offset], iolist->iol_base, iolist->iol_len);
offset += iolist->iol_len;
if (offset > sizeof(_netdev_buffer)) {
mutex_unlock(&_netdev_buffer_mutex);
return -ENOBUFS;