From patchwork Tue Feb 4 08:24:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weihang Li X-Patchwork-Id: 11364173 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6BD414E3 for ; Tue, 4 Feb 2020 08:24:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8FBAD217BA for ; Tue, 4 Feb 2020 08:24:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727197AbgBDIYr (ORCPT ); Tue, 4 Feb 2020 03:24:47 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:10150 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727097AbgBDIYq (ORCPT ); Tue, 4 Feb 2020 03:24:46 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 98451599706DB2841E24; Tue, 4 Feb 2020 16:24:39 +0800 (CST) Received: from SZA160416817.china.huawei.com (10.46.14.205) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Tue, 4 Feb 2020 16:24:30 +0800 From: Weihang Li To: , CC: , , Subject: [PATCH RFC v2 for-next 1/7] RDMA/core: add inactive attribute of ib_port_cache Date: Tue, 4 Feb 2020 16:24:02 +0800 Message-ID: <20200204082408.18728-2-liweihang@huawei.com> X-Mailer: git-send-email 2.10.0.windows.1 In-Reply-To: <20200204082408.18728-1-liweihang@huawei.com> References: <20200204082408.18728-1-liweihang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.46.14.205] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Lang Cheng Add attribute inactive to mark bonding backup port. Signed-off-by: Lang Cheng --- drivers/infiniband/core/cache.c | 16 +++++++++++++++- include/rdma/ib_cache.h | 10 ++++++++++ include/rdma/ib_verbs.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index d535995..7a7ef0e 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -1175,6 +1175,19 @@ int ib_get_cached_port_state(struct ib_device *device, } EXPORT_SYMBOL(ib_get_cached_port_state); +u8 ib_get_cached_port_inactive_status(struct ib_device *device, u8 port_num) +{ + unsigned long flags; + u8 inactive; + + read_lock_irqsave(&device->cache.lock, flags); + inactive = device->port_data[port_num].cache.inactive; + read_unlock_irqrestore(&device->cache.lock, flags); + + return inactive; +} +EXPORT_SYMBOL(ib_get_cached_port_inactive_status); + /** * rdma_get_gid_attr - Returns GID attributes for a port of a device * at a requested gid_index, if a valid GID entry exists. @@ -1393,7 +1406,7 @@ static void ib_cache_update(struct ib_device *device, if (!rdma_is_port_valid(device, port)) return; - tprops = kmalloc(sizeof *tprops, GFP_KERNEL); + tprops = kzalloc(sizeof *tprops, GFP_KERNEL); if (!tprops) return; @@ -1435,6 +1448,7 @@ static void ib_cache_update(struct ib_device *device, device->port_data[port].cache.pkey = pkey_cache; device->port_data[port].cache.lmc = tprops->lmc; device->port_data[port].cache.port_state = tprops->state; + device->port_data[port].cache.inactive = tprops->inactive; device->port_data[port].cache.subnet_prefix = tprops->subnet_prefix; write_unlock_irq(&device->cache.lock); diff --git a/include/rdma/ib_cache.h b/include/rdma/ib_cache.h index 870b5e6..63b2dd6 100644 --- a/include/rdma/ib_cache.h +++ b/include/rdma/ib_cache.h @@ -131,6 +131,16 @@ int ib_get_cached_port_state(struct ib_device *device, u8 port_num, enum ib_port_state *port_active); +/** + * ib_get_cached_port_inactive_status - Returns a cached port inactive status + * @device: The device to query. + * @port_num: The port number of the device to query. + * + * ib_get_cached_port_inactive_status() fetches the specified event inactive + * status stored in the local software cache. + */ +u8 ib_get_cached_port_inactive_status(struct ib_device *device, u8 port_num); + bool rdma_is_zero_gid(const union ib_gid *gid); const struct ib_gid_attr *rdma_get_gid_attr(struct ib_device *device, u8 port_num, int index); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 5608e14..e17d846 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -665,6 +665,7 @@ struct ib_port_attr { u8 active_speed; u8 phys_state; u16 port_cap_flags2; + u8 inactive; }; enum ib_device_modify_flags { @@ -2145,6 +2146,7 @@ struct ib_port_cache { struct ib_gid_table *gid; u8 lmc; enum ib_port_state port_state; + u8 inactive; }; struct ib_cache { From patchwork Tue Feb 4 08:24:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weihang Li X-Patchwork-Id: 11364167 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73F3E14B4 for ; Tue, 4 Feb 2020 08:24:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5C58121775 for ; Tue, 4 Feb 2020 08:24:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727185AbgBDIYm (ORCPT ); Tue, 4 Feb 2020 03:24:42 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:10149 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726763AbgBDIYm (ORCPT ); Tue, 4 Feb 2020 03:24:42 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A012D67CE558807F94B7; Tue, 4 Feb 2020 16:24:39 +0800 (CST) Received: from SZA160416817.china.huawei.com (10.46.14.205) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Tue, 4 Feb 2020 16:24:31 +0800 From: Weihang Li To: , CC: , , Subject: [PATCH RFC v2 for-next 2/7] RDMA/mlx5: remove deliver net device event Date: Tue, 4 Feb 2020 16:24:03 +0800 Message-ID: <20200204082408.18728-3-liweihang@huawei.com> X-Mailer: git-send-email 2.10.0.windows.1 In-Reply-To: <20200204082408.18728-1-liweihang@huawei.com> References: <20200204082408.18728-1-liweihang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.46.14.205] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Lang Cheng The code that handles the link event of the net device has been moved into the core, and the related processing should been removed from the provider driver. Signed-off-by: Lang Cheng --- drivers/infiniband/hw/mlx5/main.c | 95 ++++----------------------------------- 1 file changed, 9 insertions(+), 86 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 997cbfe..f202cbc 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -144,48 +144,6 @@ mlx5_ib_port_link_layer(struct ib_device *device, u8 port_num) return mlx5_port_type_cap_to_rdma_ll(port_type_cap); } -static int get_port_state(struct ib_device *ibdev, - u8 port_num, - enum ib_port_state *state) -{ - struct ib_port_attr attr; - int ret; - - memset(&attr, 0, sizeof(attr)); - ret = ibdev->ops.query_port(ibdev, port_num, &attr); - if (!ret) - *state = attr.state; - return ret; -} - -static struct mlx5_roce *mlx5_get_rep_roce(struct mlx5_ib_dev *dev, - struct net_device *ndev, - u8 *port_num) -{ - struct mlx5_eswitch *esw = dev->mdev->priv.eswitch; - struct net_device *rep_ndev; - struct mlx5_ib_port *port; - int i; - - for (i = 0; i < dev->num_ports; i++) { - port = &dev->port[i]; - if (!port->rep) - continue; - - read_lock(&port->roce.netdev_lock); - rep_ndev = mlx5_ib_get_rep_netdev(esw, - port->rep->vport); - if (rep_ndev == ndev) { - read_unlock(&port->roce.netdev_lock); - *port_num = i + 1; - return &port->roce; - } - read_unlock(&port->roce.netdev_lock); - } - - return NULL; -} - static int mlx5_netdev_event(struct notifier_block *this, unsigned long event, void *ptr) { @@ -219,52 +177,10 @@ static int mlx5_netdev_event(struct notifier_block *this, write_unlock(&roce->netdev_lock); break; - case NETDEV_CHANGE: - case NETDEV_UP: - case NETDEV_DOWN: { - struct net_device *lag_ndev = mlx5_lag_get_roce_netdev(mdev); - struct net_device *upper = NULL; - - if (lag_ndev) { - upper = netdev_master_upper_dev_get(lag_ndev); - dev_put(lag_ndev); - } - - if (ibdev->is_rep) - roce = mlx5_get_rep_roce(ibdev, ndev, &port_num); - if (!roce) - return NOTIFY_DONE; - if ((upper == ndev || (!upper && ndev == roce->netdev)) - && ibdev->ib_active) { - struct ib_event ibev = { }; - enum ib_port_state port_state; - - if (get_port_state(&ibdev->ib_dev, port_num, - &port_state)) - goto done; - - if (roce->last_port_state == port_state) - goto done; - - roce->last_port_state = port_state; - ibev.device = &ibdev->ib_dev; - if (port_state == IB_PORT_DOWN) - ibev.event = IB_EVENT_PORT_ERR; - else if (port_state == IB_PORT_ACTIVE) - ibev.event = IB_EVENT_PORT_ACTIVE; - else - goto done; - - ibev.element.port_num = port_num; - ib_dispatch_event(&ibev); - } - break; - } - default: break; } -done: + mlx5_ib_put_native_port_mdev(ibdev, port_num); return NOTIFY_DONE; } @@ -569,7 +485,14 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num, dev_put(ndev); - props->active_mtu = min(props->max_mtu, ndev_ib_mtu); + props->active_mtu = min(props->max_mtu, ndev_ib_mtu); + + if ((dev->lag_active && ndev != mlx5_lag_get_roce_netdev(mdev)) || + (!dev->lag_active && port_num != mdev_port_num)) + props->inactive = 1; + else + props->inactive = 0; + out: if (put_mdev) mlx5_ib_put_native_port_mdev(dev, port_num); From patchwork Tue Feb 4 08:24:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weihang Li X-Patchwork-Id: 11364163 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BAD0513A4 for ; Tue, 4 Feb 2020 08:24:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 973DE2192A for ; Tue, 4 Feb 2020 08:24:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727181AbgBDIYm (ORCPT ); Tue, 4 Feb 2020 03:24:42 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:10147 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727102AbgBDIYl (ORCPT ); Tue, 4 Feb 2020 03:24:41 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 90051ED0EE7CD91FF3CC; Tue, 4 Feb 2020 16:24:39 +0800 (CST) Received: from SZA160416817.china.huawei.com (10.46.14.205) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Tue, 4 Feb 2020 16:24:32 +0800 From: Weihang Li To: , CC: , , Subject: [PATCH RFC v2 for-next 3/7] qede: remove invalid notify operation Date: Tue, 4 Feb 2020 16:24:04 +0800 Message-ID: <20200204082408.18728-4-liweihang@huawei.com> X-Mailer: git-send-email 2.10.0.windows.1 In-Reply-To: <20200204082408.18728-1-liweihang@huawei.com> References: <20200204082408.18728-1-liweihang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.46.14.205] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Lang Cheng The qedr notify() will remove the processing of QEDE_UP and QEDE_DOWN, so qede no more needs to notify rdma of these two events. Signed-off-by: Lang Cheng --- drivers/net/ethernet/qlogic/qede/qede_rdma.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qede/qede_rdma.c b/drivers/net/ethernet/qlogic/qede/qede_rdma.c index ffabc2d..0493279 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_rdma.c +++ b/drivers/net/ethernet/qlogic/qede/qede_rdma.c @@ -145,8 +145,6 @@ void qede_rdma_dev_remove(struct qede_dev *edev, bool recovery) static void _qede_rdma_dev_open(struct qede_dev *edev) { - if (qedr_drv && edev->rdma_info.qedr_dev && qedr_drv->notify) - qedr_drv->notify(edev->rdma_info.qedr_dev, QEDE_UP); } static void qede_rdma_dev_open(struct qede_dev *edev) @@ -161,8 +159,6 @@ static void qede_rdma_dev_open(struct qede_dev *edev) static void _qede_rdma_dev_close(struct qede_dev *edev) { - if (qedr_drv && edev->rdma_info.qedr_dev && qedr_drv->notify) - qedr_drv->notify(edev->rdma_info.qedr_dev, QEDE_DOWN); } static void qede_rdma_dev_close(struct qede_dev *edev) From patchwork Tue Feb 4 08:24:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weihang Li X-Patchwork-Id: 11364165 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B57814E3 for ; Tue, 4 Feb 2020 08:24:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE20F218AC for ; Tue, 4 Feb 2020 08:24:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727102AbgBDIYm (ORCPT ); Tue, 4 Feb 2020 03:24:42 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:10148 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727097AbgBDIYm (ORCPT ); Tue, 4 Feb 2020 03:24:42 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 94585196024AD1E7C24D; Tue, 4 Feb 2020 16:24:39 +0800 (CST) Received: from SZA160416817.china.huawei.com (10.46.14.205) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Tue, 4 Feb 2020 16:24:33 +0800 From: Weihang Li To: , CC: , , Subject: [PATCH RFC v2 for-next 4/7] RDMA/qedr: remove deliver net device event Date: Tue, 4 Feb 2020 16:24:05 +0800 Message-ID: <20200204082408.18728-5-liweihang@huawei.com> X-Mailer: git-send-email 2.10.0.windows.1 In-Reply-To: <20200204082408.18728-1-liweihang@huawei.com> References: <20200204082408.18728-1-liweihang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.46.14.205] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Lang Cheng The code that handles the link event of the net device has been moved into the core, and the related processing should been removed from the provider driver. Signed-off-by: Lang Cheng --- drivers/infiniband/hw/qedr/main.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/infiniband/hw/qedr/main.c b/drivers/infiniband/hw/qedr/main.c index dcdc85a..d85894b 100644 --- a/drivers/infiniband/hw/qedr/main.c +++ b/drivers/infiniband/hw/qedr/main.c @@ -957,24 +957,11 @@ static void qedr_remove(struct qedr_dev *dev) ib_dealloc_device(&dev->ibdev); } -static void qedr_close(struct qedr_dev *dev) -{ - if (test_and_clear_bit(QEDR_ENET_STATE_BIT, &dev->enet_state)) - qedr_ib_dispatch_event(dev, QEDR_PORT, IB_EVENT_PORT_ERR); -} - static void qedr_shutdown(struct qedr_dev *dev) { - qedr_close(dev); qedr_remove(dev); } -static void qedr_open(struct qedr_dev *dev) -{ - if (!test_and_set_bit(QEDR_ENET_STATE_BIT, &dev->enet_state)) - qedr_ib_dispatch_event(dev, QEDR_PORT, IB_EVENT_PORT_ACTIVE); -} - static void qedr_mac_address_change(struct qedr_dev *dev) { union ib_gid *sgid = &dev->sgid_tbl[0]; @@ -1014,12 +1001,6 @@ static void qedr_mac_address_change(struct qedr_dev *dev) static void qedr_notify(struct qedr_dev *dev, enum qede_rdma_event event) { switch (event) { - case QEDE_UP: - qedr_open(dev); - break; - case QEDE_DOWN: - qedr_close(dev); - break; case QEDE_CLOSE: qedr_shutdown(dev); break; From patchwork Tue Feb 4 08:24:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weihang Li X-Patchwork-Id: 11364177 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AAFDD14E3 for ; Tue, 4 Feb 2020 08:24:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A0A921775 for ; Tue, 4 Feb 2020 08:24:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727191AbgBDIYr (ORCPT ); Tue, 4 Feb 2020 03:24:47 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:9688 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727180AbgBDIYr (ORCPT ); Tue, 4 Feb 2020 03:24:47 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A41AABAB6431532EE57A; Tue, 4 Feb 2020 16:24:44 +0800 (CST) Received: from SZA160416817.china.huawei.com (10.46.14.205) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Tue, 4 Feb 2020 16:24:34 +0800 From: Weihang Li To: , CC: , , Subject: [PATCH RFC v2 for-next 5/7] RDMA/vmw_pvrdma: remove deliver net device event Date: Tue, 4 Feb 2020 16:24:06 +0800 Message-ID: <20200204082408.18728-6-liweihang@huawei.com> X-Mailer: git-send-email 2.10.0.windows.1 In-Reply-To: <20200204082408.18728-1-liweihang@huawei.com> References: <20200204082408.18728-1-liweihang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.46.14.205] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Lang Cheng The code that handles the link event of the net device has been moved into the core, and the related processing should been removed from the provider driver. Signed-off-by: Lang Cheng --- drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c index e580ae9..b3877c5 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c @@ -694,9 +694,6 @@ static void pvrdma_netdevice_event_handle(struct pvrdma_dev *dev, switch (event) { case NETDEV_REBOOT: - case NETDEV_DOWN: - pvrdma_dispatch_event(dev, 1, IB_EVENT_PORT_ERR); - break; case NETDEV_UP: pvrdma_write_reg(dev, PVRDMA_REG_CTL, PVRDMA_DEVICE_CTL_UNQUIESCE); @@ -706,8 +703,6 @@ static void pvrdma_netdevice_event_handle(struct pvrdma_dev *dev, if (pvrdma_read_reg(dev, PVRDMA_REG_ERR)) dev_err(&dev->pdev->dev, "failed to activate device during link up\n"); - else - pvrdma_dispatch_event(dev, 1, IB_EVENT_PORT_ACTIVE); break; case NETDEV_UNREGISTER: ib_device_set_netdev(&dev->ib_dev, NULL, 1); From patchwork Tue Feb 4 08:24:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weihang Li X-Patchwork-Id: 11364171 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73CF513A4 for ; Tue, 4 Feb 2020 08:24:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5B09F21744 for ; Tue, 4 Feb 2020 08:24:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727192AbgBDIYq (ORCPT ); Tue, 4 Feb 2020 03:24:46 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:9689 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727180AbgBDIYq (ORCPT ); Tue, 4 Feb 2020 03:24:46 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A8308ACBC8048A1EA7A0; Tue, 4 Feb 2020 16:24:44 +0800 (CST) Received: from SZA160416817.china.huawei.com (10.46.14.205) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Tue, 4 Feb 2020 16:24:35 +0800 From: Weihang Li To: , CC: , , Subject: [PATCH RFC v2 for-next 6/7] RDMA/core: support send port event Date: Tue, 4 Feb 2020 16:24:07 +0800 Message-ID: <20200204082408.18728-7-liweihang@huawei.com> X-Mailer: git-send-email 2.10.0.windows.1 In-Reply-To: <20200204082408.18728-1-liweihang@huawei.com> References: <20200204082408.18728-1-liweihang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.46.14.205] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Lang Cheng For the process of handling the link event of the net device, the driver of each provider is similar, so it can be integrated into the ib_core for unified processing. Signed-off-by: Lang Cheng --- drivers/infiniband/core/device.c | 1 + drivers/infiniband/core/roce_gid_mgmt.c | 45 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 84dd74f..0427a4d 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -2225,6 +2225,7 @@ struct net_device *ib_device_get_netdev(struct ib_device *ib_dev, return res; } +EXPORT_SYMBOL(ib_device_get_netdev); /** * ib_device_get_by_netdev - Find an IB device associated with a netdev diff --git a/drivers/infiniband/core/roce_gid_mgmt.c b/drivers/infiniband/core/roce_gid_mgmt.c index 2860def..4170ba3 100644 --- a/drivers/infiniband/core/roce_gid_mgmt.c +++ b/drivers/infiniband/core/roce_gid_mgmt.c @@ -751,6 +751,12 @@ static int netdevice_event(struct notifier_block *this, unsigned long event, struct net_device *ndev = netdev_notifier_info_to_dev(ptr); struct netdev_event_work_cmd cmds[ROCE_NETDEV_CALLBACK_SZ] = { {NULL} }; + enum ib_port_state last_state; + enum ib_port_state curr_state; + struct ib_device *device; + struct ib_event ibev; + unsigned int port; + if (ndev->type != ARPHRD_ETHER) return NOTIFY_DONE; @@ -762,6 +768,45 @@ static int netdevice_event(struct notifier_block *this, unsigned long event, cmds[2] = add_cmd; break; + case NETDEV_CHANGE: + case NETDEV_DOWN: + device = ib_device_get_by_netdev(ndev, RDMA_DRIVER_UNKNOWN); + if (!device) + break; + + rdma_for_each_port (device, port) { + if (ib_device_get_netdev(device, port) != ndev) + continue; + + if (ib_get_cached_port_inactive_status(device, port)) + break; + + ib_get_cached_port_state(device, port, &last_state); + curr_state = + netif_running(ndev) && netif_carrier_ok(ndev) ? + IB_PORT_ACTIVE : + IB_PORT_DOWN; + + if (last_state == curr_state) + break; + + if (curr_state == IB_PORT_DOWN) + ibev.event = IB_EVENT_PORT_ERR; + else if (curr_state == IB_PORT_ACTIVE) + ibev.event = IB_EVENT_PORT_ACTIVE; + else + break; + + ibev.device = device; + ibev.element.port_num = port; + ib_dispatch_event(&ibev); + ibdev_dbg(ibev.device, "core send %s\n", + ib_event_msg(ibev.event)); + } + + ib_device_put(device); + break; + case NETDEV_UNREGISTER: if (ndev->reg_state < NETREG_UNREGISTERED) cmds[0] = del_cmd; From patchwork Tue Feb 4 08:24:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weihang Li X-Patchwork-Id: 11364175 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E93614B4 for ; Tue, 4 Feb 2020 08:24:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F1CD821744 for ; Tue, 4 Feb 2020 08:24:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727097AbgBDIYr (ORCPT ); Tue, 4 Feb 2020 03:24:47 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:9687 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727183AbgBDIYq (ORCPT ); Tue, 4 Feb 2020 03:24:46 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 9F87ADDC258A6722C909; Tue, 4 Feb 2020 16:24:44 +0800 (CST) Received: from SZA160416817.china.huawei.com (10.46.14.205) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Tue, 4 Feb 2020 16:24:36 +0800 From: Weihang Li To: , CC: , , Subject: [PATCH RFC v2 for-next 7/7] RDMA/core: report link status when register and deregister ib device Date: Tue, 4 Feb 2020 16:24:08 +0800 Message-ID: <20200204082408.18728-8-liweihang@huawei.com> X-Mailer: git-send-email 2.10.0.windows.1 In-Reply-To: <20200204082408.18728-1-liweihang@huawei.com> References: <20200204082408.18728-1-liweihang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.46.14.205] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Lang Cheng Support send link active event for every port of ib device except bonding backup port when ib device is being registered or deregistered. Signed-off-by: Lang Cheng --- drivers/infiniband/core/device.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 0427a4d..6cdfffa 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -1341,6 +1341,7 @@ static int enable_device_and_get(struct ib_device *device) */ int ib_register_device(struct ib_device *device, const char *name) { + unsigned int port; int ret; ret = assign_name(device, name); @@ -1405,6 +1406,28 @@ int ib_register_device(struct ib_device *device, const char *name) } ib_device_put(device); + rdma_for_each_port(device, port) { + struct net_device *netdev = ib_device_get_netdev(device, port); + enum ib_port_state port_state; + struct ib_event event; + + /* not every port has a netdevice */ + if (!netdev || + ib_get_cached_port_inactive_status(device, port)) + continue; + + ib_get_cached_port_state(device, port, &port_state); + if (port_state != IB_PORT_ACTIVE) + continue; + + event.device = device; + event.event = IB_EVENT_PORT_ACTIVE; + event.element.port_num = port; + ib_dispatch_event(&event); + ibdev_dbg(device, "init event %s\n", + ib_event_msg(event.event)); + } + return 0; dev_cleanup: @@ -1469,6 +1492,27 @@ static void __ib_unregister_device(struct ib_device *ib_dev) */ void ib_unregister_device(struct ib_device *ib_dev) { + unsigned int port; + + rdma_for_each_port(ib_dev, port) { + enum ib_port_state port_state; + struct ib_event event; + + if (ib_get_cached_port_inactive_status(ib_dev, port)) + continue; + + ib_get_cached_port_state(ib_dev, port, &port_state); + if (port_state != IB_PORT_ACTIVE) + continue; + + event.device = ib_dev; + event.event = IB_EVENT_PORT_ERR; + event.element.port_num = port; + ib_dispatch_event(&event); + ibdev_dbg(ib_dev, "init event %s\n", + ib_event_msg(event.event)); + } + get_device(&ib_dev->dev); __ib_unregister_device(ib_dev); put_device(&ib_dev->dev);