Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I2775af35386a4e52ba82991c68bce6c56f13410f
*/
/*? %%clicmd:group_label Static HTTP Server %% ?*/
*/
/*? %%clicmd:group_label Static HTTP Server %% ?*/
+#define HTTP_FIFO_THRESH (16 << 10)
+
http_static_server_main_t http_static_server_main;
/** \brief Format the called-from enum
http_static_server_main_t http_static_server_main;
/** \brief Format the called-from enum
if (hs->data_offset < vec_len (hs->data))
{
/* No: ask for a shoulder-tap when the tx fifo has space */
if (hs->data_offset < vec_len (hs->data))
{
/* No: ask for a shoulder-tap when the tx fifo has space */
- svm_fifo_add_want_deq_ntf (hs->tx_fifo,
- SVM_FIFO_WANT_DEQ_NOTIF_IF_LEQ_THRESH);
+ svm_fifo_add_want_deq_ntf (hs->tx_fifo, SVM_FIFO_WANT_DEQ_NOTIF);
hs->session_state = HTTP_STATE_SEND_MORE_DATA;
return 0;
}
hs->session_state = HTTP_STATE_SEND_MORE_DATA;
return 0;
}
* full, however avoid entering a state where the
* fifo is full all the time and small chunks of data are being enqueued
* each time. If the fifo is small (under 16K) we set
* full, however avoid entering a state where the
* fifo is full all the time and small chunks of data are being enqueued
* each time. If the fifo is small (under 16K) we set
- * the threshold to 0, meaning a notification will be given when the
+ * the threshold to it's size, meaning a notification will be given when the
-#define HTTP_FIFO_THRESH (16 << 10)
- thresh = (svm_fifo_size (hs->tx_fifo) < HTTP_FIFO_THRESH) ?
- 0 :
- svm_fifo_size (hs->tx_fifo) - HTTP_FIFO_THRESH;
-
+ thresh = clib_min (svm_fifo_size (hs->tx_fifo), HTTP_FIFO_THRESH);
svm_fifo_set_deq_thresh (hs->tx_fifo, thresh);
s->session_state = SESSION_STATE_READY;
svm_fifo_set_deq_thresh (hs->tx_fifo, thresh);
s->session_state = SESSION_STATE_READY;
SVM_FIFO_WANT_DEQ_NOTIF = 1, /**< Notify on dequeue */
SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL = 2, /**< Notify on transition from full */
SVM_FIFO_WANT_DEQ_NOTIF_IF_EMPTY = 4, /**< Notify on transition to empty */
SVM_FIFO_WANT_DEQ_NOTIF = 1, /**< Notify on dequeue */
SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL = 2, /**< Notify on transition from full */
SVM_FIFO_WANT_DEQ_NOTIF_IF_EMPTY = 4, /**< Notify on transition to empty */
- SVM_FIFO_WANT_DEQ_NOTIF_IF_LEQ_THRESH = 5, /**< Notify on transition to less
- than or equal threshold */
} svm_fifo_deq_ntf_t;
typedef enum svm_fifo_flag_
} svm_fifo_deq_ntf_t;
typedef enum svm_fifo_flag_
/* Set the flag if want_notif_if_full was the only ntf requested */
f->shr->has_deq_ntf =
f->shr->want_deq_ntf == SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL;
/* Set the flag if want_notif_if_full was the only ntf requested */
f->shr->has_deq_ntf =
f->shr->want_deq_ntf == SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL;
- svm_fifo_del_want_deq_ntf (f, SVM_FIFO_WANT_DEQ_NOTIF |
- SVM_FIFO_WANT_DEQ_NOTIF_IF_LEQ_THRESH);
+ svm_fifo_del_want_deq_ntf (f, SVM_FIFO_WANT_DEQ_NOTIF);
if (PREDICT_TRUE (want_ntf == SVM_FIFO_NO_DEQ_NOTIF))
return 0;
else if (want_ntf & SVM_FIFO_WANT_DEQ_NOTIF)
if (PREDICT_TRUE (want_ntf == SVM_FIFO_NO_DEQ_NOTIF))
return 0;
else if (want_ntf & SVM_FIFO_WANT_DEQ_NOTIF)
+ return (svm_fifo_max_enqueue (f) >= f->shr->deq_thresh);
if (want_ntf & SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL)
{
u32 max_deq = svm_fifo_max_dequeue_cons (f);
if (want_ntf & SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL)
{
u32 max_deq = svm_fifo_max_dequeue_cons (f);
if (!f->shr->has_deq_ntf && svm_fifo_is_empty (f))
return 1;
}
if (!f->shr->has_deq_ntf && svm_fifo_is_empty (f))
return 1;
}
- if (want_ntf & SVM_FIFO_WANT_DEQ_NOTIF_IF_LEQ_THRESH)
- {
- if (!f->shr->has_deq_ntf &&
- (svm_fifo_max_dequeue (f) <= f->shr->deq_thresh))
- return 1;
- }
* Set the fifo dequeue threshold which will be used for notifications.
*
* Note: If not set, by default threshold is zero, equivalent to
* Set the fifo dequeue threshold which will be used for notifications.
*
* Note: If not set, by default threshold is zero, equivalent to
+ * generating notification on each dequeue event.
*/
static inline void
svm_fifo_set_deq_thresh (svm_fifo_t *f, u32 thresh)
*/
static inline void
svm_fifo_set_deq_thresh (svm_fifo_t *f, u32 thresh)