net/smc: Add support for generic netlink API
v7 cover net/smc: Add support for generic netlink API
Please apply the following patch series for smc to netdev's net-next tree.
Up to version 4 this patch series was using the sock_diag netlink infrastructure. This version is using the generic netlink API. Generic netlink API offers a better type safety between kernel and userspace communication.
Using the generic netlink API the smc module can now provide information about SMC linkgroups, links and devices (both for SMC-R and SMC-D).
v2: Add missing include to uapi header smc_diag.h.
v3: Apply code style recommendations from review comments.
Instead of using EXPORTs to allow the smc_diag module to access data of the smc module, introduce struct smc_diag_ops and let smc_diag access the required data using function pointers.
v4: Address checkpatch.pl warnings. Do not use static inline for
functions.
v5: Use generic netlink API instead of the sock_diag netlink
infrastructure.
v6: Integrate more review comments from Jakub.
v7: Use nla_nest_start() with the new family. Use .maxattr=1 in the
genl family and define one entry for attribute 1 in the policy to reject this attritbute for all commands. All other possible attributes are rejected because NL_VALIDATE_STRICT is set for the policy implicitely, which includes NL_VALIDATE_MAXTYPE.
Setting policy[0].strict_start_type=1 does not work here because there is no valid attribute defined for this family, only plain commands. For any type > maxtype (which is .maxattr) validate_nla() would return 0 to userspace instead of -EINVAL. What helps here is __nla_validate_parse() which checks for type > maxtype and returns -EINVAL when NL_VALIDATE_MAXTYPE is set. This requires the one entry for type == .maxattr with .type = NLA_REJECT in the nla_policy.
When a future command wants to allow attributes then it can easily specify a dedicated .policy for this new command in the genl_ops array. This dedicated policy overlays the global policy specified in the genl_family structure.
Guvenc Gulce (13):
net/smc: Use active link of the connection
net/smc: Add connection counters for links
net/smc: Add link counters for IB device ports
net/smc: Add diagnostic information to smc ib-device net/smc: Add diagnostic information to link structure net/smc: Refactor smc ism v2 capability handling
net/smc: Introduce generic netlink interface for diagnostic purposes net/smc: Add support for obtaining system information net/smc: Introduce SMCR get linkgroup command
net/smc: Introduce SMCR get link command
net/smc: Add SMC-D Linkgroup diagnostic support
net/smc: Add support for obtaining SMCD device list net/smc: Add support for obtaining SMCR device list
Karsten Graul (1):
net/smc: use helper smc_conn_abort() in listen processing
include/uapi/linux/smc.h | 126 +++++++++++++ net/smc/Makefile | 2 +- net/smc/af_smc.c | 39 ++-- net/smc/smc_clc.c | 5 + net/smc/smc_clc.h | 1 + net/smc/smc_core.c | 399 ++++++++++++++++++++++++++++++++++++++- net/smc/smc_core.h | 49 +++++ net/smc/smc_diag.c | 23 +-- net/smc/smc_ib.c | 200 ++++++++++++++++++++ net/smc/smc_ib.h | 6 + net/smc/smc_ism.c | 99 +++++++++- net/smc/smc_ism.h | 6 +- net/smc/smc_netlink.c | 85 +++++++++ net/smc/smc_netlink.h | 32 ++++ net/smc/smc_pnet.c | 2 + 15 files changed, 1029 insertions(+), 45 deletions(-) create mode 100644 net/smc/smc_netlink.c create mode 100644 net/smc/smc_netlink.h
Signature · 1 line
2.17.1
PATCH v7 2/14 net/smc: Use active link of the connection
From: Guvenc Gulce <[email protected]>
Use active link of the connection directly and not via linkgroup array structure when obtaining link data of the connection.
--- net/smc/smc_diag.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/smc/smc_diag.c +5 -5
@@ -160,17 +160,17 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb, !list_empty(&smc->conn.lgr->list)) {struct smc_diag_lgrinfo linfo = { .role = smc->conn.lgr->role, - .lnk[0 ].ibport = smc->conn.lgr->lnk[0 ].ibport, - .lnk[0 ].link_id = smc->conn.lgr->lnk[0 ].link_id, + .lnk[0 ].ibport = smc->conn.lnk->ibport, + .lnk[0 ].link_id = smc->conn.lnk->link_id, };memcpy (linfo.lnk[0 ].ibname, smc->conn.lgr->lnk[0 ].smcibdev->ibdev->name, -sizeof (smc->conn.lgr->lnk[0 ].smcibdev->ibdev->name)); +sizeof (smc->conn.lnk->smcibdev->ibdev->name));smc_gid_be16_convert (linfo.lnk[0 ].gid, - smc->conn.lgr->lnk[0 ].gid); + smc->conn.lnk->gid);smc_gid_be16_convert (linfo.lnk[0 ].peer_gid, - smc->conn.lgr->lnk[0 ].peer_gid); + smc->conn.lnk->peer_gid);if (nla_put (skb,SMC_DIAG_LGRINFO ,sizeof (linfo), &linfo) <0 ) goto errout;
Signature · 1 line
2.17.1
PATCH v7 1/14 net/smc: use helper smc_conn_abort() in listen processing
In reply to Karsten GraulThe helper smc_connect_abort() can be used by the listen processing functions, too. And rename this helper to smc_conn_abort() to make the purpose clearer.
No functional change.
--- net/smc/af_smc.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
net/smc/af_smc.c +5 -12
@@ -552,8 +552,7 @@ static int smc_connect_decline_fallback(struct smc_sock *smc, int reason_code,return smc_connect_fallback (smc, reason_code); } -/* abort connecting */ -static void smc_connect_abort (struct smc_sock *smc,int local_first) +static void smc_conn_abort (struct smc_sock *smc,int local_first) {if (local_first)smc_lgr_cleanup_early (&smc->conn);
@@ -814,7 +813,7 @@ static int smc_connect_rdma(struct smc_sock *smc,return 0 ; connect_abort: -smc_connect_abort (smc, ini->first_contact_local); +smc_conn_abort (smc, ini->first_contact_local);mutex_unlock (&smc_client_lgr_pending); smc->connect_nonblock =0 ;
@@ -893,7 +892,7 @@ static int smc_connect_ism(struct smc_sock *smc,return 0 ; connect_abort: -smc_connect_abort (smc, ini->first_contact_local); +smc_conn_abort (smc, ini->first_contact_local);mutex_unlock (&smc_server_lgr_pending); smc->connect_nonblock =0 ;
@@ -1321,10 +1320,7 @@ static void smc_listen_decline(struct smc_sock *new_smc, int reason_code, int local_first, u8 version) {/* RDMA setup failed, switch back to TCP */ -if (local_first) -smc_lgr_cleanup_early (&new_smc->conn); -else -smc_conn_free (&new_smc->conn); +smc_conn_abort (new_smc ,local_first );if (reason_code <0 ) {/* error, no fallback possible */ smc_listen_out_err (new_smc);return ;
@@ -1430,10 +1426,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,/* Create send and receive buffers */ rc =smc_buf_create (new_smc, true);if (rc) { -if (ini->first_contact_local) -smc_lgr_cleanup_early (&new_smc->conn); -else -smc_conn_free (&new_smc->conn); +smc_conn_abort (new_smc, ini->first_contact_local);return (rc == -ENOSPC ) ?SMC_CLC_DECL_MAX_DMB :SMC_CLC_DECL_MEM ; }
Signature · 1 line
2.17.1
PATCH v7 3/14 net/smc: Add connection counters for links
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
Add connection counters to the structure of the link. Increase/decrease the counters as needed in the corresponding routines.
--- net/smc/smc_core.c | 16 ++++++++++++++-- net/smc/smc_core.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-)
net/smc/smc_core.c +14 -2
@@ -139,6 +139,7 @@ static int smcr_lgr_conn_assign_link(struct smc_connection *conn, bool first) }if (!conn->lnk)return SMC_CLC_DECL_NOACTLINK ; +atomic_inc (&conn->lnk->conn_cnt);return 0 ; }
@@ -180,6 +181,8 @@ static void __smc_lgr_unregister_conn(struct smc_connection *conn)struct smc_link_group *lgr = conn->lgr;rb_erase (&conn->alert_node, &lgr->conns_all); +if (conn->lnk) +atomic_dec (&conn->lnk->conn_cnt); lgr->conns_num--; conn->alert_token_local =0 ;sock_put (&smc->sk);/* sock_hold in smc_lgr_register_conn() */
@@ -314,6 +317,7 @@ int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk, lnk->smcibdev = ini->ib_dev; lnk->ibport = ini->ib_port; lnk->path_mtu = ini->ib_dev->pattr[ini->ib_port -1 ].active_mtu; +atomic_set (&lnk->conn_cnt,0 );smc_llc_link_set_uid (lnk);INIT_WORK (&lnk->link_down_wrk, smc_link_down_work);if (!ini->ib_dev->initialized) {
@@ -526,6 +530,14 @@ static int smc_switch_cursor(struct smc_sock *smc, struct smc_cdc_tx_pend *pend,return rc; } +static void smc_switch_link_and_count (struct smc_connection *conn, +struct smc_link *to_lnk) +{ +atomic_dec (&conn->lnk->conn_cnt); + conn->lnk = to_lnk; +atomic_inc (&conn->lnk->conn_cnt); +} +struct smc_link *smc_switch_conns (struct smc_link_group *lgr,struct smc_link *from_lnk,bool is_dev_err) {
@@ -574,7 +586,7 @@ struct smc_link *smc_switch_conns(struct smc_link_group *lgr, smc->sk.sk_state == SMC_PEERABORTWAIT || smc->sk.sk_state == SMC_PROCESSABORT) {spin_lock_bh (&conn->send_lock); - conn->lnk = to_lnk; +smc_switch_link_and_count (conn, to_lnk);spin_unlock_bh (&conn->send_lock);continue ; }
@@ -588,7 +600,7 @@ struct smc_link *smc_switch_conns(struct smc_link_group *lgr, }/* avoid race with smcr_tx_sndbuf_nonempty() */ spin_lock_bh (&conn->send_lock); - conn->lnk = to_lnk; +smc_switch_link_and_count (conn, to_lnk); rc =smc_switch_cursor (smc, pend, wr_buf);spin_unlock_bh (&conn->send_lock);sock_put (&smc->sk);
net/smc/smc_core.h +1 -0
@@ -129,6 +129,7 @@ struct smc_link {struct delayed_work llc_testlink_wrk;/* testlink worker */ struct completion llc_testlink_resp;/* wait for rx of testlink */ int llc_testlink_time;/* testlink interval */ +atomic_t conn_cnt;/* connections on this link */ };/* For now we just allow one parallel link per link group. The SMC protocol
Signature · 1 line
2.17.1
PATCH v7 4/14 net/smc: Add link counters for IB device ports
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
Add link counters to the structure of the smc ib device, one counter per ib port. Increase/decrease the counters as needed in the corresponding routines.
--- net/smc/smc_core.c | 13 +++++++++++++ net/smc/smc_ib.h | 2 ++ 2 files changed, 15 insertions(+)
net/smc/smc_core.c +13 -0
@@ -63,6 +63,16 @@ static inline struct list_head *smc_lgr_list_head(struct smc_link_group *lgr,return &smc_lgr_list.list; } +static void smc_ibdev_cnt_inc (struct smc_link *lnk) +{ +atomic_inc (&lnk->smcibdev->lnk_cnt_by_port[lnk->ibport -1 ]); +} + +static void smc_ibdev_cnt_dec (struct smc_link *lnk) +{ +atomic_dec (&lnk->smcibdev->lnk_cnt_by_port[lnk->ibport -1 ]); +} +static void smc_lgr_schedule_free_work (struct smc_link_group *lgr) {/* client link group creation always follows the server link group
@@ -316,6 +326,7 @@ int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk, lnk->link_idx = link_idx; lnk->smcibdev = ini->ib_dev; lnk->ibport = ini->ib_port; +smc_ibdev_cnt_inc (lnk); lnk->path_mtu = ini->ib_dev->pattr[ini->ib_port -1 ].active_mtu;atomic_set (&lnk->conn_cnt,0 );smc_llc_link_set_uid (lnk);
@@ -359,6 +370,7 @@ int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk, clear_llc_lnk:smc_llc_link_clear (lnk, false); out: +smc_ibdev_cnt_dec (lnk);put_device (&ini->ib_dev->ibdev->dev);memset (lnk,0 ,sizeof (struct smc_link )); lnk->state =SMC_LNK_UNUSED ;
@@ -749,6 +761,7 @@ void smcr_link_clear(struct smc_link *lnk, bool log)smc_ib_destroy_queue_pair (lnk);smc_ib_dealloc_protection_domain (lnk);smc_wr_free_link_mem (lnk); +smc_ibdev_cnt_dec (lnk);put_device (&lnk->smcibdev->ibdev->dev); smcibdev = lnk->smcibdev;memset (lnk,0 ,sizeof (struct smc_link ));
net/smc/smc_ib.h +2 -0
@@ -53,6 +53,8 @@ struct smc_ib_device { /* ib-device infos for smc */atomic_t lnk_cnt;/* number of links on ibdev */ wait_queue_head_t lnks_deleted;/* wait 4 removal of all links*/ struct mutex mutex;/* protect dev setup+cleanup */ +atomic_t lnk_cnt_by_port[SMC_MAX_PORTS ]; +/* number of links per port */ };struct smc_buf_desc ;
Signature · 1 line
2.17.1
PATCH v7 5/14 net/smc: Add diagnostic information to smc ib-device
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
During smc ib-device creation, add network device ifindex to smc ib-device structure. Register for netdevice changes and update ib-device accordingly. This is needed for diagnostic purposes.
--- net/smc/smc_ib.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ net/smc/smc_ib.h | 2 ++ net/smc/smc_pnet.c | 2 ++ 3 files changed, 48 insertions(+)
net/smc/smc_ib.c +44 -0
@@ -557,6 +557,49 @@ static void smc_ib_cleanup_per_ibdev(struct smc_ib_device *smcibdev)static struct ib_client smc_ib_client; +static void smc_copy_netdev_ifindex (struct smc_ib_device *smcibdev,int port) +{ +struct ib_device *ibdev = smcibdev->ibdev; +struct net_device *ndev; + +if (!ibdev->ops.get_netdev) +return ; + ndev = ibdev->ops.get_netdev (ibdev, port +1 ); +if (ndev) { + smcibdev->ndev_ifidx[port] = ndev->ifindex; +dev_put (ndev); + } +} + +void smc_ib_ndev_change (struct net_device *ndev,unsigned long event) +{ +struct smc_ib_device *smcibdev; +struct ib_device *libdev; +struct net_device *lndev; +u8 port_cnt; +int i; + +mutex_lock (&smc_ib_devices.mutex); +list_for_each_entry (smcibdev, &smc_ib_devices.list, list) { + port_cnt = smcibdev->ibdev->phys_port_cnt; +for (i =0 ; i <min_t (size_t, port_cnt,SMC_MAX_PORTS ); i++) { + libdev = smcibdev->ibdev; +if (!libdev->ops.get_netdev) +continue ; + lndev = libdev->ops.get_netdev (libdev, i +1 ); +if (lndev) +dev_put (lndev); +if (lndev != ndev) +continue ; +if (event ==NETDEV_REGISTER ) + smcibdev->ndev_ifidx[i] = ndev->ifindex; +if (event ==NETDEV_UNREGISTER ) + smcibdev->ndev_ifidx[i] =0 ; + } + } +mutex_unlock (&smc_ib_devices.mutex); +} +/* callback function for ib_register_client() */ static int smc_ib_add_dev (struct ib_device *ibdev) {
@@ -596,6 +639,7 @@ static int smc_ib_add_dev(struct ib_device *ibdev)if (smc_pnetid_by_dev_port (ibdev->dev.parent, i, smcibdev->pnetid[i]))smc_pnetid_by_table_ib (smcibdev, i +1 ); +smc_copy_netdev_ifindex (smcibdev, i); pr_warn_ratelimited("smc: ib device %s port %d has pnetid " "%.16s%s\n", smcibdev->ibdev->name, i + 1,
net/smc/smc_ib.h +2 -0
@@ -55,11 +55,13 @@ struct smc_ib_device { /* ib-device infos for smc */struct mutex mutex;/* protect dev setup+cleanup */ atomic_t lnk_cnt_by_port[SMC_MAX_PORTS ];/* number of links per port */ +int ndev_ifidx[SMC_MAX_PORTS ];/* ndev if indexes */ };struct smc_buf_desc ;struct smc_link ; +void smc_ib_ndev_change (struct net_device *ndev,unsigned long event);int smc_ib_register_client (void )__init ;void smc_ib_unregister_client (void );bool smc_ib_port_active (struct smc_ib_device *smcibdev,u8 ibport);
net/smc/smc_pnet.c +2 -0
@@ -827,9 +827,11 @@ static int smc_pnet_netdev_event(struct notifier_block *this,case NETDEV_REBOOT :case NETDEV_UNREGISTER :smc_pnet_remove_by_ndev (event_dev); +smc_ib_ndev_change (event_dev, event);return NOTIFY_OK ;case NETDEV_REGISTER :smc_pnet_add_by_ndev (event_dev); +smc_ib_ndev_change (event_dev, event);return NOTIFY_OK ;case NETDEV_UP :smc_pnet_add_base_pnetid (net, event_dev, ndev_pnetid);
Signature · 1 line
2.17.1
PATCH v7 7/14 net/smc: Refactor smc ism v2 capability handling
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
Encapsulate the smc ism v2 capability boolean value in a function for better information hiding.
--- net/smc/af_smc.c | 12 ++++++------ net/smc/smc_ism.c | 8 +++++++- net/smc/smc_ism.h | 5 ++--- 3 files changed, 15 insertions(+), 10 deletions(-)
net/smc/af_smc.c +6 -6
@@ -668,7 +668,7 @@ static int smc_find_proposal_devices(struct smc_sock *smc, ini->smc_type_v1 =SMC_TYPE_N ; }/* else RDMA is supported for this connection */ } -if (smc_ism_v2_capable &&smc_find_ism_v2_device_clnt (smc, ini)) +if (smc_ism_is_v2_capable () &&smc_find_ism_v2_device_clnt (smc, ini)) ini->smc_type_v2 =SMC_TYPE_N ;/* if neither ISM nor RDMA are supported, fallback */
@@ -920,7 +920,7 @@ static int smc_connect_check_aclc(struct smc_init_info *ini,/* perform steps before actually connecting */ static int __smc_connect (struct smc_sock *smc) { -u8 version = smc_ism_v2_capable ?SMC_V2 :SMC_V1 ; +u8 version =smc_ism_is_v2_capable () ?SMC_V2 :SMC_V1 ;struct smc_clc_msg_accept_confirm_v2 *aclc2;struct smc_clc_msg_accept_confirm *aclc;struct smc_init_info *ini =NULL ;
@@ -945,9 +945,9 @@ static int __smc_connect(struct smc_sock *smc) version); ini->smcd_version =SMC_V1 ; - ini->smcd_version |= smc_ism_v2_capable ?SMC_V2 :0 ; + ini->smcd_version |=smc_ism_is_v2_capable () ?SMC_V2 :0 ; ini->smc_type_v1 =SMC_TYPE_B ; - ini->smc_type_v2 = smc_ism_v2_capable ?SMC_TYPE_D :SMC_TYPE_N ; + ini->smc_type_v2 =smc_ism_is_v2_capable () ?SMC_TYPE_D :SMC_TYPE_N ;/* get vlan id from IP device */ if (smc_vlan_by_tcpsk (smc->clcsock, ini)) {
@@ -1355,7 +1355,7 @@ static int smc_listen_v2_check(struct smc_sock *new_smc, rc =SMC_CLC_DECL_PEERNOSMC ; goto out; } -if (!smc_ism_v2_capable) { +if (!smc_ism_is_v2_capable ()) { ini->smcd_version &= ~SMC_V2 ; rc =SMC_CLC_DECL_NOISM2SUPP ; goto out;
@@ -1681,7 +1681,7 @@ static void smc_listen_work(struct work_struct *work) { struct smc_sock *new_smc = container_of(work, struct smc_sock, smc_listen_work); -u8 version = smc_ism_v2_capable ?SMC_V2 :SMC_V1 ; +u8 version =smc_ism_is_v2_capable () ?SMC_V2 :SMC_V1 ;struct socket *newclcsock = new_smc->clcsock;struct smc_clc_msg_accept_confirm *cclc;struct smc_clc_msg_proposal_area *buf;
net/smc/smc_ism.c +7 -1
@@ -21,7 +21,7 @@ struct smcd_dev_list smcd_dev_list = { .mutex = __MUTEX_INITIALIZER(smcd_dev_list.mutex) }; -bool smc_ism_v2_capable; +static bool smc_ism_v2_capable;/* Test if an ISM communication is possible - same CPC */ int smc_ism_cantalk (u64 peer_gid,unsigned short vlan_id,struct smcd_dev *smcd)
@@ -51,6 +51,12 @@ u16 smc_ism_get_chid(struct smcd_dev *smcd)return smcd->ops->get_chid (smcd); } +/* HW supports ISM V2 and thus System EID is defined */ +bool smc_ism_is_v2_capable (void ) +{ +return smc_ism_v2_capable; +} +/* Set a connection using this DMBE. */ void smc_ism_set_conn (struct smc_connection *conn) {
net/smc/smc_ism.h +2 -3
@@ -10,6 +10,7 @@#define SMCD_ISM_H #include <linux/uio.h> +#include <linux/types.h> #include <linux/mutex.h> #include "smc.h"
@@ -20,9 +21,6 @@ struct smcd_dev_list { /* List of SMCD devices */ };extern struct smcd_dev_list smcd_dev_list;/* list of smcd devices */ -extern bool smc_ism_v2_capable;/* HW supports ISM V2 and thus -* System EID is defined -*/ struct smc_ism_vlanid {/* VLAN id set on ISM device */ struct list_head list;
@@ -52,5 +50,6 @@ int smc_ism_write(struct smcd_dev *dev, const struct smc_ism_position *pos,int smc_ism_signal_shutdown (struct smc_link_group *lgr);void smc_ism_get_system_eid (struct smcd_dev *dev,u8 **eid);u16 smc_ism_get_chid (struct smcd_dev *dev); +bool smc_ism_is_v2_capable (void );void smc_ism_init (void );#endif
Signature · 1 line
2.17.1
PATCH v7 6/14 net/smc: Add diagnostic information to link structure
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
During link creation add net-device ifindex and ib-device name to link structure. This is needed for diagnostic purposes.
When diagnostic information is gathered, we need to traverse device, linkgroup and link structures, to be able to do that we need to hold a spinlock for the linkgroup list, without this diagnostic information in link structure, another device list mutex holding would be necessary to dereference the device pointer in the link structure which would be impossible when holding a spinlock already.
--- net/smc/smc_core.c | 10 ++++++++++ net/smc/smc_core.h | 2 ++ 2 files changed, 12 insertions(+)
net/smc/smc_core.c +10 -0
@@ -313,6 +313,15 @@ static u8 smcr_next_link_id(struct smc_link_group *lgr)return link_id; } +static void smcr_copy_dev_info_to_link (struct smc_link *link) +{ +struct smc_ib_device *smcibdev = link->smcibdev; + +snprintf (link->ibname,sizeof (link->ibname),"%s" , + smcibdev->ibdev->name); + link->ndev_ifidx = smcibdev->ndev_ifidx[link->ibport -1 ]; +} +int smcr_link_init (struct smc_link_group *lgr,struct smc_link *lnk,u8 link_idx,struct smc_init_info *ini) {
@@ -327,6 +336,7 @@ int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk, lnk->smcibdev = ini->ib_dev; lnk->ibport = ini->ib_port;smc_ibdev_cnt_inc (lnk); +smcr_copy_dev_info_to_link (lnk); lnk->path_mtu = ini->ib_dev->pattr[ini->ib_port -1 ].active_mtu;atomic_set (&lnk->conn_cnt,0 );smc_llc_link_set_uid (lnk);
net/smc/smc_core.h +2 -0
@@ -124,6 +124,8 @@ struct smc_link {u8 link_is_asym;/* is link asymmetric? */ struct smc_link_group *lgr;/* parent link group */ struct work_struct link_down_wrk;/* wrk to bring link down */ +char ibname[IB_DEVICE_NAME_MAX ];/* ib device name */ +int ndev_ifidx;/* network device ifindex */ enum smc_link_state state;/* state of link */ struct delayed_work llc_testlink_wrk;/* testlink worker */
Signature · 1 line
2.17.1
PATCH v7 8/14 net/smc: Introduce generic netlink interface for diagnostic purposes
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
Introduce generic netlink interface infrastructure to expose the diagnostic information regarding smc linkgroups, links and devices.
--- include/uapi/linux/smc.h | 11 +++++++++ net/smc/Makefile | 2 +- net/smc/af_smc.c | 10 +++++++- net/smc/smc_netlink.c | 53 ++++++++++++++++++++++++++++++++++++++++ net/smc/smc_netlink.h | 23 +++++++++++++++++ 5 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 net/smc/smc_netlink.c create mode 100644 net/smc/smc_netlink.h
include/uapi/linux/smc.h +11 -0
@@ -33,4 +33,15 @@ enum { /* SMC PNET Table commands */#define SMCR_GENL_FAMILY_NAME "SMC_PNETID"#define SMCR_GENL_FAMILY_VERSION 1 +/* gennetlink interface to access non-socket information from SMC module */ +#define SMC_GENL_FAMILY_NAME "SMC_GEN_NETLINK" +#define SMC_GENL_FAMILY_VERSION 1 + +/* SMC_GENL_FAMILY top level attributes */ +enum { +SMC_GEN_UNSPEC , + __SMC_GEN_MAX, +SMC_GEN_MAX = __SMC_GEN_MAX -1 +}; +#endif /* _UAPI_LINUX_SMC_H */
net/smc/Makefile +1 -1
@@ -2,4 +2,4 @@ obj-$(CONFIG_SMC) += smc.o obj-$(CONFIG_SMC_DIAG) += smc_diag.o smc-y := af_smc.o smc_pnet.o smc_ib.o smc_clc.o smc_core.o smc_wr.o smc_llc.o -smc-y += smc_cdc.o smc_tx.o smc_rx.o smc_close.o smc_ism.o +smc-y += smc_cdc.o smc_tx.o smc_rx.o smc_close.o smc_ism.o smc_netlink.o
net/smc/af_smc.c +9 -1
@@ -45,6 +45,7 @@#include "smc_ib.h" #include "smc_ism.h" #include "smc_pnet.h" +#include "smc_netlink.h" #include "smc_tx.h" #include "smc_rx.h" #include "smc_close.h"
@@ -2495,10 +2496,14 @@ static int __init smc_init(void)smc_ism_init ();smc_clc_init (); - rc =smc_pnet_init (); + rc =smc_nl_init ();if (rc) goto out_pernet_subsys; + rc =smc_pnet_init (); +if (rc) + goto out_nl; + rc = -ENOMEM ; smc_hs_wq =alloc_workqueue ("smc_hs_wq" ,0 ,0 );if (!smc_hs_wq)
@@ -2569,6 +2574,8 @@ static int __init smc_init(void)destroy_workqueue (smc_hs_wq); out_pnet:smc_pnet_exit (); +out_nl: +smc_nl_exit (); out_pernet_subsys:unregister_pernet_subsys (&smc_net_ops);
@@ -2586,6 +2593,7 @@ static void __exit smc_exit(void)proto_unregister (&smc_proto6);proto_unregister (&smc_proto);smc_pnet_exit (); +smc_nl_exit ();unregister_pernet_subsys (&smc_net_ops);rcu_barrier (); }
net/smc/smc_netlink.c new file +53 -0
53 lines not on this page · raw message
net/smc/smc_netlink.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Shared Memory Communications over RDMA (SMC-R) and RoCE +* +* SMC Generic netlink operations +* +* Copyright IBM Corp. 2020 +* +* Author(s): Guvenc Gulce <[email protected]> +*/ + +#ifndef _SMC_NETLINK_H +#define _SMC_NETLINK_H + +#include <net/netlink.h> +#include <net/genetlink.h> + +extern struct genl_family smc_gen_nl_family; + +int smc_nl_init (void )__init ; +void smc_nl_exit (void ); + +#endif
Signature · 1 line
2.17.1
PATCH v7 10/14 net/smc: Introduce SMCR get linkgroup command
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
Introduce get linkgroup command which loops through all available SMCR linkgroups. It uses the SMC-R linkgroup list as entry point, not the socket list, which makes linkgroup diagnosis possible, in case linkgroup does not contain active connections anymore.
--- include/uapi/linux/smc.h | 15 +++++++ net/smc/smc_core.c | 85 ++++++++++++++++++++++++++++++++++++++++ net/smc/smc_core.h | 1 + net/smc/smc_netlink.c | 5 +++ 4 files changed, 106 insertions(+)
include/uapi/linux/smc.h +15 -0
@@ -40,12 +40,14 @@ enum { /* SMC PNET Table commands *//* SMC_GENL_FAMILY commands */ enum {SMC_NETLINK_GET_SYS_INFO =1 , +SMC_NETLINK_GET_LGR_SMCR , };/* SMC_GENL_FAMILY top level attributes */ enum {SMC_GEN_UNSPEC ,SMC_GEN_SYS_INFO ,/* nest */ +SMC_GEN_LGR_SMCR ,/* nest */ __SMC_GEN_MAX,SMC_GEN_MAX = __SMC_GEN_MAX -1 };
@@ -62,4 +64,17 @@ enum {SMC_NLA_SYS_MAX = __SMC_NLA_SYS_MAX -1 }; +/* SMC_GEN_LGR_SMCR attributes */ +enum { +SMC_NLA_LGR_R_UNSPEC , +SMC_NLA_LGR_R_ID ,/* u32 */ +SMC_NLA_LGR_R_ROLE ,/* u8 */ +SMC_NLA_LGR_R_TYPE ,/* u8 */ +SMC_NLA_LGR_R_PNETID ,/* string */ +SMC_NLA_LGR_R_VLAN_ID ,/* u8 */ +SMC_NLA_LGR_R_CONNS_NUM ,/* u32 */ + __SMC_NLA_LGR_R_MAX, +SMC_NLA_LGR_R_MAX = __SMC_NLA_LGR_R_MAX -1 +}; +#endif /* _UAPI_LINUX_SMC_H */
net/smc/smc_core.c +85 -0
91 lines not on this page · raw message
net/smc/smc_core.h +1 -0
@@ -415,6 +415,7 @@ struct smc_link *smc_switch_conns(struct smc_link_group *lgr,void smcr_link_down_cond (struct smc_link *lnk);void smcr_link_down_cond_sched (struct smc_link *lnk);int smc_nl_get_sys_info (struct sk_buff *skb,struct netlink_callback *cb); +int smcr_nl_get_lgr (struct sk_buff *skb,struct netlink_callback *cb);static inline struct smc_link_group *smc_get_lgr (struct smc_link *link) {
net/smc/smc_netlink.c +5 -0
@@ -28,6 +28,11 @@ static const struct genl_ops smc_gen_nl_ops[] = {/* can be retrieved by unprivileged users */ .dumpit = smc_nl_get_sys_info, }, + { + .cmd = SMC_NETLINK_GET_LGR_SMCR, + /* can be retrieved by unprivileged users */ + .dumpit = smcr_nl_get_lgr, + }, };static const struct nla_policy smc_gen_nl_policy[2 ] = {
Signature · 1 line
2.17.1
PATCH v7 12/14 net/smc: Add SMC-D Linkgroup diagnostic support
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
Deliver SMCD Linkgroup information via netlink based diagnostic interface.
--- include/uapi/linux/smc.h | 27 ++++++++ net/smc/smc_core.c | 130 +++++++++++++++++++++++++++++++++++++++ net/smc/smc_core.h | 1 + net/smc/smc_netlink.c | 5 ++ 4 files changed, 163 insertions(+)
include/uapi/linux/smc.h +27 -0
@@ -42,6 +42,7 @@ enum {SMC_NETLINK_GET_SYS_INFO =1 ,SMC_NETLINK_GET_LGR_SMCR ,SMC_NETLINK_GET_LINK_SMCR , + SMC_NETLINK_GET_LGR_SMCD, };/* SMC_GENL_FAMILY top level attributes */
@@ -50,6 +51,7 @@ enum {SMC_GEN_SYS_INFO ,/* nest */ SMC_GEN_LGR_SMCR ,/* nest */ SMC_GEN_LINK_SMCR ,/* nest */ +SMC_GEN_LGR_SMCD ,/* nest */ __SMC_GEN_MAX, SMC_GEN_MAX = __SMC_GEN_MAX - 1 };
@@ -66,6 +68,15 @@ enum {SMC_NLA_SYS_MAX = __SMC_NLA_SYS_MAX -1 }; +/* SMC_NLA_LGR_V2 nested attributes */ +enum { +SMC_NLA_LGR_V2_VER ,/* u8 */ +SMC_NLA_LGR_V2_REL ,/* u8 */ +SMC_NLA_LGR_V2_OS ,/* u8 */ +SMC_NLA_LGR_V2_NEG_EID ,/* string */ +SMC_NLA_LGR_V2_PEER_HOST ,/* string */ +}; +/* SMC_GEN_LGR_SMCR attributes */ enum {SMC_NLA_LGR_R_UNSPEC ,
@@ -95,4 +106,20 @@ enum { __SMC_NLA_LINK_MAX,SMC_NLA_LINK_MAX = __SMC_NLA_LINK_MAX -1 }; + +/* SMC_GEN_LGR_SMCD attributes */ +enum { +SMC_NLA_LGR_D_UNSPEC , +SMC_NLA_LGR_D_ID ,/* u32 */ +SMC_NLA_LGR_D_GID ,/* u64 */ +SMC_NLA_LGR_D_PEER_GID ,/* u64 */ +SMC_NLA_LGR_D_VLAN_ID ,/* u8 */ +SMC_NLA_LGR_D_CONNS_NUM ,/* u32 */ +SMC_NLA_LGR_D_PNETID ,/* string */ +SMC_NLA_LGR_D_CHID ,/* u16 */ +SMC_NLA_LGR_D_PAD ,/* flag */ +SMC_NLA_LGR_V2 ,/* nest */ + __SMC_NLA_LGR_D_MAX, +SMC_NLA_LGR_D_MAX = __SMC_NLA_LGR_D_MAX -1 +};#endif /* _UAPI_LINUX_SMC_H */
net/smc/smc_core.c +130 -0
142 lines not on this page · raw message
net/smc/smc_core.h +1 -0
@@ -430,6 +430,7 @@ void smcr_link_down_cond_sched(struct smc_link *lnk);int smc_nl_get_sys_info (struct sk_buff *skb,struct netlink_callback *cb);int smcr_nl_get_lgr (struct sk_buff *skb,struct netlink_callback *cb);int smcr_nl_get_link (struct sk_buff *skb,struct netlink_callback *cb); +int smcd_nl_get_lgr (struct sk_buff *skb,struct netlink_callback *cb);static inline struct smc_link_group *smc_get_lgr (struct smc_link *link) {
net/smc/smc_netlink.c +5 -0
@@ -38,6 +38,11 @@ static const struct genl_ops smc_gen_nl_ops[] = {/* can be retrieved by unprivileged users */ .dumpit = smcr_nl_get_link, }, + { + .cmd = SMC_NETLINK_GET_LGR_SMCD, + /* can be retrieved by unprivileged users */ + .dumpit = smcd_nl_get_lgr, + }, };static const struct nla_policy smc_gen_nl_policy[2 ] = {
Signature · 1 line
2.17.1
PATCH v7 11/14 net/smc: Introduce SMCR get link command
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
Introduce get link command which loops through all available links of all available link groups. It uses the SMC-R linkgroup list as entry point, not the socket list, which makes linkgroup diagnosis possible, in case linkgroup does not contain active connections anymore.
--- include/uapi/linux/smc.h | 18 ++++++++ net/smc/smc_core.c | 91 ++++++++++++++++++++++++++++++++++++++-- net/smc/smc_core.h | 14 +++++++ net/smc/smc_diag.c | 13 ------ net/smc/smc_netlink.c | 5 +++ 5 files changed, 124 insertions(+), 17 deletions(-)
include/uapi/linux/smc.h +18 -0
@@ -41,6 +41,7 @@ enum { /* SMC PNET Table commands */enum {SMC_NETLINK_GET_SYS_INFO =1 ,SMC_NETLINK_GET_LGR_SMCR , +SMC_NETLINK_GET_LINK_SMCR , };/* SMC_GENL_FAMILY top level attributes */
@@ -48,6 +49,7 @@ enum {SMC_GEN_UNSPEC ,SMC_GEN_SYS_INFO ,/* nest */ SMC_GEN_LGR_SMCR ,/* nest */ +SMC_GEN_LINK_SMCR ,/* nest */ __SMC_GEN_MAX, SMC_GEN_MAX = __SMC_GEN_MAX - 1 };
@@ -77,4 +79,20 @@ enum {SMC_NLA_LGR_R_MAX = __SMC_NLA_LGR_R_MAX -1 }; +/* SMC_GEN_LINK_SMCR attributes */ +enum { +SMC_NLA_LINK_UNSPEC , +SMC_NLA_LINK_ID ,/* u8 */ +SMC_NLA_LINK_IB_DEV ,/* string */ +SMC_NLA_LINK_IB_PORT ,/* u8 */ +SMC_NLA_LINK_GID ,/* string */ +SMC_NLA_LINK_PEER_GID ,/* string */ +SMC_NLA_LINK_CONN_CNT ,/* u32 */ +SMC_NLA_LINK_NET_DEV ,/* u32 */ +SMC_NLA_LINK_UID ,/* u32 */ +SMC_NLA_LINK_PEER_UID ,/* u32 */ +SMC_NLA_LINK_STATE ,/* u32 */ + __SMC_NLA_LINK_MAX, +SMC_NLA_LINK_MAX = __SMC_NLA_LINK_MAX -1 +};#endif /* _UAPI_LINUX_SMC_H */
net/smc/smc_core.c +87 -4
125 lines not on this page · raw message
net/smc/smc_core.h +14 -0
@@ -367,6 +367,19 @@ static inline bool smc_link_active(struct smc_link *lnk)return lnk->state ==SMC_LNK_ACTIVE ; } +static inline void smc_gid_be16_convert (__u8 *buf,u8 *gid_raw) +{ +sprintf (buf,"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x" , +be16_to_cpu (((__be16 *)gid_raw)[0 ]), +be16_to_cpu (((__be16 *)gid_raw)[1 ]), +be16_to_cpu (((__be16 *)gid_raw)[2 ]), +be16_to_cpu (((__be16 *)gid_raw)[3 ]), +be16_to_cpu (((__be16 *)gid_raw)[4 ]), +be16_to_cpu (((__be16 *)gid_raw)[5 ]), +be16_to_cpu (((__be16 *)gid_raw)[6 ]), +be16_to_cpu (((__be16 *)gid_raw)[7 ])); +} +struct smc_sock ;struct smc_clc_msg_accept_confirm ;struct smc_clc_msg_local ;
@@ -416,6 +429,7 @@ void smcr_link_down_cond(struct smc_link *lnk);void smcr_link_down_cond_sched (struct smc_link *lnk);int smc_nl_get_sys_info (struct sk_buff *skb,struct netlink_callback *cb);int smcr_nl_get_lgr (struct sk_buff *skb,struct netlink_callback *cb); +int smcr_nl_get_link (struct sk_buff *skb,struct netlink_callback *cb);static inline struct smc_link_group *smc_get_lgr (struct smc_link *link) {
net/smc/smc_diag.c +0 -13
@@ -31,19 +31,6 @@ static struct smc_diag_dump_ctx *smc_dump_context(struct netlink_callback *cb)return (struct smc_diag_dump_ctx *)cb->ctx; } -static void smc_gid_be16_convert (__u8 *buf,u8 *gid_raw) -{ -sprintf (buf,"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x" , -be16_to_cpu (((__be16 *)gid_raw)[0 ]), -be16_to_cpu (((__be16 *)gid_raw)[1 ]), -be16_to_cpu (((__be16 *)gid_raw)[2 ]), -be16_to_cpu (((__be16 *)gid_raw)[3 ]), -be16_to_cpu (((__be16 *)gid_raw)[4 ]), -be16_to_cpu (((__be16 *)gid_raw)[5 ]), -be16_to_cpu (((__be16 *)gid_raw)[6 ]), -be16_to_cpu (((__be16 *)gid_raw)[7 ])); -} -static void smc_diag_msg_common_fill (struct smc_diag_msg *r,struct sock *sk) {struct smc_sock *smc =smc_sk (sk);
net/smc/smc_netlink.c +5 -0
@@ -33,6 +33,11 @@ static const struct genl_ops smc_gen_nl_ops[] = {/* can be retrieved by unprivileged users */ .dumpit = smcr_nl_get_lgr, }, + { + .cmd = SMC_NETLINK_GET_LINK_SMCR, + /* can be retrieved by unprivileged users */ + .dumpit = smcr_nl_get_link, + }, };static const struct nla_policy smc_gen_nl_policy[2 ] = {
Signature · 1 line
2.17.1
PATCH v7 13/14 net/smc: Add support for obtaining SMCD device list
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
Deliver SMCD device information via netlink based
diagnostic interface.
--- include/uapi/linux/smc.h | 28 +++++++++++++ net/smc/smc_core.h | 28 +++++++++++++ net/smc/smc_ism.c | 91 ++++++++++++++++++++++++++++++++++++++++ net/smc/smc_ism.h | 1 + net/smc/smc_netlink.c | 6 +++ 5 files changed, 154 insertions(+)
include/uapi/linux/smc.h +28 -0
@@ -37,12 +37,15 @@ enum { /* SMC PNET Table commands */#define SMC_GENL_FAMILY_NAME "SMC_GEN_NETLINK"#define SMC_GENL_FAMILY_VERSION 1 +#define SMC_PCI_ID_STR_LEN 16/* Max length of pci id string */ +/* SMC_GENL_FAMILY commands */ enum {SMC_NETLINK_GET_SYS_INFO =1 ,SMC_NETLINK_GET_LGR_SMCR ,SMC_NETLINK_GET_LINK_SMCR ,SMC_NETLINK_GET_LGR_SMCD , +SMC_NETLINK_GET_DEV_SMCD , };/* SMC_GENL_FAMILY top level attributes */
@@ -52,6 +55,7 @@ enum {SMC_GEN_LGR_SMCR ,/* nest */ SMC_GEN_LINK_SMCR ,/* nest */ SMC_GEN_LGR_SMCD ,/* nest */ +SMC_GEN_DEV_SMCD ,/* nest */ __SMC_GEN_MAX, SMC_GEN_MAX = __SMC_GEN_MAX - 1 };
@@ -122,4 +126,28 @@ enum { __SMC_NLA_LGR_D_MAX,SMC_NLA_LGR_D_MAX = __SMC_NLA_LGR_D_MAX -1 }; + +/* SMC_NLA_DEV_PORT attributes */ +enum { +SMC_NLA_DEV_PORT_UNSPEC , +SMC_NLA_DEV_PORT_PNET_USR ,/* u8 */ +SMC_NLA_DEV_PORT_PNETID ,/* string */ + __SMC_NLA_DEV_PORT_MAX, +SMC_NLA_DEV_PORT_MAX = __SMC_NLA_DEV_PORT_MAX -1 +}; + +/* SMC_GEN_DEV_SMCD attributes */ +enum { +SMC_NLA_DEV_UNSPEC , +SMC_NLA_DEV_USE_CNT ,/* u32 */ +SMC_NLA_DEV_IS_CRIT ,/* u8 */ +SMC_NLA_DEV_PCI_FID ,/* u32 */ +SMC_NLA_DEV_PCI_CHID ,/* u16 */ +SMC_NLA_DEV_PCI_VENDOR ,/* u16 */ +SMC_NLA_DEV_PCI_DEVICE ,/* u16 */ +SMC_NLA_DEV_PCI_ID ,/* string */ +SMC_NLA_DEV_PORT ,/* nest */ + __SMC_NLA_DEV_MAX, +SMC_NLA_DEV_MAX = __SMC_NLA_DEV_MAX -1 +};#endif /* _UAPI_LINUX_SMC_H */
net/smc/smc_core.h +28 -0
@@ -13,6 +13,8 @@#define _SMC_CORE_H#include <linux/atomic.h> +#include <linux/smc.h> +#include <linux/pci.h> #include <rdma/ib_verbs.h> #include <net/genetlink.h>
@@ -380,6 +382,32 @@ static inline void smc_gid_be16_convert(__u8 *buf, u8 *gid_raw) be16_to_cpu(((__be16 *)gid_raw)[7])); } +struct smc_pci_dev { +__u32 pci_fid; +__u16 pci_pchid; +__u16 pci_vendor; +__u16 pci_device; +__u8 pci_id[SMC_PCI_ID_STR_LEN ]; +}; + +static inline void smc_set_pci_values (struct pci_dev *pci_dev, +struct smc_pci_dev *smc_dev) +{ + smc_dev->pci_vendor = pci_dev->vendor; + smc_dev->pci_device = pci_dev->device; +snprintf (smc_dev->pci_id,sizeof (smc_dev->pci_id),"%s" , +pci_name (pci_dev)); +#if IS_ENABLED (CONFIG_S390 ) + {/* Set s390 specific PCI information */ +struct zpci_dev *zdev; + + zdev =to_zpci (pci_dev); + smc_dev->pci_fid = zdev->fid; + smc_dev->pci_pchid = zdev->pchid; + } +#endif +} +struct smc_sock ;struct smc_clc_msg_accept_confirm ;struct smc_clc_msg_local ;
net/smc/smc_ism.c +91 -0
103 lines not on this page · raw message
net/smc/smc_ism.h +1 -0
@@ -52,4 +52,5 @@ void smc_ism_get_system_eid(struct smcd_dev *dev, u8 **eid);u16 smc_ism_get_chid (struct smcd_dev *dev);bool smc_ism_is_v2_capable (void );void smc_ism_init (void ); +int smcd_nl_get_device (struct sk_buff *skb,struct netlink_callback *cb);#endif
net/smc/smc_netlink.c +6 -0
@@ -17,6 +17,7 @@#include <linux/smc.h> #include "smc_core.h" +#include "smc_ism.h" #include "smc_netlink.h" #define SMC_CMD_MAX_ATTR 1
@@ -43,6 +44,11 @@ static const struct genl_ops smc_gen_nl_ops[] = {/* can be retrieved by unprivileged users */ .dumpit = smcd_nl_get_lgr, }, + { + .cmd = SMC_NETLINK_GET_DEV_SMCD, + /* can be retrieved by unprivileged users */ + .dumpit = smcd_nl_get_device, + }, };static const struct nla_policy smc_gen_nl_policy[2 ] = {
Signature · 1 line
2.17.1
PATCH v7 9/14 net/smc: Add support for obtaining system information
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
Add new netlink command to obtain system information of the smc module.
--- include/uapi/linux/smc.h | 18 ++++++++++++ net/smc/smc_clc.c | 5 ++++ net/smc/smc_clc.h | 1 + net/smc/smc_core.c | 60 ++++++++++++++++++++++++++++++++++++++++ net/smc/smc_core.h | 2 ++ net/smc/smc_netlink.c | 5 ++++ net/smc/smc_netlink.h | 9 ++++++ 7 files changed, 100 insertions(+)
include/uapi/linux/smc.h +18 -0
@@ -37,11 +37,29 @@ enum { /* SMC PNET Table commands */#define SMC_GENL_FAMILY_NAME "SMC_GEN_NETLINK"#define SMC_GENL_FAMILY_VERSION 1 +/* SMC_GENL_FAMILY commands */ +enum { +SMC_NETLINK_GET_SYS_INFO =1 , +}; +/* SMC_GENL_FAMILY top level attributes */ enum {SMC_GEN_UNSPEC , +SMC_GEN_SYS_INFO ,/* nest */ __SMC_GEN_MAX,SMC_GEN_MAX = __SMC_GEN_MAX -1 }; +/* SMC_GEN_SYS_INFO attributes */ +enum { +SMC_NLA_SYS_UNSPEC , +SMC_NLA_SYS_VER ,/* u8 */ +SMC_NLA_SYS_REL ,/* u8 */ +SMC_NLA_SYS_IS_ISM_V2 ,/* u8 */ +SMC_NLA_SYS_LOCAL_HOST ,/* string */ +SMC_NLA_SYS_SEID ,/* string */ + __SMC_NLA_SYS_MAX, +SMC_NLA_SYS_MAX = __SMC_NLA_SYS_MAX -1 +}; +#endif /* _UAPI_LINUX_SMC_H */
net/smc/smc_clc.c +5 -0
@@ -772,6 +772,11 @@ int smc_clc_send_accept(struct smc_sock *new_smc, bool srv_first_contact,return len >0 ?0 : len; } +void smc_clc_get_hostname (u8 **host) +{ + *host = &smc_hostname[0 ]; +} +void __init smc_clc_init (void ) {struct new_utsname *u;
net/smc/smc_clc.h +1 -0
@@ -334,5 +334,6 @@ int smc_clc_send_confirm(struct smc_sock *smc, bool clnt_first_contact,int smc_clc_send_accept (struct smc_sock *smc,bool srv_first_contact,u8 version);void smc_clc_init (void )__init ; +void smc_clc_get_hostname (u8 **host);#endif
net/smc/smc_core.c +60 -0
78 lines not on this page · raw message
net/smc/smc_core.h +2 -0
@@ -14,6 +14,7 @@#include <linux/atomic.h> #include <rdma/ib_verbs.h> +#include <net/genetlink.h> #include "smc.h" #include "smc_ib.h"
@@ -413,6 +414,7 @@ struct smc_link *smc_switch_conns(struct smc_link_group *lgr, struct smc_link *from_lnk, bool is_dev_err);void smcr_link_down_cond (struct smc_link *lnk);void smcr_link_down_cond_sched (struct smc_link *lnk); +int smc_nl_get_sys_info (struct sk_buff *skb,struct netlink_callback *cb);static inline struct smc_link_group *smc_get_lgr (struct smc_link *link) {
net/smc/smc_netlink.c +5 -0
@@ -23,6 +23,11 @@/* SMC_GENL generic netlink operation definition */ static const struct genl_ops smc_gen_nl_ops[] = { + { + .cmd =SMC_NETLINK_GET_SYS_INFO , +/* can be retrieved by unprivileged users */ + .dumpit = smc_nl_get_sys_info, + }, };static const struct nla_policy smc_gen_nl_policy[2 ] = {
net/smc/smc_netlink.h +9 -0
@@ -17,6 +17,15 @@extern struct genl_family smc_gen_nl_family; +struct smc_nl_dmp_ctx { +int pos[2 ]; +}; + +static inline struct smc_nl_dmp_ctx *smc_nl_dmp_ctx (struct netlink_callback *c) +{ +return (struct smc_nl_dmp_ctx *)c->ctx; +} +int smc_nl_init (void )__init ;void smc_nl_exit (void );
Signature · 1 line
2.17.1
PATCH v7 14/14 net/smc: Add support for obtaining SMCR device list
In reply to Karsten GraulFrom: Guvenc Gulce <[email protected]>
Deliver SMCR device information via netlink based
diagnostic interface.
--- include/uapi/linux/smc.h | 13 +++- net/smc/smc_core.c | 2 +- net/smc/smc_ib.c | 156 +++++++++++++++++++++++++++++++++++++++ net/smc/smc_ib.h | 2 + net/smc/smc_netlink.c | 6 ++ 5 files changed, 176 insertions(+), 3 deletions(-)
include/uapi/linux/smc.h +11 -2
@@ -46,6 +46,7 @@ enum {SMC_NETLINK_GET_LINK_SMCR ,SMC_NETLINK_GET_LGR_SMCD ,SMC_NETLINK_GET_DEV_SMCD , + SMC_NETLINK_GET_DEV_SMCR, };/* SMC_GENL_FAMILY top level attributes */
@@ -56,6 +57,7 @@ enum {SMC_GEN_LINK_SMCR ,/* nest */ SMC_GEN_LGR_SMCD ,/* nest */ SMC_GEN_DEV_SMCD ,/* nest */ +SMC_GEN_DEV_SMCR ,/* nest */ __SMC_GEN_MAX, SMC_GEN_MAX = __SMC_GEN_MAX - 1 };
@@ -127,16 +129,20 @@ enum {SMC_NLA_LGR_D_MAX = __SMC_NLA_LGR_D_MAX -1 }; -/* SMC_NLA_DEV_PORT attributes */ +/* SMC_NLA_DEV_PORT nested attributes */ enum {SMC_NLA_DEV_PORT_UNSPEC ,SMC_NLA_DEV_PORT_PNET_USR ,/* u8 */ SMC_NLA_DEV_PORT_PNETID ,/* string */ +SMC_NLA_DEV_PORT_NETDEV ,/* u32 */ +SMC_NLA_DEV_PORT_STATE ,/* u8 */ +SMC_NLA_DEV_PORT_VALID ,/* u8 */ +SMC_NLA_DEV_PORT_LNK_CNT ,/* u32 */ __SMC_NLA_DEV_PORT_MAX,SMC_NLA_DEV_PORT_MAX = __SMC_NLA_DEV_PORT_MAX -1 }; -/* SMC_GEN_DEV_SMCD attributes */ +/* SMC_GEN_DEV_SMCD and SMC_GEN_DEV_SMCR attributes */ enum {SMC_NLA_DEV_UNSPEC ,SMC_NLA_DEV_USE_CNT ,/* u32 */
@@ -147,7 +153,10 @@ enum {SMC_NLA_DEV_PCI_DEVICE ,/* u16 */ SMC_NLA_DEV_PCI_ID ,/* string */ SMC_NLA_DEV_PORT ,/* nest */ +SMC_NLA_DEV_PORT2 ,/* nest */ +SMC_NLA_DEV_IB_NAME ,/* string */ __SMC_NLA_DEV_MAX,SMC_NLA_DEV_MAX = __SMC_NLA_DEV_MAX -1 }; +#endif /* _UAPI_LINUX_SMC_H */
net/smc/smc_core.c +1 -1
@@ -38,7 +38,7 @@#define SMC_LGR_FREE_DELAY_SERV (600 * HZ)#define SMC_LGR_FREE_DELAY_CLNT (SMC_LGR_FREE_DELAY_SERV + 10 * HZ) -static struct smc_lgr_list smc_lgr_list = {/* established link groups */ +struct smc_lgr_list smc_lgr_list = {/* established link groups */ .lock =__SPIN_LOCK_UNLOCKED (smc_lgr_list.lock), .list =LIST_HEAD_INIT (smc_lgr_list.list), .num =0 ,
net/smc/smc_ib.c +156 -0
168 lines not on this page · raw message
net/smc/smc_ib.h +2 -0
@@ -30,6 +30,7 @@ struct smc_ib_devices { /* list of smc ib devices definition */ };extern struct smc_ib_devices smc_ib_devices;/* list of smc ib devices */ +extern struct smc_lgr_list smc_lgr_list;/* list of linkgroups */ struct smc_ib_device {/* ib-device infos for smc */ struct list_head list;
@@ -91,4 +92,5 @@ void smc_ib_sync_sg_for_device(struct smc_link *lnk,int smc_ib_determine_gid (struct smc_ib_device *smcibdev,u8 ibport,unsigned short vlan_id,u8 gid[],u8 *sgid_index);bool smc_ib_is_valid_local_systemid (void ); +int smcr_nl_get_device (struct sk_buff *skb,struct netlink_callback *cb);#endif
net/smc/smc_netlink.c +6 -0
@@ -18,6 +18,7 @@#include "smc_core.h" #include "smc_ism.h" +#include "smc_ib.h" #include "smc_netlink.h" #define SMC_CMD_MAX_ATTR 1
@@ -49,6 +50,11 @@ static const struct genl_ops smc_gen_nl_ops[] = {/* can be retrieved by unprivileged users */ .dumpit = smcd_nl_get_device, }, + { + .cmd = SMC_NETLINK_GET_DEV_SMCR, + /* can be retrieved by unprivileged users */ + .dumpit = smcr_nl_get_device, + }, };static const struct nla_policy smc_gen_nl_policy[2 ] = {
Signature · 1 line
2.17.1
Quoted 24 lines · On Tue, 1 Dec 2020 20:20:35 +0100 Karsten Graul wrote:
Please apply the following patch series for smc to netdev's net-next tree.
Up to version 4 this patch series was using the
sock_diagnetlink infrastructure. This version is using the generic netlink API. Generic netlink API offers a better type safety between kernel and userspace communication.
Using the generic netlink API the smc module can now provide information about SMC linkgroups, links and devices (both for SMC-R and SMC-D).v2: Add missing include to uapi header
smc_diag.h.v3: Apply code style recommendations from review comments.
Instead of using EXPORTs to allow thesmc_diagmodule to access data of the smc module, introduce structsmc_diag_opsand letsmc_diagaccess the required data using function pointers.v4: Address checkpatch.pl warnings. Do not use static inline for
functions.v5: Use generic netlink API instead of the
sock_diagnetlink
infrastructure.v6: Integrate more review comments from Jakub.
Quoted 15 lines
v7: Use
nla_nest_start()with the new family. Use .maxattr=1 in the
genl family and define one entry for attribute 1 in the policy to reject this attritbute for all commands. All other possible attributes are rejected becauseNL_VALIDATE_STRICTis set for the policy implicitely, which includesNL_VALIDATE_MAXTYPE.
Setting policy[0].strict_start_type=1 does not work here because there is no valid attribute defined for this family, only plain commands. For any type > maxtype (which is .maxattr)validate_nla()would return 0 to userspace instead of-EINVAL. What helps here is__nla_validate_parse()which checks for type > maxtype and returns-EINVALwhenNL_VALIDATE_MAXTYPEis set. This requires the one entry for type == .maxattr with .type =NLA_REJECTin thenla_policy.
When a future command wants to allow attributes then it can easily specify a dedicated .policy for this new command in thegenl_opsarray. This dedicated policy overlays the global policy specified in thegenl_familystructure.
Applied, thank you!