From patchwork Tue Jan 29 10:08:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Heib X-Patchwork-Id: 10785921 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57F57922 for ; Tue, 29 Jan 2019 10:09:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A8712ABF2 for ; Tue, 29 Jan 2019 10:09:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EC912AC34; Tue, 29 Jan 2019 10:09:15 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 D14A42ABF2 for ; Tue, 29 Jan 2019 10:09:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728265AbfA2KJO (ORCPT ); Tue, 29 Jan 2019 05:09:14 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:36841 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbfA2KJO (ORCPT ); Tue, 29 Jan 2019 05:09:14 -0500 Received: by mail-wm1-f65.google.com with SMTP id p6so17023608wmc.1 for ; Tue, 29 Jan 2019 02:09:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HRMWeA2l+qszeu98AHI+YszS9XHZmYHRyq2cW6gzMOI=; b=OniHl5QqFJQkYr5+haSOD0rNNI05qqSeeMykwV71G0//2azpka+Fb9AcX0DQZ+QQlm 7XeIDrt8Qn5nr7X3tvoxAk7ud2lCtCqK5XD8x9GR0/klJHliopi/q/iW3jG17nEQYac3 GNJpXg8yvhDyW+R/ilqQ7qqVouNKD+CSTBImI3nYkywT1xLDHm/HV2flG/+vN9uzJ9vR FCV5oTtnI/LtonLoO/oxk7N3rfsTPzpy6eAXrIDTuXPdaBppv2XDhijoLBWCNF48cnNW AY07hZ/sfrtXlbpgnuH/8dkOVCRS/CiYiZOYbQoxvyH04bW//aDH6mFYZY8KXZ7Jkrcn k18g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HRMWeA2l+qszeu98AHI+YszS9XHZmYHRyq2cW6gzMOI=; b=brcymzTSM69Hbfv+Gq2EL1ZX+KgP+QghGnlb8kEGfCzJVqohXrPEhvuUuh6/G/+09m 1Obl0zqtxZNuLjA8zNq1wwQFWPz8a+Af6FMbMN3KaVNv8qlJCV+Nn29AeJpo0nTRivQe rbZfGC8IdjNm7xft9PtNpbI5GvvGMIYZtxMiZ+SA77ng+aAA/h/cbKqcM/npsAnDn7/8 PltoqqJpiVBmlNRAYOhnICwu1y4o9OO6h9tO3m4sQle9XIHFRjFNAI0ofKfv3bJ69Xoo jXz7D1RCv0Yvxp1/GmaSytCNVNF4oyUlaxP5hQLeiaCzTcacuac/yA9PNxE4pn/d6o66 gTjQ== X-Gm-Message-State: AJcUukcFLIwEP0V1N59/Jc8TFfkP9ZLxYegKSioGIbRR+SWH+3Bt7UHt xYiHUcgYdRPlDoWRMtGcHazNKPe3 X-Google-Smtp-Source: ALg8bN6KxM73Bf6vyy9jMeaMGh5JXLQs75PAOMKvNSKNVM6UaRlIg0ieYpzqZCpJ6HmkcyjTR9qR+Q== X-Received: by 2002:a1c:c90b:: with SMTP id f11mr20416638wmb.33.1548756552181; Tue, 29 Jan 2019 02:09:12 -0800 (PST) Received: from kheib-workstation.redhat.com ([192.116.94.216]) by smtp.gmail.com with ESMTPSA id q12sm103902903wrx.31.2019.01.29.02.09.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jan 2019 02:09:11 -0800 (PST) From: Kamal Heib To: Doug Ledford , Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, Yuval Shaia , Marcel Apfelbaum , Kamal Heib Subject: [PATCH rdma-next 1/2] RDMA/rxe: Move rxe_init_av() to rxe_av.c Date: Tue, 29 Jan 2019 12:08:49 +0200 Message-Id: <20190129100850.18840-2-kamalheib1@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129100850.18840-1-kamalheib1@gmail.com> References: <20190129100850.18840-1-kamalheib1@gmail.com> MIME-Version: 1.0 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 Move the function rxe_init_av() to rxe_av.c file and use it instead of calling rxe_av_from_attr() and rxe_av_fill_ip_info(), also remove the unused rxe_dev parameter from rxe_init_av(). Signed-off-by: Kamal Heib Reviewed-by: Yuval Shaia Reviewed-by: Zhu Yanjun --- drivers/infiniband/sw/rxe/rxe_av.c | 6 ++++++ drivers/infiniband/sw/rxe/rxe_loc.h | 1 + drivers/infiniband/sw/rxe/rxe_qp.c | 7 ++----- drivers/infiniband/sw/rxe/rxe_verbs.c | 11 ++--------- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_av.c b/drivers/infiniband/sw/rxe/rxe_av.c index 26fe8d7dbc55..27a7dec18874 100644 --- a/drivers/infiniband/sw/rxe/rxe_av.c +++ b/drivers/infiniband/sw/rxe/rxe_av.c @@ -34,6 +34,12 @@ #include "rxe.h" #include "rxe_loc.h" +void rxe_init_av(struct rdma_ah_attr *attr, struct rxe_av *av) +{ + rxe_av_from_attr(rdma_ah_get_port_num(attr), av, attr); + rxe_av_fill_ip_info(av, attr); +} + int rxe_av_chk_attr(struct rxe_dev *rxe, struct rdma_ah_attr *attr) { struct rxe_port *port; diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h index a65fbd0ff42e..b517a6c86922 100644 --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -35,6 +35,7 @@ #define RXE_LOC_H /* rxe_av.c */ +void rxe_init_av(struct rdma_ah_attr *attr, struct rxe_av *av); int rxe_av_chk_attr(struct rxe_dev *rxe, struct rdma_ah_attr *attr); diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c index fd86fd2fbb26..be5d76b2bcca 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -631,14 +631,11 @@ int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask, qp->attr.qkey = attr->qkey; if (mask & IB_QP_AV) { - rxe_av_from_attr(attr->port_num, &qp->pri_av, &attr->ah_attr); - rxe_av_fill_ip_info(&qp->pri_av, &attr->ah_attr); + rxe_init_av(&attr->ah_attr, &qp->pri_av); } if (mask & IB_QP_ALT_PATH) { - rxe_av_from_attr(attr->alt_port_num, &qp->alt_av, - &attr->alt_ah_attr); - rxe_av_fill_ip_info(&qp->alt_av, &attr->alt_ah_attr); + rxe_init_av(&attr->alt_ah_attr, &qp->alt_av); qp->attr.alt_port_num = attr->alt_port_num; qp->attr.alt_pkey_index = attr->alt_pkey_index; qp->attr.alt_timeout = attr->alt_timeout; diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 3d01247a28db..cc5a05124ece 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -210,13 +210,6 @@ static int rxe_dealloc_pd(struct ib_pd *ibpd) return 0; } -static void rxe_init_av(struct rxe_dev *rxe, struct rdma_ah_attr *attr, - struct rxe_av *av) -{ - rxe_av_from_attr(rdma_ah_get_port_num(attr), av, attr); - rxe_av_fill_ip_info(av, attr); -} - static struct ib_ah *rxe_create_ah(struct ib_pd *ibpd, struct rdma_ah_attr *attr, u32 flags, @@ -239,7 +232,7 @@ static struct ib_ah *rxe_create_ah(struct ib_pd *ibpd, rxe_add_ref(pd); ah->pd = pd; - rxe_init_av(rxe, attr, &ah->av); + rxe_init_av(attr, &ah->av); return &ah->ibah; } @@ -253,7 +246,7 @@ static int rxe_modify_ah(struct ib_ah *ibah, struct rdma_ah_attr *attr) if (err) return err; - rxe_init_av(rxe, attr, &ah->av); + rxe_init_av(attr, &ah->av); return 0; } From patchwork Tue Jan 29 10:08:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Heib X-Patchwork-Id: 10785923 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7391B922 for ; Tue, 29 Jan 2019 10:09:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64D6B2ABF2 for ; Tue, 29 Jan 2019 10:09:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 595D02AC34; Tue, 29 Jan 2019 10:09:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 001732ABF2 for ; Tue, 29 Jan 2019 10:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728267AbfA2KJQ (ORCPT ); Tue, 29 Jan 2019 05:09:16 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42697 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbfA2KJQ (ORCPT ); Tue, 29 Jan 2019 05:09:16 -0500 Received: by mail-wr1-f67.google.com with SMTP id q18so21318638wrx.9 for ; Tue, 29 Jan 2019 02:09:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J3dLdeACcxVYs6ELEHoswhss1AgpDvc8KaCo0hf5toA=; b=TBHKSanwEHz8PIZIAKKEIRWVOqm9F/5chJPseVh4HpO6X0FvFmn9C1xBj9ouT/2ugQ xLTmy0Mgl77mqzGEBe6HeAoYaHIN7+6D9io6vKSjFcadSjfIWYA3C5XUibaUCikKQWtT 5N6gZBRF6OLXfWhwOGSWndUvwYzkhc7JEEYp7J3FUr6urin8c1tQz793AhFujH8FkTQs eUPXuIaZQURtTegGx6dFKcO1yIgHS4v8BTl29VtqR5viTJm0JERsK/1XS6OIXSjBhJnY flHuj/fyFQVREHwpoPREaWDYqXRQQKB6IB9hKiVi9b3Xe9lD2igGd1QBhDcCWMRFyfvd H48g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J3dLdeACcxVYs6ELEHoswhss1AgpDvc8KaCo0hf5toA=; b=OX6SvdZPwoTSKSGKkzMvnaXJz6KC5yDBN4E/gF7gHUZqtJDSyp/wGO9Qp8VwdY86K/ VAIxGKp7EoZb6Cp/OdkSf7tA7lcLk6uCQPoFu2YqVGhBHtElNuWWbf7r59r8hOuA52sH 5fgz+8yx0BUka64rlfQJCB6HAMwQidDp5jdvFQr+Ne4PFejq/Fb7xev18DuT5hJtBLb6 Oy5LYuxVQRsNcUPKMf3cLYhv3SBE5+CokgHmA2eq+CQxWj3dE1xrNfQMO91wfPPNSnmA u48QJxMVMNNKRt3CintIbbY2OMsX46KxVNkrOAfdve+xiBkKmd9qHpsP+P7OKVop2z5u bThA== X-Gm-Message-State: AJcUukeasc3tLz0F3yE2mt8l1g0+yCtf6+5RulK9wdNxLkEXAeneentA zI0rolH/TgoNv37PbMr09f4= X-Google-Smtp-Source: ALg8bN6SiJoDgPgYwWP0b+Y7DqeVLAIl69B+SPGtU9iKsAN3ADA+JA3VdOqYakFyl7DjE/1LmSlidA== X-Received: by 2002:adf:92a4:: with SMTP id 33mr25066576wrn.11.1548756554491; Tue, 29 Jan 2019 02:09:14 -0800 (PST) Received: from kheib-workstation.redhat.com ([192.116.94.216]) by smtp.gmail.com with ESMTPSA id q12sm103902903wrx.31.2019.01.29.02.09.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jan 2019 02:09:13 -0800 (PST) From: Kamal Heib To: Doug Ledford , Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, Yuval Shaia , Marcel Apfelbaum , Kamal Heib Subject: [PATCH rdma-next 2/2] RDMA/rxe: Improve loopback marking Date: Tue, 29 Jan 2019 12:08:50 +0200 Message-Id: <20190129100850.18840-3-kamalheib1@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129100850.18840-1-kamalheib1@gmail.com> References: <20190129100850.18840-1-kamalheib1@gmail.com> MIME-Version: 1.0 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 Currently a packet is marked for loopback only if the source and destination addresses equals. This is not enough when multiple gids are present in rxe device's gid table and the traffic is from one gid to another. Fix it by marking the packet for loopback if the destination MAC address is equal to the source MAC address. Signed-off-by: Kamal Heib Reviewed-by: Yuval Shaia Tested-by: Yuval Shaia --- drivers/infiniband/sw/rxe/rxe_av.c | 1 + drivers/infiniband/sw/rxe/rxe_net.c | 9 +++------ include/uapi/rdma/rdma_user_rxe.h | 3 +-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_av.c b/drivers/infiniband/sw/rxe/rxe_av.c index 27a7dec18874..81ee756c19b8 100644 --- a/drivers/infiniband/sw/rxe/rxe_av.c +++ b/drivers/infiniband/sw/rxe/rxe_av.c @@ -38,6 +38,7 @@ void rxe_init_av(struct rdma_ah_attr *attr, struct rxe_av *av) { rxe_av_from_attr(rdma_ah_get_port_num(attr), av, attr); rxe_av_fill_ip_info(av, attr); + memcpy(av->dmac, attr->roce.dmac, ETH_ALEN); } int rxe_av_chk_attr(struct rxe_dev *rxe, struct rdma_ah_attr *attr) diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index 8fd03ae20efc..87dfb16744cc 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -384,9 +384,6 @@ static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb, return -EHOSTUNREACH; } - if (!memcmp(saddr, daddr, sizeof(*daddr))) - pkt->mask |= RXE_LOOPBACK_MASK; - prepare_udp_hdr(skb, cpu_to_be16(qp->src_port), cpu_to_be16(ROCE_V2_UDP_DPORT)); @@ -411,9 +408,6 @@ static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb, return -EHOSTUNREACH; } - if (!memcmp(saddr, daddr, sizeof(*daddr))) - pkt->mask |= RXE_LOOPBACK_MASK; - prepare_udp_hdr(skb, cpu_to_be16(qp->src_port), cpu_to_be16(ROCE_V2_UDP_DPORT)); @@ -437,6 +431,9 @@ int rxe_prepare(struct rxe_pkt_info *pkt, struct sk_buff *skb, u32 *crc) *crc = rxe_icrc_hdr(pkt, skb); + if (ether_addr_equal(skb->dev->dev_addr, av->dmac)) + pkt->mask |= RXE_LOOPBACK_MASK; + return err; } diff --git a/include/uapi/rdma/rdma_user_rxe.h b/include/uapi/rdma/rdma_user_rxe.h index 44ef6a3b7afc..aae2e696bb38 100644 --- a/include/uapi/rdma/rdma_user_rxe.h +++ b/include/uapi/rdma/rdma_user_rxe.h @@ -58,8 +58,7 @@ struct rxe_global_route { struct rxe_av { __u8 port_num; __u8 network_type; - __u16 reserved1; - __u32 reserved2; + __u8 dmac[6]; struct rxe_global_route grh; union { struct sockaddr_in _sockaddr_in;