Commit 18cc1ccb authored by Wen Gu's avatar Wen Gu Committed by Zhengchao Shao
Browse files

net/smc: manage system EID in SMC stack instead of ISM driver

mainline inclusion
from mainline-v6.8-rc1
commit b3bf76024f645369e1fc45e0b08a2bd24f200d9b
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IACM52

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b3bf76024f645369e1fc45e0b08a2bd24f200d9b



--------------------------------

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: default avatarAlexandra Winter <wintera@linux.ibm.com>
Signed-off-by: default avatarWen Gu <guwen@linux.alibaba.com>
Reviewed-and-tested-by: default avatarWenjia Zhang <wenjia@linux.ibm.com>
Reviewed-by: default avatarAlexandra Winter <wintera@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
parent 38a6acdf
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
 */
#define ISM_DMB_WORD_OFFSET	1
#define ISM_DMB_BIT_OFFSET	(ISM_DMB_WORD_OFFSET * 32)
#define ISM_IDENT_MASK		0x00FFFF

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

struct ism_systemeid {
	u8	seid_string[24];
	u8	serial_number[4];
	u8	type[4];
};

static inline void __ism_read_cmd(struct ism_dev *ism, void *data,
				  unsigned long offset, unsigned long len)
{
+6 −32
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ static struct ism_client *clients[MAX_CLIENTS]; /* use an array rather than */
						/* a list for fast mapping  */
static u8 max_client;
static DEFINE_MUTEX(clients_lock);
static bool ism_v2_capable;
struct ism_dev_list {
	struct list_head list;
	struct mutex mutex; /* protects ism device list */
@@ -462,32 +463,6 @@ int ism_move(struct ism_dev *ism, u64 dmb_tok, unsigned int idx, bool sf,
}
EXPORT_SYMBOL_GPL(ism_move);

static struct ism_systemeid SYSTEM_EID = {
	.seid_string = "IBM-SYSZ-ISMSEID00000000",
	.serial_number = "0000",
	.type = "0000",
};

static void ism_create_system_eid(void)
{
	struct cpuid id;
	u16 ident_tail;
	char tmp[5];

	get_cpu_id(&id);
	ident_tail = (u16)(id.ident & ISM_IDENT_MASK);
	snprintf(tmp, 5, "%04X", ident_tail);
	memcpy(&SYSTEM_EID.serial_number, tmp, 4);
	snprintf(tmp, 5, "%04X", id.machine);
	memcpy(&SYSTEM_EID.type, tmp, 4);
}

u8 *ism_get_seid(void)
{
	return SYSTEM_EID.seid_string;
}
EXPORT_SYMBOL_GPL(ism_get_seid);

static void ism_handle_event(struct ism_dev *ism)
{
	struct ism_event *entry;
@@ -579,7 +554,9 @@ static int ism_dev_init(struct ism_dev *ism)

	if (!ism_add_vlan_id(ism, ISM_RESERVED_VLANID))
		/* hardware is V2 capable */
		ism_create_system_eid();
		ism_v2_capable = true;
	else
		ism_v2_capable = false;

	mutex_lock(&ism_dev_list.mutex);
	mutex_lock(&clients_lock);
@@ -684,8 +661,7 @@ static void ism_dev_exit(struct ism_dev *ism)
	}
	mutex_unlock(&clients_lock);

	if (SYSTEM_EID.serial_number[0] != '0' ||
	    SYSTEM_EID.type[0] != '0')
	if (ism_v2_capable)
		ism_del_vlan_id(ism, ISM_RESERVED_VLANID);
	unregister_ieq(ism);
	unregister_sba(ism);
@@ -832,8 +808,7 @@ static int smcd_move(struct smcd_dev *smcd, u64 dmb_tok, unsigned int idx,

static int smcd_supports_v2(void)
{
	return SYSTEM_EID.serial_number[0] != '0' ||
		SYSTEM_EID.type[0] != '0';
	return ism_v2_capable;
}

static u64 ism_get_local_gid(struct ism_dev *ism)
@@ -879,7 +854,6 @@ static const struct smcd_ops ism_ops = {
	.signal_event = smcd_signal_ieq,
	.move_data = smcd_move,
	.supports_v2 = smcd_supports_v2,
	.get_system_eid = ism_get_seid,
	.get_local_gid = smcd_get_local_gid,
	.get_chid = smcd_get_chid,
	.get_dev = smcd_get_dev,
+0 −1
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ int ism_register_dmb(struct ism_dev *dev, struct ism_dmb *dmb,
int  ism_unregister_dmb(struct ism_dev *dev, struct ism_dmb *dmb);
int  ism_move(struct ism_dev *dev, u64 dmb_tok, unsigned int idx, bool sf,
	      unsigned int offset, void *data, unsigned int size);
u8  *ism_get_seid(void);

const struct smcd_ops *ism_get_smcd_ops(void);

+0 −1
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ struct smcd_ops {
			 bool sf, unsigned int offset, void *data,
			 unsigned int size);
	int (*supports_v2)(void);
	u8* (*get_system_eid)(void);
	void (*get_local_gid)(struct smcd_dev *dev, struct smcd_gid *gid);
	u16 (*get_chid)(struct smcd_dev *dev);
	struct device* (*get_dev)(struct smcd_dev *dev);
+24 −9
Original line number Diff line number Diff line
@@ -43,6 +43,27 @@ static struct ism_client smc_ism_client = {
};
#endif

static void smc_ism_create_system_eid(void)
{
	struct smc_ism_seid *seid =
		(struct smc_ism_seid *)smc_ism_v2_system_eid;
#if IS_ENABLED(CONFIG_S390)
	struct cpuid id;
	u16 ident_tail;
	char tmp[5];

	memcpy(seid->seid_string, "IBM-SYSZ-ISMSEID00000000", 24);
	get_cpu_id(&id);
	ident_tail = (u16)(id.ident & SMC_ISM_IDENT_MASK);
	snprintf(tmp, 5, "%04X", ident_tail);
	memcpy(seid->serial_number, tmp, 4);
	snprintf(tmp, 5, "%04X", id.machine);
	memcpy(seid->type, tmp, 4);
#else
	memset(seid, 0, SMC_MAX_EID_LEN);
#endif
}

/* Test if an ISM communication is possible - same CPC */
int smc_ism_cantalk(struct smcd_gid *peer_gid, unsigned short vlan_id,
		    struct smcd_dev *smcd)
@@ -431,14 +452,8 @@ static void smcd_register_dev(struct ism_dev *ism)

	mutex_lock(&smcd_dev_list.mutex);
	if (list_empty(&smcd_dev_list.list)) {
		u8 *system_eid = NULL;

		system_eid = smcd->ops->get_system_eid();
		if (smcd->ops->supports_v2()) {
		if (smcd->ops->supports_v2())
			smc_ism_v2_capable = true;
			memcpy(smc_ism_v2_system_eid, system_eid,
			       SMC_MAX_EID_LEN);
		}
	}
	/* sort list: devices without pnetid before devices with pnetid */
	if (smcd->pnetid[0])
@@ -542,10 +557,10 @@ int smc_ism_init(void)
{
	int rc = 0;

#if IS_ENABLED(CONFIG_ISM)
	smc_ism_v2_capable = false;
	memset(smc_ism_v2_system_eid, 0, SMC_MAX_EID_LEN);
	smc_ism_create_system_eid();

#if IS_ENABLED(CONFIG_ISM)
	rc = ism_register_client(&smc_ism_client);
#endif
	return rc;
Loading