From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E0FAFA055E for ; Wed, 26 Feb 2020 02:37:50 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B58501BFCC; Wed, 26 Feb 2020 02:37:49 +0100 (CET) Received: from valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by dpdk.org (Postfix) with ESMTP id B076D1BFAB for ; Wed, 26 Feb 2020 02:37:47 +0100 (CET) Received: by valinux.co.jp (Postfix, from userid 1000) id CDD7D24086A; Wed, 26 Feb 2020 10:37:46 +0900 (JST) From: Itsuro Oda To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Wed, 26 Feb 2020 10:37:43 +0900 Message-Id: <20200226013746.2875-3-oda@valinux.co.jp> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200226013746.2875-1-oda@valinux.co.jp> References: <20200226013746.2875-1-oda@valinux.co.jp> Subject: [spp] [PATCH 2/5] primary: suport pipe PMD 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: , Errors-To: spp-bounces@dpdk.org Sender: "spp" This patch enables the primary to handle add/del request of pipe PMD. The primary comes to return infomation of pipes in the response of status request too. Signed-off-by: Itsuro Oda --- src/primary/main.c | 85 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 77 insertions(+), 8 deletions(-) diff --git a/src/primary/main.c b/src/primary/main.c index d3828e8..8d6a83d 100644 --- a/src/primary/main.c +++ b/src/primary/main.c @@ -27,7 +27,9 @@ */ #define PRI_BUF_SIZE_LCORE 128 #define PRI_BUF_SIZE_PHY 512 -#define PRI_BUF_SIZE_RING (MSG_SIZE - PRI_BUF_SIZE_LCORE - PRI_BUF_SIZE_PHY) +#define PRI_BUF_SIZE_PIPE 512 +#define PRI_BUF_SIZE_RING \ + (MSG_SIZE - PRI_BUF_SIZE_LCORE - PRI_BUF_SIZE_PHY - PRI_BUF_SIZE_PIPE) #define SPP_PATH_LEN 1024 /* seems enough for path of spp procs */ #define NOF_TOKENS 48 /* seems enough to contain tokens */ @@ -49,6 +51,7 @@ struct port_id_map { int port_id; enum port_type type; + int rx_ring_id, tx_ring_id; /* for pipe */ }; struct port_id_map port_id_list[RTE_MAX_ETHPORTS]; @@ -437,6 +440,10 @@ append_port_info_json(char *str, sprintf(str + strlen(str), "\"memif:%u\",", port_map[i].id); break; + case PIPE: + sprintf(str + strlen(str), "\"pipe:%u\",", + port_map[i].id); + break; case UNDEF: /* TODO(yasufum) Need to remove print for undefined ? */ sprintf(str + strlen(str), "\"udf\","); @@ -521,6 +528,12 @@ append_patch_info_json(char *str, "\"memif:%u\",", port_map[i].id); break; + case PIPE: + RTE_LOG(INFO, SHARED, "Type: PIPE\n"); + sprintf(patch_str + strlen(patch_str), + "\"pipe:%u\",", + port_map[i].id); + break; case UNDEF: RTE_LOG(INFO, PRIMARY, "Type: UDF\n"); /* TODO(yasufum) Need to remove print for undefined ? */ @@ -583,6 +596,12 @@ append_patch_info_json(char *str, "\"memif:%u\"", port_map[j].id); break; + case PIPE: + RTE_LOG(INFO, SHARED, "Type: PIPE\n"); + sprintf(patch_str + strlen(patch_str), + "\"pipe:%u\"", + port_map[j].id); + break; case UNDEF: RTE_LOG(INFO, PRIMARY, "Type: UDF\n"); /* @@ -729,6 +748,34 @@ ring_port_stats_json(char *str) return 0; } +static int +pipes_json(char *str) +{ + uint16_t dev_id; + char pipe_buf[30]; /* it is enough if port_id < 1000 */ + int find = 0; + + strcpy(str, "\"pipes\":["); + for (dev_id = 0; dev_id < RTE_MAX_ETHPORTS; dev_id++) { + if (port_id_list[dev_id].type != PIPE) + continue; + sprintf(pipe_buf, "{\"id\":%d,\"rx\":%d,\"tx\":%d}", + port_id_list[dev_id].port_id, + port_id_list[dev_id].rx_ring_id, + port_id_list[dev_id].tx_ring_id); + if (strlen(str) + strlen(pipe_buf) > PRI_BUF_SIZE_PIPE - 3) { + RTE_LOG(ERR, PRIMARY, "Cannot send all of pipes\n"); + break; + } + if (find) + strcat(str, ","); + find = 1; + strcat(str, pipe_buf); + } + strcat(str, "]"); + return 0; +} + /** * Retrieve all of statu of ports as JSON format managed by primary. * @@ -770,28 +817,33 @@ get_status_json(char *str) char buf_lcores[PRI_BUF_SIZE_LCORE]; char buf_phy_ports[PRI_BUF_SIZE_PHY]; char buf_ring_ports[PRI_BUF_SIZE_RING]; + char buf_pipes[PRI_BUF_SIZE_PIPE]; memset(buf_phy_ports, '\0', PRI_BUF_SIZE_PHY); memset(buf_ring_ports, '\0', PRI_BUF_SIZE_RING); memset(buf_lcores, '\0', PRI_BUF_SIZE_LCORE); + memset(buf_pipes, '\0', PRI_BUF_SIZE_PIPE); append_lcore_info_json(buf_lcores, lcore_id_used); phy_port_stats_json(buf_phy_ports); ring_port_stats_json(buf_ring_ports); + pipes_json(buf_pipes); - RTE_LOG(INFO, PRIMARY, "%s, %s\n", buf_phy_ports, buf_ring_ports); + RTE_LOG(INFO, PRIMARY, "%s, %s, %s\n", buf_phy_ports, buf_ring_ports, + buf_pipes); if (get_forwarding_flg() == 1) { char tmp_buf[512]; memset(tmp_buf, '\0', sizeof(tmp_buf)); forwarder_status_json(tmp_buf); - sprintf(str, "{%s,%s,%s,%s}", + sprintf(str, "{%s,%s,%s,%s,%s}", buf_lcores, tmp_buf, buf_phy_ports, - buf_ring_ports); + buf_ring_ports, buf_pipes); } else { - sprintf(str, "{%s,%s,%s}", - buf_lcores, buf_phy_ports, buf_ring_ports); + sprintf(str, "{%s,%s,%s,%s}", + buf_lcores, buf_phy_ports, buf_ring_ports, + buf_pipes); } return 0; @@ -803,7 +855,7 @@ get_status_json(char *str) */ /* TODO(yasufum) consider to merge do_add in nfv/commands.h */ static int -add_port(char *p_type, int p_id) +add_port(char *p_type, int p_id, char **token_list) { uint16_t dev_id; uint16_t port_id; @@ -840,6 +892,17 @@ add_port(char *p_type, int p_id) res = add_null_pmd(p_id); port_id_list[cnt].port_id = p_id; port_id_list[cnt].type = NULLPMD; + } else if (!strcmp(p_type, "pipe")) { + char *dummy; + res = add_pipe_pmd(p_id, token_list[0], token_list[1]); + if (res < 0) + return -1; + port_id_list[cnt].port_id = p_id; + port_id_list[cnt].type = PIPE; + parse_resource_uid(token_list[0], &dummy, + &port_id_list[cnt].rx_ring_id); + parse_resource_uid(token_list[1], &dummy, + &port_id_list[cnt].tx_ring_id); } if (res < 0) @@ -922,6 +985,12 @@ del_port(char *p_type, int p_id) if (dev_id == PORT_RESET) return -1; dev_detach_by_port_id(dev_id); + + } else if (!strcmp(p_type, "pipe")) { + dev_id = find_ethdev_id(p_id, PIPE); + if (dev_id == PORT_RESET) + return -1; + dev_detach_by_port_id(dev_id); } port_id_list[dev_id].port_id = PORT_RESET; @@ -1022,7 +1091,7 @@ parse_command(char *str) return ret; } - if (add_port(p_type, p_id) < 0) { + if (add_port(p_type, p_id, &token_list[2]) < 0) { RTE_LOG(ERR, PRIMARY, "Failed to add_port()\n"); sprintf(result, "%s", "\"failed\""); } else -- 2.17.1