Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2300532rwl; Sun, 26 Mar 2023 20:29:33 -0700 (PDT) X-Google-Smtp-Source: AKy350YF4B0X25uWHvwr18NPBTy7kdq754riKZ+3S8ZKFtfjSZmPNK8ebathOwsDiIHSBp7+khbL X-Received: by 2002:a17:907:b689:b0:93a:6e9c:262e with SMTP id vm9-20020a170907b68900b0093a6e9c262emr11687936ejc.23.1679887773494; Sun, 26 Mar 2023 20:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679887773; cv=none; d=google.com; s=arc-20160816; b=cvJCzKQMkUPegyM62Hz5SfZUDW/j9kqu1NDPw3eHXcH/K0L/xS1tgG6unO+101J7WE GZ1IAbpVS8y902l3234qty0lp0VgNDcJ43p7heQMLQ32VFaDfsAXvSdUCQ2n4Tz1UePv tsegjnW2+5/BPJYobOyWn94lR3K/MUztDZUCe2kgrosuAqQ1aiiCfWbdvL1dnvKzHdEI 692ZB/wPl/oaCyySBmppE39A/r9dMf7ivrOXKr6s+uoHReUkmNizGaoRg+n4cD2LXahG U45/T9/x9AhV2K1qA8U5LyxzWYutC+Tchp/myH0B/Yayx+rptyHI0E2uKYkiR3hF0+8f kAjw== 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=Kha4t9/RH9ouqBgZOUrx5h4+CYdwMCQSzHiunSlqyg6NndBFTLZCpq2k5bLLY8db1O oHtNpKeyMGBdsUzzmZlpMNFQ6Na4z5ig6mADyfPSIO+s8EM4+FAq7NWzeBB5as9+IM9W eDOuSfDKsRQ8n3kqc5C83du7fO7HcqVXVIIqE/Qlc7J9LwRmmG5XsUvnJByWwkACwzct wBL6bLa/aQGVx0gKuqDWgupWy/dsYYYn222zUGW2ZjMYrgkKW6l/ANdo1CwVvK/zcvEc Nd0l5yx7UOouULehHwC8lNRmBvNydSeq17njsoFpEkpbUTnYC6wr7Jy7K2KagQogAwws BZyg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lf14-20020a170906ae4e00b009315b84b4dasi26176600ejb.600.2023.03.26.20.29.07; Sun, 26 Mar 2023 20:29:33 -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 S232091AbjC0D2p (ORCPT + 99 others); Sun, 26 Mar 2023 23:28:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbjC0D2c (ORCPT ); Sun, 26 Mar 2023 23:28:32 -0400 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 430C940E8; Sun, 26 Mar 2023 20:28:31 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0Vef7WQP_1679887706; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0Vef7WQP_1679887706) by smtp.aliyun-inc.com; Mon, 27 Mar 2023 11:28:27 +0800 From: Wen Gu To: kgraul@linux.ibm.com, wenjia@linux.ibm.com, jaka@linux.ibm.com, wintera@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 v4 3/9] net/smc: Extract v2 check helper from SMC-D device registration Date: Mon, 27 Mar 2023 11:28:13 +0800 Message-Id: <1679887699-54797-4-git-send-email-guwen@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679887699-54797-1-git-send-email-guwen@linux.alibaba.com> References: <1679887699-54797-1-git-send-email-guwen@linux.alibaba.com> X-Spam-Status: No, score=-8.0 required=5.0 tests=ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=unavailable 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 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); -- 1.8.3.1