Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp695089lqa; Sat, 27 Apr 2024 23:09:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVT4lipJl7yoQQiI4cPqKS6/sa7t2L7PYx36Z8HhJ/ur/RNL+qXfy5FGkiLU96IPUug/uGPyXJMCguprcvsJr4OqSyhOi446NG38aLfGw== X-Google-Smtp-Source: AGHT+IE6up7PplweZvPIKHqtaHsI2G9WwaaNzK49nM2YkzHYb9IPSwvxeuM+A+f3BPOXx3ByM+o/ X-Received: by 2002:a50:c049:0:b0:571:b9ac:ff3d with SMTP id u9-20020a50c049000000b00571b9acff3dmr4442452edd.4.1714284557873; Sat, 27 Apr 2024 23:09:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714284557; cv=pass; d=google.com; s=arc-20160816; b=DgZGuewxPhI/YgVzE16WmF6bydwr4i5to9MND/GHYwC+rqdak8jqsMmqdd29lPEHm7 8gD9AYXn7QhOoyQSfJFCUNRyt3HhodC0msak0RDNP9reDE7ZnubY+MmKzlq5vJ7WR9VM iB0DibeEGJQm2bSG2gBJg1U2CEHgUDJbdkBqFor6HErPYZiHqNSrrxDikZb3v2hK1qX6 3EBXQ4kz49fv/6dOPyTfKNQ9A14wSl1rQe+/e12JM2QizF8+dIxavN46BzY2QyPRH5JT eU7w6LHoz+bRKgKv7B/QW5FhCbyWpkZ2edFnnc6KRgHFXIx5OoEzyg4uqTSEKDCs9Ehn hlhA== 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=l2Yps7c5Bty1sh7vbh22vWd/lSPyr22qvyKVft35gVY=; fh=dZ+5j4HvJgOzvN8nB02tgPlkwHWSh0WzjxQ9fqEQCrY=; b=eYQHOBIn5FEqrArgSnoZmVdGPbzFGJfegv8/9ZEdC3wHQku+v3tGXM18H/zK/uGKI+ aFeza8/APX8xDo35zQO/sRdapyUWR6PmTvcG4in890Xv+0EB2clv1q7mQ1N3/79P3qHm QTp3wvAHegAPDXAh76kcKrrjXpgxJlzF5bBS7XfFGAvh917g8i7MQpRcbaS/j/fXf46Q 3WIdafgpwLk4FXFx9Z7EFA7T85hw3JoxfndlrQbce/6vYyU80AQosQRuZ4AS3/FaSXNx /yo/kLoR/nP8UchqLVdiUqUOJuajWVUqcMxzuNGsuNaBIL3g9Y9nUBq7H6WWyqmWqWHR 26cw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=MC++bQWh; 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-161273-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161273-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 am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u11-20020a05640207cb00b00572726f6ba5si957661edy.546.2024.04.27.23.09.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 23:09:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161273-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=MC++bQWh; 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-161273-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161273-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 716391F216D1 for ; Sun, 28 Apr 2024 06:09:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8BA1A2E822; Sun, 28 Apr 2024 06:08:01 +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="MC++bQWh" Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (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 3136225601; Sun, 28 Apr 2024 06:07:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714284480; cv=none; b=h+7+A9JUKa3Xndjbj80J9JrrIvDOWfaMheQPwh+XyVwHFCyeJ8z8T6mtnzDpI6mdfvNWm8xHpOUz2wIe/LyVrtSZrUq4n9hBM2qgHqWh4sXd9jAMuxPWVNNUJKRbYEMYtDlmf82sYu+g7KL8relhXIGsmNzAJ6VwiYm4X8N8Dro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714284480; c=relaxed/simple; bh=K60X7h90/uD+qZ8BrD49lGCe+O6q6gKnxUPjgBIXdpA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PWNqF/nXP9Ap8L6EmpsxN4mYxtQQ2vry1RXqsL5EDnUTVeGgE4Uiu1pe+2t24OAVLM4pFznVITViN+1WXPacCMeL3HNVBFoBxuKVLjXN6W/rD+wjiTJNdSbd1Ezlnx8spRLxn4W6a8dTXJZWZjKeAbEYf4bNtKSjrwW4dWbT90M= 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=MC++bQWh; arc=none smtp.client-ip=115.124.30.100 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=1714284469; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=l2Yps7c5Bty1sh7vbh22vWd/lSPyr22qvyKVft35gVY=; b=MC++bQWhhuFfUV2uBPX2WDYtbAqZOVhkVTlcjftJyE49eBYF/kMvfMJwCgRW7PmcW/ANjzYep+2qK/fB6P9lq6gEiElbaSdEeUeq3SQudaQofCs3iigoCC38XByZYM3rTF8vhXVm2j1GamYZhafebYb8nlZMCN72DWK6RtLixa8= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R321e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067112;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0W5NS3AC_1714284466; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0W5NS3AC_1714284466) by smtp.aliyun-inc.com; Sun, 28 Apr 2024 14:07:48 +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: [PATCH net-next v7 03/11] net/smc: implement ID-related operations of loopback-ism Date: Sun, 28 Apr 2024 14:07:30 +0800 Message-Id: <20240428060738.60843-4-guwen@linux.alibaba.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f In-Reply-To: <20240428060738.60843-1-guwen@linux.alibaba.com> References: <20240428060738.60843-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 Reviewed-by: Wenjia Zhang Reviewed-and-tested-by: Jan Karcher --- 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 c364e3e6e3fb..0349632a76c4 100644 --- a/net/smc/smc_loopback.c +++ b/net/smc/smc_loopback.c @@ -18,11 +18,62 @@ #include "smc_ism.h" #include "smc_loopback.h" +#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, @@ -31,10 +82,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, @@ -94,6 +145,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 7fc4b374bc82..d7df79f7bb64 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; }; int smc_loopback_init(void); -- 2.32.0.3.g01195cf9f