Lines Matching defs:wx

582 		ethertype = ring->q_vector->wx->tpid[idx];
708 unsigned int budget = q_vector->wx->tx_work_limit;
835 struct wx *wx = q_vector->wx;
870 if (netif_running(wx->netdev))
871 wx_intr_enable(wx, WX_INTR_Q(q_vector->v_idx));
1515 struct wx *wx = netdev_priv(netdev);
1529 if (r_idx >= wx->num_tx_queues)
1530 r_idx = r_idx % wx->num_tx_queues;
1531 tx_ring = wx->tx_ring[r_idx];
1537 void wx_napi_enable_all(struct wx *wx)
1542 for (q_idx = 0; q_idx < wx->num_q_vectors; q_idx++) {
1543 q_vector = wx->q_vector[q_idx];
1549 void wx_napi_disable_all(struct wx *wx)
1554 for (q_idx = 0; q_idx < wx->num_q_vectors; q_idx++) {
1555 q_vector = wx->q_vector[q_idx];
1563 * @wx: board private structure to initialize
1569 static void wx_set_rss_queues(struct wx *wx)
1574 f = &wx->ring_feature[RING_F_RSS];
1577 wx->num_rx_queues = f->limit;
1578 wx->num_tx_queues = f->limit;
1581 static void wx_set_num_queues(struct wx *wx)
1584 wx->num_rx_queues = 1;
1585 wx->num_tx_queues = 1;
1586 wx->queues_per_pool = 1;
1588 wx_set_rss_queues(wx);
1593 * @wx: board private structure
1599 static int wx_acquire_msix_vectors(struct wx *wx)
1605 nvecs = max(wx->num_rx_queues, wx->num_tx_queues);
1607 nvecs = min_t(int, nvecs, wx->mac.max_msix_vectors);
1609 wx->msix_q_entries = kcalloc(nvecs, sizeof(struct msix_entry),
1611 if (!wx->msix_q_entries)
1617 wx->msix_entry = kcalloc(1, sizeof(struct msix_entry),
1619 if (!wx->msix_entry) {
1620 kfree(wx->msix_q_entries);
1621 wx->msix_q_entries = NULL;
1625 nvecs = pci_alloc_irq_vectors_affinity(wx->pdev, nvecs,
1630 wx_err(wx, "Failed to allocate MSI-X interrupts. Err: %d\n", nvecs);
1631 kfree(wx->msix_q_entries);
1632 wx->msix_q_entries = NULL;
1633 kfree(wx->msix_entry);
1634 wx->msix_entry = NULL;
1638 wx->msix_entry->entry = 0;
1639 wx->msix_entry->vector = pci_irq_vector(wx->pdev, 0);
1642 wx->msix_q_entries[i].entry = i;
1643 wx->msix_q_entries[i].vector = pci_irq_vector(wx->pdev, i + 1);
1646 wx->num_q_vectors = nvecs;
1653 * @wx: board private structure to initialize
1658 static int wx_set_interrupt_capability(struct wx *wx)
1660 struct pci_dev *pdev = wx->pdev;
1664 ret = wx_acquire_msix_vectors(wx);
1669 dev_warn(&wx->pdev->dev, "Disabling RSS support\n");
1670 wx->ring_feature[RING_F_RSS].limit = 1;
1672 wx_set_num_queues(wx);
1680 wx_err(wx, "Fallback to MSI.\n");
1682 wx_err(wx, "Fallback to LEGACY.\n");
1684 wx_err(wx, "Failed to allocate MSI/LEGACY interrupts. Error: %d\n", nvecs);
1695 * @wx: board private structure to initialize
1700 static void wx_cache_ring_rss(struct wx *wx)
1704 for (i = 0; i < wx->num_rx_queues; i++)
1705 wx->rx_ring[i]->reg_idx = i;
1707 for (i = 0; i < wx->num_tx_queues; i++)
1708 wx->tx_ring[i]->reg_idx = i;
1720 * @wx: board private structure to initialize
1721 * @v_count: q_vectors allocated on wx, used for ring interleaving
1722 * @v_idx: index of vector in wx struct
1730 static int wx_alloc_q_vector(struct wx *wx,
1748 netif_napi_add(wx->netdev, &q_vector->napi,
1751 /* tie q_vector and wx together */
1752 wx->q_vector[v_idx] = q_vector;
1753 q_vector->wx = wx;
1761 if (wx->mac.type == wx_mac_sp)
1768 q_vector->itr = wx->tx_itr_setting ?
1769 default_itr : wx->tx_itr_setting;
1772 q_vector->itr = wx->rx_itr_setting ?
1773 default_itr : wx->rx_itr_setting;
1777 ring->dev = &wx->pdev->dev;
1778 ring->netdev = wx->netdev;
1787 ring->count = wx->tx_ring_count;
1791 /* assign ring to wx */
1792 wx->tx_ring[txr_idx] = ring;
1804 ring->dev = &wx->pdev->dev;
1805 ring->netdev = wx->netdev;
1814 ring->count = wx->rx_ring_count;
1817 /* assign ring to wx */
1818 wx->rx_ring[rxr_idx] = ring;
1833 * @wx: board private structure to initialize
1840 static void wx_free_q_vector(struct wx *wx, int v_idx)
1842 struct wx_q_vector *q_vector = wx->q_vector[v_idx];
1846 wx->tx_ring[ring->queue_index] = NULL;
1849 wx->rx_ring[ring->queue_index] = NULL;
1851 wx->q_vector[v_idx] = NULL;
1858 * @wx: board private structure to initialize
1863 static int wx_alloc_q_vectors(struct wx *wx)
1866 unsigned int rxr_remaining = wx->num_rx_queues;
1867 unsigned int txr_remaining = wx->num_tx_queues;
1868 unsigned int q_vectors = wx->num_q_vectors;
1875 err = wx_alloc_q_vector(wx, q_vectors, v_idx,
1892 wx->num_tx_queues = 0;
1893 wx->num_rx_queues = 0;
1894 wx->num_q_vectors = 0;
1897 wx_free_q_vector(wx, v_idx);
1904 * @wx: board private structure to initialize
1910 static void wx_free_q_vectors(struct wx *wx)
1912 int v_idx = wx->num_q_vectors;
1914 wx->num_tx_queues = 0;
1915 wx->num_rx_queues = 0;
1916 wx->num_q_vectors = 0;
1919 wx_free_q_vector(wx, v_idx);
1922 void wx_reset_interrupt_capability(struct wx *wx)
1924 struct pci_dev *pdev = wx->pdev;
1930 kfree(wx->msix_q_entries);
1931 wx->msix_q_entries = NULL;
1932 kfree(wx->msix_entry);
1933 wx->msix_entry = NULL;
1935 pci_free_irq_vectors(wx->pdev);
1941 * @wx: board private structure to clear interrupt scheme on
1946 void wx_clear_interrupt_scheme(struct wx *wx)
1948 wx_free_q_vectors(wx);
1949 wx_reset_interrupt_capability(wx);
1953 int wx_init_interrupt_scheme(struct wx *wx)
1958 wx_set_num_queues(wx);
1961 ret = wx_set_interrupt_capability(wx);
1963 wx_err(wx, "Allocate irq vectors for failed.\n");
1968 ret = wx_alloc_q_vectors(wx);
1970 wx_err(wx, "Unable to allocate memory for queue vectors.\n");
1971 wx_reset_interrupt_capability(wx);
1975 wx_cache_ring_rss(wx);
1993 void wx_free_irq(struct wx *wx)
1995 struct pci_dev *pdev = wx->pdev;
1999 free_irq(pdev->irq, wx);
2003 for (vector = 0; vector < wx->num_q_vectors; vector++) {
2004 struct wx_q_vector *q_vector = wx->q_vector[vector];
2005 struct msix_entry *entry = &wx->msix_q_entries[vector];
2014 if (wx->mac.type == wx_mac_em)
2015 free_irq(wx->msix_entry->vector, wx);
2021 * @wx: board private structure
2025 int wx_setup_isb_resources(struct wx *wx)
2027 struct pci_dev *pdev = wx->pdev;
2029 wx->isb_mem = dma_alloc_coherent(&pdev->dev,
2031 &wx->isb_dma,
2033 if (!wx->isb_mem) {
2034 wx_err(wx, "Alloc isb_mem failed\n");
2044 * @wx: board private structure
2048 void wx_free_isb_resources(struct wx *wx)
2050 struct pci_dev *pdev = wx->pdev;
2053 wx->isb_mem, wx->isb_dma);
2054 wx->isb_mem = NULL;
2058 u32 wx_misc_isb(struct wx *wx, enum wx_isb_idx idx)
2062 cur_tag = wx->isb_mem[WX_ISB_HEADER];
2063 wx->isb_tag[idx] = cur_tag;
2065 return (__force u32)cpu_to_le32(wx->isb_mem[idx]);
2071 * @wx: pointer to wx struct
2077 static void wx_set_ivar(struct wx *wx, s8 direction,
2086 ivar = rd32(wx, WX_PX_MISC_IVAR);
2089 wr32(wx, WX_PX_MISC_IVAR, ivar);
2095 ivar = rd32(wx, WX_PX_IVAR(queue >> 1));
2098 wr32(wx, WX_PX_IVAR(queue >> 1), ivar);
2112 struct wx *wx = q_vector->wx;
2116 if (wx->mac.type == wx_mac_sp)
2123 wr32(wx, WX_PX_ITR(v_idx + 1), itr_reg);
2128 * @wx: board private structure
2133 void wx_configure_vectors(struct wx *wx)
2135 struct pci_dev *pdev = wx->pdev;
2141 wr32(wx, WX_PX_ITRSEL, eitrsel);
2145 wr32(wx, WX_PX_GPIE, WX_PX_GPIE_MODEL);
2150 wr32(wx, WX_PX_GPIE, 0);
2156 for (v_idx = 0; v_idx < wx->num_q_vectors; v_idx++) {
2157 struct wx_q_vector *q_vector = wx->q_vector[v_idx];
2161 wx_set_ivar(wx, 0, ring->reg_idx, v_idx);
2164 wx_set_ivar(wx, 1, ring->reg_idx, v_idx);
2169 wx_set_ivar(wx, -1, 0, 0);
2171 wr32(wx, WX_PX_ITR(0), 1950);
2224 * @wx: board private structure
2226 void wx_clean_all_rx_rings(struct wx *wx)
2230 for (i = 0; i < wx->num_rx_queues; i++)
2231 wx_clean_rx_ring(wx->rx_ring[i]);
2264 * @wx: pointer to hardware structure
2268 static void wx_free_all_rx_resources(struct wx *wx)
2272 for (i = 0; i < wx->num_rx_queues; i++)
2273 wx_free_rx_resources(wx->rx_ring[i]);
2340 * @wx: board private structure
2342 void wx_clean_all_tx_rings(struct wx *wx)
2346 for (i = 0; i < wx->num_tx_queues; i++)
2347 wx_clean_tx_ring(wx->tx_ring[i]);
2374 * @wx: pointer to hardware structure
2378 static void wx_free_all_tx_resources(struct wx *wx)
2382 for (i = 0; i < wx->num_tx_queues; i++)
2383 wx_free_tx_resources(wx->tx_ring[i]);
2386 void wx_free_resources(struct wx *wx)
2388 wx_free_isb_resources(wx);
2389 wx_free_all_rx_resources(wx);
2390 wx_free_all_tx_resources(wx);
2480 * @wx: pointer to hardware structure
2488 static int wx_setup_all_rx_resources(struct wx *wx)
2492 for (i = 0; i < wx->num_rx_queues; i++) {
2493 err = wx_setup_rx_resources(wx->rx_ring[i]);
2497 wx_err(wx, "Allocation for Rx Queue %u failed\n", i);
2505 wx_free_rx_resources(wx->rx_ring[i]);
2563 * @wx: pointer to private structure
2571 static int wx_setup_all_tx_resources(struct wx *wx)
2575 for (i = 0; i < wx->num_tx_queues; i++) {
2576 err = wx_setup_tx_resources(wx->tx_ring[i]);
2580 wx_err(wx, "Allocation for Tx Queue %u failed\n", i);
2588 wx_free_tx_resources(wx->tx_ring[i]);
2592 int wx_setup_resources(struct wx *wx)
2597 err = wx_setup_all_tx_resources(wx);
2602 err = wx_setup_all_rx_resources(wx);
2606 err = wx_setup_isb_resources(wx);
2613 wx_free_all_rx_resources(wx);
2615 wx_free_all_tx_resources(wx);
2629 struct wx *wx = netdev_priv(netdev);
2633 wx_update_stats(wx);
2636 for (i = 0; i < wx->num_rx_queues; i++) {
2637 struct wx_ring *ring = READ_ONCE(wx->rx_ring[i]);
2652 for (i = 0; i < wx->num_tx_queues; i++) {
2653 struct wx_ring *ring = READ_ONCE(wx->tx_ring[i]);
2671 hwstats = &wx->stats;
2682 struct wx *wx = netdev_priv(netdev);
2685 wr32m(wx, WX_RDB_RA_CTL, WX_RDB_RA_CTL_RSS_EN,
2687 wx->rss_enabled = true;
2689 wr32m(wx, WX_RDB_RA_CTL, WX_RDB_RA_CTL_RSS_EN, 0);
2690 wx->rss_enabled = false;
2702 void wx_set_ring(struct wx *wx, u32 new_tx_count,
2712 if (new_tx_count != wx->tx_ring_count) {
2713 for (i = 0; i < wx->num_tx_queues; i++) {
2714 memcpy(&temp_ring[i], wx->tx_ring[i],
2720 wx_err(wx, "setup new tx resources failed, keep using the old config\n");
2729 for (i = 0; i < wx->num_tx_queues; i++) {
2730 wx_free_tx_resources(wx->tx_ring[i]);
2732 memcpy(wx->tx_ring[i], &temp_ring[i],
2736 wx->tx_ring_count = new_tx_count;
2740 if (new_rx_count != wx->rx_ring_count) {
2741 for (i = 0; i < wx->num_rx_queues; i++) {
2742 memcpy(&temp_ring[i], wx->rx_ring[i],
2748 wx_err(wx, "setup new rx resources failed, keep using the old config\n");
2757 for (i = 0; i < wx->num_rx_queues; i++) {
2758 wx_free_rx_resources(wx->rx_ring[i]);
2759 memcpy(wx->rx_ring[i], &temp_ring[i],
2763 wx->rx_ring_count = new_rx_count;