From: ogawa.yasufumi@lab.ntt.co.jp
To: ferruh.yigit@intel.com, spp@dpdk.org, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 1/3] spp_primary: add lcores in status info
Date: Thu, 31 Jan 2019 12:05:04 +0900 [thread overview]
Message-ID: <1548903906-17403-2-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1548903906-17403-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
This patch is to add lcore used by spp_primary in the result of status
command. It is contained as a list and referred with key `lcores`.
{
"lcores": [0, 1],
"ring_ports": [
{
"id": 0,
"rx": 0,
"rx_drop": 0,
"tx": 0,
"tx_drop": 0
},
...
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/primary/init.h | 2 ++
src/primary/main.c | 34 +++++++++++++++++++++++++++-------
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/src/primary/init.h b/src/primary/init.h
index 3ea69f0..6344377 100644
--- a/src/primary/init.h
+++ b/src/primary/init.h
@@ -38,6 +38,8 @@ struct ring_port {
} stats;
};
+extern uint8_t lcore_id_used[RTE_MAX_LCORE];
+
extern struct ring_port *ring_ports;
/* the shared port information: port numbers, rx and tx stats etc. */
diff --git a/src/primary/main.c b/src/primary/main.c
index 9185e3d..c86e9ef 100644
--- a/src/primary/main.c
+++ b/src/primary/main.c
@@ -21,8 +21,9 @@
* Buffer sizes of status message of primary. Total number of size
* must be equal to MSG_SIZE 2048 defined in `shared/common.h`.
*/
+#define PRI_BUF_SIZE_LCORE 128
#define PRI_BUF_SIZE_PHY 512
-#define PRI_BUF_SIZE_RING 1512
+#define PRI_BUF_SIZE_RING (MSG_SIZE - PRI_BUF_SIZE_LCORE - PRI_BUF_SIZE_PHY)
#define SPP_PATH_LEN 1024 /* seems enough for path of spp procs */
#define NOF_TOKENS 48 /* seems enough to contain tokens */
@@ -43,6 +44,9 @@ static enum cmd_type cmd = STOP;
static struct pollfd pfd;
+/* global var for number of rings - extern in header */
+uint8_t lcore_id_used[RTE_MAX_LCORE];
+
static void
turn_off(int sig)
{
@@ -306,6 +310,7 @@ launch_sec_proc(char *sec_name, int sec_id, char **sec_args)
* Here is an exmaple.
*
* {
+ * "lcores": [0],
* "ring_ports": [
* {
* "id": 0,
@@ -332,15 +337,30 @@ static int
get_status_json(char *str)
{
int i;
+ int lcore_buf_size = PRI_BUF_SIZE_LCORE;
int phyp_buf_size = PRI_BUF_SIZE_PHY;
int ringp_buf_size = PRI_BUF_SIZE_RING;
+ char lcore_ids[PRI_BUF_SIZE_LCORE];
char phy_ports[phyp_buf_size];
char ring_ports[ringp_buf_size];
+ memset(lcore_ids, '\0', lcore_buf_size);
memset(phy_ports, '\0', phyp_buf_size);
memset(ring_ports, '\0', ringp_buf_size);
- int buf_size = 256;
+ int buf_size = 256; /* size of temp buffer */
+ char lcore_id[108]; /* seems enough */
char phy_port[buf_size];
+ char ring_port[buf_size];
+
+ memset(lcore_id, '\0', sizeof(lcore_id));
+ for (i = 0; i < RTE_MAX_LCORE; i++) {
+ if (lcore_id_used[i] == 1)
+ sprintf(lcore_id + strlen(lcore_id), "%d,", i);
+ }
+ sprintf(lcore_id + strlen(lcore_id) - 1, "%s", "");
+
+ sprintf(lcore_ids, "\"lcores\":[%s]", lcore_id);
+
for (i = 0; i < ports->num_ports; i++) {
RTE_LOG(DEBUG, PRIMARY, "Size of phy_ports str: %d\n",
@@ -373,7 +393,6 @@ get_status_json(char *str)
sprintf(phy_ports, "%s,", phy_ports);
}
- char ring_port[buf_size];
for (i = 0; i < num_rings; i++) {
RTE_LOG(DEBUG, PRIMARY, "Size of ring_ports str: %d\n",
@@ -406,11 +425,12 @@ get_status_json(char *str)
sprintf(ring_ports, "%s,", ring_ports);
}
- RTE_LOG(DEBUG, PRIMARY, "{\"phy_ports\": [%s], \"ring_ports\": [%s]}",
- phy_ports, ring_ports);
+ RTE_LOG(DEBUG, PRIMARY,
+ "{%s, \"phy_ports\": [%s], \"ring_ports\": [%s]}\n",
+ lcore_ids, phy_ports, ring_ports);
- sprintf(str, "{\"phy_ports\": [%s], \"ring_ports\": [%s]}",
- phy_ports, ring_ports);
+ sprintf(str, "{%s, \"phy_ports\": [%s], \"ring_ports\": [%s]}",
+ lcore_ids, phy_ports, ring_ports);
return 0;
}
--
2.7.4
next prev parent reply other threads:[~2019-01-31 3:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-31 3:05 [spp] [PATCH 0/3] Add getting lcores feature ogawa.yasufumi
2019-01-31 3:05 ` ogawa.yasufumi [this message]
2019-01-31 3:05 ` [spp] [PATCH 2/3] controller: add lcores in status command of pri ogawa.yasufumi
2019-01-31 3:05 ` [spp] [PATCH 3/3] spp-ctl: add API for getting CPU layout ogawa.yasufumi
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=1548903906-17403-2-git-send-email-ogawa.yasufumi@lab.ntt.co.jp \
--to=ogawa.yasufumi@lab.ntt.co.jp \
--cc=ferruh.yigit@intel.com \
--cc=spp@dpdk.org \
/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).