From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Jason Gunthorpe
<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: Bart Van Assche <Bart.VanAssche-Sjgp3cTcYWE@public.gmane.org>,
"hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org"
<hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org"
<yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH rdma-core 4/8] mlx5: Avoid sparse complaints about !!
Date: Sat, 15 Jul 2017 11:07:23 +0300 [thread overview]
Message-ID: <20170715080723.GA14674@mtr-leonro.local> (raw)
In-Reply-To: <20170713183737.GF11069-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 3681 bytes --]
On Thu, Jul 13, 2017 at 12:37:37PM -0600, Jason Gunthorpe wrote:
> On Thu, Jul 13, 2017 at 05:52:06PM +0000, Bart Van Assche wrote:
> > On Thu, 2017-07-13 at 11:20 -0600, Jason Gunthorpe wrote:
> > > On Thu, Jul 13, 2017 at 12:51:16AM -0700, Christoph Hellwig wrote:
> > > > > if (qp->qp_cap_cache & MLX5_RX_CSUM_VALID)
> > > > > - wc->wc_flags |= (!!(cqe->hds_ip_ext & MLX5_CQE_L4_OK) &
> > > > > - !!(cqe->hds_ip_ext & MLX5_CQE_L3_OK) &
> > > > > - (get_cqe_l3_hdr_type(cqe) ==
> > > > > - MLX5_CQE_L3_HDR_TYPE_IPV4)) <<
> > > > > - IBV_WC_IP_CSUM_OK_SHIFT;
> > > > > + wc->wc_flags |=
> > > > > + ((bool)(cqe->hds_ip_ext & MLX5_CQE_L4_OK) &
> > > > > + (bool)(cqe->hds_ip_ext & MLX5_CQE_L3_OK) &
> > > > > + (get_cqe_l3_hdr_type(cqe) ==
> > > > > + MLX5_CQE_L3_HDR_TYPE_IPV4))
> > > > > + << IBV_WC_IP_CSUM_OK_SHIFT;
> > > >
> > > > Meh. This code is complete crap. Please factor it out into a little
> > > > helper that mere humans can read first. And then replace the odd ^ used
> > > > as && with proper if constructs and all should make much more sense.
> > >
> > > As far as I could make out, this ugly thing is designed like this for
> > > performance.
> >
> > Hello Jason,
> >
> > How about using an expression like the below to avoid that branches get inserted
> > for testing the MLX5_CQE_L4_OK and MLX5_CQE_L3_OK flags?
> >
> > (cqe->hds_ip_ext & (MLX5_CQE_L4_OK | MLX5_CQE_L3_OK)) == MLX5_CQE_L4_OK | MLX5_CQE_L3_OK
>
> Yes, thanks, that seems a reasonable middle ground:
Thanks Jason and Bart.
>
> diff --git a/providers/mlx5/cq.c b/providers/mlx5/cq.c
> index b845127de937d0..0a6274e6878d3c 100644
> --- a/providers/mlx5/cq.c
> +++ b/providers/mlx5/cq.c
> @@ -182,6 +182,15 @@ static inline int handle_responder_lazy(struct mlx5_cq *cq, struct mlx5_cqe64 *c
> return err;
> }
>
> +/* Returns IBV_WC_IP_CSUM_OK or 0 */
> +static inline int get_csum_ok(struct mlx5_cqe64 *cqe)
> +{
> + return (((cqe->hds_ip_ext & (MLX5_CQE_L4_OK | MLX5_CQE_L3_OK)) ==
> + (MLX5_CQE_L4_OK | MLX5_CQE_L3_OK)) &
> + (get_cqe_l3_hdr_type(cqe) == MLX5_CQE_L3_HDR_TYPE_IPV4))
> + << IBV_WC_IP_CSUM_OK_SHIFT;
> +}
> +
> static inline int handle_responder(struct ibv_wc *wc, struct mlx5_cqe64 *cqe,
> struct mlx5_resource *cur_rsc, struct mlx5_srq *srq)
> {
> @@ -206,12 +215,7 @@ static inline int handle_responder(struct ibv_wc *wc, struct mlx5_cqe64 *cqe,
> if (likely(cur_rsc->type == MLX5_RSC_TYPE_QP)) {
> wq = &qp->rq;
> if (qp->qp_cap_cache & MLX5_RX_CSUM_VALID)
> - wc->wc_flags |=
> - ((bool)(cqe->hds_ip_ext & MLX5_CQE_L4_OK) &
> - (bool)(cqe->hds_ip_ext & MLX5_CQE_L3_OK) &
> - (get_cqe_l3_hdr_type(cqe) ==
> - MLX5_CQE_L3_HDR_TYPE_IPV4))
> - << IBV_WC_IP_CSUM_OK_SHIFT;
> + wc->wc_flags |= get_csum_ok(cqe);
> } else {
> wq = &(rsc_to_mrwq(cur_rsc)->rq);
> }
> @@ -1106,11 +1110,7 @@ static inline int mlx5_cq_read_wc_flags(struct ibv_cq_ex *ibcq)
> int wc_flags = 0;
>
> if (cq->flags & MLX5_CQ_FLAGS_RX_CSUM_VALID)
> - wc_flags = ((bool)(cq->cqe64->hds_ip_ext & MLX5_CQE_L4_OK) &
> - (bool)(cq->cqe64->hds_ip_ext & MLX5_CQE_L3_OK) &
> - (get_cqe_l3_hdr_type(cq->cqe64) ==
> - MLX5_CQE_L3_HDR_TYPE_IPV4))
> - << IBV_WC_IP_CSUM_OK_SHIFT;
> + wc_flags = get_csum_ok(cq->cqe64);
>
> switch (mlx5dv_get_cqe_opcode(cq->cqe64)) {
> case MLX5_CQE_RESP_WR_IMM:
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-07-15 8:07 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-12 21:17 [PATCH rdma-core 0/8] Sparse updates for Mellanox and vmw_pvrdma providers Jason Gunthorpe
[not found] ` <1499894262-10761-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-07-12 21:17 ` [PATCH rdma-core 1/8] verbs: Annoate ibv_wc helpers with endian Jason Gunthorpe
[not found] ` <1499894262-10761-2-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-07-13 6:50 ` Leon Romanovsky
[not found] ` <20170713065057.GH1528-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-07-13 17:48 ` Jason Gunthorpe
2017-07-19 16:53 ` Jason Gunthorpe
[not found] ` <20170719165351.GA25714-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-07-19 17:17 ` Leon Romanovsky
2017-07-12 21:17 ` [PATCH rdma-core 2/8] verbs: Annoate ibv_send_wr " Jason Gunthorpe
2017-07-12 21:17 ` [PATCH rdma-core 3/8] mlx4: Add sparse annotations Jason Gunthorpe
[not found] ` <1499894262-10761-4-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-07-13 7:23 ` Leon Romanovsky
[not found] ` <20170713072343.GI1528-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-07-13 8:07 ` Christoph Hellwig
[not found] ` <20170713080752.GA25727-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2017-07-13 17:16 ` Jason Gunthorpe
2017-07-12 21:17 ` [PATCH rdma-core 4/8] mlx5: Avoid sparse complaints about !! Jason Gunthorpe
[not found] ` <1499894262-10761-5-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-07-13 7:34 ` Leon Romanovsky
2017-07-13 7:51 ` Christoph Hellwig
[not found] ` <20170713075116.GA11233-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2017-07-13 17:20 ` Jason Gunthorpe
[not found] ` <20170713172035.GB11069-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-07-13 17:52 ` Bart Van Assche
[not found] ` <1499968325.2740.12.camel-Sjgp3cTcYWE@public.gmane.org>
2017-07-13 18:37 ` Jason Gunthorpe
[not found] ` <20170713183737.GF11069-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-07-15 8:07 ` Leon Romanovsky [this message]
2017-07-12 21:17 ` [PATCH rdma-core 5/8] mlx5: Add sparse annotations Jason Gunthorpe
2017-07-12 21:17 ` [PATCH rdma-core 6/8] mthca: " Jason Gunthorpe
2017-07-12 21:17 ` [PATCH rdma-core 7/8] vmw_pvrdma: Update kernel header Jason Gunthorpe
[not found] ` <1499894262-10761-8-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-07-14 17:50 ` Adit Ranadive
2017-07-12 21:17 ` [PATCH rdma-core 8/8] vmw_pvrdma: Add sparse annotations Jason Gunthorpe
[not found] ` <1499894262-10761-9-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-07-14 20:56 ` Adit Ranadive
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=20170715080723.GA14674@mtr-leonro.local \
--to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=Bart.VanAssche-Sjgp3cTcYWE@public.gmane.org \
--cc=hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.