[Pkg-ofed-commits] [libfabric] 26/123: usnic: Distinguish between a full queue and an empty queue.
Ana Beatriz Guerrero López
ana at moszumanska.debian.org
Sat Oct 22 12:28:26 UTC 2016
This is an automated email from the git hooks/post-receive script.
ana pushed a commit to annotated tag v1.1.1
in repository libfabric.
commit 1b8e184179376b37575fd828b9318fd70f997919
Author: Ben Turrubiates <bturrubi at cisco.com>
Date: Thu Aug 27 14:46:00 2015 -0700
usnic: Distinguish between a full queue and an empty queue.
Add a new CQ field representing the last operation to distinguish
between an empty queue and a full queue when the head and tail pointers
are the same.
Signed-off-by: Ben Turrubiates <bturrubi at cisco.com>
---
prov/usnic/src/usdf.h | 8 ++++++++
prov/usnic/src/usdf_cq.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/prov/usnic/src/usdf.h b/prov/usnic/src/usdf.h
index e23a577..a58cbc3 100644
--- a/prov/usnic/src/usdf.h
+++ b/prov/usnic/src/usdf.h
@@ -381,11 +381,19 @@ struct usdf_cq {
struct usdf_cq_soft_entry *cq_end;
struct usdf_cq_soft_entry *cq_head;
struct usdf_cq_soft_entry *cq_tail;
+ /* Last operation used to distinguish full vs empty. */
+ uint8_t cq_last_op;
TAILQ_HEAD(,usdf_cq_hard) cq_list;
} soft;
} c;
struct usd_completion cq_comp;
};
+
+enum {
+ USDF_SOFT_CQ_READ,
+ USDF_SOFT_CQ_WRITE
+};
+
#define cq_ftou(FCQ) container_of(FCQ, struct usdf_cq, cq_fid)
#define cq_fidtou(FID) container_of(FID, struct usdf_cq, cq_fid.fid)
#define cq_utof(CQ) (&(CQ)->cq_fid)
diff --git a/prov/usnic/src/usdf_cq.c b/prov/usnic/src/usdf_cq.c
index d99aae1..5dd2b11 100644
--- a/prov/usnic/src/usdf_cq.c
+++ b/prov/usnic/src/usdf_cq.c
@@ -480,6 +480,17 @@ usdf_progress_hard_cq(struct usdf_cq_hard *hcq)
ret = usd_poll_cq(hcq->cqh_ucq, &comp);
if (ret == 0) {
entry = cq->c.soft.cq_head;
+
+ /* If the current entry is equal to the tail and the
+ * last operation was a write, then we have filled the
+ * queue and we just drop whatever there isn't space
+ * for.
+ */
+ if ((entry == cq->c.soft.cq_tail) &&
+ (cq->c.soft.cq_last_op ==
+ USDF_SOFT_CQ_WRITE))
+ return;
+
entry->cse_context = cq->cq_comp.uc_context;
entry->cse_flags = 0;
entry->cse_len = cq->cq_comp.uc_bytes;
@@ -493,6 +504,8 @@ usdf_progress_hard_cq(struct usdf_cq_hard *hcq)
} else {
cq->c.soft.cq_head = cq->c.soft.cq_comps;
}
+
+ cq->c.soft.cq_last_op = USDF_SOFT_CQ_WRITE;
}
} while (ret != -EAGAIN);
}
@@ -507,6 +520,16 @@ usdf_cq_post_soft(struct usdf_cq_hard *hcq, void *context, size_t len,
cq = hcq->cqh_cq;
entry = cq->c.soft.cq_head;
+
+ /* If the current entry is equal to the tail and the
+ * last operation was a write, then we have filled the
+ * queue and we just drop whatever there isn't space
+ * for.
+ */
+ if ((entry == cq->c.soft.cq_tail) &&
+ (cq->c.soft.cq_last_op == USDF_SOFT_CQ_WRITE))
+ return;
+
entry->cse_context = context;
entry->cse_len = len;
entry->cse_prov_errno = prov_errno;
@@ -519,6 +542,7 @@ usdf_cq_post_soft(struct usdf_cq_hard *hcq, void *context, size_t len,
cq->c.soft.cq_head = cq->c.soft.cq_comps;
}
+ cq->c.soft.cq_last_op = USDF_SOFT_CQ_WRITE;
}
static inline ssize_t
@@ -594,7 +618,16 @@ usdf_cq_sread_common_soft(struct fid_cq *fcq, void *buf, size_t count, const voi
tail = cq->c.soft.cq_tail;
- while (entry < last && tail != cq->c.soft.cq_head) {
+ while (entry < last) {
+ /* If the head and tail are equal and the last
+ * operation was a read then that means we have an
+ * empty queue.
+ */
+ if ((tail == cq->c.soft.cq_head) &&
+ (cq->c.soft.cq_last_op ==
+ USDF_SOFT_CQ_READ))
+ break;
+
if (tail->cse_prov_errno > 0) {
if (entry > (uint8_t *)buf)
break;
@@ -610,6 +643,8 @@ usdf_cq_sread_common_soft(struct fid_cq *fcq, void *buf, size_t count, const voi
tail++;
if (tail == cq->c.soft.cq_end)
tail = cq->c.soft.cq_comps;
+
+ cq->c.soft.cq_last_op = USDF_SOFT_CQ_READ;
}
if (entry > (uint8_t *)buf) {
@@ -695,7 +730,15 @@ usdf_cq_read_common_soft(struct fid_cq *fcq, void *buf, size_t count,
last = entry + (entry_len * count);
tail = cq->c.soft.cq_tail;
- while (entry < last && tail != cq->c.soft.cq_head) {
+ while (entry < last) {
+ /* If the head and tail are equal and the last
+ * operation was a read then that means we have an
+ * empty queue.
+ */
+ if ((tail == cq->c.soft.cq_head) &&
+ (cq->c.soft.cq_last_op == USDF_SOFT_CQ_READ))
+ break;
+
if (tail->cse_prov_errno > 0) {
return -FI_EAVAIL;
}
@@ -708,6 +751,8 @@ usdf_cq_read_common_soft(struct fid_cq *fcq, void *buf, size_t count,
if (tail == cq->c.soft.cq_end) {
tail = cq->c.soft.cq_comps;
}
+
+ cq->c.soft.cq_last_op = USDF_SOFT_CQ_READ;
}
cq->c.soft.cq_tail = tail;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ofed/libfabric.git
More information about the Pkg-ofed-commits
mailing list