From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mogw0338.ocn.ad.jp (mogw0338.ocn.ad.jp [114.147.58.108]) by dpdk.org (Postfix) with ESMTP id D40E3199B6 for ; Wed, 6 Dec 2017 09:19:30 +0100 (CET) Received: from mf-smf-ucb005.ocn.ad.jp (mf-smf-ucb005.ocn.ad.jp [153.149.231.4]) by mogw0338.ocn.ad.jp (Postfix) with ESMTP id 8E47733028C; Wed, 6 Dec 2017 17:19:28 +0900 (JST) Received: from mf-smf-ucb005.ocn.ad.jp (mf-smf-ucb005 [153.149.231.4]) by mf-smf-ucb005.ocn.ad.jp (Postfix) with ESMTP id 76CAD60703; Wed, 6 Dec 2017 17:19:28 +0900 (JST) Received: from ntt.pod01.mv-mta-ucb030 (mv-mta-ucb030.ocn.ad.jp [153.149.230.164]) by mf-smf-ucb005.ocn.ad.jp (Switch-3.3.4/Switch-3.3.4) with ESMTP id vB68JNam000642; Wed, 6 Dec 2017 17:19:28 +0900 Received: from smtp.ocn.ne.jp ([153.149.227.167]) by ntt.pod01.mv-mta-ucb030 with id iYKT1w0043dLKTM01YKTsE; Wed, 06 Dec 2017 08:19:28 +0000 Received: from localhost.localdomain (sp49-98-150-93.msd.spmode.ne.jp [49.98.150.93]) by smtp.ocn.ne.jp (Postfix) with ESMTPA; Wed, 6 Dec 2017 17:19:27 +0900 (JST) 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 Date: Wed, 6 Dec 2017 17:18:20 +0900 Message-Id: <20171206081826.67688-1-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.13.1 Subject: [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Dec 2017 08:19:31 -0000 From: Yasufumi Ogawa 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 --- 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 #include #include +#include #include #include @@ -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