From patchwork Sun Apr 23 12:17:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Gu X-Patchwork-Id: 86711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2173939vqo; Sun, 23 Apr 2023 05:35:38 -0700 (PDT) X-Google-Smtp-Source: AKy350YRRksiw102toboomQbN1ALL7QHzqWuY2SAFOi5deI6Eea8jBrbaQdPNZhT7HG1+D4o8BXk X-Received: by 2002:a17:902:cec9:b0:1a5:1842:f7da with SMTP id d9-20020a170902cec900b001a51842f7damr18020897plg.6.1682253338253; Sun, 23 Apr 2023 05:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682253338; cv=none; d=google.com; s=arc-20160816; b=Xkkp5OhAUT1GkljkoMX3lPasff3qmXw7CUZ/iN7hC+qv4oNtN10/zggS4dIUyvO8Pg pf0+wMdEwTddVfnWWOIjDK8aACN4Ld53GX42dVo1JFnJ+s6R50ZIdtHYfAENU3O8H1d6 hvsEOO0Kia07cpUu0y5YP28lnPqxpSqEWQLxqrfqcnfHGpuwUGDfkfRmy7E1rlPUjAk8 c9Q4A1TN5XrDQJTyUWsLeDBFbW7RH7VnhL7txlnW5mWwk3F2PbClHd6EsQYFu5uHpyBS w1LOU4i4ASJDckyQFLhP90VfAlZ66wvRueRg5fbaZwFfkhvFZfsbU2a416olAnvZN6Nk cIFQ== 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=dwOnnlFrAXrktW1lI0OTmz1+yBrD5vcOOkfiQEPC/14=; b=jQmyT9v8zHJCzNhbTuPrCBe/O9yisWOoTN1I/yuwJihFI/iCbWaTCjbmN8+UVFrlaR Z0rZAzHm1rzTcDtzC7142yXPA3fEBTq9wub7ccn/YJSheCYZDTvy21mVM6FQrdalLM6V 0tGp1SesDWdvAIMSQ41fi2vsbSRoDl/BsirG38et5d5fakOIvCcswt44gKtgQUawhSL0 U8pKMo1LrFhC2pmIoz2peAwrzBbQV+cGHz9nyt8ZgDBotEkMZg+GxW7wWTBlr+PhbOos XmSJzbKSqJuVSMQMrP5tVW0o8pLogAvEwno6L1oxmG/y+7NsgJzimny/0VYZrdUZfQRs tTwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go8-20020a17090b03c800b002373125c085si8893037pjb.141.2023.04.23.05.35.23; Sun, 23 Apr 2023 05:35:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbjDWMSW (ORCPT + 99 others); Sun, 23 Apr 2023 08:18:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230038AbjDWMSQ (ORCPT ); Sun, 23 Apr 2023 08:18:16 -0400 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F9DD10F0; Sun, 23 Apr 2023 05:18:04 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;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=10;SR=0;TI=SMTPD_---0VgjzSOT_1682252278; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0VgjzSOT_1682252278) by smtp.aliyun-inc.com; Sun, 23 Apr 2023 20:17:59 +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: linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next v5 3/9] net/smc: Extract v2 check helper from SMC-D device registration Date: Sun, 23 Apr 2023 20:17:45 +0800 Message-Id: <1682252271-2544-4-git-send-email-guwen@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1682252271-2544-1-git-send-email-guwen@linux.alibaba.com> References: <1682252271-2544-1-git-send-email-guwen@linux.alibaba.com> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763970476528315595?= X-GMAIL-MSGID: =?utf-8?q?1763970476528315595?= 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 | 27 +++++++++++++++++---------- net/smc/smc_ism.h | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c index d4709ca..8ad4c71 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 (!list_empty(&smcd_dev_list.list)) + 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) { @@ -422,16 +438,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); 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);