From patchwork Wed Nov 29 09:44:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 171216 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp227316vqn; Wed, 29 Nov 2023 01:49:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6myabnL0fuEGS6exes33A69gw+F5Ecml9AzxktlL+O/VF2OJtsbGZUmKAuGy++PX/gP7Y X-Received: by 2002:a05:6a00:391d:b0:6cd:a145:6703 with SMTP id fh29-20020a056a00391d00b006cda1456703mr7127977pfb.2.1701251343637; Wed, 29 Nov 2023 01:49:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701251343; cv=none; d=google.com; s=arc-20160816; b=zQs9FnbcM+MKcRaceLYcZ307FuxGbmHZCTmkZEbpINcZfCPaWj9VLfVuSzURY31Ri5 p/aJQibLljQF7OYaff+2t5qO0GECur33DX5n9omPlF6a8bMwHzp5XhZRDC8ACiQSlhly 8NHOxfUa4H2c7YaiGqh8pzO3EUD5N76kKxHOlr7m6DCB1FO9d0OxkMXKxCYbmbRaT0x2 tL5raNUFyC1jGAvv5v7JzQi/nJt9FlRxQVPn/mg39tuHgCCMNv/B3hkllkS3N78WZNbO 2/PTZXRDGbUmAG2RC6tOoqMM95VTZZW5mo0OfV/bNT9Mg3cpMHwmwylXZqQs284b3CXL MksA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=a9Ut8GSbSITiZkJy2z0+aKg0zYLnCn2Ax24C02Ipy3s=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=x90xC5a/LP4Ewa4nYjRJKdBRGO4AOw46C1UQKOwsvXBqZXI/A+o6iOXP7RsUcMVreE Oph5nfVt1hiWAAca1WEEjbywpfl65rubiRtk9GelfgKE+2AhGjBmGN32I04xRlohrJXm VjXfN8Zx6hrYPJebn/LUfRt0eL4hKNZ3wS7ranimpEG92SLrn4Zpcirl83XpS6ftMYe+ 3yzHoom/hVBrtshXWjr6LRj7Vo1lvzoYJ79PmZx3M1Bk2Q79VU0FifdRMwhbUD+ngH3B U7bJWtrkKbUcg0RZX56UwPVJIzAcCcH9L1UAOhw6c4gcr2ztCiC8Gt4eQutXA9RyfCMf l4sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id e190-20020a6369c7000000b005c278464e08si13132787pgc.275.2023.11.29.01.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:49:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1431080ACFF1; Wed, 29 Nov 2023 01:49:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230179AbjK2Js2 (ORCPT + 99 others); Wed, 29 Nov 2023 04:48:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbjK2JsF (ORCPT ); Wed, 29 Nov 2023 04:48:05 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 031A819AB; Wed, 29 Nov 2023 01:48:10 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SgDyJ4hZ5zvR8t; Wed, 29 Nov 2023 17:47:36 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 29 Nov 2023 17:48:07 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH for-rc 2/6] RDMA/hns: Response dmac to userspace Date: Wed, 29 Nov 2023 17:44:30 +0800 Message-ID: <20231129094434.134528-3-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231129094434.134528-1-huangjunxian6@hisilicon.com> References: <20231129094434.134528-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 29 Nov 2023 01:49:01 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783891328726297296 X-GMAIL-MSGID: 1783891328726297296 While creating AH, dmac is already resolved in kernel. Response dmac to userspace so that userspace doesn't need to resolve dmac repeatedly. Signed-off-by: Junxian Huang --- drivers/infiniband/hw/hns/hns_roce_ah.c | 7 +++++++ include/uapi/rdma/hns-abi.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/drivers/infiniband/hw/hns/hns_roce_ah.c b/drivers/infiniband/hw/hns/hns_roce_ah.c index 3df032ddda18..e839a83c4b8f 100644 --- a/drivers/infiniband/hw/hns/hns_roce_ah.c +++ b/drivers/infiniband/hw/hns/hns_roce_ah.c @@ -57,6 +57,7 @@ int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, struct rdma_ah_attr *ah_attr = init_attr->ah_attr; const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr); struct hns_roce_dev *hr_dev = to_hr_dev(ibah->device); + struct hns_roce_ib_create_ah_resp resp = {}; struct hns_roce_ah *ah = to_hr_ah(ibah); int ret = 0; u32 max_sl; @@ -97,6 +98,12 @@ int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, ah->av.vlan_en = ah->av.vlan_id < VLAN_N_VID; } + if (udata) { + memcpy(resp.dmac, ah_attr->roce.dmac, ETH_ALEN); + ret = ib_copy_to_udata(udata, &resp, + min(udata->outlen, sizeof(resp))); + } + return ret; } diff --git a/include/uapi/rdma/hns-abi.h b/include/uapi/rdma/hns-abi.h index ce0f37f83416..c996e151081e 100644 --- a/include/uapi/rdma/hns-abi.h +++ b/include/uapi/rdma/hns-abi.h @@ -125,4 +125,9 @@ struct hns_roce_ib_alloc_pd_resp { __u32 pdn; }; +struct hns_roce_ib_create_ah_resp { + __u8 dmac[6]; + __u8 reserved[2]; +}; + #endif /* HNS_ABI_USER_H */