@@ -21,6 +21,24 @@ static inline int efa_rma_check_cap(struct efa_base_ep *base_ep) {
2121 return - FI_EOPNOTSUPP ;
2222}
2323
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+
2442/*
2543 * efa_rma_post_read() will post a read request.
2644 *
@@ -56,8 +74,6 @@ static inline ssize_t efa_rma_post_read(struct efa_base_ep *base_ep,
5674 ofi_total_iov_len (msg -> msg_iov , msg -> iov_count ),
5775 msg -> addr , (size_t ) msg -> context , flags );
5876
59- assert (msg -> iov_count > 0 &&
60- msg -> iov_count <= base_ep -> domain -> info -> tx_attr -> iov_limit );
6177 assert (msg -> rma_iov_count > 0 &&
6278 msg -> rma_iov_count <= base_ep -> domain -> info -> tx_attr -> rma_iov_limit );
6379 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
124140 if (err )
125141 return err ;
126142
143+ err = efa_rma_check_iov_count (base_ep , msg -> iov_count );
144+ if (err )
145+ return err ;
146+
127147 return efa_rma_post_read (base_ep , msg , flags | base_ep -> util_ep .tx_msg_flags );
128148}
129149
@@ -143,6 +163,10 @@ ssize_t efa_rma_readv(struct fid_ep *ep_fid, const struct iovec *iov, void **des
143163 if (err )
144164 return err ;
145165
166+ err = efa_rma_check_iov_count (base_ep , iov_count );
167+ if (err )
168+ return err ;
169+
146170 len = ofi_total_iov_len (iov , iov_count );
147171 EFA_SETUP_RMA_IOV (rma_iov , addr , len , key );
148172 EFA_SETUP_MSG_RMA (msg , iov , desc , iov_count , src_addr , & rma_iov , 1 ,
@@ -207,6 +231,11 @@ static inline ssize_t efa_rma_post_write(struct efa_base_ep *base_ep,
207231 return - FI_ENOSYS ;
208232 }
209233
234+ if (OFI_UNLIKELY (msg -> iov_count > base_ep -> domain -> device -> ibv_attr .max_sge_rd )) {
235+ EFA_WARN (FI_LOG_EP_DATA , "EFA device currently doesn't support > %d iov for rdma work request\n" , base_ep -> domain -> device -> ibv_attr .max_sge_rd );
236+ return - FI_EINVAL ;
237+ }
238+
210239 efa_tracepoint (write_begin_msg_context , (size_t ) msg -> context , (size_t ) msg -> addr );
211240
212241 EFA_DBG (FI_LOG_EP_DATA ,
@@ -277,6 +306,10 @@ ssize_t efa_rma_writemsg(struct fid_ep *ep_fid, const struct fi_msg_rma *msg,
277306 if (err )
278307 return err ;
279308
309+ err = efa_rma_check_iov_count (base_ep , msg -> iov_count );
310+ if (err )
311+ return err ;
312+
280313 return efa_rma_post_write (base_ep , msg , flags | base_ep -> util_ep .tx_msg_flags );
281314}
282315
@@ -295,6 +328,10 @@ ssize_t efa_rma_writev(struct fid_ep *ep_fid, const struct iovec *iov,
295328 if (err )
296329 return err ;
297330
331+ err = efa_rma_check_iov_count (base_ep , iov_count );
332+ if (err )
333+ return err ;
334+
298335 len = ofi_total_iov_len (iov , iov_count );
299336 EFA_SETUP_RMA_IOV (rma_iov , addr , len , key );
300337 EFA_SETUP_MSG_RMA (msg , iov , desc , iov_count , dest_addr , & rma_iov , 1 ,
0 commit comments