* pfe_hif_init * This function initializes the baseaddresses and irq, etc. */
| 781 | * This function initializes the baseaddresses and irq, etc. |
| 782 | */ |
| 783 | int |
| 784 | pfe_hif_init(struct pfe *pfe) |
| 785 | { |
| 786 | struct pfe_hif *hif = &pfe->hif; |
| 787 | int err; |
| 788 | |
| 789 | PMD_INIT_FUNC_TRACE(); |
| 790 | |
| 791 | #if defined(LS1012A_PFE_RESET_WA) |
| 792 | pfe_hif_rx_idle(hif); |
| 793 | #endif |
| 794 | |
| 795 | err = pfe_hif_alloc_descr(hif); |
| 796 | if (err) |
| 797 | goto err0; |
| 798 | |
| 799 | rte_spinlock_init(&hif->tx_lock); |
| 800 | rte_spinlock_init(&hif->lock); |
| 801 | |
| 802 | gpi_enable(HGPI_BASE_ADDR); |
| 803 | if (getenv("PFE_INTR_SUPPORT")) { |
| 804 | struct epoll_event epoll_ev; |
| 805 | int event_fd = -1, epoll_fd, pfe_cdev_fd; |
| 806 | |
| 807 | pfe_cdev_fd = open(PFE_CDEV_PATH, O_RDWR); |
| 808 | if (pfe_cdev_fd < 0) { |
| 809 | PFE_PMD_WARN("Unable to open PFE device file (%s).", |
| 810 | PFE_CDEV_PATH); |
| 811 | pfe->cdev_fd = PFE_CDEV_INVALID_FD; |
| 812 | return -1; |
| 813 | } |
| 814 | pfe->cdev_fd = pfe_cdev_fd; |
| 815 | |
| 816 | event_fd = eventfd(0, EFD_NONBLOCK); |
| 817 | /* hif interrupt enable */ |
| 818 | err = ioctl(pfe->cdev_fd, PFE_CDEV_HIF_INTR_EN, &event_fd); |
| 819 | if (err) { |
| 820 | PFE_PMD_ERR("ioctl failed for intr enable err: %d", |
| 821 | errno); |
| 822 | goto err0; |
| 823 | } |
| 824 | epoll_fd = epoll_create(1); |
| 825 | epoll_ev.events = EPOLLIN | EPOLLPRI | EPOLLET; |
| 826 | epoll_ev.data.fd = event_fd; |
| 827 | err = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, event_fd, &epoll_ev); |
| 828 | if (err < 0) { |
| 829 | PFE_PMD_ERR("epoll_ctl failed with err = %d", errno); |
| 830 | goto err0; |
| 831 | } |
| 832 | pfe->hif.epoll_fd = epoll_fd; |
| 833 | } |
| 834 | return 0; |
| 835 | err0: |
| 836 | return err; |
| 837 | } |
| 838 | |
| 839 | /* pfe_hif_exit- */ |
| 840 | void |
no test coverage detected