Damjan Marion | 19414de | 2016-06-07 12:46:55 +0200 | [diff] [blame^] | 1 | From d91c4e2de969086ebc8c3a1dfa30913ea3de37b4 Mon Sep 17 00:00:00 2001 |
John Lo | acc22d7 | 2016-04-27 16:43:44 -0400 | [diff] [blame] | 2 | From: John Daley <johndale@cisco.com> |
| 3 | Date: Mon, 25 Apr 2016 16:24:53 -0700 |
Damjan Marion | 19414de | 2016-06-07 12:46:55 +0200 | [diff] [blame^] | 4 | Subject: [PATCH 11/17] enic: fix misalignment of Rx mbuf data |
John Lo | acc22d7 | 2016-04-27 16:43:44 -0400 | [diff] [blame] | 5 | |
| 6 | Data DMA used m->data_off of uninitialized mbufs instead of |
| 7 | RTE_PKTMBUF_HEADROOM, potentially causing Rx data to be |
| 8 | placed at the wrong alignment in the mbuf. |
| 9 | |
| 10 | Fixes: 947d860c821f ("enic: improve Rx performance") |
| 11 | Signed-off-by: John Daley <johndale@cisco.com> |
| 12 | --- |
| 13 | drivers/net/enic/enic_main.c | 5 +++-- |
| 14 | drivers/net/enic/enic_rx.c | 6 ++++-- |
| 15 | 2 files changed, 7 insertions(+), 4 deletions(-) |
| 16 | |
| 17 | diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c |
Damjan Marion | 19414de | 2016-06-07 12:46:55 +0200 | [diff] [blame^] | 18 | index 06cacd4..b164307 100644 |
John Lo | acc22d7 | 2016-04-27 16:43:44 -0400 | [diff] [blame] | 19 | --- a/drivers/net/enic/enic_main.c |
| 20 | +++ b/drivers/net/enic/enic_main.c |
Damjan Marion | 19414de | 2016-06-07 12:46:55 +0200 | [diff] [blame^] | 21 | @@ -355,10 +355,11 @@ enic_alloc_rx_queue_mbufs(struct enic *enic, struct vnic_rq *rq) |
John Lo | acc22d7 | 2016-04-27 16:43:44 -0400 | [diff] [blame] | 22 | return -ENOMEM; |
| 23 | } |
| 24 | |
| 25 | - dma_addr = (dma_addr_t)(mb->buf_physaddr + mb->data_off); |
| 26 | + dma_addr = (dma_addr_t)(mb->buf_physaddr |
| 27 | + + RTE_PKTMBUF_HEADROOM); |
| 28 | |
| 29 | rq_enet_desc_enc(rqd, dma_addr, RQ_ENET_TYPE_ONLY_SOP, |
| 30 | - mb->buf_len); |
| 31 | + mb->buf_len - RTE_PKTMBUF_HEADROOM); |
| 32 | rq->mbuf_ring[i] = mb; |
| 33 | } |
| 34 | |
| 35 | diff --git a/drivers/net/enic/enic_rx.c b/drivers/net/enic/enic_rx.c |
| 36 | index 232987a..39bb55c 100644 |
| 37 | --- a/drivers/net/enic/enic_rx.c |
| 38 | +++ b/drivers/net/enic/enic_rx.c |
| 39 | @@ -314,9 +314,11 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, |
| 40 | + rx_id); |
| 41 | |
| 42 | /* Push descriptor for newly allocated mbuf */ |
| 43 | - dma_addr = (dma_addr_t)(nmb->buf_physaddr + nmb->data_off); |
| 44 | + dma_addr = (dma_addr_t)(nmb->buf_physaddr |
| 45 | + + RTE_PKTMBUF_HEADROOM); |
| 46 | rqd_ptr->address = rte_cpu_to_le_64(dma_addr); |
| 47 | - rqd_ptr->length_type = cpu_to_le16(nmb->buf_len); |
| 48 | + rqd_ptr->length_type = cpu_to_le16(nmb->buf_len |
| 49 | + - RTE_PKTMBUF_HEADROOM); |
| 50 | |
| 51 | /* Fill in the rest of the mbuf */ |
| 52 | rxmb->data_off = RTE_PKTMBUF_HEADROOM; |
| 53 | -- |
Damjan Marion | 19414de | 2016-06-07 12:46:55 +0200 | [diff] [blame^] | 54 | 2.7.4 |
John Lo | acc22d7 | 2016-04-27 16:43:44 -0400 | [diff] [blame] | 55 | |