[spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t
ogawa.yasufumi at lab.ntt.co.jp
ogawa.yasufumi at lab.ntt.co.jp
Wed Dec 6 09:18:20 CET 2017
From: Yasufumi Ogawa <ogawa.yasufumi at 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 at 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
More information about the spp
mailing list