serialqueue: Support sending messages at a background priority

Support low-priority message transmits.  This may be useful for bulk
commands that should be delayed util the comms are otherwise idle.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-02-11 18:49:27 -05:00
parent afc9bcf27b
commit 43ac56766e
2 changed files with 12 additions and 4 deletions

View File

@ -389,6 +389,7 @@ struct serialqueue {
#define MIN_RTO 0.025
#define MAX_RTO 5.000
#define MIN_REQTIME_DELTA 0.250
#define MIN_BACKGROUND_DELTA 0.005
#define IDLE_QUERY_TIME 1.0
#define DEBUG_QUEUE_SENT 100
@ -722,8 +723,13 @@ check_send_command(struct serialqueue *sq, double eventtime)
if (!list_empty(&cq->ready_queue)) {
struct queue_message *qm = list_first_entry(
&cq->ready_queue, struct queue_message, node);
if (qm->req_clock < min_ready_clock)
min_ready_clock = qm->req_clock;
uint64_t req_clock = qm->req_clock;
if (req_clock == BACKGROUND_PRIORITY_CLOCK)
req_clock = (uint64_t)(
(sq->idle_time - sq->last_clock_time + MIN_BACKGROUND_DELTA)
* sq->est_freq) + sq->last_clock;
if (req_clock < min_ready_clock)
min_ready_clock = req_clock;
}
}
@ -907,7 +913,8 @@ serialqueue_send_batch(struct serialqueue *sq, struct command_queue *cq
int len = 0;
struct queue_message *qm;
list_for_each_entry(qm, msgs, node) {
if (qm->min_clock + (1LL<<31) < qm->req_clock)
if (qm->min_clock + (1LL<<31) < qm->req_clock
&& qm->req_clock != BACKGROUND_PRIORITY_CLOCK)
qm->min_clock = qm->req_clock - (1LL<<31);
len += qm->len;
}

View File

@ -3,7 +3,8 @@
#include "list.h" // struct list_head
#define MAX_CLOCK 0x7fffffffffffffff
#define MAX_CLOCK 0x7fffffffffffffffLL
#define BACKGROUND_PRIORITY_CLOCK 0x7fffffff00000000LL
#define MESSAGE_MIN 5
#define MESSAGE_MAX 64