net/atlantic: add logging structure
[dpdk.git] / drivers / net / atlantic / atl_ethdev.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Aquantia Corporation
3  */
4
5 #include <rte_ethdev_pci.h>
6
7 #include "atl_ethdev.h"
8 #include "atl_common.h"
9
10 static int eth_atl_dev_init(struct rte_eth_dev *eth_dev);
11 static int eth_atl_dev_uninit(struct rte_eth_dev *eth_dev);
12
13 static int  atl_dev_configure(struct rte_eth_dev *dev);
14 static int  atl_dev_start(struct rte_eth_dev *dev);
15 static void atl_dev_stop(struct rte_eth_dev *dev);
16 static void atl_dev_close(struct rte_eth_dev *dev);
17 static int  atl_dev_reset(struct rte_eth_dev *dev);
18
19 static int eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
20         struct rte_pci_device *pci_dev);
21 static int eth_atl_pci_remove(struct rte_pci_device *pci_dev);
22
23 static void atl_dev_info_get(struct rte_eth_dev *dev,
24                                 struct rte_eth_dev_info *dev_info);
25
26 int atl_logtype_init;
27 int atl_logtype_driver;
28
29 /*
30  * The set of PCI devices this driver supports
31  */
32 static const struct rte_pci_id pci_id_atl_map[] = {
33         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_0001) },
34         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_D100) },
35         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_D107) },
36         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_D108) },
37         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_D109) },
38
39         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC100) },
40         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC107) },
41         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC108) },
42         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC109) },
43         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC111) },
44         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC112) },
45
46         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC100S) },
47         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC107S) },
48         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC108S) },
49         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC109S) },
50         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC111S) },
51         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC112S) },
52
53         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC111E) },
54         { RTE_PCI_DEVICE(PCI_VENDOR_ID_AQUANTIA, AQ_DEVICE_ID_AQC112E) },
55         { .vendor_id = 0, /* sentinel */ },
56 };
57
58 static struct rte_pci_driver rte_atl_pmd = {
59         .id_table = pci_id_atl_map,
60         .drv_flags = RTE_PCI_DRV_NEED_MAPPING |
61                      RTE_PCI_DRV_IOVA_AS_VA,
62         .probe = eth_atl_pci_probe,
63         .remove = eth_atl_pci_remove,
64 };
65
66 static const struct eth_dev_ops atl_eth_dev_ops = {
67         .dev_configure        = atl_dev_configure,
68         .dev_start            = atl_dev_start,
69         .dev_stop             = atl_dev_stop,
70         .dev_close            = atl_dev_close,
71         .dev_reset            = atl_dev_reset,
72         .dev_infos_get        = atl_dev_info_get,
73 };
74
75 static int
76 eth_atl_dev_init(struct rte_eth_dev *eth_dev)
77 {
78         eth_dev->dev_ops = &atl_eth_dev_ops;
79
80         /* Allocate memory for storing MAC addresses */
81         eth_dev->data->mac_addrs = rte_zmalloc("atlantic", ETHER_ADDR_LEN, 0);
82         if (eth_dev->data->mac_addrs == NULL)
83                 return -ENOMEM;
84
85         return 0;
86 }
87
88 static int
89 eth_atl_dev_uninit(struct rte_eth_dev *eth_dev)
90 {
91         rte_free(eth_dev->data->mac_addrs);
92
93         return 0;
94 }
95
96 static int
97 eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
98         struct rte_pci_device *pci_dev)
99 {
100         return rte_eth_dev_pci_generic_probe(pci_dev,
101                 sizeof(struct atl_adapter), eth_atl_dev_init);
102 }
103
104 static int
105 eth_atl_pci_remove(struct rte_pci_device *pci_dev)
106 {
107         return rte_eth_dev_pci_generic_remove(pci_dev, eth_atl_dev_uninit);
108 }
109
110 static int
111 atl_dev_configure(struct rte_eth_dev *dev __rte_unused)
112 {
113         return 0;
114 }
115
116 /*
117  * Configure device link speed and setup link.
118  * It returns 0 on success.
119  */
120 static int
121 atl_dev_start(struct rte_eth_dev *dev __rte_unused)
122 {
123         return 0;
124 }
125
126 /*
127  * Stop device: disable rx and tx functions to allow for reconfiguring.
128  */
129 static void
130 atl_dev_stop(struct rte_eth_dev *dev __rte_unused)
131 {
132 }
133
134 /*
135  * Reset and stop device.
136  */
137 static void
138 atl_dev_close(struct rte_eth_dev *dev __rte_unused)
139 {
140 }
141
142 static int
143 atl_dev_reset(struct rte_eth_dev *dev)
144 {
145         int ret;
146
147         ret = eth_atl_dev_uninit(dev);
148         if (ret)
149                 return ret;
150
151         ret = eth_atl_dev_init(dev);
152
153         return ret;
154 }
155
156 static void
157 atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
158 {
159         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
160
161         dev_info->max_rx_queues = 0;
162         dev_info->max_rx_queues = 0;
163
164         dev_info->max_vfs = pci_dev->max_vfs;
165
166         dev_info->max_hash_mac_addrs = 0;
167         dev_info->max_vmdq_pools = 0;
168         dev_info->vmdq_queue_num = 0;
169 }
170
171 RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd);
172 RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map);
173 RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic");
174
175 RTE_INIT(atl_init_log)
176 {
177         atl_logtype_init = rte_log_register("pmd.net.atlantic.init");
178         if (atl_logtype_init >= 0)
179                 rte_log_set_level(atl_logtype_init, RTE_LOG_NOTICE);
180         atl_logtype_driver = rte_log_register("pmd.net.atlantic.driver");
181         if (atl_logtype_driver >= 0)
182                 rte_log_set_level(atl_logtype_driver, RTE_LOG_NOTICE);
183 }
184