Lines Matching refs:txq
132 #define MVNETA_CPU_TXQ_ACCESS(txq) BIT(txq + 8) argument
337 #define IS_TSO_HEADER(txq, addr) \ argument
338 ((addr >= txq->tso_hdrs_phys) && \
339 (addr < txq->tso_hdrs_phys + txq->size * TSO_HEADER_SIZE))
737 static void mvneta_txq_inc_get(struct mvneta_tx_queue *txq) in mvneta_txq_inc_get() argument
739 txq->txq_get_index++; in mvneta_txq_inc_get()
740 if (txq->txq_get_index == txq->size) in mvneta_txq_inc_get()
741 txq->txq_get_index = 0; in mvneta_txq_inc_get()
745 static void mvneta_txq_inc_put(struct mvneta_tx_queue *txq) in mvneta_txq_inc_put() argument
747 txq->txq_put_index++; in mvneta_txq_inc_put()
748 if (txq->txq_put_index == txq->size) in mvneta_txq_inc_put()
749 txq->txq_put_index = 0; in mvneta_txq_inc_put()
927 struct mvneta_tx_queue *txq, in mvneta_txq_pend_desc_add() argument
932 pend_desc += txq->pending; in mvneta_txq_pend_desc_add()
937 mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val); in mvneta_txq_pend_desc_add()
940 txq->pending = 0; in mvneta_txq_pend_desc_add()
945 mvneta_txq_next_desc_get(struct mvneta_tx_queue *txq) in mvneta_txq_next_desc_get() argument
947 int tx_desc = txq->next_desc_to_proc; in mvneta_txq_next_desc_get()
949 txq->next_desc_to_proc = MVNETA_QUEUE_NEXT_DESC(txq, tx_desc); in mvneta_txq_next_desc_get()
950 return txq->descs + tx_desc; in mvneta_txq_next_desc_get()
956 static void mvneta_txq_desc_put(struct mvneta_tx_queue *txq) in mvneta_txq_desc_put() argument
958 if (txq->next_desc_to_proc == 0) in mvneta_txq_desc_put()
959 txq->next_desc_to_proc = txq->last_desc - 1; in mvneta_txq_desc_put()
961 txq->next_desc_to_proc--; in mvneta_txq_desc_put()
1223 struct mvneta_tx_queue *txq = &pp->txqs[queue]; in mvneta_port_up() local
1224 if (txq->descs) in mvneta_port_up()
1461 int rxq, txq; in mvneta_defaults_set() local
1467 for (txq = 0; txq < txq_number; txq++) in mvneta_defaults_set()
1468 if ((txq % max_cpu) == cpu) in mvneta_defaults_set()
1469 txq_map |= MVNETA_CPU_TXQ_ACCESS(txq); in mvneta_defaults_set()
1672 struct mvneta_tx_queue *txq, u32 value) in mvneta_tx_done_pkts_coal_set() argument
1676 val = mvreg_read(pp, MVNETA_TXQ_SIZE_REG(txq->id)); in mvneta_tx_done_pkts_coal_set()
1681 mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), val); in mvneta_tx_done_pkts_coal_set()
1698 struct mvneta_tx_queue *txq, in mvneta_txq_sent_desc_dec() argument
1706 mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val); in mvneta_txq_sent_desc_dec()
1711 mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val); in mvneta_txq_sent_desc_dec()
1716 struct mvneta_tx_queue *txq) in mvneta_txq_sent_desc_num_get() argument
1721 val = mvreg_read(pp, MVNETA_TXQ_STATUS_REG(txq->id)); in mvneta_txq_sent_desc_num_get()
1732 struct mvneta_tx_queue *txq) in mvneta_txq_sent_desc_proc() argument
1737 sent_desc = mvneta_txq_sent_desc_num_get(pp, txq); in mvneta_txq_sent_desc_proc()
1741 mvneta_txq_sent_desc_dec(pp, txq, sent_desc); in mvneta_txq_sent_desc_proc()
1832 struct mvneta_tx_queue *txq, int num, in mvneta_txq_bufs_free() argument
1844 struct mvneta_tx_buf *buf = &txq->buf[txq->txq_get_index]; in mvneta_txq_bufs_free()
1845 struct mvneta_tx_desc *tx_desc = txq->descs + in mvneta_txq_bufs_free()
1846 txq->txq_get_index; in mvneta_txq_bufs_free()
1848 mvneta_txq_inc_get(txq); in mvneta_txq_bufs_free()
1850 if (!IS_TSO_HEADER(txq, tx_desc->buf_phys_addr) && in mvneta_txq_bufs_free()
1876 struct mvneta_tx_queue *txq) in mvneta_txq_done() argument
1878 struct netdev_queue *nq = netdev_get_tx_queue(pp->dev, txq->id); in mvneta_txq_done()
1881 tx_done = mvneta_txq_sent_desc_proc(pp, txq); in mvneta_txq_done()
1885 mvneta_txq_bufs_free(pp, txq, tx_done, nq, true); in mvneta_txq_done()
1887 txq->count -= tx_done; in mvneta_txq_done()
1890 if (txq->count <= txq->tx_wake_threshold) in mvneta_txq_done()
2048 mvneta_xdp_submit_frame(struct mvneta_port *pp, struct mvneta_tx_queue *txq, in mvneta_xdp_submit_frame() argument
2055 if (txq->count >= txq->tx_stop_threshold) in mvneta_xdp_submit_frame()
2058 tx_desc = mvneta_txq_next_desc_get(txq); in mvneta_xdp_submit_frame()
2060 buf = &txq->buf[txq->txq_put_index]; in mvneta_xdp_submit_frame()
2066 mvneta_txq_desc_put(txq); in mvneta_xdp_submit_frame()
2085 mvneta_txq_inc_put(txq); in mvneta_xdp_submit_frame()
2086 txq->pending++; in mvneta_xdp_submit_frame()
2087 txq->count++; in mvneta_xdp_submit_frame()
2096 struct mvneta_tx_queue *txq; in mvneta_xdp_xmit_back() local
2107 txq = &pp->txqs[cpu % txq_number]; in mvneta_xdp_xmit_back()
2108 nq = netdev_get_tx_queue(pp->dev, txq->id); in mvneta_xdp_xmit_back()
2111 ret = mvneta_xdp_submit_frame(pp, txq, xdpf, false); in mvneta_xdp_xmit_back()
2119 mvneta_txq_pend_desc_add(pp, txq, 0); in mvneta_xdp_xmit_back()
2138 struct mvneta_tx_queue *txq; in mvneta_xdp_xmit() local
2148 txq = &pp->txqs[cpu % txq_number]; in mvneta_xdp_xmit()
2149 nq = netdev_get_tx_queue(pp->dev, txq->id); in mvneta_xdp_xmit()
2153 ret = mvneta_xdp_submit_frame(pp, txq, frames[i], true); in mvneta_xdp_xmit()
2162 mvneta_txq_pend_desc_add(pp, txq, 0); in mvneta_xdp_xmit()
2599 struct mvneta_port *pp, struct mvneta_tx_queue *txq) in mvneta_tso_put_hdr() argument
2602 struct mvneta_tx_buf *buf = &txq->buf[txq->txq_put_index]; in mvneta_tso_put_hdr()
2605 tx_desc = mvneta_txq_next_desc_get(txq); in mvneta_tso_put_hdr()
2609 tx_desc->buf_phys_addr = txq->tso_hdrs_phys + in mvneta_tso_put_hdr()
2610 txq->txq_put_index * TSO_HEADER_SIZE; in mvneta_tso_put_hdr()
2614 mvneta_txq_inc_put(txq); in mvneta_tso_put_hdr()
2618 mvneta_tso_put_data(struct net_device *dev, struct mvneta_tx_queue *txq, in mvneta_tso_put_data() argument
2622 struct mvneta_tx_buf *buf = &txq->buf[txq->txq_put_index]; in mvneta_tso_put_data()
2625 tx_desc = mvneta_txq_next_desc_get(txq); in mvneta_tso_put_data()
2631 mvneta_txq_desc_put(txq); in mvneta_tso_put_data()
2647 mvneta_txq_inc_put(txq); in mvneta_tso_put_data()
2652 struct mvneta_tx_queue *txq) in mvneta_tx_tso() argument
2661 if ((txq->count + tso_count_descs(skb)) >= txq->size) in mvneta_tx_tso()
2681 hdr = txq->tso_hdrs + txq->txq_put_index * TSO_HEADER_SIZE; in mvneta_tx_tso()
2684 mvneta_tso_put_hdr(skb, pp, txq); in mvneta_tx_tso()
2692 if (mvneta_tso_put_data(dev, txq, skb, in mvneta_tx_tso()
2710 struct mvneta_tx_desc *tx_desc = txq->descs + i; in mvneta_tx_tso()
2711 if (!IS_TSO_HEADER(txq, tx_desc->buf_phys_addr)) in mvneta_tx_tso()
2716 mvneta_txq_desc_put(txq); in mvneta_tx_tso()
2723 struct mvneta_tx_queue *txq) in mvneta_tx_frag_process() argument
2729 struct mvneta_tx_buf *buf = &txq->buf[txq->txq_put_index]; in mvneta_tx_frag_process()
2733 tx_desc = mvneta_txq_next_desc_get(txq); in mvneta_tx_frag_process()
2742 mvneta_txq_desc_put(txq); in mvneta_tx_frag_process()
2756 mvneta_txq_inc_put(txq); in mvneta_tx_frag_process()
2766 tx_desc = txq->descs + i; in mvneta_tx_frag_process()
2771 mvneta_txq_desc_put(txq); in mvneta_tx_frag_process()
2782 struct mvneta_tx_queue *txq = &pp->txqs[txq_id]; in mvneta_tx() local
2783 struct mvneta_tx_buf *buf = &txq->buf[txq->txq_put_index]; in mvneta_tx()
2793 frags = mvneta_tx_tso(skb, dev, txq); in mvneta_tx()
2800 tx_desc = mvneta_txq_next_desc_get(txq); in mvneta_tx()
2811 mvneta_txq_desc_put(txq); in mvneta_tx()
2822 mvneta_txq_inc_put(txq); in mvneta_tx()
2827 mvneta_txq_inc_put(txq); in mvneta_tx()
2830 if (mvneta_tx_frag_process(pp, skb, txq)) { in mvneta_tx()
2835 mvneta_txq_desc_put(txq); in mvneta_tx()
2848 txq->count += frags; in mvneta_tx()
2849 if (txq->count >= txq->tx_stop_threshold) in mvneta_tx()
2853 txq->pending + frags > MVNETA_TXQ_DEC_SENT_MASK) in mvneta_tx()
2854 mvneta_txq_pend_desc_add(pp, txq, frags); in mvneta_tx()
2856 txq->pending += frags; in mvneta_tx()
2873 struct mvneta_tx_queue *txq) in mvneta_txq_done_force() argument
2876 struct netdev_queue *nq = netdev_get_tx_queue(pp->dev, txq->id); in mvneta_txq_done_force()
2877 int tx_done = txq->count; in mvneta_txq_done_force()
2879 mvneta_txq_bufs_free(pp, txq, tx_done, nq, false); in mvneta_txq_done_force()
2882 txq->count = 0; in mvneta_txq_done_force()
2883 txq->txq_put_index = 0; in mvneta_txq_done_force()
2884 txq->txq_get_index = 0; in mvneta_txq_done_force()
2892 struct mvneta_tx_queue *txq; in mvneta_tx_done_gbe() local
2897 txq = mvneta_tx_done_policy(pp, cause_tx_done); in mvneta_tx_done_gbe()
2899 nq = netdev_get_tx_queue(pp->dev, txq->id); in mvneta_tx_done_gbe()
2902 if (txq->count) in mvneta_tx_done_gbe()
2903 mvneta_txq_done(pp, txq); in mvneta_tx_done_gbe()
2906 cause_tx_done &= ~((1 << txq->id)); in mvneta_tx_done_gbe()
3391 struct mvneta_tx_queue *txq) in mvneta_txq_sw_init() argument
3395 txq->size = pp->tx_ring_size; in mvneta_txq_sw_init()
3401 txq->tx_stop_threshold = txq->size - MVNETA_MAX_SKB_DESCS; in mvneta_txq_sw_init()
3402 txq->tx_wake_threshold = txq->tx_stop_threshold / 2; in mvneta_txq_sw_init()
3405 txq->descs = dma_alloc_coherent(pp->dev->dev.parent, in mvneta_txq_sw_init()
3406 txq->size * MVNETA_DESC_ALIGNED_SIZE, in mvneta_txq_sw_init()
3407 &txq->descs_phys, GFP_KERNEL); in mvneta_txq_sw_init()
3408 if (!txq->descs) in mvneta_txq_sw_init()
3411 txq->last_desc = txq->size - 1; in mvneta_txq_sw_init()
3413 txq->buf = kmalloc_array(txq->size, sizeof(*txq->buf), GFP_KERNEL); in mvneta_txq_sw_init()
3414 if (!txq->buf) in mvneta_txq_sw_init()
3418 txq->tso_hdrs = dma_alloc_coherent(pp->dev->dev.parent, in mvneta_txq_sw_init()
3419 txq->size * TSO_HEADER_SIZE, in mvneta_txq_sw_init()
3420 &txq->tso_hdrs_phys, GFP_KERNEL); in mvneta_txq_sw_init()
3421 if (!txq->tso_hdrs) in mvneta_txq_sw_init()
3428 cpu = txq->id % num_present_cpus(); in mvneta_txq_sw_init()
3431 cpumask_set_cpu(cpu, &txq->affinity_mask); in mvneta_txq_sw_init()
3432 netif_set_xps_queue(pp->dev, &txq->affinity_mask, txq->id); in mvneta_txq_sw_init()
3438 struct mvneta_tx_queue *txq) in mvneta_txq_hw_init() argument
3441 mvreg_write(pp, MVETH_TXQ_TOKEN_CFG_REG(txq->id), 0x03ffffff); in mvneta_txq_hw_init()
3442 mvreg_write(pp, MVETH_TXQ_TOKEN_COUNT_REG(txq->id), 0x3fffffff); in mvneta_txq_hw_init()
3445 mvreg_write(pp, MVNETA_TXQ_BASE_ADDR_REG(txq->id), txq->descs_phys); in mvneta_txq_hw_init()
3446 mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), txq->size); in mvneta_txq_hw_init()
3448 mvneta_tx_done_pkts_coal_set(pp, txq, txq->done_pkts_coal); in mvneta_txq_hw_init()
3453 struct mvneta_tx_queue *txq) in mvneta_txq_init() argument
3457 ret = mvneta_txq_sw_init(pp, txq); in mvneta_txq_init()
3461 mvneta_txq_hw_init(pp, txq); in mvneta_txq_init()
3468 struct mvneta_tx_queue *txq) in mvneta_txq_sw_deinit() argument
3470 struct netdev_queue *nq = netdev_get_tx_queue(pp->dev, txq->id); in mvneta_txq_sw_deinit()
3472 kfree(txq->buf); in mvneta_txq_sw_deinit()
3474 if (txq->tso_hdrs) in mvneta_txq_sw_deinit()
3476 txq->size * TSO_HEADER_SIZE, in mvneta_txq_sw_deinit()
3477 txq->tso_hdrs, txq->tso_hdrs_phys); in mvneta_txq_sw_deinit()
3478 if (txq->descs) in mvneta_txq_sw_deinit()
3480 txq->size * MVNETA_DESC_ALIGNED_SIZE, in mvneta_txq_sw_deinit()
3481 txq->descs, txq->descs_phys); in mvneta_txq_sw_deinit()
3485 txq->descs = NULL; in mvneta_txq_sw_deinit()
3486 txq->last_desc = 0; in mvneta_txq_sw_deinit()
3487 txq->next_desc_to_proc = 0; in mvneta_txq_sw_deinit()
3488 txq->descs_phys = 0; in mvneta_txq_sw_deinit()
3492 struct mvneta_tx_queue *txq) in mvneta_txq_hw_deinit() argument
3495 mvreg_write(pp, MVETH_TXQ_TOKEN_CFG_REG(txq->id), 0); in mvneta_txq_hw_deinit()
3496 mvreg_write(pp, MVETH_TXQ_TOKEN_COUNT_REG(txq->id), 0); in mvneta_txq_hw_deinit()
3499 mvreg_write(pp, MVNETA_TXQ_BASE_ADDR_REG(txq->id), 0); in mvneta_txq_hw_deinit()
3500 mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), 0); in mvneta_txq_hw_deinit()
3504 struct mvneta_tx_queue *txq) in mvneta_txq_deinit() argument
3506 mvneta_txq_sw_deinit(pp, txq); in mvneta_txq_deinit()
3507 mvneta_txq_hw_deinit(pp, txq); in mvneta_txq_deinit()
4521 struct mvneta_tx_queue *txq = &pp->txqs[queue]; in mvneta_ethtool_set_coalesce() local
4522 txq->done_pkts_coal = c->tx_max_coalesced_frames; in mvneta_ethtool_set_coalesce()
4523 mvneta_tx_done_pkts_coal_set(pp, txq, txq->done_pkts_coal); in mvneta_ethtool_set_coalesce()
5049 struct mvneta_tx_queue *txq = &pp->txqs[queue]; in mvneta_init() local
5050 txq->id = queue; in mvneta_init()
5051 txq->size = pp->tx_ring_size; in mvneta_init()
5052 txq->done_pkts_coal = MVNETA_TXDONE_COAL_PKTS; in mvneta_init()
5446 struct mvneta_tx_queue *txq = &pp->txqs[queue]; in mvneta_suspend() local
5448 mvneta_txq_hw_deinit(pp, txq); in mvneta_suspend()
5499 struct mvneta_tx_queue *txq = &pp->txqs[queue]; in mvneta_resume() local
5501 txq->next_desc_to_proc = 0; in mvneta_resume()
5502 mvneta_txq_hw_init(pp, txq); in mvneta_resume()