cur_idx = vq->last_avail_idx;
if (rxvq_is_mergeable(dev))
- max_tries = vq->size;
+ max_tries = vq->size - 1;
else
max_tries = 1;
while (size > 0) {
if (unlikely(cur_idx == avail_head))
return -1;
+ /*
+ * if we tried all available ring items, and still
+ * can't get enough buf, it means something abnormal
+ * happened.
+ */
+ if (unlikely(++tries > max_tries))
+ return -1;
if (unlikely(fill_vec_buf_split(dev, vq, cur_idx,
&vec_idx, buf_vec,
size -= len;
cur_idx++;
- tries++;
*num_buffers += 1;
-
- /*
- * if we tried all available ring items, and still
- * can't get enough buf, it means something abnormal
- * happened.
- */
- if (unlikely(tries > max_tries))
- return -1;
}
*nr_vec = vec_idx;
avail_idx = vq->last_avail_idx;
if (rxvq_is_mergeable(dev))
- max_tries = vq->size;
+ max_tries = vq->size - 1;
else
max_tries = 1;
while (size > 0) {
+ /*
+ * if we tried all available ring items, and still
+ * can't get enough buf, it means something abnormal
+ * happened.
+ */
+ if (unlikely(++tries > max_tries))
+ return -1;
+
if (unlikely(fill_vec_buf_packed(dev, vq,
avail_idx, &desc_count,
buf_vec, &vec_idx,
avail_idx -= vq->size;
*nr_descs += desc_count;
- tries++;
*num_buffers += 1;
-
- /*
- * if we tried all available ring items, and still
- * can't get enough buf, it means something abnormal
- * happened.
- */
- if (unlikely(tries > max_tries))
- return -1;
}
*nr_vec = vec_idx;