Lines Matching refs:ring
55 struct mlx4_en_tx_ring *ring; in mlx4_en_create_tx_ring() local
59 ring = kzalloc_node(sizeof(*ring), GFP_KERNEL, node); in mlx4_en_create_tx_ring()
60 if (!ring) { in mlx4_en_create_tx_ring()
65 ring->size = size; in mlx4_en_create_tx_ring()
66 ring->size_mask = size - 1; in mlx4_en_create_tx_ring()
67 ring->sp_stride = stride; in mlx4_en_create_tx_ring()
68 ring->full_size = ring->size - HEADROOM - MLX4_MAX_DESC_TXBBS; in mlx4_en_create_tx_ring()
71 ring->tx_info = kvmalloc_node(tmp, GFP_KERNEL, node); in mlx4_en_create_tx_ring()
72 if (!ring->tx_info) { in mlx4_en_create_tx_ring()
78 ring->tx_info, tmp); in mlx4_en_create_tx_ring()
80 ring->bounce_buf = kmalloc_node(MLX4_TX_BOUNCE_BUFFER_SIZE, in mlx4_en_create_tx_ring()
82 if (!ring->bounce_buf) { in mlx4_en_create_tx_ring()
83 ring->bounce_buf = kmalloc(MLX4_TX_BOUNCE_BUFFER_SIZE, in mlx4_en_create_tx_ring()
85 if (!ring->bounce_buf) { in mlx4_en_create_tx_ring()
90 ring->buf_size = ALIGN(size * ring->sp_stride, MLX4_EN_PAGE_SIZE); in mlx4_en_create_tx_ring()
94 err = mlx4_alloc_hwq_res(mdev->dev, &ring->sp_wqres, ring->buf_size); in mlx4_en_create_tx_ring()
101 ring->buf = ring->sp_wqres.buf.direct.buf; in mlx4_en_create_tx_ring()
104 ring, ring->buf, ring->size, ring->buf_size, in mlx4_en_create_tx_ring()
105 (unsigned long long) ring->sp_wqres.buf.direct.map); in mlx4_en_create_tx_ring()
107 err = mlx4_qp_reserve_range(mdev->dev, 1, 1, &ring->qpn, in mlx4_en_create_tx_ring()
115 err = mlx4_qp_alloc(mdev->dev, ring->qpn, &ring->sp_qp); in mlx4_en_create_tx_ring()
117 en_err(priv, "Failed allocating qp %d\n", ring->qpn); in mlx4_en_create_tx_ring()
120 ring->sp_qp.event = mlx4_en_sqp_event; in mlx4_en_create_tx_ring()
122 err = mlx4_bf_alloc(mdev->dev, &ring->bf, node); in mlx4_en_create_tx_ring()
125 ring->bf.uar = &mdev->priv_uar; in mlx4_en_create_tx_ring()
126 ring->bf.uar->map = mdev->uar_map; in mlx4_en_create_tx_ring()
127 ring->bf_enabled = false; in mlx4_en_create_tx_ring()
128 ring->bf_alloced = false; in mlx4_en_create_tx_ring()
131 ring->bf_alloced = true; in mlx4_en_create_tx_ring()
132 ring->bf_enabled = !!(priv->pflags & in mlx4_en_create_tx_ring()
135 ring->doorbell_address = ring->bf.uar->map + MLX4_SEND_DOORBELL; in mlx4_en_create_tx_ring()
137 ring->hwtstamp_tx_type = priv->hwtstamp_config.tx_type; in mlx4_en_create_tx_ring()
138 ring->queue_index = queue_index; in mlx4_en_create_tx_ring()
143 &ring->sp_affinity_mask); in mlx4_en_create_tx_ring()
145 *pring = ring; in mlx4_en_create_tx_ring()
149 mlx4_qp_release_range(mdev->dev, ring->qpn, 1); in mlx4_en_create_tx_ring()
151 mlx4_free_hwq_res(mdev->dev, &ring->sp_wqres, ring->buf_size); in mlx4_en_create_tx_ring()
153 kfree(ring->bounce_buf); in mlx4_en_create_tx_ring()
154 ring->bounce_buf = NULL; in mlx4_en_create_tx_ring()
156 kvfree(ring->tx_info); in mlx4_en_create_tx_ring()
157 ring->tx_info = NULL; in mlx4_en_create_tx_ring()
159 kfree(ring); in mlx4_en_create_tx_ring()
168 struct mlx4_en_tx_ring *ring = *pring; in mlx4_en_destroy_tx_ring() local
169 en_dbg(DRV, priv, "Destroying tx ring, qpn: %d\n", ring->qpn); in mlx4_en_destroy_tx_ring()
171 if (ring->bf_alloced) in mlx4_en_destroy_tx_ring()
172 mlx4_bf_free(mdev->dev, &ring->bf); in mlx4_en_destroy_tx_ring()
173 mlx4_qp_remove(mdev->dev, &ring->sp_qp); in mlx4_en_destroy_tx_ring()
174 mlx4_qp_free(mdev->dev, &ring->sp_qp); in mlx4_en_destroy_tx_ring()
175 mlx4_qp_release_range(priv->mdev->dev, ring->qpn, 1); in mlx4_en_destroy_tx_ring()
176 mlx4_free_hwq_res(mdev->dev, &ring->sp_wqres, ring->buf_size); in mlx4_en_destroy_tx_ring()
177 kfree(ring->bounce_buf); in mlx4_en_destroy_tx_ring()
178 ring->bounce_buf = NULL; in mlx4_en_destroy_tx_ring()
179 kvfree(ring->tx_info); in mlx4_en_destroy_tx_ring()
180 ring->tx_info = NULL; in mlx4_en_destroy_tx_ring()
181 kfree(ring); in mlx4_en_destroy_tx_ring()
186 struct mlx4_en_tx_ring *ring, in mlx4_en_activate_tx_ring() argument
192 ring->sp_cqn = cq; in mlx4_en_activate_tx_ring()
193 ring->prod = 0; in mlx4_en_activate_tx_ring()
194 ring->cons = 0xffffffff; in mlx4_en_activate_tx_ring()
195 ring->last_nr_txbb = 1; in mlx4_en_activate_tx_ring()
196 memset(ring->tx_info, 0, ring->size * sizeof(struct mlx4_en_tx_info)); in mlx4_en_activate_tx_ring()
197 memset(ring->buf, 0, ring->buf_size); in mlx4_en_activate_tx_ring()
198 ring->free_tx_desc = mlx4_en_free_tx_desc; in mlx4_en_activate_tx_ring()
200 ring->sp_qp_state = MLX4_QP_STATE_RST; in mlx4_en_activate_tx_ring()
201 ring->doorbell_qpn = cpu_to_be32(ring->sp_qp.qpn << 8); in mlx4_en_activate_tx_ring()
202 ring->mr_key = cpu_to_be32(mdev->mr.key); in mlx4_en_activate_tx_ring()
204 mlx4_en_fill_qp_context(priv, ring->size, ring->sp_stride, 1, 0, ring->qpn, in mlx4_en_activate_tx_ring()
205 ring->sp_cqn, user_prio, &ring->sp_context); in mlx4_en_activate_tx_ring()
206 if (ring->bf_alloced) in mlx4_en_activate_tx_ring()
207 ring->sp_context.usr_page = in mlx4_en_activate_tx_ring()
209 ring->bf.uar->index)); in mlx4_en_activate_tx_ring()
211 err = mlx4_qp_to_ready(mdev->dev, &ring->sp_wqres.mtt, &ring->sp_context, in mlx4_en_activate_tx_ring()
212 &ring->sp_qp, &ring->sp_qp_state); in mlx4_en_activate_tx_ring()
213 if (!cpumask_empty(&ring->sp_affinity_mask)) in mlx4_en_activate_tx_ring()
214 netif_set_xps_queue(priv->dev, &ring->sp_affinity_mask, in mlx4_en_activate_tx_ring()
215 ring->queue_index); in mlx4_en_activate_tx_ring()
221 struct mlx4_en_tx_ring *ring) in mlx4_en_deactivate_tx_ring() argument
225 mlx4_qp_modify(mdev->dev, NULL, ring->sp_qp_state, in mlx4_en_deactivate_tx_ring()
226 MLX4_QP_STATE_RST, NULL, 0, 0, &ring->sp_qp); in mlx4_en_deactivate_tx_ring()
229 static inline bool mlx4_en_is_tx_ring_full(struct mlx4_en_tx_ring *ring) in mlx4_en_is_tx_ring_full() argument
231 u32 used = READ_ONCE(ring->prod) - READ_ONCE(ring->cons); in mlx4_en_is_tx_ring_full()
233 return used > ring->full_size; in mlx4_en_is_tx_ring_full()
237 struct mlx4_en_tx_ring *ring, int index, in mlx4_en_stamp_wqe() argument
241 struct mlx4_en_tx_desc *tx_desc = ring->buf + (index << LOG_TXBB_SIZE); in mlx4_en_stamp_wqe()
242 struct mlx4_en_tx_info *tx_info = &ring->tx_info[index]; in mlx4_en_stamp_wqe()
243 void *end = ring->buf + ring->buf_size; in mlx4_en_stamp_wqe()
263 ptr = ring->buf; in mlx4_en_stamp_wqe()
271 struct mlx4_en_tx_ring *ring,
276 struct mlx4_en_tx_ring *ring, in mlx4_en_free_tx_desc() argument
280 struct mlx4_en_tx_info *tx_info = &ring->tx_info[index]; in mlx4_en_free_tx_desc()
281 struct mlx4_en_tx_desc *tx_desc = ring->buf + (index << LOG_TXBB_SIZE); in mlx4_en_free_tx_desc()
283 void *end = ring->buf + ring->buf_size; in mlx4_en_free_tx_desc()
323 data = ring->buf + ((void *)data - end); in mlx4_en_free_tx_desc()
329 data = ring->buf; in mlx4_en_free_tx_desc()
343 struct mlx4_en_tx_ring *ring,
348 struct mlx4_en_tx_ring *ring, in mlx4_en_recycle_tx_desc() argument
352 struct mlx4_en_tx_info *tx_info = &ring->tx_info[index]; in mlx4_en_recycle_tx_desc()
358 if (!napi_mode || !mlx4_en_rx_recycle(ring->recycle_ring, &frame)) { in mlx4_en_recycle_tx_desc()
367 int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring) in mlx4_en_free_tx_buf() argument
373 ring->cons += ring->last_nr_txbb; in mlx4_en_free_tx_buf()
375 ring->cons, ring->prod); in mlx4_en_free_tx_buf()
377 if ((u32) (ring->prod - ring->cons) > ring->size) { in mlx4_en_free_tx_buf()
383 while (ring->cons != ring->prod) { in mlx4_en_free_tx_buf()
384 ring->last_nr_txbb = ring->free_tx_desc(priv, ring, in mlx4_en_free_tx_buf()
385 ring->cons & ring->size_mask, in mlx4_en_free_tx_buf()
387 ring->cons += ring->last_nr_txbb; in mlx4_en_free_tx_buf()
391 if (ring->tx_queue) in mlx4_en_free_tx_buf()
392 netdev_tx_reset_queue(ring->tx_queue); in mlx4_en_free_tx_buf()
401 u16 cqe_index, struct mlx4_en_tx_ring *ring) in mlx4_en_handle_err_cqe() argument
410 ring->sp_cqn, cqe_index, err_cqe->vendor_err_syndrome, err_cqe->syndrome); in mlx4_en_handle_err_cqe()
414 wqe_index = be16_to_cpu(err_cqe->wqe_index) & ring->size_mask; in mlx4_en_handle_err_cqe()
415 tx_info = &ring->tx_info[wqe_index]; in mlx4_en_handle_err_cqe()
417 en_err(priv, "Related WQE - qpn 0x%x, wqe index 0x%x, wqe size 0x%x\n", ring->qpn, in mlx4_en_handle_err_cqe()
419 tx_desc = ring->buf + (wqe_index << LOG_TXBB_SIZE); in mlx4_en_handle_err_cqe()
434 struct mlx4_en_tx_ring *ring = priv->tx_ring[cq->type][cq->ring]; in mlx4_en_process_tx_cq() local
441 u32 size_mask = ring->size_mask; in mlx4_en_process_tx_cq()
454 netdev_txq_bql_complete_prefetchw(ring->tx_queue); in mlx4_en_process_tx_cq()
458 last_nr_txbb = READ_ONCE(ring->last_nr_txbb); in mlx4_en_process_tx_cq()
459 ring_cons = READ_ONCE(ring->cons); in mlx4_en_process_tx_cq()
476 if (!test_and_set_bit(MLX4_EN_TX_RING_STATE_RECOVERING, &ring->state)) in mlx4_en_process_tx_cq()
478 ring); in mlx4_en_process_tx_cq()
489 if (unlikely(ring->tx_info[ring_index].ts_requested)) in mlx4_en_process_tx_cq()
493 last_nr_txbb = INDIRECT_CALL_2(ring->free_tx_desc, in mlx4_en_process_tx_cq()
496 priv, ring, ring_index, in mlx4_en_process_tx_cq()
499 mlx4_en_stamp_wqe(priv, ring, stamp_index, in mlx4_en_process_tx_cq()
501 ring->size)); in mlx4_en_process_tx_cq()
505 bytes += ring->tx_info[ring_index].nr_bytes; in mlx4_en_process_tx_cq()
522 WRITE_ONCE(ring->last_nr_txbb, last_nr_txbb); in mlx4_en_process_tx_cq()
523 WRITE_ONCE(ring->cons, ring_cons + txbbs_skipped); in mlx4_en_process_tx_cq()
528 netdev_tx_completed_queue(ring->tx_queue, packets, bytes); in mlx4_en_process_tx_cq()
532 if (netif_tx_queue_stopped(ring->tx_queue) && in mlx4_en_process_tx_cq()
533 !mlx4_en_is_tx_ring_full(ring)) { in mlx4_en_process_tx_cq()
534 netif_tx_wake_queue(ring->tx_queue); in mlx4_en_process_tx_cq()
535 ring->wake_queue++; in mlx4_en_process_tx_cq()
571 struct mlx4_en_tx_ring *ring, in mlx4_en_bounce_to_desc() argument
575 u32 copy = (ring->size - index) << LOG_TXBB_SIZE; in mlx4_en_bounce_to_desc()
582 *((u32 *) (ring->buf + i)) = in mlx4_en_bounce_to_desc()
583 *((u32 *) (ring->bounce_buf + copy + i)); in mlx4_en_bounce_to_desc()
590 *((u32 *)(ring->buf + (index << LOG_TXBB_SIZE) + i)) = in mlx4_en_bounce_to_desc()
591 *((u32 *) (ring->bounce_buf + i)); in mlx4_en_bounce_to_desc()
595 return ring->buf + (index << LOG_TXBB_SIZE); in mlx4_en_bounce_to_desc()
757 void mlx4_en_xmit_doorbell(struct mlx4_en_tx_ring *ring) in mlx4_en_xmit_doorbell() argument
770 (__force u32)ring->doorbell_qpn, ring->doorbell_address); in mlx4_en_xmit_doorbell()
773 static void mlx4_en_tx_write_desc(struct mlx4_en_tx_ring *ring, in mlx4_en_tx_write_desc() argument
792 mlx4_bf_copy(ring->bf.reg + ring->bf.offset, &tx_desc->ctrl, in mlx4_en_tx_write_desc()
797 ring->bf.offset ^= ring->bf.buf_size; in mlx4_en_tx_write_desc()
805 mlx4_en_xmit_doorbell(ring); in mlx4_en_tx_write_desc()
807 ring->xmit_more++; in mlx4_en_tx_write_desc()
880 struct mlx4_en_tx_ring *ring; in mlx4_en_xmit() local
903 ring = priv->tx_ring[TX][tx_ind]; in mlx4_en_xmit()
917 bf_ok = ring->bf_enabled; in mlx4_en_xmit()
932 netdev_txq_bql_enqueue_prefetchw(ring->tx_queue); in mlx4_en_xmit()
935 index = ring->prod & ring->size_mask; in mlx4_en_xmit()
936 bf_index = ring->prod; in mlx4_en_xmit()
940 if (likely(index + nr_txbb <= ring->size)) in mlx4_en_xmit()
941 tx_desc = ring->buf + (index << LOG_TXBB_SIZE); in mlx4_en_xmit()
948 tx_desc = (struct mlx4_en_tx_desc *) ring->bounce_buf; in mlx4_en_xmit()
954 tx_info = &ring->tx_info[index]; in mlx4_en_xmit()
980 lso_header_size, ring->mr_key, in mlx4_en_xmit()
989 if (unlikely(ring->hwtstamp_tx_type == HWTSTAMP_TX_ON && in mlx4_en_xmit()
1004 ring->tx_csum++; in mlx4_en_xmit()
1024 ((ring->prod & ring->size) ? in mlx4_en_xmit()
1052 ring->tso_packets++; in mlx4_en_xmit()
1056 ring->packets += i; in mlx4_en_xmit()
1060 ((ring->prod & ring->size) ? in mlx4_en_xmit()
1063 ring->packets++; in mlx4_en_xmit()
1065 ring->bytes += tx_info->nr_bytes; in mlx4_en_xmit()
1088 WRITE_ONCE(ring->prod, ring->prod + nr_txbb); in mlx4_en_xmit()
1092 tx_desc = mlx4_en_bounce_to_desc(priv, ring, index, desc_size); in mlx4_en_xmit()
1097 stop_queue = mlx4_en_is_tx_ring_full(ring); in mlx4_en_xmit()
1099 netif_tx_stop_queue(ring->tx_queue); in mlx4_en_xmit()
1100 ring->queue_stopped++; in mlx4_en_xmit()
1103 send_doorbell = __netdev_tx_sent_queue(ring->tx_queue, in mlx4_en_xmit()
1112 qpn_vlan.bf_qpn = ring->doorbell_qpn | cpu_to_be32(real_size); in mlx4_en_xmit()
1116 mlx4_en_tx_write_desc(ring, tx_desc, qpn_vlan, desc_size, bf_index, in mlx4_en_xmit()
1128 if (unlikely(!mlx4_en_is_tx_ring_full(ring))) { in mlx4_en_xmit()
1129 netif_tx_wake_queue(ring->tx_queue); in mlx4_en_xmit()
1130 ring->wake_queue++; in mlx4_en_xmit()
1136 ring->tx_dropped++; in mlx4_en_xmit()
1147 struct mlx4_en_tx_ring *ring) in mlx4_en_init_tx_xdp_ring_descs() argument
1151 for (i = 0; i < ring->size; i++) { in mlx4_en_init_tx_xdp_ring_descs()
1152 struct mlx4_en_tx_info *tx_info = &ring->tx_info[i]; in mlx4_en_init_tx_xdp_ring_descs()
1153 struct mlx4_en_tx_desc *tx_desc = ring->buf + in mlx4_en_init_tx_xdp_ring_descs()
1164 tx_desc->data.lkey = ring->mr_key; in mlx4_en_init_tx_xdp_ring_descs()
1178 struct mlx4_en_tx_ring *ring; in mlx4_en_xmit_frame() local
1186 ring = priv->tx_ring[TX_XDP][tx_ind]; in mlx4_en_xmit_frame()
1188 if (unlikely(mlx4_en_is_tx_ring_full(ring))) in mlx4_en_xmit_frame()
1191 index = ring->prod & ring->size_mask; in mlx4_en_xmit_frame()
1192 tx_info = &ring->tx_info[index]; in mlx4_en_xmit_frame()
1194 tx_desc = ring->buf + (index << LOG_TXBB_SIZE); in mlx4_en_xmit_frame()
1214 ((ring->prod & ring->size) ? in mlx4_en_xmit_frame()
1219 WRITE_ONCE(ring->prod, ring->prod + MLX4_EN_XDP_TX_NRTXBB); in mlx4_en_xmit_frame()
1226 ring->xmit_more++; in mlx4_en_xmit_frame()