From patchwork Wed Aug 13 11:39:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 379610 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id EAD7714007B for ; Wed, 13 Aug 2014 21:39:49 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752203AbaHMLjq (ORCPT ); Wed, 13 Aug 2014 07:39:46 -0400 Received: from mail-wg0-f50.google.com ([74.125.82.50]:35880 "EHLO mail-wg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752088AbaHMLjm (ORCPT ); Wed, 13 Aug 2014 07:39:42 -0400 Received: by mail-wg0-f50.google.com with SMTP id n12so11066140wgh.33 for ; Wed, 13 Aug 2014 04:39:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vUx/2eaRtGsO+qfSmf2wMgETbVNrT3WS3o9zCwc3xR8=; b=hXWUswYdPwveMNgCIcJIuUT+pD3BUJv881hGNKEp0wU1cIldNln2vNSTrcvOIDwQUK 5wDcnxvM7qLGAxpR9wPf2ume+J9omdCu8rNETJMpYU3ohWLQv1SstYEUHd5kD2VXES6S 89PjLluqX633CXSj0iPSJgAPceryzV+wUcyK3aQxO96lVubVxE/4IyqyGO9QtXJgxOs3 Tp9VpApHmNtgyTFfCmgzORA9kqnbppL3PxVkmKcTZJPBeXdKgqyWzJSMFxzly98vZP0f o70mfOMbA0LXyyNaPKhhbwJGyvRXRqqINlsR+P7pwDyEpzIPxaEnGdAe+iGYKJU/c65s LJXA== X-Gm-Message-State: ALoCoQka1PM5YKKguhIyjGKVTNPzSeGscijVXdeVBGhxG6zGZngN5rWfX/C8fpFRHdQwCO4VT87R X-Received: by 10.180.97.129 with SMTP id ea1mr4548922wib.29.1407929981530; Wed, 13 Aug 2014 04:39:41 -0700 (PDT) Received: from localhost (out.voltaire.com. [193.47.165.251]) by mx.google.com with ESMTPSA id ej10sm67111044wib.12.2014.08.13.04.39.40 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 13 Aug 2014 04:39:40 -0700 (PDT) From: Eli Cohen X-Google-Original-From: Eli Cohen To: roland@kernel.org, davem@davemloft.net Cc: netdev@vger.kernel.org, rdma@vger.kernel.org, amirv@mellanox.com, yevgenyp@mellanox.com, Eli Cohen Subject: [PATCH net-next 04/10] IB/mlx5: Remove duplicate code from mlx5_set_path Date: Wed, 13 Aug 2014 14:39:05 +0300 Message-Id: <1407929951-16362-5-git-send-email-eli@mellanox.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1407929951-16362-1-git-send-email-eli@mellanox.com> References: <1407929951-16362-1-git-send-email-eli@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Some of the fields where set twice. Re-organize to avoid that. Signed-off-by: Eli Cohen --- drivers/infiniband/hw/mlx5/qp.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 9c1c76b0b7f5..a5192336efd7 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -1317,6 +1317,11 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, const struct ib_ah_attr *ah, path->rlid = cpu_to_be16(ah->dlid); if (ah->ah_flags & IB_AH_GRH) { + if (ah->grh.sgid_index >= gen->port[port - 1].gid_table_len) { + pr_err(KERN_ERR "sgid_index (%u) too large. max is %d\n", + ah->grh.sgid_index, gen->port[port - 1].gid_table_len); + return -EINVAL; + } path->grh_mlid |= 1 << 7; path->mgid_index = ah->grh.sgid_index; path->hop_limit = ah->grh.hop_limit; @@ -1332,22 +1337,6 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, const struct ib_ah_attr *ah, path->static_rate = err; path->port = port; - if (ah->ah_flags & IB_AH_GRH) { - if (ah->grh.sgid_index >= gen->port[port - 1].gid_table_len) { - pr_err(KERN_ERR "sgid_index (%u) too large. max is %d\n", - ah->grh.sgid_index, gen->port[port - 1].gid_table_len); - return -EINVAL; - } - - path->grh_mlid |= 1 << 7; - path->mgid_index = ah->grh.sgid_index; - path->hop_limit = ah->grh.hop_limit; - path->tclass_flowlabel = - cpu_to_be32((ah->grh.traffic_class << 20) | - (ah->grh.flow_label)); - memcpy(path->rgid, ah->grh.dgid.raw, 16); - } - if (attr_mask & IB_QP_TIMEOUT) path->ackto_lt = attr->timeout << 3;