From patchwork Thu Dec 7 11:42:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 175092 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4721318vqy; Thu, 7 Dec 2023 03:46:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHc6ucj0itQP1Ze6Q0jUrhylhpwj0MLIbrk3Y5b4qB0OZEWzdslLGl1Ofw+T7RzH7uemEtJ X-Received: by 2002:a05:6a20:3c90:b0:190:6ee:3e9a with SMTP id b16-20020a056a203c9000b0019006ee3e9amr511796pzj.108.1701949587311; Thu, 07 Dec 2023 03:46:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701949587; cv=none; d=google.com; s=arc-20160816; b=VOZQFoa3eiKCv7cOHaEjaPsWtFnNB3L3s9FJYsY2rpMCzS0i83ftxGDQiZKZcQ04sc ZVYsxuGWD1/KI2snPwlg1cguxYpBsh+xEgfa9+Tj3BlrOIu6tALsaB++GMKijKTOdx+B Ed76Qh4LeV7TEct3iccfvuoDh0cUf2zik93nQVxKCowplQsJdyhvl1fN9R5I5QhKl4no kK3Yfz5zUdmAtF5zQdOSwqKm0UvrK3cUS9OeGFl1gL6Odl+z/mp+qOBy+RMV9OjLx2At HVZyUq+GMqQb0KiSSnn5D76cNpuURFGcZghdWPBf3FTVkUfJGJTxhu1t8NqikIS5okBH HV8w== 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 Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id bz36-20020a056a02062400b005c65c11ad0dsi1092011pgb.772.2023.12.07.03.46.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 03:46:27 -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 ED0E98034637; Thu, 7 Dec 2023 03:46:24 -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 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:25 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784623490255460553 X-GMAIL-MSGID: 1784623490255460553 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 */