From patchwork Tue Sep 19 14:41:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Gu X-Patchwork-Id: 141926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3445477vqi; Tue, 19 Sep 2023 07:49:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHiRUzv34sMrDBBAYDiB0F9yFkQy9OfVsTfQ8g+/RO+FNDrzhrereNrTwwkWnNwZ5DPtXop X-Received: by 2002:a17:902:b494:b0:1bc:6c8:cded with SMTP id y20-20020a170902b49400b001bc06c8cdedmr11721228plr.67.1695134961895; Tue, 19 Sep 2023 07:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695134961; cv=none; d=google.com; s=arc-20160816; b=yGjL3jRByM9zszOM3SRzZVgOGyPdjgARZAxjUXpDlPrB13c2TWRVpkm5o37Klj/3CC SND7W16D56SdhcFh+HlzjwDb8vpvWcK1ROOeEf7S30YVbop6VuOoZHVmlwDWlvSjpwf+ hdsK6B/H/twsmx9gMSWKqvNZ/PBRwrdqIjZyxiB/i0arUrZixUp9BNzIFM37jEe14mBW nj969ptewlLCoa+jHlvmO0K8N74lGbqo+7dDXbODZs2oSK5HACutNY9jkz5NY6pI19BZ XGiag0RgK6mg12cE9u2vi1JSXof0twq1P53WLLRLQBGLSBCPMSs5npB+YAe3/8WVQy9w /qgw== 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=+47dTlC+Vj/P01OqcMc0YmlorliQR5W9SpHf6vBNwl8=; fh=2Ks5OhTjwS8gZt4F+VGxBODwUEQ0u2wJBF3lQY5ZqAM=; b=s+vsivhzbHiySnyQ78irv7hSx92QV/b3flA9Zr4A7bCYWw2kTyLMgX56b50Nw73eL9 /5+qkdskj3l/Z1GmmWH3CvzPaXa8iTojzo+ldGYOLp31eeHje/ygcwX9armWPomTdt6B FRgEocDJhmfO/BynSINqSEP9HKJQemG2Eqo7A7ZlZVQEK7h93J7gZXamirTTUeIhsUKC 5qNuUMev2DDWSlxLlqAeSchmfZCcQDhneY4so26PUMbKO69MnJUFcN1FAFshkidwkXL1 UYObB0GLwLJg82Cba7zqXs9+ungVhl1ml7vWqChTlTWDycKQO5FW+xDlkPJulGVQZAAi Xz1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id j6-20020a170903024600b001b9e31bda39si10415936plh.118.2023.09.19.07.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 07:49:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 5F11B81BDA47; Tue, 19 Sep 2023 07:43:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232918AbjISOnA (ORCPT + 26 others); Tue, 19 Sep 2023 10:43:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232877AbjISOmv (ORCPT ); Tue, 19 Sep 2023 10:42:51 -0400 Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A048D6; Tue, 19 Sep 2023 07:42:44 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R701e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0VsRxW5r_1695134559; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0VsRxW5r_1695134559) by smtp.aliyun-inc.com; Tue, 19 Sep 2023 22:42:41 +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: alibuda@linux.alibaba.com, tonylu@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 03/18] net/smc: extract v2 check helper from SMC-D device registration Date: Tue, 19 Sep 2023 22:41:47 +0800 Message-Id: <1695134522-126655-4-git-send-email-guwen@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1695134522-126655-1-git-send-email-guwen@linux.alibaba.com> References: <1695134522-126655-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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 07:43:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777477837633440473 X-GMAIL-MSGID: 1777477837633440473 This patch extracts v2-capable logic from the process of registering the ISM device as an SMC-D device, so that the registration process of other underlying devices can reuse it. Signed-off-by: Wen Gu --- net/smc/smc_ism.c | 29 ++++++++++++++++++----------- net/smc/smc_ism.h | 1 + 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c index 9e53bcf..6fa87d8 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -69,6 +69,22 @@ bool smc_ism_is_v2_capable(void) return smc_ism_v2_capable; } +/* must be called under smcd_dev_list.mutex lock */ +void smc_ism_check_v2_capable(struct smcd_dev *smcd) +{ + u8 *system_eid = NULL; + + if (smc_ism_v2_capable) + return; + + system_eid = smcd->ops->get_system_eid(); + if (smcd->ops->supports_v2()) { + smc_ism_v2_capable = true; + memcpy(smc_ism_v2_system_eid, system_eid, + SMC_MAX_EID_LEN); + } +} + /* Set a connection using this DMBE. */ void smc_ism_set_conn(struct smc_connection *conn) { @@ -424,16 +440,7 @@ static void smcd_register_dev(struct ism_dev *ism) smc_pnetid_by_table_smcd(smcd); mutex_lock(&smcd_dev_list.mutex); - if (list_empty(&smcd_dev_list.list)) { - u8 *system_eid = NULL; - - system_eid = smcd->ops->get_system_eid(); - if (smcd->ops->supports_v2()) { - smc_ism_v2_capable = true; - memcpy(smc_ism_v2_system_eid, system_eid, - SMC_MAX_EID_LEN); - } - } + smc_ism_check_v2_capable(smcd); /* sort list: devices without pnetid before devices with pnetid */ if (smcd->pnetid[0]) list_add_tail(&smcd->list, &smcd_dev_list.list); @@ -536,10 +543,10 @@ int smc_ism_init(void) { int rc = 0; -#if IS_ENABLED(CONFIG_ISM) smc_ism_v2_capable = false; memset(smc_ism_v2_system_eid, 0, SMC_MAX_EID_LEN); +#if IS_ENABLED(CONFIG_ISM) rc = ism_register_client(&smc_ism_client); #endif return rc; diff --git a/net/smc/smc_ism.h b/net/smc/smc_ism.h index 832b2f4..14d2e77 100644 --- a/net/smc/smc_ism.h +++ b/net/smc/smc_ism.h @@ -42,6 +42,7 @@ int smc_ism_register_dmb(struct smc_link_group *lgr, int buf_size, void smc_ism_get_system_eid(u8 **eid); u16 smc_ism_get_chid(struct smcd_dev *dev); bool smc_ism_is_v2_capable(void); +void smc_ism_check_v2_capable(struct smcd_dev *dev); int smc_ism_init(void); void smc_ism_exit(void); int smcd_nl_get_device(struct sk_buff *skb, struct netlink_callback *cb);