1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Intel Corporation
11 #include <rte_interrupts.h>
12 #include <rte_debug.h>
14 #include <rte_atomic.h>
16 #include <rte_ether.h>
17 #include <rte_ethdev_pci.h>
18 #include <rte_kvargs.h>
19 #include <rte_malloc.h>
20 #include <rte_memzone.h>
23 #include <iavf_devids.h>
25 #include "ice_generic_flow.h"
26 #include "ice_dcf_ethdev.h"
29 ice_dcf_recv_pkts(__rte_unused void *rx_queue,
30 __rte_unused struct rte_mbuf **bufs,
31 __rte_unused uint16_t nb_pkts)
37 ice_dcf_xmit_pkts(__rte_unused void *tx_queue,
38 __rte_unused struct rte_mbuf **bufs,
39 __rte_unused uint16_t nb_pkts)
45 ice_dcf_dev_start(struct rte_eth_dev *dev)
47 dev->data->dev_link.link_status = ETH_LINK_UP;
53 ice_dcf_dev_stop(struct rte_eth_dev *dev)
55 dev->data->dev_link.link_status = ETH_LINK_DOWN;
59 ice_dcf_dev_configure(__rte_unused struct rte_eth_dev *dev)
65 ice_dcf_dev_info_get(struct rte_eth_dev *dev,
66 struct rte_eth_dev_info *dev_info)
68 struct ice_dcf_adapter *adapter = dev->data->dev_private;
70 dev_info->max_mac_addrs = 1;
71 dev_info->max_rx_pktlen = (uint32_t)-1;
72 dev_info->max_rx_queues = RTE_DIM(adapter->rxqs);
73 dev_info->max_tx_queues = RTE_DIM(adapter->txqs);
79 ice_dcf_stats_get(__rte_unused struct rte_eth_dev *dev,
80 __rte_unused struct rte_eth_stats *igb_stats)
86 ice_dcf_stats_reset(__rte_unused struct rte_eth_dev *dev)
92 ice_dcf_dev_promiscuous_enable(__rte_unused struct rte_eth_dev *dev)
98 ice_dcf_dev_promiscuous_disable(__rte_unused struct rte_eth_dev *dev)
104 ice_dcf_dev_allmulticast_enable(__rte_unused struct rte_eth_dev *dev)
110 ice_dcf_dev_allmulticast_disable(__rte_unused struct rte_eth_dev *dev)
116 ice_dcf_dev_filter_ctrl(struct rte_eth_dev *dev,
117 enum rte_filter_type filter_type,
118 __rte_unused enum rte_filter_op filter_op,
119 __rte_unused void *arg)
126 switch (filter_type) {
128 PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
138 ice_dcf_dev_close(struct rte_eth_dev *dev)
140 struct ice_dcf_adapter *adapter = dev->data->dev_private;
142 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
146 dev->rx_pkt_burst = NULL;
147 dev->tx_pkt_burst = NULL;
149 ice_dcf_uninit_parent_adapter(dev);
150 ice_dcf_uninit_hw(dev, &adapter->real_hw);
154 ice_dcf_queue_release(__rte_unused void *q)
159 ice_dcf_link_update(__rte_unused struct rte_eth_dev *dev,
160 __rte_unused int wait_to_complete)
166 ice_dcf_rx_queue_setup(struct rte_eth_dev *dev,
167 uint16_t rx_queue_id,
168 __rte_unused uint16_t nb_rx_desc,
169 __rte_unused unsigned int socket_id,
170 __rte_unused const struct rte_eth_rxconf *rx_conf,
171 __rte_unused struct rte_mempool *mb_pool)
173 struct ice_dcf_adapter *adapter = dev->data->dev_private;
175 dev->data->rx_queues[rx_queue_id] = &adapter->rxqs[rx_queue_id];
181 ice_dcf_tx_queue_setup(struct rte_eth_dev *dev,
182 uint16_t tx_queue_id,
183 __rte_unused uint16_t nb_tx_desc,
184 __rte_unused unsigned int socket_id,
185 __rte_unused const struct rte_eth_txconf *tx_conf)
187 struct ice_dcf_adapter *adapter = dev->data->dev_private;
189 dev->data->tx_queues[tx_queue_id] = &adapter->txqs[tx_queue_id];
194 static const struct eth_dev_ops ice_dcf_eth_dev_ops = {
195 .dev_start = ice_dcf_dev_start,
196 .dev_stop = ice_dcf_dev_stop,
197 .dev_close = ice_dcf_dev_close,
198 .dev_configure = ice_dcf_dev_configure,
199 .dev_infos_get = ice_dcf_dev_info_get,
200 .rx_queue_setup = ice_dcf_rx_queue_setup,
201 .tx_queue_setup = ice_dcf_tx_queue_setup,
202 .rx_queue_release = ice_dcf_queue_release,
203 .tx_queue_release = ice_dcf_queue_release,
204 .link_update = ice_dcf_link_update,
205 .stats_get = ice_dcf_stats_get,
206 .stats_reset = ice_dcf_stats_reset,
207 .promiscuous_enable = ice_dcf_dev_promiscuous_enable,
208 .promiscuous_disable = ice_dcf_dev_promiscuous_disable,
209 .allmulticast_enable = ice_dcf_dev_allmulticast_enable,
210 .allmulticast_disable = ice_dcf_dev_allmulticast_disable,
211 .filter_ctrl = ice_dcf_dev_filter_ctrl,
215 ice_dcf_dev_init(struct rte_eth_dev *eth_dev)
217 struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
219 eth_dev->dev_ops = &ice_dcf_eth_dev_ops;
220 eth_dev->rx_pkt_burst = ice_dcf_recv_pkts;
221 eth_dev->tx_pkt_burst = ice_dcf_xmit_pkts;
223 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
226 eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
228 adapter->real_hw.vc_event_msg_cb = ice_dcf_handle_pf_event_msg;
229 if (ice_dcf_init_hw(eth_dev, &adapter->real_hw) != 0) {
230 PMD_INIT_LOG(ERR, "Failed to init DCF hardware");
234 if (ice_dcf_init_parent_adapter(eth_dev) != 0) {
235 PMD_INIT_LOG(ERR, "Failed to init DCF parent adapter");
236 ice_dcf_uninit_hw(eth_dev, &adapter->real_hw);
244 ice_dcf_dev_uninit(struct rte_eth_dev *eth_dev)
246 ice_dcf_dev_close(eth_dev);
252 ice_dcf_cap_check_handler(__rte_unused const char *key,
253 const char *value, __rte_unused void *opaque)
255 if (strcmp(value, "dcf"))
262 ice_dcf_cap_selected(struct rte_devargs *devargs)
264 struct rte_kvargs *kvlist;
265 const char *key = "cap";
271 kvlist = rte_kvargs_parse(devargs->args, NULL);
275 if (!rte_kvargs_count(kvlist, key))
278 /* dcf capability selected when there's a key-value pair: cap=dcf */
279 if (rte_kvargs_process(kvlist, key,
280 ice_dcf_cap_check_handler, NULL) < 0)
286 rte_kvargs_free(kvlist);
290 static int eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv,
291 struct rte_pci_device *pci_dev)
293 if (!ice_dcf_cap_selected(pci_dev->device.devargs))
296 return rte_eth_dev_pci_generic_probe(pci_dev,
297 sizeof(struct ice_dcf_adapter),
301 static int eth_ice_dcf_pci_remove(struct rte_pci_device *pci_dev)
303 return rte_eth_dev_pci_generic_remove(pci_dev, ice_dcf_dev_uninit);
306 static const struct rte_pci_id pci_id_ice_dcf_map[] = {
307 { RTE_PCI_DEVICE(IAVF_INTEL_VENDOR_ID, IAVF_DEV_ID_ADAPTIVE_VF) },
308 { .vendor_id = 0, /* sentinel */ },
311 static struct rte_pci_driver rte_ice_dcf_pmd = {
312 .id_table = pci_id_ice_dcf_map,
313 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
314 .probe = eth_ice_dcf_pci_probe,
315 .remove = eth_ice_dcf_pci_remove,
318 RTE_PMD_REGISTER_PCI(net_ice_dcf, rte_ice_dcf_pmd);
319 RTE_PMD_REGISTER_PCI_TABLE(net_ice_dcf, pci_id_ice_dcf_map);
320 RTE_PMD_REGISTER_KMOD_DEP(net_ice_dcf, "* igb_uio | vfio-pci");
321 RTE_PMD_REGISTER_PARAM_STRING(net_ice_dcf, "cap=dcf");