Skip to content

Commit 45783ee

Browse files
Wen GuPaolo Abeni
authored andcommitted
net/smc: implement ID-related operations of loopback-ism
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 <guwen@linux.alibaba.com> Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com> Reviewed-and-tested-by: Jan Karcher <jaka@linux.ibm.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 46ac644 commit 45783ee

File tree

2 files changed

+60
-5
lines changed

2 files changed

+60
-5
lines changed

net/smc/smc_loopback.c

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,62 @@
1818
#include "smc_ism.h"
1919
#include "smc_loopback.h"
2020

21+
#define SMC_LO_V2_CAPABLE 0x1 /* loopback-ism acts as ISMv2 */
22+
2123
static const char smc_lo_dev_name[] = "loopback-ism";
2224
static struct smc_lo_dev *lo_dev;
2325

26+
static void smc_lo_generate_ids(struct smc_lo_dev *ldev)
27+
{
28+
struct smcd_gid *lgid = &ldev->local_gid;
29+
uuid_t uuid;
30+
31+
uuid_gen(&uuid);
32+
memcpy(&lgid->gid, &uuid, sizeof(lgid->gid));
33+
memcpy(&lgid->gid_ext, (u8 *)&uuid + sizeof(lgid->gid),
34+
sizeof(lgid->gid_ext));
35+
36+
ldev->chid = SMC_LO_RESERVED_CHID;
37+
}
38+
39+
static int smc_lo_query_rgid(struct smcd_dev *smcd, struct smcd_gid *rgid,
40+
u32 vid_valid, u32 vid)
41+
{
42+
struct smc_lo_dev *ldev = smcd->priv;
43+
44+
/* rgid should be the same as lgid */
45+
if (!ldev || rgid->gid != ldev->local_gid.gid ||
46+
rgid->gid_ext != ldev->local_gid.gid_ext)
47+
return -ENETUNREACH;
48+
return 0;
49+
}
50+
51+
static int smc_lo_supports_v2(void)
52+
{
53+
return SMC_LO_V2_CAPABLE;
54+
}
55+
56+
static void smc_lo_get_local_gid(struct smcd_dev *smcd,
57+
struct smcd_gid *smcd_gid)
58+
{
59+
struct smc_lo_dev *ldev = smcd->priv;
60+
61+
smcd_gid->gid = ldev->local_gid.gid;
62+
smcd_gid->gid_ext = ldev->local_gid.gid_ext;
63+
}
64+
65+
static u16 smc_lo_get_chid(struct smcd_dev *smcd)
66+
{
67+
return ((struct smc_lo_dev *)smcd->priv)->chid;
68+
}
69+
70+
static struct device *smc_lo_get_dev(struct smcd_dev *smcd)
71+
{
72+
return &((struct smc_lo_dev *)smcd->priv)->dev;
73+
}
74+
2475
static const struct smcd_ops lo_ops = {
25-
.query_remote_gid = NULL,
76+
.query_remote_gid = smc_lo_query_rgid,
2677
.register_dmb = NULL,
2778
.unregister_dmb = NULL,
2879
.add_vlan_id = NULL,
@@ -31,10 +82,10 @@ static const struct smcd_ops lo_ops = {
3182
.reset_vlan_required = NULL,
3283
.signal_event = NULL,
3384
.move_data = NULL,
34-
.supports_v2 = NULL,
35-
.get_local_gid = NULL,
36-
.get_chid = NULL,
37-
.get_dev = NULL,
85+
.supports_v2 = smc_lo_supports_v2,
86+
.get_local_gid = smc_lo_get_local_gid,
87+
.get_chid = smc_lo_get_chid,
88+
.get_dev = smc_lo_get_dev,
3889
};
3990

4091
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)
94145

95146
static int smc_lo_dev_init(struct smc_lo_dev *ldev)
96147
{
148+
smc_lo_generate_ids(ldev);
97149
return smcd_lo_register_dev(ldev);
98150
}
99151

net/smc/smc_loopback.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@
2020

2121
#if IS_ENABLED(CONFIG_SMC_LO)
2222
#define SMC_LO_MAX_DMBS 5000
23+
#define SMC_LO_RESERVED_CHID 0xFFFF
2324

2425
struct smc_lo_dev {
2526
struct smcd_dev *smcd;
2627
struct device dev;
28+
u16 chid;
29+
struct smcd_gid local_gid;
2730
};
2831

2932
int smc_loopback_init(void);

0 commit comments

Comments
 (0)