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;