Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RDMA/mlx5: Separate restrack callbacks initialization from main.c

The restrack code has separate .c, so move callbacks initialization to
that file to improve code locality.

Link: https://lore.kernel.org/r/20200702081809.423482-3-leon@kernel.org
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Leon Romanovsky and committed by
Jason Gunthorpe
b572ebe6 ac47bf5e

+46 -77
+9 -34
drivers/infiniband/hw/mlx5/main.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB 1 2 /* 2 - * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved. 3 - * 4 - * This software is available to you under a choice of one of two 5 - * licenses. You may choose to be licensed under the terms of the GNU 6 - * General Public License (GPL) Version 2, available from the file 7 - * COPYING in the main directory of this source tree, or the 8 - * OpenIB.org BSD license below: 9 - * 10 - * Redistribution and use in source and binary forms, with or 11 - * without modification, are permitted provided that the following 12 - * conditions are met: 13 - * 14 - * - Redistributions of source code must retain the above 15 - * copyright notice, this list of conditions and the following 16 - * disclaimer. 17 - * 18 - * - Redistributions in binary form must reproduce the above 19 - * copyright notice, this list of conditions and the following 20 - * disclaimer in the documentation and/or other materials 21 - * provided with the distribution. 22 - * 23 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27 - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28 - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 - * SOFTWARE. 3 + * Copyright (c) 2013-2020, Mellanox Technologies inc. All rights reserved. 31 4 */ 32 5 33 6 #include <linux/debugfs.h> ··· 35 62 #include "srq.h" 36 63 #include "qp.h" 37 64 #include "wr.h" 65 + #include "restrack.h" 38 66 #include <linux/mlx5/fs_helpers.h> 39 67 #include <linux/mlx5/accel.h> 40 68 #include <rdma/uverbs_std_types.h> ··· 6589 6615 .drain_rq = mlx5_ib_drain_rq, 6590 6616 .drain_sq = mlx5_ib_drain_sq, 6591 6617 .enable_driver = mlx5_ib_enable_driver, 6592 - .fill_res_cq_entry_raw = mlx5_ib_fill_res_cq_entry_raw, 6593 - .fill_res_mr_entry = mlx5_ib_fill_res_mr_entry, 6594 - .fill_res_mr_entry_raw = mlx5_ib_fill_res_mr_entry_raw, 6595 - .fill_res_qp_entry_raw = mlx5_ib_fill_res_qp_entry_raw, 6596 - .fill_stat_mr_entry = mlx5_ib_fill_stat_mr_entry, 6597 6618 .get_dev_fw_str = get_dev_fw_str, 6598 6619 .get_dma_mr = mlx5_ib_get_dma_mr, 6599 6620 .get_link_layer = mlx5_ib_port_link_layer, ··· 7174 7205 STAGE_CREATE(MLX5_IB_STAGE_DELAY_DROP, 7175 7206 mlx5_ib_stage_delay_drop_init, 7176 7207 mlx5_ib_stage_delay_drop_cleanup), 7208 + STAGE_CREATE(MLX5_IB_STAGE_RESTRACK, 7209 + mlx5_ib_restrack_init, 7210 + NULL), 7177 7211 }; 7178 7212 7179 7213 const struct mlx5_ib_profile raw_eth_profile = { ··· 7230 7258 mlx5_ib_stage_ib_reg_cleanup), 7231 7259 STAGE_CREATE(MLX5_IB_STAGE_POST_IB_REG_UMR, 7232 7260 mlx5_ib_stage_post_ib_reg_umr_init, 7261 + NULL), 7262 + STAGE_CREATE(MLX5_IB_STAGE_RESTRACK, 7263 + mlx5_ib_restrack_init, 7233 7264 NULL), 7234 7265 }; 7235 7266
+3 -35
drivers/infiniband/hw/mlx5/mlx5_ib.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 1 2 /* 2 - * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved. 3 - * 4 - * This software is available to you under a choice of one of two 5 - * licenses. You may choose to be licensed under the terms of the GNU 6 - * General Public License (GPL) Version 2, available from the file 7 - * COPYING in the main directory of this source tree, or the 8 - * OpenIB.org BSD license below: 9 - * 10 - * Redistribution and use in source and binary forms, with or 11 - * without modification, are permitted provided that the following 12 - * conditions are met: 13 - * 14 - * - Redistributions of source code must retain the above 15 - * copyright notice, this list of conditions and the following 16 - * disclaimer. 17 - * 18 - * - Redistributions in binary form must reproduce the above 19 - * copyright notice, this list of conditions and the following 20 - * disclaimer in the documentation and/or other materials 21 - * provided with the distribution. 22 - * 23 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27 - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28 - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 - * SOFTWARE. 3 + * Copyright (c) 2013-2020, Mellanox Technologies inc. All rights reserved. 31 4 */ 32 5 33 6 #ifndef MLX5_IB_H ··· 823 850 MLX5_IB_STAGE_IB_REG, 824 851 MLX5_IB_STAGE_POST_IB_REG_UMR, 825 852 MLX5_IB_STAGE_DELAY_DROP, 826 - MLX5_IB_STAGE_CLASS_ATTR, 853 + MLX5_IB_STAGE_RESTRACK, 827 854 MLX5_IB_STAGE_MAX, 828 855 }; 829 856 ··· 1347 1374 u8 *native_port_num); 1348 1375 void mlx5_ib_put_native_port_mdev(struct mlx5_ib_dev *dev, 1349 1376 u8 port_num); 1350 - int mlx5_ib_fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ib_mr); 1351 - int mlx5_ib_fill_res_mr_entry_raw(struct sk_buff *msg, struct ib_mr *ib_mr); 1352 - int mlx5_ib_fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ibqp); 1353 - int mlx5_ib_fill_res_cq_entry_raw(struct sk_buff *msg, struct ib_cq *ibcq); 1354 - int mlx5_ib_fill_stat_mr_entry(struct sk_buff *msg, struct ib_mr *ib_mr); 1355 1377 1356 1378 extern const struct uapi_definition mlx5_ib_devx_defs[]; 1357 1379 extern const struct uapi_definition mlx5_ib_flow_defs[];
+21 -8
drivers/infiniband/hw/mlx5/restrack.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB 2 2 /* 3 - * Copyright (c) 2019, Mellanox Technologies inc. All rights reserved. 3 + * Copyright (c) 2019-2020, Mellanox Technologies Ltd. All rights reserved. 4 4 */ 5 5 6 6 #include <uapi/rdma/rdma_netlink.h> ··· 8 8 #include <rdma/ib_umem_odp.h> 9 9 #include <rdma/restrack.h> 10 10 #include "mlx5_ib.h" 11 + #include "restrack.h" 11 12 12 13 #define MAX_DUMP_SIZE 1024 13 14 ··· 78 77 return err; 79 78 } 80 79 81 - int mlx5_ib_fill_stat_mr_entry(struct sk_buff *msg, 82 - struct ib_mr *ibmr) 80 + static int fill_stat_mr_entry(struct sk_buff *msg, struct ib_mr *ibmr) 83 81 { 84 82 struct mlx5_ib_mr *mr = to_mmr(ibmr); 85 83 struct nlattr *table_attr; ··· 112 112 return -EMSGSIZE; 113 113 } 114 114 115 - int mlx5_ib_fill_res_mr_entry_raw(struct sk_buff *msg, struct ib_mr *ibmr) 115 + static int fill_res_mr_entry_raw(struct sk_buff *msg, struct ib_mr *ibmr) 116 116 { 117 117 struct mlx5_ib_mr *mr = to_mmr(ibmr); 118 118 ··· 120 120 mlx5_mkey_to_idx(mr->mmkey.key)); 121 121 } 122 122 123 - int mlx5_ib_fill_res_mr_entry(struct sk_buff *msg, 124 - struct ib_mr *ibmr) 123 + static int fill_res_mr_entry(struct sk_buff *msg, struct ib_mr *ibmr) 125 124 { 126 125 struct mlx5_ib_mr *mr = to_mmr(ibmr); 127 126 struct nlattr *table_attr; ··· 148 149 return -EMSGSIZE; 149 150 } 150 151 151 - int mlx5_ib_fill_res_cq_entry_raw(struct sk_buff *msg, struct ib_cq *ibcq) 152 + static int fill_res_cq_entry_raw(struct sk_buff *msg, struct ib_cq *ibcq) 152 153 { 153 154 struct mlx5_ib_dev *dev = to_mdev(ibcq->device); 154 155 struct mlx5_ib_cq *cq = to_mcq(ibcq); ··· 156 157 return fill_res_raw(msg, dev, MLX5_SGMT_TYPE_PRM_QUERY_CQ, cq->mcq.cqn); 157 158 } 158 159 159 - int mlx5_ib_fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ibqp) 160 + static int fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ibqp) 160 161 { 161 162 struct mlx5_ib_dev *dev = to_mdev(ibqp->device); 162 163 163 164 return fill_res_raw(msg, dev, MLX5_SGMT_TYPE_PRM_QUERY_QP, 164 165 ibqp->qp_num); 166 + } 167 + 168 + static const struct ib_device_ops restrack_ops = { 169 + .fill_res_cq_entry_raw = fill_res_cq_entry_raw, 170 + .fill_res_mr_entry = fill_res_mr_entry, 171 + .fill_res_mr_entry_raw = fill_res_mr_entry_raw, 172 + .fill_res_qp_entry_raw = fill_res_qp_entry_raw, 173 + .fill_stat_mr_entry = fill_stat_mr_entry, 174 + }; 175 + 176 + int mlx5_ib_restrack_init(struct mlx5_ib_dev *dev) 177 + { 178 + ib_set_device_ops(&dev->ib_dev, &restrack_ops); 179 + return 0; 165 180 }
+13
drivers/infiniband/hw/mlx5/restrack.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2 + /* 3 + * Copyright (c) 2013-2020, Mellanox Technologies Ltd. All rights reserved. 4 + */ 5 + 6 + #ifndef _MLX5_IB_RESTRACK_H 7 + #define _MLX5_IB_RESTRACK_H 8 + 9 + #include "mlx5_ib.h" 10 + 11 + int mlx5_ib_restrack_init(struct mlx5_ib_dev *dev); 12 + 13 + #endif /* _MLX5_IB_RESTRACK_H */