drivers/bus: move driver assignment to end of probing
[dpdk.git] / drivers / bus / vdev / vdev_params.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2018 GaĆ«tan Rivet
3  */
4
5 #include <rte_dev.h>
6 #include <rte_bus.h>
7 #include <rte_kvargs.h>
8 #include <rte_errno.h>
9
10 #include "vdev_logs.h"
11 #include "vdev_private.h"
12
13 enum vdev_params {
14         RTE_VDEV_PARAM_MAX,
15 };
16
17 static const char * const vdev_params_keys[] = {
18         [RTE_VDEV_PARAM_MAX] = NULL,
19 };
20
21 static int
22 vdev_dev_match(const struct rte_device *dev,
23                const void *_kvlist)
24 {
25         const struct rte_kvargs *kvlist = _kvlist;
26
27         (void) kvlist;
28         (void) dev;
29         return 0;
30 }
31
32 void *
33 rte_vdev_dev_iterate(const void *start,
34                      const char *str,
35                      const struct rte_dev_iterator *it __rte_unused)
36 {
37         struct rte_kvargs *kvargs = NULL;
38         struct rte_device *dev;
39
40         if (str != NULL) {
41                 kvargs = rte_kvargs_parse(str, vdev_params_keys);
42                 if (kvargs == NULL) {
43                         VDEV_LOG(ERR, "cannot parse argument list\n");
44                         rte_errno = EINVAL;
45                         return NULL;
46                 }
47         }
48         dev = rte_vdev_find_device(start, vdev_dev_match, kvargs);
49         rte_kvargs_free(kvargs);
50         return dev;
51 }