pkg/lwip: update to use iolists
This commit is contained in:
parent
1faa845d8e
commit
403faf2314
@ -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 */
|
pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
|
||||||
#endif
|
#endif
|
||||||
LL_COUNT(p, q, count);
|
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++) {
|
for (q = p, count = 0; q != NULL; q = q->next, count++) {
|
||||||
pkt[count].iov_base = q->payload;
|
iolist_t *iol = &iolist[count];
|
||||||
pkt[count].iov_len = (size_t)q->len;
|
|
||||||
|
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
|
#if ETH_PAD_SIZE
|
||||||
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
|
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
|
||||||
#endif
|
#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
|
#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);
|
LWIP_ASSERT("p->next == NULL", p->next == NULL);
|
||||||
netdev_t *netdev = (netdev_t *)netif->state;
|
netdev_t *netdev = (netdev_t *)netif->state;
|
||||||
struct iovec pkt = {
|
iolist_t pkt = {
|
||||||
.iov_base = p->payload,
|
.iol_base = p->payload,
|
||||||
.iov_len = (p->len - IEEE802154_FCS_LEN), /* FCS is written by driver */
|
.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
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -141,16 +141,16 @@ static int _netdev_recv(netdev_t *dev, char *buf, int len, void *info)
|
|||||||
return res;
|
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 };
|
msg_t done = { .type = _SEND_DONE };
|
||||||
unsigned offset = 0;
|
unsigned offset = 0;
|
||||||
|
|
||||||
(void)dev;
|
(void)dev;
|
||||||
mutex_lock(&_netdev_buffer_mutex);
|
mutex_lock(&_netdev_buffer_mutex);
|
||||||
for (int i = 0; i < count; i++) {
|
for (; iolist; iolist = iolist->iol_next) {
|
||||||
memcpy(&_netdev_buffer[offset], vector[i].iov_base, vector[i].iov_len);
|
memcpy(&_netdev_buffer[offset], iolist->iol_base, iolist->iol_len);
|
||||||
offset += vector[i].iov_len;
|
offset += iolist->iol_len;
|
||||||
if (offset > sizeof(_netdev_buffer)) {
|
if (offset > sizeof(_netdev_buffer)) {
|
||||||
mutex_unlock(&_netdev_buffer_mutex);
|
mutex_unlock(&_netdev_buffer_mutex);
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
|
|||||||
@ -143,16 +143,16 @@ static int _netdev_recv(netdev_t *dev, char *buf, int len, void *info)
|
|||||||
return res;
|
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 };
|
msg_t done = { .type = _SEND_DONE };
|
||||||
unsigned offset = 0;
|
unsigned offset = 0;
|
||||||
|
|
||||||
(void)dev;
|
(void)dev;
|
||||||
mutex_lock(&_netdev_buffer_mutex);
|
mutex_lock(&_netdev_buffer_mutex);
|
||||||
for (int i = 0; i < count; i++) {
|
for (; iolist; iolist = iolist->iol_next) {
|
||||||
memcpy(&_netdev_buffer[offset], vector[i].iov_base, vector[i].iov_len);
|
memcpy(&_netdev_buffer[offset], iolist->iol_base, iolist->iol_len);
|
||||||
offset += vector[i].iov_len;
|
offset += iolist->iol_len;
|
||||||
if (offset > sizeof(_netdev_buffer)) {
|
if (offset > sizeof(_netdev_buffer)) {
|
||||||
mutex_unlock(&_netdev_buffer_mutex);
|
mutex_unlock(&_netdev_buffer_mutex);
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user