Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Wen Gu and committed by
David S. Miller
b3bf7602 c6b8b8eb

+37 -50
-7
drivers/s390/net/ism.h
··· 16 16 */ 17 17 #define ISM_DMB_WORD_OFFSET 1 18 18 #define ISM_DMB_BIT_OFFSET (ISM_DMB_WORD_OFFSET * 32) 19 - #define ISM_IDENT_MASK 0x00FFFF 20 19 21 20 #define ISM_REG_SBA 0x1 22 21 #define ISM_REG_IEQ 0x2 ··· 190 191 191 192 #define ISM_CREATE_REQ(dmb, idx, sf, offset) \ 192 193 ((dmb) | (idx) << 24 | (sf) << 23 | (offset)) 193 - 194 - struct ism_systemeid { 195 - u8 seid_string[24]; 196 - u8 serial_number[4]; 197 - u8 type[4]; 198 - }; 199 194 200 195 static inline void __ism_read_cmd(struct ism_dev *ism, void *data, 201 196 unsigned long offset, unsigned long len)
+6 -32
drivers/s390/net/ism_drv.c
··· 36 36 /* a list for fast mapping */ 37 37 static u8 max_client; 38 38 static DEFINE_MUTEX(clients_lock); 39 + static bool ism_v2_capable; 39 40 struct ism_dev_list { 40 41 struct list_head list; 41 42 struct mutex mutex; /* protects ism device list */ ··· 444 443 } 445 444 EXPORT_SYMBOL_GPL(ism_move); 446 445 447 - static struct ism_systemeid SYSTEM_EID = { 448 - .seid_string = "IBM-SYSZ-ISMSEID00000000", 449 - .serial_number = "0000", 450 - .type = "0000", 451 - }; 452 - 453 - static void ism_create_system_eid(void) 454 - { 455 - struct cpuid id; 456 - u16 ident_tail; 457 - char tmp[5]; 458 - 459 - get_cpu_id(&id); 460 - ident_tail = (u16)(id.ident & ISM_IDENT_MASK); 461 - snprintf(tmp, 5, "%04X", ident_tail); 462 - memcpy(&SYSTEM_EID.serial_number, tmp, 4); 463 - snprintf(tmp, 5, "%04X", id.machine); 464 - memcpy(&SYSTEM_EID.type, tmp, 4); 465 - } 466 - 467 - u8 *ism_get_seid(void) 468 - { 469 - return SYSTEM_EID.seid_string; 470 - } 471 - EXPORT_SYMBOL_GPL(ism_get_seid); 472 - 473 446 static void ism_handle_event(struct ism_dev *ism) 474 447 { 475 448 struct ism_event *entry; ··· 535 560 536 561 if (!ism_add_vlan_id(ism, ISM_RESERVED_VLANID)) 537 562 /* hardware is V2 capable */ 538 - ism_create_system_eid(); 563 + ism_v2_capable = true; 564 + else 565 + ism_v2_capable = false; 539 566 540 567 mutex_lock(&ism_dev_list.mutex); 541 568 mutex_lock(&clients_lock); ··· 642 665 } 643 666 mutex_unlock(&clients_lock); 644 667 645 - if (SYSTEM_EID.serial_number[0] != '0' || 646 - SYSTEM_EID.type[0] != '0') 668 + if (ism_v2_capable) 647 669 ism_del_vlan_id(ism, ISM_RESERVED_VLANID); 648 670 unregister_ieq(ism); 649 671 unregister_sba(ism); ··· 789 813 790 814 static int smcd_supports_v2(void) 791 815 { 792 - return SYSTEM_EID.serial_number[0] != '0' || 793 - SYSTEM_EID.type[0] != '0'; 816 + return ism_v2_capable; 794 817 } 795 818 796 819 static u64 ism_get_local_gid(struct ism_dev *ism) ··· 835 860 .signal_event = smcd_signal_ieq, 836 861 .move_data = smcd_move, 837 862 .supports_v2 = smcd_supports_v2, 838 - .get_system_eid = ism_get_seid, 839 863 .get_local_gid = smcd_get_local_gid, 840 864 .get_chid = smcd_get_chid, 841 865 .get_dev = smcd_get_dev,
-1
include/linux/ism.h
··· 86 86 int ism_unregister_dmb(struct ism_dev *dev, struct ism_dmb *dmb); 87 87 int ism_move(struct ism_dev *dev, u64 dmb_tok, unsigned int idx, bool sf, 88 88 unsigned int offset, void *data, unsigned int size); 89 - u8 *ism_get_seid(void); 90 89 91 90 const struct smcd_ops *ism_get_smcd_ops(void); 92 91
-1
include/net/smc.h
··· 73 73 bool sf, unsigned int offset, void *data, 74 74 unsigned int size); 75 75 int (*supports_v2)(void); 76 - u8* (*get_system_eid)(void); 77 76 void (*get_local_gid)(struct smcd_dev *dev, struct smcd_gid *gid); 78 77 u16 (*get_chid)(struct smcd_dev *dev); 79 78 struct device* (*get_dev)(struct smcd_dev *dev);
+24 -9
net/smc/smc_ism.c
··· 43 43 }; 44 44 #endif 45 45 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 + 46 67 /* Test if an ISM communication is possible - same CPC */ 47 68 int smc_ism_cantalk(struct smcd_gid *peer_gid, unsigned short vlan_id, 48 69 struct smcd_dev *smcd) ··· 452 431 453 432 mutex_lock(&smcd_dev_list.mutex); 454 433 if (list_empty(&smcd_dev_list.list)) { 455 - u8 *system_eid = NULL; 456 - 457 - system_eid = smcd->ops->get_system_eid(); 458 - if (smcd->ops->supports_v2()) { 434 + if (smcd->ops->supports_v2()) 459 435 smc_ism_v2_capable = true; 460 - memcpy(smc_ism_v2_system_eid, system_eid, 461 - SMC_MAX_EID_LEN); 462 - } 463 436 } 464 437 /* sort list: devices without pnetid before devices with pnetid */ 465 438 if (smcd->pnetid[0]) ··· 557 542 { 558 543 int rc = 0; 559 544 560 - #if IS_ENABLED(CONFIG_ISM) 561 545 smc_ism_v2_capable = false; 562 - memset(smc_ism_v2_system_eid, 0, SMC_MAX_EID_LEN); 546 + smc_ism_create_system_eid(); 563 547 548 + #if IS_ENABLED(CONFIG_ISM) 564 549 rc = ism_register_client(&smc_ism_client); 565 550 #endif 566 551 return rc;
+7
net/smc/smc_ism.h
··· 16 16 #include "smc.h" 17 17 18 18 #define SMC_VIRTUAL_ISM_CHID_MASK 0xFF00 19 + #define SMC_ISM_IDENT_MASK 0x00FFFF 19 20 20 21 struct smcd_dev_list { /* List of SMCD devices */ 21 22 struct list_head list; ··· 29 28 struct list_head list; 30 29 unsigned short vlanid; /* Vlan id */ 31 30 refcount_t refcnt; /* Reference count */ 31 + }; 32 + 33 + struct smc_ism_seid { 34 + u8 seid_string[24]; 35 + u8 serial_number[4]; 36 + u8 type[4]; 32 37 }; 33 38 34 39 struct smcd_dev;