@@ -21,6 +21,24 @@ static inline int efa_rma_check_cap(struct efa_base_ep *base_ep) {
21
21
return - FI_EOPNOTSUPP ;
22
22
}
23
23
24
+ /**
25
+ * @brief Check whether the device supports the given iov_count for rdma work request
26
+ *
27
+ * @param base_ep pointer of efa_base_ep
28
+ * @param count the iov count of the msg
29
+ * @return int 0 on success, -FI_EOPNOTSUPP on failure
30
+ */
31
+ static inline int efa_rma_check_iov_count (struct efa_base_ep * base_ep , size_t count )
32
+ {
33
+ size_t max_sge = MIN (EFA_DEVICE_MAX_RDMA_SGE , base_ep -> domain -> device -> ibv_attr .max_sge_rd );
34
+
35
+ if (OFI_UNLIKELY (count > max_sge )) {
36
+ EFA_WARN (FI_LOG_EP_DATA , "EFA device currently doesn't support > %zu iov for rdma work request\n" , max_sge );
37
+ return - FI_EOPNOTSUPP ;
38
+ }
39
+ return 0 ;
40
+ }
41
+
24
42
/*
25
43
* efa_rma_post_read() will post a read request.
26
44
*
@@ -56,8 +74,6 @@ static inline ssize_t efa_rma_post_read(struct efa_base_ep *base_ep,
56
74
ofi_total_iov_len (msg -> msg_iov , msg -> iov_count ),
57
75
msg -> addr , (size_t ) msg -> context , flags );
58
76
59
- assert (msg -> iov_count > 0 &&
60
- msg -> iov_count <= base_ep -> domain -> info -> tx_attr -> iov_limit );
61
77
assert (msg -> rma_iov_count > 0 &&
62
78
msg -> rma_iov_count <= base_ep -> domain -> info -> tx_attr -> rma_iov_limit );
63
79
assert (ofi_total_iov_len (msg -> msg_iov , msg -> iov_count ) <=
@@ -124,6 +140,10 @@ ssize_t efa_rma_readmsg(struct fid_ep *ep_fid, const struct fi_msg_rma *msg, uin
124
140
if (err )
125
141
return err ;
126
142
143
+ err = efa_rma_check_iov_count (base_ep , msg -> iov_count );
144
+ if (err )
145
+ return err ;
146
+
127
147
return efa_rma_post_read (base_ep , msg , flags | base_ep -> util_ep .tx_msg_flags );
128
148
}
129
149
@@ -143,6 +163,10 @@ ssize_t efa_rma_readv(struct fid_ep *ep_fid, const struct iovec *iov, void **des
143
163
if (err )
144
164
return err ;
145
165
166
+ err = efa_rma_check_iov_count (base_ep , iov_count );
167
+ if (err )
168
+ return err ;
169
+
146
170
len = ofi_total_iov_len (iov , iov_count );
147
171
EFA_SETUP_RMA_IOV (rma_iov , addr , len , key );
148
172
EFA_SETUP_MSG_RMA (msg , iov , desc , iov_count , src_addr , & rma_iov , 1 ,
@@ -277,6 +301,10 @@ ssize_t efa_rma_writemsg(struct fid_ep *ep_fid, const struct fi_msg_rma *msg,
277
301
if (err )
278
302
return err ;
279
303
304
+ err = efa_rma_check_iov_count (base_ep , msg -> iov_count );
305
+ if (err )
306
+ return err ;
307
+
280
308
return efa_rma_post_write (base_ep , msg , flags | base_ep -> util_ep .tx_msg_flags );
281
309
}
282
310
@@ -295,6 +323,10 @@ ssize_t efa_rma_writev(struct fid_ep *ep_fid, const struct iovec *iov,
295
323
if (err )
296
324
return err ;
297
325
326
+ err = efa_rma_check_iov_count (base_ep , iov_count );
327
+ if (err )
328
+ return err ;
329
+
298
330
len = ofi_total_iov_len (iov , iov_count );
299
331
EFA_SETUP_RMA_IOV (rma_iov , addr , len , key );
300
332
EFA_SETUP_MSG_RMA (msg , iov , desc , iov_count , dest_addr , & rma_iov , 1 ,
0 commit comments