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

net/smc: define a reserved CHID range for virtual ISM devices

mainline inclusion
from mainline-v6.8-rc1
commit 8dd512df3c98ce8081e3541990bf849157675723
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=8dd512df3c98ce8081e3541990bf849157675723



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

According to virtual ISM support feature defined by SMCv2.1, CHIDs in
the range 0xFF00 to 0xFFFF are reserved for use by virtual ISM devices.

And two helpers are introduced to distinguish virtual ISM devices from
the existing platform firmware ISM devices.

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 0630b376
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@

#include "smc.h"

#define SMC_VIRTUAL_ISM_CHID_MASK	0xFF00

struct smcd_dev_list {	/* List of SMCD devices */
	struct list_head list;
	struct mutex mutex;	/* Protects list of devices */
@@ -56,4 +58,22 @@ static inline int smc_ism_write(struct smcd_dev *smcd, u64 dmb_tok,
	return rc < 0 ? rc : 0;
}

static inline bool __smc_ism_is_virtual(u16 chid)
{
	/* CHIDs in range of 0xFF00 to 0xFFFF are reserved
	 * for virtual ISM device.
	 *
	 * loopback-ism:	0xFFFF
	 * virtio-ism:		0xFF00 ~ 0xFFFE
	 */
	return ((chid & 0xFF00) == 0xFF00);
}

static inline bool smc_ism_is_virtual(struct smcd_dev *smcd)
{
	u16 chid = smcd->ops->get_chid(smcd);

	return __smc_ism_is_virtual(chid);
}

#endif