net/smc: Introduce explicit check for v2 support
authorStefan Raspl <raspl@linux.ibm.com>
Mon, 13 Mar 2023 10:10:31 +0000 (11:10 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Mar 2023 08:18:35 +0000 (08:18 +0000)
Previously, v2 support was derived from a very specific format of the SEID
as part of the SMC-D codebase. Make this part of the SMC-D device API, so
implementers do not need to adhere to a specific SEID format.

Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
Reviewed-and-tested-by: Jan Karcher <jaka@linux.ibm.com>
Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com>
Signed-off-by: Wenjia Zhang <wenjia@linux.ibm.com>
Reviewed-by: Tony Lu <tonylu@linux.alibaba.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/ism_drv.c
include/net/smc.h
net/smc/smc_ism.c

index eb7e13486087849339ba5c400ac9841e617b8fd2..1c73d32966f19b27da07959a31f5b5d0396637ca 100644 (file)
@@ -842,6 +842,12 @@ static int smcd_move(struct smcd_dev *smcd, u64 dmb_tok, unsigned int idx,
        return ism_move(smcd->priv, dmb_tok, idx, sf, offset, data, size);
 }
 
+static int smcd_supports_v2(void)
+{
+       return SYSTEM_EID.serial_number[0] != '0' ||
+               SYSTEM_EID.type[0] != '0';
+}
+
 static u64 smcd_get_local_gid(struct smcd_dev *smcd)
 {
        return ism_get_local_gid(smcd->priv);
@@ -869,6 +875,7 @@ static const struct smcd_ops ism_ops = {
        .reset_vlan_required = smcd_reset_vlan_required,
        .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,
index 597cb938118271210ec13ea5676c7930934dd61d..a002552be29c342c96cf4cae79d8bee83243cfbc 100644 (file)
@@ -67,6 +67,7 @@ struct smcd_ops {
        int (*move_data)(struct smcd_dev *dev, u64 dmb_tok, unsigned int idx,
                         bool sf, unsigned int offset, void *data,
                         unsigned int size);
+       int (*supports_v2)(void);
        u8* (*get_system_eid)(void);
        u64 (*get_local_gid)(struct smcd_dev *dev);
        u16 (*get_chid)(struct smcd_dev *dev);
index 3b0b7710c6b0f11e3f51b704b891d5868703e755..fbee2493091f13078775021cfd3c702eb97c8d28 100644 (file)
@@ -429,7 +429,7 @@ static void smcd_register_dev(struct ism_dev *ism)
                u8 *system_eid = NULL;
 
                system_eid = smcd->ops->get_system_eid();
-               if (system_eid[24] != '0' || system_eid[28] != '0') {
+               if (smcd->ops->supports_v2()) {
                        smc_ism_v2_capable = true;
                        memcpy(smc_ism_v2_system_eid, system_eid,
                               SMC_MAX_EID_LEN);