2 * Copyright (c) 2016 Solarflare Communications Inc.
5 * This software was jointly developed between OKTET Labs (under contract
6 * for Solarflare) and Solarflare Communications, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
11 * 1. Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <rte_ethdev.h>
35 #include "sfc_debug.h"
37 #include "sfc_kvargs.h"
41 sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
43 struct sfc_adapter *sa = dev->data->dev_private;
45 sfc_log_init(sa, "entry");
47 dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device);
50 static const struct eth_dev_ops sfc_eth_dev_ops = {
51 .dev_infos_get = sfc_dev_infos_get,
55 sfc_eth_dev_init(struct rte_eth_dev *dev)
57 struct sfc_adapter *sa = dev->data->dev_private;
58 struct rte_pci_device *pci_dev = SFC_DEV_TO_PCI(dev);
61 /* Required for logging */
64 /* Copy PCI device info to the dev->data */
65 rte_eth_copy_pci_info(dev, pci_dev);
67 rc = sfc_kvargs_parse(sa);
69 goto fail_kvargs_parse;
71 rc = sfc_kvargs_process(sa, SFC_KVARG_DEBUG_INIT,
72 sfc_kvarg_bool_handler, &sa->debug_init);
74 goto fail_kvarg_debug_init;
76 sfc_log_init(sa, "entry");
78 dev->dev_ops = &sfc_eth_dev_ops;
80 sfc_log_init(sa, "done");
83 fail_kvarg_debug_init:
84 sfc_kvargs_cleanup(sa);
87 sfc_log_init(sa, "failed %d", rc);
93 sfc_eth_dev_uninit(struct rte_eth_dev *dev)
95 struct sfc_adapter *sa = dev->data->dev_private;
97 sfc_log_init(sa, "entry");
101 sfc_kvargs_cleanup(sa);
103 sfc_log_init(sa, "done");
105 /* Required for logging, so cleanup last */
110 static const struct rte_pci_id pci_id_sfc_efx_map[] = {
111 { .vendor_id = 0 /* sentinel */ }
114 static struct eth_driver sfc_efx_pmd = {
116 .id_table = pci_id_sfc_efx_map,
118 .probe = rte_eth_dev_pci_probe,
119 .remove = rte_eth_dev_pci_remove,
121 .eth_dev_init = sfc_eth_dev_init,
122 .eth_dev_uninit = sfc_eth_dev_uninit,
123 .dev_private_size = sizeof(struct sfc_adapter),
126 RTE_PMD_REGISTER_PCI(net_sfc_efx, sfc_efx_pmd.pci_drv);
127 RTE_PMD_REGISTER_PCI_TABLE(net_sfc_efx, pci_id_sfc_efx_map);
128 RTE_PMD_REGISTER_PARAM_STRING(net_sfc_efx,
129 SFC_KVARG_DEBUG_INIT "=" SFC_KVARG_VALUES_BOOL);