2019-09-23 02:28:29

by Eugene Syromiatnikov

[permalink] [raw]
Subject: [PATCH net v2 0/3] net/smc: move some definitions to UAPI

Hello.

As of now, it's a bit difficult to use SMC protocol, as significant part
of definitions related to it are defined in private headers and are not
part of UAPI. The following commits move some definitions to UAPI,
making them readily available to the user space.

Changes since v1[1]:
* Patch "provide fallback diagnostic codes in UAPI" is updated
in accordance with the updated set of diagnostic codes.

[1] https://lkml.org/lkml/2018/10/7/177

Eugene Syromiatnikov (3):
uapi, net/smc: move protocol constant definitions to UAPI
uapi, net/smc: provide fallback diagnostic codes in UAPI
uapi, net/smc: provide socket state constants in UAPI

include/uapi/linux/smc.h | 32 +++++++++++++++++++++++++++++++-
include/uapi/linux/smc_diag.h | 17 +++++++++++++++++
net/smc/smc.h | 22 ++--------------------
net/smc/smc_clc.h | 22 ----------------------
4 files changed, 50 insertions(+), 43 deletions(-)

--
2.1.4


2019-09-23 02:28:29

by Eugene Syromiatnikov

[permalink] [raw]
Subject: [PATCH net v2 1/3] uapi, net/smc: move protocol constant definitions to UAPI

SMCPROTO_* constants are expected to be used by userspace[1],
but they were defined in a private header instead.

[1] http://manpages.ubuntu.com/manpages/cosmic/man7/af_smc.7.html

Fixes: ac7138746e14 ("smc: establish new socket family")
Fixes: aaa4d33f6da1 ("net/smc: enable ipv6 support for smc")
Signed-off-by: Eugene Syromiatnikov <[email protected]>
---
include/uapi/linux/smc.h | 7 ++++++-
net/smc/smc.h | 4 +---
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/uapi/linux/smc.h b/include/uapi/linux/smc.h
index 0e11ca4..10561f8 100644
--- a/include/uapi/linux/smc.h
+++ b/include/uapi/linux/smc.h
@@ -2,7 +2,8 @@
/*
* Shared Memory Communications over RDMA (SMC-R) and RoCE
*
- * Definitions for generic netlink based configuration of an SMC-R PNET table
+ * Definitions for SMC protocol and generic netlink based configuration
+ * of an SMC-R PNET table
*
* Copyright IBM Corp. 2016
*
@@ -12,6 +13,10 @@
#ifndef _UAPI_LINUX_SMC_H_
#define _UAPI_LINUX_SMC_H_

+/* AF_SMC socket protocols */
+#define SMCPROTO_SMC 0 /* SMC protocol, IPv4 */
+#define SMCPROTO_SMC6 1 /* SMC protocol, IPv6 */
+
/* Netlink SMC_PNETID attributes */
enum {
SMC_PNETID_UNSPEC,
diff --git a/net/smc/smc.h b/net/smc/smc.h
index 878313f..e60effc 100644
--- a/net/smc/smc.h
+++ b/net/smc/smc.h
@@ -15,12 +15,10 @@
#include <linux/types.h>
#include <linux/compiler.h> /* __aligned */
#include <net/sock.h>
+#include <linux/smc.h>

#include "smc_ib.h"

-#define SMCPROTO_SMC 0 /* SMC protocol, IPv4 */
-#define SMCPROTO_SMC6 1 /* SMC protocol, IPv6 */
-
extern struct proto smc_proto;
extern struct proto smc_proto6;

--
2.1.4

2019-09-23 03:40:27

by Eugene Syromiatnikov

[permalink] [raw]
Subject: [PATCH net v2 2/3] uapi, net/smc: provide fallback diagnostic codes in UAPI

Since the values to which these codes are corresponding to are already
exposed via sock_diag interface.

Signed-off-by: Eugene Syromiatnikov <[email protected]>
---
include/uapi/linux/smc.h | 25 +++++++++++++++++++++++++
net/smc/smc_clc.h | 22 ----------------------
2 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/include/uapi/linux/smc.h b/include/uapi/linux/smc.h
index 10561f8..9fbf365 100644
--- a/include/uapi/linux/smc.h
+++ b/include/uapi/linux/smc.h
@@ -17,6 +17,31 @@
#define SMCPROTO_SMC 0 /* SMC protocol, IPv4 */
#define SMCPROTO_SMC6 1 /* SMC protocol, IPv6 */

+/* Diagnostic codes */
+#define SMC_CLC_DECL_MEM 0x01010000 /* insufficient memory resources */
+#define SMC_CLC_DECL_TIMEOUT_CL 0x02010000 /* timeout w4 QP confirm link */
+#define SMC_CLC_DECL_TIMEOUT_AL 0x02020000 /* timeout w4 QP add link */
+#define SMC_CLC_DECL_CNFERR 0x03000000 /* configuration error */
+#define SMC_CLC_DECL_PEERNOSMC 0x03010000 /* peer did not indicate SMC */
+#define SMC_CLC_DECL_IPSEC 0x03020000 /* IPsec usage */
+#define SMC_CLC_DECL_NOSMCDEV 0x03030000 /* no SMC device found (R or D) */
+#define SMC_CLC_DECL_NOSMCDDEV 0x03030001 /* no SMC-D device found */
+#define SMC_CLC_DECL_NOSMCRDEV 0x03030002 /* no SMC-R device found */
+#define SMC_CLC_DECL_SMCDNOTALK 0x03030003 /* SMC-D dev can't talk to peer */
+#define SMC_CLC_DECL_MODEUNSUPP 0x03040000 /* smc modes do not match (R or D)*/
+#define SMC_CLC_DECL_RMBE_EC 0x03050000 /* peer has eyecatcher in RMBE */
+#define SMC_CLC_DECL_OPTUNSUPP 0x03060000 /* fastopen sockopt not supported */
+#define SMC_CLC_DECL_DIFFPREFIX 0x03070000 /* IP prefix / subnet mismatch */
+#define SMC_CLC_DECL_GETVLANERR 0x03080000 /* err to get vlan id of ip device*/
+#define SMC_CLC_DECL_ISMVLANERR 0x03090000 /* err to reg vlan id on ism dev */
+#define SMC_CLC_DECL_SYNCERR 0x04000000 /* synchronization error */
+#define SMC_CLC_DECL_PEERDECL 0x05000000 /* peer declined during handshake */
+#define SMC_CLC_DECL_INTERR 0x09990000 /* internal error */
+#define SMC_CLC_DECL_ERR_RTOK 0x09990001 /* rtoken handling failed */
+#define SMC_CLC_DECL_ERR_RDYLNK 0x09990002 /* ib ready link failed */
+#define SMC_CLC_DECL_ERR_REGRMB 0x09990003 /* reg rmb failed */
+
+
/* Netlink SMC_PNETID attributes */
enum {
SMC_PNETID_UNSPEC,
diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h
index ca20927..db6a78f 100644
--- a/net/smc/smc_clc.h
+++ b/net/smc/smc_clc.h
@@ -28,28 +28,6 @@
#define SMC_TYPE_B 3 /* SMC-R and SMC-D */
#define CLC_WAIT_TIME (6 * HZ) /* max. wait time on clcsock */
#define CLC_WAIT_TIME_SHORT HZ /* short wait time on clcsock */
-#define SMC_CLC_DECL_MEM 0x01010000 /* insufficient memory resources */
-#define SMC_CLC_DECL_TIMEOUT_CL 0x02010000 /* timeout w4 QP confirm link */
-#define SMC_CLC_DECL_TIMEOUT_AL 0x02020000 /* timeout w4 QP add link */
-#define SMC_CLC_DECL_CNFERR 0x03000000 /* configuration error */
-#define SMC_CLC_DECL_PEERNOSMC 0x03010000 /* peer did not indicate SMC */
-#define SMC_CLC_DECL_IPSEC 0x03020000 /* IPsec usage */
-#define SMC_CLC_DECL_NOSMCDEV 0x03030000 /* no SMC device found (R or D) */
-#define SMC_CLC_DECL_NOSMCDDEV 0x03030001 /* no SMC-D device found */
-#define SMC_CLC_DECL_NOSMCRDEV 0x03030002 /* no SMC-R device found */
-#define SMC_CLC_DECL_SMCDNOTALK 0x03030003 /* SMC-D dev can't talk to peer */
-#define SMC_CLC_DECL_MODEUNSUPP 0x03040000 /* smc modes do not match (R or D)*/
-#define SMC_CLC_DECL_RMBE_EC 0x03050000 /* peer has eyecatcher in RMBE */
-#define SMC_CLC_DECL_OPTUNSUPP 0x03060000 /* fastopen sockopt not supported */
-#define SMC_CLC_DECL_DIFFPREFIX 0x03070000 /* IP prefix / subnet mismatch */
-#define SMC_CLC_DECL_GETVLANERR 0x03080000 /* err to get vlan id of ip device*/
-#define SMC_CLC_DECL_ISMVLANERR 0x03090000 /* err to reg vlan id on ism dev */
-#define SMC_CLC_DECL_SYNCERR 0x04000000 /* synchronization error */
-#define SMC_CLC_DECL_PEERDECL 0x05000000 /* peer declined during handshake */
-#define SMC_CLC_DECL_INTERR 0x09990000 /* internal error */
-#define SMC_CLC_DECL_ERR_RTOK 0x09990001 /* rtoken handling failed */
-#define SMC_CLC_DECL_ERR_RDYLNK 0x09990002 /* ib ready link failed */
-#define SMC_CLC_DECL_ERR_REGRMB 0x09990003 /* reg rmb failed */

struct smc_clc_msg_hdr { /* header1 of clc messages */
u8 eyecatcher[4]; /* eye catcher */
--
2.1.4

2019-09-23 03:57:23

by Eugene Syromiatnikov

[permalink] [raw]
Subject: [PATCH net v2 3/3] uapi, net/smc: provide socket state constants in UAPI

As socket state itself is already exposed via sock_diag interface.

Fixes: ac7138746e14 ("smc: establish new socket family")
Fixes: b38d732477e4 ("smc: socket closing and linkgroup cleanup")
Signed-off-by: Eugene Syromiatnikov <[email protected]>
---
include/uapi/linux/smc_diag.h | 17 +++++++++++++++++
net/smc/smc.h | 18 +-----------------
2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/include/uapi/linux/smc_diag.h b/include/uapi/linux/smc_diag.h
index 8cb3a6f..6798ec0 100644
--- a/include/uapi/linux/smc_diag.h
+++ b/include/uapi/linux/smc_diag.h
@@ -31,6 +31,23 @@ struct smc_diag_msg {
__aligned_u64 diag_inode;
};

+enum smc_state { /* possible states of an SMC socket */
+ SMC_ACTIVE = 1,
+ SMC_INIT = 2,
+ SMC_CLOSED = 7,
+ SMC_LISTEN = 10,
+ /* normal close */
+ SMC_PEERCLOSEWAIT1 = 20,
+ SMC_PEERCLOSEWAIT2 = 21,
+ SMC_APPFINCLOSEWAIT = 24,
+ SMC_APPCLOSEWAIT1 = 22,
+ SMC_APPCLOSEWAIT2 = 23,
+ SMC_PEERFINCLOSEWAIT = 25,
+ /* abnormal close */
+ SMC_PEERABORTWAIT = 26,
+ SMC_PROCESSABORT = 27,
+};
+
/* Mode of a connection */
enum {
SMC_DIAG_MODE_SMCR,
diff --git a/net/smc/smc.h b/net/smc/smc.h
index e60effc..7eaef72 100644
--- a/net/smc/smc.h
+++ b/net/smc/smc.h
@@ -16,6 +16,7 @@
#include <linux/compiler.h> /* __aligned */
#include <net/sock.h>
#include <linux/smc.h>
+#include <linux/smc_diag.h>

#include "smc_ib.h"

@@ -26,23 +27,6 @@ extern struct proto smc_proto6;
#define KERNEL_HAS_ATOMIC64
#endif

-enum smc_state { /* possible states of an SMC socket */
- SMC_ACTIVE = 1,
- SMC_INIT = 2,
- SMC_CLOSED = 7,
- SMC_LISTEN = 10,
- /* normal close */
- SMC_PEERCLOSEWAIT1 = 20,
- SMC_PEERCLOSEWAIT2 = 21,
- SMC_APPFINCLOSEWAIT = 24,
- SMC_APPCLOSEWAIT1 = 22,
- SMC_APPCLOSEWAIT2 = 23,
- SMC_PEERFINCLOSEWAIT = 25,
- /* abnormal close */
- SMC_PEERABORTWAIT = 26,
- SMC_PROCESSABORT = 27,
-};
-
struct smc_link_group;

struct smc_wr_rx_hdr { /* common prefix part of LLC and CDC to demultiplex */
--
2.1.4

2019-09-25 15:27:23

by Ursula Braun

[permalink] [raw]
Subject: Re: [PATCH net v2 0/3] net/smc: move some definitions to UAPI



On 9/20/19 5:41 PM, Eugene Syromiatnikov wrote:
> Hello.
>
> As of now, it's a bit difficult to use SMC protocol, as significant part
> of definitions related to it are defined in private headers and are not
> part of UAPI. The following commits move some definitions to UAPI,
> making them readily available to the user space.
>
> Changes since v1[1]:
> * Patch "provide fallback diagnostic codes in UAPI" is updated
> in accordance with the updated set of diagnostic codes.
>
> [1] https://lkml.org/lkml/2018/10/7/177
>

Thanks Eugene, your patches look good. They will be part of our next SMC
patch submission for the net-next tree.

Regards, Ursula

> Eugene Syromiatnikov (3):
> uapi, net/smc: move protocol constant definitions to UAPI
> uapi, net/smc: provide fallback diagnostic codes in UAPI
> uapi, net/smc: provide socket state constants in UAPI
>
> include/uapi/linux/smc.h | 32 +++++++++++++++++++++++++++++++-
> include/uapi/linux/smc_diag.h | 17 +++++++++++++++++
> net/smc/smc.h | 22 ++--------------------
> net/smc/smc_clc.h | 22 ----------------------
> 4 files changed, 50 insertions(+), 43 deletions(-)
>

2019-09-26 08:16:23

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net v2 0/3] net/smc: move some definitions to UAPI

From: Eugene Syromiatnikov <[email protected]>
Date: Fri, 20 Sep 2019 17:41:47 +0200

> As of now, it's a bit difficult to use SMC protocol, as significant part
> of definitions related to it are defined in private headers and are not
> part of UAPI. The following commits move some definitions to UAPI,
> making them readily available to the user space.
>
> Changes since v1[1]:
> * Patch "provide fallback diagnostic codes in UAPI" is updated
> in accordance with the updated set of diagnostic codes.
>
> [1] https://lkml.org/lkml/2018/10/7/177

Isn't it way too late for this?

These definitions will now be duplicates for userland code that
defines the values on their own.

2019-09-26 09:31:08

by Ursula Braun

[permalink] [raw]
Subject: Re: [PATCH net v2 0/3] net/smc: move some definitions to UAPI



On 9/24/19 4:52 PM, David Miller wrote:
> From: Eugene Syromiatnikov <[email protected]>
> Date: Fri, 20 Sep 2019 17:41:47 +0200
>
>> As of now, it's a bit difficult to use SMC protocol, as significant part
>> of definitions related to it are defined in private headers and are not
>> part of UAPI. The following commits move some definitions to UAPI,
>> making them readily available to the user space.
>>
>> Changes since v1[1]:
>> * Patch "provide fallback diagnostic codes in UAPI" is updated
>> in accordance with the updated set of diagnostic codes.
>>
>> [1] https://lkml.org/lkml/2018/10/7/177
>
> Isn't it way too late for this?
>
> These definitions will now be duplicates for userland code that
> defines the values on their own.
>

Dave,
we have to admit that it is already late for these patches. Nevertheless
we think it is better to come up with them now than never. We doubt there
exists already much userland code for it - except our own IBM-provided
package smc-tools. Thus we appreciate acceptance of these patches.

Kind regards, Ursula



2019-09-26 09:34:57

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net v2 0/3] net/smc: move some definitions to UAPI

From: Ursula Braun <[email protected]>
Date: Wed, 25 Sep 2019 14:10:05 +0200

> we have to admit that it is already late for these patches. Nevertheless
> we think it is better to come up with them now than never. We doubt there
> exists already much userland code for it - except our own IBM-provided
> package smc-tools. Thus we appreciate acceptance of these patches.

Ursula, it's going to break the build of userland code.

I consider that unacceptable.