From patchwork Mon Mar 27 03:28:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Gu X-Patchwork-Id: 75195 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1258008vqo; Sun, 26 Mar 2023 21:03:27 -0700 (PDT) X-Google-Smtp-Source: AK7set+wev09xFbnN1vONQvcjKvLDZwL/wJAEHQeYwlkq7n78+NyEVBGhRk4Q8s6dQqXIOyqVuZD X-Received: by 2002:a05:6a20:92a4:b0:da:c40:8dc with SMTP id q36-20020a056a2092a400b000da0c4008dcmr7760817pzg.6.1679889806745; Sun, 26 Mar 2023 21:03:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679889806; cv=none; d=google.com; s=arc-20160816; b=gp6EsfbbDbUqrtbB8xh+avMGD9ngPb9ocJTkB3u88zbNt+BcMMLJ0zvowY9EtRyrVS a9QUmrCM5fL+eLUm92RtWGXKUCF4F6G0dWOxCnWoj2Qrs4/+IqcW+3MCuRPJhWyFQ9G7 gripfYeMP2NpXzA0fNr0LkMROMeOP389OnxcFwUXB+TTvdZs+FZex1mOAzNwCIYdMpBI oamy0dWhayiOuMV+TbvGC7255KjkVq3iRykFLew17PJcwyaWEtNgQK7UQiEzvHw3OcV3 bbdrmn1Z7h3KnuHgaoPiEUxsYUcmTLDhXFlkM0poe21bG9wpOhrem0E/2OFiC6UE/oLO ViOg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv130-20020a632e88000000b00513234112aasi7033898pgb.886.2023.03.26.21.03.11; Sun, 26 Mar 2023 21:03:26 -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 S232119AbjC0D2p (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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761492133833867222?= X-GMAIL-MSGID: =?utf-8?q?1761492133833867222?= 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);