Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org
Cc: ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp,
	gerald.rogers@intel.com, sy.jong.choi@intel.com
Subject: [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t
Date: Wed,  6 Dec 2017 17:18:20 +0900	[thread overview]
Message-ID: <20171206081826.67688-1-ogawa.yasufumi@lab.ntt.co.jp> (raw)

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

In SPP, type of port_id is int while it is changed from uint8_t to
uint16_t in DPDK 17.11. It causes compile errors for incompatible
pointer type.

In addition, SPP expects negative value of port_id if it is
unassigned or invalid case. It is also a problem because comparing
uint16_t with negative value is not allowed.

This update is to change type of port_id and its validation. PORT_RESET
used for unassigned ports is changed from -99 to UINT16_MAX to avoid
negative value.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/nfv/nfv.c       | 14 +++++++-------
 src/shared/common.h | 11 ++++++-----
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/nfv/nfv.c b/src/nfv/nfv.c
index fc9ad1e..4bd9f6d 100644
--- a/src/nfv/nfv.c
+++ b/src/nfv/nfv.c
@@ -120,10 +120,10 @@ forward(void)
 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
 		struct rte_mbuf *bufs[MAX_PKT_BURST];
 
-		if (ports_fwd_array[i].in_port_id < 0)
+		if (ports_fwd_array[i].in_port_id == PORT_RESET)
 			continue;
 
-		if (ports_fwd_array[i].out_port_id < 0)
+		if (ports_fwd_array[i].out_port_id == PORT_RESET)
 			continue;
 
 		/* if status active, i count is in port*/
@@ -223,7 +223,7 @@ forward_array_reset(void)
 
 	/* initialize port forward array*/
 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
-		if (ports_fwd_array[i].in_port_id > -1) {
+		if (ports_fwd_array[i].in_port_id != PORT_RESET) {
 			ports_fwd_array[i].out_port_id = PORT_RESET;
 			RTE_LOG(INFO, APP, "Port ID %d\n", i);
 			RTE_LOG(INFO, APP, "out_port_id %d\n",
@@ -242,7 +242,7 @@ print_active_ports(char *str)
 
 	/* every elements value*/
 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
-		if (ports_fwd_array[i].in_port_id < 0)
+		if (ports_fwd_array[i].in_port_id == PORT_RESET)
 			continue;
 
 		RTE_LOG(INFO, APP, "Port ID %d\n", i);
@@ -250,7 +250,7 @@ print_active_ports(char *str)
 			ports_fwd_array[i].in_port_id);
 
 		sprintf(str + strlen(str), "port id: %d,", i);
-		if (ports_fwd_array[i].in_port_id >= 0)
+		if (ports_fwd_array[i].in_port_id != PORT_RESET)
 			sprintf(str + strlen(str), "on,");
 		else
 			sprintf(str + strlen(str), "off,");
@@ -309,7 +309,7 @@ forward_array_remove(int port_id)
 	forward_array_init_one(port_id);
 
 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
-		if (ports_fwd_array[i].in_port_id < 0)
+		if (ports_fwd_array[i].in_port_id == PORT_RESET)
 			continue;
 
 		if (ports_fwd_array[i].out_port_id == port_id) {
@@ -439,7 +439,7 @@ add_vhost_pmd(int index)
 		.rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
 	};
 	struct rte_mempool *mp;
-	uint8_t vhost_port_id;
+	uint16_t vhost_port_id;
 	int nr_queues = 1;
 	const char *name;
 	char devargs[64];
diff --git a/src/shared/common.h b/src/shared/common.h
index 6ae4ac9..27138bd 100644
--- a/src/shared/common.h
+++ b/src/shared/common.h
@@ -41,6 +41,7 @@
 #include <string.h>
 #include <sys/socket.h>
 #include <unistd.h>
+#include <limits.h>
 
 #include <rte_branch_prediction.h>
 #include <rte_common.h>
@@ -57,7 +58,7 @@
 #define MAX_CLIENT  99
 #define MSG_SIZE    1000
 #define SOCK_RESET  -1
-#define PORT_RESET  -99
+#define PORT_RESET  UINT16_MAX
 
 /*
  * When doing reads from the NIC or the client queues,
@@ -128,10 +129,10 @@ struct port_map {
 };
 
 struct port {
-	int in_port_id;
-	int out_port_id;
-	uint16_t (*rx_func)(uint8_t, uint16_t, struct rte_mbuf **, uint16_t);
-	uint16_t (*tx_func)(uint8_t, uint16_t, struct rte_mbuf **, uint16_t);
+	uint16_t in_port_id;
+	uint16_t out_port_id;
+	uint16_t (*rx_func)(uint16_t, uint16_t, struct rte_mbuf **, uint16_t);
+	uint16_t (*tx_func)(uint16_t, uint16_t, struct rte_mbuf **, uint16_t);
 };
 
 /* define common names for structures shared between server and client */
-- 
2.13.1

             reply	other threads:[~2017-12-06  8:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-06  8:18 ogawa.yasufumi [this message]
2017-12-06  8:18 ` [spp] [PATCH 2/7] spp_vm: " ogawa.yasufumi
2017-12-06  8:18 ` [spp] [PATCH 3/7] spp_primary: change type of ports_id " ogawa.yasufumi
2017-12-06  8:18 ` [spp] [PATCH 4/7] spp_vm: " ogawa.yasufumi
2017-12-06  8:18 ` [spp] [PATCH 5/7] spp/shared: " ogawa.yasufumi
2017-12-06  8:18 ` [spp] [PATCH 6/7] spp: change type of counter " ogawa.yasufumi
2017-12-06  8:18 ` [spp] [PATCH 7/7] spp/shared: refactor printing port status ogawa.yasufumi
2017-12-07 18:08 ` [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171206081826.67688-1-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=gerald.rogers@intel.com \
    --cc=spp@dpdk.org \
    --cc=sy.jong.choi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).