From patchwork Fri Feb 10 11:19:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 9566579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D9E3A601EA for ; Fri, 10 Feb 2017 11:23:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6E022853D for ; Fri, 10 Feb 2017 11:23:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB66E28559; Fri, 10 Feb 2017 11:23:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E1982853D for ; Fri, 10 Feb 2017 11:23:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751445AbdBJLXS (ORCPT ); Fri, 10 Feb 2017 06:23:18 -0500 Received: from mail-qk0-f180.google.com ([209.85.220.180]:32888 "EHLO mail-qk0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752176AbdBJLXE (ORCPT ); Fri, 10 Feb 2017 06:23:04 -0500 Received: by mail-qk0-f180.google.com with SMTP id s140so35473255qke.0 for ; Fri, 10 Feb 2017 03:21:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MUeyStfdgskYbT2KXuaZ0/mMGcjPs+OJf7FGZWdx1NA=; b=AxmxvP9CEZ4UGHNJgpP27saoel/hbS3lliuvJp1+frB7Nx38EiDTUU0dN9BPqVNFj7 kbSRKiomZ4FGyYrkXkPOEzhbO2NwDS68CkH2G1UswcztfH3GKx2GlOdUEduX3Xzu6Q11 Pi7gHBPa/TBat9hS4ASj2OpMIY6LXm3y8NlSc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MUeyStfdgskYbT2KXuaZ0/mMGcjPs+OJf7FGZWdx1NA=; b=hG9lOHdjKWMFR6Ylv7Vco0pkOPKv+kiFUbXVi7bjwyII8TyN8+PX1qw806WwxaLp14 aquARioaHiR0TfABGJ6g9MPAMS6fx3eaSadg21Qjry7iDtEF2Six/4hoUf+6QqGsVfeO +jpyPh0JIHT9aKWgA0bXm7IOAFRNO3/ByVPExKaqhNqyFUjvEj+5x4EdV+W6RQlO4CjK aBfLtOqQpImJbKebJWj6U8e2Wy7er7NIU6vfbx+ZQ8Bfh/GY5llAsaOEr2dqs8p7b0dm mALrnYId40n8zJZoihEnG3+l5hSij3Ldd/i/1u08xvj3C47RkFZLuSaJF7Kk2hCzQ73k 5uWg== X-Gm-Message-State: AMke39ms6/AzFlXPjNraWl41vOlkXIBnimStOT/Aktl58gIP/00BDAO0yiqE0XDp2zwTtGNA X-Received: by 10.55.181.6 with SMTP id e6mr7333232qkf.298.1486725676737; Fri, 10 Feb 2017 03:21:16 -0800 (PST) Received: from dhcp-10-192-206-197.iig.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id z23sm1211412qkb.30.2017.02.10.03.21.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Feb 2017 03:21:16 -0800 (PST) From: Selvin Xavier To: dledford@redhat.com, linux-rdma@vger.kernel.org Cc: netdev@vger.kernel.org, Selvin Xavier , Eddie Wai , Devesh Sharma , Somnath Kotur , Sriharsha Basavapatna Subject: [PATCH V5 for-next 17/21] RDMA/bnxt_re: Handling dispatching of events to IB stack Date: Fri, 10 Feb 2017 03:19:49 -0800 Message-Id: <1486725593-9872-18-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1486725593-9872-1-git-send-email-selvin.xavier@broadcom.com> References: <1486725593-9872-1-git-send-email-selvin.xavier@broadcom.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch implements events dispatching to the IB stack based on NETDEV events received. v2: Removed cleanup of the resources during driver unload since we are calling unregister_netdevice_notifier first in the exit. v3: Fixes cocci warnings and some sparse warnings v5: Removes qp_wait parameter from bnxt_re_dev_stop() as it was never used Signed-off-by: Eddie Wai Signed-off-by: Devesh Sharma Signed-off-by: Somnath Kotur Signed-off-by: Sriharsha Basavapatna Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/main.c | 59 ++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c index 95dbbbe..c84691a 100644 --- a/drivers/infiniband/hw/bnxt_re/main.c +++ b/drivers/infiniband/hw/bnxt_re/main.c @@ -712,6 +712,51 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev) return rc; } +static void bnxt_re_dispatch_event(struct ib_device *ibdev, struct ib_qp *qp, + u8 port_num, enum ib_event_type event) +{ + struct ib_event ib_event; + + ib_event.device = ibdev; + if (qp) + ib_event.element.qp = qp; + else + ib_event.element.port_num = port_num; + ib_event.event = event; + ib_dispatch_event(&ib_event); +} + +static bool bnxt_re_is_qp1_or_shadow_qp(struct bnxt_re_dev *rdev, + struct bnxt_re_qp *qp) +{ + return (qp->ib_qp.qp_type == IB_QPT_GSI) || (qp == rdev->qp1_sqp); +} + +static void bnxt_re_dev_stop(struct bnxt_re_dev *rdev) +{ + int mask = IB_QP_STATE; + struct ib_qp_attr qp_attr; + struct bnxt_re_qp *qp; + + qp_attr.qp_state = IB_QPS_ERR; + mutex_lock(&rdev->qp_lock); + list_for_each_entry(qp, &rdev->qp_list, list) { + /* Modify the state of all QPs except QP1/Shadow QP */ + if (!bnxt_re_is_qp1_or_shadow_qp(rdev, qp)) { + if (qp->qplib_qp.state != + CMDQ_MODIFY_QP_NEW_STATE_RESET && + qp->qplib_qp.state != + CMDQ_MODIFY_QP_NEW_STATE_ERR) { + bnxt_re_dispatch_event(&rdev->ibdev, &qp->ib_qp, + 1, IB_EVENT_QP_FATAL); + bnxt_re_modify_qp(&qp->ib_qp, &qp_attr, mask, + NULL); + } + } + } + mutex_unlock(&rdev->qp_lock); +} + static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev, bool lock_wait) { int i, rc; @@ -871,6 +916,9 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev) } } set_bit(BNXT_RE_FLAG_IBDEV_REGISTERED, &rdev->flags); + bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1, IB_EVENT_PORT_ACTIVE); + bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1, IB_EVENT_GID_CHANGE); + return 0; free_sctx: bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id, true); @@ -950,8 +998,19 @@ static void bnxt_re_task(struct work_struct *work) "Failed to register with IB: %#x", rc); break; case NETDEV_UP: + bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1, + IB_EVENT_PORT_ACTIVE); + break; case NETDEV_DOWN: + bnxt_re_dev_stop(rdev); + break; case NETDEV_CHANGE: + if (!netif_carrier_ok(rdev->netdev)) + bnxt_re_dev_stop(rdev); + else if (netif_carrier_ok(rdev->netdev)) + bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1, + IB_EVENT_PORT_ACTIVE); + break; default: break; }