Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b3bf760

Browse files
Wen Gudavem330
Wen Gu
authored andcommittedDec 26, 2023
net/smc: manage system EID in SMC stack instead of ISM driver
The System EID (SEID) is an internal EID that is used by the SMCv2 software stack that has a predefined and constant value representing the s390 physical machine that the OS is executing on. So it should be managed by SMC stack instead of ISM driver and be consistent for all ISMv2 device (including virtual ISM devices) on s390 architecture. Suggested-by: Alexandra Winter <wintera@linux.ibm.com> Signed-off-by: Wen Gu <guwen@linux.alibaba.com> Reviewed-and-tested-by: Wenjia Zhang <wenjia@linux.ibm.com> Reviewed-by: Alexandra Winter <wintera@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c6b8b8e commit b3bf760

File tree

6 files changed

+37
-50
lines changed

6 files changed

+37
-50
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

+6-32
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);
@@ -813,8 +789,7 @@ static int smcd_move(struct smcd_dev *smcd, u64 dmb_tok, unsigned int idx,
813789

814790
static int smcd_supports_v2(void)
815791
{
816-
return SYSTEM_EID.serial_number[0] != '0' ||
817-
SYSTEM_EID.type[0] != '0';
792+
return ism_v2_capable;
818793
}
819794

820795
static u64 ism_get_local_gid(struct ism_dev *ism)
@@ -860,7 +835,6 @@ static const struct smcd_ops ism_ops = {
860835
.signal_event = smcd_signal_ieq,
861836
.move_data = smcd_move,
862837
.supports_v2 = smcd_supports_v2,
863-
.get_system_eid = ism_get_seid,
864838
.get_local_gid = smcd_get_local_gid,
865839
.get_chid = smcd_get_chid,
866840
.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

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ struct smcd_ops {
7373
bool sf, unsigned int offset, void *data,
7474
unsigned int size);
7575
int (*supports_v2)(void);
76-
u8* (*get_system_eid)(void);
7776
void (*get_local_gid)(struct smcd_dev *dev, struct smcd_gid *gid);
7877
u16 (*get_chid)(struct smcd_dev *dev);
7978
struct device* (*get_dev)(struct smcd_dev *dev);

‎net/smc/smc_ism.c

+24-9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ static struct ism_client smc_ism_client = {
4343
};
4444
#endif
4545

46+
static void smc_ism_create_system_eid(void)
47+
{
48+
struct smc_ism_seid *seid =
49+
(struct smc_ism_seid *)smc_ism_v2_system_eid;
50+
#if IS_ENABLED(CONFIG_S390)
51+
struct cpuid id;
52+
u16 ident_tail;
53+
char tmp[5];
54+
55+
memcpy(seid->seid_string, "IBM-SYSZ-ISMSEID00000000", 24);
56+
get_cpu_id(&id);
57+
ident_tail = (u16)(id.ident & SMC_ISM_IDENT_MASK);
58+
snprintf(tmp, 5, "%04X", ident_tail);
59+
memcpy(seid->serial_number, tmp, 4);
60+
snprintf(tmp, 5, "%04X", id.machine);
61+
memcpy(seid->type, tmp, 4);
62+
#else
63+
memset(seid, 0, SMC_MAX_EID_LEN);
64+
#endif
65+
}
66+
4667
/* Test if an ISM communication is possible - same CPC */
4768
int smc_ism_cantalk(struct smcd_gid *peer_gid, unsigned short vlan_id,
4869
struct smcd_dev *smcd)
@@ -431,14 +452,8 @@ static void smcd_register_dev(struct ism_dev *ism)
431452

432453
mutex_lock(&smcd_dev_list.mutex);
433454
if (list_empty(&smcd_dev_list.list)) {
434-
u8 *system_eid = NULL;
435-
436-
system_eid = smcd->ops->get_system_eid();
437-
if (smcd->ops->supports_v2()) {
455+
if (smcd->ops->supports_v2())
438456
smc_ism_v2_capable = true;
439-
memcpy(smc_ism_v2_system_eid, system_eid,
440-
SMC_MAX_EID_LEN);
441-
}
442457
}
443458
/* sort list: devices without pnetid before devices with pnetid */
444459
if (smcd->pnetid[0])
@@ -542,10 +557,10 @@ int smc_ism_init(void)
542557
{
543558
int rc = 0;
544559

545-
#if IS_ENABLED(CONFIG_ISM)
546560
smc_ism_v2_capable = false;
547-
memset(smc_ism_v2_system_eid, 0, SMC_MAX_EID_LEN);
561+
smc_ism_create_system_eid();
548562

563+
#if IS_ENABLED(CONFIG_ISM)
549564
rc = ism_register_client(&smc_ism_client);
550565
#endif
551566
return rc;

‎net/smc/smc_ism.h

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "smc.h"
1717

1818
#define SMC_VIRTUAL_ISM_CHID_MASK 0xFF00
19+
#define SMC_ISM_IDENT_MASK 0x00FFFF
1920

2021
struct smcd_dev_list { /* List of SMCD devices */
2122
struct list_head list;
@@ -30,6 +31,12 @@ struct smc_ism_vlanid { /* VLAN id set on ISM device */
3031
refcount_t refcnt; /* Reference count */
3132
};
3233

34+
struct smc_ism_seid {
35+
u8 seid_string[24];
36+
u8 serial_number[4];
37+
u8 type[4];
38+
};
39+
3340
struct smcd_dev;
3441

3542
int smc_ism_cantalk(struct smcd_gid *peer_gid, unsigned short vlan_id,

0 commit comments

Comments
 (0)
Please sign in to comment.