* [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t
@ 2017-12-06 8:18 ogawa.yasufumi
2017-12-06 8:18 ` [spp] [PATCH 2/7] spp_vm: " ogawa.yasufumi
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: ogawa.yasufumi @ 2017-12-06 8:18 UTC (permalink / raw)
To: spp; +Cc: ferruh.yigit, ogawa.yasufumi, gerald.rogers, sy.jong.choi
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [spp] [PATCH 2/7] spp_vm: change type of port_id to uint16_t
2017-12-06 8:18 [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t ogawa.yasufumi
@ 2017-12-06 8:18 ` ogawa.yasufumi
2017-12-06 8:18 ` [spp] [PATCH 3/7] spp_primary: change type of ports_id " ogawa.yasufumi
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ogawa.yasufumi @ 2017-12-06 8:18 UTC (permalink / raw)
To: spp; +Cc: ferruh.yigit, ogawa.yasufumi, gerald.rogers, sy.jong.choi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
This patch is similar to previous commit for updating spp_nfv.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/vm/main.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/vm/main.c b/src/vm/main.c
index a1c4fac..7095446 100644
--- a/src/vm/main.c
+++ b/src/vm/main.c
@@ -63,10 +63,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 */
@@ -182,7 +182,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",
@@ -200,7 +200,7 @@ print_active_ports(char *str)
sprintf(str, "%d\n", client_id);
/* 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);
@@ -208,7 +208,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,");
@@ -250,7 +250,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) {
--
2.13.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [spp] [PATCH 3/7] spp_primary: change type of ports_id to uint16_t
2017-12-06 8:18 [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t ogawa.yasufumi
2017-12-06 8:18 ` [spp] [PATCH 2/7] spp_vm: " ogawa.yasufumi
@ 2017-12-06 8:18 ` ogawa.yasufumi
2017-12-06 8:18 ` [spp] [PATCH 4/7] spp_vm: " ogawa.yasufumi
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ogawa.yasufumi @ 2017-12-06 8:18 UTC (permalink / raw)
To: spp; +Cc: ferruh.yigit, ogawa.yasufumi, gerald.rogers, sy.jong.choi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Type of ID and number of ports managed in primary is uint8 while it is
changed from uint8_t to uint16_t in DPDK 17.11.
This update is to change type of ID and number of ports to uint16_t.
It also includes updates for common functions called from primary.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/primary/args.c | 2 +-
src/primary/args.h | 2 +-
src/primary/init.c | 3 ++-
src/primary/main.c | 2 +-
src/shared/common.c | 2 +-
src/shared/common.h | 6 +++---
6 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/primary/args.c b/src/primary/args.c
index 55433a1..a786d3a 100644
--- a/src/primary/args.c
+++ b/src/primary/args.c
@@ -66,7 +66,7 @@ usage(void)
* on error.
*/
int
-parse_app_args(uint8_t max_ports, int argc, char *argv[])
+parse_app_args(uint16_t max_ports, int argc, char *argv[])
{
int option_index, opt;
char **argvopt = argv;
diff --git a/src/primary/args.h b/src/primary/args.h
index 73e1f82..e290860 100644
--- a/src/primary/args.h
+++ b/src/primary/args.h
@@ -40,6 +40,6 @@ extern uint8_t num_clients;
extern char *server_ip;
extern int server_port;
-int parse_app_args(uint8_t max_ports, int argc, char *argv[]);
+int parse_app_args(uint16_t max_ports, int argc, char *argv[]);
#endif /* ifndef _ARGS_H_ */
diff --git a/src/primary/init.c b/src/primary/init.c
index 5ea21f9..7a15e9b 100644
--- a/src/primary/init.c
+++ b/src/primary/init.c
@@ -134,7 +134,8 @@ init(int argc, char *argv[])
{
int retval;
const struct rte_memzone *mz;
- uint8_t i, total_ports;
+ uint8_t i;
+ uint16_t total_ports;
/* init EAL, parsing EAL args */
retval = rte_eal_init(argc, argv);
diff --git a/src/primary/main.c b/src/primary/main.c
index 15fa53a..d3feef7 100644
--- a/src/primary/main.c
+++ b/src/primary/main.c
@@ -56,7 +56,7 @@ turn_off(int sig)
}
static const char *
-get_printable_mac_addr(uint8_t port)
+get_printable_mac_addr(uint16_t port)
{
static const char err_address[] = "00:00:00:00:00:00";
static char addresses[RTE_MAX_ETHPORTS][sizeof(err_address)];
diff --git a/src/shared/common.c b/src/shared/common.c
index da73cfe..9455294 100644
--- a/src/shared/common.c
+++ b/src/shared/common.c
@@ -160,7 +160,7 @@ init_port(uint8_t port_num, struct rte_mempool *pktmbuf_pool)
* array variable
*/
int
-parse_portmask(struct port_info *ports, uint8_t max_ports,
+parse_portmask(struct port_info *ports, uint16_t max_ports,
const char *portmask)
{
char *end = NULL;
diff --git a/src/shared/common.h b/src/shared/common.h
index 27138bd..5b8d11d 100644
--- a/src/shared/common.h
+++ b/src/shared/common.h
@@ -108,8 +108,8 @@ struct stats {
} __rte_cache_aligned;
struct port_info {
- uint8_t num_ports;
- uint8_t id[RTE_MAX_ETHPORTS];
+ uint16_t num_ports;
+ uint16_t id[RTE_MAX_ETHPORTS];
struct stats port_stats[RTE_MAX_ETHPORTS];
struct stats client_stats[MAX_CLIENT];
};
@@ -191,7 +191,7 @@ void check_all_ports_link_status(struct port_info *ports, uint8_t port_num,
int init_port(uint8_t port_num, struct rte_mempool *pktmbuf_pool);
-int parse_portmask(struct port_info *ports, uint8_t max_ports,
+int parse_portmask(struct port_info *ports, uint16_t max_ports,
const char *portmask);
int parse_num_clients(uint8_t *num_clients, const char *clients);
int parse_server(char **server_ip, int *server_port, char *server_addr);
--
2.13.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [spp] [PATCH 4/7] spp_vm: change type of ports_id to uint16_t
2017-12-06 8:18 [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t ogawa.yasufumi
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 ` ogawa.yasufumi
2017-12-06 8:18 ` [spp] [PATCH 5/7] spp/shared: " ogawa.yasufumi
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ogawa.yasufumi @ 2017-12-06 8:18 UTC (permalink / raw)
To: spp; +Cc: ferruh.yigit, ogawa.yasufumi, gerald.rogers, sy.jong.choi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
This update is to change type of ID and number of ports to uint16_t.
It also includes updates for common functions called from from spp_vm,
spp_primary and spp_nfv.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/nfv/nfv.c | 2 +-
src/primary/args.c | 2 +-
src/primary/args.h | 2 +-
src/shared/common.c | 4 ++--
src/shared/common.h | 2 +-
src/vm/args.c | 4 ++--
src/vm/args.h | 4 ++--
src/vm/init.c | 3 ++-
8 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/src/nfv/nfv.c b/src/nfv/nfv.c
index 4bd9f6d..9edf06d 100644
--- a/src/nfv/nfv.c
+++ b/src/nfv/nfv.c
@@ -46,7 +46,7 @@ static sig_atomic_t on = 1;
* our client id number - tells us which rx queue to read, and NIC TX
* queue to write to.
*/
-static uint8_t client_id;
+static uint16_t client_id;
static char *server_ip;
static int server_port;
diff --git a/src/primary/args.c b/src/primary/args.c
index a786d3a..ba7c69b 100644
--- a/src/primary/args.c
+++ b/src/primary/args.c
@@ -40,7 +40,7 @@
#include "init.h"
/* global var for number of clients - extern in header */
-uint8_t num_clients;
+uint16_t num_clients;
char *server_ip;
int server_port;
diff --git a/src/primary/args.h b/src/primary/args.h
index e290860..020e848 100644
--- a/src/primary/args.h
+++ b/src/primary/args.h
@@ -36,7 +36,7 @@
#include <stdint.h>
-extern uint8_t num_clients;
+extern uint16_t num_clients;
extern char *server_ip;
extern int server_port;
diff --git a/src/shared/common.c b/src/shared/common.c
index 9455294..7c7c6c8 100644
--- a/src/shared/common.c
+++ b/src/shared/common.c
@@ -197,7 +197,7 @@ parse_portmask(struct port_info *ports, uint16_t max_ports,
* and convert to a number to store in the num_clients variable
*/
int
-parse_num_clients(uint8_t *num_clients, const char *clients)
+parse_num_clients(uint16_t *num_clients, const char *clients)
{
char *end = NULL;
unsigned long temp;
@@ -209,7 +209,7 @@ parse_num_clients(uint8_t *num_clients, const char *clients)
if (end == NULL || *end != '\0' || temp == 0)
return -1;
- *num_clients = (uint8_t)temp;
+ *num_clients = (uint16_t)temp;
return 0;
}
diff --git a/src/shared/common.h b/src/shared/common.h
index 5b8d11d..33c4d4f 100644
--- a/src/shared/common.h
+++ b/src/shared/common.h
@@ -193,7 +193,7 @@ int init_port(uint8_t port_num, struct rte_mempool *pktmbuf_pool);
int parse_portmask(struct port_info *ports, uint16_t max_ports,
const char *portmask);
-int parse_num_clients(uint8_t *num_clients, const char *clients);
+int parse_num_clients(uint16_t *num_clients, const char *clients);
int parse_server(char **server_ip, int *server_port, char *server_addr);
int spp_atoi(const char *str, int *val);
diff --git a/src/vm/args.c b/src/vm/args.c
index dc11d77..f4bf856 100644
--- a/src/vm/args.c
+++ b/src/vm/args.c
@@ -40,7 +40,7 @@
#include "init.h"
/* global var for number of clients - extern in header */
-uint8_t client_id;
+uint16_t client_id;
char *server_ip;
int server_port;
@@ -66,7 +66,7 @@ usage(void)
* on error.
*/
int
-parse_app_args(uint8_t max_ports, int argc, char *argv[])
+parse_app_args(uint16_t max_ports, int argc, char *argv[])
{
int option_index, opt;
char **argvopt = argv;
diff --git a/src/vm/args.h b/src/vm/args.h
index ecaebd2..15243e5 100644
--- a/src/vm/args.h
+++ b/src/vm/args.h
@@ -36,10 +36,10 @@
#include <stdint.h>
-extern uint8_t client_id;
+extern uint16_t client_id;
extern char *server_ip;
extern int server_port;
-int parse_app_args(uint8_t max_ports, int argc, char *argv[]);
+int parse_app_args(uint16_t max_ports, int argc, char *argv[]);
#endif /* ifndef _ARGS_H_ */
diff --git a/src/vm/init.c b/src/vm/init.c
index 40b0ffe..4405489 100644
--- a/src/vm/init.c
+++ b/src/vm/init.c
@@ -91,7 +91,8 @@ init(int argc, char *argv[])
{
int retval;
const struct rte_memzone *mz;
- uint8_t i, total_ports;
+ uint8_t i;
+ uint16_t total_ports;
/* init EAL, parsing EAL args */
retval = rte_eal_init(argc, argv);
--
2.13.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [spp] [PATCH 5/7] spp/shared: change type of ports_id to uint16_t
2017-12-06 8:18 [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t ogawa.yasufumi
` (2 preceding siblings ...)
2017-12-06 8:18 ` [spp] [PATCH 4/7] spp_vm: " ogawa.yasufumi
@ 2017-12-06 8:18 ` ogawa.yasufumi
2017-12-06 8:18 ` [spp] [PATCH 6/7] spp: change type of counter " ogawa.yasufumi
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ogawa.yasufumi @ 2017-12-06 8:18 UTC (permalink / raw)
To: spp; +Cc: ferruh.yigit, ogawa.yasufumi, gerald.rogers, sy.jong.choi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
This update is to change argument type of ID and number of ports to
uint16_t.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/shared/common.c | 9 +++++----
src/shared/common.h | 4 ++--
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/shared/common.c b/src/shared/common.c
index 7c7c6c8..dd1f88c 100644
--- a/src/shared/common.c
+++ b/src/shared/common.c
@@ -37,12 +37,13 @@
/* Check the link status of all ports in up to 9s, and print them finally */
void
-check_all_ports_link_status(struct port_info *ports, uint8_t port_num,
+check_all_ports_link_status(struct port_info *ports, uint16_t port_num,
uint32_t port_mask)
{
#define CHECK_INTERVAL 100 /* 100ms */
#define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
- uint8_t portid, count, all_ports_up;
+ uint8_t count, all_ports_up;
+ uint16_t portid;
struct rte_eth_link link;
RTE_LOG(INFO, APP, "\nChecking link status");
@@ -102,7 +103,7 @@ check_all_ports_link_status(struct port_info *ports, uint8_t port_num,
* - start the port and report its status to stdout
*/
int
-init_port(uint8_t port_num, struct rte_mempool *pktmbuf_pool)
+init_port(uint16_t port_num, struct rte_mempool *pktmbuf_pool)
{
/* for port configuration all features are off by default */
const struct rte_eth_conf port_conf = {
@@ -165,7 +166,7 @@ parse_portmask(struct port_info *ports, uint16_t max_ports,
{
char *end = NULL;
unsigned long pm;
- uint8_t count = 0;
+ uint16_t count = 0;
if (portmask == NULL || *portmask == '\0')
return -1;
diff --git a/src/shared/common.h b/src/shared/common.h
index 33c4d4f..e29c7b9 100644
--- a/src/shared/common.h
+++ b/src/shared/common.h
@@ -186,10 +186,10 @@ get_vhost_iface_name(unsigned int id)
return buffer;
}
-void check_all_ports_link_status(struct port_info *ports, uint8_t port_num,
+void check_all_ports_link_status(struct port_info *ports, uint16_t port_num,
uint32_t port_mask);
-int init_port(uint8_t port_num, struct rte_mempool *pktmbuf_pool);
+int init_port(uint16_t port_num, struct rte_mempool *pktmbuf_pool);
int parse_portmask(struct port_info *ports, uint16_t max_ports,
const char *portmask);
--
2.13.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [spp] [PATCH 6/7] spp: change type of counter to uint16_t
2017-12-06 8:18 [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t ogawa.yasufumi
` (3 preceding siblings ...)
2017-12-06 8:18 ` [spp] [PATCH 5/7] spp/shared: " ogawa.yasufumi
@ 2017-12-06 8:18 ` 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
6 siblings, 0 replies; 8+ messages in thread
From: ogawa.yasufumi @ 2017-12-06 8:18 UTC (permalink / raw)
To: spp; +Cc: ferruh.yigit, ogawa.yasufumi, gerald.rogers, sy.jong.choi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Counters of uint8_t for ports should be changed to uint16_t. The name
of counter 'i' is also changed to 'count' to be more explicit meaning.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/primary/init.c | 9 ++++-----
src/vm/init.c | 9 ++++-----
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/src/primary/init.c b/src/primary/init.c
index 7a15e9b..2630783 100644
--- a/src/primary/init.c
+++ b/src/primary/init.c
@@ -134,8 +134,7 @@ init(int argc, char *argv[])
{
int retval;
const struct rte_memzone *mz;
- uint8_t i;
- uint16_t total_ports;
+ uint16_t count, total_ports;
/* init EAL, parsing EAL args */
retval = rte_eal_init(argc, argv);
@@ -177,11 +176,11 @@ init(int argc, char *argv[])
/* now initialise the ports we will use */
if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
- for (i = 0; i < ports->num_ports; i++) {
- retval = init_port(ports->id[i], pktmbuf_pool);
+ for (count = 0; count < ports->num_ports; count++) {
+ retval = init_port(ports->id[count], pktmbuf_pool);
if (retval != 0)
rte_exit(EXIT_FAILURE,
- "Cannot initialise port %d\n", i);
+ "Cannot initialise port %d\n", count);
}
}
check_all_ports_link_status(ports, ports->num_ports, (~0x0));
diff --git a/src/vm/init.c b/src/vm/init.c
index 4405489..fb9b7ec 100644
--- a/src/vm/init.c
+++ b/src/vm/init.c
@@ -91,8 +91,7 @@ init(int argc, char *argv[])
{
int retval;
const struct rte_memzone *mz;
- uint8_t i;
- uint16_t total_ports;
+ uint16_t count, total_ports;
/* init EAL, parsing EAL args */
retval = rte_eal_init(argc, argv);
@@ -130,11 +129,11 @@ init(int argc, char *argv[])
/* now initialise the ports we will use */
if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
- for (i = 0; i < total_ports; i++) {
- retval = init_port(ports->id[i], pktmbuf_pool);
+ for (count = 0; count < total_ports; count++) {
+ retval = init_port(ports->id[count], pktmbuf_pool);
if (retval != 0)
rte_exit(EXIT_FAILURE,
- "Cannot initialise port %d\n", i);
+ "Cannot initialise port %d\n", count);
}
}
check_all_ports_link_status(ports, total_ports, (~0x0));
--
2.13.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [spp] [PATCH 7/7] spp/shared: refactor printing port status
2017-12-06 8:18 [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t ogawa.yasufumi
` (4 preceding siblings ...)
2017-12-06 8:18 ` [spp] [PATCH 6/7] spp: change type of counter " ogawa.yasufumi
@ 2017-12-06 8:18 ` ogawa.yasufumi
2017-12-07 18:08 ` [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t Ferruh Yigit
6 siblings, 0 replies; 8+ messages in thread
From: ogawa.yasufumi @ 2017-12-06 8:18 UTC (permalink / raw)
To: spp; +Cc: ferruh.yigit, ogawa.yasufumi, gerald.rogers, sy.jong.choi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Port status of each of clients is printed with print_active_ports().
It is defined in both of spp_nfv and spp_vm. It is redundant and should
be changed to be a common library function.
This update is to move print_active_ports() in shared/common.c as common
library. This update also following changes.
* client_id, ports_fwd_array and port_map are added as arguments
of this function to be enable them referred.
* Print 'none' instead of port_id if port is unassigned.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/nfv/nfv.c | 53 +-------------------------------------------
src/shared/common.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
src/shared/common.h | 4 ++++
src/vm/main.c | 52 +------------------------------------------
4 files changed, 69 insertions(+), 103 deletions(-)
diff --git a/src/nfv/nfv.c b/src/nfv/nfv.c
index 9edf06d..5972657 100644
--- a/src/nfv/nfv.c
+++ b/src/nfv/nfv.c
@@ -232,57 +232,6 @@ forward_array_reset(void)
}
}
-/* print forward array active port*/
-static void
-print_active_ports(char *str)
-{
- unsigned int i;
-
- sprintf(str, "%d\n", client_id);
-
- /* every elements value*/
- for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
- if (ports_fwd_array[i].in_port_id == PORT_RESET)
- continue;
-
- RTE_LOG(INFO, APP, "Port ID %d\n", i);
- RTE_LOG(INFO, APP, "Status %d\n",
- ports_fwd_array[i].in_port_id);
-
- sprintf(str + strlen(str), "port id: %d,", i);
- if (ports_fwd_array[i].in_port_id != PORT_RESET)
- sprintf(str + strlen(str), "on,");
- else
- sprintf(str + strlen(str), "off,");
-
- switch (port_map[i].port_type) {
- case PHY:
- RTE_LOG(INFO, APP, "Type: PHY\n");
- sprintf(str + strlen(str), "PHY,");
- break;
- case RING:
- RTE_LOG(INFO, APP, "Type: RING\n");
- sprintf(str + strlen(str), "RING(%u),",
- port_map[i].id);
- break;
- case VHOST:
- RTE_LOG(INFO, APP, "Type: VHOST\n");
- sprintf(str + strlen(str), "VHOST(%u),",
- port_map[i].id);
- break;
- case UNDEF:
- RTE_LOG(INFO, APP, "Type: UDF\n");
- sprintf(str + strlen(str), "UDF,");
- break;
- }
-
- RTE_LOG(INFO, APP, "Out Port ID %d\n",
- ports_fwd_array[i].out_port_id);
- sprintf(str + strlen(str), "outport: %d\n",
- ports_fwd_array[i].out_port_id);
- }
-}
-
static int
do_send(int *connected, int *sock, char *str)
{
@@ -560,7 +509,7 @@ parse_command(char *str)
i = sprintf(str, "Client ID %d Running\n", client_id);
else
i = sprintf(str, "Client ID %d Idling\n", client_id);
- print_active_ports(str + i);
+ print_active_ports(str + i, client_id, ports_fwd_array, port_map);
} else if (!strcmp(token_list[0], "_get_client_id")) {
memset(str, '\0', MSG_SIZE);
diff --git a/src/shared/common.c b/src/shared/common.c
index dd1f88c..5b87385 100644
--- a/src/shared/common.c
+++ b/src/shared/common.c
@@ -250,3 +250,66 @@ spp_atoi(const char *str, int *val)
return 0;
}
+
+/*
+ * Print port status in forward array
+ *
+ * Each of port status is formatted as
+ * "port_id:[PORT_ID],[IN_PORT_STAT],[TYPE],output:[OUTPORT_STAT]"
+ */
+void
+print_active_ports(char *str, uint16_t client_id,
+ struct port *ports_fwd_array,
+ struct port_map *port_map)
+{
+ unsigned int i;
+
+ sprintf(str, "clinet_id:%d\n", client_id);
+
+ /* Every elements value */
+ for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
+ if (ports_fwd_array[i].in_port_id == PORT_RESET)
+ continue;
+
+ RTE_LOG(INFO, APP, "Port ID %d\n", i);
+ RTE_LOG(INFO, APP, "Status %d\n",
+ ports_fwd_array[i].in_port_id);
+
+ sprintf(str + strlen(str), "port_id:%d,", i);
+ /* in_port_id is same value as port_id */
+ if (ports_fwd_array[i].in_port_id != PORT_RESET)
+ sprintf(str + strlen(str), "on,");
+ else
+ sprintf(str + strlen(str), "off,");
+
+ switch (port_map[i].port_type) {
+ case PHY:
+ RTE_LOG(INFO, APP, "Type: PHY\n");
+ sprintf(str + strlen(str), "PHY,");
+ break;
+ case RING:
+ RTE_LOG(INFO, APP, "Type: RING\n");
+ sprintf(str + strlen(str), "RING(%u),",
+ port_map[i].id);
+ break;
+ case VHOST:
+ RTE_LOG(INFO, APP, "Type: VHOST\n");
+ sprintf(str + strlen(str), "VHOST(%u),",
+ port_map[i].id);
+ break;
+ case UNDEF:
+ RTE_LOG(INFO, APP, "Type: UDF\n");
+ sprintf(str + strlen(str), "UDF,");
+ break;
+ }
+
+ RTE_LOG(INFO, APP, "Out Port ID %d\n",
+ ports_fwd_array[i].out_port_id);
+ if (ports_fwd_array[i].out_port_id == PORT_RESET) {
+ sprintf(str + strlen(str), "outport:%s\n", "none");
+ } else {
+ sprintf(str + strlen(str), "outport:%d\n",
+ ports_fwd_array[i].out_port_id);
+ }
+ }
+}
diff --git a/src/shared/common.h b/src/shared/common.h
index e29c7b9..5defbb0 100644
--- a/src/shared/common.h
+++ b/src/shared/common.h
@@ -196,6 +196,10 @@ int parse_portmask(struct port_info *ports, uint16_t max_ports,
int parse_num_clients(uint16_t *num_clients, const char *clients);
int parse_server(char **server_ip, int *server_port, char *server_addr);
+void print_active_ports(char *str, uint16_t client_id,
+ struct port *ports_fwd_array,
+ struct port_map *port_map);
+
int spp_atoi(const char *str, int *val);
#define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
diff --git a/src/vm/main.c b/src/vm/main.c
index 7095446..c9f1571 100644
--- a/src/vm/main.c
+++ b/src/vm/main.c
@@ -191,56 +191,6 @@ forward_array_reset(void)
}
}
-/* print forward array active port */
-static void
-print_active_ports(char *str)
-{
- unsigned int i;
-
- sprintf(str, "%d\n", client_id);
- /* every elements value */
- for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
- if (ports_fwd_array[i].in_port_id == PORT_RESET)
- continue;
-
- RTE_LOG(INFO, APP, "Port ID %d\n", i);
- RTE_LOG(INFO, APP, "Status %d\n",
- ports_fwd_array[i].in_port_id);
-
- sprintf(str + strlen(str), "port id: %d,", i);
- if (ports_fwd_array[i].in_port_id != PORT_RESET)
- sprintf(str + strlen(str), "on,");
- else
- sprintf(str + strlen(str), "off,");
-
- switch (port_map[i].port_type) {
- case PHY:
- RTE_LOG(INFO, APP, "Type: PHY\n");
- sprintf(str + strlen(str), "PHY,");
- break;
- case RING:
- RTE_LOG(INFO, APP, "Type: RING\n");
- sprintf(str + strlen(str), "RING(%u),",
- port_map[i].id);
- break;
- case VHOST:
- RTE_LOG(INFO, APP, "Type: VHOST\n");
- sprintf(str + strlen(str), "VHOST(%u),",
- port_map[i].id);
- break;
- case UNDEF:
- RTE_LOG(INFO, APP, "Type: UDF\n");
- sprintf(str + strlen(str), "UDF,");
- break;
- }
-
- RTE_LOG(INFO, APP, "Out Port ID %d\n",
- ports_fwd_array[i].out_port_id);
- sprintf(str + strlen(str), "outport: %d\n",
- ports_fwd_array[i].out_port_id);
- }
-}
-
static void
forward_array_remove(int port_id)
{
@@ -456,7 +406,7 @@ parse_command(char *str)
i = sprintf(str, "Client ID %d Running\n", client_id);
else
i = sprintf(str, "Client ID %d Idling\n", client_id);
- print_active_ports(str + i);
+ print_active_ports(str + i, client_id, ports_fwd_array, port_map);
} else if (!strcmp(token_list[0], "_get_client_id")) {
memset(str, '\0', MSG_SIZE);
--
2.13.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t
2017-12-06 8:18 [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t ogawa.yasufumi
` (5 preceding siblings ...)
2017-12-06 8:18 ` [spp] [PATCH 7/7] spp/shared: refactor printing port status ogawa.yasufumi
@ 2017-12-07 18:08 ` Ferruh Yigit
6 siblings, 0 replies; 8+ messages in thread
From: Ferruh Yigit @ 2017-12-07 18:08 UTC (permalink / raw)
To: ogawa.yasufumi, spp; +Cc: gerald.rogers, sy.jong.choi
On 12/6/2017 12:18 AM, ogawa.yasufumi@lab.ntt.co.jp wrote:
> 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>
Series applied, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-12-07 18:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-06 8:18 [spp] [PATCH 1/7] spp_nfv: change type of port_id to uint16_t ogawa.yasufumi
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
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).