From: Wen Gu <guwen@linux.alibaba.com>
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 v2 2/5] net/smc: choose loopback device in SMC-D communication
Date: Tue, 20 Dec 2022 11:21:42 +0800 [thread overview]
Message-ID: <1671506505-104676-3-git-send-email-guwen@linux.alibaba.com> (raw)
In-Reply-To: <1671506505-104676-1-git-send-email-guwen@linux.alibaba.com>
This patch allows SMC-D to use loopback device.
But noted that the implementation here is quiet simple and informal.
Loopback device will always be firstly chosen, and fallback happens
if loopback communication is impossible.
It needs to be discussed how client indicates to peer that multiple
SMC-D devices are available and how server picks a suitable one.
Signed-off-by: Wen Gu <guwen@linux.alibaba.com>
---
net/smc/af_smc.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++------
net/smc/smc_clc.c | 4 +++-
net/smc/smc_ism.c | 3 ++-
3 files changed, 54 insertions(+), 8 deletions(-)
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 9546c02..b9884c8 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -979,6 +979,28 @@ static int smc_find_ism_device(struct smc_sock *smc, struct smc_init_info *ini)
return 0;
}
+/* check if there is a lo device available for this connection. */
+static int smc_find_lo_device(struct smc_sock *smc, struct smc_init_info *ini)
+{
+ struct smcd_dev *sdev;
+
+ mutex_lock(&smcd_dev_list.mutex);
+ list_for_each_entry(sdev, &smcd_dev_list.list, list) {
+ if (sdev->is_loopback && !sdev->going_away &&
+ (!ini->ism_peer_gid[0] ||
+ !smc_ism_cantalk(ini->ism_peer_gid[0], ini->vlan_id,
+ sdev))) {
+ ini->ism_dev[0] = sdev;
+ break;
+ }
+ }
+ mutex_unlock(&smcd_dev_list.mutex);
+ if (!ini->ism_dev[0])
+ return SMC_CLC_DECL_NOSMCDDEV;
+ ini->ism_chid[0] = smc_ism_get_chid(ini->ism_dev[0]);
+ return 0;
+}
+
/* is chid unique for the ism devices that are already determined? */
static bool smc_find_ism_v2_is_unique_chid(u16 chid, struct smc_init_info *ini,
int cnt)
@@ -1044,10 +1066,20 @@ static int smc_find_proposal_devices(struct smc_sock *smc,
{
int rc = 0;
- /* check if there is an ism device available */
+ /* TODO:
+ * How to indicate to peer if ism device and loopback
+ * device are both available ?
+ *
+ * The RFC patch hasn't resolved this, just simply always
+ * chooses loopback device first, and fallback if loopback
+ * communication is impossible.
+ *
+ */
+ /* check if there is an ism or loopback device available */
if (!(ini->smcd_version & SMC_V1) ||
- smc_find_ism_device(smc, ini) ||
- smc_connect_ism_vlan_setup(smc, ini))
+ (smc_find_lo_device(smc, ini) &&
+ (smc_find_ism_device(smc, ini) ||
+ smc_connect_ism_vlan_setup(smc, ini))))
ini->smcd_version &= ~SMC_V1;
/* else ISM V1 is supported for this connection */
@@ -2135,9 +2167,20 @@ static void smc_find_ism_v1_device_serv(struct smc_sock *new_smc,
goto not_found;
ini->is_smcd = true; /* prepare ISM check */
ini->ism_peer_gid[0] = ntohll(pclc_smcd->ism.gid);
- rc = smc_find_ism_device(new_smc, ini);
- if (rc)
- goto not_found;
+
+ /* TODO:
+ * How to know that peer has both loopback and ism device ?
+ *
+ * The RFC patch hasn't resolved this, simply tries loopback
+ * device first, then ism device.
+ */
+ /* find available loopback or ism device */
+ if (smc_find_lo_device(new_smc, ini)) {
+ rc = smc_find_ism_device(new_smc, ini);
+ if (rc)
+ goto not_found;
+ }
+
ini->ism_selected = 0;
rc = smc_listen_ism_init(new_smc, ini);
if (!rc)
diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
index dfb9797..3887692 100644
--- a/net/smc/smc_clc.c
+++ b/net/smc/smc_clc.c
@@ -486,7 +486,9 @@ static int smc_clc_prfx_set4_rcu(struct dst_entry *dst, __be32 ipv4,
return -ENODEV;
in_dev_for_each_ifa_rcu(ifa, in_dev) {
- if (!inet_ifa_match(ipv4, ifa))
+ /* add loopback support */
+ if (inet_addr_type(dev_net(dst->dev), ipv4) != RTN_LOCAL &&
+ !inet_ifa_match(ipv4, ifa))
continue;
prop->prefix_len = inet_mask_len(ifa->ifa_mask);
prop->outgoing_subnet = ifa->ifa_address & ifa->ifa_mask;
diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c
index 911fe08..1d10435 100644
--- a/net/smc/smc_ism.c
+++ b/net/smc/smc_ism.c
@@ -227,7 +227,8 @@ static int smc_nl_handle_smcd_dev(struct smcd_dev *smcd,
if (nla_put_u8(skb, SMC_NLA_DEV_IS_CRIT, use_cnt > 0))
goto errattr;
memset(&smc_pci_dev, 0, sizeof(smc_pci_dev));
- smc_set_pci_values(to_pci_dev(smcd->dev.parent), &smc_pci_dev);
+ if (!smcd->is_loopback)
+ smc_set_pci_values(to_pci_dev(smcd->dev.parent), &smc_pci_dev);
if (nla_put_u32(skb, SMC_NLA_DEV_PCI_FID, smc_pci_dev.pci_fid))
goto errattr;
if (nla_put_u16(skb, SMC_NLA_DEV_PCI_CHID, smc_pci_dev.pci_pchid))
--
1.8.3.1
next prev parent reply other threads:[~2022-12-20 3:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-20 3:21 [RFC PATCH net-next v2 0/5] net/smc:Introduce SMC-D based loopback acceleration Wen Gu
2022-12-20 3:21 ` [RFC PATCH net-next v2 1/5] net/smc: introduce SMC-D loopback device Wen Gu
2023-01-19 16:25 ` Alexandra Winter
2023-01-30 16:30 ` Wen Gu
2022-12-20 3:21 ` Wen Gu [this message]
2022-12-20 3:21 ` [RFC PATCH net-next v2 3/5] net/smc: add dmb attach and detach interface Wen Gu
2022-12-20 3:21 ` [RFC PATCH net-next v2 4/5] net/smc: avoid data copy from sndbuf to peer RMB in SMC-D loopback Wen Gu
2022-12-20 3:21 ` [RFC PATCH net-next v2 5/5] net/smc: logic of cursors update in SMC-D loopback connections Wen Gu
2022-12-20 14:02 ` [RFC PATCH net-next v2 0/5] net/smc:Introduce SMC-D based loopback acceleration Niklas Schnelle
2022-12-21 13:14 ` Wen Gu
2023-01-04 16:09 ` Alexandra Winter
2023-01-12 12:12 ` Wen Gu
2023-01-16 11:01 ` Wenjia Zhang
2023-01-18 12:15 ` Wen Gu
2023-01-19 12:30 ` Alexandra Winter
2023-01-30 16:27 ` Wen Gu
2022-12-26 10:46 ` Dust Li
2022-12-28 10:26 ` Wen Gu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1671506505-104676-3-git-send-email-guwen@linux.alibaba.com \
--to=guwen@linux.alibaba.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jaka@linux.ibm.com \
--cc=kgraul@linux.ibm.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wenjia@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox