diff mbox series

[net-next,1/2] net/smc: Introduce explicit check for v2 support

Message ID 20230313101032.13180-2-wenjia@linux.ibm.com (mailing list archive)
State Accepted
Commit f947568e258038d3c2f8f38a9a7dabaca36643ec
Delegated to: Netdev Maintainers
Headers show
Series smc: Updates 2023-03-01 | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers warning 4 maintainers not CCed: gor@linux.ibm.com svens@linux.ibm.com agordeev@linux.ibm.com borntraeger@linux.ibm.com
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 34 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Wenjia Zhang March 13, 2023, 10:10 a.m. UTC
From: Stefan Raspl <raspl@linux.ibm.com>

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>
---
 drivers/s390/net/ism_drv.c | 7 +++++++
 include/net/smc.h          | 1 +
 net/smc/smc_ism.c          | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

Comments

Tony Lu March 13, 2023, 11:19 a.m. UTC | #1
On Mon, Mar 13, 2023 at 11:10:31AM +0100, Wenjia Zhang wrote:
> From: Stefan Raspl <raspl@linux.ibm.com>
> 
> 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>

This solved my doubts about the magic number, and helps the extensions
of SMC-D. Thank you.

Reviewed-by: Tony Lu <tonylu@linux.alibaba.com>

> ---
>  drivers/s390/net/ism_drv.c | 7 +++++++
>  include/net/smc.h          | 1 +
>  net/smc/smc_ism.c          | 2 +-
>  3 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/s390/net/ism_drv.c b/drivers/s390/net/ism_drv.c
> index eb7e13486087..1c73d32966f1 100644
> --- a/drivers/s390/net/ism_drv.c
> +++ b/drivers/s390/net/ism_drv.c
> @@ -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,
> diff --git a/include/net/smc.h b/include/net/smc.h
> index 597cb9381182..a002552be29c 100644
> --- a/include/net/smc.h
> +++ b/include/net/smc.h
> @@ -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);
> diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c
> index 3b0b7710c6b0..fbee2493091f 100644
> --- a/net/smc/smc_ism.c
> +++ b/net/smc/smc_ism.c
> @@ -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);
> -- 
> 2.37.2
diff mbox series

Patch

diff --git a/drivers/s390/net/ism_drv.c b/drivers/s390/net/ism_drv.c
index eb7e13486087..1c73d32966f1 100644
--- a/drivers/s390/net/ism_drv.c
+++ b/drivers/s390/net/ism_drv.c
@@ -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,
diff --git a/include/net/smc.h b/include/net/smc.h
index 597cb9381182..a002552be29c 100644
--- a/include/net/smc.h
+++ b/include/net/smc.h
@@ -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);
diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c
index 3b0b7710c6b0..fbee2493091f 100644
--- a/net/smc/smc_ism.c
+++ b/net/smc/smc_ism.c
@@ -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);