From patchwork Tue Jan 19 07:14:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 86855 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 21659A0A03; Tue, 19 Jan 2021 08:15:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 01947140D37; Tue, 19 Jan 2021 08:15:43 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 0F416140D2B for ; Tue, 19 Jan 2021 08:15:41 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 19 Jan 2021 09:15:41 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 10J7FfYa003537; Tue, 19 Jan 2021 09:15:41 +0200 From: Xueming Li To: Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso , Ajit Khaparde , Somnath Kotur , John Daley , Hyong Youb Kim , Beilei Xing , Jeff Guo , Haiyue Wang , Matan Azrad , Shahaf Shuler , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Tue, 19 Jan 2021 07:14:53 +0000 Message-Id: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [PATCH v5 1/9] ethdev: introduce representor type X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" To support more representor type, this patch introduces representor type enum. The enum is subject to extend for new types upcoming. Signed-off-by: Xueming Li Acked-by: Viacheslav Ovsiienko Acked-by: Thomas Monjalon Acked-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_ethdev.c | 7 +++++++ drivers/net/enic/enic_ethdev.c | 7 +++++++ drivers/net/i40e/i40e_ethdev.c | 8 ++++++++ drivers/net/ixgbe/ixgbe_ethdev.c | 8 ++++++++ drivers/net/mlx5/linux/mlx5_os.c | 11 +++++++++++ lib/librte_ethdev/ethdev_private.c | 5 +++++ lib/librte_ethdev/rte_ethdev_driver.h | 9 +++++++++ 7 files changed, 55 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 74b0f3d1dc..d7c8b3ec07 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -5586,6 +5586,13 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, int i, ret = 0; struct rte_kvargs *kvlist = NULL; + if (eth_da->type == RTE_ETH_REPRESENTOR_NONE) + return 0; + if (eth_da->type != RTE_ETH_REPRESENTOR_VF) { + PMD_DRV_LOG(ERR, "unsupported representor type %d\n", + eth_da->type); + return -ENOTSUP; + } num_rep = eth_da->nb_representor_ports; if (num_rep > BNXT_MAX_VF_REPS) { PMD_DRV_LOG(ERR, "nb_representor_ports = %d > %d MAX VF REPS\n", diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index d041a6bee9..dd085caa93 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -1303,6 +1303,13 @@ static int eth_enic_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, if (retval) return retval; } + if (eth_da.type == RTE_ETH_REPRESENTOR_NONE) + return 0; + if (eth_da.type != RTE_ETH_REPRESENTOR_VF) { + ENICPMD_LOG(ERR, "unsupported representor type: %s\n", + pci_dev->device.devargs->args); + return -ENOTSUP; + } retval = rte_eth_dev_create(&pci_dev->device, pci_dev->device.name, sizeof(struct enic), eth_dev_pci_specific_init, pci_dev, diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index f083ac52fa..eb55d64585 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -638,6 +638,14 @@ eth_i40e_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, return retval; } + if (eth_da.type == RTE_ETH_REPRESENTOR_NONE) + return 0; + if (eth_da.type != RTE_ETH_REPRESENTOR_VF) { + PMD_DRV_LOG(ERR, "unsupported representor type: %s\n", + pci_dev->device.devargs->args); + return -ENOTSUP; + } + retval = rte_eth_dev_create(&pci_dev->device, pci_dev->device.name, sizeof(struct i40e_adapter), eth_dev_pci_specific_init, pci_dev, diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index fa0f5afd03..6f1a710dae 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -1717,6 +1717,14 @@ eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, } else memset(ð_da, 0, sizeof(eth_da)); + if (eth_da.type == RTE_ETH_REPRESENTOR_NONE) + return 0; + if (eth_da.type != RTE_ETH_REPRESENTOR_VF) { + PMD_DRV_LOG(ERR, "unsupported representor type: %s\n", + pci_dev->device.devargs->args); + return -ENOTSUP; + } + retval = rte_eth_dev_create(&pci_dev->device, pci_dev->device.name, sizeof(struct ixgbe_adapter), eth_dev_pci_specific_init, pci_dev, diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 9ac1d46b1b..caead107b0 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -705,6 +705,17 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, strerror(rte_errno)); return NULL; } + if (eth_da.type != RTE_ETH_REPRESENTOR_NONE) { + /* Representor not specified. */ + rte_errno = EBUSY; + return NULL; + } + if (eth_da.type != RTE_ETH_REPRESENTOR_VF) { + rte_errno = ENOTSUP; + DRV_LOG(ERR, "unsupported representor type: %s", + dpdk_dev->devargs->args); + return NULL; + } for (i = 0; i < eth_da.nb_representor_ports; ++i) if (eth_da.representor_ports[i] == (uint16_t)switch_info->port_name) diff --git a/lib/librte_ethdev/ethdev_private.c b/lib/librte_ethdev/ethdev_private.c index 162a502fe7..c1a411dba4 100644 --- a/lib/librte_ethdev/ethdev_private.c +++ b/lib/librte_ethdev/ethdev_private.c @@ -111,11 +111,16 @@ rte_eth_devargs_process_range(char *str, uint16_t *list, uint16_t *len_list, return 0; } +/* + * representor format: + * #: range or single number of VF representor + */ int rte_eth_devargs_parse_representor_ports(char *str, void *data) { struct rte_eth_devargs *eth_da = data; + eth_da->type = RTE_ETH_REPRESENTOR_VF; return rte_eth_devargs_process_range(str, eth_da->representor_ports, ð_da->nb_representor_ports, RTE_MAX_ETHPORTS); } diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h index 0eacfd8425..cd33184f17 100644 --- a/lib/librte_ethdev/rte_ethdev_driver.h +++ b/lib/librte_ethdev/rte_ethdev_driver.h @@ -1193,6 +1193,14 @@ __rte_internal int rte_eth_switch_domain_free(uint16_t domain_id); +/** Ethernet device representor port type */ +enum rte_eth_representor_type { + RTE_ETH_REPRESENTOR_NONE, /**< not a representor. */ + RTE_ETH_REPRESENTOR_VF, /**< representor of Virtual Function. */ + RTE_ETH_REPRESENTOR_SF, /**< representor of Sub Function. */ + RTE_ETH_REPRESENTOR_PF, /**< representor of host Physical Function. */ +}; + /** Generic Ethernet device arguments */ struct rte_eth_devargs { uint16_t ports[RTE_MAX_ETHPORTS]; @@ -1203,6 +1211,7 @@ struct rte_eth_devargs { /** representor port/s identifier to enable on device */ uint16_t nb_representor_ports; /** number of ports in representor port field */ + enum rte_eth_representor_type type; /* type of representor */ }; /** From patchwork Tue Jan 19 07:14:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 86856 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4B7C7A0A03; Tue, 19 Jan 2021 08:15:50 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA129140D57; Tue, 19 Jan 2021 08:15:48 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id DD7E0140D55 for ; Tue, 19 Jan 2021 08:15:46 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 19 Jan 2021 09:15:41 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 10J7FfYb003537; Tue, 19 Jan 2021 09:15:41 +0200 From: Xueming Li To: Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Tue, 19 Jan 2021 07:14:54 +0000 Message-Id: <1611040501-11666-2-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> References: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> In-Reply-To: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [PATCH v5 2/9] ethdev: support representor port list X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" To support extended representor syntax, this patch extends the representor list parsing to support for representor port range in devargs, examples: representor=[1,2,3] - single list representor=[1,3-5,7,9-11] - list with singles and ranges Signed-off-by: Xueming Li Acked-by: Viacheslav Ovsiienko Acked-by: Thomas Monjalon --- lib/librte_ethdev/ethdev_private.c | 124 ++++++++++++++++------------- lib/librte_ethdev/ethdev_private.h | 3 - lib/librte_ethdev/rte_class_eth.c | 4 +- lib/librte_ethdev/rte_ethdev.c | 5 +- 4 files changed, 72 insertions(+), 64 deletions(-) diff --git a/lib/librte_ethdev/ethdev_private.c b/lib/librte_ethdev/ethdev_private.c index c1a411dba4..e87636f665 100644 --- a/lib/librte_ethdev/ethdev_private.c +++ b/lib/librte_ethdev/ethdev_private.c @@ -38,82 +38,93 @@ eth_find_device(const struct rte_eth_dev *start, rte_eth_cmp_t cmp, return NULL; } -int -rte_eth_devargs_parse_list(char *str, rte_eth_devargs_callback_t callback, - void *data) +/* Put new value into list. */ +static int +rte_eth_devargs_enlist(uint16_t *list, uint16_t *len_list, + const uint16_t max_list, uint16_t val) { - char *str_start; - int state; - int result; + uint16_t i; - if (*str != '[') - /* Single element, not a list */ - return callback(str, data); - - /* Sanity check, then strip the brackets */ - str_start = &str[strlen(str) - 1]; - if (*str_start != ']') { - RTE_LOG(ERR, EAL, "(%s): List does not end with ']'\n", str); - return -EINVAL; - } - str++; - *str_start = '\0'; - - /* Process list elements */ - state = 0; - while (1) { - if (state == 0) { - if (*str == '\0') - break; - if (*str != ',') { - str_start = str; - state = 1; - } - } else if (state == 1) { - if (*str == ',' || *str == '\0') { - if (str > str_start) { - /* Non-empty string fragment */ - *str = '\0'; - result = callback(str_start, data); - if (result < 0) - return result; - } - state = 0; - } - } - str++; + if (*len_list >= max_list) + return -1; + for (i = 0; i < *len_list; i++) { + if (list[i] == val) + return 0; } + list[(*len_list)++] = val; return 0; } -static int +/* Parse and enlist a range expression of "min-max" or a single value. */ +static char * rte_eth_devargs_process_range(char *str, uint16_t *list, uint16_t *len_list, const uint16_t max_list) { uint16_t lo, hi, val; int result; + char *pos = str; result = sscanf(str, "%hu-%hu", &lo, &hi); if (result == 1) { - if (*len_list >= max_list) - return -ENOMEM; - list[(*len_list)++] = lo; + if (rte_eth_devargs_enlist(list, len_list, max_list, lo) != 0) + return NULL; } else if (result == 2) { - if (lo >= hi || lo > RTE_MAX_ETHPORTS || hi > RTE_MAX_ETHPORTS) - return -EINVAL; + if (lo >= hi) + return NULL; for (val = lo; val <= hi; val++) { - if (*len_list >= max_list) - return -ENOMEM; - list[(*len_list)++] = val; + if (rte_eth_devargs_enlist(list, len_list, max_list, + val) != 0) + return NULL; } } else - return -EINVAL; - return 0; + return NULL; + while (*pos != 0 && ((*pos >= '0' && *pos <= '9') || *pos == '-')) + pos++; + return pos; +} + +/* + * Parse list of values separated by ",". + * Each value could be a range [min-max] or single number. + * Examples: + * 2 - single + * [1,2,3] - single list + * [1,3-5,7,9-11] - list with singles and ranges + */ +static char * +rte_eth_devargs_process_list(char *str, uint16_t *list, uint16_t *len_list, + const uint16_t max_list) +{ + char *pos = str; + + if (*pos == '[') + pos++; + while (1) { + pos = rte_eth_devargs_process_range(pos, list, len_list, + max_list); + if (pos == NULL) + return NULL; + if (*pos != ',') /* end of list */ + break; + pos++; + } + if (*str == '[' && *pos != ']') + return NULL; + if (*pos == ']') + pos++; + return pos; } /* - * representor format: + * Parse representor ports from a single value or lists. + * + * Representor format: * #: range or single number of VF representor + * + * Examples of #: + * 2 - single + * [1,2,3] - single list + * [1,3-5,7,9-11] - list with singles and ranges */ int rte_eth_devargs_parse_representor_ports(char *str, void *data) @@ -121,6 +132,9 @@ rte_eth_devargs_parse_representor_ports(char *str, void *data) struct rte_eth_devargs *eth_da = data; eth_da->type = RTE_ETH_REPRESENTOR_VF; - return rte_eth_devargs_process_range(str, eth_da->representor_ports, + str = rte_eth_devargs_process_list(str, eth_da->representor_ports, ð_da->nb_representor_ports, RTE_MAX_ETHPORTS); + if (str == NULL) + RTE_LOG(ERR, EAL, "wrong representor format: %s\n", str); + return str == NULL ? -1 : 0; } diff --git a/lib/librte_ethdev/ethdev_private.h b/lib/librte_ethdev/ethdev_private.h index 905a45c337..220ddd4408 100644 --- a/lib/librte_ethdev/ethdev_private.h +++ b/lib/librte_ethdev/ethdev_private.h @@ -26,9 +26,6 @@ eth_find_device(const struct rte_eth_dev *_start, rte_eth_cmp_t cmp, const void *data); /* Parse devargs value for representor parameter. */ -typedef int (*rte_eth_devargs_callback_t)(char *str, void *data); -int rte_eth_devargs_parse_list(char *str, rte_eth_devargs_callback_t callback, - void *data); int rte_eth_devargs_parse_representor_ports(char *str, void *data); #ifdef __cplusplus diff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c index 6338355e25..efe6149df5 100644 --- a/lib/librte_ethdev/rte_class_eth.c +++ b/lib/librte_ethdev/rte_class_eth.c @@ -77,9 +77,7 @@ eth_representor_cmp(const char *key __rte_unused, if (values == NULL) return -1; memset(&representors, 0, sizeof(representors)); - ret = rte_eth_devargs_parse_list(values, - rte_eth_devargs_parse_representor_ports, - &representors); + ret = rte_eth_devargs_parse_representor_ports(values, &representors); free(values); if (ret != 0) return -1; /* invalid devargs value */ diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 71e1e9a6db..91b3263338 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -5561,9 +5561,8 @@ rte_eth_devargs_parse(const char *dargs, struct rte_eth_devargs *eth_da) for (i = 0; i < args.count; i++) { pair = &args.pairs[i]; if (strcmp("representor", pair->key) == 0) { - result = rte_eth_devargs_parse_list(pair->value, - rte_eth_devargs_parse_representor_ports, - eth_da); + result = rte_eth_devargs_parse_representor_ports( + pair->value, eth_da); if (result < 0) goto parse_cleanup; } From patchwork Tue Jan 19 07:14:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 86857 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BEFBEA0A03; Tue, 19 Jan 2021 08:15:57 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D9630140D66; Tue, 19 Jan 2021 08:15:49 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id DF7E5140D57 for ; Tue, 19 Jan 2021 08:15:46 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 19 Jan 2021 09:15:42 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 10J7FfYc003537; Tue, 19 Jan 2021 09:15:41 +0200 From: Xueming Li To: Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Tue, 19 Jan 2021 07:14:55 +0000 Message-Id: <1611040501-11666-3-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> References: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> In-Reply-To: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [PATCH v5 3/9] ethdev: support new VF representor syntax X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Current VF representor syntax: representor=2 - single representor representor=[0-3] - single range To prepare for more representor types, this patch adds compatible VF representor devargs syntax: vf#: representor=vf2 - single representor representor=vf[1,3,5] - single list representor=vf[0-3] - single range representor=vf[0,1,4-7] - list with singles and range For backwards compatibility, representor "#" is interpreted as "vf#". Signed-off-by: Xueming Li Acked-by: Viacheslav Ovsiienko Acked-by: Thomas Monjalon Acked-by: Andrew Rybchenko --- doc/guides/prog_guide/poll_mode_drv.rst | 7 ++++--- lib/librte_ethdev/ethdev_private.c | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/guides/prog_guide/poll_mode_drv.rst b/doc/guides/prog_guide/poll_mode_drv.rst index 239ec820ea..0117c2af07 100644 --- a/doc/guides/prog_guide/poll_mode_drv.rst +++ b/doc/guides/prog_guide/poll_mode_drv.rst @@ -374,9 +374,10 @@ parameters to those ports. this argument allows user to specify which switch ports to enable port representors for.:: - -a DBDF,representor=0 - -a DBDF,representor=[0,4,6,9] - -a DBDF,representor=[0-31] + -a DBDF,representor=vf0 + -a DBDF,representor=vf[0,4,6,9] + -a DBDF,representor=vf[0-31] + -a DBDF,representor=vf[0,2-4,7,9-11] Note: PMDs are not required to support the standard device arguments and users should consult the relevant PMD documentation to see support devargs. diff --git a/lib/librte_ethdev/ethdev_private.c b/lib/librte_ethdev/ethdev_private.c index e87636f665..20e48a48be 100644 --- a/lib/librte_ethdev/ethdev_private.c +++ b/lib/librte_ethdev/ethdev_private.c @@ -119,7 +119,8 @@ rte_eth_devargs_process_list(char *str, uint16_t *list, uint16_t *len_list, * Parse representor ports from a single value or lists. * * Representor format: - * #: range or single number of VF representor + * #: range or single number of VF representor - legacy + * vf#: VF port representor/s * * Examples of #: * 2 - single @@ -132,6 +133,8 @@ rte_eth_devargs_parse_representor_ports(char *str, void *data) struct rte_eth_devargs *eth_da = data; eth_da->type = RTE_ETH_REPRESENTOR_VF; + if (str[0] == 'v' && str[1] == 'f') + str += 2; str = rte_eth_devargs_process_list(str, eth_da->representor_ports, ð_da->nb_representor_ports, RTE_MAX_ETHPORTS); if (str == NULL) From patchwork Tue Jan 19 07:14:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 86858 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A4C16A0A03; Tue, 19 Jan 2021 08:16:06 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A80EB140D6C; Tue, 19 Jan 2021 08:15:51 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id E6D2F140D5B for ; Tue, 19 Jan 2021 08:15:46 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 19 Jan 2021 09:15:42 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 10J7FfYd003537; Tue, 19 Jan 2021 09:15:42 +0200 From: Xueming Li To: Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Tue, 19 Jan 2021 07:14:56 +0000 Message-Id: <1611040501-11666-4-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> References: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> In-Reply-To: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [PATCH v5 4/9] ethdev: support sub function representor X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" SubFunction is a portion of the PCI device, created on demand, a SF netdev has its own dedicated queues(txq, rxq). A SF netdev supports eswitch representation offload similar to existing PF and VF representors. To support SF representor, this patch introduces new devargs syntax, examples: representor=sf0 - single SubFunction representor representor=sf[1,3,5] - single list representor=sf[0-3], - single range representor=sf[0,2-6,8,10-12] - list with singles and ranges Signed-off-by: Xueming Li Acked-by: Viacheslav Ovsiienko Acked-by: Thomas Monjalon Acked-by: Andrew Rybchenko --- doc/guides/prog_guide/poll_mode_drv.rst | 4 +++ .../prog_guide/switch_representation.rst | 35 +++++++++++++------ lib/librte_ethdev/ethdev_private.c | 11 ++++-- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/doc/guides/prog_guide/poll_mode_drv.rst b/doc/guides/prog_guide/poll_mode_drv.rst index 0117c2af07..86e5867f1b 100644 --- a/doc/guides/prog_guide/poll_mode_drv.rst +++ b/doc/guides/prog_guide/poll_mode_drv.rst @@ -378,6 +378,10 @@ parameters to those ports. -a DBDF,representor=vf[0,4,6,9] -a DBDF,representor=vf[0-31] -a DBDF,representor=vf[0,2-4,7,9-11] + -a DBDF,representor=sf0 + -a DBDF,representor=sf[1,3,5] + -a DBDF,representor=sf[0-1023] + -a DBDF,representor=sf[0,2-4,7,9-11] Note: PMDs are not required to support the standard device arguments and users should consult the relevant PMD documentation to see support devargs. diff --git a/doc/guides/prog_guide/switch_representation.rst b/doc/guides/prog_guide/switch_representation.rst index 07ba12bea6..ff6aa91c80 100644 --- a/doc/guides/prog_guide/switch_representation.rst +++ b/doc/guides/prog_guide/switch_representation.rst @@ -13,7 +13,7 @@ Introduction Network adapters with multiple physical ports and/or SR-IOV capabilities usually support the offload of traffic steering rules between their virtual -functions (VFs), physical functions (PFs) and ports. +functions (VFs), sub functions (SFs), physical functions (PFs) and ports. Like for standard Ethernet switches, this involves a combination of automatic MAC learning and manual configuration. For most purposes it is @@ -24,7 +24,7 @@ layer 2 (L2) traffic (such as OVS) need to steer traffic themselves according on their own criteria. Without a standard software interface to manage traffic steering rules -between VFs, PFs and the various physical ports of a given device, +between VFs, SFs, PFs and the various physical ports of a given device, applications cannot take advantage of these offloads; software processing is mandatory even for traffic which ends up re-injected into the device it originates from. @@ -34,6 +34,17 @@ the DPDK flow API (**rte_flow**), with emphasis on the SR-IOV use case (PF/VF steering) using a single physical port for clarity, however the same logic applies to any number of ports without necessarily involving SR-IOV. +Sub Function +------------ +Besides SR-IOV, Sub function is a portion of the PCI device, a SF netdev +has its own dedicated queues(txq, rxq). A SF netdev supports E-Switch +representation offload similar to existing PF and VF representors. +A SF shares PCI level resources with other SFs and/or with its parent PCI +function. + +Sub function is created on-demand, coexists with VFs. Number of SFs is +limited by hardware resources. + Port Representors ----------------- @@ -42,15 +53,16 @@ applications usually have to process a bit of traffic in software before thinking about offloading specific flows to hardware. Applications therefore need the ability to receive and inject traffic to -various device endpoints (other VFs, PFs or physical ports) before +various device endpoints (other VFs, SFs, PFs or physical ports) before connecting them together. Device drivers must provide means to hook the "other end" of these endpoints and to refer them when configuring flow rules. This role is left to so-called "port representors" (also known as "VF -representors" in the specific context of VFs), which are to DPDK what the -Ethernet switch device driver model (**switchdev**) [1]_ is to Linux, and -which can be thought as a software "patch panel" front-end for applications. +representors" in the specific context of VFs, "SF representors" in the +specific context of SFs), which are to DPDK what the Ethernet switch +device driver model (**switchdev**) [1]_ is to Linux, and which can be +thought as a software "patch panel" front-end for applications. - DPDK port representors are implemented as additional virtual Ethernet device (**ethdev**) instances, spawned on an as needed basis through @@ -59,9 +71,12 @@ which can be thought as a software "patch panel" front-end for applications. :: - -a pci:dbdf,representor=0 - -a pci:dbdf,representor=[0-3] - -a pci:dbdf,representor=[0,5-11] + -a pci:dbdf,representor=vf0 + -a pci:dbdf,representor=vf[0-3] + -a pci:dbdf,representor=vf[0,5-11] + -a pci:dbdf,representor=sf1 + -a pci:dbdf,representor=sf[0-1023] + -a pci:dbdf,representor=sf[0,2-1023] - As virtual devices, they may be more limited than their physical counterparts, for instance by exposing only a subset of device @@ -360,7 +375,7 @@ Compared to creating a brand new dedicated interface, **rte_flow** was deemed flexible enough to manage representor traffic only with minor extensions: -- Using physical ports, PF, VF or port representors as targets. +- Using physical ports, PF, SF, VF or port representors as targets. - Affecting traffic that is not necessarily addressed to the DPDK port ID a flow rule is associated with (e.g. forcing VF traffic redirection to PF). diff --git a/lib/librte_ethdev/ethdev_private.c b/lib/librte_ethdev/ethdev_private.c index 20e48a48be..d513f035d0 100644 --- a/lib/librte_ethdev/ethdev_private.c +++ b/lib/librte_ethdev/ethdev_private.c @@ -121,6 +121,7 @@ rte_eth_devargs_process_list(char *str, uint16_t *list, uint16_t *len_list, * Representor format: * #: range or single number of VF representor - legacy * vf#: VF port representor/s + * sf#: SF port representor/s * * Examples of #: * 2 - single @@ -132,9 +133,15 @@ rte_eth_devargs_parse_representor_ports(char *str, void *data) { struct rte_eth_devargs *eth_da = data; - eth_da->type = RTE_ETH_REPRESENTOR_VF; - if (str[0] == 'v' && str[1] == 'f') + if (str[0] == 'v' && str[1] == 'f') { + eth_da->type = RTE_ETH_REPRESENTOR_VF; str += 2; + } else if (str[0] == 's' && str[1] == 'f') { + eth_da->type = RTE_ETH_REPRESENTOR_SF; + str += 2; + } else { + eth_da->type = RTE_ETH_REPRESENTOR_VF; + } str = rte_eth_devargs_process_list(str, eth_da->representor_ports, ð_da->nb_representor_ports, RTE_MAX_ETHPORTS); if (str == NULL) From patchwork Tue Jan 19 07:14:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 86859 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 41700A0A03; Tue, 19 Jan 2021 08:16:16 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E151B140D93; Tue, 19 Jan 2021 08:15:52 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id EE4AD140D5D for ; Tue, 19 Jan 2021 08:15:46 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 19 Jan 2021 09:15:42 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 10J7FfYe003537; Tue, 19 Jan 2021 09:15:42 +0200 From: Xueming Li To: Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Tue, 19 Jan 2021 07:14:57 +0000 Message-Id: <1611040501-11666-5-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> References: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> In-Reply-To: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [PATCH v5 5/9] ethdev: support PF index in representor X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" With Kernel bonding, multiple underlying PFs are bonded, VFs come from different PF, need to identify representor of VFs unambiguously by adding PF index. This patch introduces optional 'pf' section to representor devargs syntax, examples: representor=pf0vf0 - single VF representor representor=pf[0-1]sf[0-1023] - SF representors from 2 PFs Signed-off-by: Xueming Li Acked-by: Viacheslav Ovsiienko Acked-by: Thomas Monjalon --- doc/guides/prog_guide/poll_mode_drv.rst | 2 ++ lib/librte_ethdev/ethdev_private.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/guides/prog_guide/poll_mode_drv.rst b/doc/guides/prog_guide/poll_mode_drv.rst index 86e5867f1b..b2147aad30 100644 --- a/doc/guides/prog_guide/poll_mode_drv.rst +++ b/doc/guides/prog_guide/poll_mode_drv.rst @@ -382,6 +382,8 @@ parameters to those ports. -a DBDF,representor=sf[1,3,5] -a DBDF,representor=sf[0-1023] -a DBDF,representor=sf[0,2-4,7,9-11] + -a DBDF,representor=pf1vf0 + -a DBDF,representor=pf[0-1]sf[0-127] Note: PMDs are not required to support the standard device arguments and users should consult the relevant PMD documentation to see support devargs. diff --git a/lib/librte_ethdev/ethdev_private.c b/lib/librte_ethdev/ethdev_private.c index d513f035d0..b9fdbd0f72 100644 --- a/lib/librte_ethdev/ethdev_private.c +++ b/lib/librte_ethdev/ethdev_private.c @@ -120,8 +120,8 @@ rte_eth_devargs_process_list(char *str, uint16_t *list, uint16_t *len_list, * * Representor format: * #: range or single number of VF representor - legacy - * vf#: VF port representor/s - * sf#: SF port representor/s + * [pf#]vf#: VF port representor/s + * [pf#]sf#: SF port representor/s * * Examples of #: * 2 - single @@ -133,6 +133,14 @@ rte_eth_devargs_parse_representor_ports(char *str, void *data) { struct rte_eth_devargs *eth_da = data; + if (str[0] == 'p' && str[1] == 'f') { + eth_da->type = RTE_ETH_REPRESENTOR_PF; + str += 2; + str = rte_eth_devargs_process_list(str, eth_da->ports, + ð_da->nb_ports, RTE_MAX_ETHPORTS); + if (str == NULL) + goto err; + } if (str[0] == 'v' && str[1] == 'f') { eth_da->type = RTE_ETH_REPRESENTOR_VF; str += 2; @@ -144,6 +152,7 @@ rte_eth_devargs_parse_representor_ports(char *str, void *data) } str = rte_eth_devargs_process_list(str, eth_da->representor_ports, ð_da->nb_representor_ports, RTE_MAX_ETHPORTS); +err: if (str == NULL) RTE_LOG(ERR, EAL, "wrong representor format: %s\n", str); return str == NULL ? -1 : 0; From patchwork Tue Jan 19 07:14:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 86862 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 12214A0A03; Tue, 19 Jan 2021 08:16:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A90EC140DAA; Tue, 19 Jan 2021 08:15:56 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 0D5DD140D61 for ; Tue, 19 Jan 2021 08:15:46 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 19 Jan 2021 09:15:43 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 10J7FfYf003537; Tue, 19 Jan 2021 09:15:42 +0200 From: Xueming Li To: Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso , Bruce Richardson , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Tue, 19 Jan 2021 07:14:58 +0000 Message-Id: <1611040501-11666-6-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> References: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> In-Reply-To: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [PATCH v5 6/9] ethdev: support multi-host in representor X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The NIC can have multiple PCIe links and can be attached to the multiple hosts, for example the same single NIC can be shared for multiple server units in the rack. On each PCIe link NIC can provide multiple PFs and VFs/SFs based on these ones. To provide the unambiguous identification of the PCIe function the controller index is added. The full representor identifier consists of three indices - controller index, PF index, and VF or SF index (if any). This patch introduces controller index to ethdev representor syntax, examples: [[c#]pf#]vf#: VF port representor/s, example: pf0vf1 [[c#]pf#]sf#: SF port representor/s, example: c1pf1sf[0-3] c# is controller(host) ID/range in case of multi-host, optional. For user application (e.g. OVS), PMD is responsible to interpret and locate representor device based on controller ID, PF ID and VF/SF ID in representor syntax. Signed-off-by: Xueming Li Acked-by: Viacheslav Ovsiienko Acked-by: Thomas Monjalon --- config/rte_config.h | 1 + lib/librte_ethdev/ethdev_private.c | 12 ++++++++++-- lib/librte_ethdev/rte_ethdev_driver.h | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/config/rte_config.h b/config/rte_config.h index a0b5160ff2..23d02d51ef 100644 --- a/config/rte_config.h +++ b/config/rte_config.h @@ -58,6 +58,7 @@ #define RTE_MAX_QUEUES_PER_PORT 1024 #define RTE_ETHDEV_QUEUE_STAT_CNTRS 16 /* max 256 */ #define RTE_ETHDEV_RXTX_CALLBACKS 1 +#define RTE_MAX_MULTI_HOST_CTRLS 4 /* cryptodev defines */ #define RTE_CRYPTO_MAX_DEVS 64 diff --git a/lib/librte_ethdev/ethdev_private.c b/lib/librte_ethdev/ethdev_private.c index b9fdbd0f72..9a0945c22e 100644 --- a/lib/librte_ethdev/ethdev_private.c +++ b/lib/librte_ethdev/ethdev_private.c @@ -120,8 +120,8 @@ rte_eth_devargs_process_list(char *str, uint16_t *list, uint16_t *len_list, * * Representor format: * #: range or single number of VF representor - legacy - * [pf#]vf#: VF port representor/s - * [pf#]sf#: SF port representor/s + * [[c#]pf#]vf#: VF port representor/s + * [[c#]pf#]sf#: SF port representor/s * * Examples of #: * 2 - single @@ -133,6 +133,14 @@ rte_eth_devargs_parse_representor_ports(char *str, void *data) { struct rte_eth_devargs *eth_da = data; + if (str[0] == 'c') { + str += 1; + str = rte_eth_devargs_process_list(str, eth_da->mh_controllers, + ð_da->nb_mh_controllers, + RTE_DIM(eth_da->mh_controllers)); + if (str == NULL) + goto err; + } if (str[0] == 'p' && str[1] == 'f') { eth_da->type = RTE_ETH_REPRESENTOR_PF; str += 2; diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h index cd33184f17..b01f118965 100644 --- a/lib/librte_ethdev/rte_ethdev_driver.h +++ b/lib/librte_ethdev/rte_ethdev_driver.h @@ -1203,6 +1203,10 @@ enum rte_eth_representor_type { /** Generic Ethernet device arguments */ struct rte_eth_devargs { + uint16_t mh_controllers[RTE_MAX_MULTI_HOST_CTRLS]; + /** controller/s number in case of multi-host */ + uint16_t nb_mh_controllers; + /** number of controllers in multi-host controllers field */ uint16_t ports[RTE_MAX_ETHPORTS]; /** port/s number to enable on a multi-port single function */ uint16_t nb_ports; From patchwork Tue Jan 19 07:14:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 86860 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 73CCFA0A03; Tue, 19 Jan 2021 08:16:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2B0B5140D99; Tue, 19 Jan 2021 08:15:54 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 08AC3140D60 for ; Tue, 19 Jan 2021 08:15:46 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 19 Jan 2021 09:15:43 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 10J7FfYg003537; Tue, 19 Jan 2021 09:15:43 +0200 From: Xueming Li To: Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso , Ajit Khaparde , Somnath Kotur , John Daley , Hyong Youb Kim , Beilei Xing , Jeff Guo , Haiyue Wang , Matan Azrad , Shahaf Shuler , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Ray Kinsella , Neil Horman Date: Tue, 19 Jan 2021 07:14:59 +0000 Message-Id: <1611040501-11666-7-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> References: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> In-Reply-To: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [PATCH v5 7/9] devarg: change representor ID to bitmap X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The NIC can have multiple PCIe links and can be attached to multiple hosts, for example the same single NIC can be shared for multiple server units in the rack. On each PCIe link NIC can provide multiple PFs and VFs/SFs based on these ones. The full representor identifier consists of three indices - controller index, PF index, and VF or SF index (if any). SR-IOV and SubFunction are created on top of PF. PF index is introduced because there might be multiple PFs in the bonding configuration and only bonding device is probed. In eth representor comparator callback, ethdev was compared with devarg. Since ethdev representor port didn't contain controller index and PF index information, callback returned representor from other PF or controller. This patch changes representor ID to bitmap so that the ethdev representor comparer callback returns correct ethdev by comparing full representor information including: controller index, PF index, representor type, SF or VF index. Representor ID bitmap definition: xxxx xxxx xxxx xxxx |||| |LLL LLLL LLLL vf/sf id |||| L 1:sf, 0:vf ||LL pf id LL controller(host) id This approach keeps binary compatibility with all drivers, VF representor id matches with simple id for non-bonding and non-multi-host configurations. In the future, the representor ID field and each section should extend to bigger width to support more devices. Signed-off-by: Xueming Li Acked-by: Viacheslav Ovsiienko Acked-by: Thomas Monjalon --- drivers/net/bnxt/bnxt_reps.c | 3 +- drivers/net/enic/enic_vf_representor.c | 3 +- drivers/net/i40e/i40e_vf_representor.c | 3 +- drivers/net/ixgbe/ixgbe_vf_representor.c | 3 +- drivers/net/mlx5/linux/mlx5_os.c | 4 +- lib/librte_ethdev/rte_class_eth.c | 38 +++++++++++++---- lib/librte_ethdev/rte_ethdev.c | 26 ++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 53 ++++++++++++++++++++++++ lib/librte_ethdev/version.map | 2 + 9 files changed, 122 insertions(+), 13 deletions(-) diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c index f7bbf77d3f..34febc2d1e 100644 --- a/drivers/net/bnxt/bnxt_reps.c +++ b/drivers/net/bnxt/bnxt_reps.c @@ -186,7 +186,8 @@ int bnxt_representor_init(struct rte_eth_dev *eth_dev, void *params) eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR | RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; - eth_dev->data->representor_id = rep_params->vf_id; + eth_dev->data->representor_id = rte_eth_representor_id_encode( + 0, 0, RTE_ETH_REPRESENTOR_VF, rep_params->vf_id); rte_eth_random_addr(vf_rep_bp->dflt_mac_addr); memcpy(vf_rep_bp->mac_addr, vf_rep_bp->dflt_mac_addr, diff --git a/drivers/net/enic/enic_vf_representor.c b/drivers/net/enic/enic_vf_representor.c index c2c03c0281..632317af15 100644 --- a/drivers/net/enic/enic_vf_representor.c +++ b/drivers/net/enic/enic_vf_representor.c @@ -674,7 +674,8 @@ int enic_vf_representor_init(struct rte_eth_dev *eth_dev, void *init_params) eth_dev->dev_ops = &enic_vf_representor_dev_ops; eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR | RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; - eth_dev->data->representor_id = vf->vf_id; + eth_dev->data->representor_id = rte_eth_representor_id_encode( + 0, 0, RTE_ETH_REPRESENTOR_VF, vf->vf_id); eth_dev->data->mac_addrs = rte_zmalloc("enic_mac_addr_vf", sizeof(struct rte_ether_addr) * ENIC_UNICAST_PERFECT_FILTERS, 0); diff --git a/drivers/net/i40e/i40e_vf_representor.c b/drivers/net/i40e/i40e_vf_representor.c index 9e40406a3d..d90d0fdb9d 100644 --- a/drivers/net/i40e/i40e_vf_representor.c +++ b/drivers/net/i40e/i40e_vf_representor.c @@ -510,7 +510,8 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params) ethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR | RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; - ethdev->data->representor_id = representor->vf_id; + ethdev->data->representor_id = rte_eth_representor_id_encode( + 0, 0, RTE_ETH_REPRESENTOR_VF, representor->vf_id); /* Setting the number queues allocated to the VF */ ethdev->data->nb_rx_queues = vf->vsi->nb_qps; diff --git a/drivers/net/ixgbe/ixgbe_vf_representor.c b/drivers/net/ixgbe/ixgbe_vf_representor.c index 8185f0d3bb..e15b794761 100644 --- a/drivers/net/ixgbe/ixgbe_vf_representor.c +++ b/drivers/net/ixgbe/ixgbe_vf_representor.c @@ -196,7 +196,8 @@ ixgbe_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params) return -ENODEV; ethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR; - ethdev->data->representor_id = representor->vf_id; + ethdev->data->representor_id = rte_eth_representor_id_encode( + 0, 0, RTE_ETH_REPRESENTOR_VF, representor->vf_id); /* Set representor device ops */ ethdev->dev_ops = &ixgbe_vf_representor_dev_ops; diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index caead107b0..4d7940bcca 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1025,7 +1025,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, #endif /* representor_id field keeps the unmodified VF index. */ priv->representor_id = switch_info->representor ? - switch_info->port_name : -1; + rte_eth_representor_id_encode(0, 0, RTE_ETH_REPRESENTOR_VF, + switch_info->port_name) : + -1; /* * Look for sibling devices in order to reuse their switch domain * if any, otherwise allocate one. diff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c index efe6149df5..994db96960 100644 --- a/lib/librte_ethdev/rte_class_eth.c +++ b/lib/librte_ethdev/rte_class_eth.c @@ -66,8 +66,8 @@ eth_representor_cmp(const char *key __rte_unused, int ret; char *values; const struct rte_eth_dev_data *data = opaque; - struct rte_eth_devargs representors; - uint16_t index; + struct rte_eth_devargs eth_da; + uint16_t index, c, p, f; if ((data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) return -1; /* not a representor port */ @@ -76,17 +76,39 @@ eth_representor_cmp(const char *key __rte_unused, values = strdup(value); if (values == NULL) return -1; - memset(&representors, 0, sizeof(representors)); - ret = rte_eth_devargs_parse_representor_ports(values, &representors); + memset(ð_da, 0, sizeof(eth_da)); + ret = rte_eth_devargs_parse_representor_ports(values, ð_da); free(values); if (ret != 0) return -1; /* invalid devargs value */ + /* Set default values. */ + if (eth_da.nb_mh_controllers == 0) { + eth_da.nb_mh_controllers = 1; + eth_da.mh_controllers[0] = 0; + } + if (eth_da.nb_ports == 0) { + eth_da.nb_ports = 1; + eth_da.ports[0] = 0; + } + if (eth_da.nb_representor_ports == 0) { + eth_da.nb_representor_ports = 1; + eth_da.representor_ports[0] = 0; + } /* Return 0 if representor id is matching one of the values. */ - for (index = 0; index < representors.nb_representor_ports; index++) - if (data->representor_id == - representors.representor_ports[index]) - return 0; + for (c = 0; c < eth_da.nb_mh_controllers; ++c) { + for (p = 0; p < eth_da.nb_ports; ++p) { + for (f = 0; f < eth_da.nb_representor_ports; ++f) { + index = rte_eth_representor_id_encode( + eth_da.mh_controllers[c], + eth_da.ports[p], + eth_da.type, + eth_da.representor_ports[f]); + if (data->representor_id == index) + return 0; + } + } + } return -1; /* no match */ } diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 91b3263338..2cac0ccfbd 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -5575,6 +5575,32 @@ rte_eth_devargs_parse(const char *dargs, struct rte_eth_devargs *eth_da) return result; } +uint16_t +rte_eth_representor_id_encode(uint16_t controller, uint16_t pf, + enum rte_eth_representor_type type, + uint16_t representor_port) +{ + return (((controller & 3) << 14) | + ((pf & 3) << 12) | + (!!(type == RTE_ETH_REPRESENTOR_SF) << 11) | + (representor_port & 0x7ff)); +} + +uint16_t +rte_eth_representor_id_parse(const uint16_t representor_id, + uint16_t *controller, uint16_t *pf, + enum rte_eth_representor_type *type) +{ + if (controller) + *controller = (representor_id >> 14) & 3; + if (pf) + *pf = (representor_id >> 12) & 3; + if (type) + *type = ((representor_id >> 11) & 1) ? + RTE_ETH_REPRESENTOR_SF : RTE_ETH_REPRESENTOR_VF; + return representor_id & 0x7ff; +} + static int eth_dev_handle_port_list(const char *cmd __rte_unused, const char *params __rte_unused, diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h index b01f118965..57253c8f90 100644 --- a/lib/librte_ethdev/rte_ethdev_driver.h +++ b/lib/librte_ethdev/rte_ethdev_driver.h @@ -1218,6 +1218,59 @@ struct rte_eth_devargs { enum rte_eth_representor_type type; /* type of representor */ }; +#define RTE_NO_REPRESENTOR_ID UINT16_MAX /**< No representor ID. */ + +/** + * PMD helper function to encode representor ID + * + * The compact format is used for device iterator that comparing + * ethdev representor ID with target devargs. + * + * xxxx xxxx xxxx xxxx + * |||| |LLL LLLL LLLL vf/sf id + * |||| L 1:sf, 0:vf + * ||LL pf id + * LL controller(host) id + * + * @param controller + * Controller ID. + * @param pf + * PF port ID. + * @param type + * Representor type. + * @param representor_port + * Representor port ID. + * + * @return + * Encoded representor ID. + */ +__rte_internal +uint16_t +rte_eth_representor_id_encode(uint16_t controller, uint16_t pf, + enum rte_eth_representor_type type, + uint16_t representor_port); + +/** + * PMD helper function to parse representor ID + * + * @param representor_id + * Representor ID. + * @param controller + * Parsed controller ID. + * @param pf + * Parsed PF port ID. + * @param type + * Parsed representor type. + * + * @return + * Parsed representor port ID. + */ +__rte_internal +uint16_t +rte_eth_representor_id_parse(const uint16_t representor_id, + uint16_t *controller, uint16_t *pf, + enum rte_eth_representor_type *type); + /** * PMD helper function to parse ethdev arguments * diff --git a/lib/librte_ethdev/version.map b/lib/librte_ethdev/version.map index d3f5410806..44edaed507 100644 --- a/lib/librte_ethdev/version.map +++ b/lib/librte_ethdev/version.map @@ -257,6 +257,8 @@ INTERNAL { rte_eth_dev_release_port; rte_eth_dev_internal_reset; rte_eth_devargs_parse; + rte_eth_representor_id_encode; + rte_eth_representor_id_parse; rte_eth_dma_zone_free; rte_eth_dma_zone_reserve; rte_eth_hairpin_queue_peer_bind; From patchwork Tue Jan 19 07:15:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 86863 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2AD29A0A03; Tue, 19 Jan 2021 08:16:52 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3867B140DBE; Tue, 19 Jan 2021 08:15:58 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 11062140D63 for ; Tue, 19 Jan 2021 08:15:46 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 19 Jan 2021 09:15:43 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 10J7FfYh003537; Tue, 19 Jan 2021 09:15:43 +0200 From: Xueming Li To: Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Tue, 19 Jan 2021 07:15:00 +0000 Message-Id: <1611040501-11666-8-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> References: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> In-Reply-To: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [PATCH v5 8/9] ethdev: add capability of sub-function representor X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Old DPDK version or some drivers didn't support SubFunction representor. For application to adapt different DPDK version automatically, or to be used for different NICs, this patch introduces new eth device capability of supporting SubFunction representor device. Signed-off-by: Xueming Li Acked-by: Viacheslav Ovsiienko Acked-by: Thomas Monjalon --- lib/librte_ethdev/rte_ethdev.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 2cbce958cf..da65adf1ab 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1433,6 +1433,8 @@ struct rte_eth_conf { #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP 0x00000001 /** Device supports Tx queue setup after device started. */ #define RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP 0x00000002 +/** Device supports SubFunction representor. */ +#define RTE_ETH_DEV_CAPA_REPRESENTOR_SF 0x00000004 /**@}*/ /* From patchwork Tue Jan 19 07:15:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 86861 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 98869A0A03; Tue, 19 Jan 2021 08:16:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6555B140DA3; Tue, 19 Jan 2021 08:15:55 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 15764140D66 for ; Tue, 19 Jan 2021 08:15:46 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 19 Jan 2021 09:15:43 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 10J7FfYi003537; Tue, 19 Jan 2021 09:15:43 +0200 From: Xueming Li To: Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso , Olivier Matz Date: Tue, 19 Jan 2021 07:15:01 +0000 Message-Id: <1611040501-11666-9-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> References: <1611040501-11666-1-git-send-email-xuemingl@nvidia.com> In-Reply-To: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [PATCH v5 9/9] kvargs: update parser to support lists X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch updates kvargs parser to support lists on top of range, allow multiple lists or range: k1=a[1,2]b[3-5] Signed-off-by: Xueming Li Acked-by: Viacheslav Ovsiienko Acked-by: Thomas Monjalon --- app/test/test_kvargs.c | 46 +++++++++++++-- lib/librte_kvargs/rte_kvargs.c | 101 +++++++++++++++++++++++---------- 2 files changed, 112 insertions(+), 35 deletions(-) diff --git a/app/test/test_kvargs.c b/app/test/test_kvargs.c index 2a2dae43a0..a91ea8dc47 100644 --- a/app/test/test_kvargs.c +++ b/app/test/test_kvargs.c @@ -35,6 +35,25 @@ static int check_handler(const char *key, const char *value, return 0; } +/* test parsing. */ +static int test_kvargs_parsing(const char *args, unsigned int n) +{ + struct rte_kvargs *kvlist; + + kvlist = rte_kvargs_parse(args, NULL); + if (kvlist == NULL) { + printf("rte_kvargs_parse() error: %s\n", args); + return -1; + } + if (kvlist->count != n) { + printf("invalid count value %d: %s\n", kvlist->count, args); + rte_kvargs_free(kvlist); + return -1; + } + rte_kvargs_free(kvlist); + return 0; +} + /* test a valid case */ static int test_valid_kvargs(void) { @@ -42,6 +61,19 @@ static int test_valid_kvargs(void) const char *args; const char *valid_keys_list[] = { "foo", "check", NULL }; const char **valid_keys; + static const struct { + unsigned int expected; + const char *input; + } valid_inputs[] = { + { 2, "foo=1,foo=" }, + { 2, "foo=1,foo=" }, + { 2, "foo=1,foo" }, + { 2, "foo=1,=2" }, + { 1, "foo=[1,2" }, + { 1, ",=" }, + { 1, "foo=[" }, + }; + unsigned int i; /* empty args is valid */ args = ""; @@ -191,6 +223,14 @@ static int test_valid_kvargs(void) } rte_kvargs_free(kvlist); + valid_keys = NULL; + + for (i = 0; i < RTE_DIM(valid_inputs); ++i) { + args = valid_inputs[i].input; + if (test_kvargs_parsing(args, valid_inputs[i].expected)) + goto fail; + } + return 0; fail: @@ -212,12 +252,6 @@ static int test_invalid_kvargs(void) /* list of argument that should fail */ const char *args_list[] = { "wrong-key=x", /* key not in valid_keys_list */ - "foo=1,foo=", /* empty value */ - "foo=1,foo", /* no value */ - "foo=1,=2", /* no key */ - "foo=[1,2", /* no closing bracket in value */ - ",=", /* also test with a smiley */ - "foo=[", /* no value in list and no closing bracket */ NULL }; const char **args; const char *valid_keys_list[] = { "foo", "check", NULL }; diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c index 285081c86c..ffae8914cf 100644 --- a/lib/librte_kvargs/rte_kvargs.c +++ b/lib/librte_kvargs/rte_kvargs.c @@ -5,6 +5,7 @@ #include #include +#include #include @@ -13,15 +14,19 @@ /* * Receive a string with a list of arguments following the pattern * key=value,key=value,... and insert them into the list. - * strtok() is used so the params string will be copied to be modified. + * Params string will be copied to be modified. + * list "[]" and list element splitter ",", "-" is treated as value. + * Supported examples: + * k1=v1,k2=v2 + * k1 + * k1=x[0-1]y[1,3-5,9]z */ static int rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params) { - unsigned i; - char *str; - char *ctx1 = NULL; - char *ctx2 = NULL; + char *str, *start; + bool in_list = false, end_key = false, end_value = false; + bool save = false, end_pair = false; /* Copy the const char *params to a modifiable string * to pass to rte_strsplit @@ -32,36 +37,74 @@ rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params) /* browse each key/value pair and add it in kvlist */ str = kvlist->str; - while ((str = strtok_r(str, RTE_KVARGS_PAIRS_DELIM, &ctx1)) != NULL) { + start = str; /* start of current key or value */ + while (1) { + switch (*str) { + case '=': /* End of key. */ + end_key = true; + save = true; + break; + case ',': + /* End of value, skip comma in middle of range */ + if (!in_list) { + if (end_key) + end_value = true; + else + end_key = true; + save = true; + end_pair = true; + } + break; + case '[': /* Start of list. */ + in_list = true; + break; + case ']': /* End of list. */ + if (in_list) + in_list = false; + break; + case '\0': /* End of string */ + if (end_key) + end_value = true; + else + end_key = true; + save = true; + end_pair = true; + break; + default: + break; + } - i = kvlist->count; - if (i >= RTE_KVARGS_MAX) - return -1; + if (!save) { + /* Continue if not end of key or value. */ + str++; + continue; + } - kvlist->pairs[i].key = strtok_r(str, RTE_KVARGS_KV_DELIM, &ctx2); - kvlist->pairs[i].value = strtok_r(NULL, RTE_KVARGS_KV_DELIM, &ctx2); - if (kvlist->pairs[i].key == NULL || - kvlist->pairs[i].value == NULL) + if (kvlist->count >= RTE_KVARGS_MAX) return -1; - /* Detect list [a,b] to skip comma delimiter in list. */ - str = kvlist->pairs[i].value; - if (str[0] == '[') { - /* Find the end of the list. */ - while (str[strlen(str) - 1] != ']') { - /* Restore the comma erased by strtok_r(). */ - if (ctx1 == NULL || ctx1[0] == '\0') - return -1; /* no closing bracket */ - str[strlen(str)] = ','; - /* Parse until next comma. */ - str = strtok_r(NULL, RTE_KVARGS_PAIRS_DELIM, &ctx1); - if (str == NULL) - return -1; /* no closing bracket */ - } + if (end_value) + /* Value parsed */ + kvlist->pairs[kvlist->count].value = start; + else if (end_key) + /* Key parsed. */ + kvlist->pairs[kvlist->count].key = start; + + if (end_pair) { + if (end_value || str != start) + /* Ignore empty pair. */ + kvlist->count++; + end_key = false; + end_value = false; + end_pair = false; } - kvlist->count++; - str = NULL; + if (*str == '\0') /* End of string. */ + break; + *str = '\0'; + str++; + start = str; + save = false; } return 0;