From patchwork Fri Dec 18 14:55:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 85465 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D753FA09FD; Fri, 18 Dec 2020 15:57:26 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 294C4CB38; Fri, 18 Dec 2020 15:56:19 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 3A9F6CB00 for ; Fri, 18 Dec 2020 15:56:13 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 18 Dec 2020 16:56:06 +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 0BIEu65R013340; Fri, 18 Dec 2020 16:56:06 +0200 From: Xueming Li To: Viacheslav Ovsiienko , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz , Matan Azrad Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso Date: Fri, 18 Dec 2020 14:55:50 +0000 Message-Id: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [RFC 1/7] ethdev: support sub function representor X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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 SF representor, this patch enhances devargs syntax: [pf#]vf#: new VF port representor/s, example: vf[0-3], pf0vf3 [pf#]sf#: new SF port representor/s, example: sf[0-3], pf1sf2 pf# is optional for SF and VF representor. If not present, representor is detected from PCI BDF of device argument. In case of bonding, pf# indicates owner PF device of SF or VF. For backwards compatible, # default to vf#. Enhances rte_eth_devargs_parse_representor_port() function to parse new representor syntax, replace rte_eth_devargs_parse_list() function which only parse simple list. Signed-off-by: Xueming Li --- lib/librte_ethdev/ethdev_private.c | 115 ++++++++++++++------------ lib/librte_ethdev/ethdev_private.h | 3 - lib/librte_ethdev/rte_class_eth.c | 7 +- lib/librte_ethdev/rte_ethdev.c | 5 +- lib/librte_ethdev/rte_ethdev_driver.h | 9 ++ 5 files changed, 77 insertions(+), 62 deletions(-) diff --git a/lib/librte_ethdev/ethdev_private.c b/lib/librte_ethdev/ethdev_private.c index 162a502fe7..2a057c5f36 100644 --- a/lib/librte_ethdev/ethdev_private.c +++ b/lib/librte_ethdev/ethdev_private.c @@ -38,60 +38,13 @@ 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) -{ - char *str_start; - int state; - int result; - - 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++; - } - return 0; -} - static int 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) { @@ -99,7 +52,7 @@ rte_eth_devargs_process_range(char *str, uint16_t *list, uint16_t *len_list, return -ENOMEM; list[(*len_list)++] = lo; } else if (result == 2) { - if (lo >= hi || lo > RTE_MAX_ETHPORTS || hi > RTE_MAX_ETHPORTS) + if (lo >= hi) return -EINVAL; for (val = lo; val <= hi; val++) { if (*len_list >= max_list) @@ -108,14 +61,74 @@ rte_eth_devargs_process_range(char *str, uint16_t *list, uint16_t *len_list, } } else return -EINVAL; - return 0; + while (*pos != 0 && ((*pos >= '0' && *pos <= '9') || *pos == '-')) + pos++; + return pos - str; } +static int +rte_eth_devargs_process_list(char *str, uint16_t *list, uint16_t *len_list, + const uint16_t max_list) +{ + char *pos = str; + int ret; + + if (*pos == '[') + pos++; + while (1) { + ret = rte_eth_devargs_process_range(pos, list, len_list, + max_list); + if (ret < 0) + return ret; + pos += ret; + if (*pos != ',') /* end of list */ + break; + pos++; + } + if (*str == '[' && *pos != ']') + return -EINVAL; + if (*pos == ']') + pos++; + return pos - str; +} + +/* + * representor format: + * #: range or single number of VF representor - legacy + * [pf#]vf#: VF port representor/s + * [pf#]sf#: SF port representor/s + */ int rte_eth_devargs_parse_representor_ports(char *str, void *data) { struct rte_eth_devargs *eth_da = data; + int ret; - return rte_eth_devargs_process_range(str, eth_da->representor_ports, + eth_da->type = RTE_ETH_REPRESENTOR_NONE; + /* parse pf# */ + if (str[0] == 'p' && str[1] == 'f') { + str += 2; + eth_da->type = RTE_ETH_REPRESENTOR_PF; + ret = rte_eth_devargs_process_list(str, eth_da->ports, + ð_da->nb_ports, RTE_MAX_ETHPORTS); + if (ret < 0) + goto err; + str += ret; + } + /* parse vf# and sf#, number # alone implies VF */ + 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; + } + ret = rte_eth_devargs_process_list(str, eth_da->representor_ports, ð_da->nb_representor_ports, RTE_MAX_ETHPORTS); +err: + if (ret < 0) + RTE_LOG(ERR, EAL, "wrong representor format: %s", str); + return ret < 0 ? ret : 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..7da06808ea 100644 --- a/lib/librte_ethdev/rte_class_eth.c +++ b/lib/librte_ethdev/rte_class_eth.c @@ -66,7 +66,7 @@ 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; + struct rte_eth_devargs representors = { 0 }; uint16_t index; if ((data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) @@ -76,10 +76,7 @@ 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_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 17ddacc78d..2ac51ac149 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -5542,9 +5542,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; } diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h index 0eacfd8425..edb000cbd4 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 type */ +enum rte_eth_representor_type { + RTE_ETH_REPRESENTOR_NONE, /* not a representor */ + RTE_ETH_REPRESENTOR_VF, /* representor of VF */ + RTE_ETH_REPRESENTOR_SF, /* representor of SF */ + RTE_ETH_REPRESENTOR_PF, /* representor of host PF */ +}; + /** 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 Fri Dec 18 14:55:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 85464 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BD02FA09FD; Fri, 18 Dec 2020 15:57:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A497ACB27; Fri, 18 Dec 2020 15:56:17 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 24138CAFF for ; Fri, 18 Dec 2020 15:56:13 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 18 Dec 2020 16:56:06 +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 0BIEu65S013340; Fri, 18 Dec 2020 16:56:06 +0200 From: Xueming Li To: Viacheslav Ovsiienko , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz , Matan Azrad Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso Date: Fri, 18 Dec 2020 14:55:51 +0000 Message-Id: <1608303356-13089-3-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [RFC 2/7] ethdev: support multi-host representor X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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 introduce multi-host controller for 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 ID/range in case of multi-host, optional. It is mostly for SmartNIC attached to multiple hosts in the same rack to allow routing the packets between PF/SF/VF running on these hosts. Signed-off-by: Xueming Li --- config/rte_config.h | 1 + lib/librte_ethdev/ethdev_private.c | 13 +++++++++++-- lib/librte_ethdev/rte_ethdev_driver.h | 4 ++++ 3 files changed, 16 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 2a057c5f36..3e455acea9 100644 --- a/lib/librte_ethdev/ethdev_private.c +++ b/lib/librte_ethdev/ethdev_private.c @@ -95,8 +95,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 */ int rte_eth_devargs_parse_representor_ports(char *str, void *data) @@ -105,6 +105,15 @@ rte_eth_devargs_parse_representor_ports(char *str, void *data) int ret; eth_da->type = RTE_ETH_REPRESENTOR_NONE; + if (str[0] == 'c') { + str += 1; + ret = rte_eth_devargs_process_list(str, eth_da->mh_controllers, + ð_da->nb_mh_controllers, + RTE_DIM(eth_da->mh_controllers)); + if (ret < 0) + goto err; + str += ret; + } /* parse pf# */ if (str[0] == 'p' && str[1] == 'f') { str += 2; diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h index edb000cbd4..a7969c9408 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 contollerss field */ uint16_t ports[RTE_MAX_ETHPORTS]; /** port/s number to enable on a multi-port single function */ uint16_t nb_ports; From patchwork Fri Dec 18 14:55:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 85463 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 65948A09FD; Fri, 18 Dec 2020 15:56:44 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1A24CCB06; Fri, 18 Dec 2020 15:56:16 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id E5425CAF7 for ; Fri, 18 Dec 2020 15:56:12 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 18 Dec 2020 16:56:06 +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 0BIEu65T013340; Fri, 18 Dec 2020 16:56:06 +0200 From: Xueming Li To: Viacheslav Ovsiienko , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz , Matan Azrad Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso Date: Fri, 18 Dec 2020 14:55:52 +0000 Message-Id: <1608303356-13089-4-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [RFC 3/7] devarg: change reprsentor ID to bitmap X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" In eth representor comparer callback, ethdev was compared with devarg. Since ethdev representor port didn't contain controller(host) and owner port information, callback only compared representor port and returned representor port on other PF port. This patch changes representor port to bitmap encoding, expands and updates representor port ID after parsing, when device representor ID uses the same bitmap encoding, the eth representor comparer callback returns correct ethdev. Representor port ID bitmap definition: Representor ID bitmap: xxxx xxxx xxxx xxxx |||| |LLL LLLL LLLL vf/sf id |||| L 1:sf, 0:vf ||LL pf id LL controller(host) id Signed-off-by: Xueming Li --- 0000-cover-letter.patch | 44 +++++++++++++++++++++++++++ lib/librte_ethdev/ethdev_private.c | 42 ++++++++++++++++++++++++- lib/librte_ethdev/rte_ethdev_driver.h | 22 ++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 0000-cover-letter.patch diff --git a/0000-cover-letter.patch b/0000-cover-letter.patch new file mode 100644 index 0000000000..3f8ce2be72 --- /dev/null +++ b/0000-cover-letter.patch @@ -0,0 +1,44 @@ +From 4e1f8fc062fa6813e0b57f78ad72760601ca1d98 Mon Sep 17 00:00:00 2001 +From: Xueming Li +Date: Fri, 18 Dec 2020 22:31:53 +0800 +Subject: [RFC 0/7] *** SUBJECT HERE *** +To: Viacheslav Ovsiienko , + Thomas Monjalon , + Ferruh Yigit , + Andrew Rybchenko , + Olivier Matz , + Matan Azrad +Cc: dev@dpdk.org, + xuemingl@nvidia.com, + Asaf Penso + +*** BLURB HERE *** + +Xueming Li (7): + ethdev: support sub function representor + ethdev: support multi-host representor + devarg: change reprsentor ID to bitmap + ethdev: capability for new representor syntax + kvargs: update parser for new representor syntax + common/mlx5: update representor name parsing + net/mlx5: support representor of sub function + + config/rte_config.h | 1 + + drivers/common/mlx5/linux/mlx5_common_os.c | 32 ++-- + drivers/common/mlx5/linux/mlx5_nl.c | 2 + + drivers/common/mlx5/mlx5_common.h | 2 + + drivers/net/mlx5/linux/mlx5_ethdev_os.c | 5 + + drivers/net/mlx5/linux/mlx5_os.c | 69 ++++++++- + drivers/net/mlx5/mlx5_ethdev.c | 2 + + lib/librte_ethdev/ethdev_private.c | 163 ++++++++++++++------- + lib/librte_ethdev/ethdev_private.h | 3 - + lib/librte_ethdev/rte_class_eth.c | 7 +- + lib/librte_ethdev/rte_ethdev.c | 5 +- + lib/librte_ethdev/rte_ethdev.h | 2 + + lib/librte_ethdev/rte_ethdev_driver.h | 35 +++++ + lib/librte_kvargs/rte_kvargs.c | 82 +++++++---- + 14 files changed, 306 insertions(+), 104 deletions(-) + +-- +2.25.1 + diff --git a/lib/librte_ethdev/ethdev_private.c b/lib/librte_ethdev/ethdev_private.c index 3e455acea9..a0fc187378 100644 --- a/lib/librte_ethdev/ethdev_private.c +++ b/lib/librte_ethdev/ethdev_private.c @@ -93,16 +93,20 @@ rte_eth_devargs_process_list(char *str, uint16_t *list, uint16_t *len_list, } /* - * representor format: + * Parse representor ports, expand and update representor port ID. + * Representor format: * #: range or single number of VF representor - legacy * [[c#]pf#]vf#: VF port representor/s * [[c#]pf#]sf#: SF port representor/s + * + * See RTE_ETH_REPR() for representor ID format. */ int rte_eth_devargs_parse_representor_ports(char *str, void *data) { struct rte_eth_devargs *eth_da = data; int ret; + uint32_t c, p, f, i = 0; eth_da->type = RTE_ETH_REPRESENTOR_NONE; if (str[0] == 'c') { @@ -136,6 +140,42 @@ rte_eth_devargs_parse_representor_ports(char *str, void *data) } ret = rte_eth_devargs_process_list(str, eth_da->representor_ports, ð_da->nb_representor_ports, RTE_MAX_ETHPORTS); + if (ret < 0) + goto err; + + /* Set default values, expand and update representor ID. */ + if (!eth_da->nb_mh_controllers) { + eth_da->nb_mh_controllers = 1; + eth_da->mh_controllers[0] = 0; + } + if (!eth_da->nb_ports) { + eth_da->nb_ports = 1; + eth_da->ports[0] = 0; + } + if (!eth_da->nb_representor_ports) { + eth_da->nb_representor_ports = 1; + eth_da->representor_ports[0] = 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) { + i = c * eth_da->nb_ports * + eth_da->nb_representor_ports + + p * eth_da->nb_representor_ports + f; + if (i >= RTE_DIM(eth_da->representor_ports)) { + RTE_LOG(ERR, EAL, "too many representor specified: %s", + str); + return -EINVAL; + } + eth_da->representor_ports[i] = RTE_ETH_REPR( + eth_da->mh_controllers[c], + eth_da->ports[p], + eth_da->type == RTE_ETH_REPRESENTOR_SF, + eth_da->representor_ports[f]); + } + } + } + eth_da->nb_representor_ports = i + 1; err: if (ret < 0) RTE_LOG(ERR, EAL, "wrong representor format: %s", str); diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h index a7969c9408..dbad55c704 100644 --- a/lib/librte_ethdev/rte_ethdev_driver.h +++ b/lib/librte_ethdev/rte_ethdev_driver.h @@ -1218,6 +1218,28 @@ struct rte_eth_devargs { enum rte_eth_representor_type type; /* type of representor */ }; +/** + * Encoding representor port 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 + */ +#define RTE_ETH_REPR(c, pf, sf, port) \ + ((((c) & 3) << 14) | \ + (((pf) & 3) << 12) | \ + (!!(sf) << 11) | \ + ((port) & 0x7ff)) +/** Get 'pf' port id from representor ID */ +#define RTE_ETH_REPR_PF(repr) (((repr) >> 12) & 3) +/** Get 'vf' or 'sf' port from representor ID */ +#define RTE_ETH_REPR_PORT(repr) ((repr) & 0x7ff) + /** * PMD helper function to parse ethdev arguments * From patchwork Fri Dec 18 14:55:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 85462 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EEEEFA09FD; Fri, 18 Dec 2020 15:56:28 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 96EDCCAF7; Fri, 18 Dec 2020 15:56:14 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id DB451CAF1 for ; Fri, 18 Dec 2020 15:56:12 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 18 Dec 2020 16:56:06 +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 0BIEu65U013340; Fri, 18 Dec 2020 16:56:06 +0200 From: Xueming Li To: Viacheslav Ovsiienko , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz , Matan Azrad Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso Date: Fri, 18 Dec 2020 14:55:53 +0000 Message-Id: <1608303356-13089-5-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [RFC 4/7] ethdev: capability for new representor syntax X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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 introduces new eth device capability to support SubFunction representor device. Signed-off-by: Xueming Li --- 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 f5f8919186..3c087bec67 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1432,6 +1432,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 Fri Dec 18 14:55:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 85468 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0325BA09FD; Fri, 18 Dec 2020 15:58:23 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1D40ECB93; Fri, 18 Dec 2020 15:56:23 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 924ABCAFF for ; Fri, 18 Dec 2020 15:56:13 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 18 Dec 2020 16:56:06 +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 0BIEu65V013340; Fri, 18 Dec 2020 16:56:06 +0200 From: Xueming Li To: Viacheslav Ovsiienko , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz , Matan Azrad Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso Date: Fri, 18 Dec 2020 14:55:54 +0000 Message-Id: <1608303356-13089-6-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [RFC 5/7] kvargs: update parser for new representor syntax X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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 allow comma in list value: k1=a[1,2]b[3-5] Signed-off-by: Xueming Li --- lib/librte_kvargs/rte_kvargs.c | 82 +++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 26 deletions(-) diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c index 285081c86c..6193109a17 100644 --- a/lib/librte_kvargs/rte_kvargs.c +++ b/lib/librte_kvargs/rte_kvargs.c @@ -13,15 +13,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 + * v1 + * 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; + int in_list = 0, end_k = 0, end_v = 0; /* Copy the const char *params to a modifiable string * to pass to rte_strsplit @@ -32,36 +36,62 @@ 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_k = 1; + break; + case ',': + /* End of value, skip comma in middle of range */ + if (!in_list) + end_v = 1; + break; + case '[': /* Start of list. */ + in_list++; + break; + case ']': /* End of list. */ + if (in_list) + in_list--; + break; + case 0: /* End of string */ + end_v = 1; + break; + default: + break; + } + + if (!end_k && !end_v) { + /* Continue if not end of key or value. */ + str++; + continue; + } i = kvlist->count; if (i >= RTE_KVARGS_MAX) return -1; - 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) - 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 (start == str) /* Empty key or value. */ + start = NULL; + + if (end_k) { + /* Key parsed. */ + kvlist->pairs[i].key = start; + end_k = 0; + } else if (end_v) { + /* Allow single key or single value. */ + if (kvlist->pairs[i].key || start) { + kvlist->pairs[i].value = start; + kvlist->count++; } + end_v = 0; } - kvlist->count++; - str = NULL; + if (!*str) /* End of string. */ + break; + *str = 0; + str++; + start = str; } return 0; From patchwork Fri Dec 18 14:55:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 85467 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A81FAA09FD; Fri, 18 Dec 2020 15:58:01 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 18164CB7E; Fri, 18 Dec 2020 15:56:22 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 92179CAF1 for ; Fri, 18 Dec 2020 15:56:13 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 18 Dec 2020 16:56:07 +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 0BIEu65W013340; Fri, 18 Dec 2020 16:56:06 +0200 From: Xueming Li To: Viacheslav Ovsiienko , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz , Matan Azrad Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso Date: Fri, 18 Dec 2020 14:55:55 +0000 Message-Id: <1608303356-13089-7-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [RFC 6/7] common/mlx5: update representor name parsing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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 representor name parsing for SF. In sysfs, representor name stored in from 'phys_port_name file', similar to VF representor, switch port name of SF representor is "pfsf". For netlink message, net SF type is supported. Examples: pf0sf1 pf0sf[0-3] Signed-off-by: Xueming Li --- drivers/common/mlx5/linux/mlx5_common_os.c | 32 +++++++++++++++------- drivers/common/mlx5/linux/mlx5_nl.c | 2 ++ drivers/common/mlx5/mlx5_common.h | 2 ++ drivers/net/mlx5/linux/mlx5_ethdev_os.c | 3 ++ 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c index 0edd78ea6d..5cf9576921 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.c +++ b/drivers/common/mlx5/linux/mlx5_common_os.c @@ -97,22 +97,34 @@ void mlx5_translate_port_name(const char *port_name_in, struct mlx5_switch_info *port_info_out) { - char pf_c1, pf_c2, vf_c1, vf_c2, eol; + char ctrl = 0, pf_c1, pf_c2, vf_c1, vf_c2, eol; char *end; int sc_items; - /* - * Check for port-name as a string of the form pf0vf0 - * (support kernel ver >= 5.0 or OFED ver >= 4.6). - */ + sc_items = sscanf(port_name_in, "%c%d", + &ctrl, &port_info_out->ctrl_num); + if (sc_items == 2 && ctrl == 'c') { + port_name_in++; /* 'c' */ + port_name_in += snprintf(NULL, 0, "%d", + port_info_out->ctrl_num); + } + /* Check for port-name as a string of the form pf0vf0 or pf0sf0 */ sc_items = sscanf(port_name_in, "%c%c%d%c%c%d%c", &pf_c1, &pf_c2, &port_info_out->pf_num, &vf_c1, &vf_c2, &port_info_out->port_name, &eol); - if (sc_items == 6 && - pf_c1 == 'p' && pf_c2 == 'f' && - vf_c1 == 'v' && vf_c2 == 'f') { - port_info_out->name_type = MLX5_PHYS_PORT_NAME_TYPE_PFVF; - return; + if (sc_items == 6 && pf_c1 == 'p' && pf_c2 == 'f') { + if (vf_c1 == 'v' && vf_c2 == 'f') { + /* Kernel ver >= 5.0 or OFED ver >= 4.6 */ + port_info_out->name_type = + MLX5_PHYS_PORT_NAME_TYPE_PFVF; + return; + } + if (vf_c1 == 's' && vf_c2 == 'f') { + /* Kernel ver >= 5.11 or OFED ver >= 5.1 */ + port_info_out->name_type = + MLX5_PHYS_PORT_NAME_TYPE_PFSF; + return; + } } /* * Check for port-name as a string of the form p0 diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c index 40d8620300..3d55cc98b4 100644 --- a/drivers/common/mlx5/linux/mlx5_nl.c +++ b/drivers/common/mlx5/linux/mlx5_nl.c @@ -1148,6 +1148,8 @@ mlx5_nl_check_switch_info(bool num_vf_set, case MLX5_PHYS_PORT_NAME_TYPE_PFHPF: /* Fallthrough */ case MLX5_PHYS_PORT_NAME_TYPE_PFVF: + /* Fallthrough */ + case MLX5_PHYS_PORT_NAME_TYPE_PFSF: /* New representors naming schema. */ switch_info->representor = 1; break; diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index a484b74b9c..4c75addd08 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -153,6 +153,7 @@ enum mlx5_nl_phys_port_name_type { MLX5_PHYS_PORT_NAME_TYPE_UPLINK, /* p0, kernel ver >= 5.0 */ MLX5_PHYS_PORT_NAME_TYPE_PFVF, /* pf0vf0, kernel ver >= 5.0 */ MLX5_PHYS_PORT_NAME_TYPE_PFHPF, /* pf0, kernel ver >= 5.7, HPF rep */ + MLX5_PHYS_PORT_NAME_TYPE_PFSF, /* pf0sf0, kernel ver >= 5.0 */ MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN, /* Unrecognized. */ }; @@ -161,6 +162,7 @@ struct mlx5_switch_info { uint32_t master:1; /**< Master device. */ uint32_t representor:1; /**< Representor device. */ enum mlx5_nl_phys_port_name_type name_type; /** < Port name type. */ + int32_t ctrl_num; /**< Controller number (valid for c#pf#vf# format). */ int32_t pf_num; /**< PF number (valid for pfxvfx format only). */ int32_t port_name; /**< Representor port name. */ uint64_t switch_id; /**< Switch identifier. */ diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index 128845cb52..d4eed11fbc 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -1013,6 +1013,9 @@ mlx5_sysfs_check_switch_info(bool device_dir, /* New representors naming schema. */ switch_info->representor = 1; break; + default: + switch_info->master = device_dir; + break; } } From patchwork Fri Dec 18 14:55:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 85466 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2E0E7A09FD; Fri, 18 Dec 2020 15:57:47 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 078BACB6B; Fri, 18 Dec 2020 15:56:21 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 92319CAF7 for ; Fri, 18 Dec 2020 15:56:13 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 18 Dec 2020 16:56:07 +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 0BIEu65X013340; Fri, 18 Dec 2020 16:56:07 +0200 From: Xueming Li To: Viacheslav Ovsiienko , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz , Matan Azrad Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso Date: Fri, 18 Dec 2020 14:55:56 +0000 Message-Id: <1608303356-13089-8-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-1-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [RFC 7/7] net/mlx5: support representor of sub function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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 supports of SF representor. Similar to VF representor, switch port name of SF representor in sysfs phys_port_name is "pfsf". Device representor argumnt is "representors=sf[list]", list member could be mix of instance and range. Example: representors=sf[0,2,4,8-12,-1] To probe VF representor and SF representor, need to separate into 2 devices: -a ,representor=vf[list] -a ,representor=sf[list] Signed-off-by: Xueming Li --- drivers/net/mlx5/linux/mlx5_ethdev_os.c | 2 + drivers/net/mlx5/linux/mlx5_os.c | 69 ++++++++++++++++++++++--- drivers/net/mlx5/mlx5_ethdev.c | 2 + 3 files changed, 67 insertions(+), 6 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index d4eed11fbc..11c30d587c 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -1010,6 +1010,8 @@ mlx5_sysfs_check_switch_info(bool device_dir, case MLX5_PHYS_PORT_NAME_TYPE_PFHPF: /* Fallthrough */ case MLX5_PHYS_PORT_NAME_TYPE_PFVF: + /* Fallthrough */ + case MLX5_PHYS_PORT_NAME_TYPE_PFSF: /* New representors naming schema. */ switch_info->representor = 1; break; diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 917d6be7b8..aeac1abb2c 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -692,20 +692,70 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, /* Determine if this port representor is supposed to be spawned. */ if (switch_info->representor && dpdk_dev->devargs) { - struct rte_eth_devargs eth_da; + struct rte_eth_devargs eth_da = { .nb_ports = 0 }; err = rte_eth_devargs_parse(dpdk_dev->devargs->args, ð_da); if (err) { rte_errno = -err; DRV_LOG(ERR, "failed to process device arguments: %s", - strerror(rte_errno)); + dpdk_dev->devargs->args); return NULL; } + switch (eth_da.type) { + case RTE_ETH_REPRESENTOR_PF: + if (switch_info->name_type != + MLX5_PHYS_PORT_NAME_TYPE_PFHPF) { + rte_errno = EBUSY; + return NULL; + } + break; + case RTE_ETH_REPRESENTOR_SF: + if (switch_info->name_type != + MLX5_PHYS_PORT_NAME_TYPE_PFSF) { + rte_errno = EBUSY; + return NULL; + } + break; + case RTE_ETH_REPRESENTOR_VF: + /* Allows HPF representor index -1 as exception. */ + if (!(spawn->info.port_name == -1 && + switch_info->name_type == + MLX5_PHYS_PORT_NAME_TYPE_PFHPF) && + switch_info->name_type != + MLX5_PHYS_PORT_NAME_TYPE_PFVF) { + rte_errno = EBUSY; + return NULL; + } + break; + default: + rte_errno = EBUSY; + return NULL; + } + /* Check controller ID: */ + for (i = 0; i < eth_da.nb_mh_controllers; ++i) + if (eth_da.mh_controllers[i] == + (uint16_t)switch_info->ctrl_num) + break; + if (eth_da.nb_mh_controllers && i == eth_da.nb_mh_controllers) { + rte_errno = EBUSY; + return NULL; + } + /* Check PF ID: */ + for (i = 0; i < eth_da.nb_ports; ++i) + if (eth_da.ports[i] == + (uint16_t)switch_info->pf_num) + break; + if (eth_da.nb_ports && i == eth_da.nb_ports) { + rte_errno = EBUSY; + return NULL; + } + /* Check SF/VF ID: */ for (i = 0; i < eth_da.nb_representor_ports; ++i) if (eth_da.representor_ports[i] == (uint16_t)switch_info->port_name) break; - if (i == eth_da.nb_representor_ports) { + if (eth_da.type != RTE_ETH_REPRESENTOR_PF && + i == eth_da.nb_representor_ports) { rte_errno = EBUSY; return NULL; } @@ -716,8 +766,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, if (!switch_info->representor) strlcpy(name, dpdk_dev->name, sizeof(name)); else - snprintf(name, sizeof(name), "%s_representor_%u", - dpdk_dev->name, switch_info->port_name); + snprintf(name, sizeof(name), "%s_representor_%s%u", + dpdk_dev->name, + switch_info->name_type == + MLX5_PHYS_PORT_NAME_TYPE_PFSF ? "sf" : "vf", + switch_info->port_name); } else { /* Bonding device. */ if (!switch_info->representor) @@ -725,9 +778,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, dpdk_dev->name, mlx5_os_get_dev_device_name(spawn->phys_dev)); else - snprintf(name, sizeof(name), "%s_%s_representor_%u", + snprintf(name, sizeof(name), "%s_%s_representor_%s%u", dpdk_dev->name, mlx5_os_get_dev_device_name(spawn->phys_dev), + switch_info->name_type == + MLX5_PHYS_PORT_NAME_TYPE_PFSF ? "sf" : "vf", switch_info->port_name); } /* check if the device is already spawned */ @@ -1966,6 +2021,8 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, case MLX5_PHYS_PORT_NAME_TYPE_PFHPF: /* Fallthrough */ case MLX5_PHYS_PORT_NAME_TYPE_PFVF: + /* Fallthrough */ + case MLX5_PHYS_PORT_NAME_TYPE_PFSF: if (list[ns].info.pf_num == bd) ns++; break; diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index 45ee7e4488..ad6aacc329 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -374,6 +374,8 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) break; } } + if (priv->master) + info->dev_capa = RTE_ETH_DEV_CAPA_REPRESENTOR_SF; return 0; }