Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1591204rdb; Thu, 7 Dec 2023 03:46:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqv7oO/h6IS4rjdaFOAu/S9v03ZUlFC8e7xwlx9+WJgwgMMH5fJrTK2bEgw0Mi+5Ee24h8 X-Received: by 2002:a62:cf87:0:b0:6ce:2731:79f8 with SMTP id b129-20020a62cf87000000b006ce273179f8mr1664145pfg.46.1701949591044; Thu, 07 Dec 2023 03:46:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701949591; cv=none; d=google.com; s=arc-20160816; b=Jo4U42kAnRQgTQNASun16V6jGNS/dYTCWmDf1TzjaZlGBw7g0kHB+wDo3pdHydwCe0 VGl3hMikp8Qq0geUrMzsxCulPVooaoyQatCh3ZjbPncBCGE5GXT+yY42MkDaeV+aaXO/ KQQ4wHtHTFCBXqASCe+vwxVcHs2RdYuGbgm1e/jRLCUoI7D2H+0BXYUxt4lsvFJ0X3Os 2FlzA4kyvKkHJU9Jot7SnRzA8EzFPlxOdZfdEYRJKo/DBokHLSIPMuHgGl+wRiStGoDJ jmDuJSvmbKm2IMNmAahpG/zcFJQgiEnNAqEJH5peGAWIFsA4/QdsxjXH6QC7JwQSXbhm QzEQ== 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=ZgbsRgbMUMlEqhh5ZfKy65FqTSm42DA47B5sqf3lK6U=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=AYWMwlqq2dtBQm3FTR1hNlaEWf/6dG/tLx/ez6SDo198iKmKn3AwMu76HBC+4AnMQH MzcL0Ih2ai9QqtPSFASNUd7dP5lGRLBCHbokHLLsFFi+JN/9zP/U8mo7724v1jKdOOib X6xKU75Zfq1l+7eoxRlK/urlBRF0ATUqKhiZ1tpzBEk8REA6kwSe40vVtlDDDiFSJmaM 2pWjUvBui2mxvCXhAkfhEpUBelqQSOs0GqUTQPfc5aPi1xDNXxO2gs254D1uUvauMzDD nTEmFh9GiHxJ9amPzHaVdGQotkEjzIOkEOdcWPoaouvAEbFxQqXkowZ3nQ5ShOVPN/d8 K0TA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id b17-20020a656691000000b005c658bf308fsi1042980pgw.323.2023.12.07.03.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 03:46:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id B22878079AFC; Thu, 7 Dec 2023 03:46:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379007AbjLGLqO (ORCPT + 99 others); Thu, 7 Dec 2023 06:46:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232493AbjLGLqF (ORCPT ); Thu, 7 Dec 2023 06:46:05 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7EE4137; Thu, 7 Dec 2023 03:46:10 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SmCBc4MnszYsp3; Thu, 7 Dec 2023 19:45:28 +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; Thu, 7 Dec 2023 19:46:08 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH v2 for-next 2/5] RDMA/hns: Response dmac to userspace Date: Thu, 7 Dec 2023 19:42:28 +0800 Message-ID: <20231207114231.2872104-3-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231207114231.2872104-1-huangjunxian6@hisilicon.com> References: <20231207114231.2872104-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 07 Dec 2023 03:46:28 -0800 (PST) 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 fbf046982374..b4209b6aed8d 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))); + } + err_out: if (ret) atomic64_inc(&hr_dev->dfx_cnt[HNS_ROCE_DFX_AH_CREATE_ERR_CNT]); 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 */ -- 2.30.0