Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp709220rdh; Sun, 24 Sep 2023 08:19:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRtFDxTQXBCk0ZvUtNc/8xIfqRIB1lDzimKnJxBijHWERX+xQ5eNHHuWFTUGysCCtoxXNM X-Received: by 2002:a92:d341:0:b0:34f:2484:64ce with SMTP id a1-20020a92d341000000b0034f248464cemr5235640ilh.23.1695568739802; Sun, 24 Sep 2023 08:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695568739; cv=none; d=google.com; s=arc-20160816; b=nyOPf9AkFDykOjbD2PRnQrLFejNk3Kfs/+lj7YJd2dOUfbqAEc/b+pYF7nWWZUq4PS +PTCJoofnAUgccuRjLWFeWuAlV+txv2z9iP2x0zrWeAkskdoDg5yhAzrqnxtjo3AALPC a8eO/KOrs0Bgo3RH2U+9g6oIAxNxSZv2dARl+D7KuncH/9ZQhUOK8+Fbb89RSAAgOrPT YK3U7ZJLlHs6HqraAmVeYGGUx/xbdSdTkpyM/FAmSCItMHGzawZJMB2JRFsHeOhL9pW9 02p0VB1F9Fy50ma+4Ddd1ogy5MhHRdUgOLyq6UpamqSVa5+mco61c59lc1lsTlGLfk3j y0dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=0qOiCvainaNcdtZKyF4Y6WFfKvyMXdWNzKozxRKr+Bg=; fh=kTBstCixiri9Ahdk8UNuw7wmcx8Ry+mqafUdDsc8Vd0=; b=HwmEo/sHUz4D/YlSMnBIf3J3lEejVZhaRJG+Kj2d0pWZ9smJ+/ODnpvfra/qj2sjlu Sdtm83Ua8oJGeSPOD7GkJ1/tflZf9UtpwcgzqyIviOoWOgpLS0UDgM7CDi4Uqg40tqt+ 9h7eTv7Uv4vSP9q+7HLc/TxpLidZAQaoGGwclDT34qufLZ3PrcLwwQ/7Y22yZ2ALGOE7 FKZApqeRucaTxAI8U9jI3wfL2QM0hvnjGOwUsUrZ+AOgA9yvGFZG1RthAi12MZMgn89Z sOgqGF7EPWw5TdumYdK25dPgd3UkGnxhm42nCSeaehWQnxuJkVBxZVTZy3Z0QB6CnAsC 4IuQ== 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=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id i7-20020a636d07000000b0057745b2d018si5361212pgc.390.2023.09.24.08.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 08:18:59 -0700 (PDT) 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=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 598E5801F82A; Sun, 24 Sep 2023 08:18:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230001AbjIXPSY (ORCPT + 99 others); Sun, 24 Sep 2023 11:18:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229593AbjIXPR6 (ORCPT ); Sun, 24 Sep 2023 11:17:58 -0400 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51A3410D0; Sun, 24 Sep 2023 08:17:37 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=18;SR=0;TI=SMTPD_---0VsinOet_1695568651; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0VsinOet_1695568651) by smtp.aliyun-inc.com; Sun, 24 Sep 2023 23:17:33 +0800 From: Wen Gu To: kgraul@linux.ibm.com, wenjia@linux.ibm.com, jaka@linux.ibm.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: wintera@linux.ibm.com, schnelle@linux.ibm.com, gbayer@linux.ibm.com, pasic@linux.ibm.com, alibuda@linux.alibaba.com, tonylu@linux.alibaba.com, dust.li@linux.alibaba.com, guwen@linux.alibaba.com, linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 15/18] net/smc: add operations for DMB attach and detach Date: Sun, 24 Sep 2023 23:16:50 +0800 Message-Id: <1695568613-125057-16-git-send-email-guwen@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1695568613-125057-1-git-send-email-guwen@linux.alibaba.com> References: <1695568613-125057-1-git-send-email-guwen@linux.alibaba.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY 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]); Sun, 24 Sep 2023 08:18:57 -0700 (PDT) This patch extends smcd_ops, adding two more semantic for SMC-D DMB: - attach_dmb: Attach an already registered DMB to a specific buf_desc, so that we can refer to the DMB through this buf_desc. - detach_dmb: Reverse operation of attach_dmb. detach the DMB from the buf_desc. This interface extension is to prepare for the avoidance of memory copy from sndbuf to RMB with SMC-D device whose DMBs has ISM_ATTR_DMB_MAP attribute. Signed-off-by: Wen Gu --- include/net/smc.h | 2 ++ net/smc/smc_ism.c | 31 +++++++++++++++++++++++++++++++ net/smc/smc_ism.h | 2 ++ 3 files changed, 35 insertions(+) diff --git a/include/net/smc.h b/include/net/smc.h index 917572fb..39a21ed 100644 --- a/include/net/smc.h +++ b/include/net/smc.h @@ -72,6 +72,8 @@ struct smcd_ops { int (*register_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb, void *client); int (*unregister_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb); + int (*attach_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb); + int (*detach_dmb)(struct smcd_dev *dev, u64 token); int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id); int (*del_vlan_id)(struct smcd_dev *dev, u64 vlan_id); int (*set_vlan_required)(struct smcd_dev *dev); diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c index 9b31d00..32d5d96 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -244,6 +244,37 @@ int smc_ism_register_dmb(struct smc_link_group *lgr, int dmb_len, return rc; } +int smc_ism_attach_dmb(struct smcd_dev *dev, u64 token, + struct smc_buf_desc *dmb_desc) +{ + struct smcd_dmb dmb; + int rc = 0; + + memset(&dmb, 0, sizeof(dmb)); + dmb.dmb_tok = token; + + if (!dev->ops->attach_dmb) + return -EINVAL; + + rc = dev->ops->attach_dmb(dev, &dmb); + if (!rc) { + dmb_desc->sba_idx = dmb.sba_idx; + dmb_desc->token = dmb.dmb_tok; + dmb_desc->cpu_addr = dmb.cpu_addr; + dmb_desc->dma_addr = dmb.dma_addr; + dmb_desc->len = dmb.dmb_len; + } + return rc; +} + +int smc_ism_detach_dmb(struct smcd_dev *dev, u64 token) +{ + if (!dev->ops->detach_dmb) + return -EINVAL; + + return dev->ops->detach_dmb(dev, token); +} + static int smc_nl_handle_smcd_dev(struct smcd_dev *smcd, struct sk_buff *skb, struct netlink_callback *cb) diff --git a/net/smc/smc_ism.h b/net/smc/smc_ism.h index cef212c..f30aae4 100644 --- a/net/smc/smc_ism.h +++ b/net/smc/smc_ism.h @@ -45,6 +45,8 @@ int smc_ism_register_dmb(struct smc_link_group *lgr, int buf_size, struct smc_buf_desc *dmb_desc); int smc_ism_unregister_dmb(struct smcd_dev *dev, struct smc_buf_desc *dmb_desc); bool smc_ism_dmb_mappable(struct smcd_dev *smcd); +int smc_ism_attach_dmb(struct smcd_dev *dev, u64 token, struct smc_buf_desc *dmb_desc); +int smc_ism_detach_dmb(struct smcd_dev *dev, u64 token); int smc_ism_signal_shutdown(struct smc_link_group *lgr); void smc_ism_get_system_eid(u8 **eid); u16 smc_ism_get_chid(struct smcd_dev *dev); -- 1.8.3.1