Received: by 2002:a05:7208:70d5:b0:7f:5597:fa5c with SMTP id q21csp2214793rba; Sun, 24 Mar 2024 06:57:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUR37xplde00hlwiJomw/Ru5VAv2Cbh/ErSID/Z8if4Xk8XMab1unsyUVtFDDHtt9HaHUWDIjYAQD3u3NtSTcR+oE9tnG8bMH0V+yVhhQ== X-Google-Smtp-Source: AGHT+IHYP30ZD7xhkZ08Kq//ojLjCHCvZyiC7LM2rl07pyzK8mQd64Nc/eEs3oVAMpUwcU/Jwq4f X-Received: by 2002:a05:6a00:b43:b0:6e4:62ed:23c3 with SMTP id p3-20020a056a000b4300b006e462ed23c3mr7338387pfo.9.1711288638877; Sun, 24 Mar 2024 06:57:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711288638; cv=pass; d=google.com; s=arc-20160816; b=pFGgaaOpuQYTq9Mzo8+mr263dP19j4D6cEdnOoQSN+ckpedlxzLd9HqE0csIGXEPjp Sdc+/LPPmTfSmtBuss32cBwQM9s9pCCAjjZ+fstQATVEupJ5ftRsxKZu+X4AtSXQI+R6 q/LRfcfqIJyTPkNDEoRJS/4XAUv7Cj6k6WvygmuI2nA9Y/QozVT2YaKxXe+3xRPXLTvH 8sLYe17rarhHvMZBG9AA2SW6slLo8uvHcHa2VQX2Zl+rwmmvcMgfBZM+LHFIgTDPH5pS cM7ie36j+omz8kyt9WgTcV2c4esa4ySDe3QZnniIOePj2dl0peEWVFWQUDD5aaj4slxI MeMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Sx8Stdecs/B8G/DClK+hIesJCh7pZJGeKI91YYQmuB0=; fh=dZ+5j4HvJgOzvN8nB02tgPlkwHWSh0WzjxQ9fqEQCrY=; b=ruFi+BjEbnQPyu3sRR1xAYYXlEaiImmrZcHgIMA+ybPp9JiVYhLtT5hXDs0tJAK0NW a0T73Ouh0j8kB2o4CLr0YdMMw0ePEkC7DUFT6ByJpmEYzWfmEvAhFocU+4pE4TctdbpU lFZKVWCX5u60TaKvUpGyEJbuXq2020+jGJ+It+L4L6GJ+MVc8IYdgkbnR9DNK76+IvcB Kk5DpEk9ZLS1STKajmv42PRLgRry2B5GUagDR7iUZxR3OZKVO+rDNWODnEpaej5U/Ytr J+N0eZivjY82AJSRHvEk81OFCOg/PVMPa0s7C76qci5W1xqystMpL7MnRmdhKkBiA/o0 WCPA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=hu2p9pWD; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-112691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112691-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x6-20020a626306000000b006ea90bbe709si3474817pfb.339.2024.03.24.06.57.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 06:57:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=hu2p9pWD; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-112691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112691-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 08421B2122E for ; Sun, 24 Mar 2024 13:56:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CEB31B59F; Sun, 24 Mar 2024 13:55:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="hu2p9pWD" Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAC5418E3A; Sun, 24 Mar 2024 13:55:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711288544; cv=none; b=OezNRkBRbBS6RGG4UsMEdSax+/H8IGxkGMrRXjabUCEF1NTB9wAzaumaFDxFJDZVqYqF94Ka9fSsmxT1MzNqa6VV3U2sfzBCLIiGhNh36xeYaWC7rmTSa/sUv7PjsQhoJ+xviiUWIYles7ps1xk1t8TGcZlolBDTpi1J/wdRYBA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711288544; c=relaxed/simple; bh=je+eZyQU6jp+Pv4SlGJfzl9JB+vuOQZNigijjGElmm8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yz6CPfPyJTIhH5N0xEh3GrSzlEivgdZCz9Sk5AIHa3GnrLT4V0oHtsyFoCHiScccNs3G6WrfuNqtN2QLVGgeEyx/5za6KheMAd4EJwqDfF3U5pjPCqE2caKlXOAJ9qkZ4sbiv1dvfoJjCwZ1PPKWhQKFjcUQTRA4zSshHhIkfw0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=hu2p9pWD; arc=none smtp.client-ip=115.124.30.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1711288534; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=Sx8Stdecs/B8G/DClK+hIesJCh7pZJGeKI91YYQmuB0=; b=hu2p9pWDpurOYMg99zNeZniNnOxGvyiuzJqBDyhfVd2qqEtyiAE2Eoee53nKTK8ogeuPUaL7ODVKiHvoC1rRNuJTh1ZBSoZT3A7Apbj8trg0EM+CpXwqXHIIUN5M3/z3sgB+pmFqug4sXPKuiiPzH6KcjTNKeWfom04jOJxDX3c= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0W372W5l_1711288531; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0W372W5l_1711288531) by smtp.aliyun-inc.com; Sun, 24 Mar 2024 21:55:33 +0800 From: Wen Gu To: wintera@linux.ibm.com, twinkler@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, wenjia@linux.ibm.com, jaka@linux.ibm.com Cc: borntraeger@linux.ibm.com, svens@linux.ibm.com, alibuda@linux.alibaba.com, tonylu@linux.alibaba.com, guwen@linux.alibaba.com, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH net-next v5 03/11] net/smc: implement ID-related operations of loopback-ism Date: Sun, 24 Mar 2024 21:55:14 +0800 Message-Id: <20240324135522.108564-4-guwen@linux.alibaba.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f In-Reply-To: <20240324135522.108564-1-guwen@linux.alibaba.com> References: <20240324135522.108564-1-guwen@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This implements operations related to IDs for the loopback-ism device. loopback-ism uses an Extended GID that is a 128-bit GID instead of the existing ISM 64-bit GID, and uses the CHID defined with the reserved value 0xFFFF. Signed-off-by: Wen Gu --- net/smc/smc_loopback.c | 62 ++++++++++++++++++++++++++++++++++++++---- net/smc/smc_loopback.h | 3 ++ 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/net/smc/smc_loopback.c b/net/smc/smc_loopback.c index 3990f689ae79..3eb623e030eb 100644 --- a/net/smc/smc_loopback.c +++ b/net/smc/smc_loopback.c @@ -19,11 +19,62 @@ #include "smc_loopback.h" #if IS_ENABLED(CONFIG_SMC_LO) +#define SMC_LO_V2_CAPABLE 0x1 /* loopback-ism acts as ISMv2 */ + static const char smc_lo_dev_name[] = "loopback-ism"; static struct smc_lo_dev *lo_dev; +static void smc_lo_generate_ids(struct smc_lo_dev *ldev) +{ + struct smcd_gid *lgid = &ldev->local_gid; + uuid_t uuid; + + uuid_gen(&uuid); + memcpy(&lgid->gid, &uuid, sizeof(lgid->gid)); + memcpy(&lgid->gid_ext, (u8 *)&uuid + sizeof(lgid->gid), + sizeof(lgid->gid_ext)); + + ldev->chid = SMC_LO_RESERVED_CHID; +} + +static int smc_lo_query_rgid(struct smcd_dev *smcd, struct smcd_gid *rgid, + u32 vid_valid, u32 vid) +{ + struct smc_lo_dev *ldev = smcd->priv; + + /* rgid should be the same as lgid */ + if (!ldev || rgid->gid != ldev->local_gid.gid || + rgid->gid_ext != ldev->local_gid.gid_ext) + return -ENETUNREACH; + return 0; +} + +static int smc_lo_supports_v2(void) +{ + return SMC_LO_V2_CAPABLE; +} + +static void smc_lo_get_local_gid(struct smcd_dev *smcd, + struct smcd_gid *smcd_gid) +{ + struct smc_lo_dev *ldev = smcd->priv; + + smcd_gid->gid = ldev->local_gid.gid; + smcd_gid->gid_ext = ldev->local_gid.gid_ext; +} + +static u16 smc_lo_get_chid(struct smcd_dev *smcd) +{ + return ((struct smc_lo_dev *)smcd->priv)->chid; +} + +static struct device *smc_lo_get_dev(struct smcd_dev *smcd) +{ + return &((struct smc_lo_dev *)smcd->priv)->dev; +} + static const struct smcd_ops lo_ops = { - .query_remote_gid = NULL, + .query_remote_gid = smc_lo_query_rgid, .register_dmb = NULL, .unregister_dmb = NULL, .add_vlan_id = NULL, @@ -32,10 +83,10 @@ static const struct smcd_ops lo_ops = { .reset_vlan_required = NULL, .signal_event = NULL, .move_data = NULL, - .supports_v2 = NULL, - .get_local_gid = NULL, - .get_chid = NULL, - .get_dev = NULL, + .supports_v2 = smc_lo_supports_v2, + .get_local_gid = smc_lo_get_local_gid, + .get_chid = smc_lo_get_chid, + .get_dev = smc_lo_get_dev, }; static struct smcd_dev *smcd_lo_alloc_dev(const struct smcd_ops *ops, @@ -95,6 +146,7 @@ static void smcd_lo_unregister_dev(struct smc_lo_dev *ldev) static int smc_lo_dev_init(struct smc_lo_dev *ldev) { + smc_lo_generate_ids(ldev); return smcd_lo_register_dev(ldev); } diff --git a/net/smc/smc_loopback.h b/net/smc/smc_loopback.h index 77980650b2bd..11868e5ac732 100644 --- a/net/smc/smc_loopback.h +++ b/net/smc/smc_loopback.h @@ -20,10 +20,13 @@ #if IS_ENABLED(CONFIG_SMC_LO) #define SMC_LO_MAX_DMBS 5000 +#define SMC_LO_RESERVED_CHID 0xFFFF struct smc_lo_dev { struct smcd_dev *smcd; struct device dev; + u16 chid; + struct smcd_gid local_gid; }; #endif -- 2.32.0.3.g01195cf9f