+static int
+parse_xstats_list(const char *in_str, struct rte_eth_xstat_name **xstats,
+ unsigned int *xstats_num)
+{
+ int max_names_nb, names_nb, nonempty_names_nb;
+ int name, nonempty_name;
+ int stringlen;
+ char **names;
+ char *str;
+ int ret;
+ int i;
+
+ names = NULL;
+ str = strdup(in_str);
+ if (str == NULL) {
+ ret = -ENOMEM;
+ goto out;
+ }
+ stringlen = strlen(str);
+
+ for (i = 0, max_names_nb = 1; str[i] != '\0'; i++) {
+ if (str[i] == ',')
+ max_names_nb++;
+ }
+
+ names = calloc(max_names_nb, sizeof(*names));
+ if (names == NULL) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ names_nb = rte_strsplit(str, stringlen, names, max_names_nb, ',');
+ if (names_nb < 0) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ nonempty_names_nb = 0;
+ for (i = 0; i < names_nb; i++) {
+ if (names[i][0] == '\0')
+ continue;
+ nonempty_names_nb++;
+ }
+ *xstats = calloc(nonempty_names_nb, sizeof(**xstats));
+ if (*xstats == NULL) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ for (name = nonempty_name = 0; name < names_nb; name++) {
+ if (names[name][0] == '\0')
+ continue;
+ rte_strscpy((*xstats)[nonempty_name].name, names[name],
+ sizeof((*xstats)[nonempty_name].name));
+ nonempty_name++;
+ }
+
+ *xstats_num = nonempty_names_nb;
+ ret = 0;
+
+out:
+ free(names);
+ free(str);
+ return ret;
+}
+
+static int
+parse_link_speed(int n)
+{
+ uint32_t speed = RTE_ETH_LINK_SPEED_FIXED;
+
+ switch (n) {
+ case 1000:
+ speed |= RTE_ETH_LINK_SPEED_1G;
+ break;
+ case 10000:
+ speed |= RTE_ETH_LINK_SPEED_10G;
+ break;
+ case 25000:
+ speed |= RTE_ETH_LINK_SPEED_25G;
+ break;
+ case 40000:
+ speed |= RTE_ETH_LINK_SPEED_40G;
+ break;
+ case 50000:
+ speed |= RTE_ETH_LINK_SPEED_50G;
+ break;
+ case 100000:
+ speed |= RTE_ETH_LINK_SPEED_100G;
+ break;
+ case 200000:
+ speed |= RTE_ETH_LINK_SPEED_200G;
+ break;
+ case 100:
+ case 10:
+ default:
+ fprintf(stderr, "Unsupported fixed speed\n");
+ return 0;
+ }
+
+ return speed;
+}
+