@@ -46,7 +46,6 @@ typedef struct odp_pktout_queue_t {
#define ODP_PKTIO_MACADDR_MAXSIZE 16
#define ODP_PKTIN_NO_WAIT 0
-#define ODP_PKTIN_WAIT UINT64_MAX
/**
* @}
@@ -1699,33 +1699,28 @@ int odp_pktin_recv_tmo(odp_pktin_queue_t queue, odp_packet_t packets[], int num,
while (1) {
ret = entry->s.ops->recv(entry, queue.index, packets, num);
- if (ret != 0)
+ if (ret != 0 || wait == 0)
return ret;
- if (wait == 0)
- return 0;
+ /* Avoid unnecessary system calls. Record the start time
+ * only when needed and after the first call to recv. */
+ if (odp_unlikely(!started)) {
+ odp_time_t t;
- if (wait != ODP_PKTIN_WAIT) {
- /* Avoid unnecessary system calls. Record the start time
- * only when needed and after the first call to recv. */
- if (odp_unlikely(!started)) {
- odp_time_t t;
-
- t = odp_time_local_from_ns(wait * 1000);
- started = 1;
- t1 = odp_time_sum(odp_time_local(), t);
- }
+ t = odp_time_local_from_ns(wait * 1000);
+ started = 1;
+ t1 = odp_time_sum(odp_time_local(), t);
+ }
- /* Check every SLEEP_CHECK rounds if total wait time
- * has been exceeded. */
- if ((++sleep_round & (SLEEP_CHECK - 1)) == 0) {
- t2 = odp_time_local();
+ /* Check every SLEEP_CHECK rounds if total wait time
+ * has been exceeded. */
+ if ((++sleep_round & (SLEEP_CHECK - 1)) == 0) {
+ t2 = odp_time_local();
- if (odp_time_cmp(t2, t1) > 0)
- return 0;
- }
- wait = wait > SLEEP_USEC ? wait - SLEEP_USEC : 0;
+ if (odp_time_cmp(t2, t1) > 0)
+ return 0;
}
+ wait = wait > SLEEP_USEC ? wait - SLEEP_USEC : 0;
nanosleep(&ts, NULL);
}
@@ -1779,25 +1774,23 @@ int odp_pktin_recv_mq_tmo(const odp_pktin_queue_t queues[], unsigned num_q,
if (wait == 0)
return 0;
- if (wait != ODP_PKTIN_WAIT) {
- if (odp_unlikely(!started)) {
- odp_time_t t;
+ if (odp_unlikely(!started)) {
+ odp_time_t t;
- t = odp_time_local_from_ns(wait * 1000);
- started = 1;
- t1 = odp_time_sum(odp_time_local(), t);
- }
+ t = odp_time_local_from_ns(wait * 1000);
+ started = 1;
+ t1 = odp_time_sum(odp_time_local(), t);
+ }
- /* Check every SLEEP_CHECK rounds if total wait time
- * has been exceeded. */
- if ((++sleep_round & (SLEEP_CHECK - 1)) == 0) {
- t2 = odp_time_local();
+ /* Check every SLEEP_CHECK rounds if total wait time
+ * has been exceeded. */
+ if ((++sleep_round & (SLEEP_CHECK - 1)) == 0) {
+ t2 = odp_time_local();
- if (odp_time_cmp(t2, t1) > 0)
- return 0;
- }
- wait = wait > SLEEP_USEC ? wait - SLEEP_USEC : 0;
+ if (odp_time_cmp(t2, t1) > 0)
+ return 0;
}
+ wait = wait > SLEEP_USEC ? wait - SLEEP_USEC : 0;
nanosleep(&ts, NULL);
}
@@ -107,8 +107,7 @@ static int sock_recv_mq_tmo_select(pktio_entry_t * const *entry,
timeout.tv_sec = usecs / (1000 * 1000);
timeout.tv_usec = usecs - timeout.tv_sec * (1000ULL * 1000ULL);
- if (select(maxfd + 1, readfds, NULL, NULL,
- usecs == ODP_PKTIN_WAIT ? NULL : &timeout) == 0)
+ if (select(maxfd + 1, readfds, NULL, NULL, &timeout) == 0)
return 0;
for (i = 0; i < num_q; i++) {
@@ -721,8 +721,7 @@ static int sock_recv_tmo(pktio_entry_t *pktio_entry, int index,
FD_ZERO(&readfds);
maxfd = sock_fd_set(pktio_entry, index, &readfds);
- if (select(maxfd + 1, &readfds, NULL, NULL,
- usecs == ODP_PKTIN_WAIT ? NULL : &timeout) == 0)
+ if (select(maxfd + 1, &readfds, NULL, NULL, &timeout) == 0)
return 0;
return sock_mmsg_recv(pktio_entry, index, pkt_table, num);
@@ -759,8 +758,7 @@ static int sock_recv_mq_tmo(pktio_entry_t *pktio_entry[], int index[],
maxfd = maxfd2;
}
- if (select(maxfd + 1, &readfds, NULL, NULL,
- usecs == ODP_PKTIN_WAIT ? NULL : &timeout) == 0)
+ if (select(maxfd + 1, &readfds, NULL, NULL, &timeout) == 0)
return 0;
for (i = 0; i < num_q; i++) {
@@ -647,8 +647,7 @@ static int sock_mmap_recv_tmo(pktio_entry_t *pktio_entry, int index,
FD_ZERO(&readfds);
maxfd = sock_mmap_fd_set(pktio_entry, index, &readfds);
- if (select(maxfd + 1, &readfds, NULL, NULL,
- usecs == ODP_PKTIN_WAIT ? NULL : &timeout) == 0)
+ if (select(maxfd + 1, &readfds, NULL, NULL, &timeout) == 0)
return 0;
return sock_mmap_recv(pktio_entry, index, pkt_table, num);
@@ -685,8 +684,7 @@ static int sock_mmap_recv_mq_tmo(pktio_entry_t *pktio_entry[], int index[],
timeout.tv_sec = usecs / (1000 * 1000);
timeout.tv_usec = usecs - timeout.tv_sec * (1000ULL * 1000ULL);
- if (select(maxfd + 1, &readfds, NULL, NULL,
- usecs == ODP_PKTIN_WAIT ? NULL : &timeout) == 0)
+ if (select(maxfd + 1, &readfds, NULL, NULL, &timeout) == 0)
return 0;
for (i = 0; i < num_q; i++) {