From patchwork Thu Jul 28 01:32:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 9250525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ABF9F607D3 for ; Thu, 28 Jul 2016 01:32:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D6B7219AC for ; Thu, 28 Jul 2016 01:32:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9189B26253; Thu, 28 Jul 2016 01:32:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01712219AC for ; Thu, 28 Jul 2016 01:32:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758866AbcG1Bcl (ORCPT ); Wed, 27 Jul 2016 21:32:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49180 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758826AbcG1Bck (ORCPT ); Wed, 27 Jul 2016 21:32:40 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 94F0DC0467E6; Thu, 28 Jul 2016 01:32:40 +0000 (UTC) Received: from hp-dl360pgen8-07.khw.lab.eng.bos.redhat.com (hp-dl360pgen8-07.khw.lab.eng.bos.redhat.com [10.16.184.47]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6S1WdGf017930; Wed, 27 Jul 2016 21:32:39 -0400 From: Jarod Wilson To: linux-rdma@vger.kernel.org Cc: Jarod Wilson , Yishai Hadas Subject: [PATCH libmlx5 7/6] combine inline_hdr and inline_hdr_start Date: Wed, 27 Jul 2016 21:32:34 -0400 Message-Id: <1469669554-23782-1-git-send-email-jarod@redhat.com> In-Reply-To: <1469647047-7544-1-git-send-email-jarod@redhat.com> References: <1469647047-7544-1-git-send-email-jarod@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 28 Jul 2016 01:32:40 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I can't see any good reason why inline_hdr and inline_hdr_start should be two separate arrays in struct mlx5_wqe_eth_seg. The only time I see anything actually accessed by dereferencing either inline_hdr or inline_hdr_start is when the MLX5_ETH_L2_INLINE_HEADER_SIZE or less bytes are copied into inline_hdr_start. By default, it's 18 bytes, copied to what is a 2-byte and a 16-byte array back to back in the struct, and coverity and clang both sound alarms because the code says "just write 18 bytes into that 2-byte array", which in practice is ultimately fine, but again, why?... I propose to just add two bytes to inline_hdr and drop inline_hdr_start. CC: Yishai Hadas Signed-off-by: Jarod Wilson --- src/qp.c | 4 ++-- src/wqe.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/qp.c b/src/qp.c index 8bb66be..f4a22be 100644 --- a/src/qp.c +++ b/src/qp.c @@ -369,14 +369,14 @@ static inline int copy_eth_inline_headers(struct ibv_qp *ibqp, if (likely(wr->sg_list[0].length >= MLX5_ETH_L2_INLINE_HEADER_SIZE)) { inl_hdr_copy_size = MLX5_ETH_L2_INLINE_HEADER_SIZE; - memcpy(eseg->inline_hdr_start, + memcpy(eseg->inline_hdr, (void *)(uintptr_t)wr->sg_list[0].addr, inl_hdr_copy_size); } else { for (j = 0; j < wr->num_sge && inl_hdr_size > 0; ++j) { inl_hdr_copy_size = min(wr->sg_list[j].length, inl_hdr_size); - memcpy(eseg->inline_hdr_start + + memcpy(eseg->inline_hdr + (MLX5_ETH_L2_INLINE_HEADER_SIZE - inl_hdr_size), (void *)(uintptr_t)wr->sg_list[j].addr, inl_hdr_copy_size); diff --git a/src/wqe.h b/src/wqe.h index c2622d5..d979232 100644 --- a/src/wqe.h +++ b/src/wqe.h @@ -92,8 +92,7 @@ struct mlx5_wqe_eth_seg { uint16_t mss; uint32_t rsvd2; uint16_t inline_hdr_sz; - uint8_t inline_hdr_start[2]; - uint8_t inline_hdr[16]; + uint8_t inline_hdr[MLX5_ETH_L2_INLINE_HEADER_SIZE]; }; struct mlx5_wqe_ctrl_seg {