Skip to content

Commit e3eb47f

Browse files
committed
Merge branch 'net-smcv2.1-ISM-device-support'
Wen Gu says: ==================== net/smc: implement SMCv2.1 virtual ISM device support The fourth edition of SMCv2 adds the SMC version 2.1 feature updates for SMC-Dv2 with virtual ISM. Virtual ISM are created and supported mainly by OS or hypervisor software, comparable to IBM ISM which is based on platform firmware or hardware. With the introduction of virtual ISM, SMCv2.1 makes some updates: - Introduce feature bitmask to indicate supplemental features. - Reserve a range of CHIDs for virtual ISM. - Support extended GIDs (128 bits) in CLC handshake. So this patch set aims to implement these updates in Linux kernel. And it acts as the first part of SMC-D virtual ISM extension & loopback-ism [1]. [1] https://lore.kernel.org/netdev/1695568613-125057-1-git-send-email-guwen@linux.alibaba.com/ v8->v7: - Patch #7: v7 mistakenly changed the type of gid_ext in smc_clc_msg_accept_confirm to u64 instead of __be64 as previous versions when fixing the rebase conflicts. So fix this mistake. v7->v6: Link: https://lore.kernel.org/netdev/20231219084536.8158-1-guwen@linux.alibaba.com/ - Collect the Reviewed-by tag in v6; - Patch #3: redefine the struct smc_clc_msg_accept_confirm; - Patch #7: Because that the Patch #3 already adds '__packed' to smc_clc_msg_accept_confirm, so Patch #7 doesn't need to do the same thing. But this is a minor change, so I kept the 'Reviewed-by' tag. Other changes in previous versions but not yet acked: - Patch #1: Some minor changes in subject and fix the format issue (length exceeds 80 columns) compared to v3. - Patch #5: removes useless ini->feature_mask assignment in __smc_connect() and smc_listen_v2_check() compared to v4. - Patch #8: new added, compared to v3. v6->v5: Link: https://lore.kernel.org/netdev/1702371151-125258-1-git-send-email-guwen@linux.alibaba.com/ - Add 'Reviewed-by' label given in the previous versions: * Patch #4, #6, #9, #10 have nothing changed since v3; - Patch #2: * fix the format issue (Alignment should match open parenthesis) compared to v5; * remove useless clc->hdr.length assignment in smcr_clc_prep_confirm_accept() compared to v5; - Patch #3: new added compared to v5. - Patch #7: some minor changes like aclc_v2->aclc or clc_v2->clc compared to v5 due to the introduction of Patch #3. Since there were no major changes, I kept the 'Reviewed-by' label. Other changes in previous versions but not yet acked: - Patch #1: Some minor changes in subject and fix the format issue (length exceeds 80 columns) compared to v3. - Patch #5: removes useless ini->feature_mask assignment in __smc_connect() and smc_listen_v2_check() compared to v4. - Patch #8: new added, compared to v3. v5->v4: Link: https://lore.kernel.org/netdev/1702021259-41504-1-git-send-email-guwen@linux.alibaba.com/ - Patch #6: improve the comment of SMCD_CLC_MAX_V2_GID_ENTRIES; - Patch #4: remove useless ini->feature_mask assignment; v4->v3: https://lore.kernel.org/netdev/1701920994-73705-1-git-send-email-guwen@linux.alibaba.com/ - Patch #6: use SMCD_CLC_MAX_V2_GID_ENTRIES to indicate the max gid entries in CLC proposal and using SMC_MAX_V2_ISM_DEVS to indicate the max devices to propose; - Patch #6: use i and i+1 in smc_find_ism_v2_device_serv(); - Patch #2: replace the large if-else block in smc_clc_send_confirm_accept() with 2 subfunctions; - Fix missing byte order conversion of GID and token in CLC handshake, which is in a separate patch sending to net: https://lore.kernel.org/netdev/1701882157-87956-1-git-send-email-guwen@linux.alibaba.com/ - Patch #7: add extended GID in SMC-D lgr netlink attribute; v3->v2: https://lore.kernel.org/netdev/1701343695-122657-1-git-send-email-guwen@linux.alibaba.com/ - Rename smc_clc_fill_fce as smc_clc_fill_fce_v2x; - Remove ISM_IDENT_MASK from drivers/s390/net/ism.h; - Add explicitly assigning 'false' to ism_v2_capable in ism_dev_init(); - Remove smc_ism_set_v2_capable() helper for now, and introduce it in later loopback-ism implementation; v2->v1: - Fix sparse complaint; - Rebase to the latest net-next; ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents e9301af + b3bf760 commit e3eb47f

File tree

16 files changed

+448
-295
lines changed

16 files changed

+448
-295
lines changed

drivers/s390/net/ism.h

-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717
#define ISM_DMB_WORD_OFFSET 1
1818
#define ISM_DMB_BIT_OFFSET (ISM_DMB_WORD_OFFSET * 32)
19-
#define ISM_IDENT_MASK 0x00FFFF
2019

2120
#define ISM_REG_SBA 0x1
2221
#define ISM_REG_IEQ 0x2
@@ -192,12 +191,6 @@ struct ism_sba {
192191
#define ISM_CREATE_REQ(dmb, idx, sf, offset) \
193192
((dmb) | (idx) << 24 | (sf) << 23 | (offset))
194193

195-
struct ism_systemeid {
196-
u8 seid_string[24];
197-
u8 serial_number[4];
198-
u8 type[4];
199-
};
200-
201194
static inline void __ism_read_cmd(struct ism_dev *ism, void *data,
202195
unsigned long offset, unsigned long len)
203196
{

drivers/s390/net/ism_drv.c

+17-40
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static struct ism_client *clients[MAX_CLIENTS]; /* use an array rather than */
3636
/* a list for fast mapping */
3737
static u8 max_client;
3838
static DEFINE_MUTEX(clients_lock);
39+
static bool ism_v2_capable;
3940
struct ism_dev_list {
4041
struct list_head list;
4142
struct mutex mutex; /* protects ism device list */
@@ -443,32 +444,6 @@ int ism_move(struct ism_dev *ism, u64 dmb_tok, unsigned int idx, bool sf,
443444
}
444445
EXPORT_SYMBOL_GPL(ism_move);
445446

446-
static struct ism_systemeid SYSTEM_EID = {
447-
.seid_string = "IBM-SYSZ-ISMSEID00000000",
448-
.serial_number = "0000",
449-
.type = "0000",
450-
};
451-
452-
static void ism_create_system_eid(void)
453-
{
454-
struct cpuid id;
455-
u16 ident_tail;
456-
char tmp[5];
457-
458-
get_cpu_id(&id);
459-
ident_tail = (u16)(id.ident & ISM_IDENT_MASK);
460-
snprintf(tmp, 5, "%04X", ident_tail);
461-
memcpy(&SYSTEM_EID.serial_number, tmp, 4);
462-
snprintf(tmp, 5, "%04X", id.machine);
463-
memcpy(&SYSTEM_EID.type, tmp, 4);
464-
}
465-
466-
u8 *ism_get_seid(void)
467-
{
468-
return SYSTEM_EID.seid_string;
469-
}
470-
EXPORT_SYMBOL_GPL(ism_get_seid);
471-
472447
static void ism_handle_event(struct ism_dev *ism)
473448
{
474449
struct ism_event *entry;
@@ -560,7 +535,9 @@ static int ism_dev_init(struct ism_dev *ism)
560535

561536
if (!ism_add_vlan_id(ism, ISM_RESERVED_VLANID))
562537
/* hardware is V2 capable */
563-
ism_create_system_eid();
538+
ism_v2_capable = true;
539+
else
540+
ism_v2_capable = false;
564541

565542
mutex_lock(&ism_dev_list.mutex);
566543
mutex_lock(&clients_lock);
@@ -665,8 +642,7 @@ static void ism_dev_exit(struct ism_dev *ism)
665642
}
666643
mutex_unlock(&clients_lock);
667644

668-
if (SYSTEM_EID.serial_number[0] != '0' ||
669-
SYSTEM_EID.type[0] != '0')
645+
if (ism_v2_capable)
670646
ism_del_vlan_id(ism, ISM_RESERVED_VLANID);
671647
unregister_ieq(ism);
672648
unregister_sba(ism);
@@ -743,10 +719,10 @@ static int ism_query_rgid(struct ism_dev *ism, u64 rgid, u32 vid_valid,
743719
return ism_cmd(ism, &cmd);
744720
}
745721

746-
static int smcd_query_rgid(struct smcd_dev *smcd, u64 rgid, u32 vid_valid,
747-
u32 vid)
722+
static int smcd_query_rgid(struct smcd_dev *smcd, struct smcd_gid *rgid,
723+
u32 vid_valid, u32 vid)
748724
{
749-
return ism_query_rgid(smcd->priv, rgid, vid_valid, vid);
725+
return ism_query_rgid(smcd->priv, rgid->gid, vid_valid, vid);
750726
}
751727

752728
static int smcd_register_dmb(struct smcd_dev *smcd, struct smcd_dmb *dmb,
@@ -797,10 +773,11 @@ static int ism_signal_ieq(struct ism_dev *ism, u64 rgid, u32 trigger_irq,
797773
return ism_cmd(ism, &cmd);
798774
}
799775

800-
static int smcd_signal_ieq(struct smcd_dev *smcd, u64 rgid, u32 trigger_irq,
801-
u32 event_code, u64 info)
776+
static int smcd_signal_ieq(struct smcd_dev *smcd, struct smcd_gid *rgid,
777+
u32 trigger_irq, u32 event_code, u64 info)
802778
{
803-
return ism_signal_ieq(smcd->priv, rgid, trigger_irq, event_code, info);
779+
return ism_signal_ieq(smcd->priv, rgid->gid,
780+
trigger_irq, event_code, info);
804781
}
805782

806783
static int smcd_move(struct smcd_dev *smcd, u64 dmb_tok, unsigned int idx,
@@ -812,18 +789,19 @@ static int smcd_move(struct smcd_dev *smcd, u64 dmb_tok, unsigned int idx,
812789

813790
static int smcd_supports_v2(void)
814791
{
815-
return SYSTEM_EID.serial_number[0] != '0' ||
816-
SYSTEM_EID.type[0] != '0';
792+
return ism_v2_capable;
817793
}
818794

819795
static u64 ism_get_local_gid(struct ism_dev *ism)
820796
{
821797
return ism->local_gid;
822798
}
823799

824-
static u64 smcd_get_local_gid(struct smcd_dev *smcd)
800+
static void smcd_get_local_gid(struct smcd_dev *smcd,
801+
struct smcd_gid *smcd_gid)
825802
{
826-
return ism_get_local_gid(smcd->priv);
803+
smcd_gid->gid = ism_get_local_gid(smcd->priv);
804+
smcd_gid->gid_ext = 0;
827805
}
828806

829807
static u16 ism_get_chid(struct ism_dev *ism)
@@ -857,7 +835,6 @@ static const struct smcd_ops ism_ops = {
857835
.signal_event = smcd_signal_ieq,
858836
.move_data = smcd_move,
859837
.supports_v2 = smcd_supports_v2,
860-
.get_system_eid = ism_get_seid,
861838
.get_local_gid = smcd_get_local_gid,
862839
.get_chid = smcd_get_chid,
863840
.get_dev = smcd_get_dev,

include/linux/ism.h

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ int ism_register_dmb(struct ism_dev *dev, struct ism_dmb *dmb,
8686
int ism_unregister_dmb(struct ism_dev *dev, struct ism_dmb *dmb);
8787
int ism_move(struct ism_dev *dev, u64 dmb_tok, unsigned int idx, bool sf,
8888
unsigned int offset, void *data, unsigned int size);
89-
u8 *ism_get_seid(void);
9089

9190
const struct smcd_ops *ism_get_smcd_ops(void);
9291

include/net/smc.h

+10-6
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,28 @@ struct smcd_dmb {
5252
struct smcd_dev;
5353
struct ism_client;
5454

55+
struct smcd_gid {
56+
u64 gid;
57+
u64 gid_ext;
58+
};
59+
5560
struct smcd_ops {
56-
int (*query_remote_gid)(struct smcd_dev *dev, u64 rgid, u32 vid_valid,
57-
u32 vid);
61+
int (*query_remote_gid)(struct smcd_dev *dev, struct smcd_gid *rgid,
62+
u32 vid_valid, u32 vid);
5863
int (*register_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb,
5964
struct ism_client *client);
6065
int (*unregister_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
6166
int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
6267
int (*del_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
6368
int (*set_vlan_required)(struct smcd_dev *dev);
6469
int (*reset_vlan_required)(struct smcd_dev *dev);
65-
int (*signal_event)(struct smcd_dev *dev, u64 rgid, u32 trigger_irq,
66-
u32 event_code, u64 info);
70+
int (*signal_event)(struct smcd_dev *dev, struct smcd_gid *rgid,
71+
u32 trigger_irq, u32 event_code, u64 info);
6772
int (*move_data)(struct smcd_dev *dev, u64 dmb_tok, unsigned int idx,
6873
bool sf, unsigned int offset, void *data,
6974
unsigned int size);
7075
int (*supports_v2)(void);
71-
u8* (*get_system_eid)(void);
72-
u64 (*get_local_gid)(struct smcd_dev *dev);
76+
void (*get_local_gid)(struct smcd_dev *dev, struct smcd_gid *gid);
7377
u16 (*get_chid)(struct smcd_dev *dev);
7478
struct device* (*get_dev)(struct smcd_dev *dev);
7579
};

include/uapi/linux/smc.h

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ enum {
160160
SMC_NLA_LGR_D_CHID, /* u16 */
161161
SMC_NLA_LGR_D_PAD, /* flag */
162162
SMC_NLA_LGR_D_V2_COMMON, /* nest */
163+
SMC_NLA_LGR_D_EXT_GID, /* u64 */
164+
SMC_NLA_LGR_D_PEER_EXT_GID, /* u64 */
163165
__SMC_NLA_LGR_D_MAX,
164166
SMC_NLA_LGR_D_MAX = __SMC_NLA_LGR_D_MAX - 1
165167
};

include/uapi/linux/smc_diag.h

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ struct smcd_diag_dmbinfo { /* SMC-D Socket internals */
107107
__aligned_u64 my_gid; /* My GID */
108108
__aligned_u64 token; /* Token of DMB */
109109
__aligned_u64 peer_token; /* Token of remote DMBE */
110+
__aligned_u64 peer_gid_ext; /* Peer GID (extended part) */
111+
__aligned_u64 my_gid_ext; /* My GID (extended part) */
110112
};
111113

112114
#endif /* _UAPI_SMC_DIAG_H_ */

0 commit comments

Comments
 (0)