diff mbox series

[API-NEXT,v3,2/3] linux-generic: pktio: drop support for indefinite waits in recv_tmo

Message ID 1516636829-25161-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v3,1/3] test: validation: drop use of indefinite wait in pktio test | expand

Commit Message

Github ODP bot Jan. 22, 2018, 4 p.m. UTC
From: Bill Fischofer <bill.fischofer@linaro.org>


Drop support for the deprecated ODP_PKTIN_WAIT option on
odp_pktin_recv_tmo() and odp_pktin_recv_mq_tmo()

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

---
/** Email created from pull request 410 (Bill-Fischofer-Linaro:pktio-dropwait)
 ** https://github.com/Linaro/odp/pull/410
 ** Patch: https://github.com/Linaro/odp/pull/410.patch
 ** Base sha: 5fba303faf04d29b616f687ce1f721400b2c6f9c
 ** Merge commit sha: d3ec5308bd5a6917dc91dee1860dab99bd6e9b15
 **/
 include/odp/api/abi-default/packet_io.h     |  1 -
 platform/linux-generic/odp_packet_io.c      | 65 +++++++++++++----------------
 platform/linux-generic/pktio/pktio_common.c |  3 +-
 platform/linux-generic/pktio/socket.c       |  6 +--
 platform/linux-generic/pktio/socket_mmap.c  |  6 +--
 5 files changed, 34 insertions(+), 47 deletions(-)
diff mbox series

Patch

diff --git a/include/odp/api/abi-default/packet_io.h b/include/odp/api/abi-default/packet_io.h
index 4795f8fc3..7cd3edd75 100644
--- a/include/odp/api/abi-default/packet_io.h
+++ b/include/odp/api/abi-default/packet_io.h
@@ -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
 
 /**
  * @}
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 095f6be12..a06fa67b4 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -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);
 	}
diff --git a/platform/linux-generic/pktio/pktio_common.c b/platform/linux-generic/pktio/pktio_common.c
index f6fb4a73d..c7a1c3ab9 100644
--- a/platform/linux-generic/pktio/pktio_common.c
+++ b/platform/linux-generic/pktio/pktio_common.c
@@ -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++) {
diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c
index 147a06900..c198336a0 100644
--- a/platform/linux-generic/pktio/socket.c
+++ b/platform/linux-generic/pktio/socket.c
@@ -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++) {
diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c
index 1bdb745a4..da83d8452 100644
--- a/platform/linux-generic/pktio/socket_mmap.c
+++ b/platform/linux-generic/pktio/socket_mmap.c
@@ -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++) {