Lines Matching refs:tx_ring
474 nfp_net_tx_ring_init(struct nfp_net_tx_ring *tx_ring, in nfp_net_tx_ring_init() argument
479 tx_ring->idx = idx; in nfp_net_tx_ring_init()
480 tx_ring->r_vec = r_vec; in nfp_net_tx_ring_init()
482 tx_ring->qcidx = tx_ring->idx * nn->stride_tx; in nfp_net_tx_ring_init()
483 tx_ring->qcp_q = nn->tx_bar + NFP_QCP_QUEUE_OFF(tx_ring->qcidx); in nfp_net_tx_ring_init()
608 static inline int nfp_net_tx_full(struct nfp_net_tx_ring *tx_ring, int dcnt) in nfp_net_tx_full() argument
610 return (tx_ring->wr_p - tx_ring->rd_p) >= (tx_ring->cnt - dcnt); in nfp_net_tx_full()
614 static int nfp_net_tx_ring_should_wake(struct nfp_net_tx_ring *tx_ring) in nfp_net_tx_ring_should_wake() argument
616 return !nfp_net_tx_full(tx_ring, MAX_SKB_FRAGS * 4); in nfp_net_tx_ring_should_wake()
619 static int nfp_net_tx_ring_should_stop(struct nfp_net_tx_ring *tx_ring) in nfp_net_tx_ring_should_stop() argument
621 return nfp_net_tx_full(tx_ring, MAX_SKB_FRAGS + 1); in nfp_net_tx_ring_should_stop()
634 struct nfp_net_tx_ring *tx_ring) in nfp_net_tx_ring_stop() argument
640 if (unlikely(nfp_net_tx_ring_should_wake(tx_ring))) in nfp_net_tx_ring_stop()
762 struct nfp_net_tx_ring *tx_ring; in nfp_net_tx() local
771 tx_ring = &nn->tx_rings[qidx]; in nfp_net_tx()
772 r_vec = tx_ring->r_vec; in nfp_net_tx()
777 if (unlikely(nfp_net_tx_full(tx_ring, nr_frags + 1))) { in nfp_net_tx()
779 qidx, tx_ring->wr_p, tx_ring->rd_p); in nfp_net_tx()
793 wr_idx = tx_ring->wr_p % tx_ring->cnt; in nfp_net_tx()
796 txbuf = &tx_ring->txbufs[wr_idx]; in nfp_net_tx()
804 txd = &tx_ring->txds[wr_idx]; in nfp_net_tx()
837 wr_idx = (wr_idx + 1) % tx_ring->cnt; in nfp_net_tx()
838 tx_ring->txbufs[wr_idx].skb = skb; in nfp_net_tx()
839 tx_ring->txbufs[wr_idx].dma_addr = dma_addr; in nfp_net_tx()
840 tx_ring->txbufs[wr_idx].fidx = f; in nfp_net_tx()
842 txd = &tx_ring->txds[wr_idx]; in nfp_net_tx()
857 tx_ring->wr_p += nr_frags + 1; in nfp_net_tx()
858 if (nfp_net_tx_ring_should_stop(tx_ring)) in nfp_net_tx()
859 nfp_net_tx_ring_stop(nd_q, tx_ring); in nfp_net_tx()
861 tx_ring->wr_ptr_add += nr_frags + 1; in nfp_net_tx()
865 nfp_qcp_wr_ptr_add(tx_ring->qcp_q, tx_ring->wr_ptr_add); in nfp_net_tx()
866 tx_ring->wr_ptr_add = 0; in nfp_net_tx()
877 tx_ring->txbufs[wr_idx].dma_addr, in nfp_net_tx()
879 tx_ring->txbufs[wr_idx].skb = NULL; in nfp_net_tx()
880 tx_ring->txbufs[wr_idx].dma_addr = 0; in nfp_net_tx()
881 tx_ring->txbufs[wr_idx].fidx = -2; in nfp_net_tx()
884 wr_idx += tx_ring->cnt; in nfp_net_tx()
886 dma_unmap_single(&nn->pdev->dev, tx_ring->txbufs[wr_idx].dma_addr, in nfp_net_tx()
888 tx_ring->txbufs[wr_idx].skb = NULL; in nfp_net_tx()
889 tx_ring->txbufs[wr_idx].dma_addr = 0; in nfp_net_tx()
890 tx_ring->txbufs[wr_idx].fidx = -2; in nfp_net_tx()
906 static void nfp_net_tx_complete(struct nfp_net_tx_ring *tx_ring) in nfp_net_tx_complete() argument
908 struct nfp_net_r_vector *r_vec = tx_ring->r_vec; in nfp_net_tx_complete()
920 qcp_rd_p = nfp_qcp_rd_ptr_read(tx_ring->qcp_q); in nfp_net_tx_complete()
922 if (qcp_rd_p == tx_ring->qcp_rd_p) in nfp_net_tx_complete()
925 if (qcp_rd_p > tx_ring->qcp_rd_p) in nfp_net_tx_complete()
926 todo = qcp_rd_p - tx_ring->qcp_rd_p; in nfp_net_tx_complete()
928 todo = qcp_rd_p + tx_ring->cnt - tx_ring->qcp_rd_p; in nfp_net_tx_complete()
931 idx = tx_ring->rd_p % tx_ring->cnt; in nfp_net_tx_complete()
932 tx_ring->rd_p++; in nfp_net_tx_complete()
934 skb = tx_ring->txbufs[idx].skb; in nfp_net_tx_complete()
939 fidx = tx_ring->txbufs[idx].fidx; in nfp_net_tx_complete()
944 tx_ring->txbufs[idx].dma_addr, in nfp_net_tx_complete()
947 done_pkts += tx_ring->txbufs[idx].pkt_cnt; in nfp_net_tx_complete()
948 done_bytes += tx_ring->txbufs[idx].real_len; in nfp_net_tx_complete()
953 tx_ring->txbufs[idx].dma_addr, in nfp_net_tx_complete()
961 tx_ring->txbufs[idx].dma_addr = 0; in nfp_net_tx_complete()
962 tx_ring->txbufs[idx].skb = NULL; in nfp_net_tx_complete()
963 tx_ring->txbufs[idx].fidx = -2; in nfp_net_tx_complete()
966 tx_ring->qcp_rd_p = qcp_rd_p; in nfp_net_tx_complete()
973 nd_q = netdev_get_tx_queue(nn->netdev, tx_ring->idx); in nfp_net_tx_complete()
975 if (nfp_net_tx_ring_should_wake(tx_ring)) { in nfp_net_tx_complete()
983 WARN_ONCE(tx_ring->wr_p - tx_ring->rd_p > tx_ring->cnt, in nfp_net_tx_complete()
985 tx_ring->rd_p, tx_ring->wr_p, tx_ring->cnt); in nfp_net_tx_complete()
996 nfp_net_tx_ring_reset(struct nfp_net *nn, struct nfp_net_tx_ring *tx_ring) in nfp_net_tx_ring_reset() argument
1002 while (tx_ring->rd_p != tx_ring->wr_p) { in nfp_net_tx_ring_reset()
1006 idx = tx_ring->rd_p % tx_ring->cnt; in nfp_net_tx_ring_reset()
1007 skb = tx_ring->txbufs[idx].skb; in nfp_net_tx_ring_reset()
1009 fidx = tx_ring->txbufs[idx].fidx; in nfp_net_tx_ring_reset()
1014 tx_ring->txbufs[idx].dma_addr, in nfp_net_tx_ring_reset()
1020 tx_ring->txbufs[idx].dma_addr, in nfp_net_tx_ring_reset()
1028 tx_ring->txbufs[idx].dma_addr = 0; in nfp_net_tx_ring_reset()
1029 tx_ring->txbufs[idx].skb = NULL; in nfp_net_tx_ring_reset()
1030 tx_ring->txbufs[idx].fidx = -2; in nfp_net_tx_ring_reset()
1032 tx_ring->qcp_rd_p++; in nfp_net_tx_ring_reset()
1033 tx_ring->rd_p++; in nfp_net_tx_ring_reset()
1036 memset(tx_ring->txds, 0, sizeof(*tx_ring->txds) * tx_ring->cnt); in nfp_net_tx_ring_reset()
1037 tx_ring->wr_p = 0; in nfp_net_tx_ring_reset()
1038 tx_ring->rd_p = 0; in nfp_net_tx_ring_reset()
1039 tx_ring->qcp_rd_p = 0; in nfp_net_tx_ring_reset()
1040 tx_ring->wr_ptr_add = 0; in nfp_net_tx_ring_reset()
1042 nd_q = netdev_get_tx_queue(nn->netdev, tx_ring->idx); in nfp_net_tx_ring_reset()
1528 struct nfp_net_tx_ring *tx_ring = r_vec->tx_ring; in nfp_net_poll() local
1533 tx_ring = &nn->tx_rings[rx_ring->idx]; in nfp_net_poll()
1534 txq = netdev_get_tx_queue(nn->netdev, tx_ring->idx); in nfp_net_poll()
1535 nfp_net_tx_complete(tx_ring); in nfp_net_poll()
1554 static void nfp_net_tx_ring_free(struct nfp_net_tx_ring *tx_ring) in nfp_net_tx_ring_free() argument
1556 struct nfp_net_r_vector *r_vec = tx_ring->r_vec; in nfp_net_tx_ring_free()
1560 kfree(tx_ring->txbufs); in nfp_net_tx_ring_free()
1562 if (tx_ring->txds) in nfp_net_tx_ring_free()
1563 dma_free_coherent(&pdev->dev, tx_ring->size, in nfp_net_tx_ring_free()
1564 tx_ring->txds, tx_ring->dma); in nfp_net_tx_ring_free()
1566 tx_ring->cnt = 0; in nfp_net_tx_ring_free()
1567 tx_ring->txbufs = NULL; in nfp_net_tx_ring_free()
1568 tx_ring->txds = NULL; in nfp_net_tx_ring_free()
1569 tx_ring->dma = 0; in nfp_net_tx_ring_free()
1570 tx_ring->size = 0; in nfp_net_tx_ring_free()
1580 static int nfp_net_tx_ring_alloc(struct nfp_net_tx_ring *tx_ring, u32 cnt) in nfp_net_tx_ring_alloc() argument
1582 struct nfp_net_r_vector *r_vec = tx_ring->r_vec; in nfp_net_tx_ring_alloc()
1587 tx_ring->cnt = cnt; in nfp_net_tx_ring_alloc()
1589 tx_ring->size = sizeof(*tx_ring->txds) * tx_ring->cnt; in nfp_net_tx_ring_alloc()
1590 tx_ring->txds = dma_zalloc_coherent(&pdev->dev, tx_ring->size, in nfp_net_tx_ring_alloc()
1591 &tx_ring->dma, GFP_KERNEL); in nfp_net_tx_ring_alloc()
1592 if (!tx_ring->txds) in nfp_net_tx_ring_alloc()
1595 sz = sizeof(*tx_ring->txbufs) * tx_ring->cnt; in nfp_net_tx_ring_alloc()
1596 tx_ring->txbufs = kzalloc(sz, GFP_KERNEL); in nfp_net_tx_ring_alloc()
1597 if (!tx_ring->txbufs) in nfp_net_tx_ring_alloc()
1600 netif_set_xps_queue(nn->netdev, &r_vec->affinity_mask, tx_ring->idx); in nfp_net_tx_ring_alloc()
1603 tx_ring->idx, tx_ring->qcidx, in nfp_net_tx_ring_alloc()
1604 tx_ring->cnt, (unsigned long long)tx_ring->dma, tx_ring->txds); in nfp_net_tx_ring_alloc()
1609 nfp_net_tx_ring_free(tx_ring); in nfp_net_tx_ring_alloc()
1646 old[r].r_vec->tx_ring = &rings[r]; in nfp_net_shadow_tx_rings_swap()
1800 r_vec->tx_ring = &nn->tx_rings[idx]; in nfp_net_prepare_vector()
1801 nfp_net_tx_ring_init(r_vec->tx_ring, r_vec, idx); in nfp_net_prepare_vector()
1948 nfp_net_tx_ring_reset(nn, nn->r_vecs[r].tx_ring); in nfp_net_clear_config_and_disable()
1964 nn_writeq(nn, NFP_NET_CFG_TXR_ADDR(idx), r_vec->tx_ring->dma); in nfp_net_vec_write_ring_data()
1965 nn_writeb(nn, NFP_NET_CFG_TXR_SZ(idx), ilog2(r_vec->tx_ring->cnt)); in nfp_net_vec_write_ring_data()
2112 err = nfp_net_tx_ring_alloc(nn->r_vecs[r].tx_ring, nn->txd_cnt); in nfp_net_netdev_open()
2163 nfp_net_tx_ring_free(nn->r_vecs[r].tx_ring); in nfp_net_netdev_open()
2208 nfp_net_tx_ring_free(nn->r_vecs[r].tx_ring); in nfp_net_close_free_all()