DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/thunderx: check data offset alignment requirement
@ 2017-03-04 12:46 Jerin Jacob
  2017-03-06  5:30 ` Hemant Agrawal
  2017-03-13  8:02 ` [dpdk-dev] [PATCH v2] " Jerin Jacob
  0 siblings, 2 replies; 5+ messages in thread
From: Jerin Jacob @ 2017-03-04 12:46 UTC (permalink / raw)
  To: dev; +Cc: Jerin Jacob

nicvf HW expects the DMA address of the packet data to be
aligned with cache line size.

Packet data offset is a function of struct mbuf size,
mbuf private size and headroom. mbuf private size can
be changed from the application in pool creation, this
check detects HW alignment requirement constraint in pmd
start function.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 drivers/net/thunderx/nicvf_ethdev.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index 1060319..ad7b5d6 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -1410,7 +1410,7 @@ static int
 nicvf_vf_start(struct rte_eth_dev *dev, struct nicvf *nic, uint32_t rbdrsz)
 {
 	int ret;
-	uint16_t qidx;
+	uint16_t qidx, data_off;
 	uint32_t total_rxq_desc, nb_rbdr_desc, exp_buffs;
 	uint64_t mbuf_phys_off = 0;
 	struct nicvf_rxq *rxq;
@@ -1451,10 +1451,17 @@ nicvf_vf_start(struct rte_eth_dev *dev, struct nicvf *nic, uint32_t rbdrsz)
 				     nic->vf_id, qidx, rxq->pool->name);
 			return -ENOMEM;
 		}
-		rxq->mbuf_phys_off -= nicvf_mbuff_meta_length(mbuf);
-		rxq->mbuf_phys_off -= RTE_PKTMBUF_HEADROOM;
+		data_off = nicvf_mbuff_meta_length(mbuf);
+		data_off += RTE_PKTMBUF_HEADROOM;
 		rte_pktmbuf_free(mbuf);
 
+		if (data_off % RTE_CACHE_LINE_SIZE) {
+			PMD_INIT_LOG(ERR, "unaligned data_offset=%d delta=%d\n",
+				data_off, data_off % RTE_CACHE_LINE_SIZE);
+			return -EINVAL;
+		}
+		rxq->mbuf_phys_off -= data_off;
+
 		if (mbuf_phys_off == 0)
 			mbuf_phys_off = rxq->mbuf_phys_off;
 		if (mbuf_phys_off != rxq->mbuf_phys_off) {
-- 
2.5.5

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] net/thunderx: check data offset alignment requirement
  2017-03-04 12:46 [dpdk-dev] [PATCH] net/thunderx: check data offset alignment requirement Jerin Jacob
@ 2017-03-06  5:30 ` Hemant Agrawal
  2017-03-06  5:32   ` Jerin Jacob
  2017-03-13  8:02 ` [dpdk-dev] [PATCH v2] " Jerin Jacob
  1 sibling, 1 reply; 5+ messages in thread
From: Hemant Agrawal @ 2017-03-06  5:30 UTC (permalink / raw)
  To: Jerin Jacob, dev

On 3/4/2017 6:16 PM, Jerin Jacob wrote:
> nicvf HW expects the DMA address of the packet data to be
> aligned with cache line size.
>
> Packet data offset is a function of struct mbuf size,
> mbuf private size and headroom. mbuf private size can
> be changed from the application in pool creation, this
> check detects HW alignment requirement constraint in pmd
> start function.
>
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
>  drivers/net/thunderx/nicvf_ethdev.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
> index 1060319..ad7b5d6 100644
> --- a/drivers/net/thunderx/nicvf_ethdev.c
> +++ b/drivers/net/thunderx/nicvf_ethdev.c
> @@ -1410,7 +1410,7 @@ static int
>  nicvf_vf_start(struct rte_eth_dev *dev, struct nicvf *nic, uint32_t rbdrsz)
>  {
>  	int ret;
> -	uint16_t qidx;
> +	uint16_t qidx, data_off;
>  	uint32_t total_rxq_desc, nb_rbdr_desc, exp_buffs;
>  	uint64_t mbuf_phys_off = 0;
>  	struct nicvf_rxq *rxq;
> @@ -1451,10 +1451,17 @@ nicvf_vf_start(struct rte_eth_dev *dev, struct nicvf *nic, uint32_t rbdrsz)
>  				     nic->vf_id, qidx, rxq->pool->name);
>  			return -ENOMEM;
>  		}
> -		rxq->mbuf_phys_off -= nicvf_mbuff_meta_length(mbuf);
> -		rxq->mbuf_phys_off -= RTE_PKTMBUF_HEADROOM;
> +		data_off = nicvf_mbuff_meta_length(mbuf);
> +		data_off += RTE_PKTMBUF_HEADROOM;
>  		rte_pktmbuf_free(mbuf);
>
> +		if (data_off % RTE_CACHE_LINE_SIZE) {
> +			PMD_INIT_LOG(ERR, "unaligned data_offset=%d delta=%d\n",
> +				data_off, data_off % RTE_CACHE_LINE_SIZE);

Do you also want to log about the particular pool having this issue?
rxq->pool->name

> +			return -EINVAL;
> +		}
> +		rxq->mbuf_phys_off -= data_off;
> +
>  		if (mbuf_phys_off == 0)
>  			mbuf_phys_off = rxq->mbuf_phys_off;
>  		if (mbuf_phys_off != rxq->mbuf_phys_off) {
>
otherwise, you may add:
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] net/thunderx: check data offset alignment requirement
  2017-03-06  5:30 ` Hemant Agrawal
@ 2017-03-06  5:32   ` Jerin Jacob
  0 siblings, 0 replies; 5+ messages in thread
From: Jerin Jacob @ 2017-03-06  5:32 UTC (permalink / raw)
  To: Hemant Agrawal; +Cc: dev

On Mon, Mar 06, 2017 at 11:00:01AM +0530, Hemant Agrawal wrote:
> On 3/4/2017 6:16 PM, Jerin Jacob wrote:
> > nicvf HW expects the DMA address of the packet data to be
> > aligned with cache line size.
> > 
> > Packet data offset is a function of struct mbuf size,
> > mbuf private size and headroom. mbuf private size can
> > be changed from the application in pool creation, this
> > check detects HW alignment requirement constraint in pmd
> > start function.
> > 
> > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> > ---
> >  drivers/net/thunderx/nicvf_ethdev.c | 13 ++++++++++---
> >  1 file changed, 10 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
> > index 1060319..ad7b5d6 100644
> > --- a/drivers/net/thunderx/nicvf_ethdev.c
> > +++ b/drivers/net/thunderx/nicvf_ethdev.c
> > @@ -1410,7 +1410,7 @@ static int
> >  nicvf_vf_start(struct rte_eth_dev *dev, struct nicvf *nic, uint32_t rbdrsz)
> >  {
> >  	int ret;
> > -	uint16_t qidx;
> > +	uint16_t qidx, data_off;
> >  	uint32_t total_rxq_desc, nb_rbdr_desc, exp_buffs;
> >  	uint64_t mbuf_phys_off = 0;
> >  	struct nicvf_rxq *rxq;
> > @@ -1451,10 +1451,17 @@ nicvf_vf_start(struct rte_eth_dev *dev, struct nicvf *nic, uint32_t rbdrsz)
> >  				     nic->vf_id, qidx, rxq->pool->name);
> >  			return -ENOMEM;
> >  		}
> > -		rxq->mbuf_phys_off -= nicvf_mbuff_meta_length(mbuf);
> > -		rxq->mbuf_phys_off -= RTE_PKTMBUF_HEADROOM;
> > +		data_off = nicvf_mbuff_meta_length(mbuf);
> > +		data_off += RTE_PKTMBUF_HEADROOM;
> >  		rte_pktmbuf_free(mbuf);
> > 
> > +		if (data_off % RTE_CACHE_LINE_SIZE) {
> > +			PMD_INIT_LOG(ERR, "unaligned data_offset=%d delta=%d\n",
> > +				data_off, data_off % RTE_CACHE_LINE_SIZE);
> 
> Do you also want to log about the particular pool having this issue?
> rxq->pool->name

Yes.I will add the pool name in v2.

Thanks.
> 
> > +			return -EINVAL;
> > +		}
> > +		rxq->mbuf_phys_off -= data_off;
> > +
> >  		if (mbuf_phys_off == 0)
> >  			mbuf_phys_off = rxq->mbuf_phys_off;
> >  		if (mbuf_phys_off != rxq->mbuf_phys_off) {
> > 
> otherwise, you may add:
> Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH v2] net/thunderx: check data offset alignment requirement
  2017-03-04 12:46 [dpdk-dev] [PATCH] net/thunderx: check data offset alignment requirement Jerin Jacob
  2017-03-06  5:30 ` Hemant Agrawal
@ 2017-03-13  8:02 ` Jerin Jacob
  2017-03-14 15:39   ` Ferruh Yigit
  1 sibling, 1 reply; 5+ messages in thread
From: Jerin Jacob @ 2017-03-13  8:02 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, hemant.agrawal, Jerin Jacob

nicvf HW expects the DMA address of the packet data to be
aligned with cache line size.

Packet data offset is a function of struct mbuf size,
mbuf private size and headroom. mbuf private size can
be changed from the application in pool creation, this
check detects HW alignment requirement constraint in pmd
start function.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
v2:
Add pool name in error log(Hemant)
---
 drivers/net/thunderx/nicvf_ethdev.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index fa1cb32..5f34237 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -1409,7 +1409,7 @@ static int
 nicvf_vf_start(struct rte_eth_dev *dev, struct nicvf *nic, uint32_t rbdrsz)
 {
 	int ret;
-	uint16_t qidx;
+	uint16_t qidx, data_off;
 	uint32_t total_rxq_desc, nb_rbdr_desc, exp_buffs;
 	uint64_t mbuf_phys_off = 0;
 	struct nicvf_rxq *rxq;
@@ -1450,10 +1450,18 @@ nicvf_vf_start(struct rte_eth_dev *dev, struct nicvf *nic, uint32_t rbdrsz)
 				     nic->vf_id, qidx, rxq->pool->name);
 			return -ENOMEM;
 		}
-		rxq->mbuf_phys_off -= nicvf_mbuff_meta_length(mbuf);
-		rxq->mbuf_phys_off -= RTE_PKTMBUF_HEADROOM;
+		data_off = nicvf_mbuff_meta_length(mbuf);
+		data_off += RTE_PKTMBUF_HEADROOM;
 		rte_pktmbuf_free(mbuf);
 
+		if (data_off % RTE_CACHE_LINE_SIZE) {
+			PMD_INIT_LOG(ERR, "%s: unaligned data_off=%d delta=%d",
+				rxq->pool->name, data_off,
+				data_off % RTE_CACHE_LINE_SIZE);
+			return -EINVAL;
+		}
+		rxq->mbuf_phys_off -= data_off;
+
 		if (mbuf_phys_off == 0)
 			mbuf_phys_off = rxq->mbuf_phys_off;
 		if (mbuf_phys_off != rxq->mbuf_phys_off) {
-- 
2.5.5

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/thunderx: check data offset alignment requirement
  2017-03-13  8:02 ` [dpdk-dev] [PATCH v2] " Jerin Jacob
@ 2017-03-14 15:39   ` Ferruh Yigit
  0 siblings, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2017-03-14 15:39 UTC (permalink / raw)
  To: Jerin Jacob, dev; +Cc: hemant.agrawal

On 3/13/2017 8:02 AM, Jerin Jacob wrote:
> nicvf HW expects the DMA address of the packet data to be
> aligned with cache line size.
> 
> Packet data offset is a function of struct mbuf size,
> mbuf private size and headroom. mbuf private size can
> be changed from the application in pool creation, this
> check detects HW alignment requirement constraint in pmd
> start function.
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>

Applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-03-14 15:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-04 12:46 [dpdk-dev] [PATCH] net/thunderx: check data offset alignment requirement Jerin Jacob
2017-03-06  5:30 ` Hemant Agrawal
2017-03-06  5:32   ` Jerin Jacob
2017-03-13  8:02 ` [dpdk-dev] [PATCH v2] " Jerin Jacob
2017-03-14 15:39   ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).