Message ID | 1418856112-8589-2-git-send-email-maxim.uvarov@linaro.org |
---|---|
State | New |
Headers | show |
On 12/18/2014 03:13 AM, Stuart Haslam wrote: > On Wed, Dec 17, 2014 at 10:41:50PM +0000, Maxim Uvarov wrote: >> Correctly remove queue from packet i/o and remove it from scheduler. >> >> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> >> --- >> platform/linux-generic/odp_packet_io.c | 26 +++++++++++++++++++++++++- >> 1 file changed, 25 insertions(+), 1 deletion(-) >> >> diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c >> index 3ca8100..1b3ab24 100644 >> --- a/platform/linux-generic/odp_packet_io.c >> +++ b/platform/linux-generic/odp_packet_io.c >> @@ -391,7 +391,31 @@ int odp_pktio_inq_setdef(odp_pktio_t id, odp_queue_t queue) >> >> int odp_pktio_inq_remdef(odp_pktio_t id) >> { >> - return odp_pktio_inq_setdef(id, ODP_QUEUE_INVALID); >> + pktio_entry_t *pktio_entry = get_pktio_entry(id); >> + odp_queue_t queue; >> + queue_entry_t *qentry; >> + >> + if (pktio_entry == NULL) >> + return -1; >> + >> + lock_entry(pktio_entry); >> + queue = pktio_entry->s.inq_default; >> + qentry = queue_to_qentry(queue); >> + >> + queue_lock(qentry); >> + if (qentry->s.status == QUEUE_STATUS_FREE) { >> + queue_unlock(qentry); >> + unlock_entry(pktio_entry); >> + return -1; /* Queue is already free or not empty */ > or not empty?.. you haven't checked if it's empty. It might be not empty in that case. Copy pased that comment. Will remove it. >> + } >> + >> + qentry->s.enqueue = queue_enq_dummy; >> + qentry->s.enqueue_multi = queue_enq_multi_dummy; >> + qentry->s.status = QUEUE_STATUS_FREE; > Setting the status to FREE means it can be allocated again on the next > odp_queue_create() call, which isn't what you want. ok. > Still not clearing pktio->s.inq_default > > Also I think you should be clearing queue->s.pktin ok. >> + queue_unlock(qentry); >> + unlock_entry(pktio_entry); >> + >> + return 0; >> } >> >> odp_queue_t odp_pktio_inq_getdef(odp_pktio_t id) >> -- >> 1.8.5.1.163.gd7aced9 >>
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 3ca8100..1b3ab24 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -391,7 +391,31 @@ int odp_pktio_inq_setdef(odp_pktio_t id, odp_queue_t queue) int odp_pktio_inq_remdef(odp_pktio_t id) { - return odp_pktio_inq_setdef(id, ODP_QUEUE_INVALID); + pktio_entry_t *pktio_entry = get_pktio_entry(id); + odp_queue_t queue; + queue_entry_t *qentry; + + if (pktio_entry == NULL) + return -1; + + lock_entry(pktio_entry); + queue = pktio_entry->s.inq_default; + qentry = queue_to_qentry(queue); + + queue_lock(qentry); + if (qentry->s.status == QUEUE_STATUS_FREE) { + queue_unlock(qentry); + unlock_entry(pktio_entry); + return -1; /* Queue is already free or not empty */ + } + + qentry->s.enqueue = queue_enq_dummy; + qentry->s.enqueue_multi = queue_enq_multi_dummy; + qentry->s.status = QUEUE_STATUS_FREE; + queue_unlock(qentry); + unlock_entry(pktio_entry); + + return 0; } odp_queue_t odp_pktio_inq_getdef(odp_pktio_t id)
Correctly remove queue from packet i/o and remove it from scheduler. Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> --- platform/linux-generic/odp_packet_io.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)