1 /* SPDX-License-Identifier: BSD-3-Clause
6 #include <rte_kvargs.h>
7 #include <rte_ethdev_vdev.h>
8 #include <rte_bus_vdev.h>
14 #define PFE_MAX_MACS 1 /*we can support upto 4 MACs per IF*/
15 #define PFE_VDEV_GEM_ID_ARG "intf"
17 struct pfe_vdev_init_params {
20 static struct pfe *g_pfe;
21 /* Supported Rx offloads */
22 static uint64_t dev_rx_offloads_sup =
23 DEV_RX_OFFLOAD_IPV4_CKSUM |
24 DEV_RX_OFFLOAD_UDP_CKSUM |
25 DEV_RX_OFFLOAD_TCP_CKSUM;
27 /* Supported Tx offloads */
28 static uint64_t dev_tx_offloads_sup =
29 DEV_TX_OFFLOAD_IPV4_CKSUM |
30 DEV_TX_OFFLOAD_UDP_CKSUM |
31 DEV_TX_OFFLOAD_TCP_CKSUM;
33 /* TODO: make pfe_svr a runtime option.
34 * Driver should be able to get the SVR
35 * information from HW.
37 unsigned int pfe_svr = SVR_LS1012A_REV1;
38 static void *cbus_emac_base[3];
39 static void *cbus_gpi_base[3];
46 pfe_gemac_init(struct pfe_eth_priv_s *priv)
50 cfg.speed = SPEED_1000M;
51 cfg.duplex = DUPLEX_FULL;
53 gemac_set_config(priv->EMAC_baseaddr, &cfg);
54 gemac_allow_broadcast(priv->EMAC_baseaddr);
55 gemac_enable_1536_rx(priv->EMAC_baseaddr);
56 gemac_enable_stacked_vlan(priv->EMAC_baseaddr);
57 gemac_enable_pause_rx(priv->EMAC_baseaddr);
58 gemac_set_bus_width(priv->EMAC_baseaddr, 64);
59 gemac_enable_rx_checksum_offload(priv->EMAC_baseaddr);
65 pfe_soc_version_get(void)
67 FILE *svr_file = NULL;
68 unsigned int svr_ver = 0;
70 PMD_INIT_FUNC_TRACE();
72 svr_file = fopen(PFE_SOC_ID_FILE, "r");
74 PFE_PMD_ERR("Unable to open SoC device");
75 return; /* Not supported on this infra */
78 if (fscanf(svr_file, "svr:%x", &svr_ver) > 0)
81 PFE_PMD_ERR("Unable to read SoC device");
86 static int pfe_eth_start(struct pfe_eth_priv_s *priv)
88 gpi_enable(priv->GPI_baseaddr);
89 gemac_enable(priv->EMAC_baseaddr);
95 pfe_eth_flush_txQ(struct pfe_eth_priv_s *priv, int tx_q_num, int
96 __rte_unused from_tx, __rte_unused int n_desc)
98 struct rte_mbuf *mbuf;
101 /* Clean HIF and client queue */
102 while ((mbuf = hif_lib_tx_get_next_complete(&priv->client,
108 rte_pktmbuf_free(mbuf);
115 pfe_eth_flush_tx(struct pfe_eth_priv_s *priv)
119 for (ii = 0; ii < emac_txq_cnt; ii++)
120 pfe_eth_flush_txQ(priv, ii, 0, 0);
124 pfe_eth_event_handler(void *data, int event, __rte_unused int qno)
126 struct pfe_eth_priv_s *priv = data;
129 case EVENT_TXDONE_IND:
130 pfe_eth_flush_tx(priv);
131 hif_lib_event_handler_start(&priv->client, EVENT_TXDONE_IND, 0);
133 case EVENT_HIGH_RX_WM:
142 pfe_recv_pkts_on_intr(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
144 struct hif_client_rx_queue *queue = rxq;
145 struct pfe_eth_priv_s *priv = queue->priv;
146 struct epoll_event epoll_ev;
147 uint64_t ticks = 1; /* 1 msec */
149 int have_something, work_done;
151 #define RESET_STATUS (HIF_INT | HIF_RXPKT_INT)
153 /*TODO can we remove this cleanup from here?*/
154 pfe_tx_do_cleanup(priv->pfe);
155 have_something = pfe_hif_rx_process(priv->pfe, nb_pkts);
156 work_done = hif_lib_receive_pkt(rxq, priv->pfe->hif.shm->pool,
159 if (!have_something || !work_done) {
160 writel(RESET_STATUS, HIF_INT_SRC);
161 writel(readl(HIF_INT_ENABLE) | HIF_RXPKT_INT, HIF_INT_ENABLE);
162 ret = epoll_wait(priv->pfe->hif.epoll_fd, &epoll_ev, 1, ticks);
163 if (ret < 0 && errno != EINTR)
164 PFE_PMD_ERR("epoll_wait fails with %d\n", errno);
171 pfe_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
173 struct hif_client_rx_queue *queue = rxq;
174 struct pfe_eth_priv_s *priv = queue->priv;
175 struct rte_mempool *pool;
177 /*TODO can we remove this cleanup from here?*/
178 pfe_tx_do_cleanup(priv->pfe);
179 pfe_hif_rx_process(priv->pfe, nb_pkts);
180 pool = priv->pfe->hif.shm->pool;
182 return hif_lib_receive_pkt(rxq, pool, rx_pkts, nb_pkts);
186 pfe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
188 struct hif_client_tx_queue *queue = tx_queue;
189 struct pfe_eth_priv_s *priv = queue->priv;
190 struct rte_eth_stats *stats = &priv->stats;
193 for (i = 0; i < nb_pkts; i++) {
194 if (tx_pkts[i]->nb_segs > 1) {
195 struct rte_mbuf *mbuf;
198 hif_lib_xmit_pkt(&priv->client, queue->queue_id,
199 (void *)(size_t)rte_pktmbuf_iova(tx_pkts[i]),
200 tx_pkts[i]->buf_addr + tx_pkts[i]->data_off,
201 tx_pkts[i]->data_len, 0x0, HIF_FIRST_BUFFER,
204 mbuf = tx_pkts[i]->next;
205 for (j = 0; j < (tx_pkts[i]->nb_segs - 2); j++) {
206 hif_lib_xmit_pkt(&priv->client, queue->queue_id,
207 (void *)(size_t)rte_pktmbuf_iova(mbuf),
208 mbuf->buf_addr + mbuf->data_off,
214 hif_lib_xmit_pkt(&priv->client, queue->queue_id,
215 (void *)(size_t)rte_pktmbuf_iova(mbuf),
216 mbuf->buf_addr + mbuf->data_off,
218 0x0, HIF_LAST_BUFFER | HIF_DATA_VALID,
221 hif_lib_xmit_pkt(&priv->client, queue->queue_id,
222 (void *)(size_t)rte_pktmbuf_iova(tx_pkts[i]),
223 tx_pkts[i]->buf_addr + tx_pkts[i]->data_off,
224 tx_pkts[i]->pkt_len, 0 /*ctrl*/,
225 HIF_FIRST_BUFFER | HIF_LAST_BUFFER |
229 stats->obytes += tx_pkts[i]->pkt_len;
232 stats->opackets += nb_pkts;
233 pfe_tx_do_cleanup(priv->pfe);
239 pfe_dummy_xmit_pkts(__rte_unused void *tx_queue,
240 __rte_unused struct rte_mbuf **tx_pkts,
241 __rte_unused uint16_t nb_pkts)
247 pfe_dummy_recv_pkts(__rte_unused void *rxq,
248 __rte_unused struct rte_mbuf **rx_pkts,
249 __rte_unused uint16_t nb_pkts)
255 pfe_eth_open(struct rte_eth_dev *dev)
257 struct pfe_eth_priv_s *priv = dev->data->dev_private;
258 struct hif_client_s *client;
259 struct hif_shm *hif_shm;
262 /* Register client driver with HIF */
263 client = &priv->client;
266 hif_shm = client->pfe->hif.shm;
267 /* TODO please remove the below code of if block, once we add
268 * the proper cleanup in eth_close
270 if (!test_bit(PFE_CL_GEM0 + priv->id,
271 &hif_shm->g_client_status[0])) {
272 /* Register client driver with HIF */
273 memset(client, 0, sizeof(*client));
274 client->id = PFE_CL_GEM0 + priv->id;
275 client->tx_qn = emac_txq_cnt;
276 client->rx_qn = EMAC_RXQ_CNT;
278 client->pfe = priv->pfe;
279 client->port_id = dev->data->port_id;
280 client->event_handler = pfe_eth_event_handler;
282 client->tx_qsize = EMAC_TXQ_DEPTH;
283 client->rx_qsize = EMAC_RXQ_DEPTH;
285 rc = hif_lib_client_register(client);
287 PFE_PMD_ERR("hif_lib_client_register(%d)"
288 " failed", client->id);
292 /* Freeing the packets if already exists */
294 struct rte_mbuf *rx_pkts[32];
295 /* TODO multiqueue support */
296 ret = hif_lib_receive_pkt(&client->rx_q[0],
297 hif_shm->pool, rx_pkts, 32);
300 for (i = 0; i < ret; i++)
301 rte_pktmbuf_free(rx_pkts[i]);
302 ret = hif_lib_receive_pkt(&client->rx_q[0],
308 /* Register client driver with HIF */
309 memset(client, 0, sizeof(*client));
310 client->id = PFE_CL_GEM0 + priv->id;
311 client->tx_qn = emac_txq_cnt;
312 client->rx_qn = EMAC_RXQ_CNT;
314 client->pfe = priv->pfe;
315 client->port_id = dev->data->port_id;
316 client->event_handler = pfe_eth_event_handler;
318 client->tx_qsize = EMAC_TXQ_DEPTH;
319 client->rx_qsize = EMAC_RXQ_DEPTH;
321 rc = hif_lib_client_register(client);
323 PFE_PMD_ERR("hif_lib_client_register(%d) failed",
328 rc = pfe_eth_start(priv);
329 dev->rx_pkt_burst = &pfe_recv_pkts;
330 dev->tx_pkt_burst = &pfe_xmit_pkts;
331 /* If no prefetch is configured. */
332 if (getenv("PFE_INTR_SUPPORT")) {
333 dev->rx_pkt_burst = &pfe_recv_pkts_on_intr;
334 PFE_PMD_INFO("PFE INTERRUPT Mode enabled");
343 pfe_eth_open_cdev(struct pfe_eth_priv_s *priv)
350 pfe_cdev_fd = open(PFE_CDEV_PATH, O_RDONLY);
351 if (pfe_cdev_fd < 0) {
352 PFE_PMD_WARN("Unable to open PFE device file (%s).\n",
354 PFE_PMD_WARN("Link status update will not be available.\n");
355 priv->link_fd = PFE_CDEV_INVALID_FD;
359 priv->link_fd = pfe_cdev_fd;
365 pfe_eth_close_cdev(struct pfe_eth_priv_s *priv)
370 if (priv->link_fd != PFE_CDEV_INVALID_FD) {
371 close(priv->link_fd);
372 priv->link_fd = PFE_CDEV_INVALID_FD;
377 pfe_eth_stop(struct rte_eth_dev *dev/*, int wake*/)
379 struct pfe_eth_priv_s *priv = dev->data->dev_private;
381 gemac_disable(priv->EMAC_baseaddr);
382 gpi_disable(priv->GPI_baseaddr);
384 dev->rx_pkt_burst = &pfe_dummy_recv_pkts;
385 dev->tx_pkt_burst = &pfe_dummy_xmit_pkts;
389 pfe_eth_exit(struct rte_eth_dev *dev, struct pfe *pfe)
391 PMD_INIT_FUNC_TRACE();
394 /* Close the device file for link status */
395 pfe_eth_close_cdev(dev->data->dev_private);
397 rte_free(dev->data->mac_addrs);
398 rte_eth_dev_release_port(dev);
403 pfe_eth_close(struct rte_eth_dev *dev)
411 pfe_eth_exit(dev, g_pfe);
413 if (g_pfe->nb_devs == 0) {
415 pfe_hif_lib_exit(g_pfe);
422 pfe_eth_configure(struct rte_eth_dev *dev __rte_unused)
428 pfe_eth_info(struct rte_eth_dev *dev,
429 struct rte_eth_dev_info *dev_info)
431 struct pfe_eth_priv_s *internals = dev->data->dev_private;
433 dev_info->if_index = internals->id;
434 dev_info->max_mac_addrs = PFE_MAX_MACS;
435 dev_info->max_rx_queues = dev->data->nb_rx_queues;
436 dev_info->max_tx_queues = dev->data->nb_tx_queues;
437 dev_info->min_rx_bufsize = HIF_RX_PKT_MIN_SIZE;
438 dev_info->rx_offload_capa = dev_rx_offloads_sup;
439 dev_info->tx_offload_capa = dev_tx_offloads_sup;
440 if (pfe_svr == SVR_LS1012A_REV1)
441 dev_info->max_rx_pktlen = MAX_MTU_ON_REV1 + PFE_ETH_OVERHEAD;
443 dev_info->max_rx_pktlen = JUMBO_FRAME_SIZE;
448 /* Only first mb_pool given on first call of this API will be used
449 * in whole system, also nb_rx_desc and rx_conf are unused params
452 pfe_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
453 __rte_unused uint16_t nb_rx_desc,
454 __rte_unused unsigned int socket_id,
455 __rte_unused const struct rte_eth_rxconf *rx_conf,
456 struct rte_mempool *mb_pool)
460 struct pfe_eth_priv_s *priv = dev->data->dev_private;
464 if (queue_idx >= EMAC_RXQ_CNT) {
465 PFE_PMD_ERR("Invalid queue idx = %d, Max queues = %d",
466 queue_idx, EMAC_RXQ_CNT);
470 if (!pfe->hif.setuped) {
471 rc = pfe_hif_shm_init(pfe->hif.shm, mb_pool);
473 PFE_PMD_ERR("Could not allocate buffer descriptors");
477 pfe->hif.shm->pool = mb_pool;
478 if (pfe_hif_init_buffers(&pfe->hif)) {
479 PFE_PMD_ERR("Could not initialize buffer descriptors");
485 pfe->hif.setuped = 1;
487 dev->data->rx_queues[queue_idx] = &priv->client.rx_q[queue_idx];
488 priv->client.rx_q[queue_idx].queue_id = queue_idx;
494 pfe_rx_queue_release(void *q __rte_unused)
496 PMD_INIT_FUNC_TRACE();
500 pfe_tx_queue_release(void *q __rte_unused)
502 PMD_INIT_FUNC_TRACE();
506 pfe_tx_queue_setup(struct rte_eth_dev *dev,
508 __rte_unused uint16_t nb_desc,
509 __rte_unused unsigned int socket_id,
510 __rte_unused const struct rte_eth_txconf *tx_conf)
512 struct pfe_eth_priv_s *priv = dev->data->dev_private;
514 if (queue_idx >= emac_txq_cnt) {
515 PFE_PMD_ERR("Invalid queue idx = %d, Max queues = %d",
516 queue_idx, emac_txq_cnt);
519 dev->data->tx_queues[queue_idx] = &priv->client.tx_q[queue_idx];
520 priv->client.tx_q[queue_idx].queue_id = queue_idx;
524 static const struct eth_dev_ops ops = {
525 .dev_start = pfe_eth_open,
526 .dev_stop = pfe_eth_stop,
527 .dev_close = pfe_eth_close,
528 .dev_configure = pfe_eth_configure,
529 .dev_infos_get = pfe_eth_info,
530 .rx_queue_setup = pfe_rx_queue_setup,
531 .rx_queue_release = pfe_rx_queue_release,
532 .tx_queue_setup = pfe_tx_queue_setup,
533 .tx_queue_release = pfe_tx_queue_release,
537 pfe_eth_init(struct rte_vdev_device *vdev, struct pfe *pfe, int id)
539 struct rte_eth_dev *eth_dev = NULL;
540 struct pfe_eth_priv_s *priv = NULL;
541 struct ls1012a_eth_platform_data *einfo;
542 struct ls1012a_pfe_platform_data *pfe_info;
545 eth_dev = rte_eth_vdev_allocate(vdev, sizeof(*priv));
549 /* Extract pltform data */
550 pfe_info = (struct ls1012a_pfe_platform_data *)&pfe->platform_data;
552 PFE_PMD_ERR("pfe missing additional platform data");
557 einfo = (struct ls1012a_eth_platform_data *)pfe_info->ls1012a_eth_pdata;
559 /* einfo never be NULL, but no harm in having this check */
561 PFE_PMD_ERR("pfe missing additional gemacs platform data");
566 priv = eth_dev->data->dev_private;
567 priv->ndev = eth_dev;
568 priv->id = einfo[id].gem_id;
571 pfe->eth.eth_priv[id] = priv;
573 /* Set the info in the priv to the current info */
574 priv->einfo = &einfo[id];
575 priv->EMAC_baseaddr = cbus_emac_base[id];
576 priv->PHY_baseaddr = cbus_emac_base[id];
577 priv->GPI_baseaddr = cbus_gpi_base[id];
579 #define HIF_GEMAC_TMUQ_BASE 6
580 priv->low_tmu_q = HIF_GEMAC_TMUQ_BASE + (id * 2);
581 priv->high_tmu_q = priv->low_tmu_q + 1;
583 rte_spinlock_init(&priv->lock);
585 /* Copy the station address into the dev structure, */
586 eth_dev->data->mac_addrs = rte_zmalloc("mac_addr",
587 ETHER_ADDR_LEN * PFE_MAX_MACS, 0);
588 if (eth_dev->data->mac_addrs == NULL) {
589 PFE_PMD_ERR("Failed to allocate mem %d to store MAC addresses",
590 ETHER_ADDR_LEN * PFE_MAX_MACS);
595 eth_dev->data->mtu = 1500;
596 eth_dev->dev_ops = &ops;
597 pfe_eth_stop(eth_dev);
598 pfe_gemac_init(priv);
600 eth_dev->data->nb_rx_queues = 1;
601 eth_dev->data->nb_tx_queues = 1;
603 /* For link status, open the PFE CDEV; Error from this function
604 * is silently ignored; In case of error, the link status will not
607 pfe_eth_open_cdev(priv);
608 rte_eth_dev_probing_finish(eth_dev);
612 rte_eth_dev_release_port(eth_dev);
617 pfe_get_gemac_if_proprties(struct pfe *pfe,
618 __rte_unused const struct device_node *parent,
619 unsigned int port, unsigned int if_cnt,
620 struct ls1012a_pfe_platform_data *pdata)
622 const struct device_node *gem = NULL;
624 unsigned int ii = 0, phy_id = 0;
626 const void *mac_addr;
628 for (ii = 0; ii < if_cnt; ii++) {
629 gem = of_get_next_child(parent, gem);
632 addr = of_get_property(gem, "reg", &size);
633 if (addr && (rte_be_to_cpu_32((unsigned int)*addr) == port))
638 PFE_PMD_ERR("Failed to find interface = %d", if_cnt);
642 pdata->ls1012a_eth_pdata[port].gem_id = port;
644 mac_addr = of_get_mac_address(gem);
647 memcpy(pdata->ls1012a_eth_pdata[port].mac_addr, mac_addr,
651 addr = of_get_property(gem, "fsl,mdio-mux-val", &size);
653 PFE_PMD_ERR("Invalid mdio-mux-val....");
655 phy_id = rte_be_to_cpu_32((unsigned int)*addr);
656 pdata->ls1012a_eth_pdata[port].mdio_muxval = phy_id;
658 if (pdata->ls1012a_eth_pdata[port].phy_id < 32)
659 pfe->mdio_muxval[pdata->ls1012a_eth_pdata[port].phy_id] =
660 pdata->ls1012a_eth_pdata[port].mdio_muxval;
668 /* Parse integer from integer argument */
670 parse_integer_arg(const char *key __rte_unused,
671 const char *value, void *extra_args)
677 i = strtol(value, &end, 10);
678 if (*end != 0 || errno != 0 || i < 0 || i > 1) {
679 PFE_PMD_ERR("Supported Port IDS are 0 and 1");
683 *((uint32_t *)extra_args) = i;
689 pfe_parse_vdev_init_params(struct pfe_vdev_init_params *params,
690 struct rte_vdev_device *dev)
692 struct rte_kvargs *kvlist = NULL;
695 static const char * const pfe_vdev_valid_params[] = {
700 const char *input_args = rte_vdev_device_args(dev);
705 kvlist = rte_kvargs_parse(input_args, pfe_vdev_valid_params);
709 ret = rte_kvargs_process(kvlist,
713 rte_kvargs_free(kvlist);
718 pmd_pfe_probe(struct rte_vdev_device *vdev)
721 const struct device_node *np;
723 const uint32_t *addr;
724 uint64_t cbus_addr, ddr_size, cbus_size;
725 int rc = -1, fd = -1, gem_id;
726 unsigned int ii, interface_count = 0;
728 struct pfe_vdev_init_params init_params = {
732 name = rte_vdev_device_name(vdev);
733 rc = pfe_parse_vdev_init_params(&init_params, vdev);
737 RTE_LOG(INFO, PMD, "Initializing pmd_pfe for %s Given gem-id %d\n",
738 name, init_params.gem_id);
741 if (g_pfe->nb_devs >= g_pfe->max_intf) {
742 PFE_PMD_ERR("PFE %d dev already created Max is %d",
743 g_pfe->nb_devs, g_pfe->max_intf);
749 g_pfe = rte_zmalloc(NULL, sizeof(*g_pfe), RTE_CACHE_LINE_SIZE);
753 /* Load the device-tree driver */
756 PFE_PMD_ERR("of_init failed with ret: %d", rc);
760 np = of_find_compatible_node(NULL, NULL, "fsl,pfe");
762 PFE_PMD_ERR("Invalid device node");
767 addr = of_get_address(np, 0, &cbus_size, NULL);
769 PFE_PMD_ERR("of_get_address cannot return qman address\n");
772 cbus_addr = of_translate_address(np, addr);
774 PFE_PMD_ERR("of_translate_address failed\n");
778 addr = of_get_address(np, 1, &ddr_size, NULL);
780 PFE_PMD_ERR("of_get_address cannot return qman address\n");
784 g_pfe->ddr_phys_baseaddr = of_translate_address(np, addr);
785 if (!g_pfe->ddr_phys_baseaddr) {
786 PFE_PMD_ERR("of_translate_address failed\n");
790 g_pfe->ddr_baseaddr = pfe_mem_ptov(g_pfe->ddr_phys_baseaddr);
791 g_pfe->ddr_size = ddr_size;
792 g_pfe->cbus_size = cbus_size;
794 fd = open("/dev/mem", O_RDWR);
795 g_pfe->cbus_baseaddr = mmap(NULL, cbus_size, PROT_READ | PROT_WRITE,
796 MAP_SHARED, fd, cbus_addr);
798 if (g_pfe->cbus_baseaddr == MAP_FAILED) {
799 PFE_PMD_ERR("Can not map cbus base");
804 /* Read interface count */
805 prop = of_get_property(np, "fsl,pfe-num-interfaces", &size);
807 PFE_PMD_ERR("Failed to read number of interfaces");
812 interface_count = rte_be_to_cpu_32((unsigned int)*prop);
813 if (interface_count <= 0) {
814 PFE_PMD_ERR("No ethernet interface count : %d",
819 PFE_PMD_INFO("num interfaces = %d ", interface_count);
821 g_pfe->max_intf = interface_count;
822 g_pfe->platform_data.ls1012a_mdio_pdata[0].phy_mask = 0xffffffff;
824 for (ii = 0; ii < interface_count; ii++) {
825 pfe_get_gemac_if_proprties(g_pfe, np, ii, interface_count,
826 &g_pfe->platform_data);
829 pfe_lib_init(g_pfe->cbus_baseaddr, g_pfe->ddr_baseaddr,
830 g_pfe->ddr_phys_baseaddr, g_pfe->ddr_size);
832 PFE_PMD_INFO("CLASS version: %x", readl(CLASS_VERSION));
833 PFE_PMD_INFO("TMU version: %x", readl(TMU_VERSION));
835 PFE_PMD_INFO("BMU1 version: %x", readl(BMU1_BASE_ADDR + BMU_VERSION));
836 PFE_PMD_INFO("BMU2 version: %x", readl(BMU2_BASE_ADDR + BMU_VERSION));
838 PFE_PMD_INFO("EGPI1 version: %x", readl(EGPI1_BASE_ADDR + GPI_VERSION));
839 PFE_PMD_INFO("EGPI2 version: %x", readl(EGPI2_BASE_ADDR + GPI_VERSION));
840 PFE_PMD_INFO("HGPI version: %x", readl(HGPI_BASE_ADDR + GPI_VERSION));
842 PFE_PMD_INFO("HIF version: %x", readl(HIF_VERSION));
843 PFE_PMD_INFO("HIF NOPCY version: %x", readl(HIF_NOCPY_VERSION));
845 cbus_emac_base[0] = EMAC1_BASE_ADDR;
846 cbus_emac_base[1] = EMAC2_BASE_ADDR;
848 cbus_gpi_base[0] = EGPI1_BASE_ADDR;
849 cbus_gpi_base[1] = EGPI2_BASE_ADDR;
851 rc = pfe_hif_lib_init(g_pfe);
855 rc = pfe_hif_init(g_pfe);
858 pfe_soc_version_get();
860 if (init_params.gem_id < 0)
861 gem_id = g_pfe->nb_devs;
863 gem_id = init_params.gem_id;
865 RTE_LOG(INFO, PMD, "Init pmd_pfe for %s gem-id %d(given =%d)\n",
866 name, gem_id, init_params.gem_id);
868 rc = pfe_eth_init(vdev, g_pfe, gem_id);
880 pfe_hif_lib_exit(g_pfe);
884 munmap(g_pfe->cbus_baseaddr, cbus_size);
891 pmd_pfe_remove(struct rte_vdev_device *vdev)
894 struct rte_eth_dev *eth_dev = NULL;
896 name = rte_vdev_device_name(vdev);
900 PFE_PMD_INFO("Closing eventdev sw device %s", name);
905 eth_dev = rte_eth_dev_allocated(name);
909 pfe_eth_exit(eth_dev, g_pfe);
910 munmap(g_pfe->cbus_baseaddr, g_pfe->cbus_size);
912 if (g_pfe->nb_devs == 0) {
914 pfe_hif_lib_exit(g_pfe);
922 struct rte_vdev_driver pmd_pfe_drv = {
923 .probe = pmd_pfe_probe,
924 .remove = pmd_pfe_remove,
927 RTE_PMD_REGISTER_VDEV(PFE_NAME_PMD, pmd_pfe_drv);
928 RTE_PMD_REGISTER_PARAM_STRING(PFE_NAME_PMD, PFE_VDEV_GEM_ID_ARG "=<int> ");
930 RTE_INIT(pfe_pmd_init_log)
932 pfe_logtype_pmd = rte_log_register("pmd.net.pfe");
933 if (pfe_logtype_pmd >= 0)
934 rte_log_set_level(pfe_logtype_pmd, RTE_LOG_NOTICE);