diff options
author | Florin Coras <fcoras@cisco.com> | 2023-05-29 16:19:38 -0700 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2023-06-02 16:22:08 +0000 |
commit | 95f95670982f1ab056e45047eb0b78cf682df73f (patch) | |
tree | d0a3437bd0c75a4ddfaf742ef6d1bad7f2e52ed3 /src | |
parent | b4b65194e36ac3b378c8f5a40694ce1618696384 (diff) |
vcl: refactor want deq ntf checks for null fifos
Type: refactor
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I5d0445ca381f1a4943bb2fe454433b3454043b56
(cherry picked from commit 607eb203b1e954ac3f7ed82bd7bde3cf3aad60cf)
Diffstat (limited to 'src')
-rw-r--r-- | src/vcl/vcl_private.h | 16 | ||||
-rw-r--r-- | src/vcl/vppcom.c | 41 |
2 files changed, 28 insertions, 29 deletions
diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h index dabe52c899c..39a0f05034f 100644 --- a/src/vcl/vcl_private.h +++ b/src/vcl/vcl_private.h @@ -666,6 +666,22 @@ vcl_session_dgram_tx_evt (vcl_session_t *s, session_evt_type_t et) return (s->flags & VCL_SESSION_F_CONNECTED) ? et : SESSION_IO_EVT_TX_MAIN; } +static inline void +vcl_session_add_want_deq_ntf (vcl_session_t *s, svm_fifo_deq_ntf_t evt) +{ + svm_fifo_t *txf = vcl_session_is_ct (s) ? s->ct_tx_fifo : s->tx_fifo; + if (txf) + svm_fifo_add_want_deq_ntf (txf, evt); +} + +static inline void +vcl_session_del_want_deq_ntf (vcl_session_t *s, svm_fifo_deq_ntf_t evt) +{ + svm_fifo_t *txf = vcl_session_is_ct (s) ? s->ct_tx_fifo : s->tx_fifo; + if (txf) + svm_fifo_del_want_deq_ntf (txf, evt); +} + /* * Helpers */ diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c index ecbbf7a7d5f..9e7af0a3a50 100644 --- a/src/vcl/vppcom.c +++ b/src/vcl/vppcom.c @@ -2421,12 +2421,8 @@ vcl_select_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, clib_bitmap_set_no_check ((uword *) write_map, sid, 1); *bits_set += 1; s = vcl_session_get (wrk, sid); - if (!s->tx_fifo) - break; /* We didn't have a fifo when the event was added */ - svm_fifo_add_want_deq_ntf ( - (vcl_session_is_ct (s) ? s->ct_tx_fifo : s->tx_fifo), - SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL); + vcl_session_add_want_deq_ntf (s, SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL); break; case SESSION_CTRL_EVT_DISCONNECTED: disconnected_msg = (session_disconnected_msg_t *) e->data; @@ -2636,10 +2632,9 @@ vppcom_select (int n_bits, vcl_si_set * read_map, vcl_si_set * write_map, clib_bitmap_set_no_check ((uword *) write_map, sid, 1); bits_set++; } - else if (s->tx_fifo) + else { - svm_fifo_t *txf = vcl_session_is_ct (s) ? s->ct_tx_fifo : s->tx_fifo; - svm_fifo_add_want_deq_ntf (txf, SVM_FIFO_WANT_DEQ_NOTIF); + vcl_session_add_want_deq_ntf (s, SVM_FIFO_WANT_DEQ_NOTIF); } } @@ -2801,7 +2796,6 @@ vppcom_epoll_ctl (uint32_t vep_handle, int op, uint32_t session_handle, int rv = VPPCOM_OK, add_evt = 0; vcl_session_t *vep_session; vcl_session_t *s; - svm_fifo_t *txf; if (vep_handle == session_handle) { @@ -2874,9 +2868,8 @@ vppcom_epoll_ctl (uint32_t vep_handle, int op, uint32_t session_handle, s->flags |= VCL_SESSION_F_IS_VEP_SESSION; vep_session->vep.next_sh = session_handle; - txf = vcl_session_is_ct (s) ? s->ct_tx_fifo : s->tx_fifo; - if (txf && (event->events & EPOLLOUT)) - svm_fifo_add_want_deq_ntf (txf, SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL); + if (event->events & EPOLLOUT) + vcl_session_add_want_deq_ntf (s, SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL); /* Generate EPOLLOUT if tx fifo not full */ if ((event->events & EPOLLOUT) && (vcl_session_write_ready (s) > 0)) @@ -2929,14 +2922,10 @@ vppcom_epoll_ctl (uint32_t vep_handle, int op, uint32_t session_handle, goto done; } - txf = vcl_session_is_ct (s) ? s->ct_tx_fifo : s->tx_fifo; - if (txf) - { - if (event->events & EPOLLOUT) - svm_fifo_add_want_deq_ntf (txf, SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL); - else - svm_fifo_del_want_deq_ntf (txf, SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL); - } + if (event->events & EPOLLOUT) + vcl_session_add_want_deq_ntf (s, SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL); + else + vcl_session_del_want_deq_ntf (s, SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL); /* Generate EPOLLOUT if session write ready nd event was not on */ if ((event->events & EPOLLOUT) && !(s->vep.ev.events & EPOLLOUT) && @@ -3014,11 +3003,7 @@ vppcom_epoll_ctl (uint32_t vep_handle, int op, uint32_t session_handle, s->flags &= ~VCL_SESSION_F_IS_VEP_SESSION; if (vcl_session_is_open (s)) - { - txf = vcl_session_is_ct (s) ? s->ct_tx_fifo : s->tx_fifo; - if (txf) - svm_fifo_del_want_deq_ntf (txf, SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL); - } + vcl_session_del_want_deq_ntf (s, SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL); VDBG (1, "EPOLL_CTL_DEL: vep_idx %u, sh %u!", vep_handle, session_handle); @@ -3108,12 +3093,10 @@ vcl_epoll_wait_handle_mq_event (vcl_worker_t * wrk, session_event_t * e, break; session_events = s->vep.ev.events; /* Generate EPOLLOUT because there's no connected event */ - if (!(EPOLLOUT & session_events) || !s->tx_fifo) + if (!(EPOLLOUT & session_events)) break; /* We didn't have a fifo when the event was added */ - svm_fifo_add_want_deq_ntf ( - (vcl_session_is_ct (s) ? s->ct_tx_fifo : s->tx_fifo), - SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL); + vcl_session_add_want_deq_ntf (s, SVM_FIFO_WANT_DEQ_NOTIF_IF_FULL); add_event = 1; events[*num_ev].events = EPOLLOUT; session_evt_data = s->vep.ev.data.u64; |