1
2
3
4
5
6#include <inttypes.h>
7
8#include <rte_byteorder.h>
9#include <rte_malloc.h>
10
11#include "bnxt.h"
12#include "bnxt_hwrm.h"
13#include "bnxt_ring.h"
14#include "bnxt_txq.h"
15#include "bnxt_txr.h"
16#include "hsi_struct_def_dpdk.h"
17#include <stdbool.h>
18
19
20
21
22
23void bnxt_free_tx_rings(struct bnxt *bp)
24{
25 int i;
26
27 for (i = 0; i < (int)bp->tx_nr_rings; i++) {
28 struct bnxt_tx_queue *txq = bp->tx_queues[i];
29
30 if (!txq)
31 continue;
32
33 bnxt_free_ring(txq->tx_ring->tx_ring_struct);
34 rte_free(txq->tx_ring->tx_ring_struct);
35 rte_free(txq->tx_ring);
36
37 bnxt_free_ring(txq->cp_ring->cp_ring_struct);
38 rte_free(txq->cp_ring->cp_ring_struct);
39 rte_free(txq->cp_ring);
40
41 rte_free(txq);
42 bp->tx_queues[i] = NULL;
43 }
44}
45
46int bnxt_init_one_tx_ring(struct bnxt_tx_queue *txq)
47{
48 struct bnxt_tx_ring_info *txr = txq->tx_ring;
49 struct bnxt_ring *ring = txr->tx_ring_struct;
50
51 txq->tx_wake_thresh = ring->ring_size / 2;
52 ring->fw_ring_id = INVALID_HW_RING_ID;
53
54 return 0;
55}
56
57int bnxt_init_tx_ring_struct(struct bnxt_tx_queue *txq, unsigned int socket_id)
58{
59 struct bnxt_cp_ring_info *cpr;
60 struct bnxt_tx_ring_info *txr;
61 struct bnxt_ring *ring;
62
63 txr = rte_zmalloc_socket("bnxt_tx_ring",
64 sizeof(struct bnxt_tx_ring_info),
65 RTE_CACHE_LINE_SIZE, socket_id);
66 if (txr == NULL)
67 return -ENOMEM;
68 txq->tx_ring = txr;
69
70 ring = rte_zmalloc_socket("bnxt_tx_ring_struct",
71 sizeof(struct bnxt_ring),
72 RTE_CACHE_LINE_SIZE, socket_id);
73 if (ring == NULL)
74 return -ENOMEM;
75 txr->tx_ring_struct = ring;
76 ring->ring_size = rte_align32pow2(txq->nb_tx_desc);
77 ring->ring_mask = ring->ring_size - 1;
78 ring->bd = (void *)txr->tx_desc_ring;
79 ring->bd_dma = txr->tx_desc_mapping;
80 ring->vmem_size = ring->ring_size * sizeof(struct rte_mbuf *);
81 ring->vmem = (void **)&txr->tx_buf_ring;
82 ring->fw_ring_id = INVALID_HW_RING_ID;
83
84 cpr = rte_zmalloc_socket("bnxt_tx_ring",
85 sizeof(struct bnxt_cp_ring_info),
86 RTE_CACHE_LINE_SIZE, socket_id);
87 if (cpr == NULL)
88 return -ENOMEM;
89 txq->cp_ring = cpr;
90
91 ring = rte_zmalloc_socket("bnxt_tx_ring_struct",
92 sizeof(struct bnxt_ring),
93 RTE_CACHE_LINE_SIZE, socket_id);
94 if (ring == NULL)
95 return -ENOMEM;
96 cpr->cp_ring_struct = ring;
97 ring->ring_size = txr->tx_ring_struct->ring_size;
98 ring->ring_mask = ring->ring_size - 1;
99 ring->bd = (void *)cpr->cp_desc_ring;
100 ring->bd_dma = cpr->cp_desc_mapping;
101 ring->vmem_size = 0;
102 ring->vmem = NULL;
103 ring->fw_ring_id = INVALID_HW_RING_ID;
104
105 return 0;
106}
107
108static bool
109bnxt_xmit_need_long_bd(struct rte_mbuf *tx_pkt, struct bnxt_tx_queue *txq)
110{
111 if (tx_pkt->ol_flags & (PKT_TX_TCP_SEG | PKT_TX_TCP_CKSUM |
112 PKT_TX_UDP_CKSUM | PKT_TX_IP_CKSUM |
113 PKT_TX_VLAN_PKT | PKT_TX_OUTER_IP_CKSUM |
114 PKT_TX_TUNNEL_GRE | PKT_TX_TUNNEL_VXLAN |
115 PKT_TX_TUNNEL_GENEVE | PKT_TX_IEEE1588_TMST |
116 PKT_TX_QINQ_PKT) ||
117 (BNXT_TRUFLOW_EN(txq->bp) &&
118 (txq->bp->tx_cfa_action || txq->vfr_tx_cfa_action)))
119 return true;
120 return false;
121}
122
123static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
124 struct bnxt_tx_queue *txq,
125 uint16_t *coal_pkts,
126 struct tx_bd_long **last_txbd)
127{
128 struct bnxt_tx_ring_info *txr = txq->tx_ring;
129 struct bnxt_ring *ring = txr->tx_ring_struct;
130 uint32_t outer_tpid_bd = 0;
131 struct tx_bd_long *txbd;
132 struct tx_bd_long_hi *txbd1 = NULL;
133 uint32_t vlan_tag_flags;
134 bool long_bd = false;
135 unsigned short nr_bds;
136 uint16_t prod;
137 struct rte_mbuf *m_seg;
138 struct rte_mbuf **tx_buf;
139 static const uint32_t lhint_arr[4] = {
140 TX_BD_LONG_FLAGS_LHINT_LT512,
141 TX_BD_LONG_FLAGS_LHINT_LT1K,
142 TX_BD_LONG_FLAGS_LHINT_LT2K,
143 TX_BD_LONG_FLAGS_LHINT_LT2K
144 };
145
146 if (unlikely(is_bnxt_in_error(txq->bp)))
147 return -EIO;
148
149 long_bd = bnxt_xmit_need_long_bd(tx_pkt, txq);
150 nr_bds = long_bd + tx_pkt->nb_segs;
151
152 if (unlikely(bnxt_tx_avail(txq) < nr_bds))
153 return -ENOMEM;
154
155
156 if (unlikely(nr_bds > BNXT_MAX_TSO_SEGS)) {
157 PMD_DRV_LOG(ERR,
158 "Num descriptors %d exceeds HW limit\n", nr_bds);
159 return -ENOSPC;
160 }
161
162
163 if (unlikely(rte_pktmbuf_pkt_len(tx_pkt) < BNXT_MIN_PKT_SIZE)) {
164 uint8_t pad = BNXT_MIN_PKT_SIZE - rte_pktmbuf_pkt_len(tx_pkt);
165 char *seg = rte_pktmbuf_append(tx_pkt, pad);
166
167 if (!seg) {
168 PMD_DRV_LOG(ERR,
169 "Failed to pad mbuf by %d bytes\n",
170 pad);
171 return -ENOMEM;
172 }
173
174
175 memset(seg, 0, pad);
176 }
177
178
179 RTE_VERIFY(tx_pkt->data_len);
180
181 prod = RING_IDX(ring, txr->tx_raw_prod);
182 tx_buf = &txr->tx_buf_ring[prod];
183 *tx_buf = tx_pkt;
184
185 txbd = &txr->tx_desc_ring[prod];
186 txbd->opaque = *coal_pkts;
187 txbd->flags_type = nr_bds << TX_BD_LONG_FLAGS_BD_CNT_SFT;
188 txbd->flags_type |= TX_BD_SHORT_FLAGS_COAL_NOW;
189 txbd->flags_type |= TX_BD_LONG_FLAGS_NO_CMPL;
190 txbd->len = tx_pkt->data_len;
191 if (tx_pkt->pkt_len >= 2048)
192 txbd->flags_type |= TX_BD_LONG_FLAGS_LHINT_GTE2K;
193 else
194 txbd->flags_type |= lhint_arr[tx_pkt->pkt_len >> 9];
195 txbd->address = rte_cpu_to_le_64(rte_mbuf_data_iova(tx_pkt));
196 *last_txbd = txbd;
197
198 if (long_bd) {
199 txbd->flags_type |= TX_BD_LONG_TYPE_TX_BD_LONG;
200 vlan_tag_flags = 0;
201
202
203 if (tx_pkt->ol_flags & PKT_TX_QINQ_PKT) {
204 vlan_tag_flags = TX_BD_LONG_CFA_META_KEY_VLAN_TAG |
205 tx_pkt->vlan_tci_outer;
206 outer_tpid_bd = txq->bp->outer_tpid_bd &
207 BNXT_OUTER_TPID_BD_MASK;
208 vlan_tag_flags |= outer_tpid_bd;
209 } else if (tx_pkt->ol_flags & PKT_TX_VLAN_PKT) {
210
211
212
213 vlan_tag_flags = TX_BD_LONG_CFA_META_KEY_VLAN_TAG |
214 tx_pkt->vlan_tci;
215
216
217
218
219 vlan_tag_flags |=
220 TX_BD_LONG_CFA_META_VLAN_TPID_TPID8100;
221 }
222
223 txr->tx_raw_prod = RING_NEXT(txr->tx_raw_prod);
224
225 prod = RING_IDX(ring, txr->tx_raw_prod);
226 txbd1 = (struct tx_bd_long_hi *)&txr->tx_desc_ring[prod];
227 txbd1->lflags = 0;
228 txbd1->cfa_meta = vlan_tag_flags;
229
230
231
232 txbd1->kid_or_ts_high_mss = 0;
233
234 if (txq->vfr_tx_cfa_action)
235 txbd1->cfa_action = txq->vfr_tx_cfa_action;
236 else
237 txbd1->cfa_action = txq->bp->tx_cfa_action;
238
239 if (tx_pkt->ol_flags & PKT_TX_TCP_SEG) {
240 uint16_t hdr_size;
241
242
243 txbd1->lflags |= TX_BD_LONG_LFLAGS_LSO |
244 TX_BD_LONG_LFLAGS_T_IPID;
245 hdr_size = tx_pkt->l2_len + tx_pkt->l3_len +
246 tx_pkt->l4_len;
247 hdr_size += (tx_pkt->ol_flags & PKT_TX_TUNNEL_MASK) ?
248 tx_pkt->outer_l2_len +
249 tx_pkt->outer_l3_len : 0;
250
251
252
253
254 txbd1->kid_or_ts_low_hdr_size = hdr_size >> 1;
255 txbd1->kid_or_ts_high_mss = tx_pkt->tso_segsz;
256 RTE_VERIFY(txbd1->kid_or_ts_high_mss);
257
258 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_IIP_TCP_UDP_CKSUM) ==
259 PKT_TX_OIP_IIP_TCP_UDP_CKSUM) {
260
261 txbd1->lflags |= TX_BD_FLG_TIP_IP_TCP_UDP_CHKSUM;
262 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_IIP_TCP_CKSUM) ==
263 PKT_TX_OIP_IIP_TCP_CKSUM) {
264
265 txbd1->lflags |= TX_BD_FLG_TIP_IP_TCP_UDP_CHKSUM;
266 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_IIP_UDP_CKSUM) ==
267 PKT_TX_OIP_IIP_UDP_CKSUM) {
268
269 txbd1->lflags |= TX_BD_FLG_TIP_IP_TCP_UDP_CHKSUM;
270 } else if ((tx_pkt->ol_flags & PKT_TX_IIP_TCP_UDP_CKSUM) ==
271 PKT_TX_IIP_TCP_UDP_CKSUM) {
272
273 txbd1->lflags |= TX_BD_FLG_IP_TCP_UDP_CHKSUM;
274 } else if ((tx_pkt->ol_flags & PKT_TX_IIP_UDP_CKSUM) ==
275 PKT_TX_IIP_UDP_CKSUM) {
276
277 txbd1->lflags |= TX_BD_FLG_IP_TCP_UDP_CHKSUM;
278 } else if ((tx_pkt->ol_flags & PKT_TX_IIP_TCP_CKSUM) ==
279 PKT_TX_IIP_TCP_CKSUM) {
280
281 txbd1->lflags |= TX_BD_FLG_IP_TCP_UDP_CHKSUM;
282 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_TCP_UDP_CKSUM) ==
283 PKT_TX_OIP_TCP_UDP_CKSUM) {
284
285 txbd1->lflags |= TX_BD_FLG_TIP_TCP_UDP_CHKSUM;
286 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_UDP_CKSUM) ==
287 PKT_TX_OIP_UDP_CKSUM) {
288
289 txbd1->lflags |= TX_BD_FLG_TIP_TCP_UDP_CHKSUM;
290 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_TCP_CKSUM) ==
291 PKT_TX_OIP_TCP_CKSUM) {
292
293 txbd1->lflags |= TX_BD_FLG_TIP_TCP_UDP_CHKSUM;
294 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_IIP_CKSUM) ==
295 PKT_TX_OIP_IIP_CKSUM) {
296
297 txbd1->lflags |= TX_BD_FLG_TIP_IP_CHKSUM;
298 } else if ((tx_pkt->ol_flags & PKT_TX_TCP_UDP_CKSUM) ==
299 PKT_TX_TCP_UDP_CKSUM) {
300
301 txbd1->lflags |= TX_BD_LONG_LFLAGS_TCP_UDP_CHKSUM;
302 } else if ((tx_pkt->ol_flags & PKT_TX_TCP_CKSUM) ==
303 PKT_TX_TCP_CKSUM) {
304
305 txbd1->lflags |= TX_BD_LONG_LFLAGS_TCP_UDP_CHKSUM;
306 } else if ((tx_pkt->ol_flags & PKT_TX_UDP_CKSUM) ==
307 PKT_TX_UDP_CKSUM) {
308
309 txbd1->lflags |= TX_BD_LONG_LFLAGS_TCP_UDP_CHKSUM;
310 } else if ((tx_pkt->ol_flags & PKT_TX_IP_CKSUM) ==
311 PKT_TX_IP_CKSUM) {
312
313 txbd1->lflags |= TX_BD_LONG_LFLAGS_IP_CHKSUM;
314 } else if ((tx_pkt->ol_flags & PKT_TX_OUTER_IP_CKSUM) ==
315 PKT_TX_OUTER_IP_CKSUM) {
316
317 txbd1->lflags |= TX_BD_LONG_LFLAGS_T_IP_CHKSUM;
318 } else if ((tx_pkt->ol_flags & PKT_TX_IEEE1588_TMST) ==
319 PKT_TX_IEEE1588_TMST) {
320
321 txbd1->lflags |= TX_BD_LONG_LFLAGS_STAMP;
322 }
323 } else {
324 txbd->flags_type |= TX_BD_SHORT_TYPE_TX_BD_SHORT;
325 }
326
327 m_seg = tx_pkt->next;
328 while (m_seg) {
329
330 RTE_VERIFY(m_seg->data_len);
331 txr->tx_raw_prod = RING_NEXT(txr->tx_raw_prod);
332
333 prod = RING_IDX(ring, txr->tx_raw_prod);
334 tx_buf = &txr->tx_buf_ring[prod];
335 *tx_buf = m_seg;
336
337 txbd = &txr->tx_desc_ring[prod];
338 txbd->address = rte_cpu_to_le_64(rte_mbuf_data_iova(m_seg));
339 txbd->flags_type = TX_BD_SHORT_TYPE_TX_BD_SHORT;
340 txbd->len = m_seg->data_len;
341
342 m_seg = m_seg->next;
343 }
344
345 txbd->flags_type |= TX_BD_LONG_FLAGS_PACKET_END;
346
347 txr->tx_raw_prod = RING_NEXT(txr->tx_raw_prod);
348
349 return 0;
350}
351
352
353
354
355
356static void bnxt_tx_cmp_fast(struct bnxt_tx_queue *txq, int nr_pkts)
357{
358 struct bnxt_tx_ring_info *txr = txq->tx_ring;
359 struct bnxt_ring *ring = txr->tx_ring_struct;
360 struct rte_mbuf **free = txq->free;
361 uint16_t raw_cons = txr->tx_raw_cons;
362 unsigned int blk = 0;
363 int i, j;
364
365 for (i = 0; i < nr_pkts; i++) {
366 struct rte_mbuf **tx_buf;
367 unsigned short nr_bds;
368
369 tx_buf = &txr->tx_buf_ring[RING_IDX(ring, raw_cons)];
370 nr_bds = (*tx_buf)->nb_segs +
371 bnxt_xmit_need_long_bd(*tx_buf, txq);
372 for (j = 0; j < nr_bds; j++) {
373 if (*tx_buf) {
374
375 free[blk++] = *tx_buf;
376 *tx_buf = NULL;
377 }
378 raw_cons = RING_NEXT(raw_cons);
379 tx_buf = &txr->tx_buf_ring[RING_IDX(ring, raw_cons)];
380 }
381 }
382 if (blk)
383 rte_mempool_put_bulk(free[0]->pool, (void *)free, blk);
384
385 txr->tx_raw_cons = raw_cons;
386}
387
388static void bnxt_tx_cmp(struct bnxt_tx_queue *txq, int nr_pkts)
389{
390 struct bnxt_tx_ring_info *txr = txq->tx_ring;
391 struct bnxt_ring *ring = txr->tx_ring_struct;
392 struct rte_mempool *pool = NULL;
393 struct rte_mbuf **free = txq->free;
394 uint16_t raw_cons = txr->tx_raw_cons;
395 unsigned int blk = 0;
396 int i, j;
397
398 for (i = 0; i < nr_pkts; i++) {
399 struct rte_mbuf *mbuf;
400 struct rte_mbuf **tx_buf;
401 unsigned short nr_bds;
402
403 tx_buf = &txr->tx_buf_ring[RING_IDX(ring, raw_cons)];
404 nr_bds = (*tx_buf)->nb_segs +
405 bnxt_xmit_need_long_bd(*tx_buf, txq);
406 for (j = 0; j < nr_bds; j++) {
407 mbuf = *tx_buf;
408 *tx_buf = NULL;
409 raw_cons = RING_NEXT(raw_cons);
410 tx_buf = &txr->tx_buf_ring[RING_IDX(ring, raw_cons)];
411 if (!mbuf)
412 continue;
413
414 mbuf = rte_pktmbuf_prefree_seg(mbuf);
415 if (unlikely(!mbuf))
416 continue;
417
418
419
420 if (likely(mbuf->pool == pool)) {
421
422 free[blk++] = mbuf;
423 } else {
424
425
426
427
428 if (likely(pool != NULL))
429 rte_mempool_put_bulk(pool,
430 (void *)free,
431 blk);
432
433
434 free[0] = mbuf;
435 pool = mbuf->pool;
436 blk = 1;
437 }
438 }
439 }
440 if (blk)
441 rte_mempool_put_bulk(pool, (void *)free, blk);
442
443 txr->tx_raw_cons = raw_cons;
444}
445
446static int bnxt_handle_tx_cp(struct bnxt_tx_queue *txq)
447{
448 uint32_t nb_tx_pkts = 0, cons, ring_mask, opaque;
449 struct bnxt_cp_ring_info *cpr = txq->cp_ring;
450 uint32_t raw_cons = cpr->cp_raw_cons;
451 struct bnxt_ring *cp_ring_struct;
452 struct tx_cmpl *txcmp;
453
454 if (bnxt_tx_bds_in_hw(txq) < txq->tx_free_thresh)
455 return 0;
456
457 cp_ring_struct = cpr->cp_ring_struct;
458 ring_mask = cp_ring_struct->ring_mask;
459
460 do {
461 cons = RING_CMPL(ring_mask, raw_cons);
462 txcmp = (struct tx_cmpl *)&cpr->cp_desc_ring[cons];
463
464 if (!bnxt_cpr_cmp_valid(txcmp, raw_cons, ring_mask + 1))
465 break;
466
467 opaque = rte_le_to_cpu_32(txcmp->opaque);
468
469 if (CMP_TYPE(txcmp) == TX_CMPL_TYPE_TX_L2)
470 nb_tx_pkts += opaque;
471 else
472 RTE_LOG_DP(ERR, PMD,
473 "Unhandled CMP type %02x\n",
474 CMP_TYPE(txcmp));
475 raw_cons = NEXT_RAW_CMP(raw_cons);
476 } while (nb_tx_pkts < ring_mask);
477
478 if (nb_tx_pkts) {
479 if (txq->offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
480 bnxt_tx_cmp_fast(txq, nb_tx_pkts);
481 else
482 bnxt_tx_cmp(txq, nb_tx_pkts);
483 cpr->cp_raw_cons = raw_cons;
484 bnxt_db_cq(cpr);
485 }
486
487 return nb_tx_pkts;
488}
489
490uint16_t bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
491 uint16_t nb_pkts)
492{
493 int rc;
494 uint16_t nb_tx_pkts = 0;
495 uint16_t coal_pkts = 0;
496 struct bnxt_tx_queue *txq = tx_queue;
497 struct tx_bd_long *last_txbd = NULL;
498
499
500 bnxt_handle_tx_cp(txq);
501
502
503 if (unlikely(!txq->tx_started)) {
504 PMD_DRV_LOG(DEBUG, "Tx q stopped;return\n");
505 return 0;
506 }
507
508
509 for (nb_tx_pkts = 0; nb_tx_pkts < nb_pkts; nb_tx_pkts++) {
510 coal_pkts++;
511 rc = bnxt_start_xmit(tx_pkts[nb_tx_pkts], txq,
512 &coal_pkts, &last_txbd);
513
514 if (unlikely(rc))
515 break;
516 }
517
518 if (likely(nb_tx_pkts)) {
519
520 last_txbd->flags_type &= ~TX_BD_LONG_FLAGS_NO_CMPL;
521 bnxt_db_write(&txq->tx_ring->tx_db, txq->tx_ring->tx_raw_prod);
522 }
523
524 return nb_tx_pkts;
525}
526
527
528
529
530
531
532
533uint16_t
534bnxt_dummy_xmit_pkts(void *tx_queue __rte_unused,
535 struct rte_mbuf **tx_pkts __rte_unused,
536 uint16_t nb_pkts __rte_unused)
537{
538 return 0;
539}
540
541int bnxt_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
542{
543 struct bnxt *bp = dev->data->dev_private;
544 struct bnxt_tx_queue *txq = bp->tx_queues[tx_queue_id];
545 int rc = 0;
546
547 rc = is_bnxt_in_error(bp);
548 if (rc)
549 return rc;
550
551 bnxt_free_hwrm_tx_ring(bp, tx_queue_id);
552 rc = bnxt_alloc_hwrm_tx_ring(bp, tx_queue_id);
553 if (rc)
554 return rc;
555
556 dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
557 txq->tx_started = true;
558 PMD_DRV_LOG(DEBUG, "Tx queue started\n");
559
560 return 0;
561}
562
563int bnxt_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
564{
565 struct bnxt *bp = dev->data->dev_private;
566 struct bnxt_tx_queue *txq = bp->tx_queues[tx_queue_id];
567 int rc = 0;
568
569 rc = is_bnxt_in_error(bp);
570 if (rc)
571 return rc;
572
573
574 bnxt_handle_tx_cp(txq);
575
576 dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
577 txq->tx_started = false;
578 PMD_DRV_LOG(DEBUG, "Tx queue stopped\n");
579
580 return 0;
581}
582
583
584
585
586
587int bnxt_flush_tx_cmp(struct bnxt_cp_ring_info *cpr)
588{
589 uint32_t raw_cons = cpr->cp_raw_cons;
590 uint32_t cons;
591 uint32_t nb_tx_pkts = 0;
592 struct tx_cmpl *txcmp;
593 struct cmpl_base *cp_desc_ring = cpr->cp_desc_ring;
594 struct bnxt_ring *cp_ring_struct = cpr->cp_ring_struct;
595 uint32_t ring_mask = cp_ring_struct->ring_mask;
596 uint32_t opaque = 0;
597
598 do {
599 cons = RING_CMPL(ring_mask, raw_cons);
600 txcmp = (struct tx_cmpl *)&cp_desc_ring[cons];
601
602 opaque = rte_cpu_to_le_32(txcmp->opaque);
603 raw_cons = NEXT_RAW_CMP(raw_cons);
604
605 if (CMP_TYPE(txcmp) == TX_CMPL_TYPE_TX_L2)
606 nb_tx_pkts += opaque;
607 else if (CMP_TYPE(txcmp) == HWRM_CMPL_TYPE_HWRM_DONE)
608 return 1;
609 } while (nb_tx_pkts < ring_mask);
610
611 if (nb_tx_pkts) {
612 cpr->cp_raw_cons = raw_cons;
613 bnxt_db_cq(cpr);
614 }
615
616 return 0;
617}
618