From: Parav Pandit <parav@xxxxxxxxxxxx> Move code to reusable helper functions to reuse in subsequent patch in handling net namespace change netlink command for an rdma device. Signed-off-by: Parav Pandit <parav@xxxxxxxxxxxx> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- drivers/infiniband/core/cache.c | 25 +++++++++++++++---------- drivers/infiniband/core/core_priv.h | 3 +++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index 7b04590f307f..ae67396af92f 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -896,7 +896,7 @@ static int _gid_table_setup_one(struct ib_device *ib_dev) return -ENOMEM; } -static void gid_table_cleanup_one(struct ib_device *ib_dev) +void ib_gid_table_cleanup_one(struct ib_device *ib_dev) { struct ib_gid_table *table; u8 port; @@ -906,6 +906,10 @@ static void gid_table_cleanup_one(struct ib_device *ib_dev) cleanup_gid_table_port(ib_dev, port + rdma_start_port(ib_dev), table); } + /* + * Flush the wq for any pending GID delete work. + */ + flush_workqueue(ib_wq); } static int gid_table_setup_one(struct ib_device *ib_dev) @@ -1426,9 +1430,16 @@ static void ib_cache_event(struct ib_event_handler *handler, } } -int ib_cache_setup_one(struct ib_device *device) +void ib_device_cache_update(struct ib_device *device) { int p; + + for (p = rdma_start_port(device); p <= rdma_end_port(device); p++) + ib_cache_update(device, p, true); +} + +int ib_cache_setup_one(struct ib_device *device) +{ int err; rwlock_init(&device->cache.lock); @@ -1447,8 +1458,7 @@ int ib_cache_setup_one(struct ib_device *device) return err; } - for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p) - ib_cache_update(device, p + rdma_start_port(device), true); + ib_device_cache_update(device); INIT_IB_EVENT_HANDLER(&device->cache.event_handler, device, ib_cache_event); @@ -1484,10 +1494,5 @@ void ib_cache_cleanup_one(struct ib_device *device) */ ib_unregister_event_handler(&device->cache.event_handler); flush_workqueue(ib_wq); - gid_table_cleanup_one(device); - - /* - * Flush the wq second time for any pending GID delete work. - */ - flush_workqueue(ib_wq); + ib_gid_table_cleanup_one(device); } diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h index f2da31de62c9..7dc6f814f387 100644 --- a/drivers/infiniband/core/core_priv.h +++ b/drivers/infiniband/core/core_priv.h @@ -357,4 +357,7 @@ int ib_setup_port_attrs(struct ib_core_device *coredev, int (*port_callback)(struct ib_device *, u8, struct kobject *), bool alloc_hw_stats); + +void ib_device_cache_update(struct ib_device *device); +void ib_gid_table_cleanup_one(struct ib_device *device); #endif /* _CORE_PRIV_H */ -- 2.19.1