4 * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
5 * Copyright (c) 2016 NXP. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Freescale Semiconductor, Inc nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <rte_ethdev.h>
39 #include <rte_malloc.h>
40 #include <rte_memcpy.h>
41 #include <rte_string_fns.h>
42 #include <rte_cycles.h>
43 #include <rte_kvargs.h>
45 #include <rte_ethdev.h>
46 #include <rte_fslmc.h>
48 #include <fslmc_vfio.h>
49 #include "dpaa2_ethdev.h"
51 static struct rte_dpaa2_driver rte_dpaa2_pmd;
54 dpaa2_dev_init(struct rte_eth_dev *eth_dev)
56 /* For secondary processes, the primary has done all the work */
57 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
60 eth_dev->data->drv_name = rte_dpaa2_pmd.driver.name;
66 dpaa2_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused)
68 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
75 rte_dpaa2_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
76 struct rte_dpaa2_device *dpaa2_dev)
78 struct rte_eth_dev *eth_dev;
79 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
83 sprintf(ethdev_name, "dpni-%d", dpaa2_dev->object_id);
85 eth_dev = rte_eth_dev_allocate(ethdev_name);
89 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
90 eth_dev->data->dev_private = rte_zmalloc(
91 "ethdev private structure",
92 sizeof(struct dpaa2_dev_priv),
94 if (eth_dev->data->dev_private == NULL) {
95 RTE_LOG(CRIT, PMD, "Cannot allocate memzone for"
96 " private port data\n");
97 rte_eth_dev_release_port(eth_dev);
101 eth_dev->device = &dpaa2_dev->device;
102 dpaa2_dev->eth_dev = eth_dev;
103 eth_dev->data->rx_mbuf_alloc_failed = 0;
105 /* Invoke PMD device initialization function */
106 diag = dpaa2_dev_init(eth_dev);
110 if (rte_eal_process_type() == RTE_PROC_PRIMARY)
111 rte_free(eth_dev->data->dev_private);
112 rte_eth_dev_release_port(eth_dev);
117 rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev)
119 struct rte_eth_dev *eth_dev;
121 eth_dev = dpaa2_dev->eth_dev;
122 dpaa2_dev_uninit(eth_dev);
124 if (rte_eal_process_type() == RTE_PROC_PRIMARY)
125 rte_free(eth_dev->data->dev_private);
126 rte_eth_dev_release_port(eth_dev);
131 static struct rte_dpaa2_driver rte_dpaa2_pmd = {
132 .drv_type = DPAA2_MC_DPNI_DEVID,
133 .probe = rte_dpaa2_probe,
134 .remove = rte_dpaa2_remove,
137 RTE_PMD_REGISTER_DPAA2(net_dpaa2, rte_dpaa2_pmd);