|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [UNIKRAFT/LWIP PATCH v4 5/5] uknetdev: Retrieve `ioalign` from device
Retrieve `ioalign` from uknetdev device and apply it to packet buffer
allocations.
Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
---
uknetdev.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/uknetdev.c b/uknetdev.c
index 7b689f9..50c6460 100644
--- a/uknetdev.c
+++ b/uknetdev.c
@@ -67,6 +67,7 @@ struct lwip_netdev_data {
struct uk_alloc *pkt_a;
uint16_t rx_headroom;
uint16_t tx_headroom;
+ uint16_t ioalign; /* required alignment for RX/TX buffers */
#ifdef CONFIG_HAVE_SCHED
struct uk_thread *poll_thread; /* Thread per device */
char *_name; /* Thread name */
@@ -99,7 +100,7 @@ static uint16_t netif_alloc_rxpkts(void *argp, struct
uk_netbuf *nb[],
for (i = 0; i < count; ++i) {
nb[i] = lwip_alloc_netbuf(lwip_data->pkt_a,
UKNETDEV_BUFLEN,
- 1,
+ lwip_data->ioalign,
lwip_data->rx_headroom);
if (!nb[i]) {
/* we run out of memory */
@@ -116,7 +117,6 @@ static err_t uknetdev_output(struct netif *nf, struct pbuf
*p)
struct lwip_netdev_data *lwip_data;
struct pbuf *q;
struct uk_netbuf *nb;
- void *allocation;
char *wpos;
int ret;
@@ -126,14 +126,13 @@ static err_t uknetdev_output(struct netif *nf, struct
pbuf *p)
lwip_data = (struct lwip_netdev_data *) dev->scratch_pad;
UK_ASSERT(lwip_data);
- allocation = uk_malloc(lwip_data->pkt_a, UKNETDEV_BUFLEN);
- if (!allocation)
+ nb = uk_netbuf_alloc_buf(lwip_data->pkt_a,
+ UKNETDEV_BUFLEN,
+ lwip_data->ioalign,
+ lwip_data->tx_headroom,
+ 0, NULL);
+ if (!nb)
return ERR_MEM;
- nb = uk_netbuf_prepare_buf(allocation, UKNETDEV_BUFLEN,
- lwip_data->tx_headroom, 0, NULL);
- UK_ASSERT(nb);
- nb->_a = a; /* register allocator for free operation */
- nb->_b = allocation;
if (unlikely(p->tot_len > uk_netbuf_tailroom(nb))) {
LWIP_DEBUGF(NETIF_DEBUG,
@@ -494,12 +493,14 @@ err_t uknetdev_init(struct netif *nf)
lwip_data->rx_headroom = info.nb_encap_rx;
lwip_data->tx_headroom = info.nb_encap_tx;
#endif
+ lwip_data->ioalign = info.ioalign;
lwip_data->pkt_a = a;
LWIP_DEBUGF(NETIF_DEBUG,
- ("%s: %c%c%u: Need headroom rx:%"PRIu16", tx:%"PRIu16"\n",
+ ("%s: %c%c%u: Headroom rx:%"PRIu16", tx:%"PRIu16"; I/O
align: 0x%"PRIx16"\n",
__func__, nf->name[0], nf->name[1], nf->num,
- lwip_data->rx_headroom, lwip_data->tx_headroom));
+ lwip_data->rx_headroom, lwip_data->tx_headroom,
+ lwip_data->ioalign));
/*
* Device configuration,
--
2.20.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |