From patchwork Mon Nov 2 19:33:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karsten Graul X-Patchwork-Id: 315784 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40072C2D0A3 for ; Mon, 2 Nov 2020 19:39:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF91422280 for ; Mon, 2 Nov 2020 19:39:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="YQMZl/Bn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727039AbgKBTjl (ORCPT ); Mon, 2 Nov 2020 14:39:41 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:14576 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726509AbgKBTjk (ORCPT ); Mon, 2 Nov 2020 14:39:40 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JaxpP065522 for ; Mon, 2 Nov 2020 14:39:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=s/HRzeD+3KGfEzpf5dG4UYvemk8/JHV23L+u+8kEYfw=; b=YQMZl/Bns89jlvSg77lcPX+UB2XqwzkUV0GUGTAMif+DFY+fnMCWJzBz9RcIFZap+uEu upa6U0xOfoc0wkC+F37Deyx4KM+1E1yhE6XMQRk8TPU1wouHQG3sElbFvQZrufyWO8+G AjZXWZBnVugavf4Xs/RIn+jqLeF7p4DurTo/5MeKtNw6ToznYbDWvfuw7Avbcdwm+2wP 7dWBcMLJobbf0PXwebJ6zQOHBmm0me9R2syAJW8mDzX8PjoJQ9yaJ36iKpK1pl4OQ36J SNg2SJfPVciZECN8RAWEbSM7BFOY8Ftuxjl5GNf1baJdD1lUh+5pjikG3132XU9Tr7wY Bg== Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0b-001b2d01.pphosted.com with ESMTP id 34hn6ge7x9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 02 Nov 2020 14:39:38 -0500 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JXdkj031970 for ; Mon, 2 Nov 2020 19:34:28 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma01fra.de.ibm.com with ESMTP id 34jbytrbb8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 02 Nov 2020 19:34:28 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0A2JYQxi9503328 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 2 Nov 2020 19:34:26 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E684A4C040; Mon, 2 Nov 2020 19:34:25 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B2E6F4C04A; Mon, 2 Nov 2020 19:34:25 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 2 Nov 2020 19:34:25 +0000 (GMT) From: Karsten Graul To: davem@davemloft.net Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org, hca@linux.ibm.com, raspl@linux.ibm.com Subject: [PATCH net-next 01/15] net/smc: use helper smc_conn_abort() in listen processing Date: Mon, 2 Nov 2020 20:33:55 +0100 Message-Id: <20201102193409.70901-2-kgraul@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201102193409.70901-1-kgraul@linux.ibm.com> References: <20201102193409.70901-1-kgraul@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-02_13:2020-11-02,2020-11-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=3 clxscore=1015 phishscore=0 mlxscore=0 bulkscore=0 mlxlogscore=717 lowpriorityscore=0 malwarescore=0 priorityscore=1501 spamscore=0 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011020145 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The 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. Signed-off-by: Karsten Graul --- net/smc/af_smc.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 527185af7bf3..bc3e45289771 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -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; @@ -1320,10 +1319,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; @@ -1429,10 +1425,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; } From patchwork Mon Nov 2 19:33:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karsten Graul X-Patchwork-Id: 315785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BCF2C388F9 for ; Mon, 2 Nov 2020 19:35:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2303F22268 for ; Mon, 2 Nov 2020 19:35:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="nJ8I6F0u" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726753AbgKBTee (ORCPT ); Mon, 2 Nov 2020 14:34:34 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49252 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726731AbgKBTed (ORCPT ); Mon, 2 Nov 2020 14:34:33 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JVgWn185308; Mon, 2 Nov 2020 14:34:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=nAtl1/5O5Eb11bfeE1ZbWJ4BWiXIDYZngCXDabu8CkA=; b=nJ8I6F0uquXdPJrB1nu42iC0XRwlYBT+iKwa9hg1emKFlZs6X2AIyXU3i90I36y1c2+T /KbEe4kG3hRyHJW7jvgq4Te9qFc1C4hGxxSSde1OjEESeD9gMQnVuK1uA8gr1XPQ93gy vrUdrvK9Se2euJi/D3P65fM2pi26RBFmVjsrLjQc/Kfow0IXwW9sVNZ+wNDS19psCcaF /9TVA3Dx1RN0uqrI4wGBsVBcBZVB22eVReoriEXYrosjXgzQ02VsnoPduFvNzdQGikAE Dz0ISxFJSaSm1l18whYIVC1vokNMU0RZCCLnSdCEx0hqBAg0IkA9q1rXuDl8Hs6+azXD wg== Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com with ESMTP id 34j8yn3k9h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 14:34:31 -0500 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JXNUx023847; Mon, 2 Nov 2020 19:34:29 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma02fra.de.ibm.com with ESMTP id 34j6j40fbq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 19:34:29 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0A2JYQGO2097842 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Nov 2020 19:34:26 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C4CB4C040; Mon, 2 Nov 2020 19:34:26 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3ABFE4C04A; Mon, 2 Nov 2020 19:34:26 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 2 Nov 2020 19:34:26 +0000 (GMT) From: Karsten Graul To: davem@davemloft.net Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org, hca@linux.ibm.com, raspl@linux.ibm.com Subject: [PATCH net-next 03/15] net/smc: Add connection counters for links Date: Mon, 2 Nov 2020 20:33:57 +0100 Message-Id: <20201102193409.70901-4-kgraul@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201102193409.70901-1-kgraul@linux.ibm.com> References: <20201102193409.70901-1-kgraul@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-02_12:2020-11-02,2020-11-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 phishscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011020145 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Guvenc Gulce Add connection counters to the structure of the link. Increase/decrease the counters as needed in the corresponding routines. Signed-off-by: Guvenc Gulce Signed-off-by: Karsten Graul --- net/smc/smc_core.c | 16 ++++++++++++++-- net/smc/smc_core.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index 2b19863f7171..6e2077161267 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -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 inline 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); diff --git a/net/smc/smc_core.h b/net/smc/smc_core.h index 9aee54a6bcba..83a88a4635db 100644 --- a/net/smc/smc_core.h +++ b/net/smc/smc_core.h @@ -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; }; /* For now we just allow one parallel link per link group. The SMC protocol From patchwork Mon Nov 2 19:33:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karsten Graul X-Patchwork-Id: 315787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A96F4C2D0A3 for ; Mon, 2 Nov 2020 19:34:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CBC32225E for ; Mon, 2 Nov 2020 19:34:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Qtp+5v5h" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726837AbgKBTei (ORCPT ); Mon, 2 Nov 2020 14:34:38 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:9704 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725809AbgKBTed (ORCPT ); Mon, 2 Nov 2020 14:34:33 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JWhqK029563; Mon, 2 Nov 2020 14:34:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=ag+R+vMP/I79qQbBPxbwIUcND10y7U6pOMvU9TEVx9s=; b=Qtp+5v5hxcWLYMpDZ6mBiCRrUvwYvMqd8hF4URoV81FIsSxX1dc2vqfYhm4VXKmVjmbW ktZf3KIzgAkl1bANd5Vzx+2NLp4/cQ6OZHtPMqua0HJ8Ds7GRWAqhV83MUZDfNJ2Tdrj qboX3EmjLkuUT8tj4gKhNoWAtQTITzWv+WAdFJAkjwMaBrUQtZdJzyO9+EogyIL47p6R JBYLUGrpdYneVXLm+rI/Co/if/+Loy28XXeFVfvA5fZ3D+c+s7iWUizvVgLVFWZ8J/jP 0kMYI1HadyRIus6Wrv1Vx6qcITkf07CelP+9jwAaqAd6UHYKIQLHOzIaj3sgW2utg5yy bg== Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 34jfg7hva7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 14:34:32 -0500 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JXlNc031195; Mon, 2 Nov 2020 19:34:29 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06fra.de.ibm.com with ESMTP id 34h01kh82c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 19:34:29 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0A2JYQU99372322 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Nov 2020 19:34:26 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A91984C040; Mon, 2 Nov 2020 19:34:26 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 77DA74C050; Mon, 2 Nov 2020 19:34:26 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 2 Nov 2020 19:34:26 +0000 (GMT) From: Karsten Graul To: davem@davemloft.net Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org, hca@linux.ibm.com, raspl@linux.ibm.com Subject: [PATCH net-next 04/15] net/smc: Add link counters for IB device ports Date: Mon, 2 Nov 2020 20:33:58 +0100 Message-Id: <20201102193409.70901-5-kgraul@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201102193409.70901-1-kgraul@linux.ibm.com> References: <20201102193409.70901-1-kgraul@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-02_13:2020-11-02,2020-11-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 spamscore=0 adultscore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 suspectscore=3 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011020149 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Guvenc Gulce 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. Signed-off-by: Guvenc Gulce Signed-off-by: Karsten Graul --- net/smc/smc_core.c | 3 +++ net/smc/smc_ib.h | 1 + 2 files changed, 4 insertions(+) diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index 6e2077161267..da94725deb09 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -316,6 +316,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; + atomic_inc(&ini->ib_dev->lnk_cnt_by_port[ini->ib_port - 1]); 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); @@ -360,6 +361,7 @@ int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk, smc_llc_link_clear(lnk, false); out: put_device(&ini->ib_dev->ibdev->dev); + atomic_dec(&ini->ib_dev->lnk_cnt_by_port[ini->ib_port - 1]); memset(lnk, 0, sizeof(struct smc_link)); lnk->state = SMC_LNK_UNUSED; if (!atomic_dec_return(&ini->ib_dev->lnk_cnt)) @@ -750,6 +752,7 @@ void smcr_link_clear(struct smc_link *lnk, bool log) smc_ib_dealloc_protection_domain(lnk); smc_wr_free_link_mem(lnk); put_device(&lnk->smcibdev->ibdev->dev); + atomic_dec(&lnk->smcibdev->lnk_cnt_by_port[lnk->ibport - 1]); smcibdev = lnk->smcibdev; memset(lnk, 0, sizeof(struct smc_link)); lnk->state = SMC_LNK_UNUSED; diff --git a/net/smc/smc_ib.h b/net/smc/smc_ib.h index 2ce481187dd0..3e6bfeddd53b 100644 --- a/net/smc/smc_ib.h +++ b/net/smc/smc_ib.h @@ -53,6 +53,7 @@ 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];/*#lnk per port*/ }; struct smc_buf_desc; From patchwork Mon Nov 2 19:33:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karsten Graul X-Patchwork-Id: 315786 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F23FC2D0A3 for ; Mon, 2 Nov 2020 19:35:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D51C222268 for ; Mon, 2 Nov 2020 19:35:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="mexleEgD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726776AbgKBTeg (ORCPT ); Mon, 2 Nov 2020 14:34:36 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:62002 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726734AbgKBTed (ORCPT ); Mon, 2 Nov 2020 14:34:33 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JXQOh081724; Mon, 2 Nov 2020 14:34:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=+TPR0daW9e7jOfEBRkwgpCs1I8h8v7CyKwoTrDgYITQ=; b=mexleEgDrrZPmraXEBLco/N20TrR65ii6nd7B9Ysxy/017D0BwLwgjQ4Ff2Kddd82J9K gPzphTWyTk8uz1XpqFHUIEIOnK6S+Rb5visUHpDdPecLcP/nwJfmdU6ga548KPo6YNOT On20jRGJb09i77cQVjLx2fm0EHwAsMR82te8jM/c7Bh6O5xi6e6wngFAuyT6y8ACIR6+ KhevqTwh3VCravLhli9VZD9Xg86vxPKmwdW6D1ziNsfjjkQRamKvnoHtXUinA6+8xcWO NVMd04eSlJQJ0Yg62nuX8EQdK1QWF04J892Trhju8XtC9lOCurE94ltKwQZF3oJ/0i/e rQ== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 34jmdtqw9s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 14:34:31 -0500 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JX8h9027864; Mon, 2 Nov 2020 19:34:29 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 34h0fcte9j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 19:34:29 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0A2JYRG47602690 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Nov 2020 19:34:27 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E61A34C04A; Mon, 2 Nov 2020 19:34:26 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B46094C044; Mon, 2 Nov 2020 19:34:26 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 2 Nov 2020 19:34:26 +0000 (GMT) From: Karsten Graul To: davem@davemloft.net Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org, hca@linux.ibm.com, raspl@linux.ibm.com Subject: [PATCH net-next 05/15] net/smc: Add diagnostic information to smc ib-device Date: Mon, 2 Nov 2020 20:33:59 +0100 Message-Id: <20201102193409.70901-6-kgraul@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201102193409.70901-1-kgraul@linux.ibm.com> References: <20201102193409.70901-1-kgraul@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-02_13:2020-11-02,2020-11-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 suspectscore=1 bulkscore=0 spamscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011020149 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Guvenc Gulce During smc ib-device creation, add network device name to smc ib-device structure. Register for netdevice name changes and update ib-device accordingly. This is needed for diagnostic purposes. Signed-off-by: Guvenc Gulce Signed-off-by: Karsten Graul --- net/smc/smc_ib.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ net/smc/smc_ib.h | 2 ++ net/smc/smc_pnet.c | 3 +++ 3 files changed, 52 insertions(+) diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c index 1c314dbdc7fa..c4a04e868bf0 100644 --- a/net/smc/smc_ib.c +++ b/net/smc/smc_ib.c @@ -557,6 +557,52 @@ static void smc_ib_cleanup_per_ibdev(struct smc_ib_device *smcibdev) static struct ib_client smc_ib_client; +static void smc_copy_netdev_name(struct smc_ib_device *smcibdev, int port) +{ + struct ib_device *ibdev = smcibdev->ibdev; + struct net_device *ndev; + + if (ibdev->ops.get_netdev) { + ndev = ibdev->ops.get_netdev(ibdev, port + 1); + if (ndev) { + snprintf((char *)&smcibdev->netdev[port], + sizeof(smcibdev->netdev[port]), + "%s", ndev->name); + dev_put(ndev); + } + } +} + +void smc_ib_ndev_name_change(struct net_device *ndev) +{ + 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) { + lndev = libdev->ops.get_netdev(libdev, i + 1); + if (lndev) + dev_put(lndev); + if (lndev == ndev) { + snprintf((char *)&smcibdev->netdev[i], + sizeof(smcibdev->netdev[i]), + "%s", ndev->name); + } + } + } + } + mutex_unlock(&smc_ib_devices.mutex); +} + /* callback function for ib_register_client() */ static int smc_ib_add_dev(struct ib_device *ibdev) { @@ -596,6 +642,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_name(smcibdev, i); pr_warn_ratelimited("smc: ib device %s port %d has pnetid " "%.16s%s\n", smcibdev->ibdev->name, i + 1, diff --git a/net/smc/smc_ib.h b/net/smc/smc_ib.h index 3e6bfeddd53b..b0868146b46b 100644 --- a/net/smc/smc_ib.h +++ b/net/smc/smc_ib.h @@ -54,11 +54,13 @@ struct smc_ib_device { /* ib-device infos for smc */ 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];/*#lnk per port*/ + u8 netdev[SMC_MAX_PORTS][IFNAMSIZ];/* ndev names */ }; struct smc_buf_desc; struct smc_link; +void smc_ib_ndev_name_change(struct net_device *ndev); 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); diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c index f3c18b991d35..b0f40d73afd6 100644 --- a/net/smc/smc_pnet.c +++ b/net/smc/smc_pnet.c @@ -828,6 +828,9 @@ static int smc_pnet_netdev_event(struct notifier_block *this, case NETDEV_UNREGISTER: smc_pnet_remove_by_ndev(event_dev); return NOTIFY_OK; + case NETDEV_CHANGENAME: + smc_ib_ndev_name_change(event_dev); + return NOTIFY_OK; case NETDEV_REGISTER: smc_pnet_add_by_ndev(event_dev); return NOTIFY_OK; From patchwork Mon Nov 2 19:34:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karsten Graul X-Patchwork-Id: 315790 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5491C388F9 for ; Mon, 2 Nov 2020 19:34:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87E8222268 for ; Mon, 2 Nov 2020 19:34:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="HqJIU4ce" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726878AbgKBTek (ORCPT ); Mon, 2 Nov 2020 14:34:40 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:61590 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726742AbgKBTef (ORCPT ); Mon, 2 Nov 2020 14:34:35 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JXDdo145354; Mon, 2 Nov 2020 14:34:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=4Lkl76hOBrZ18uzG6AFvLrEACEmcfsYiRgNsqLoBsHs=; b=HqJIU4ceJ0qBymQyyk746+t1UHpPh0dHodPOLG8LaAWqXfjKMroKvK8YWKTt3eGgFDKb DojYNJlsyNnU8S5kfdpQzpu7/dV41hocZmz6vgFgD5KSYOyw2dmF8K5Qx6OuQy2GOVNj SrvW9+R37cmKbe30Kg+QwHvvkzHW53JHQ/FgsKDuLPsmqrf4Dt6ugh1XZNLA9wMPJ52E +TUPEWmj/RK4rwge9c+OMdT/jz6AN2d0VmC3Sbq4UI4OMajdd3V7Lw+XviXRbIQ9IlPU A5BysyVRjazMnTc/bIVjoPp8itTgp4EcvksEbzqPFyExeuDHOTO7WcVK4LnT6TV9Alxu 2A== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 34jphb350x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 14:34:34 -0500 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JWKMm028437; Mon, 2 Nov 2020 19:34:32 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 34h01uac9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 19:34:31 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0A2JYTuu6226674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Nov 2020 19:34:29 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF3964C04E; Mon, 2 Nov 2020 19:34:28 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD70F4C046; Mon, 2 Nov 2020 19:34:28 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 2 Nov 2020 19:34:28 +0000 (GMT) From: Karsten Graul To: davem@davemloft.net Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org, hca@linux.ibm.com, raspl@linux.ibm.com Subject: [PATCH net-next 13/15] net/smc: Add support for obtaining SMCR device list Date: Mon, 2 Nov 2020 20:34:07 +0100 Message-Id: <20201102193409.70901-14-kgraul@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201102193409.70901-1-kgraul@linux.ibm.com> References: <20201102193409.70901-1-kgraul@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-02_13:2020-11-02,2020-11-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 bulkscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 suspectscore=1 malwarescore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011020149 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Guvenc Gulce Deliver SMCR device information via netlink based diagnostic interface. Signed-off-by: Guvenc Gulce Signed-off-by: Karsten Graul --- include/uapi/linux/smc_diag.h | 6 ++ net/smc/smc_diag.c | 133 ++++++++++++++++++++++++++++++++++ net/smc/smc_ib.c | 2 + 3 files changed, 141 insertions(+) diff --git a/include/uapi/linux/smc_diag.h b/include/uapi/linux/smc_diag.h index b01133eb998c..84c8dfc76080 100644 --- a/include/uapi/linux/smc_diag.h +++ b/include/uapi/linux/smc_diag.h @@ -87,6 +87,7 @@ enum { /* SMC_DIAG_GET_DEV_INFO command extensions */ enum { SMC_DIAG_DEV_INFO_SMCD = 1, + SMC_DIAG_DEV_INFO_SMCR, }; #define SMC_DIAG_MAX (__SMC_DIAG_MAX - 1) @@ -181,6 +182,11 @@ struct smc_diag_dev_info { __u16 pci_vendor; /* PCI Vendor */ __u16 pci_device; /* PCI Device Vendor ID */ __u8 pci_id[SMC_PCI_ID_STR_LEN]; /* PCI ID */ + __u8 dev_name[IB_DEVICE_NAME_MAX]; /* IB Device name */ + __u8 netdev[SMC_MAX_PORTS][IFNAMSIZ]; /* Netdev name(s) */ + __u8 port_state[SMC_MAX_PORTS]; /* IB Port State */ + __u8 port_valid[SMC_MAX_PORTS]; /* Is IB Port valid */ + __u32 lnk_cnt_by_port[SMC_MAX_PORTS]; /* # lnks per port */ }; struct smc_diag_lgr { diff --git a/net/smc/smc_diag.c b/net/smc/smc_diag.c index 252aae0b11d9..58bfbe0bef4d 100644 --- a/net/smc/smc_diag.c +++ b/net/smc/smc_diag.c @@ -365,6 +365,34 @@ static int smc_diag_handle_lgr(struct smc_link_group *lgr, return rc; } +static bool smcr_diag_is_dev_critical(struct smc_lgr_list *smc_lgr, + struct smc_ib_device *smcibdev) +{ + struct smc_link_group *lgr; + bool rc = false; + int i; + + spin_lock_bh(&smc_lgr->lock); + list_for_each_entry(lgr, &smc_lgr->list, list) { + if (lgr->is_smcd) + continue; + for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++) { + if (lgr->lnk[i].state == SMC_LNK_UNUSED) + continue; + if (lgr->lnk[i].smcibdev == smcibdev) { + if (lgr->type == SMC_LGR_SINGLE || + lgr->type == SMC_LGR_ASYMMETRIC_LOCAL) { + rc = true; + goto out; + } + } + } + } +out: + spin_unlock_bh(&smc_lgr->lock); + return rc; +} + static int smc_diag_fill_lgr_list(struct smc_lgr_list *smc_lgr, struct sk_buff *skb, struct netlink_callback *cb, @@ -520,6 +548,108 @@ static int smc_diag_prep_smcd_dev(struct smcd_dev_list *dev_list, return rc; } +static inline void smc_diag_handle_dev_port(struct smc_diag_dev_info *smc_diag_dev, + struct ib_device *ibdev, + struct smc_ib_device *smcibdev, + int port) +{ + unsigned char port_state; + + smc_diag_dev->port_valid[port] = 1; + snprintf((char *)&smc_diag_dev->netdev[port], + sizeof(smc_diag_dev->netdev[port]), + "%s", (char *)&smcibdev->netdev[port]); + snprintf((char *)&smc_diag_dev->pnet_id[port], + sizeof(smc_diag_dev->pnet_id[port]), "%s", + (char *)&smcibdev->pnetid[port]); + smc_diag_dev->pnetid_by_user[port] = smcibdev->pnetid_by_user[port]; + port_state = smc_ib_port_active(smcibdev, port + 1); + smc_diag_dev->port_state[port] = port_state; + smc_diag_dev->lnk_cnt_by_port[port] = + atomic_read(&smcibdev->lnk_cnt_by_port[port]); +} + +static int smc_diag_handle_smcr_dev(struct smc_ib_device *smcibdev, + struct sk_buff *skb, + struct netlink_callback *cb, + struct smc_diag_req_v2 *req) +{ + struct smc_diag_dev_info smc_dev; + struct smc_pci_dev smc_pci_dev; + struct pci_dev *pci_dev; + unsigned char is_crit; + struct nlmsghdr *nlh; + int dummy = 0; + int i, rc = 0; + + nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, MAGIC_SEQ_V2_ACK, + cb->nlh->nlmsg_type, 0, NLM_F_MULTI); + if (!nlh) + return -EMSGSIZE; + + memset(&smc_dev, 0, sizeof(smc_dev)); + memset(&smc_pci_dev, 0, sizeof(smc_pci_dev)); + for (i = 1; i <= SMC_MAX_PORTS; i++) { + if (rdma_is_port_valid(smcibdev->ibdev, i)) { + smc_diag_handle_dev_port(&smc_dev, smcibdev->ibdev, + smcibdev, i - 1); + } + } + pci_dev = to_pci_dev(smcibdev->ibdev->dev.parent); + smc_set_pci_values(pci_dev, &smc_pci_dev); + smc_dev.pci_device = smc_pci_dev.pci_device; + smc_dev.pci_fid = smc_pci_dev.pci_fid; + smc_dev.pci_pchid = smc_pci_dev.pci_pchid; + smc_dev.pci_vendor = smc_pci_dev.pci_vendor; + snprintf(smc_dev.pci_id, sizeof(smc_dev.pci_id), "%s", + smc_pci_dev.pci_id); + snprintf(smc_dev.dev_name, sizeof(smc_dev.dev_name), + "%s", smcibdev->ibdev->name); + is_crit = smcr_diag_is_dev_critical(&smc_lgr_list, smcibdev); + smc_dev.is_critical = is_crit; + + /* Just a command place holder to signal back the command reply type */ + if (nla_put(skb, SMC_DIAG_GET_DEV_INFO, sizeof(dummy), &dummy) < 0) + goto errout; + + if (nla_put(skb, SMC_DIAG_DEV_INFO_SMCR, + sizeof(smc_dev), &smc_dev) < 0) + goto errout; + + nlmsg_end(skb, nlh); + return rc; + +errout: + nlmsg_cancel(skb, nlh); + return -EMSGSIZE; +} + +static int smc_diag_prep_smcr_dev(struct smc_ib_devices *dev_list, + struct sk_buff *skb, + struct netlink_callback *cb, + struct smc_diag_req_v2 *req) +{ + struct smc_diag_dump_ctx *cb_ctx = smc_dump_context(cb); + struct smc_ib_device *smcibdev; + int snum = cb_ctx->pos[0]; + int rc = 0, num = 0; + + mutex_lock(&dev_list->mutex); + list_for_each_entry(smcibdev, &dev_list->list, list) { + if (num < snum) + goto next; + rc = smc_diag_handle_smcr_dev(smcibdev, skb, cb, req); + if (rc < 0) + goto out; +next: + num++; + } +out: + mutex_unlock(&dev_list->mutex); + cb_ctx->pos[0] = num; + return rc; +} + static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb, struct netlink_callback *cb, const struct smc_diag_req *req) @@ -625,6 +755,9 @@ static int smc_diag_dump_ext(struct sk_buff *skb, struct netlink_callback *cb) if ((req->cmd_ext & (1 << (SMC_DIAG_DEV_INFO_SMCD - 1)))) smc_diag_prep_smcd_dev(&smcd_dev_list, skb, cb, req); + if ((req->cmd_ext & (1 << (SMC_DIAG_DEV_INFO_SMCR - 1)))) + smc_diag_prep_smcr_dev(&smc_ib_devices, skb, cb, + req); } return skb->len; diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c index c4a04e868bf0..14688aa74d66 100644 --- a/net/smc/smc_ib.c +++ b/net/smc/smc_ib.c @@ -37,6 +37,7 @@ struct smc_ib_devices smc_ib_devices = { /* smc-registered ib devices */ .mutex = __MUTEX_INITIALIZER(smc_ib_devices.mutex), .list = LIST_HEAD_INIT(smc_ib_devices.list), }; +EXPORT_SYMBOL_GPL(smc_ib_devices); u8 local_systemid[SMC_SYSTEMID_LEN]; /* unique system identifier */ @@ -181,6 +182,7 @@ bool smc_ib_port_active(struct smc_ib_device *smcibdev, u8 ibport) { return smcibdev->pattr[ibport - 1].state == IB_PORT_ACTIVE; } +EXPORT_SYMBOL_GPL(smc_ib_port_active); /* determine the gid for an ib-device port and vlan id */ int smc_ib_determine_gid(struct smc_ib_device *smcibdev, u8 ibport, From patchwork Mon Nov 2 19:34:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karsten Graul X-Patchwork-Id: 315789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAC81C4742C for ; Mon, 2 Nov 2020 19:34:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85DD422280 for ; Mon, 2 Nov 2020 19:34:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="o2jY0iXl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726908AbgKBTen (ORCPT ); Mon, 2 Nov 2020 14:34:43 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:2004 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726755AbgKBTef (ORCPT ); Mon, 2 Nov 2020 14:34:35 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JXQNL081725; Mon, 2 Nov 2020 14:34:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=GXYYG5W/z64twXT5jsWbsX3F6v3+7ExKhA4tiagpNYk=; b=o2jY0iXlHpKe4ac3PzvQhUXVP/KqXBnp87O1T2oL4UzXHHGNd0ublH9GJWzTfLnee5VW 62HJH/qHXO2IuBQJo1JdrpXD7za3TwvPQsVQuyIezyY7/LDG6hBYvW9Q+rxMeDzLZE04 S6uLANxCh8yXGLI61iw41eCvU5Ww4SMXruxlQBk95maABCc4CufeY2QXO/wBsMSQEFpG IGug11FL5aglWSRo6AHfvw5Dl+1EJTMs2UfPK4lxzLy2lklLEaGFr4cFc3fTLdzkn8gU rYm8jDhnIZelNQxLteKoLue5NMHEx2AhqQNLli0CPrAKi/EQdTmhyMgiTX77u57cakV8 9Q== Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 34jmdtqwau-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 14:34:34 -0500 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JXc7s020896; Mon, 2 Nov 2020 19:34:32 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma05fra.de.ibm.com with ESMTP id 34h01qs8cg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 19:34:32 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0A2JYTGC6226676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Nov 2020 19:34:29 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 375064C044; Mon, 2 Nov 2020 19:34:29 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 061AC4C059; Mon, 2 Nov 2020 19:34:29 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 2 Nov 2020 19:34:28 +0000 (GMT) From: Karsten Graul To: davem@davemloft.net Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org, hca@linux.ibm.com, raspl@linux.ibm.com Subject: [PATCH net-next 14/15] net/smc: Refactor smc ism v2 capability handling Date: Mon, 2 Nov 2020 20:34:08 +0100 Message-Id: <20201102193409.70901-15-kgraul@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201102193409.70901-1-kgraul@linux.ibm.com> References: <20201102193409.70901-1-kgraul@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-02_13:2020-11-02,2020-11-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 suspectscore=1 bulkscore=0 spamscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011020149 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Guvenc Gulce Encapsulate the smc ism v2 capability boolean value in a function for better information hiding. Signed-off-by: Guvenc Gulce Signed-off-by: Karsten Graul --- net/smc/af_smc.c | 12 ++++++------ net/smc/smc_ism.c | 9 ++++++++- net/smc/smc_ism.h | 5 ++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index bc3e45289771..850e6df47a59 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -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)) { @@ -1354,7 +1354,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; @@ -1680,7 +1680,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; diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c index 5bb2c7fb4ea8..2a2571637bc6 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -22,7 +22,7 @@ struct smcd_dev_list smcd_dev_list = { }; EXPORT_SYMBOL_GPL(smcd_dev_list); -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) @@ -53,6 +53,13 @@ u16 smc_ism_get_chid(struct smcd_dev *smcd) } EXPORT_SYMBOL_GPL(smc_ism_get_chid); +/* HW supports ISM V2 and thus System EID is defined */ +bool smc_ism_is_v2_capable(void) +{ + return smc_ism_v2_capable; +} +EXPORT_SYMBOL_GPL(smc_ism_is_v2_capable); + /* Set a connection using this DMBE. */ void smc_ism_set_conn(struct smc_connection *conn) { diff --git a/net/smc/smc_ism.h b/net/smc/smc_ism.h index 8048e09ddcf8..481a4b7df30b 100644 --- a/net/smc/smc_ism.h +++ b/net/smc/smc_ism.h @@ -10,6 +10,7 @@ #define SMCD_ISM_H #include +#include #include #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 From patchwork Mon Nov 2 19:34:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karsten Graul X-Patchwork-Id: 315788 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14DC1C388F9 for ; Mon, 2 Nov 2020 19:34:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB73022268 for ; Mon, 2 Nov 2020 19:34:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="tHLR4qMS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbgKBTeq (ORCPT ); Mon, 2 Nov 2020 14:34:46 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:1134 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726754AbgKBTef (ORCPT ); Mon, 2 Nov 2020 14:34:35 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JWCKT097463; Mon, 2 Nov 2020 14:34:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=TtBpSMcEyB0Tm9tJv0b3QBpvAjAt5zAfwu+ZGA/KNF8=; b=tHLR4qMSmvcE7EI6r5a0DUofgzSD/e261EaQS52LUiboxTTf6eSE5S/wg9muCFXfnXnT Ksnr32xiFMLzKvUtKmmxStHI+10GLnksL00XU3Ms17N7zMcXDcwJ8Doy7c3IBkBfb0w8 rEJAc0n42FcGi1BYtlLgCzOoVI4erm2S/I41dZh9u0cUe+gXEafDFtI/T8CW3Y0U56vx xqybmsjUQWD+7i6SOPXX9yP9GuFOBkZfVKGg3XJ7V1tDWmJ3it9nvGRBym8bYO0MerEY CtzSXzZwRyaXC34twlWN/XchOHuK9XEA5s1TvAPiLnRojZNmgnlU8FQsAx4ROgm9GRvo Ag== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 34jqpys684-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 14:34:34 -0500 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0A2JWKQd028431; Mon, 2 Nov 2020 19:34:32 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 34h01uac9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 02 Nov 2020 19:34:32 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0A2JYTt155050640 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Nov 2020 19:34:29 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 74D5B4C044; Mon, 2 Nov 2020 19:34:29 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 432204C046; Mon, 2 Nov 2020 19:34:29 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 2 Nov 2020 19:34:29 +0000 (GMT) From: Karsten Graul To: davem@davemloft.net Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org, hca@linux.ibm.com, raspl@linux.ibm.com Subject: [PATCH net-next 15/15] net/smc: Add support for obtaining system information Date: Mon, 2 Nov 2020 20:34:09 +0100 Message-Id: <20201102193409.70901-16-kgraul@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201102193409.70901-1-kgraul@linux.ibm.com> References: <20201102193409.70901-1-kgraul@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-02_13:2020-11-02,2020-11-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 suspectscore=1 bulkscore=0 priorityscore=1501 clxscore=1015 phishscore=0 malwarescore=0 adultscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011020145 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Guvenc Gulce Add new netlink command to obtain system information of the smc module. Signed-off-by: Guvenc Gulce Signed-off-by: Karsten Graul --- include/uapi/linux/smc.h | 1 + include/uapi/linux/smc_diag.h | 18 ++++++++++ net/smc/smc_clc.c | 6 ++++ net/smc/smc_clc.h | 1 + net/smc/smc_diag.c | 62 +++++++++++++++++++++++++++++++++++ net/smc/smc_ism.c | 1 + 6 files changed, 89 insertions(+) diff --git a/include/uapi/linux/smc.h b/include/uapi/linux/smc.h index 736e8b98c8a5..04385a98037a 100644 --- a/include/uapi/linux/smc.h +++ b/include/uapi/linux/smc.h @@ -38,6 +38,7 @@ enum { /* SMC PNET Table commands */ #define SMC_LGR_ID_SIZE 4 #define SMC_MAX_HOSTNAME_LEN 32 /* Max length of hostname */ #define SMC_MAX_EID_LEN 32 /* Max length of eid */ +#define SMC_MAX_EID 8 /* Max number of eids */ #define SMC_MAX_PORTS 2 /* Max # of ports per ib device */ #define SMC_PCI_ID_STR_LEN 16 /* Max length of pci id string */ #endif /* _UAPI_LINUX_SMC_H */ diff --git a/include/uapi/linux/smc_diag.h b/include/uapi/linux/smc_diag.h index 84c8dfc76080..e1ebeddfb3d7 100644 --- a/include/uapi/linux/smc_diag.h +++ b/include/uapi/linux/smc_diag.h @@ -74,6 +74,7 @@ enum { enum { SMC_DIAG_GET_LGR_INFO = SMC_DIAG_EXTS_PER_CMD, SMC_DIAG_GET_DEV_INFO, + SMC_DIAG_GET_SYS_INFO, __SMC_DIAG_EXT_MAX, }; @@ -90,6 +91,11 @@ enum { SMC_DIAG_DEV_INFO_SMCR, }; +/* SMC_DIAG_GET_SYS_INFO command extensions */ +enum { + SMC_DIAG_SYS_INFO = 1, +}; + #define SMC_DIAG_MAX (__SMC_DIAG_MAX - 1) #define SMC_DIAG_EXT_MAX (__SMC_DIAG_EXT_MAX - 1) @@ -130,6 +136,18 @@ struct smc_diag_v2_lgr_info { __u8 peer_hostname[SMC_MAX_HOSTNAME_LEN]; /* Peer host */ }; + +struct smc_system_info { + __u8 smc_version; /* SMC Version */ + __u8 smc_release; /* SMC Release */ + __u8 ueid_count; /* Number of UEIDs */ + __u8 smc_ism_is_v2; /* Is ISM SMC v2 capable */ + __u32 reserved; /* Reserved for future use */ + __u8 local_hostname[SMC_MAX_HOSTNAME_LEN]; /* Hostnames */ + __u8 seid[SMC_MAX_EID_LEN]; /* System EID */ + __u8 ueid[SMC_MAX_EID][SMC_MAX_EID_LEN]; /* User EIDs */ +}; + /* SMC_DIAG_LINKINFO */ struct smc_diag_linkinfo { diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c index 696d89c2dce4..ca887ee6b249 100644 --- a/net/smc/smc_clc.c +++ b/net/smc/smc_clc.c @@ -772,6 +772,12 @@ 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]; +} +EXPORT_SYMBOL_GPL(smc_clc_get_hostname); + void __init smc_clc_init(void) { struct new_utsname *u; diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h index e7ab05683bc9..9ed9eb3abe46 100644 --- a/net/smc/smc_clc.h +++ b/net/smc/smc_clc.h @@ -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 diff --git a/net/smc/smc_diag.c b/net/smc/smc_diag.c index 58bfbe0bef4d..a69a401329ab 100644 --- a/net/smc/smc_diag.c +++ b/net/smc/smc_diag.c @@ -23,6 +23,7 @@ #include "smc_ib.h" #include "smc_ism.h" #include "smc_core.h" +#include "smc_clc.h" struct smc_diag_dump_ctx { int pos[2]; @@ -650,6 +651,63 @@ static int smc_diag_prep_smcr_dev(struct smc_ib_devices *dev_list, return rc; } +static int smc_diag_prep_sys_info(struct smcd_dev_list *dev_list, + struct sk_buff *skb, + struct netlink_callback *cb, + struct smc_diag_req_v2 *req) +{ + struct smc_diag_dump_ctx *cb_ctx = smc_dump_context(cb); + struct smc_system_info smc_sys_info; + int dummy = 0, rc = 0, num = 0; + struct smcd_dev *smcd_dev; + int snum = cb_ctx->pos[0]; + struct nlmsghdr *nlh; + u8 *seid = NULL; + u8 *host = NULL; + + nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, MAGIC_SEQ_V2_ACK, + cb->nlh->nlmsg_type, 0, NLM_F_MULTI); + if (!nlh) + return -EMSGSIZE; + + if (snum > num) + goto errout; + + memset(&smc_sys_info, 0, sizeof(smc_sys_info)); + smc_sys_info.smc_ism_is_v2 = smc_ism_is_v2_capable(); + smc_sys_info.smc_version = SMC_V2; + smc_sys_info.smc_release = SMC_RELEASE; + smc_clc_get_hostname(&host); + + if (host) + memcpy(smc_sys_info.local_hostname, host, + sizeof(smc_sys_info.local_hostname)); + mutex_lock(&dev_list->mutex); + smcd_dev = list_first_entry_or_null(&dev_list->list, struct smcd_dev, list); + if (smcd_dev) + smc_ism_get_system_eid(smcd_dev, &seid); + mutex_unlock(&dev_list->mutex); + + if (seid && smc_sys_info.smc_ism_is_v2) + memcpy(smc_sys_info.seid, seid, sizeof(smc_sys_info.seid)); + + /* Just a command place holder to signal back the command reply type */ + if (nla_put(skb, SMC_DIAG_GET_SYS_INFO, sizeof(dummy), &dummy) < 0) + goto errout; + + if (nla_put(skb, SMC_DIAG_SYS_INFO, + sizeof(smc_sys_info), &smc_sys_info) < 0) + goto errout; + nlmsg_end(skb, nlh); + num++; + cb_ctx->pos[0] = num; + return rc; + +errout: + nlmsg_cancel(skb, nlh); + return -EMSGSIZE; +} + static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb, struct netlink_callback *cb, const struct smc_diag_req *req) @@ -758,6 +816,10 @@ static int smc_diag_dump_ext(struct sk_buff *skb, struct netlink_callback *cb) if ((req->cmd_ext & (1 << (SMC_DIAG_DEV_INFO_SMCR - 1)))) smc_diag_prep_smcr_dev(&smc_ib_devices, skb, cb, req); + } else if (req->cmd == SMC_DIAG_GET_SYS_INFO) { + if ((req->cmd_ext & (1 << (SMC_DIAG_SYS_INFO - 1)))) + smc_diag_prep_sys_info(&smcd_dev_list, skb, cb, + req); } return skb->len; diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c index 2a2571637bc6..c3bcca3ca1aa 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -46,6 +46,7 @@ void smc_ism_get_system_eid(struct smcd_dev *smcd, u8 **eid) { smcd->ops->get_system_eid(smcd, eid); } +EXPORT_SYMBOL_GPL(smc_ism_get_system_eid); u16 smc_ism_get_chid(struct smcd_dev *smcd) {