@@ -66,15 +66,13 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
6666 struct ib_device_attr * props )
6767{
6868 struct mlx5_ib_dev * dev = to_mdev (ibdev );
69+ struct mlx5_core_dev * mdev = dev -> mdev ;
6970 struct ib_smp * in_mad = NULL ;
7071 struct ib_smp * out_mad = NULL ;
71- struct mlx5_general_caps * gen ;
7272 int err = - ENOMEM ;
7373 int max_rq_sg ;
7474 int max_sq_sg ;
75- u64 flags ;
7675
77- gen = & dev -> mdev -> caps .gen ;
7876 in_mad = kzalloc (sizeof (* in_mad ), GFP_KERNEL );
7977 out_mad = kmalloc (sizeof (* out_mad ), GFP_KERNEL );
8078 if (!in_mad || !out_mad )
@@ -96,18 +94,18 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
9694 IB_DEVICE_PORT_ACTIVE_EVENT |
9795 IB_DEVICE_SYS_IMAGE_GUID |
9896 IB_DEVICE_RC_RNR_NAK_GEN ;
99- flags = gen -> flags ;
100- if (flags & MLX5_DEV_CAP_FLAG_BAD_PKEY_CNTR )
97+
98+ if (MLX5_CAP_GEN ( mdev , pkv ) )
10199 props -> device_cap_flags |= IB_DEVICE_BAD_PKEY_CNTR ;
102- if (flags & MLX5_DEV_CAP_FLAG_BAD_QKEY_CNTR )
100+ if (MLX5_CAP_GEN ( mdev , qkv ) )
103101 props -> device_cap_flags |= IB_DEVICE_BAD_QKEY_CNTR ;
104- if (flags & MLX5_DEV_CAP_FLAG_APM )
102+ if (MLX5_CAP_GEN ( mdev , apm ) )
105103 props -> device_cap_flags |= IB_DEVICE_AUTO_PATH_MIG ;
106104 props -> device_cap_flags |= IB_DEVICE_LOCAL_DMA_LKEY ;
107- if (flags & MLX5_DEV_CAP_FLAG_XRC )
105+ if (MLX5_CAP_GEN ( mdev , xrc ) )
108106 props -> device_cap_flags |= IB_DEVICE_XRC ;
109107 props -> device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS ;
110- if (flags & MLX5_DEV_CAP_FLAG_SIG_HAND_OVER ) {
108+ if (MLX5_CAP_GEN ( mdev , sho ) ) {
111109 props -> device_cap_flags |= IB_DEVICE_SIGNATURE_HANDOVER ;
112110 /* At this stage no support for signature handover */
113111 props -> sig_prot_cap = IB_PROT_T10DIF_TYPE_1 |
@@ -116,7 +114,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
116114 props -> sig_guard_cap = IB_GUARD_T10DIF_CRC |
117115 IB_GUARD_T10DIF_CSUM ;
118116 }
119- if (flags & MLX5_DEV_CAP_FLAG_BLOCK_MCAST )
117+ if (MLX5_CAP_GEN ( mdev , block_lb_mc ) )
120118 props -> device_cap_flags |= IB_DEVICE_BLOCK_MULTICAST_LOOPBACK ;
121119
122120 props -> vendor_id = be32_to_cpup ((__be32 * )(out_mad -> data + 36 )) &
@@ -126,37 +124,38 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
126124 memcpy (& props -> sys_image_guid , out_mad -> data + 4 , 8 );
127125
128126 props -> max_mr_size = ~0ull ;
129- props -> page_size_cap = gen -> min_page_sz ;
130- props -> max_qp = 1 << gen -> log_max_qp ;
131- props -> max_qp_wr = gen -> max_wqes ;
132- max_rq_sg = gen -> max_rq_desc_sz / sizeof (struct mlx5_wqe_data_seg );
133- max_sq_sg = (gen -> max_sq_desc_sz - sizeof (struct mlx5_wqe_ctrl_seg )) /
134- sizeof (struct mlx5_wqe_data_seg );
127+ props -> page_size_cap = 1ull << MLX5_CAP_GEN (mdev , log_pg_sz );
128+ props -> max_qp = 1 << MLX5_CAP_GEN (mdev , log_max_qp );
129+ props -> max_qp_wr = 1 << MLX5_CAP_GEN (mdev , log_max_qp_sz );
130+ max_rq_sg = MLX5_CAP_GEN (mdev , max_wqe_sz_rq ) /
131+ sizeof (struct mlx5_wqe_data_seg );
132+ max_sq_sg = (MLX5_CAP_GEN (mdev , max_wqe_sz_sq ) -
133+ sizeof (struct mlx5_wqe_ctrl_seg )) /
134+ sizeof (struct mlx5_wqe_data_seg );
135135 props -> max_sge = min (max_rq_sg , max_sq_sg );
136- props -> max_cq = 1 << gen -> log_max_cq ;
137- props -> max_cqe = gen -> max_cqes - 1 ;
138- props -> max_mr = 1 << gen -> log_max_mkey ;
139- props -> max_pd = 1 << gen -> log_max_pd ;
140- props -> max_qp_rd_atom = 1 << gen -> log_max_ra_req_qp ;
141- props -> max_qp_init_rd_atom = 1 << gen -> log_max_ra_res_qp ;
142- props -> max_srq = 1 << gen -> log_max_srq ;
143- props -> max_srq_wr = gen -> max_srq_wqes - 1 ;
144- props -> local_ca_ack_delay = gen -> local_ca_ack_delay ;
136+ props -> max_cq = 1 << MLX5_CAP_GEN ( mdev , log_max_cq ) ;
137+ props -> max_cqe = ( 1 << MLX5_CAP_GEN ( mdev , log_max_eq_sz )) - 1 ;
138+ props -> max_mr = 1 << MLX5_CAP_GEN ( mdev , log_max_mkey ) ;
139+ props -> max_pd = 1 << MLX5_CAP_GEN ( mdev , log_max_pd ) ;
140+ props -> max_qp_rd_atom = 1 << MLX5_CAP_GEN ( mdev , log_max_ra_req_qp ) ;
141+ props -> max_qp_init_rd_atom = 1 << MLX5_CAP_GEN ( mdev , log_max_ra_res_qp ) ;
142+ props -> max_srq = 1 << MLX5_CAP_GEN ( mdev , log_max_srq ) ;
143+ props -> max_srq_wr = ( 1 << MLX5_CAP_GEN ( mdev , log_max_srq_sz )) - 1 ;
144+ props -> local_ca_ack_delay = MLX5_CAP_GEN ( mdev , local_ca_ack_delay ) ;
145145 props -> max_res_rd_atom = props -> max_qp_rd_atom * props -> max_qp ;
146146 props -> max_srq_sge = max_rq_sg - 1 ;
147147 props -> max_fast_reg_page_list_len = (unsigned int )-1 ;
148- props -> local_ca_ack_delay = gen -> local_ca_ack_delay ;
149148 props -> atomic_cap = IB_ATOMIC_NONE ;
150149 props -> masked_atomic_cap = IB_ATOMIC_NONE ;
151150 props -> max_pkeys = be16_to_cpup ((__be16 * )(out_mad -> data + 28 ));
152- props -> max_mcast_grp = 1 << gen -> log_max_mcg ;
153- props -> max_mcast_qp_attach = gen -> max_qp_mcg ;
151+ props -> max_mcast_grp = 1 << MLX5_CAP_GEN ( mdev , log_max_mcg ) ;
152+ props -> max_mcast_qp_attach = MLX5_CAP_GEN ( mdev , max_qp_mcg ) ;
154153 props -> max_total_mcast_qp_attach = props -> max_mcast_qp_attach *
155154 props -> max_mcast_grp ;
156155 props -> max_map_per_fmr = INT_MAX ; /* no limit in ConnectIB */
157156
158157#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
159- if (dev -> mdev -> caps . gen . flags & MLX5_DEV_CAP_FLAG_ON_DMND_PG )
158+ if (MLX5_CAP_GEN ( mdev , pg ) )
160159 props -> device_cap_flags |= IB_DEVICE_ON_DEMAND_PAGING ;
161160 props -> odp_caps = dev -> odp_caps ;
162161#endif
@@ -172,14 +171,13 @@ int mlx5_ib_query_port(struct ib_device *ibdev, u8 port,
172171 struct ib_port_attr * props )
173172{
174173 struct mlx5_ib_dev * dev = to_mdev (ibdev );
174+ struct mlx5_core_dev * mdev = dev -> mdev ;
175175 struct ib_smp * in_mad = NULL ;
176176 struct ib_smp * out_mad = NULL ;
177- struct mlx5_general_caps * gen ;
178177 int ext_active_speed ;
179178 int err = - ENOMEM ;
180179
181- gen = & dev -> mdev -> caps .gen ;
182- if (port < 1 || port > gen -> num_ports ) {
180+ if (port < 1 || port > MLX5_CAP_GEN (mdev , num_ports )) {
183181 mlx5_ib_warn (dev , "invalid port number %d\n" , port );
184182 return - EINVAL ;
185183 }
@@ -210,8 +208,8 @@ int mlx5_ib_query_port(struct ib_device *ibdev, u8 port,
210208 props -> phys_state = out_mad -> data [33 ] >> 4 ;
211209 props -> port_cap_flags = be32_to_cpup ((__be32 * )(out_mad -> data + 20 ));
212210 props -> gid_tbl_len = out_mad -> data [50 ];
213- props -> max_msg_sz = 1 << gen -> log_max_msg ;
214- props -> pkey_tbl_len = gen -> port [port - 1 ].pkey_table_len ;
211+ props -> max_msg_sz = 1 << MLX5_CAP_GEN ( mdev , log_max_msg ) ;
212+ props -> pkey_tbl_len = mdev -> port_caps [port - 1 ].pkey_table_len ;
215213 props -> bad_pkey_cntr = be16_to_cpup ((__be16 * )(out_mad -> data + 46 ));
216214 props -> qkey_viol_cntr = be16_to_cpup ((__be16 * )(out_mad -> data + 48 ));
217215 props -> active_width = out_mad -> data [31 ] & 0xf ;
@@ -238,7 +236,7 @@ int mlx5_ib_query_port(struct ib_device *ibdev, u8 port,
238236
239237 /* If reported active speed is QDR, check if is FDR-10 */
240238 if (props -> active_speed == 4 ) {
241- if (gen -> ext_port_cap [port - 1 ] &
239+ if (mdev -> port_caps [port - 1 ]. ext_port_cap &
242240 MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO ) {
243241 init_query_mad (in_mad );
244242 in_mad -> attr_id = MLX5_ATTR_EXTENDED_PORT_INFO ;
@@ -392,7 +390,6 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
392390 struct mlx5_ib_alloc_ucontext_req_v2 req ;
393391 struct mlx5_ib_alloc_ucontext_resp resp ;
394392 struct mlx5_ib_ucontext * context ;
395- struct mlx5_general_caps * gen ;
396393 struct mlx5_uuar_info * uuari ;
397394 struct mlx5_uar * uars ;
398395 int gross_uuars ;
@@ -403,7 +400,6 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
403400 int i ;
404401 size_t reqlen ;
405402
406- gen = & dev -> mdev -> caps .gen ;
407403 if (!dev -> ib_active )
408404 return ERR_PTR (- EAGAIN );
409405
@@ -436,14 +432,14 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
436432
437433 num_uars = req .total_num_uuars / MLX5_NON_FP_BF_REGS_PER_PAGE ;
438434 gross_uuars = num_uars * MLX5_BF_REGS_PER_PAGE ;
439- resp .qp_tab_size = 1 << gen -> log_max_qp ;
440- resp .bf_reg_size = gen -> bf_reg_size ;
441- resp .cache_line_size = L1_CACHE_BYTES ;
442- resp .max_sq_desc_sz = gen -> max_sq_desc_sz ;
443- resp .max_rq_desc_sz = gen -> max_rq_desc_sz ;
444- resp .max_send_wqebb = gen -> max_wqes ;
445- resp .max_recv_wr = gen -> max_wqes ;
446- resp .max_srq_recv_wr = gen -> max_srq_wqes ;
435+ resp .qp_tab_size = 1 << MLX5_CAP_GEN ( dev -> mdev , log_max_qp ) ;
436+ resp .bf_reg_size = 1 << MLX5_CAP_GEN ( dev -> mdev , log_bf_reg_size ) ;
437+ resp .cache_line_size = L1_CACHE_BYTES ;
438+ resp .max_sq_desc_sz = MLX5_CAP_GEN ( dev -> mdev , max_wqe_sz_sq ) ;
439+ resp .max_rq_desc_sz = MLX5_CAP_GEN ( dev -> mdev , max_wqe_sz_rq ) ;
440+ resp .max_send_wqebb = 1 << MLX5_CAP_GEN ( dev -> mdev , log_max_qp_sz ) ;
441+ resp .max_recv_wr = 1 << MLX5_CAP_GEN ( dev -> mdev , log_max_qp_sz ) ;
442+ resp .max_srq_recv_wr = 1 << MLX5_CAP_GEN ( dev -> mdev , log_max_srq_sz ) ;
447443
448444 context = kzalloc (sizeof (* context ), GFP_KERNEL );
449445 if (!context )
@@ -493,7 +489,7 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
493489 mutex_init (& context -> db_page_mutex );
494490
495491 resp .tot_uuars = req .total_num_uuars ;
496- resp .num_ports = gen -> num_ports ;
492+ resp .num_ports = MLX5_CAP_GEN ( dev -> mdev , num_ports ) ;
497493 err = ib_copy_to_udata (udata , & resp ,
498494 sizeof (resp ) - sizeof (resp .reserved ));
499495 if (err )
@@ -895,23 +891,19 @@ static void mlx5_ib_event(struct mlx5_core_dev *dev, void *context,
895891
896892static void get_ext_port_caps (struct mlx5_ib_dev * dev )
897893{
898- struct mlx5_general_caps * gen ;
899894 int port ;
900895
901- gen = & dev -> mdev -> caps .gen ;
902- for (port = 1 ; port <= gen -> num_ports ; port ++ )
896+ for (port = 1 ; port <= MLX5_CAP_GEN (dev -> mdev , num_ports ); port ++ )
903897 mlx5_query_ext_port_caps (dev , port );
904898}
905899
906900static int get_port_caps (struct mlx5_ib_dev * dev )
907901{
908902 struct ib_device_attr * dprops = NULL ;
909903 struct ib_port_attr * pprops = NULL ;
910- struct mlx5_general_caps * gen ;
911904 int err = - ENOMEM ;
912905 int port ;
913906
914- gen = & dev -> mdev -> caps .gen ;
915907 pprops = kmalloc (sizeof (* pprops ), GFP_KERNEL );
916908 if (!pprops )
917909 goto out ;
@@ -926,14 +918,17 @@ static int get_port_caps(struct mlx5_ib_dev *dev)
926918 goto out ;
927919 }
928920
929- for (port = 1 ; port <= gen -> num_ports ; port ++ ) {
921+ for (port = 1 ; port <= MLX5_CAP_GEN ( dev -> mdev , num_ports ) ; port ++ ) {
930922 err = mlx5_ib_query_port (& dev -> ib_dev , port , pprops );
931923 if (err ) {
932- mlx5_ib_warn (dev , "query_port %d failed %d\n" , port , err );
924+ mlx5_ib_warn (dev , "query_port %d failed %d\n" ,
925+ port , err );
933926 break ;
934927 }
935- gen -> port [port - 1 ].pkey_table_len = dprops -> max_pkeys ;
936- gen -> port [port - 1 ].gid_table_len = pprops -> gid_tbl_len ;
928+ dev -> mdev -> port_caps [port - 1 ].pkey_table_len =
929+ dprops -> max_pkeys ;
930+ dev -> mdev -> port_caps [port - 1 ].gid_table_len =
931+ pprops -> gid_tbl_len ;
937932 mlx5_ib_dbg (dev , "pkey_table_len %d, gid_table_len %d\n" ,
938933 dprops -> max_pkeys , pprops -> gid_tbl_len );
939934 }
@@ -1207,8 +1202,8 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
12071202 strlcpy (dev -> ib_dev .name , "mlx5_%d" , IB_DEVICE_NAME_MAX );
12081203 dev -> ib_dev .owner = THIS_MODULE ;
12091204 dev -> ib_dev .node_type = RDMA_NODE_IB_CA ;
1210- dev -> ib_dev .local_dma_lkey = mdev -> caps . gen . reserved_lkey ;
1211- dev -> num_ports = mdev -> caps . gen . num_ports ;
1205+ dev -> ib_dev .local_dma_lkey = 0 /* not supported for now */ ;
1206+ dev -> num_ports = MLX5_CAP_GEN ( mdev , num_ports ) ;
12121207 dev -> ib_dev .phys_port_cnt = dev -> num_ports ;
12131208 dev -> ib_dev .num_comp_vectors =
12141209 dev -> mdev -> priv .eq_table .num_comp_vectors ;
@@ -1286,9 +1281,9 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
12861281 dev -> ib_dev .free_fast_reg_page_list = mlx5_ib_free_fast_reg_page_list ;
12871282 dev -> ib_dev .check_mr_status = mlx5_ib_check_mr_status ;
12881283
1289- mlx5_ib_internal_query_odp_caps (dev );
1284+ mlx5_ib_internal_fill_odp_caps (dev );
12901285
1291- if (mdev -> caps . gen . flags & MLX5_DEV_CAP_FLAG_XRC ) {
1286+ if (MLX5_CAP_GEN ( mdev , xrc ) ) {
12921287 dev -> ib_dev .alloc_xrcd = mlx5_ib_alloc_xrcd ;
12931288 dev -> ib_dev .dealloc_xrcd = mlx5_ib_dealloc_xrcd ;
12941289 dev -> ib_dev .uverbs_cmd_mask |=
0 commit comments