@@ -471,6 +471,52 @@ static void mlx5e_rq_free_mpwqe_info(struct mlx5e_rq *rq)
471
471
kfree (rq -> mpwqe .info );
472
472
}
473
473
474
+ static int mlx5e_create_umr_mkey (struct mlx5e_priv * priv ,
475
+ u64 npages , u8 page_shift ,
476
+ struct mlx5_core_mkey * umr_mkey )
477
+ {
478
+ struct mlx5_core_dev * mdev = priv -> mdev ;
479
+ int inlen = MLX5_ST_SZ_BYTES (create_mkey_in );
480
+ void * mkc ;
481
+ u32 * in ;
482
+ int err ;
483
+
484
+ if (!MLX5E_VALID_NUM_MTTS (npages ))
485
+ return - EINVAL ;
486
+
487
+ in = mlx5_vzalloc (inlen );
488
+ if (!in )
489
+ return - ENOMEM ;
490
+
491
+ mkc = MLX5_ADDR_OF (create_mkey_in , in , memory_key_mkey_entry );
492
+
493
+ MLX5_SET (mkc , mkc , free , 1 );
494
+ MLX5_SET (mkc , mkc , umr_en , 1 );
495
+ MLX5_SET (mkc , mkc , lw , 1 );
496
+ MLX5_SET (mkc , mkc , lr , 1 );
497
+ MLX5_SET (mkc , mkc , access_mode , MLX5_MKC_ACCESS_MODE_MTT );
498
+
499
+ MLX5_SET (mkc , mkc , qpn , 0xffffff );
500
+ MLX5_SET (mkc , mkc , pd , mdev -> mlx5e_res .pdn );
501
+ MLX5_SET64 (mkc , mkc , len , npages << page_shift );
502
+ MLX5_SET (mkc , mkc , translations_octword_size ,
503
+ MLX5_MTT_OCTW (npages ));
504
+ MLX5_SET (mkc , mkc , log_page_size , page_shift );
505
+
506
+ err = mlx5_core_create_mkey (mdev , umr_mkey , in , inlen );
507
+
508
+ kvfree (in );
509
+ return err ;
510
+ }
511
+
512
+ static int mlx5e_create_rq_umr_mkey (struct mlx5e_rq * rq )
513
+ {
514
+ struct mlx5e_priv * priv = rq -> priv ;
515
+ u64 num_mtts = MLX5E_REQUIRED_MTTS (BIT (priv -> params .log_rq_size ));
516
+
517
+ return mlx5e_create_umr_mkey (priv , num_mtts , PAGE_SHIFT , & rq -> umr_mkey );
518
+ }
519
+
474
520
static int mlx5e_create_rq (struct mlx5e_channel * c ,
475
521
struct mlx5e_rq_param * param ,
476
522
struct mlx5e_rq * rq )
@@ -527,18 +573,20 @@ static int mlx5e_create_rq(struct mlx5e_channel *c,
527
573
rq -> alloc_wqe = mlx5e_alloc_rx_mpwqe ;
528
574
rq -> dealloc_wqe = mlx5e_dealloc_rx_mpwqe ;
529
575
530
- rq -> mpwqe .mtt_offset = c -> ix *
531
- MLX5E_REQUIRED_MTTS (1 , BIT (priv -> params .log_rq_size ));
532
-
533
576
rq -> mpwqe_stride_sz = BIT (priv -> params .mpwqe_log_stride_sz );
534
577
rq -> mpwqe_num_strides = BIT (priv -> params .mpwqe_log_num_strides );
535
578
536
579
rq -> buff .wqe_sz = rq -> mpwqe_stride_sz * rq -> mpwqe_num_strides ;
537
580
byte_count = rq -> buff .wqe_sz ;
538
- rq -> mkey_be = cpu_to_be32 ( c -> priv -> umr_mkey . key );
539
- err = mlx5e_rq_alloc_mpwqe_info (rq , c );
581
+
582
+ err = mlx5e_create_rq_umr_mkey (rq );
540
583
if (err )
541
584
goto err_rq_wq_destroy ;
585
+ rq -> mkey_be = cpu_to_be32 (rq -> umr_mkey .key );
586
+
587
+ err = mlx5e_rq_alloc_mpwqe_info (rq , c );
588
+ if (err )
589
+ goto err_destroy_umr_mkey ;
542
590
break ;
543
591
default : /* MLX5_WQ_TYPE_LINKED_LIST */
544
592
rq -> dma_info = kzalloc_node (wq_sz * sizeof (* rq -> dma_info ),
@@ -589,6 +637,9 @@ static int mlx5e_create_rq(struct mlx5e_channel *c,
589
637
590
638
return 0 ;
591
639
640
+ err_destroy_umr_mkey :
641
+ mlx5_core_destroy_mkey (mdev , & rq -> umr_mkey );
642
+
592
643
err_rq_wq_destroy :
593
644
if (rq -> xdp_prog )
594
645
bpf_prog_put (rq -> xdp_prog );
@@ -607,6 +658,7 @@ static void mlx5e_destroy_rq(struct mlx5e_rq *rq)
607
658
switch (rq -> wq_type ) {
608
659
case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ :
609
660
mlx5e_rq_free_mpwqe_info (rq );
661
+ mlx5_core_destroy_mkey (rq -> priv -> mdev , & rq -> umr_mkey );
610
662
break ;
611
663
default : /* MLX5_WQ_TYPE_LINKED_LIST */
612
664
kfree (rq -> dma_info );
@@ -1201,7 +1253,7 @@ static int mlx5e_create_cq(struct mlx5e_channel *c,
1201
1253
1202
1254
static void mlx5e_destroy_cq (struct mlx5e_cq * cq )
1203
1255
{
1204
- mlx5_wq_destroy (& cq -> wq_ctrl );
1256
+ mlx5_cqwq_destroy (& cq -> wq_ctrl );
1205
1257
}
1206
1258
1207
1259
static int mlx5e_enable_cq (struct mlx5e_cq * cq , struct mlx5e_cq_param * param )
@@ -1218,7 +1270,7 @@ static int mlx5e_enable_cq(struct mlx5e_cq *cq, struct mlx5e_cq_param *param)
1218
1270
int err ;
1219
1271
1220
1272
inlen = MLX5_ST_SZ_BYTES (create_cq_in ) +
1221
- sizeof (u64 ) * cq -> wq_ctrl .buf .npages ;
1273
+ sizeof (u64 ) * cq -> wq_ctrl .frag_buf .npages ;
1222
1274
in = mlx5_vzalloc (inlen );
1223
1275
if (!in )
1224
1276
return - ENOMEM ;
@@ -1227,15 +1279,15 @@ static int mlx5e_enable_cq(struct mlx5e_cq *cq, struct mlx5e_cq_param *param)
1227
1279
1228
1280
memcpy (cqc , param -> cqc , sizeof (param -> cqc ));
1229
1281
1230
- mlx5_fill_page_array (& cq -> wq_ctrl .buf ,
1231
- (__be64 * )MLX5_ADDR_OF (create_cq_in , in , pas ));
1282
+ mlx5_fill_page_frag_array (& cq -> wq_ctrl .frag_buf ,
1283
+ (__be64 * )MLX5_ADDR_OF (create_cq_in , in , pas ));
1232
1284
1233
1285
mlx5_vector2eqn (mdev , param -> eq_ix , & eqn , & irqn_not_used );
1234
1286
1235
1287
MLX5_SET (cqc , cqc , cq_period_mode , param -> cq_period_mode );
1236
1288
MLX5_SET (cqc , cqc , c_eqn , eqn );
1237
1289
MLX5_SET (cqc , cqc , uar_page , mcq -> uar -> index );
1238
- MLX5_SET (cqc , cqc , log_page_size , cq -> wq_ctrl .buf .page_shift -
1290
+ MLX5_SET (cqc , cqc , log_page_size , cq -> wq_ctrl .frag_buf .page_shift -
1239
1291
MLX5_ADAPTER_PAGE_SHIFT );
1240
1292
MLX5_SET64 (cqc , cqc , dbr_addr , cq -> wq_ctrl .db .dma );
1241
1293
@@ -3625,43 +3677,6 @@ static void mlx5e_destroy_q_counter(struct mlx5e_priv *priv)
3625
3677
mlx5_core_dealloc_q_counter (priv -> mdev , priv -> q_counter );
3626
3678
}
3627
3679
3628
- static int mlx5e_create_umr_mkey (struct mlx5e_priv * priv )
3629
- {
3630
- struct mlx5_core_dev * mdev = priv -> mdev ;
3631
- u64 npages = MLX5E_REQUIRED_MTTS (priv -> profile -> max_nch (mdev ),
3632
- BIT (MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW ));
3633
- int inlen = MLX5_ST_SZ_BYTES (create_mkey_in );
3634
- void * mkc ;
3635
- u32 * in ;
3636
- int err ;
3637
-
3638
- in = mlx5_vzalloc (inlen );
3639
- if (!in )
3640
- return - ENOMEM ;
3641
-
3642
- mkc = MLX5_ADDR_OF (create_mkey_in , in , memory_key_mkey_entry );
3643
-
3644
- npages = min_t (u32 , ALIGN (U16_MAX , 4 ) * 2 , npages );
3645
-
3646
- MLX5_SET (mkc , mkc , free , 1 );
3647
- MLX5_SET (mkc , mkc , umr_en , 1 );
3648
- MLX5_SET (mkc , mkc , lw , 1 );
3649
- MLX5_SET (mkc , mkc , lr , 1 );
3650
- MLX5_SET (mkc , mkc , access_mode , MLX5_MKC_ACCESS_MODE_MTT );
3651
-
3652
- MLX5_SET (mkc , mkc , qpn , 0xffffff );
3653
- MLX5_SET (mkc , mkc , pd , mdev -> mlx5e_res .pdn );
3654
- MLX5_SET64 (mkc , mkc , len , npages << PAGE_SHIFT );
3655
- MLX5_SET (mkc , mkc , translations_octword_size ,
3656
- MLX5_MTT_OCTW (npages ));
3657
- MLX5_SET (mkc , mkc , log_page_size , PAGE_SHIFT );
3658
-
3659
- err = mlx5_core_create_mkey (mdev , & priv -> umr_mkey , in , inlen );
3660
-
3661
- kvfree (in );
3662
- return err ;
3663
- }
3664
-
3665
3680
static void mlx5e_nic_init (struct mlx5_core_dev * mdev ,
3666
3681
struct net_device * netdev ,
3667
3682
const struct mlx5e_profile * profile ,
@@ -3868,15 +3883,9 @@ int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
3868
3883
profile = priv -> profile ;
3869
3884
clear_bit (MLX5E_STATE_DESTROYING , & priv -> state );
3870
3885
3871
- err = mlx5e_create_umr_mkey (priv );
3872
- if (err ) {
3873
- mlx5_core_err (mdev , "create umr mkey failed, %d\n" , err );
3874
- goto out ;
3875
- }
3876
-
3877
3886
err = profile -> init_tx (priv );
3878
3887
if (err )
3879
- goto err_destroy_umr_mkey ;
3888
+ goto out ;
3880
3889
3881
3890
err = mlx5e_open_drop_rq (priv );
3882
3891
if (err ) {
@@ -3916,9 +3925,6 @@ int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
3916
3925
err_cleanup_tx :
3917
3926
profile -> cleanup_tx (priv );
3918
3927
3919
- err_destroy_umr_mkey :
3920
- mlx5_core_destroy_mkey (mdev , & priv -> umr_mkey );
3921
-
3922
3928
out :
3923
3929
return err ;
3924
3930
}
@@ -3967,7 +3973,6 @@ void mlx5e_detach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
3967
3973
profile -> cleanup_rx (priv );
3968
3974
mlx5e_close_drop_rq (priv );
3969
3975
profile -> cleanup_tx (priv );
3970
- mlx5_core_destroy_mkey (priv -> mdev , & priv -> umr_mkey );
3971
3976
cancel_delayed_work_sync (& priv -> update_stats_work );
3972
3977
}
3973
3978
0 commit comments