forked from openucx/ucx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrc_mlx5.inl
More file actions
2038 lines (1755 loc) · 79.9 KB
/
Copy pathrc_mlx5.inl
File metadata and controls
2038 lines (1755 loc) · 79.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2001-2026. ALL RIGHTS RESERVED.
* Copyright (C) Advanced Micro Devices, Inc. 2024. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/
#include "rc_mlx5.h"
#include "rc_mlx5_common.h"
#include <uct/base/uct_iov.inl>
#include <uct/ib/mlx5/ib_mlx5.inl>
#include <uct/ib/mlx5/ib_mlx5_log.h>
#define UCT_RC_MLX5_EP_DECL(_tl_ep, _iface, _ep) \
uct_rc_mlx5_ep_t *_ep = ucs_derived_of(_tl_ep, uct_rc_mlx5_ep_t); \
uct_rc_mlx5_iface_common_t *_iface = ucs_derived_of(_tl_ep->iface, \
uct_rc_mlx5_iface_common_t)
#define UCT_RC_MLX5_BASE_EP_DECL(_tl_ep, _iface, _ep) \
uct_rc_mlx5_base_ep_t *_ep = ucs_derived_of(_tl_ep, uct_rc_mlx5_base_ep_t); \
uct_rc_mlx5_iface_common_t *_iface = ucs_derived_of(_tl_ep->iface, \
uct_rc_mlx5_iface_common_t)
static UCS_F_ALWAYS_INLINE size_t
uct_rc_mlx5_base_put_sgl_zcopy_max_count(uct_rc_mlx5_iface_common_t *iface)
{
size_t max_count;
/* Cap at half the QP so one SGL cannot monopolize the send queue. */
max_count = ucs_min(iface->super.config.tx_qp_len / 2, iface->tx.bb_max);
max_count = ucs_min(max_count,
uct_rc_iface_tx_cq_capacity(iface->super.config.tx_cq_len));
return max_count;
}
static UCS_F_ALWAYS_INLINE void
uct_rc_mlx5_ep_fence_put(uct_rc_mlx5_iface_common_t *iface, uct_ib_mlx5_txwq_t *txwq,
uct_rkey_t *rkey, uint64_t *addr, uint16_t offset,
uint8_t *fm_ce_se)
{
if (uct_rc_ep_fm(&iface->super, &txwq->fi, 1)) {
*fm_ce_se = iface->config.put_fence_flag;
*rkey = uct_ib_resolve_atomic_rkey(*rkey, offset, addr);
} else {
*fm_ce_se = 0;
*rkey = uct_ib_md_direct_rkey(*rkey);
}
}
static UCS_F_ALWAYS_INLINE void
uct_rc_mlx5_ep_fence_get(uct_rc_mlx5_iface_common_t *iface, uct_ib_mlx5_txwq_t *txwq,
uct_rkey_t *rkey, uint8_t *fm_ce_se)
{
*rkey = uct_ib_md_direct_rkey(*rkey);
*fm_ce_se = uct_rc_ep_fm(&iface->super, &txwq->fi,
iface->config.atomic_fence_flag);
}
static UCS_F_ALWAYS_INLINE void
uct_rc_mlx5_txqp_process_tx_cqe(uct_rc_txqp_t *txqp, struct mlx5_cqe64 *cqe,
uint16_t hw_ci)
{
if (cqe->op_own & MLX5_INLINE_SCATTER_32) {
uct_rc_txqp_completion_inl_resp(txqp, cqe, hw_ci);
} else if (cqe->op_own & MLX5_INLINE_SCATTER_64) {
uct_rc_txqp_completion_inl_resp(txqp, cqe - 1, hw_ci);
} else {
uct_rc_txqp_completion_desc(txqp, hw_ci);
}
}
static UCS_F_ALWAYS_INLINE void
uct_rc_mlx5_iface_common_rx_inline(uct_rc_mlx5_iface_common_t *iface,
uct_ib_iface_recv_desc_t *desc,
int stats_counter, unsigned byte_len)
{
UCS_STATS_UPDATE_COUNTER(iface->stats, stats_counter, 1);
VALGRIND_MAKE_MEM_UNDEFINED(uct_ib_iface_recv_desc_hdr(&iface->super.super, desc),
byte_len);
}
static UCS_F_ALWAYS_INLINE void
uct_rc_mlx5_srq_prefetch_setup(uct_rc_mlx5_iface_common_t *iface)
{
unsigned wqe_ctr = iface->rx.srq.free_idx + 2;
uct_ib_mlx5_srq_seg_t *seg;
seg = uct_ib_mlx5_srq_get_wqe(&iface->rx.srq, wqe_ctr);
iface->rx.pref_ptr =
uct_ib_iface_recv_desc_hdr(&iface->super.super, seg->srq.desc);
}
static UCS_F_NOINLINE void
uct_rc_mlx5_iface_hold_srq_desc(uct_rc_mlx5_iface_common_t *iface,
uct_ib_mlx5_srq_seg_t *seg,
struct mlx5_cqe64 *cqe, uint16_t wqe_ctr,
unsigned offset, uct_recv_desc_t *release_desc)
{
void *udesc;
int stride_idx;
int desc_offset;
if (UCT_RC_MLX5_MP_ENABLED(iface)) {
/* stride_idx is valid in non inline CQEs only.
* We can assume that stride_idx is correct here, because CQE
* with data would always force upper layer to save the data and
* return UCS_OK from the corresponding callback. */
stride_idx = uct_ib_mlx5_cqe_stride_index(cqe);
ucs_assert(stride_idx < iface->tm.mp.num_strides);
ucs_assert(!(cqe->op_own & (MLX5_INLINE_SCATTER_32 |
MLX5_INLINE_SCATTER_64)));
udesc = (void*)be64toh(seg->dptr[stride_idx].addr);
desc_offset = offset - iface->super.super.config.rx_hdr_offset;
udesc = UCS_PTR_BYTE_OFFSET(udesc, desc_offset);
uct_recv_desc(udesc) = release_desc;
seg->srq.ptr_mask &= ~UCS_BIT(stride_idx);
} else {
udesc = UCS_PTR_BYTE_OFFSET(seg->srq.desc, offset);
uct_recv_desc(udesc) = release_desc;
seg->srq.ptr_mask &= ~1;
seg->srq.desc = NULL;
}
}
static UCS_F_ALWAYS_INLINE void
uct_rc_mlx5_iface_release_srq_seg(uct_rc_mlx5_iface_common_t *iface,
uct_ib_mlx5_srq_seg_t *seg,
struct mlx5_cqe64 *cqe, uint16_t wqe_ctr,
ucs_status_t status, unsigned offset,
uct_recv_desc_t *release_desc, int poll_flags)
{
uct_ib_mlx5_srq_t *srq = &iface->rx.srq;
uint16_t wqe_index;
int seg_free;
/* Need to wrap wqe_ctr, because in case of cyclic srq topology
* it is wrapped around 0xFFFF regardless of real SRQ size.
* But it respects srq size when srq topology is a linked-list. */
wqe_index = wqe_ctr & srq->mask;
if (ucs_unlikely(status == UCS_INPROGRESS)) {
uct_rc_mlx5_iface_hold_srq_desc(iface, seg, cqe, wqe_ctr, offset,
release_desc);
}
if (UCT_RC_MLX5_MP_ENABLED(iface)) {
if (--seg->srq.strides) {
/* Segment can't be freed until all strides are consumed */
return;
}
seg->srq.strides = iface->tm.mp.num_strides;
}
++iface->super.rx.srq.available;
if (poll_flags & UCT_IB_MLX5_POLL_FLAG_LINKED_LIST) {
seg = uct_ib_mlx5_srq_get_wqe(srq, srq->free_idx);
seg->srq.next_wqe_index = htons(wqe_index);
srq->free_idx = wqe_index;
return;
}
seg_free = (seg->srq.ptr_mask == UCS_MASK(iface->tm.mp.num_strides));
if (ucs_likely(seg_free && (wqe_ctr == (srq->ready_idx + 1)))) {
/* If the descriptor was not used - if there are no "holes", we can just
* reuse it on the receive queue. Otherwise, ready pointer will stay behind
* until post_recv allocated more descriptors from the memory pool, fills
* the holes, and moves it forward.
*/
ucs_assert(wqe_ctr == (srq->free_idx + 1));
++srq->ready_idx;
++srq->free_idx;
return;
}
if (wqe_ctr == (srq->free_idx + 1)) {
++srq->free_idx;
} else {
/* Mark the segment as out-of-order, post_recv will advance free */
seg->srq.free = 1;
}
}
#define uct_rc_mlx5_iface_mp_hash_lookup(_h_name, _h_ptr, _key, _last, _flags, \
_iface) \
({ \
uct_rc_mlx5_mp_context_t *ctx; \
khiter_t h_it; \
int ret; \
h_it = kh_get(_h_name, _h_ptr, _key); \
if (h_it == kh_end(_h_ptr)) { \
/* No data from this sender - this must be the first fragment */ \
*(_flags) |= UCT_CB_PARAM_FLAG_FIRST; \
if (ucs_likely(_last)) { \
/* fast path - single fragment message */ \
return &(_iface)->tm.mp.last_frag_ctx; \
} \
h_it = kh_put(_h_name, _h_ptr, _key, &ret); \
ucs_assert(ret != UCS_KH_PUT_KEY_PRESENT); \
ctx = &kh_value(_h_ptr, h_it); \
} else { \
ctx = &kh_value(_h_ptr, h_it); \
if (_last) { \
(_iface)->tm.mp.last_frag_ctx = *ctx; \
kh_del(_h_name, _h_ptr, h_it); \
return &(_iface)->tm.mp.last_frag_ctx; \
} \
} \
*(_flags) |= UCT_CB_PARAM_FLAG_MORE; \
ctx; \
})
static UCS_F_ALWAYS_INLINE uct_rc_mlx5_mp_context_t*
uct_rc_mlx5_iface_rx_mp_context_from_ep(uct_rc_mlx5_iface_common_t *iface,
struct mlx5_cqe64 *cqe, unsigned *flags)
{
uint32_t qp_num = ntohl(cqe->sop_drop_qpn) & UCS_MASK(UCT_IB_QPN_ORDER);
uct_rc_mlx5_ep_t *ep = ucs_derived_of(uct_rc_iface_lookup_ep(&iface->super,
qp_num),
uct_rc_mlx5_ep_t);
ucs_assert(ep != NULL);
if (ep->mp.free) {
*flags |= UCT_CB_PARAM_FLAG_FIRST;
ep->mp.free = 0;
}
if (cqe->byte_cnt & htonl(UCT_IB_MLX5_MP_RQ_LAST_MSG_FLAG)) {
ucs_assert(!ep->mp.free);
ep->mp.free = 1;
} else {
*flags |= UCT_CB_PARAM_FLAG_MORE;
}
return &ep->mp;
}
static UCS_F_ALWAYS_INLINE uct_rc_mlx5_mp_context_t*
uct_rc_mlx5_iface_rx_mp_context_from_hash(uct_rc_mlx5_iface_common_t *iface,
struct mlx5_cqe64 *cqe,
unsigned *flags)
{
#if UCS_ENABLE_ASSERT
uct_ib_mlx5_md_t *md = ucs_derived_of(iface->super.super.super.md,
uct_ib_mlx5_md_t);
#endif
uct_rc_mlx5_mp_context_t *mp_ctx;
uct_rc_mlx5_mp_hash_key_t key_gid;
uint64_t key_lid;
void *gid;
int last;
if (ucs_likely(ucs_test_all_flags(cqe->byte_cnt,
htonl(UCT_IB_MLX5_MP_RQ_LAST_MSG_FLAG |
UCT_IB_MLX5_MP_RQ_FIRST_MSG_FLAG)))) {
ucs_assert(md->flags & UCT_IB_MLX5_MD_FLAG_MP_XRQ_FIRST_MSG);
*flags |= UCT_CB_PARAM_FLAG_FIRST;
return &iface->tm.mp.last_frag_ctx;
}
last = cqe->byte_cnt & htonl(UCT_IB_MLX5_MP_RQ_LAST_MSG_FLAG);
if (uct_ib_mlx5_cqe_is_grh_present(cqe)) {
gid = uct_ib_mlx5_gid_from_cqe(cqe);
/* Use guid and QP as a key. No need to fetch just qp
* and convert to le. */
key_gid.guid = *(uint64_t*)UCS_PTR_BYTE_OFFSET(gid, 8);
key_gid.qp_num = cqe->flags_rqpn;
mp_ctx = uct_rc_mlx5_iface_mp_hash_lookup(uct_rc_mlx5_mp_hash_gid,
&iface->tm.mp.hash_gid,
key_gid, last, flags,
iface);
} else {
/* Combine QP and SLID as a key. No need to fetch just qp
* and convert to le. */
key_lid = (uint64_t)cqe->flags_rqpn << 32 | cqe->slid;
mp_ctx = uct_rc_mlx5_iface_mp_hash_lookup(uct_rc_mlx5_mp_hash_lid,
&iface->tm.mp.hash_lid,
key_lid, last, flags,
iface);
}
ucs_assert(mp_ctx != NULL);
return mp_ctx;
}
static UCS_F_ALWAYS_INLINE struct mlx5_cqe64*
uct_rc_mlx5_iface_poll_rx_cq(uct_rc_mlx5_iface_common_t *iface, int poll_flags)
{
/* Prefetch the descriptor if it was scheduled */
ucs_read_prefetch(iface->rx.pref_ptr);
return uct_ib_mlx5_poll_cq(&iface->super.super, &iface->cq[UCT_IB_DIR_RX],
poll_flags,
uct_rc_mlx5_iface_check_rx_completion);
}
static UCS_F_ALWAYS_INLINE void*
uct_rc_mlx5_iface_common_data(uct_rc_mlx5_iface_common_t *iface,
struct mlx5_cqe64 *cqe,
unsigned byte_len, unsigned *flags)
{
uct_ib_mlx5_srq_seg_t *seg;
uct_ib_iface_recv_desc_t *desc;
void *hdr;
seg = uct_ib_mlx5_srq_get_wqe(&iface->rx.srq, ntohs(cqe->wqe_counter));
desc = seg->srq.desc;
/* Get a pointer to AM or Tag header (after which comes the payload)
* Support cases of inline scatter by pointing directly to CQE.
*/
if (cqe->op_own & MLX5_INLINE_SCATTER_32) {
hdr = cqe;
uct_rc_mlx5_iface_common_rx_inline(iface, desc,
UCT_RC_MLX5_IFACE_STAT_RX_INL_32,
byte_len);
*flags = 0;
} else if (cqe->op_own & MLX5_INLINE_SCATTER_64) {
hdr = cqe - 1;
uct_rc_mlx5_iface_common_rx_inline(iface, desc,
UCT_RC_MLX5_IFACE_STAT_RX_INL_64,
byte_len);
*flags = 0;
} else {
hdr = uct_ib_iface_recv_desc_hdr(&iface->super.super, desc);
VALGRIND_MAKE_MEM_DEFINED(hdr, byte_len);
*flags = UCT_CB_PARAM_FLAG_DESC;
/* Assuming that next packet likely will be non-inline,
* setup the next prefetch pointer
*/
uct_rc_mlx5_srq_prefetch_setup(iface);
}
return hdr;
}
static UCS_F_ALWAYS_INLINE uct_rc_mlx5_mp_context_t*
uct_rc_mlx5_iface_single_frag_context(uct_rc_mlx5_iface_common_t *iface,
unsigned *flags)
{
*flags |= UCT_CB_PARAM_FLAG_FIRST;
return &iface->tm.mp.last_frag_ctx;
}
static UCS_F_ALWAYS_INLINE void*
uct_rc_mlx5_iface_tm_common_data(uct_rc_mlx5_iface_common_t *iface,
struct mlx5_cqe64 *cqe, unsigned byte_len,
unsigned *flags, int poll_flags,
uct_rc_mlx5_mp_context_t **context_p)
{
uct_ib_mlx5_srq_seg_t *seg;
void *hdr;
int stride_idx;
if (!UCT_RC_MLX5_MP_ENABLED(iface)) {
/* uct_rc_mlx5_iface_common_data will initialize flags value */
hdr = uct_rc_mlx5_iface_common_data(iface, cqe, byte_len, flags);
*context_p = uct_rc_mlx5_iface_single_frag_context(iface, flags);
return hdr;
}
ucs_assert(byte_len <= UCT_IB_MLX5_MP_RQ_BYTE_CNT_MASK);
*flags = 0;
if (ucs_test_all_flags(poll_flags, UCT_IB_MLX5_POLL_FLAG_HAS_EP |
UCT_IB_MLX5_POLL_FLAG_TAG_CQE)) {
*context_p = uct_rc_mlx5_iface_rx_mp_context_from_ep(iface, cqe, flags);
} else if (poll_flags & UCT_IB_MLX5_POLL_FLAG_TAG_CQE) {
*context_p = uct_rc_mlx5_iface_rx_mp_context_from_hash(iface, cqe, flags);
} else {
/* Non-tagged messages (AM, RNDV Fin) should always arrive in
* a single fragment */
*context_p = uct_rc_mlx5_iface_single_frag_context(iface, flags);
}
/* Get a pointer to the tag header or the payload (if it is not the first
* fragment). */
if (cqe->op_own & MLX5_INLINE_SCATTER_32) {
hdr = cqe;
uct_rc_mlx5_iface_common_rx_inline(iface, NULL,
UCT_RC_MLX5_IFACE_STAT_RX_INL_32,
byte_len);
} else if (cqe->op_own & MLX5_INLINE_SCATTER_64) {
hdr = cqe - 1;
uct_rc_mlx5_iface_common_rx_inline(iface, NULL,
UCT_RC_MLX5_IFACE_STAT_RX_INL_64,
byte_len);
} else {
*flags |= UCT_CB_PARAM_FLAG_DESC;
seg = uct_ib_mlx5_srq_get_wqe(&iface->rx.srq, ntohs(cqe->wqe_counter));
stride_idx = uct_ib_mlx5_cqe_stride_index(cqe);
ucs_assert(stride_idx < iface->tm.mp.num_strides);
hdr = (void*)be64toh(seg->dptr[stride_idx].addr);
VALGRIND_MAKE_MEM_DEFINED(hdr, byte_len);
}
return hdr;
}
static UCS_F_ALWAYS_INLINE void
uct_rc_mlx5_iface_common_am_handler(uct_rc_mlx5_iface_common_t *iface,
struct mlx5_cqe64 *cqe,
uct_rc_mlx5_hdr_t *hdr, unsigned flags,
unsigned byte_len, int poll_flags)
{
uint16_t wqe_ctr;
uct_rc_iface_ops_t *rc_ops;
uct_ib_mlx5_srq_seg_t *seg;
uint32_t qp_num;
ucs_status_t status;
wqe_ctr = ntohs(cqe->wqe_counter);
seg = uct_ib_mlx5_srq_get_wqe(&iface->rx.srq, wqe_ctr);
uct_ib_mlx5_log_rx(&iface->super.super, cqe, hdr,
uct_rc_mlx5_common_packet_dump);
if (ucs_unlikely(hdr->rc_hdr.am_id & UCT_RC_EP_FC_MASK)) {
qp_num = ntohl(cqe->sop_drop_qpn) & UCS_MASK(UCT_IB_QPN_ORDER);
rc_ops = ucs_derived_of(iface->super.super.ops, uct_rc_iface_ops_t);
/* coverity[overrun-buffer-val] */
status = rc_ops->fc_handler(&iface->super, qp_num, &hdr->rc_hdr,
byte_len - sizeof(*hdr),
cqe->imm_inval_pkey, cqe->slid, flags);
} else {
status = uct_iface_invoke_am(&iface->super.super.super, hdr->rc_hdr.am_id,
hdr + 1, byte_len - sizeof(*hdr),
flags);
}
uct_rc_mlx5_iface_release_srq_seg(iface, seg, cqe, wqe_ctr, status,
iface->tm.am_desc.offset,
&iface->tm.am_desc.super, poll_flags);
}
static UCS_F_ALWAYS_INLINE uint8_t
uct_rc_mlx5_ep_fm_cq_update(uct_rc_mlx5_iface_common_t *iface,
uct_ib_mlx5_txwq_t *txwq, int flag)
{
uint8_t fm_ce_se = MLX5_WQE_CTRL_CQ_UPDATE;
fm_ce_se |= uct_rc_ep_fm(&iface->super, &txwq->fi, flag);
return fm_ce_se;
}
static UCS_F_ALWAYS_INLINE uint32_t
uct_rc_mlx5_num_packets(const uct_ib_mlx5_txwq_t *txwq,
size_t message_length)
{
ucs_assert(txwq->path_mtu_shift > 0);
return (message_length + txwq->path_mtu_mask) >> txwq->path_mtu_shift;
}
static UCS_F_ALWAYS_INLINE void
uct_rc_mlx5_txwq_add_psn(uct_ib_mlx5_txwq_t *txwq, int qp_type,
uint32_t num_packets)
{
if (qp_type == IBV_QPT_RC) {
txwq->next_wqe_psn += num_packets;
}
}
static UCS_F_ALWAYS_INLINE void
uct_rc_mlx5_txwq_update_psn(uct_ib_mlx5_txwq_t *txwq, int qp_type,
size_t message_length)
{
if (qp_type == IBV_QPT_RC) {
uct_rc_mlx5_txwq_add_psn(txwq, qp_type,
uct_rc_mlx5_num_packets(txwq,
message_length));
}
}
static UCS_F_ALWAYS_INLINE void
uct_rc_mlx5_common_post_send(uct_rc_mlx5_iface_common_t *iface, int qp_type,
uct_rc_txqp_t *txqp, uct_ib_mlx5_txwq_t *txwq,
uint8_t opcode, uint8_t opmod, uint8_t fm_ce_se,
uint16_t dci_channel, size_t wqe_size,
uint32_t imm, int max_log_sge,
uct_ib_log_sge_t *log_sge)
{
struct mlx5_wqe_ctrl_seg *ctrl;
uint16_t res_count;
if (opcode != MLX5_OPCODE_NOP) {
/* If FAILED, allow only NOP sends to be posted (used by endpoint
* flush operations) */
ucs_assert(!(txwq->flags & UCT_IB_MLX5_TXWQ_FLAG_FAILED));
}
if ((opcode == MLX5_OPCODE_SEND) || (opcode == MLX5_OPCODE_SEND_IMM)) {
uct_rc_ep_fm(&iface->super, &txwq->fi, 0);
}
ctrl = txwq->curr;
if (opcode == MLX5_OPCODE_SEND_IMM) {
uct_ib_mlx5_set_ctrl_seg_with_imm(ctrl, txwq->sw_pi, opcode, opmod,
txwq->super.qp_num, fm_ce_se,
dci_channel, wqe_size, imm);
} else {
uct_ib_mlx5_set_ctrl_seg(ctrl, txwq->sw_pi, opcode, opmod,
txwq->super.qp_num, fm_ce_se, dci_channel,
wqe_size);
}
ucs_assert(qp_type == iface->super.super.config.qp_type);
uct_ib_mlx5_log_tx(&iface->super.super, ctrl, txwq->qstart, txwq->qend,
max_log_sge, log_sge,
((opcode == MLX5_OPCODE_SEND) || (opcode == MLX5_OPCODE_SEND_IMM)) ?
uct_rc_mlx5_common_packet_dump : NULL);
res_count = uct_ib_mlx5_post_send(txwq, ctrl, wqe_size, 1);
if (fm_ce_se & MLX5_WQE_CTRL_CQ_UPDATE) {
txwq->sig_pi = txwq->prev_sw_pi;
}
#if HAVE_TL_DC
if (qp_type == UCT_IB_QPT_DCI) {
txqp->available -= res_count;
return;
}
#endif
uct_rc_txqp_posted(txqp, &iface->super, res_count, fm_ce_se & MLX5_WQE_CTRL_CQ_UPDATE);
}
static UCS_F_ALWAYS_INLINE void uct_rc_mlx5_txqp_inline_iov_post(
uct_rc_mlx5_iface_common_t *iface, int qp_type, uct_rc_txqp_t *txqp,
uct_ib_mlx5_txwq_t *txwq, const uct_iov_t *iov, size_t iovcnt,
size_t iov_length, uint8_t am_id, size_t av_size, uint16_t dci_channel)
{
struct mlx5_wqe_ctrl_seg *ctrl = txwq->curr;
struct mlx5_wqe_inl_data_seg *inl;
uct_rc_mlx5_hdr_t *rch;
size_t wqe_size, ctrl_av_size;
unsigned fm_ce_se;
ctrl_av_size = sizeof(*ctrl) + av_size;
wqe_size = ctrl_av_size + sizeof(*inl) + sizeof(*rch) + iov_length;
inl = UCS_PTR_BYTE_OFFSET(ctrl, ctrl_av_size);
inl = uct_ib_mlx5_txwq_wrap_exact(txwq, inl);
inl->byte_count = htonl((iov_length + sizeof(*rch)) | MLX5_INLINE_SEG);
rch = (uct_rc_mlx5_hdr_t*)(inl + 1);
fm_ce_se = MLX5_WQE_CTRL_SOLICITED | uct_rc_iface_tx_moderation(
&iface->super, txqp, MLX5_WQE_CTRL_CQ_UPDATE);
uct_rc_mlx5_am_hdr_fill(rch, am_id);
uct_ib_mlx5_inline_iov_copy(rch + 1, iov, iovcnt, iov_length, txwq);
uct_rc_mlx5_common_post_send(iface, qp_type, txqp, txwq, MLX5_OPCODE_SEND,
0, fm_ce_se, dci_channel, wqe_size, 0,
INT_MAX, NULL);
uct_rc_mlx5_txwq_add_psn(txwq, qp_type, 1);
}
/*
* Generic function that setups and posts WQE with inline segment
* Parameters which are not relevant to the opcode are ignored.
*
* +--------+-----+-------+--------+------------
* SEND | CTRL | INL | am_id | am_hdr | payload ...
* +--------+-----+---+---+-+-------+-----------
* RDMA_WRITE | CTRL | RADDR | INL | payload ...
* +--------+---------+-----+-------------------
*
* CTRL is mlx5_wqe_ctrl_seg for RC and
* mlx5_wqe_ctrl_seg + mlx5_wqe_datagram_seg for DC
*
* NOTE: switch is optimized away during inlining because opcode
* is a compile time constant
*/
static UCS_F_ALWAYS_INLINE void
uct_rc_mlx5_txqp_inline_post(uct_rc_mlx5_iface_common_t *iface, int qp_type,
uct_rc_txqp_t *txqp, uct_ib_mlx5_txwq_t *txwq,
unsigned opcode, const void *buffer, unsigned length,
/* SEND */ uint8_t am_id, uint64_t am_hdr, uint32_t imm_val_be,
/* RDMA */ uint64_t rdma_raddr, uct_rkey_t rdma_rkey,
size_t av_size, unsigned fm_ce_se,
uint16_t dci_channel, int max_log_sge)
{
struct mlx5_wqe_ctrl_seg *ctrl;
struct mlx5_wqe_raddr_seg *raddr;
struct mlx5_wqe_inl_data_seg *inl;
uct_rc_mlx5_am_short_hdr_t *am;
uct_rc_mlx5_hdr_t *rc_hdr;
size_t wqe_size, ctrl_av_size;
void *next_seg;
ctrl = txwq->curr;
ctrl_av_size = sizeof(*ctrl) + av_size;
next_seg = UCS_PTR_BYTE_OFFSET(ctrl, ctrl_av_size);
next_seg = uct_ib_mlx5_txwq_wrap_exact(txwq, next_seg);
switch (opcode) {
case MLX5_OPCODE_SEND_IMM:
/* Fall through to MLX5_OPCODE_SEND handler */
case MLX5_OPCODE_SEND:
/* Set inline segment which has AM id, AM header, and AM payload */
wqe_size = ctrl_av_size + sizeof(*inl) + sizeof(*am) + length;
inl = next_seg;
inl->byte_count = htonl((length + sizeof(*am)) | MLX5_INLINE_SEG);
am = (void*)(inl + 1);
am->am_hdr = am_hdr;
uct_rc_mlx5_am_hdr_fill(&am->rc_hdr, am_id);
uct_ib_mlx5_inline_copy(am + 1, buffer, length, txwq);
fm_ce_se |= uct_rc_iface_tx_moderation(&iface->super, txqp, MLX5_WQE_CTRL_CQ_UPDATE);
break;
case MLX5_OPCODE_SEND|UCT_RC_MLX5_OPCODE_FLAG_RAW:
/* Send empty AM with just AM id (used by FC) */
wqe_size = ctrl_av_size + sizeof(*inl) + sizeof(*rc_hdr);
inl = next_seg;
inl->byte_count = htonl(sizeof(*rc_hdr) | MLX5_INLINE_SEG);
rc_hdr = (void*)(inl + 1);
uct_rc_mlx5_am_hdr_fill(rc_hdr, am_id);
fm_ce_se |= uct_rc_iface_tx_moderation(&iface->super, txqp, MLX5_WQE_CTRL_CQ_UPDATE);
break;
case MLX5_OPCODE_RDMA_WRITE:
/* Set RDMA segment */
if (length == 0) {
wqe_size = ctrl_av_size + sizeof(*raddr);
} else {
wqe_size = ctrl_av_size + sizeof(*raddr) + sizeof(*inl) + length;
}
raddr = next_seg;
uct_ib_mlx5_ep_set_rdma_seg(raddr, rdma_raddr, rdma_rkey);
inl = uct_ib_mlx5_txwq_wrap_none(txwq, raddr + 1);
inl->byte_count = htonl(length | MLX5_INLINE_SEG);
uct_ib_mlx5_inline_copy(inl + 1, buffer, length, txwq);
fm_ce_se |= uct_rc_iface_tx_moderation(&iface->super, txqp, MLX5_WQE_CTRL_CQ_UPDATE);
break;
case MLX5_OPCODE_NOP:
/* Empty inline segment */
wqe_size = sizeof(*ctrl) + av_size;
inl = next_seg;
inl->byte_count = htonl(MLX5_INLINE_SEG);
fm_ce_se |= MLX5_WQE_CTRL_CQ_UPDATE | MLX5_WQE_CTRL_FENCE;
break;
default:
ucs_fatal("invalid send opcode");
}
uct_rc_mlx5_common_post_send(iface, qp_type, txqp, txwq, opcode, 0, fm_ce_se,
dci_channel, wqe_size, imm_val_be,
max_log_sge, NULL);
if (opcode != MLX5_OPCODE_NOP) {
/* Inline short operations always fit in one RC packet. */
uct_rc_mlx5_txwq_add_psn(txwq, qp_type, 1);
}
}
/*
* Generic data-pointer posting function.
* Parameters which are not relevant to the opcode are ignored.
*
* +--------+-----+-------+
* SEND | CTRL | INL | DPSEG |
* +--------+-----+---+---+----+
* RDMA_WRITE | CTRL | RADDR | DPSEG |
* +--------+---------+--------+-------+
* ATOMIC | CTRL | RADDR | ATOMIC | DPSEG |
* +--------+---------+--------+-------+
*
* CTRL is mlx5_wqe_ctrl_seg for RC and
* mlx5_wqe_ctrl_seg + mlx5_wqe_datagram_seg for DC
*
* NOTE: switch is optimized away during inlining because opcode_flags
* is a compile time constant
*/
static UCS_F_ALWAYS_INLINE void
uct_rc_mlx5_txqp_dptr_post(uct_rc_mlx5_iface_common_t *iface, int qp_type,
uct_rc_txqp_t *txqp, uct_ib_mlx5_txwq_t *txwq,
unsigned opcode_flags, const void *buffer,
unsigned length, uint32_t *lkey_p,
/* RDMA/ATOMIC */ uint64_t remote_addr, uct_rkey_t rkey,
/* ATOMIC */ uint64_t compare_mask, uint64_t compare,
/* ATOMIC */ uint64_t swap_mask, uint64_t swap_add,
size_t av_size, uint8_t fm_ce_se,
uint16_t dci_channel, uint32_t imm_val_be,
int max_log_sge, uct_ib_log_sge_t *log_sge)
{
struct mlx5_wqe_ctrl_seg *ctrl;
struct mlx5_wqe_raddr_seg *raddr;
struct mlx5_wqe_atomic_seg *atomic;
struct mlx5_wqe_data_seg *dptr;
struct uct_ib_mlx5_atomic_masked_cswap32_seg *masked_cswap32;
struct uct_ib_mlx5_atomic_masked_fadd32_seg *masked_fadd32;
struct uct_ib_mlx5_atomic_masked_cswap64_seg *masked_cswap64;
struct uct_ib_mlx5_atomic_masked_fadd64_seg *masked_fadd64;
size_t wqe_size, ctrl_av_size;
uint8_t opmod;
void *next_seg;
if (!(fm_ce_se & MLX5_WQE_CTRL_CQ_UPDATE)) {
fm_ce_se |= uct_rc_iface_tx_moderation(&iface->super, txqp, MLX5_WQE_CTRL_CQ_UPDATE);
}
opmod = 0;
ctrl = txwq->curr;
ctrl_av_size = sizeof(*ctrl) + av_size;
next_seg = UCS_PTR_BYTE_OFFSET(ctrl, ctrl_av_size);
next_seg = uct_ib_mlx5_txwq_wrap_exact(txwq, next_seg);
switch (opcode_flags) {
case MLX5_OPCODE_SEND_IMM: /* Used by tag offload */
case MLX5_OPCODE_SEND:
/* Data segment only */
ucs_assert(length < (2ul << 30));
/* TODO: make proper check for all cases TM, MP, etc
* ucs_assert(length <= iface->super.super.config.seg_size); */
wqe_size = ctrl_av_size + sizeof(struct mlx5_wqe_data_seg);
uct_ib_mlx5_set_data_seg(next_seg, buffer, length, *lkey_p);
break;
case MLX5_OPCODE_RDMA_READ:
fm_ce_se |= MLX5_WQE_CTRL_CQ_UPDATE;
/* Fall through */
case MLX5_OPCODE_RDMA_WRITE:
/* Set RDMA segment */
ucs_assert(length <= UCT_IB_MAX_MESSAGE_SIZE);
raddr = next_seg;
uct_ib_mlx5_ep_set_rdma_seg(raddr, remote_addr, rkey);
/* Data segment */
if (length == 0) {
wqe_size = ctrl_av_size + sizeof(*raddr);
uct_rc_mlx5_txwq_add_psn(txwq, qp_type, 1);
} else {
/* dptr cannot wrap, because ctrl+av could be either 2 or 4 segs */
dptr = uct_ib_mlx5_txwq_wrap_none(txwq, raddr + 1);
wqe_size = ctrl_av_size + sizeof(*raddr) + sizeof(*dptr);
uct_ib_mlx5_set_data_seg(dptr, buffer, length, *lkey_p);
}
break;
case MLX5_OPCODE_ATOMIC_FA:
case MLX5_OPCODE_ATOMIC_CS:
ucs_assert(length == sizeof(uint64_t));
raddr = next_seg;
uct_ib_mlx5_ep_set_rdma_seg(raddr, remote_addr, rkey);
/* atomic cannot wrap, because ctrl+av could be either 2 or 4 segs */
atomic = uct_ib_mlx5_txwq_wrap_none(txwq, raddr + 1);
if (opcode_flags == MLX5_OPCODE_ATOMIC_CS) {
atomic->compare = compare;
}
atomic->swap_add = swap_add;
dptr = uct_ib_mlx5_txwq_wrap_exact(txwq, atomic + 1);
uct_ib_mlx5_set_data_seg(dptr, buffer, length, *lkey_p);
wqe_size = ctrl_av_size + sizeof(*raddr) + sizeof(*atomic) +
sizeof(*dptr);
break;
case MLX5_OPCODE_ATOMIC_MASKED_CS:
raddr = next_seg;
uct_ib_mlx5_ep_set_rdma_seg(raddr, remote_addr, rkey);
switch (length) {
case sizeof(uint32_t):
opmod = UCT_IB_MLX5_OPMOD_EXT_ATOMIC(2);
masked_cswap32 = uct_ib_mlx5_txwq_wrap_none(txwq, raddr + 1);
masked_cswap32->swap = swap_add;
masked_cswap32->compare = compare;
masked_cswap32->swap_mask = swap_mask;
masked_cswap32->compare_mask = compare_mask;
dptr = uct_ib_mlx5_txwq_wrap_exact(txwq, masked_cswap32 + 1);
wqe_size = ctrl_av_size + sizeof(*raddr) +
sizeof(*masked_cswap32) + sizeof(*dptr);
break;
case sizeof(uint64_t):
opmod = UCT_IB_MLX5_OPMOD_EXT_ATOMIC(3); /* Ext. atomic, size 2**3 */
masked_cswap64 = uct_ib_mlx5_txwq_wrap_none(txwq, raddr + 1);
masked_cswap64->swap = swap_add;
masked_cswap64->compare = compare;
/* 2nd half of masked_cswap64 can wrap */
masked_cswap64 = uct_ib_mlx5_txwq_wrap_exact(txwq, masked_cswap64 + 1);
masked_cswap64->swap = swap_mask;
masked_cswap64->compare = compare_mask;
dptr = uct_ib_mlx5_txwq_wrap_exact(txwq, masked_cswap64 + 1);
wqe_size = ctrl_av_size + sizeof(*raddr) +
2 * sizeof(*masked_cswap64) + sizeof(*dptr);
break;
default:
ucs_fatal("invalid atomic type length %d", length);
}
uct_ib_mlx5_set_data_seg(dptr, buffer, length, *lkey_p);
break;
case MLX5_OPCODE_ATOMIC_MASKED_FA:
raddr = next_seg;
uct_ib_mlx5_ep_set_rdma_seg(raddr, remote_addr, rkey);
switch (length) {
case sizeof(uint32_t):
opmod = UCT_IB_MLX5_OPMOD_EXT_ATOMIC(2);
masked_fadd32 = uct_ib_mlx5_txwq_wrap_none(txwq, raddr + 1);
masked_fadd32->add = swap_add;
masked_fadd32->filed_boundary = compare;
dptr = uct_ib_mlx5_txwq_wrap_exact(txwq, masked_fadd32 + 1);
wqe_size = ctrl_av_size + sizeof(*raddr) +
sizeof(*masked_fadd32) + sizeof(*dptr);
break;
case sizeof(uint64_t):
opmod = UCT_IB_MLX5_OPMOD_EXT_ATOMIC(3); /* Ext. atomic, size 2**3 */
masked_fadd64 = uct_ib_mlx5_txwq_wrap_none(txwq, raddr + 1);
masked_fadd64->add = swap_add;
masked_fadd64->filed_boundary = compare;
dptr = uct_ib_mlx5_txwq_wrap_exact(txwq, masked_fadd64 + 1);
wqe_size = ctrl_av_size + sizeof(*raddr) +
sizeof(*masked_fadd64) + sizeof(*dptr);
break;
default:
ucs_fatal("invalid atomic type length %d", length);
}
uct_ib_mlx5_set_data_seg(dptr, buffer, length, *lkey_p);
break;
default:
ucs_fatal("invalid send opcode");
}
uct_rc_mlx5_common_post_send(iface, qp_type, txqp, txwq,
(opcode_flags & UCT_RC_MLX5_OPCODE_MASK), opmod,
fm_ce_se, dci_channel, wqe_size, imm_val_be,
max_log_sge, log_sge);
uct_rc_mlx5_txwq_update_psn(txwq, qp_type, length);
}
static UCS_F_ALWAYS_INLINE
void uct_rc_mlx5_txqp_dptr_post_iov(uct_rc_mlx5_iface_common_t *iface, int qp_type,
uct_rc_txqp_t *txqp, uct_ib_mlx5_txwq_t *txwq,
unsigned opcode_flags,
/* IOV */ const uct_iov_t *iov, size_t iovcnt,
/* SEND */ uint8_t am_id, const void *am_hdr, unsigned am_hdr_len,
/* RDMA */ uint64_t remote_addr, uct_rkey_t rkey,
/* TAG */ uct_tag_t tag, uint32_t app_ctx, uint32_t ib_imm_be,
/* MMO */ const uct_ib_mlx5_dma_opaque_mr_t *opaque_mr,
size_t av_size, uint8_t fm_ce_se,
uint16_t dci_channel, int max_log_sge)
{
struct mlx5_wqe_ctrl_seg *ctrl;
struct mlx5_wqe_raddr_seg *raddr;
struct mlx5_wqe_data_seg *dptr;
struct mlx5_wqe_inl_data_seg *inl;
uct_rc_mlx5_hdr_t *rch;
unsigned wqe_size, inl_seg_size, ctrl_av_size;
size_t iov_length, message_length;
void *next_seg;
uint8_t opmod;
#if HAVE_MLX5_MMO
uct_ib_mlx5_dma_seg_t *dma_seg;
const void *dma_src_buf, *dma_dst_buf;
uint32_t dma_src_key, dma_dst_key;
#endif
if (!(fm_ce_se & MLX5_WQE_CTRL_CQ_UPDATE)) {
fm_ce_se |= uct_rc_iface_tx_moderation(&iface->super, txqp, MLX5_WQE_CTRL_CQ_UPDATE);
}
ctrl = txwq->curr;
ctrl_av_size = sizeof(*ctrl) + av_size;
next_seg = UCS_PTR_BYTE_OFFSET(ctrl, ctrl_av_size);
next_seg = uct_ib_mlx5_txwq_wrap_exact(txwq, next_seg);
switch (opcode_flags) {
case MLX5_OPCODE_SEND:
inl_seg_size = ucs_align_up_pow2(sizeof(*inl) + sizeof(*rch) + am_hdr_len,
UCT_IB_MLX5_WQE_SEG_SIZE);
/* Inline segment with AM ID and header */
inl = next_seg;
inl->byte_count = htonl((sizeof(*rch) + am_hdr_len) | MLX5_INLINE_SEG);
rch = (uct_rc_mlx5_hdr_t *)(inl + 1);
uct_rc_mlx5_am_hdr_fill(rch, am_id);
uct_ib_mlx5_inline_copy(rch + 1, am_hdr, am_hdr_len, txwq);
/* Data segment with payload */
dptr = (struct mlx5_wqe_data_seg *)((char *)inl + inl_seg_size);
wqe_size = ctrl_av_size + inl_seg_size +
uct_ib_mlx5_set_data_seg_iov(
txwq, dptr, iov, iovcnt, &iov_length);
opmod = 0;
message_length = iov_length + sizeof(*rch) + am_hdr_len;
ucs_assert(message_length <= iface->super.super.config.seg_size);
ucs_assert(wqe_size <= UCT_IB_MLX5_MAX_SEND_WQE_SIZE);
break;
#if IBV_HW_TM
case MLX5_OPCODE_SEND|UCT_RC_MLX5_OPCODE_FLAG_TM:
case MLX5_OPCODE_SEND_IMM|UCT_RC_MLX5_OPCODE_FLAG_TM:
inl_seg_size = ucs_align_up_pow2(sizeof(*inl) + sizeof(struct ibv_tmh),
UCT_IB_MLX5_WQE_SEG_SIZE);
inl = next_seg;
inl->byte_count = htonl(sizeof(struct ibv_tmh) | MLX5_INLINE_SEG);
dptr = uct_ib_mlx5_txwq_wrap_exact(txwq, (char *)inl + inl_seg_size);
wqe_size = ctrl_av_size + inl_seg_size +
uct_ib_mlx5_set_data_seg_iov(
txwq, dptr, iov, iovcnt, &iov_length);
opmod = 0;
message_length = iov_length + sizeof(struct ibv_tmh);
uct_rc_mlx5_fill_tmh((struct ibv_tmh*)(inl + 1), tag, app_ctx,
IBV_TMH_EAGER);
ucs_assert(wqe_size <= UCT_IB_MLX5_MAX_SEND_WQE_SIZE);
break;
#endif
case MLX5_OPCODE_RDMA_READ:
fm_ce_se |= MLX5_WQE_CTRL_CQ_UPDATE;
/* Fall through */
case MLX5_OPCODE_RDMA_WRITE:
/* Set RDMA segment */
raddr = next_seg;
uct_ib_mlx5_ep_set_rdma_seg(raddr, remote_addr, rkey);
/* Data segment */
wqe_size = ctrl_av_size + sizeof(*raddr) +
uct_ib_mlx5_set_data_seg_iov(
txwq, (void*)(raddr + 1), iov, iovcnt,
&message_length);
opmod = 0;
ucs_assert(message_length <= UCT_IB_MAX_MESSAGE_SIZE);
break;
#if HAVE_MLX5_MMO
case MLX5_OPCODE_MMO|UCT_RC_MLX5_OPCODE_FLAG_MMO_PUT:
case MLX5_OPCODE_MMO|UCT_RC_MLX5_OPCODE_FLAG_MMO_GET:
ucs_assert(av_size == 0);
dma_seg = next_seg;
#if ENABLE_DEBUG_DATA
dma_seg->padding = 0xdeadbeef;
#endif
dma_seg->be_opaque_lkey = opaque_mr->be_lkey;
dma_seg->be_opaque_vaddr = opaque_mr->be_vaddr;
ucs_assertv(iovcnt == 1, "iovcnt %zu is not supported by MMO", iovcnt);
if (opcode_flags & UCT_RC_MLX5_OPCODE_FLAG_MMO_PUT) {
dma_src_buf = iov[0].buffer;
dma_src_key = uct_ib_memh_get_lkey(iov[0].memh);
dma_dst_buf = (const void*)remote_addr;
dma_dst_key = rkey;
} else /* UCT_RC_MLX5_OPCODE_FLAG_MMO_GET */ {
dma_src_buf = (const void*)remote_addr;
dma_src_key = rkey;
dma_dst_buf = iov[0].buffer;
dma_dst_key = uct_ib_memh_get_lkey(iov[0].memh);
}
dptr = uct_ib_mlx5_txwq_wrap_none(txwq, dma_seg + 1);
uct_ib_mlx5_set_data_seg(dptr /* gather segment */,
dma_src_buf, iov[0].length, dma_src_key);
dptr = uct_ib_mlx5_txwq_wrap_none(txwq, dptr + 1);
uct_ib_mlx5_set_data_seg(dptr /* scatter segment */,
dma_dst_buf, iov[0].length, dma_dst_key);
wqe_size = sizeof(*ctrl) + sizeof(*dma_seg) +
(2 * sizeof(*dptr));
opmod = UCT_IB_MLX5_OPMOD_MMO_DMA;
message_length = 0;
break;
#endif
default:
ucs_fatal("invalid send opcode");
}
uct_rc_mlx5_common_post_send(iface, qp_type, txqp, txwq,
opcode_flags & UCT_RC_MLX5_OPCODE_MASK, opmod,
fm_ce_se, dci_channel, wqe_size, ib_imm_be,
max_log_sge, NULL);
#if HAVE_MLX5_MMO
if ((opcode_flags & UCT_RC_MLX5_OPCODE_MASK) == MLX5_OPCODE_MMO) {
return;
}
#endif
uct_rc_mlx5_txwq_update_psn(txwq, qp_type, message_length);