Cleanup mlx5_ib main file
Subsystems (2)
cover Cleanup mlx5_ib main file
From: Leon Romanovsky <[email protected]>
Over the years, the main.c file grew above all imagination and was >8K LOC of the code. This caused to a huge burden while I started to work on ib_flow allocation patches.
This series implements long standing "internal" wish to move flow logic from the main to separate file.
Based on
https://lore.kernel.org/linux-rdma/[email protected]
Thanks
Leon Romanovsky (6):
RDMA/mlx5: Limit the scope of mlx5_ib_enable_driver function RDMA/mlx5: Separate restrack callbacks initialization from main.c RDMA/mlx5: Separate counters from main.c
RDMA/mlx5: Separate flow steering logic from main.c RDMA/mlx5: Cleanup DEVX initialization flow
RDMA/mlx5: Delete one-time used functions
drivers/infiniband/hw/mlx5/Makefile | 3 +- drivers/infiniband/hw/mlx5/cmd.c | 12 - drivers/infiniband/hw/mlx5/cmd.h | 1 - drivers/infiniband/hw/mlx5/counters.c | 709 +++++ drivers/infiniband/hw/mlx5/counters.h | 17 + drivers/infiniband/hw/mlx5/devx.c | 102 +- drivers/infiniband/hw/mlx5/devx.h | 45 + drivers/infiniband/hw/mlx5/flow.c | 765 ----- drivers/infiniband/hw/mlx5/fs.c | 2514 +++++++++++++++ drivers/infiniband/hw/mlx5/fs.h | 29 + drivers/infiniband/hw/mlx5/main.c | 4112 +++++-------------------- drivers/infiniband/hw/mlx5/mlx5_ib.h | 76 +- drivers/infiniband/hw/mlx5/qp.c | 1 + drivers/infiniband/hw/mlx5/qp.h | 1 + drivers/infiniband/hw/mlx5/restrack.c | 29 +- drivers/infiniband/hw/mlx5/restrack.h | 13 + 16 files changed, 4184 insertions(+), 4245 deletions(-) create mode 100644 drivers/infiniband/hw/mlx5/counters.c create mode 100644 drivers/infiniband/hw/mlx5/counters.h create mode 100644 drivers/infiniband/hw/mlx5/devx.h delete mode 100644 drivers/infiniband/hw/mlx5/flow.c create mode 100644 drivers/infiniband/hw/mlx5/fs.c create mode 100644 drivers/infiniband/hw/mlx5/fs.h create mode 100644 drivers/infiniband/hw/mlx5/restrack.h
--
2.26.2
PATCH 1/6 RDMA/mlx5: Limit the scope of mlx5_ib_enable_driver function
From: Leon Romanovsky <[email protected]>
The mlx5_ib_enable_driver() is local function and doesn't need to be shared in mlx5_ib, so change it's signature to have static keyword in it.
--- drivers/infiniband/hw/mlx5/main.c | 24 ++++++++++++------------ drivers/infiniband/hw/mlx5/mlx5_ib.h | 1 - 2 files changed, 12 insertions(+), 13 deletions(-)
drivers/infiniband/hw/mlx5/main.c +12 -12
@@ -6572,6 +6572,18 @@ static void mlx5_ib_stage_flow_db_cleanup(struct mlx5_ib_dev *dev)kfree (dev->flow_db); } +static int mlx5_ib_enable_driver (struct ib_device *dev) +{ +struct mlx5_ib_dev *mdev =to_mdev (dev); +int ret; + + ret =mlx5_ib_test_wc (mdev); +mlx5_ib_dbg (mdev,"Write-Combining %s" , + mdev->wc_support ?"supported" :"not supported" ); + +return ret; +} +static const struct ib_device_ops mlx5_ib_dev_ops = { .owner =THIS_MODULE , .driver_id =RDMA_DRIVER_MLX5 ,
@@ -7097,18 +7109,6 @@ static void mlx5_ib_stage_devx_cleanup(struct mlx5_ib_dev *dev) } } -int mlx5_ib_enable_driver (struct ib_device *dev) -{ -struct mlx5_ib_dev *mdev =to_mdev (dev); -int ret; - - ret =mlx5_ib_test_wc (mdev); -mlx5_ib_dbg (mdev,"Write-Combining %s" , - mdev->wc_support ?"supported" :"not supported" ); - -return ret; -} -void __mlx5_ib_remove (struct mlx5_ib_dev *dev,const struct mlx5_ib_profile *profile,int stage)
drivers/infiniband/hw/mlx5/mlx5_ib.h +0 -1
@@ -1541,7 +1541,6 @@ static inline bool mlx5_ib_can_use_umr(struct mlx5_ib_dev *dev,return true; } -int mlx5_ib_enable_driver (struct ib_device *dev);int mlx5_ib_test_wc (struct mlx5_ib_dev *dev);static inline bool mlx5_ib_lag_should_assign_affinity (struct mlx5_ib_dev *dev)
Signature · 1 line
2.26.2
PATCH 2/6 RDMA/mlx5: Separate restrack callbacks initialization from main.c
In reply to Leon RomanovskyFrom: Leon Romanovsky <[email protected]>
The restrack code has separate .c, so move callbacks initialization to that file to improve code locality.
--- drivers/infiniband/hw/mlx5/main.c | 43 ++++++--------------------- drivers/infiniband/hw/mlx5/mlx5_ib.h | 38 ++--------------------- drivers/infiniband/hw/mlx5/restrack.c | 29 +++++++++++++----- drivers/infiniband/hw/mlx5/restrack.h | 13 ++++++++ 4 files changed, 46 insertions(+), 77 deletions(-) create mode 100644 drivers/infiniband/hw/mlx5/restrack.h
drivers/infiniband/hw/mlx5/main.c +9 -34
@@ -1,33 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* -* Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved. -* -* This software is available to you under a choice of one of two -* licenses. You may choose to be licensed under the terms of the GNU -* General Public License (GPL) Version 2, available from the file -* COPYING in the main directory of this source tree, or the -* OpenIB.org BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. +* Copyright (c) 2013-2020, Mellanox Technologies inc. All rights reserved. */ #include <linux/debugfs.h>
@@ -62,6 +35,7 @@#include "srq.h" #include "qp.h" #include "wr.h" +#include "restrack.h" #include <linux/mlx5/fs_helpers.h> #include <linux/mlx5/accel.h> #include <rdma/uverbs_std_types.h>
@@ -6618,11 +6592,6 @@ static const struct ib_device_ops mlx5_ib_dev_ops = { .drain_rq = mlx5_ib_drain_rq, .drain_sq = mlx5_ib_drain_sq, .enable_driver = mlx5_ib_enable_driver, - .fill_res_cq_entry_raw = mlx5_ib_fill_res_cq_entry_raw, - .fill_res_mr_entry = mlx5_ib_fill_res_mr_entry, - .fill_res_mr_entry_raw = mlx5_ib_fill_res_mr_entry_raw, - .fill_res_qp_entry_raw = mlx5_ib_fill_res_qp_entry_raw, - .fill_stat_mr_entry = mlx5_ib_fill_stat_mr_entry, .get_dev_fw_str = get_dev_fw_str, .get_dma_mr = mlx5_ib_get_dma_mr, .get_link_layer = mlx5_ib_port_link_layer,
@@ -7210,6 +7179,9 @@ static const struct mlx5_ib_profile pf_profile = {STAGE_CREATE (MLX5_IB_STAGE_DELAY_DROP , mlx5_ib_stage_delay_drop_init, mlx5_ib_stage_delay_drop_cleanup), +STAGE_CREATE (MLX5_IB_STAGE_RESTRACK , + mlx5_ib_restrack_init, + NULL), }; const struct mlx5_ib_profile raw_eth_profile = {
@@ -7264,6 +7236,9 @@ const struct mlx5_ib_profile raw_eth_profile = {STAGE_CREATE (MLX5_IB_STAGE_POST_IB_REG_UMR , mlx5_ib_stage_post_ib_reg_umr_init,NULL ), +STAGE_CREATE (MLX5_IB_STAGE_RESTRACK , + mlx5_ib_restrack_init, + NULL), };static void *mlx5_ib_add_slave_port (struct mlx5_core_dev *mdev)
drivers/infiniband/hw/mlx5/mlx5_ib.h +3 -35
@@ -1,33 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ /* -* Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved. -* -* This software is available to you under a choice of one of two -* licenses. You may choose to be licensed under the terms of the GNU -* General Public License (GPL) Version 2, available from the file -* COPYING in the main directory of this source tree, or the -* OpenIB.org BSD license below: -* -* Redistribution and use in source and binary forms, with or -* without modification, are permitted provided that the following -* conditions are met: -* -* - Redistributions of source code must retain the above -* copyright notice, this list of conditions and the following -* disclaimer. -* -* - Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. +* Copyright (c) 2013-2020, Mellanox Technologies inc. All rights reserved. */ #ifndef MLX5_IB_H
@@ -850,7 +823,7 @@ enum mlx5_ib_stages {MLX5_IB_STAGE_IB_REG ,MLX5_IB_STAGE_POST_IB_REG_UMR ,MLX5_IB_STAGE_DELAY_DROP , -MLX5_IB_STAGE_CLASS_ATTR , +MLX5_IB_STAGE_RESTRACK , MLX5_IB_STAGE_MAX, };
@@ -1373,11 +1346,6 @@ struct mlx5_core_dev *mlx5_ib_get_native_port_mdev(struct mlx5_ib_dev *dev, u8 *native_port_num);void mlx5_ib_put_native_port_mdev (struct mlx5_ib_dev *dev,u8 port_num); -int mlx5_ib_fill_res_mr_entry (struct sk_buff *msg,struct ib_mr *ib_mr); -int mlx5_ib_fill_res_mr_entry_raw (struct sk_buff *msg,struct ib_mr *ib_mr); -int mlx5_ib_fill_res_qp_entry_raw (struct sk_buff *msg,struct ib_qp *ibqp); -int mlx5_ib_fill_res_cq_entry_raw (struct sk_buff *msg,struct ib_cq *ibcq); -int mlx5_ib_fill_stat_mr_entry (struct sk_buff *msg,struct ib_mr *ib_mr);extern const struct uapi_definition mlx5_ib_devx_defs[];extern const struct uapi_definition mlx5_ib_flow_defs[];
drivers/infiniband/hw/mlx5/restrack.c +21 -8
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB /* -* Copyright (c) 2019, Mellanox Technologies inc. All rights reserved. +* Copyright (c) 2019-2020, Mellanox Technologies Ltd. All rights reserved. */ #include <uapi/rdma/rdma_netlink.h>
@@ -8,6 +8,7 @@#include <rdma/ib_umem_odp.h> #include <rdma/restrack.h> #include "mlx5_ib.h" +#include "restrack.h" #define MAX_DUMP_SIZE 1024
@@ -77,8 +78,7 @@ static int fill_res_raw(struct sk_buff *msg, struct mlx5_ib_dev *dev,return err; } -int mlx5_ib_fill_stat_mr_entry (struct sk_buff *msg, -struct ib_mr *ibmr) +static int fill_stat_mr_entry (struct sk_buff *msg,struct ib_mr *ibmr) {struct mlx5_ib_mr *mr =to_mmr (ibmr);struct nlattr *table_attr;
@@ -112,7 +112,7 @@ int mlx5_ib_fill_stat_mr_entry(struct sk_buff *msg,return -EMSGSIZE ; } -int mlx5_ib_fill_res_mr_entry_raw (struct sk_buff *msg,struct ib_mr *ibmr) +static int fill_res_mr_entry_raw (struct sk_buff *msg,struct ib_mr *ibmr) {struct mlx5_ib_mr *mr =to_mmr (ibmr);
@@ -120,8 +120,7 @@ int mlx5_ib_fill_res_mr_entry_raw(struct sk_buff *msg, struct ib_mr *ibmr) mlx5_mkey_to_idx(mr->mmkey.key)); } -int mlx5_ib_fill_res_mr_entry (struct sk_buff *msg, -struct ib_mr *ibmr) +static int fill_res_mr_entry (struct sk_buff *msg,struct ib_mr *ibmr) {struct mlx5_ib_mr *mr =to_mmr (ibmr);struct nlattr *table_attr;
@@ -149,7 +148,7 @@ int mlx5_ib_fill_res_mr_entry(struct sk_buff *msg,return -EMSGSIZE ; } -int mlx5_ib_fill_res_cq_entry_raw (struct sk_buff *msg,struct ib_cq *ibcq) +static int fill_res_cq_entry_raw (struct sk_buff *msg,struct ib_cq *ibcq) {struct mlx5_ib_dev *dev =to_mdev (ibcq->device);struct mlx5_ib_cq *cq =to_mcq (ibcq);
@@ -157,10 +156,24 @@ int mlx5_ib_fill_res_cq_entry_raw(struct sk_buff *msg, struct ib_cq *ibcq)return fill_res_raw (msg, dev,MLX5_SGMT_TYPE_PRM_QUERY_CQ , cq->mcq.cqn); } -int mlx5_ib_fill_res_qp_entry_raw (struct sk_buff *msg,struct ib_qp *ibqp) +static int fill_res_qp_entry_raw (struct sk_buff *msg,struct ib_qp *ibqp) {struct mlx5_ib_dev *dev =to_mdev (ibqp->device);return fill_res_raw (msg, dev,MLX5_SGMT_TYPE_PRM_QUERY_QP , ibqp->qp_num); } + +static const struct ib_device_ops restrack_ops = { + .fill_res_cq_entry_raw = fill_res_cq_entry_raw, + .fill_res_mr_entry = fill_res_mr_entry, + .fill_res_mr_entry_raw = fill_res_mr_entry_raw, + .fill_res_qp_entry_raw = fill_res_qp_entry_raw, + .fill_stat_mr_entry = fill_stat_mr_entry, +}; + +int mlx5_ib_restrack_init (struct mlx5_ib_dev *dev) +{ +ib_set_device_ops (&dev->ib_dev, &restrack_ops); +return 0 ; +}
drivers/infiniband/hw/mlx5/restrack.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* +* Copyright (c) 2013-2020, Mellanox Technologies Ltd. All rights reserved. +*/ + +#ifndef _MLX5_IB_RESTRACK_H +#define _MLX5_IB_RESTRACK_H + +#include "mlx5_ib.h" + +int mlx5_ib_restrack_init (struct mlx5_ib_dev *dev); + +#endif /* _MLX5_IB_RESTRACK_H */
Signature · 1 line
2.26.2
PATCH 3/6 RDMA/mlx5: Separate counters from main.c
In reply to Leon RomanovskyFrom: Leon Romanovsky <[email protected]>
There are number of counters types supported in mlx5_ib: HW counters, congestion counters, Q-counters and flow counters. Almost all supporting code was placed in main.c that made almost impossible to maintain the code anymore. Let's create separate code namespace for the counters to easy future generalization effort.
--- drivers/infiniband/hw/mlx5/Makefile | 1 + drivers/infiniband/hw/mlx5/cmd.c | 12 - drivers/infiniband/hw/mlx5/cmd.h | 1 - drivers/infiniband/hw/mlx5/counters.c | 709 ++++++++++++++++++++++++++ drivers/infiniband/hw/mlx5/counters.h | 17 + drivers/infiniband/hw/mlx5/main.c | 701 +------------------------ drivers/infiniband/hw/mlx5/mlx5_ib.h | 3 - drivers/infiniband/hw/mlx5/qp.c | 1 + drivers/infiniband/hw/mlx5/qp.h | 1 + 9 files changed, 737 insertions(+), 709 deletions(-) create mode 100644 drivers/infiniband/hw/mlx5/counters.c create mode 100644 drivers/infiniband/hw/mlx5/counters.h
drivers/infiniband/hw/mlx5/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-$(CONFIG_MLX5_INFINIBAND) += mlx5_ib.o mlx5_ib-y := ah.o \ cmd.o \ cong.o \ + counters.o \ cq.o \ doorbell.o \ gsi.o \
drivers/infiniband/hw/mlx5/cmd.c +0 -12
@@ -148,18 +148,6 @@ void mlx5_cmd_dealloc_memic(struct mlx5_dm *dm, phys_addr_t addr, u64 length)spin_unlock (&dm->lock); } -int mlx5_cmd_query_ext_ppcnt_counters (struct mlx5_core_dev *dev,void *out) -{ -u32 in[MLX5_ST_SZ_DW (ppcnt_reg)] = {}; -int sz =MLX5_ST_SZ_BYTES (ppcnt_reg); - -MLX5_SET (ppcnt_reg, in, local_port,1 ); - -MLX5_SET (ppcnt_reg, in, grp,MLX5_ETHERNET_EXTENDED_COUNTERS_GROUP ); -return mlx5_core_access_reg (dev, in, sz, out, sz,MLX5_REG_PPCNT , -0 ,0 ); -} -void mlx5_cmd_destroy_tir (struct mlx5_core_dev *dev,u32 tirn,u16 uid) {u32 in[MLX5_ST_SZ_DW (destroy_tir_in)] = {};
drivers/infiniband/hw/mlx5/cmd.h +0 -1
@@ -41,7 +41,6 @@ int mlx5_cmd_dump_fill_mkey(struct mlx5_core_dev *dev, u32 *mkey);int mlx5_cmd_null_mkey (struct mlx5_core_dev *dev,u32 *null_mkey);int mlx5_cmd_query_cong_params (struct mlx5_core_dev *dev,int cong_point,void *out); -int mlx5_cmd_query_ext_ppcnt_counters (struct mlx5_core_dev *dev,void *out);int mlx5_cmd_alloc_memic (struct mlx5_dm *dm,phys_addr_t *addr,u64 length,u32 alignment);void mlx5_cmd_dealloc_memic (struct mlx5_dm *dm,phys_addr_t addr,u64 length);
drivers/infiniband/hw/mlx5/counters.c new file +709 -0
709 lines not on this page · raw message
drivers/infiniband/hw/mlx5/counters.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* +* Copyright (c) 2013-2020, Mellanox Technologies inc. All rights reserved. +*/ + +#ifndef _MLX5_IB_COUNTERS_H +#define _MLX5_IB_COUNTERS_H + +#include "mlx5_ib.h" + +int mlx5_ib_counters_init (struct mlx5_ib_dev *dev); +void mlx5_ib_counters_cleanup (struct mlx5_ib_dev *dev); +void mlx5_ib_counters_clear_description (struct ib_counters *counters); +int mlx5_ib_flow_counters_set_data (struct ib_counters *ibcounters, +struct mlx5_ib_create_flow *ucmd); +u16 mlx5_ib_get_counters_id (struct mlx5_ib_dev *dev,u8 port_num); +#endif /* _MLX5_IB_COUNTERS_H */
drivers/infiniband/hw/mlx5/main.c +8 -693
785 lines not on this page · raw message
drivers/infiniband/hw/mlx5/mlx5_ib.h +0 -3
@@ -1487,9 +1487,6 @@ int bfregn_to_uar_index(struct mlx5_ib_dev *dev, struct mlx5_bfreg_info *bfregi, u32 bfregn, bool dyn_bfreg); -int mlx5_ib_qp_set_counter (struct ib_qp *qp,struct rdma_counter *counter); -u16 mlx5_ib_get_counters_id (struct mlx5_ib_dev *dev,u8 port_num); -static inline bool mlx5_ib_can_use_umr (struct mlx5_ib_dev *dev,bool do_modify_atomic,int access_flags) {
drivers/infiniband/hw/mlx5/qp.c +1 -0
@@ -38,6 +38,7 @@#include <linux/mlx5/fs.h> #include "mlx5_ib.h" #include "ib_rep.h" +#include "counters.h" #include "cmd.h" #include "qp.h" #include "wr.h"
drivers/infiniband/hw/mlx5/qp.h +1 -0
@@ -43,4 +43,5 @@ void mlx5_core_res_put(struct mlx5_core_rsc_common *res);int mlx5_core_xrcd_alloc (struct mlx5_ib_dev *dev,u32 *xrcdn);int mlx5_core_xrcd_dealloc (struct mlx5_ib_dev *dev,u32 xrcdn); +int mlx5_ib_qp_set_counter (struct ib_qp *qp,struct rdma_counter *counter);#endif /* _MLX5_IB_QP_H */
Signature · 1 line
2.26.2
PATCH 4/6 RDMA/mlx5: Separate flow steering logic from main.c
In reply to Leon RomanovskyFrom: Leon Romanovsky <[email protected]>
Move flow steering logic to be in separate file and rename flow.c to be fs.c because it is better describe the content.
--- drivers/infiniband/hw/mlx5/Makefile | 2 +- drivers/infiniband/hw/mlx5/devx.c | 59 +- drivers/infiniband/hw/mlx5/devx.h | 26 + drivers/infiniband/hw/mlx5/flow.c | 765 -------- drivers/infiniband/hw/mlx5/fs.c | 2514 ++++++++++++++++++++++++++ drivers/infiniband/hw/mlx5/fs.h | 29 + drivers/infiniband/hw/mlx5/main.c | 1721 +----------------- drivers/infiniband/hw/mlx5/mlx5_ib.h | 20 +- 8 files changed, 2579 insertions(+), 2557 deletions(-) create mode 100644 drivers/infiniband/hw/mlx5/devx.h delete mode 100644 drivers/infiniband/hw/mlx5/flow.c create mode 100644 drivers/infiniband/hw/mlx5/fs.c create mode 100644 drivers/infiniband/hw/mlx5/fs.h
drivers/infiniband/hw/mlx5/Makefile +1 -1
@@ -23,6 +23,6 @@ mlx5_ib-y := ah.o \ mlx5_ib-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += odp.o mlx5_ib-$(CONFIG_MLX5_ESWITCH) += ib_rep.o mlx5_ib-$(CONFIG_INFINIBAND_USER_ACCESS) += devx.o \ - flow.o \ + fs.o \ qos.o \ std_types.o
drivers/infiniband/hw/mlx5/devx.c +1 -58
77 lines not on this page · raw message
drivers/infiniband/hw/mlx5/devx.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* +* Copyright (c) 2019-2020, Mellanox Technologies inc. All rights reserved. +*/ + +#ifndef _MLX5_IB_DEVX_H +#define _MLX5_IB_DEVX_H + +#include "mlx5_ib.h" + +#define MLX5_MAX_DESTROY_INBOX_SIZE_DW MLX5_ST_SZ_DW(delete_fte_in) +struct devx_obj { +struct mlx5_ib_dev *ib_dev; +u64 obj_id; +u32 dinlen;/* destroy inbox length */ +u32 dinbox[MLX5_MAX_DESTROY_INBOX_SIZE_DW ]; +u32 flags; +union { +struct mlx5_ib_devx_mr devx_mr; +struct mlx5_core_dct core_dct; +struct mlx5_core_cq core_cq; +u32 flow_counter_bulk_size; + }; +struct list_head event_sub;/* holds devx_event_subscription entries */ +}; +#endif /* _MLX5_IB_DEVX_H */
drivers/infiniband/hw/mlx5/flow.c deleted +0 -765
765 lines not on this page · raw message
drivers/infiniband/hw/mlx5/fs.c new file +2514 -0
2,125 lines not on this page · raw message
drivers/infiniband/hw/mlx5/fs.h new file +29 -0
Lines of this file are not shown. View the raw message.
drivers/infiniband/hw/mlx5/main.c +7 -1714
1,721 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.26.2
Part of the diff is not shown here. View the raw message.
PATCH 5/6 RDMA/mlx5: Cleanup DEVX initialization flow
In reply to Leon RomanovskyFrom: Leon Romanovsky <[email protected]>
Move DEVX initialization and cleanup flows to the devx.c instead of having almost empty functions in main.c
--- drivers/infiniband/hw/mlx5/devx.c | 43 +++++++++++++++++----------- drivers/infiniband/hw/mlx5/devx.h | 19 ++++++++++++ drivers/infiniband/hw/mlx5/main.c | 29 ++++--------------- drivers/infiniband/hw/mlx5/mlx5_ib.h | 14 --------- 4 files changed, 51 insertions(+), 54 deletions(-)
drivers/infiniband/hw/mlx5/devx.c +27 -16
@@ -2362,17 +2362,24 @@ static int devx_event_notifier(struct notifier_block *nb,return NOTIFY_OK ; } -void mlx5_ib_devx_init_event_table (struct mlx5_ib_dev *dev) +int mlx5_ib_devx_init (struct mlx5_ib_dev *dev) {struct mlx5_devx_event_table *table = &dev->devx_event_table; +int uid; + + uid =mlx5_ib_devx_create (dev, false); +if (uid >0 ) { + dev->devx_whitelist_uid = uid; +xa_init (&table->event_xa); +mutex_init (&table->event_xa_lock); +MLX5_NB_INIT (&table->devx_nb, devx_event_notifier,NOTIFY_ANY ); +mlx5_eq_notifier_register (dev->mdev, &table->devx_nb); + } -xa_init (&table->event_xa); -mutex_init (&table->event_xa_lock); -MLX5_NB_INIT (&table->devx_nb, devx_event_notifier,NOTIFY_ANY ); -mlx5_eq_notifier_register (dev->mdev, &table->devx_nb); +return 0 ; } -void mlx5_ib_devx_cleanup_event_table (struct mlx5_ib_dev *dev) +void mlx5_ib_devx_cleanup (struct mlx5_ib_dev *dev) {struct mlx5_devx_event_table *table = &dev->devx_event_table;struct devx_event_subscription *sub, *tmp;
@@ -2380,17 +2387,21 @@ void mlx5_ib_devx_cleanup_event_table(struct mlx5_ib_dev *dev)void *entry;unsigned long id; -mlx5_eq_notifier_unregister (dev->mdev, &table->devx_nb); -mutex_lock (&dev->devx_event_table.event_xa_lock); -xa_for_each (&table->event_xa, id, entry) { - event = entry; -list_for_each_entry_safe (sub, tmp, &event->unaffiliated_list, - xa_list) -devx_cleanup_subscription (dev, sub); -kfree (entry); +if (dev->devx_whitelist_uid) { +mlx5_eq_notifier_unregister (dev->mdev, &table->devx_nb); +mutex_lock (&dev->devx_event_table.event_xa_lock); +xa_for_each (&table->event_xa, id, entry) { + event = entry; +list_for_each_entry_safe ( + sub, tmp, &event->unaffiliated_list, xa_list) +devx_cleanup_subscription (dev, sub); +kfree (entry); + } +mutex_unlock (&dev->devx_event_table.event_xa_lock); +xa_destroy (&table->event_xa); + +mlx5_ib_devx_destroy (dev, dev->devx_whitelist_uid); } -mutex_unlock (&dev->devx_event_table.event_xa_lock); -xa_destroy (&table->event_xa); } static ssize_t devx_async_cmd_event_read(struct file *filp, char __user *buf,
drivers/infiniband/hw/mlx5/devx.h +19 -0
@@ -23,4 +23,23 @@ struct devx_obj { };struct list_head event_sub;/* holds devx_event_subscription entries */ }; +#if IS_ENABLED (CONFIG_INFINIBAND_USER_ACCESS ) +int mlx5_ib_devx_create (struct mlx5_ib_dev *dev,bool is_user); +void mlx5_ib_devx_destroy (struct mlx5_ib_dev *dev,u16 uid); +int mlx5_ib_devx_init (struct mlx5_ib_dev *dev); +void mlx5_ib_devx_cleanup (struct mlx5_ib_dev *dev); +#else +static inline int mlx5_ib_devx_create (struct mlx5_ib_dev *dev,bool is_user) +{ +return -EOPNOTSUPP ; +} +static inline void mlx5_ib_devx_destroy (struct mlx5_ib_dev *dev,u16 uid) {} +static inline int mlx5_ib_devx_init (struct mlx5_ib_dev *dev) +{ +return 0 ; +} +static inline void mlx5_ib_devx_cleanup (struct mlx5_ib_dev *dev) +{ +} +#endif #endif /* _MLX5_IB_DEVX_H */
drivers/infiniband/hw/mlx5/main.c +5 -24
@@ -32,6 +32,7 @@#include "mlx5_ib.h" #include "ib_rep.h" #include "cmd.h" +#include "devx.h" #include "fs.h" #include "srq.h" #include "qp.h"
@@ -4666,26 +4667,6 @@ static void mlx5_ib_stage_dev_notifier_cleanup(struct mlx5_ib_dev *dev)mlx5_notifier_unregister (dev->mdev, &dev->mdev_events); } -static int mlx5_ib_stage_devx_init (struct mlx5_ib_dev *dev) -{ -int uid; - - uid =mlx5_ib_devx_create (dev, false); -if (uid >0 ) { - dev->devx_whitelist_uid = uid; -mlx5_ib_devx_init_event_table (dev); - } - -return 0 ; -} -static void mlx5_ib_stage_devx_cleanup (struct mlx5_ib_dev *dev) -{ -if (dev->devx_whitelist_uid) { -mlx5_ib_devx_cleanup_event_table (dev); -mlx5_ib_devx_destroy (dev, dev->devx_whitelist_uid); - } -} -void __mlx5_ib_remove (struct mlx5_ib_dev *dev,const struct mlx5_ib_profile *profile,int stage)
@@ -4776,8 +4757,8 @@ static const struct mlx5_ib_profile pf_profile = { NULL, mlx5_ib_stage_pre_ib_reg_umr_cleanup),STAGE_CREATE (MLX5_IB_STAGE_WHITELIST_UID , - mlx5_ib_stage_devx_init, - mlx5_ib_stage_devx_cleanup), + mlx5_ib_devx_init, + mlx5_ib_devx_cleanup),STAGE_CREATE (MLX5_IB_STAGE_IB_REG , mlx5_ib_stage_ib_reg_init, mlx5_ib_stage_ib_reg_cleanup),
@@ -4836,8 +4817,8 @@ const struct mlx5_ib_profile raw_eth_profile = { NULL, mlx5_ib_stage_pre_ib_reg_umr_cleanup),STAGE_CREATE (MLX5_IB_STAGE_WHITELIST_UID , - mlx5_ib_stage_devx_init, - mlx5_ib_stage_devx_cleanup), + mlx5_ib_devx_init, + mlx5_ib_devx_cleanup),STAGE_CREATE (MLX5_IB_STAGE_IB_REG , mlx5_ib_stage_ib_reg_init, mlx5_ib_stage_ib_reg_cleanup),
drivers/infiniband/hw/mlx5/mlx5_ib.h +0 -14
@@ -1352,20 +1352,6 @@ extern const struct uapi_definition mlx5_ib_flow_defs[];extern const struct uapi_definition mlx5_ib_qos_defs[];extern const struct uapi_definition mlx5_ib_std_types_defs[]; - -#if IS_ENABLED (CONFIG_INFINIBAND_USER_ACCESS ) -int mlx5_ib_devx_create (struct mlx5_ib_dev *dev,bool is_user); -void mlx5_ib_devx_destroy (struct mlx5_ib_dev *dev,u16 uid); -void mlx5_ib_devx_init_event_table (struct mlx5_ib_dev *dev); -void mlx5_ib_devx_cleanup_event_table (struct mlx5_ib_dev *dev); -#else -static inline int -mlx5_ib_devx_create (struct mlx5_ib_dev *dev, -bool is_user) {return -EOPNOTSUPP ; } -static inline void mlx5_ib_devx_destroy (struct mlx5_ib_dev *dev,u16 uid) {} -static inline void mlx5_ib_devx_init_event_table (struct mlx5_ib_dev *dev) {} -static inline void mlx5_ib_devx_cleanup_event_table (struct mlx5_ib_dev *dev) {} -#endif static inline void init_query_mad (struct ib_smp *mad) { mad->base_version =1 ;
Signature · 1 line
2.26.2
PATCH 6/6 RDMA/mlx5: Delete one-time used functions
In reply to Leon RomanovskyFrom: Leon Romanovsky <[email protected]>
Fast and furious cleanup of main.c from one-time and duplicated functions.
--- drivers/infiniband/hw/mlx5/main.c | 472 +++++++++++++----------------- 1 file changed, 198 insertions(+), 274 deletions(-)
drivers/infiniband/hw/mlx5/main.c +198 -274
@@ -3023,137 +3023,6 @@ static int get_port_caps(struct mlx5_ib_dev *dev, u8 port)return __get_port_caps (dev, port); } -static void destroy_umrc_res (struct mlx5_ib_dev *dev) -{ -int err; - - err =mlx5_mr_cache_cleanup (dev); -if (err) -mlx5_ib_warn (dev,"mr cache cleanup failed\n" ); - -if (dev->umrc.qp) -mlx5_ib_destroy_qp (dev->umrc.qp,NULL ); -if (dev->umrc.cq) -ib_free_cq (dev->umrc.cq); -if (dev->umrc.pd) -ib_dealloc_pd (dev->umrc.pd); -} - -enum { -MAX_UMR_WR =128 , -}; - -static int create_umr_res (struct mlx5_ib_dev *dev) -{ -struct ib_qp_init_attr *init_attr =NULL ; -struct ib_qp_attr *attr =NULL ; -struct ib_pd *pd; -struct ib_cq *cq; -struct ib_qp *qp; -int ret; - - attr =kzalloc (sizeof (*attr),GFP_KERNEL ); - init_attr =kzalloc (sizeof (*init_attr),GFP_KERNEL ); -if (!attr || !init_attr) { - ret = -ENOMEM ; - goto error_0; - } - - pd =ib_alloc_pd (&dev->ib_dev,0 ); -if (IS_ERR (pd)) { -mlx5_ib_dbg (dev,"Couldn't create PD for sync UMR QP\n" ); - ret =PTR_ERR (pd); - goto error_0; - } - - cq =ib_alloc_cq (&dev->ib_dev,NULL ,128 ,0 ,IB_POLL_SOFTIRQ ); -if (IS_ERR (cq)) { -mlx5_ib_dbg (dev,"Couldn't create CQ for sync UMR QP\n" ); - ret =PTR_ERR (cq); - goto error_2; - } - - init_attr->send_cq = cq; - init_attr->recv_cq = cq; - init_attr->sq_sig_type =IB_SIGNAL_ALL_WR ; - init_attr->cap.max_send_wr =MAX_UMR_WR ; - init_attr->cap.max_send_sge =1 ; - init_attr->qp_type =MLX5_IB_QPT_REG_UMR ; - init_attr->port_num =1 ; - qp =mlx5_ib_create_qp (pd, init_attr,NULL ); -if (IS_ERR (qp)) { -mlx5_ib_dbg (dev,"Couldn't create sync UMR QP\n" ); - ret =PTR_ERR (qp); - goto error_3; - } - qp->device = &dev->ib_dev; - qp->real_qp = qp; - qp->uobject =NULL ; - qp->qp_type =MLX5_IB_QPT_REG_UMR ; - qp->send_cq = init_attr->send_cq; - qp->recv_cq = init_attr->recv_cq; - - attr->qp_state =IB_QPS_INIT ; - attr->port_num =1 ; - ret =mlx5_ib_modify_qp (qp, attr,IB_QP_STATE |IB_QP_PKEY_INDEX | -IB_QP_PORT ,NULL ); -if (ret) { -mlx5_ib_dbg (dev,"Couldn't modify UMR QP\n" ); - goto error_4; - } - -memset (attr,0 ,sizeof (*attr)); - attr->qp_state =IB_QPS_RTR ; - attr->path_mtu =IB_MTU_256 ; - - ret =mlx5_ib_modify_qp (qp, attr,IB_QP_STATE ,NULL ); -if (ret) { -mlx5_ib_dbg (dev,"Couldn't modify umr QP to rtr\n" ); - goto error_4; - } - -memset (attr,0 ,sizeof (*attr)); - attr->qp_state =IB_QPS_RTS ; - ret =mlx5_ib_modify_qp (qp, attr,IB_QP_STATE ,NULL ); -if (ret) { -mlx5_ib_dbg (dev,"Couldn't modify umr QP to rts\n" ); - goto error_4; - } - - dev->umrc.qp = qp; - dev->umrc.cq = cq; - dev->umrc.pd = pd; - -sema_init (&dev->umrc.sem,MAX_UMR_WR ); - ret =mlx5_mr_cache_init (dev); -if (ret) { -mlx5_ib_warn (dev,"mr cache init failed %d\n" , ret); - goto error_4; - } - -kfree (attr); -kfree (init_attr); - -return 0 ; - -error_4: -mlx5_ib_destroy_qp (qp,NULL ); - dev->umrc.qp =NULL ; - -error_3: -ib_free_cq (cq); - dev->umrc.cq =NULL ; - -error_2: -ib_dealloc_pd (pd); - dev->umrc.pd =NULL ; - -error_0: -kfree (attr); -kfree (init_attr); -return ret; -} -static u8 mlx5_get_umr_fence (u8 umr_fence_cap) {switch (umr_fence_cap) {
@@ -3166,16 +3035,15 @@ static u8 mlx5_get_umr_fence(u8 umr_fence_cap) } } -static int create_dev_resources (struct mlx5_ib_resources *devr) +static int mlx5_ib_dev_res_init (struct mlx5_ib_dev *dev) { +struct mlx5_ib_resources *devr = &dev->devr;struct ib_srq_init_attr attr; -struct mlx5_ib_dev *dev;struct ib_device *ibdev;struct ib_cq_init_attr cq_attr = {.cqe =1 };int port;int ret =0 ; - dev = container_of(devr, struct mlx5_ib_dev, devr); ibdev = &dev->ib_dev;mutex_init (&devr->mutex);
@@ -3296,8 +3164,9 @@ static int create_dev_resources(struct mlx5_ib_resources *devr)return ret; } -static void destroy_dev_resources (struct mlx5_ib_resources *devr) +static void mlx5_ib_dev_res_cleanup (struct mlx5_ib_dev *dev) { +struct mlx5_ib_resources *devr = &dev->devr;int port;mlx5_ib_destroy_srq (devr->s1,NULL );
@@ -3509,23 +3378,6 @@ static int mlx5_ib_rn_get_params(struct ib_device *device, u8 port_num,return mlx5_rdma_rn_get_params (to_mdev (device)->mdev, device, params); } -static void delay_drop_debugfs_cleanup (struct mlx5_ib_dev *dev) -{ -if (!dev->delay_drop.dir_debugfs) -return ; -debugfs_remove_recursive (dev->delay_drop.dir_debugfs); - dev->delay_drop.dir_debugfs =NULL ; -} - -static void cancel_delay_drop (struct mlx5_ib_dev *dev) -{ -if (!(dev->ib_dev.attrs.raw_packet_caps &IB_RAW_PACKET_CAP_DELAY_DROP )) -return ; - -cancel_work_sync (&dev->delay_drop.delay_drop_work); -delay_drop_debugfs_cleanup (dev); -} -static ssize_t delay_drop_timeout_read (struct file *filp,char __user *buf,size_t count,loff_t *pos) {
@@ -3565,40 +3417,6 @@ static const struct file_operations fops_delay_drop_timeout = { .read = delay_drop_timeout_read, }; -static void delay_drop_debugfs_init (struct mlx5_ib_dev *dev) -{ -struct dentry *root; - -if (!mlx5_debugfs_root) -return ; - - root =debugfs_create_dir ("delay_drop" , dev->mdev->priv.dbg_root); - dev->delay_drop.dir_debugfs = root; - -debugfs_create_atomic_t ("num_timeout_events" ,0400 , root, - &dev->delay_drop.events_cnt); -debugfs_create_atomic_t ("num_rqs" ,0400 , root, - &dev->delay_drop.rqs_cnt); -debugfs_create_file ("timeout" ,0600 , root, &dev->delay_drop, - &fops_delay_drop_timeout); -} - -static void init_delay_drop (struct mlx5_ib_dev *dev) -{ -if (!(dev->ib_dev.attrs.raw_packet_caps &IB_RAW_PACKET_CAP_DELAY_DROP )) -return ; - -mutex_init (&dev->delay_drop.lock); - dev->delay_drop.dev = dev; - dev->delay_drop.activate = false; - dev->delay_drop.timeout =MLX5_MAX_DELAY_DROP_TIMEOUT_MS *1000 ; -INIT_WORK (&dev->delay_drop.delay_drop_work, delay_drop_handler); -atomic_set (&dev->delay_drop.rqs_cnt,0 ); -atomic_set (&dev->delay_drop.events_cnt,0 ); - -delay_drop_debugfs_init (dev); -} -static void mlx5_ib_unbind_slave_port (struct mlx5_ib_dev *ibdev,struct mlx5_ib_multiport_info *mpi) {
@@ -4463,65 +4281,36 @@ static const struct ib_device_ops mlx5_ib_dev_common_roce_ops = { .modify_wq = mlx5_ib_modify_wq, }; -static int mlx5_ib_stage_common_roce_init (struct mlx5_ib_dev *dev) -{ -u8 port_num; - - dev->ib_dev.uverbs_ex_cmd_mask |= - (1ull <<IB_USER_VERBS_EX_CMD_CREATE_WQ ) | - (1ull <<IB_USER_VERBS_EX_CMD_MODIFY_WQ ) | - (1ull <<IB_USER_VERBS_EX_CMD_DESTROY_WQ ) | - (1ull <<IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL ) | - (1ull <<IB_USER_VERBS_EX_CMD_DESTROY_RWQ_IND_TBL ); -ib_set_device_ops (&dev->ib_dev, &mlx5_ib_dev_common_roce_ops); - - port_num =mlx5_core_native_port_num (dev->mdev) -1 ; - -/* Register only for native ports */ -return mlx5_add_netdev_notifier (dev, port_num); -} - -static void mlx5_ib_stage_common_roce_cleanup (struct mlx5_ib_dev *dev) -{ -u8 port_num =mlx5_core_native_port_num (dev->mdev) -1 ; - -mlx5_remove_netdev_notifier (dev, port_num); -} - -static int mlx5_ib_stage_raw_eth_roce_init (struct mlx5_ib_dev *dev) -{ -struct mlx5_core_dev *mdev = dev->mdev; -enum rdma_link_layer ll; -int port_type_cap; -int err =0 ; - - port_type_cap =MLX5_CAP_GEN (mdev, port_type); - ll =mlx5_port_type_cap_to_rdma_ll (port_type_cap); - -if (ll ==IB_LINK_LAYER_ETHERNET ) - err =mlx5_ib_stage_common_roce_init (dev); - -return err; -} - -static void mlx5_ib_stage_raw_eth_roce_cleanup (struct mlx5_ib_dev *dev) -{ -mlx5_ib_stage_common_roce_cleanup (dev); -} - -static int mlx5_ib_stage_roce_init (struct mlx5_ib_dev *dev) +static int mlx5_ib_roce_init (struct mlx5_ib_dev *dev) {struct mlx5_core_dev *mdev = dev->mdev;enum rdma_link_layer ll;int port_type_cap; +u8 port_num =0 ;int err; port_type_cap =MLX5_CAP_GEN (mdev, port_type); ll =mlx5_port_type_cap_to_rdma_ll (port_type_cap);if (ll ==IB_LINK_LAYER_ETHERNET ) { - err =mlx5_ib_stage_common_roce_init (dev); -if (err) + dev->ib_dev.uverbs_ex_cmd_mask |= + (1ull <<IB_USER_VERBS_EX_CMD_CREATE_WQ ) | + (1ull <<IB_USER_VERBS_EX_CMD_MODIFY_WQ ) | + (1ull <<IB_USER_VERBS_EX_CMD_DESTROY_WQ ) | + (1ull <<IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL ) | + (1ull <<IB_USER_VERBS_EX_CMD_DESTROY_RWQ_IND_TBL ); +ib_set_device_ops (&dev->ib_dev, &mlx5_ib_dev_common_roce_ops); + + port_num =mlx5_core_native_port_num (dev->mdev) -1 ; + +/* Register only for native ports */ + err =mlx5_add_netdev_notifier (dev, port_num); +if (err || dev->is_rep || !mlx5_is_roce_enabled (mdev)) +/* +* We don't enable ETH interface for +* 1. IB representors +* 2. User disabled ROCE through devlink interface +*/ return err; err =mlx5_enable_eth (dev);
@@ -4531,44 +4320,27 @@ static int mlx5_ib_stage_roce_init(struct mlx5_ib_dev *dev)return 0 ; cleanup: -mlx5_ib_stage_common_roce_cleanup (dev); - +mlx5_remove_netdev_notifier (dev, port_num);return err; } -static void mlx5_ib_stage_roce_cleanup (struct mlx5_ib_dev *dev) +static void mlx5_ib_roce_cleanup (struct mlx5_ib_dev *dev) {struct mlx5_core_dev *mdev = dev->mdev;enum rdma_link_layer ll;int port_type_cap; +u8 port_num; port_type_cap =MLX5_CAP_GEN (mdev, port_type); ll =mlx5_port_type_cap_to_rdma_ll (port_type_cap);if (ll ==IB_LINK_LAYER_ETHERNET ) { -mlx5_disable_eth (dev); -mlx5_ib_stage_common_roce_cleanup (dev); - } -} - -static int mlx5_ib_stage_dev_res_init (struct mlx5_ib_dev *dev) -{ -return create_dev_resources (&dev->devr); -} - -static void mlx5_ib_stage_dev_res_cleanup (struct mlx5_ib_dev *dev) -{ -destroy_dev_resources (&dev->devr); -} - -static int mlx5_ib_stage_odp_init (struct mlx5_ib_dev *dev) -{ -return mlx5_ib_odp_init_one (dev); -} +if (!dev->is_rep) +mlx5_disable_eth (dev); -static void mlx5_ib_stage_odp_cleanup (struct mlx5_ib_dev *dev) -{ -mlx5_ib_odp_cleanup_one (dev); + port_num =mlx5_core_native_port_num (dev->mdev) -1 ; +mlx5_remove_netdev_notifier (dev, port_num); + } }static int mlx5_ib_stage_cong_debugfs_init (struct mlx5_ib_dev *dev)
@@ -4630,7 +4402,18 @@ static int mlx5_ib_stage_ib_reg_init(struct mlx5_ib_dev *dev)static void mlx5_ib_stage_pre_ib_reg_umr_cleanup (struct mlx5_ib_dev *dev) { -destroy_umrc_res (dev); +int err; + + err =mlx5_mr_cache_cleanup (dev); +if (err) +mlx5_ib_warn (dev,"mr cache cleanup failed\n" ); + +if (dev->umrc.qp) +mlx5_ib_destroy_qp (dev->umrc.qp,NULL ); +if (dev->umrc.cq) +ib_free_cq (dev->umrc.cq); +if (dev->umrc.pd) +ib_dealloc_pd (dev->umrc.pd); }static void mlx5_ib_stage_ib_reg_cleanup (struct mlx5_ib_dev *dev)
@@ -4638,21 +4421,162 @@ static void mlx5_ib_stage_ib_reg_cleanup(struct mlx5_ib_dev *dev)ib_unregister_device (&dev->ib_dev); } +enum { +MAX_UMR_WR =128 , +}; +static int mlx5_ib_stage_post_ib_reg_umr_init (struct mlx5_ib_dev *dev) { -return create_umr_res (dev); +struct ib_qp_init_attr *init_attr =NULL ; +struct ib_qp_attr *attr =NULL ; +struct ib_pd *pd; +struct ib_cq *cq; +struct ib_qp *qp; +int ret; + + attr =kzalloc (sizeof (*attr),GFP_KERNEL ); + init_attr =kzalloc (sizeof (*init_attr),GFP_KERNEL ); +if (!attr || !init_attr) { + ret = -ENOMEM ; + goto error_0; + } + + pd =ib_alloc_pd (&dev->ib_dev,0 ); +if (IS_ERR (pd)) { +mlx5_ib_dbg (dev,"Couldn't create PD for sync UMR QP\n" ); + ret =PTR_ERR (pd); + goto error_0; + } + + cq =ib_alloc_cq (&dev->ib_dev,NULL ,128 ,0 ,IB_POLL_SOFTIRQ ); +if (IS_ERR (cq)) { +mlx5_ib_dbg (dev,"Couldn't create CQ for sync UMR QP\n" ); + ret =PTR_ERR (cq); + goto error_2; + } + + init_attr->send_cq = cq; + init_attr->recv_cq = cq; + init_attr->sq_sig_type =IB_SIGNAL_ALL_WR ; + init_attr->cap.max_send_wr =MAX_UMR_WR ; + init_attr->cap.max_send_sge =1 ; + init_attr->qp_type =MLX5_IB_QPT_REG_UMR ; + init_attr->port_num =1 ; + qp =mlx5_ib_create_qp (pd, init_attr,NULL ); +if (IS_ERR (qp)) { +mlx5_ib_dbg (dev,"Couldn't create sync UMR QP\n" ); + ret =PTR_ERR (qp); + goto error_3; + } + qp->device = &dev->ib_dev; + qp->real_qp = qp; + qp->uobject =NULL ; + qp->qp_type =MLX5_IB_QPT_REG_UMR ; + qp->send_cq = init_attr->send_cq; + qp->recv_cq = init_attr->recv_cq; + + attr->qp_state =IB_QPS_INIT ; + attr->port_num =1 ; + ret =mlx5_ib_modify_qp (qp, attr,IB_QP_STATE |IB_QP_PKEY_INDEX | +IB_QP_PORT ,NULL ); +if (ret) { +mlx5_ib_dbg (dev,"Couldn't modify UMR QP\n" ); + goto error_4; + } + +memset (attr,0 ,sizeof (*attr)); + attr->qp_state =IB_QPS_RTR ; + attr->path_mtu =IB_MTU_256 ; + + ret =mlx5_ib_modify_qp (qp, attr,IB_QP_STATE ,NULL ); +if (ret) { +mlx5_ib_dbg (dev,"Couldn't modify umr QP to rtr\n" ); + goto error_4; + } + +memset (attr,0 ,sizeof (*attr)); + attr->qp_state =IB_QPS_RTS ; + ret =mlx5_ib_modify_qp (qp, attr,IB_QP_STATE ,NULL ); +if (ret) { +mlx5_ib_dbg (dev,"Couldn't modify umr QP to rts\n" ); + goto error_4; + } + + dev->umrc.qp = qp; + dev->umrc.cq = cq; + dev->umrc.pd = pd; + +sema_init (&dev->umrc.sem,MAX_UMR_WR ); + ret =mlx5_mr_cache_init (dev); +if (ret) { +mlx5_ib_warn (dev,"mr cache init failed %d\n" , ret); + goto error_4; + } + +kfree (attr); +kfree (init_attr); + +return 0 ; + +error_4: +mlx5_ib_destroy_qp (qp,NULL ); + dev->umrc.qp =NULL ; + +error_3: +ib_free_cq (cq); + dev->umrc.cq =NULL ; + +error_2: +ib_dealloc_pd (pd); + dev->umrc.pd =NULL ; + +error_0: +kfree (attr); +kfree (init_attr); +return ret; }static int mlx5_ib_stage_delay_drop_init (struct mlx5_ib_dev *dev) { -init_delay_drop (dev); +struct dentry *root; + +if (!(dev->ib_dev.attrs.raw_packet_caps &IB_RAW_PACKET_CAP_DELAY_DROP )) +return 0 ; + +mutex_init (&dev->delay_drop.lock); + dev->delay_drop.dev = dev; + dev->delay_drop.activate = false; + dev->delay_drop.timeout =MLX5_MAX_DELAY_DROP_TIMEOUT_MS *1000 ; +INIT_WORK (&dev->delay_drop.delay_drop_work, delay_drop_handler); +atomic_set (&dev->delay_drop.rqs_cnt,0 ); +atomic_set (&dev->delay_drop.events_cnt,0 ); + +if (!mlx5_debugfs_root) +return 0 ; + root =debugfs_create_dir ("delay_drop" , dev->mdev->priv.dbg_root); + dev->delay_drop.dir_debugfs = root; + +debugfs_create_atomic_t ("num_timeout_events" ,0400 , root, + &dev->delay_drop.events_cnt); +debugfs_create_atomic_t ("num_rqs" ,0400 , root, + &dev->delay_drop.rqs_cnt); +debugfs_create_file ("timeout" ,0600 , root, &dev->delay_drop, + &fops_delay_drop_timeout);return 0 ; }static void mlx5_ib_stage_delay_drop_cleanup (struct mlx5_ib_dev *dev) { -cancel_delay_drop (dev); +if (!(dev->ib_dev.attrs.raw_packet_caps &IB_RAW_PACKET_CAP_DELAY_DROP )) +return ; + +cancel_work_sync (&dev->delay_drop.delay_drop_work); +if (!dev->delay_drop.dir_debugfs) +return ; + +debugfs_remove_recursive (dev->delay_drop.dir_debugfs); + dev->delay_drop.dir_debugfs =NULL ; }static int mlx5_ib_stage_dev_notifier_init (struct mlx5_ib_dev *dev)
@@ -4724,8 +4648,8 @@ static const struct mlx5_ib_profile pf_profile = { mlx5_ib_stage_non_default_cb, NULL),STAGE_CREATE (MLX5_IB_STAGE_ROCE , - mlx5_ib_stage_roce_init, - mlx5_ib_stage_roce_cleanup), + mlx5_ib_roce_init, + mlx5_ib_roce_cleanup),STAGE_CREATE (MLX5_IB_STAGE_QP , mlx5_init_qp_table, mlx5_cleanup_qp_table),
@@ -4733,14 +4657,14 @@ static const struct mlx5_ib_profile pf_profile = { mlx5_init_srq_table, mlx5_cleanup_srq_table),STAGE_CREATE (MLX5_IB_STAGE_DEVICE_RESOURCES , - mlx5_ib_stage_dev_res_init, - mlx5_ib_stage_dev_res_cleanup), + mlx5_ib_dev_res_init, + mlx5_ib_dev_res_cleanup),STAGE_CREATE (MLX5_IB_STAGE_DEVICE_NOTIFIER , mlx5_ib_stage_dev_notifier_init, mlx5_ib_stage_dev_notifier_cleanup),STAGE_CREATE (MLX5_IB_STAGE_ODP , - mlx5_ib_stage_odp_init, - mlx5_ib_stage_odp_cleanup), + mlx5_ib_odp_init_one, + mlx5_ib_odp_cleanup_one),STAGE_CREATE (MLX5_IB_STAGE_COUNTERS , mlx5_ib_counters_init, mlx5_ib_counters_cleanup),
@@ -4787,8 +4711,8 @@ const struct mlx5_ib_profile raw_eth_profile = { mlx5_ib_stage_raw_eth_non_default_cb, NULL),STAGE_CREATE (MLX5_IB_STAGE_ROCE , - mlx5_ib_stage_raw_eth_roce_init, - mlx5_ib_stage_raw_eth_roce_cleanup), + mlx5_ib_roce_init, + mlx5_ib_roce_cleanup),STAGE_CREATE (MLX5_IB_STAGE_QP , mlx5_init_qp_table, mlx5_cleanup_qp_table),
@@ -4796,8 +4720,8 @@ const struct mlx5_ib_profile raw_eth_profile = { mlx5_init_srq_table, mlx5_cleanup_srq_table),STAGE_CREATE (MLX5_IB_STAGE_DEVICE_RESOURCES , - mlx5_ib_stage_dev_res_init, - mlx5_ib_stage_dev_res_cleanup), + mlx5_ib_dev_res_init, + mlx5_ib_dev_res_cleanup),STAGE_CREATE (MLX5_IB_STAGE_DEVICE_NOTIFIER , mlx5_ib_stage_dev_notifier_init, mlx5_ib_stage_dev_notifier_cleanup),
Signature · 1 line
2.26.2
Quoted 11 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
Over the years, the
main.cfile grew above all imagination and was >8K LOC of the code. This caused to a huge burden while I started to work onib_flowallocation patches.This series implements long standing "internal" wish to move flow logic from the main to separate file.
Based on
https://lore.kernel.org/linux-rdma/[email protected]
Isn't this the series you said to drop? Can this be applied independently?
Jason
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
Over the years, the
main.cfile grew above all imagination and was >8K LOC of the code. This caused to a huge burden while I started to work onib_flowallocation patches.
Quoted 8 lines
Quoted 5 lines
This series implements long standing "internal" wish to move flow logic from the main to separate file.
Based on
https://lore.kernel.org/linux-rdma/[email protected]Isn't this the series you said to drop? Can this be applied independently?
I asked to drop one patch in question, the one that revealed issue with reference counting and convoluted error unwind flow.
https://lore.kernel.org/lkml/20200630145926.GA4837@unreal
It probably can be applied independently, but I didn't try.
Thanks
Quoted 2 lines
Jason
Quoted 14 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
Over the years, the
main.cfile grew above all imagination and was >8K LOC of the code. This caused to a huge burden while I started to work onib_flowallocation patches.This series implements long standing "internal" wish to move flow logic from the main to separate file.
Based on
https://lore.kernel.org/linux-rdma/[email protected]Thanks
Quoted 7 lines
Leon Romanovsky (6):
RDMA/mlx5: Limit the scope ofmlx5_ib_enable_driverfunction RDMA/mlx5: Separate restrack callbacks initialization frommain.cRDMA/mlx5: Separate counters frommain.c
RDMA/mlx5: Separate flow steering logic frommain.cRDMA/mlx5: Cleanup DEVX initialization flow
RDMA/mlx5: Delete one-time used functions
Applied to for-next, thanks
Jason