diff mbox

[dpdk-dev] enic: fix misalignment of Rx mbuf data

Message ID 1461725516-7166-1-git-send-email-johndale@cisco.com (mailing list archive)
State Accepted, archived
Delegated to: Bruce Richardson
Headers show

Commit Message

John Daley April 27, 2016, 2:51 a.m. UTC
Data DMA used m->data_off of uninitialized mbufs instead of
RTE_PKTMBUF_HEADROOM, potentially causing Rx data to be
placed at the wrong alignment in the mbuf.

Fixes: 947d860c821f ("enic: improve Rx performance")
Signed-off-by: John Daley <johndale@cisco.com>
---
 drivers/net/enic/enic_main.c | 5 +++--
 drivers/net/enic/enic_rx.c   | 6 ++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

Comments

Bruce Richardson May 4, 2016, 10:22 a.m. UTC | #1
On Tue, Apr 26, 2016 at 07:51:56PM -0700, John Daley wrote:
> Data DMA used m->data_off of uninitialized mbufs instead of
> RTE_PKTMBUF_HEADROOM, potentially causing Rx data to be
> placed at the wrong alignment in the mbuf.
> 
> Fixes: 947d860c821f ("enic: improve Rx performance")
> Signed-off-by: John Daley <johndale@cisco.com>
> ---
>  drivers/net/enic/enic_main.c | 5 +++--
>  drivers/net/enic/enic_rx.c   | 6 ++++--
>  2 files changed, 7 insertions(+), 4 deletions(-)
>
Applied to dpdk-next-net/rel_16_07

/Bruce
diff mbox

Patch

diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index be4e9e5..646d87f 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -354,10 +354,11 @@  enic_alloc_rx_queue_mbufs(struct enic *enic, struct vnic_rq *rq)
 			return -ENOMEM;
 		}
 
-		dma_addr = (dma_addr_t)(mb->buf_physaddr + mb->data_off);
+		dma_addr = (dma_addr_t)(mb->buf_physaddr
+			   + RTE_PKTMBUF_HEADROOM);
 
 		rq_enet_desc_enc(rqd, dma_addr, RQ_ENET_TYPE_ONLY_SOP,
-				 mb->buf_len);
+				 mb->buf_len - RTE_PKTMBUF_HEADROOM);
 		rq->mbuf_ring[i] = mb;
 	}
 
diff --git a/drivers/net/enic/enic_rx.c b/drivers/net/enic/enic_rx.c
index 232987a..39bb55c 100644
--- a/drivers/net/enic/enic_rx.c
+++ b/drivers/net/enic/enic_rx.c
@@ -314,9 +314,11 @@  enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 				 + rx_id);
 
 		/* Push descriptor for newly allocated mbuf */
-		dma_addr = (dma_addr_t)(nmb->buf_physaddr + nmb->data_off);
+		dma_addr = (dma_addr_t)(nmb->buf_physaddr
+			   + RTE_PKTMBUF_HEADROOM);
 		rqd_ptr->address = rte_cpu_to_le_64(dma_addr);
-		rqd_ptr->length_type = cpu_to_le16(nmb->buf_len);
+		rqd_ptr->length_type = cpu_to_le16(nmb->buf_len
+				       - RTE_PKTMBUF_HEADROOM);
 
 		/* Fill in the rest of the mbuf */
 		rxmb->data_off = RTE_PKTMBUF_HEADROOM;