net/smc: add EID support
cover net/smc: add EID support
Hi Dave & Jakub,
please apply the following patch series for smc to netdev's net-next tree. The series introduce the so called Enterprise ID support for smc protocol. Including the generic netlink based interface.
Thanks,
Guvenc Gulce
Karsten Graul (3):
net/smc: add support for user defined EIDs net/smc: keep static copy of system EID net/smc: add generic netlink support for system EID
include/uapi/linux/smc.h | 27 ++++ net/smc/af_smc.c | 34 ++-- net/smc/smc.h | 3 - net/smc/smc_clc.c | 330 +++++++++++++++++++++++++++++++++++++-- net/smc/smc_clc.h | 19 ++- net/smc/smc_core.c | 10 +- net/smc/smc_core.h | 1 + net/smc/smc_ism.c | 16 +- net/smc/smc_ism.h | 2 +- net/smc/smc_netlink.c | 47 +++++- net/smc/smc_netlink.h | 2 + 11 files changed, 443 insertions(+), 48 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/3 net/smc: add support for user defined EIDs
From: Karsten Graul <[email protected]>
SMC-Dv2 allows users to define EIDs which allows to create separate name spaces enabling users to cluster their SMC-Dv2 connections. Add support for user defined EIDs and extent the generic netlink interface so users can add, remove and dump EIDs.
--- include/uapi/linux/smc.h | 15 +++ net/smc/af_smc.c | 34 +++-- net/smc/smc.h | 3 - net/smc/smc_clc.c | 263 +++++++++++++++++++++++++++++++++++++-- net/smc/smc_clc.h | 16 ++- net/smc/smc_core.h | 1 + net/smc/smc_netlink.c | 32 ++++- net/smc/smc_netlink.h | 2 + 8 files changed, 335 insertions(+), 31 deletions(-)
include/uapi/linux/smc.h +15 -0
@@ -38,6 +38,9 @@ enum { /* SMC PNET Table commands */#define SMC_GENL_FAMILY_VERSION 1#define SMC_PCI_ID_STR_LEN 16/* Max length of pci id string */ +#define SMC_MAX_HOSTNAME_LEN 32/* Max length of the hostname */ +#define SMC_MAX_UEID 4/* Max number of user EIDs */ +#define SMC_MAX_EID_LEN 32/* Max length of an EID */ /* SMC_GENL_FAMILY commands */ enum {
@@ -49,6 +52,10 @@ enum {SMC_NETLINK_GET_DEV_SMCR ,SMC_NETLINK_GET_STATS ,SMC_NETLINK_GET_FBACK_STATS , +SMC_NETLINK_DUMP_UEID , +SMC_NETLINK_ADD_UEID , +SMC_NETLINK_REMOVE_UEID , + SMC_NETLINK_FLUSH_UEID, };/* SMC_GENL_FAMILY top level attributes */
@@ -242,4 +249,12 @@ enum { __SMC_NLA_FBACK_STATS_MAX,SMC_NLA_FBACK_STATS_MAX = __SMC_NLA_FBACK_STATS_MAX -1 }; + +/* SMC_NETLINK_UEID attributes */ +enum { +SMC_NLA_EID_TABLE_UNSPEC , +SMC_NLA_EID_TABLE_ENTRY ,/* string */ + __SMC_NLA_EID_TABLE_MAX, +SMC_NLA_EID_TABLE_MAX = __SMC_NLA_EID_TABLE_MAX -1 +};#endif /* _UAPI_LINUX_SMC_H */
net/smc/af_smc.c +22 -12
@@ -829,7 +829,7 @@ static int smc_connect_rdma(struct smc_sock *smc,smc_rmb_sync_sg_for_device (&smc->conn); reason_code =smc_clc_send_confirm (smc, ini->first_contact_local, -SMC_V1 ); +SMC_V1 ,NULL );if (reason_code) goto connect_abort;
@@ -883,6 +883,7 @@ static int smc_connect_ism(struct smc_sock *smc,struct smc_clc_msg_accept_confirm *aclc, struct smc_init_info *ini) { + u8 *eid = NULL;int rc =0 ; ini->is_smcd = true;
@@ -918,8 +919,15 @@ static int smc_connect_ism(struct smc_sock *smc,smc_rx_init (smc);smc_tx_init (smc); +if (aclc->hdr.version >SMC_V1 ) { +struct smc_clc_msg_accept_confirm_v2 *clc_v2 = + (struct smc_clc_msg_accept_confirm_v2 *)aclc; + + eid = clc_v2->eid; + } + rc =smc_clc_send_confirm (smc, ini->first_contact_local, - aclc->hdr.version); + aclc->hdr.version, eid);if (rc) goto connect_abort;mutex_unlock (&smc_server_lgr_pending);
@@ -1533,9 +1541,8 @@ static void smc_find_ism_v2_device_serv(struct smc_sock *new_smc, pclc_smcd =smc_get_clc_msg_smcd (pclc); smc_v2_ext =smc_get_clc_v2_ext (pclc); smcd_v2_ext =smc_get_clc_smcd_v2_ext (smc_v2_ext); -if (!smcd_v2_ext || - !smc_v2_ext->hdr.flag.seid) {/* no system EID support for SMCD */ -smc_find_ism_store_rc (SMC_CLC_DECL_NOSEID , ini); +if (!smcd_v2_ext) { +smc_find_ism_store_rc (SMC_CLC_DECL_NOV2DEXT , ini); goto not_found; }
@@ -1555,13 +1562,13 @@ static void smc_find_ism_v2_device_serv(struct smc_sock *new_smc, }mutex_unlock (&smcd_dev_list.mutex); -if (ini->ism_dev[0 ]) { -smc_ism_get_system_eid (ini->ism_dev[0 ], &eid); -if (memcmp (eid, smcd_v2_ext->system_eid,SMC_MAX_EID_LEN )) - goto not_found; - }else { +if (!ini->ism_dev[0 ]) + goto not_found; + +smc_ism_get_system_eid (ini->ism_dev[0 ], &eid); +if (!smc_clc_match_eid (ini->negotiated_eid, smc_v2_ext, + smcd_v2_ext->system_eid, eid)) goto not_found; - }/* separate - outside the smcd_dev_list.lock */ smcd_version = ini->smcd_version;
@@ -1579,6 +1586,7 @@ static void smc_find_ism_v2_device_serv(struct smc_sock *new_smc, }/* no V2 ISM device could be initialized */ ini->smcd_version = smcd_version;/* restore original value */ + ini->negotiated_eid[0 ] =0 ; not_found: ini->smcd_version &= ~SMC_V2 ;
@@ -1788,7 +1796,8 @@ static void smc_listen_work(struct work_struct *work)/* send SMC Accept CLC message */ rc =smc_clc_send_accept (new_smc, ini->first_contact_local, - ini->smcd_version ==SMC_V2 ?SMC_V2 :SMC_V1 ); + ini->smcd_version ==SMC_V2 ?SMC_V2 :SMC_V1 , + ini->negotiated_eid);if (rc) goto out_unlock;
@@ -2662,6 +2671,7 @@ static void __exit smc_exit(void)proto_unregister (&smc_proto);smc_pnet_exit ();smc_nl_exit (); +smc_clc_exit ();unregister_pernet_subsys (&smc_net_stat_ops);unregister_pernet_subsys (&smc_net_ops);rcu_barrier ();
net/smc/smc.h +0 -3
@@ -29,9 +29,6 @@* devices */ -#define SMC_MAX_HOSTNAME_LEN 32 -#define SMC_MAX_EID_LEN 32 -extern struct proto smc_proto;extern struct proto smc_proto6;
net/smc/smc_clc.c +250 -13
342 lines not on this page · raw message
net/smc/smc_clc.h +14 -2
@@ -14,8 +14,10 @@#define _SMC_CLC_H#include <rdma/ib_verbs.h> +#include <linux/smc.h> #include "smc.h" +#include "smc_netlink.h" #define SMC_CLC_PROPOSAL 0x01#define SMC_CLC_ACCEPT 0x02
@@ -158,6 +160,7 @@ struct smc_clc_msg_proposal { /* clc proposal message sent by Linux */ }__aligned(4) ;#define SMC_CLC_MAX_V6_PREFIX 8 +#define SMC_CLC_MAX_UEID 8struct smc_clc_msg_proposal_area {struct smc_clc_msg_proposal pclc_base;
@@ -165,6 +168,7 @@ struct smc_clc_msg_proposal_area {struct smc_clc_msg_proposal_prefix pclc_prfx;struct smc_clc_ipv6_prefix pclc_prfx_ipv6[SMC_CLC_MAX_V6_PREFIX ];struct smc_clc_v2_extension pclc_v2_ext; +u8 user_eids[SMC_CLC_MAX_UEID ][SMC_MAX_EID_LEN ];struct smc_clc_smcd_v2_extension pclc_smcd_v2_ext;struct smc_clc_smcd_gid_chid pclc_gidchids[SMC_MAX_ISM_DEVS ];struct smc_clc_msg_trail pclc_trl;
@@ -330,10 +334,18 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,int smc_clc_send_decline (struct smc_sock *smc,u32 peer_diag_info,u8 version);int smc_clc_send_proposal (struct smc_sock *smc,struct smc_init_info *ini);int smc_clc_send_confirm (struct smc_sock *smc,bool clnt_first_contact, -u8 version); +u8 version,u8 *eid);int smc_clc_send_accept (struct smc_sock *smc,bool srv_first_contact, -u8 version); +u8 version,u8 *negotiated_eid);void smc_clc_init (void )__init ; +void smc_clc_exit (void );void smc_clc_get_hostname (u8 **host); +bool smc_clc_match_eid (u8 *negotiated_eid, +struct smc_clc_v2_extension *smc_v2_ext, +u8 *peer_eid,u8 *local_eid); +int smc_nl_dump_ueid (struct sk_buff *skb,struct netlink_callback *cb); +int smc_nl_add_ueid (struct sk_buff *skb,struct genl_info *info); +int smc_nl_remove_ueid (struct sk_buff *skb,struct genl_info *info); +int smc_nl_flush_ueid (struct sk_buff *skb,struct genl_info *info);#endif
net/smc/smc_core.h +1 -0
@@ -310,6 +310,7 @@ struct smc_init_info {u8 first_contact_local;unsigned short vlan_id;u32 rc; +u8 negotiated_eid[SMC_MAX_EID_LEN ];/* SMC-R */ struct smc_clc_msg_local *ib_lcl;struct smc_ib_device *ib_dev;
net/smc/smc_netlink.c +31 -1
@@ -19,11 +19,19 @@#include "smc_core.h" #include "smc_ism.h" #include "smc_ib.h" +#include "smc_clc.h" #include "smc_stats.h" #include "smc_netlink.h" -#define SMC_CMD_MAX_ATTR 1 +const struct nla_policy +smc_gen_ueid_policy[SMC_NLA_EID_TABLE_MAX +1 ] = { + [SMC_NLA_EID_TABLE_UNSPEC ] = { .type =NLA_UNSPEC }, + [SMC_NLA_EID_TABLE_ENTRY ] = { .type =NLA_STRING , + .len =SMC_MAX_EID_LEN , + }, +}; +#define SMC_CMD_MAX_ATTR 1/* SMC_GENL generic netlink operation definition */ static const struct genl_ops smc_gen_nl_ops[] = { {
@@ -66,6 +74,28 @@ static const struct genl_ops smc_gen_nl_ops[] = {/* can be retrieved by unprivileged users */ .dumpit = smc_nl_get_fback_stats, }, + { + .cmd = SMC_NETLINK_DUMP_UEID, + /* can be retrieved by unprivileged users */ + .dumpit = smc_nl_dump_ueid, + }, + { + .cmd = SMC_NETLINK_ADD_UEID, + .flags = GENL_ADMIN_PERM, + .doit = smc_nl_add_ueid, + .policy = smc_gen_ueid_policy, + }, + { + .cmd = SMC_NETLINK_REMOVE_UEID, + .flags = GENL_ADMIN_PERM, + .doit = smc_nl_remove_ueid, + .policy = smc_gen_ueid_policy, + }, + { + .cmd = SMC_NETLINK_FLUSH_UEID, + .flags = GENL_ADMIN_PERM, + .doit = smc_nl_flush_ueid, + }, }; static const struct nla_policy smc_gen_nl_policy[2] = {
net/smc/smc_netlink.h +2 -0
@@ -17,6 +17,8 @@extern struct genl_family smc_gen_nl_family; +extern const struct nla_policy smc_gen_ueid_policy[]; +struct smc_nl_dmp_ctx {int pos[3 ]; };
Signature · 1 line
2.25.1
PATCH 2/3 net/smc: keep static copy of system EID
In reply to Guvenc GulceFrom: Karsten Graul <[email protected]>
The system EID is retrieved using an registered ISM device each time when needed. This adds some unnecessary complexity at all places where the system EID is needed, but no ISM device is at hand. Simplify the code and save the system EID in a static variable in smc_ism.c.
--- net/smc/af_smc.c | 2 +- net/smc/smc_clc.c | 5 +---- net/smc/smc_core.c | 10 ++-------- net/smc/smc_ism.c | 16 ++++++++++++---- net/smc/smc_ism.h | 2 +- 5 files changed, 17 insertions(+), 18 deletions(-)
net/smc/af_smc.c +1 -1
@@ -1565,7 +1565,7 @@ static void smc_find_ism_v2_device_serv(struct smc_sock *new_smc,if (!ini->ism_dev[0 ]) goto not_found; -smc_ism_get_system_eid (ini->ism_dev[0 ], &eid); +smc_ism_get_system_eid (&eid);if (!smc_clc_match_eid (ini->negotiated_eid, smc_v2_ext, smcd_v2_ext->system_eid, eid)) goto not_found;
net/smc/smc_clc.c +1 -4
@@ -796,10 +796,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini) offsetofend(struct smc_clnt_opts_area_hdr, smcd_v2_ext_offset) + v2_ext->hdr.eid_cnt * SMC_MAX_EID_LEN); -if (ini->ism_dev[0 ]) -smc_ism_get_system_eid (ini->ism_dev[0 ], &eid); -else -smc_ism_get_system_eid (ini->ism_dev[1 ], &eid); +smc_ism_get_system_eid (&eid);if (eid && v2_ext->hdr.flag.seid)memcpy (smcd_v2_ext->system_eid, eid,SMC_MAX_EID_LEN ); plen +=sizeof (*v2_ext) +sizeof (*smcd_v2_ext);
net/smc/smc_core.c +2 -8
@@ -223,7 +223,6 @@ int smc_nl_get_sys_info(struct sk_buff *skb, struct netlink_callback *cb)struct smc_nl_dmp_ctx *cb_ctx =smc_nl_dmp_ctx (cb);char hostname[SMC_MAX_HOSTNAME_LEN +1 ];char smc_seid[SMC_MAX_EID_LEN +1 ]; -struct smcd_dev *smcd_dev;struct nlattr *attrs;u8 *seid =NULL ;u8 *host =NULL ;
@@ -252,13 +251,8 @@ int smc_nl_get_sys_info(struct sk_buff *skb, struct netlink_callback *cb)if (nla_put_string (skb,SMC_NLA_SYS_LOCAL_HOST , hostname)) goto errattr; } -mutex_lock (&smcd_dev_list.mutex); - smcd_dev =list_first_entry_or_null (&smcd_dev_list.list, - struct smcd_dev, list); -if (smcd_dev) -smc_ism_get_system_eid (smcd_dev, &seid); -mutex_unlock (&smcd_dev_list.mutex); -if (seid &&smc_ism_is_v2_capable ()) { +if (smc_ism_is_v2_capable ()) { +smc_ism_get_system_eid (&seid);memcpy (smc_seid, seid,SMC_MAX_EID_LEN ); smc_seid[SMC_MAX_EID_LEN ] =0 ;if (nla_put_string (skb,SMC_NLA_SYS_SEID , smc_seid))
net/smc/smc_ism.c +12 -4
@@ -23,6 +23,7 @@ struct smcd_dev_list smcd_dev_list = { };static bool smc_ism_v2_capable; +static u8 smc_ism_v2_system_eid[SMC_MAX_EID_LEN ];/* Test if an ISM communication is possible - same CPC */ int smc_ism_cantalk (u64 peer_gid,unsigned short vlan_id,struct smcd_dev *smcd)
@@ -42,9 +43,12 @@ int smc_ism_write(struct smcd_dev *smcd, const struct smc_ism_position *pos,return rc <0 ? rc :0 ; } -void smc_ism_get_system_eid (struct smcd_dev *smcd,u8 **eid) +void smc_ism_get_system_eid (u8 **eid) { - smcd->ops->get_system_eid (smcd, eid); +if (!smc_ism_v2_capable) + *eid =NULL ; +else + *eid = smc_ism_v2_system_eid; }u16 smc_ism_get_chid (struct smcd_dev *smcd)
@@ -435,9 +439,12 @@ int smcd_register_dev(struct smcd_dev *smcd)if (list_empty (&smcd_dev_list.list)) {u8 *system_eid =NULL ; -smc_ism_get_system_eid (smcd, &system_eid); -if (system_eid[24 ] !='0' || system_eid[28 ] !='0' ) + smcd->ops->get_system_eid (smcd, &system_eid); +if (system_eid[24 ] !='0' || system_eid[28 ] !='0' ) { smc_ism_v2_capable = true; +memcpy (smc_ism_v2_system_eid, system_eid, +SMC_MAX_EID_LEN ); + } }/* sort list: devices without pnetid before devices with pnetid */ if (smcd->pnetid[0 ])
@@ -533,4 +540,5 @@ EXPORT_SYMBOL_GPL(smcd_handle_irq);void __init smc_ism_init (void ) { smc_ism_v2_capable = false; +memset (smc_ism_v2_system_eid,0 ,SMC_MAX_EID_LEN ); }
net/smc/smc_ism.h +1 -1
@@ -48,7 +48,7 @@ int smc_ism_unregister_dmb(struct smcd_dev *dev, struct smc_buf_desc *dmb_desc);int smc_ism_write (struct smcd_dev *dev,const struct smc_ism_position *pos,void *data,size_t len);int smc_ism_signal_shutdown (struct smc_link_group *lgr); -void smc_ism_get_system_eid (struct smcd_dev *dev,u8 **eid); +void smc_ism_get_system_eid (u8 **eid);u16 smc_ism_get_chid (struct smcd_dev *dev);bool smc_ism_is_v2_capable (void );void smc_ism_init (void );
Signature · 1 line
2.25.1
PATCH 3/3 net/smc: add generic netlink support for system EID
In reply to Guvenc GulceFrom: Karsten Graul <[email protected]>
With SMC-Dv2 users can configure if the static system EID should be used during CLC handshake, or if only user EIDs are allowed.
Add generic netlink support to enable and disable the system EID, and to retrieve the system EID and its current enabled state.
--- include/uapi/linux/smc.h | 12 ++++++++ net/smc/smc_clc.c | 62 ++++++++++++++++++++++++++++++++++++++++ net/smc/smc_clc.h | 3 ++ net/smc/smc_netlink.c | 15 ++++++++++ 4 files changed, 92 insertions(+)
include/uapi/linux/smc.h +12 -0
@@ -56,6 +56,9 @@ enum {SMC_NETLINK_ADD_UEID ,SMC_NETLINK_REMOVE_UEID ,SMC_NETLINK_FLUSH_UEID , +SMC_NETLINK_DUMP_SEID , +SMC_NETLINK_ENABLE_SEID , + SMC_NETLINK_DISABLE_SEID, };/* SMC_GENL_FAMILY top level attributes */
@@ -257,4 +260,13 @@ enum { __SMC_NLA_EID_TABLE_MAX,SMC_NLA_EID_TABLE_MAX = __SMC_NLA_EID_TABLE_MAX -1 }; + +/* SMC_NETLINK_SEID attributes */ +enum { +SMC_NLA_SEID_UNSPEC , +SMC_NLA_SEID_ENTRY ,/* string */ +SMC_NLA_SEID_ENABLED ,/* u8 */ + __SMC_NLA_SEID_TABLE_MAX, +SMC_NLA_SEID_TABLE_MAX = __SMC_NLA_SEID_TABLE_MAX -1 +};#endif /* _UAPI_LINUX_SMC_H */
net/smc/smc_clc.c +62 -0
74 lines not on this page · raw message
net/smc/smc_clc.h +3 -0
@@ -347,5 +347,8 @@ int smc_nl_dump_ueid(struct sk_buff *skb, struct netlink_callback *cb);int smc_nl_add_ueid (struct sk_buff *skb,struct genl_info *info);int smc_nl_remove_ueid (struct sk_buff *skb,struct genl_info *info);int smc_nl_flush_ueid (struct sk_buff *skb,struct genl_info *info); +int smc_nl_dump_seid (struct sk_buff *skb,struct netlink_callback *cb); +int smc_nl_enable_seid (struct sk_buff *skb,struct genl_info *info); +int smc_nl_disable_seid (struct sk_buff *skb,struct genl_info *info);#endif
net/smc/smc_netlink.c +15 -0
@@ -96,6 +96,21 @@ static const struct genl_ops smc_gen_nl_ops[] = { .flags = GENL_ADMIN_PERM, .doit = smc_nl_flush_ueid, }, + { + .cmd = SMC_NETLINK_DUMP_SEID, + /* can be retrieved by unprivileged users */ + .dumpit = smc_nl_dump_seid, + }, + { + .cmd = SMC_NETLINK_ENABLE_SEID, + .flags = GENL_ADMIN_PERM, + .doit = smc_nl_enable_seid, + }, + { + .cmd = SMC_NETLINK_DISABLE_SEID, + .flags = GENL_ADMIN_PERM, + .doit = smc_nl_disable_seid, + }, }; static const struct nla_policy smc_gen_nl_policy[2] = {
Signature · 1 line
2.25.1
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 9 lines · On Tue, 14 Sep 2021 10:35:04 +0200 you wrote:
Hi Dave & Jakub,
please apply the following patch series for smc to netdev's net-next tree. The series introduce the so called Enterprise ID support for smc protocol. Including the generic netlink based interface.
Thanks,
[...]
Here is the summary with links:
- [net-next,1/3] net/smc: add support for user defined EIDs
https://git.kernel.org/netdev/net-next/c/fa0866625543 - [net-next,2/3] net/smc: keep static copy of system EID https://git.kernel.org/netdev/net-next/c/11a26c59fc51 - [net-next,3/3] net/smc: add generic netlink support for system EID https://git.kernel.org/netdev/net-next/c/3c572145c24e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html