Soft Patch Panel
 help / color / mirror / Atom feed
From: Yasufumi Ogawa <yasufum.o@gmail.com>
To: Itsuro Oda <oda@valinux.co.jp>
Cc: spp@dpdk.org, ferruh.yigit@intel.com
Subject: Re: [spp] [PATCH 2/5] primary: suport pipe PMD
Date: Wed, 26 Feb 2020 15:29:47 +0900
Message-ID: <ffcc1f51-65fc-6b2d-dc04-d37b2be87280@gmail.com> (raw)
In-Reply-To: <20200226013746.2875-3-oda@valinux.co.jp>

> 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 <oda@valinux.co.jp>
> ---
>   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
This define was updated in a patch from Hideyuki, so it is failed to 
merge for a conflict. It might be other conflicts after that, but I 
haven't check it yet though.

Could you update your patch with the latest code base which was updated 
yesterday.

Thanks

> -#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
> 

  reply	other threads:[~2020-02-26  6:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26  1:37 [spp] [PATCH 0/5] REST API and CLI support for " Itsuro Oda
2020-02-26  1:37 ` [spp] [PATCH 1/5] shared: add PIPE port type Itsuro Oda
2020-02-26  1:37 ` [spp] [PATCH 2/5] primary: suport pipe PMD Itsuro Oda
2020-02-26  6:29   ` Yasufumi Ogawa [this message]
2020-02-26  1:37 ` [spp] [PATCH 3/5] spp_nfv: ignore " Itsuro Oda
2020-02-26  1:37 ` [spp] [PATCH 4/5] spp-ctl: enable add pipe port to the primary Itsuro Oda
2020-02-26  1:37 ` [spp] [PATCH 5/5] cli: support pipe PMD Itsuro Oda
2020-02-26  7:06 ` [spp] [PATCH v2 0/5] REST API and CLI support for " Itsuro Oda
2020-02-26  7:06   ` [spp] [PATCH v2 1/5] shared: add PIPE port type Itsuro Oda
2020-02-26  7:06   ` [spp] [PATCH v2 2/5] primary: suport pipe PMD Itsuro Oda
2020-02-26  7:06   ` [spp] [PATCH v2 3/5] spp_nfv: ignore " Itsuro Oda
2020-02-26  7:06   ` [spp] [PATCH v2 4/5] spp-ctl: enable add pipe port to the primary Itsuro Oda
2020-02-26  7:06   ` [spp] [PATCH v2 5/5] cli: support pipe PMD Itsuro Oda

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=ffcc1f51-65fc-6b2d-dc04-d37b2be87280@gmail.com \
    --to=yasufum.o@gmail.com \
    --cc=ferruh.yigit@intel.com \
    --cc=oda@valinux.co.jp \
    --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

Soft Patch Panel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/spp/0 spp/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 spp spp/ https://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git