DPDK patches and discussions
 help / color / mirror / Atom feed
From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
To: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] mlx4: fix compilation warnings for 32 bit
Date: Fri, 12 Jun 2015 17:15:46 +0200	[thread overview]
Message-ID: <20150612151546.GJ12195@6wind.com> (raw)
In-Reply-To: <1432304251-8025-1-git-send-email-nelio.laranjeiro@6wind.com>

On Fri, May 22, 2015 at 04:17:31PM +0200, Nelio Laranjeiro wrote:
> Fix warning messages "cast to pointer from integer of different size" when
> compiling DPDK in 32 bit with Mellanox PMD.
> 
> SGE addresses are 64 bit integers, converting them to pointers must be done
> through uintptr_t to avoid compilation warnings when those have a different
> size.
> 
> Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> ---
>  lib/librte_pmd_mlx4/mlx4.c |   27 ++++++++++++++++-----------
>  1 file changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/lib/librte_pmd_mlx4/mlx4.c b/lib/librte_pmd_mlx4/mlx4.c
> index fa749f4..b0b1c50 100644
> --- a/lib/librte_pmd_mlx4/mlx4.c
> +++ b/lib/librte_pmd_mlx4/mlx4.c
> @@ -832,8 +832,8 @@ txq_free_elts(struct txq *txq)
>  
>  		if (WR_ID(elt->wr.wr_id).offset == 0)
>  			continue;
> -		rte_pktmbuf_free((void *)(elt->sges[0].addr -
> -					  WR_ID(elt->wr.wr_id).offset));
> +		rte_pktmbuf_free((void *)((uintptr_t)elt->sges[0].addr -
> +			WR_ID(elt->wr.wr_id).offset));
>  	}
>  	rte_free(elts);
>  }
> @@ -1067,7 +1067,8 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
>  		/* Clean up old buffer. */
>  		if (likely(WR_ID(wr->wr_id).offset != 0)) {
>  			struct rte_mbuf *tmp = (void *)
> -				(elt->sges[0].addr - WR_ID(wr->wr_id).offset);
> +				((uintptr_t)elt->sges[0].addr -
> +				 WR_ID(wr->wr_id).offset);
>  
>  			/* Faster than rte_pktmbuf_free(). */
>  			do {
> @@ -1143,7 +1144,8 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
>  			/* Update SGE. */
>  			sge->addr = (uintptr_t)rte_pktmbuf_mtod(buf, char *);
>  			if (txq->priv->vf)
> -				rte_prefetch0((volatile void *)sge->addr);
> +				rte_prefetch0((volatile void *)
> +					(uintptr_t)sge->addr);
>  			sge->length = DATA_LEN(buf);
>  			sge->lkey = lkey;
>  #if (MLX4_PMD_MAX_INLINE > 0) || defined(MLX4_PMD_SOFT_COUNTERS)
> @@ -1742,7 +1744,8 @@ rxq_alloc_elts(struct rxq *rxq, unsigned int elts_n, struct rte_mbuf **pool)
>  		/* Make sure elts index and SGE mbuf pointer can be deduced
>  		 * from WR ID. */
>  		if ((WR_ID(wr->wr_id).id != i) ||
> -		    ((void *)(sge->addr - WR_ID(wr->wr_id).offset) != buf)) {
> +		    ((void *)((uintptr_t)sge->addr -
> +			WR_ID(wr->wr_id).offset) != buf)) {
>  			ERROR("%p: cannot store index and offset in WR ID",
>  			      (void *)rxq);
>  			sge->addr = 0;
> @@ -1769,8 +1772,8 @@ error:
>  			if (elt->sge.addr == 0)
>  				continue;
>  			assert(WR_ID(elt->wr.wr_id).id == i);
> -			buf = (void *)
> -				(elt->sge.addr - WR_ID(elt->wr.wr_id).offset);
> +			buf = (void *)((uintptr_t)elt->sge.addr -
> +				WR_ID(elt->wr.wr_id).offset);
>  			rte_pktmbuf_free_seg(buf);
>  		}
>  		rte_free(elts);
> @@ -1805,7 +1808,8 @@ rxq_free_elts(struct rxq *rxq)
>  		if (elt->sge.addr == 0)
>  			continue;
>  		assert(WR_ID(elt->wr.wr_id).id == i);
> -		buf = (void *)(elt->sge.addr - WR_ID(elt->wr.wr_id).offset);
> +		buf = (void *)((uintptr_t)elt->sge.addr -
> +			WR_ID(elt->wr.wr_id).offset);
>  		rte_pktmbuf_free_seg(buf);
>  	}
>  	rte_free(elts);
> @@ -2508,8 +2512,8 @@ mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
>  		uint32_t len = wc->byte_len;
>  		struct rxq_elt *elt = &(*elts)[WR_ID(wr_id).id];
>  		struct ibv_recv_wr *wr = &elt->wr;
> -		struct rte_mbuf *seg =
> -			(void *)(elt->sge.addr - WR_ID(wr_id).offset);
> +		struct rte_mbuf *seg = (void *)((uintptr_t)elt->sge.addr -
> +			WR_ID(wr_id).offset);
>  		struct rte_mbuf *rep;
>  
>  		/* Sanity checks. */
> @@ -2891,7 +2895,8 @@ rxq_rehash(struct rte_eth_dev *dev, struct rxq *rxq)
>  		for (i = 0; (i != elemof(*elts)); ++i) {
>  			struct rxq_elt *elt = &(*elts)[i];
>  			struct rte_mbuf *buf = (void *)
> -				(elt->sge.addr - WR_ID(elt->wr.wr_id).offset);
> +				((uintptr_t)elt->sge.addr -
> +				 WR_ID(elt->wr.wr_id).offset);
>  
>  			assert(WR_ID(elt->wr.wr_id).id == i);
>  			pool[k++] = buf;
> -- 
> 1.7.10.4
> 

Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>

-- 
Adrien Mazarguil
6WIND

  reply	other threads:[~2015-06-12 15:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22 14:17 Nelio Laranjeiro
2015-06-12 15:15 ` Adrien Mazarguil [this message]
2015-06-12 15:42   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150612151546.GJ12195@6wind.com \
    --to=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=nelio.laranjeiro@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).