net/smc: define a reserved CHID range for virtual ISM devices
authorWen Gu <guwen@linux.alibaba.com>
Tue, 19 Dec 2023 14:26:12 +0000 (22:26 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 26 Dec 2023 20:24:33 +0000 (20:24 +0000)
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: 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>
net/smc/smc_ism.h

index 832b2f42d79f342f16a30f85bdf22fc8e5a00887..d1228a615f23c6644053944169fd6bf6ca383a07 100644 (file)
@@ -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