6e2ee86c058a824cd3e02bb544808d8efe936126
[dpdk.git] / drivers / net / bnxt / bnxt_txr.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2018 Broadcom
3  * All rights reserved.
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_cpr.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  * TX Ring handling
21  */
22
23 void 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
46 int 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
57 int 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 bnxt_sw_tx_bd);
81         ring->vmem = (void **)&txr->tx_buf_ring;
82
83         cpr = rte_zmalloc_socket("bnxt_tx_ring",
84                                  sizeof(struct bnxt_cp_ring_info),
85                                  RTE_CACHE_LINE_SIZE, socket_id);
86         if (cpr == NULL)
87                 return -ENOMEM;
88         txq->cp_ring = cpr;
89
90         ring = rte_zmalloc_socket("bnxt_tx_ring_struct",
91                                   sizeof(struct bnxt_ring),
92                                   RTE_CACHE_LINE_SIZE, socket_id);
93         if (ring == NULL)
94                 return -ENOMEM;
95         cpr->cp_ring_struct = ring;
96         ring->ring_size = txr->tx_ring_struct->ring_size;
97         ring->ring_mask = ring->ring_size - 1;
98         ring->bd = (void *)cpr->cp_desc_ring;
99         ring->bd_dma = cpr->cp_desc_mapping;
100         ring->vmem_size = 0;
101         ring->vmem = NULL;
102
103         return 0;
104 }
105
106 static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
107                                 struct bnxt_tx_queue *txq,
108                                 uint16_t *coal_pkts,
109                                 struct tx_bd_long **last_txbd)
110 {
111         struct bnxt_tx_ring_info *txr = txq->tx_ring;
112         uint32_t outer_tpid_bd = 0;
113         struct tx_bd_long *txbd;
114         struct tx_bd_long_hi *txbd1 = NULL;
115         uint32_t vlan_tag_flags, cfa_action;
116         bool long_bd = false;
117         unsigned short nr_bds = 0;
118         struct rte_mbuf *m_seg;
119         struct bnxt_sw_tx_bd *tx_buf;
120         static const uint32_t lhint_arr[4] = {
121                 TX_BD_LONG_FLAGS_LHINT_LT512,
122                 TX_BD_LONG_FLAGS_LHINT_LT1K,
123                 TX_BD_LONG_FLAGS_LHINT_LT2K,
124                 TX_BD_LONG_FLAGS_LHINT_LT2K
125         };
126
127         if (unlikely(is_bnxt_in_error(txq->bp)))
128                 return -EIO;
129
130         if (tx_pkt->ol_flags & (PKT_TX_TCP_SEG | PKT_TX_TCP_CKSUM |
131                                 PKT_TX_UDP_CKSUM | PKT_TX_IP_CKSUM |
132                                 PKT_TX_VLAN_PKT | PKT_TX_OUTER_IP_CKSUM |
133                                 PKT_TX_TUNNEL_GRE | PKT_TX_TUNNEL_VXLAN |
134                                 PKT_TX_TUNNEL_GENEVE | PKT_TX_IEEE1588_TMST |
135                                 PKT_TX_QINQ_PKT))
136                 long_bd = true;
137
138         nr_bds = long_bd + tx_pkt->nb_segs;
139         if (unlikely(bnxt_tx_avail(txq) < nr_bds))
140                 return -ENOMEM;
141
142         /* Check if number of Tx descriptors is above HW limit */
143         if (unlikely(nr_bds > BNXT_MAX_TSO_SEGS)) {
144                 PMD_DRV_LOG(ERR,
145                             "Num descriptors %d exceeds HW limit\n", nr_bds);
146                 return -ENOSPC;
147         }
148
149         /* If packet length is less than minimum packet size, pad it */
150         if (unlikely(rte_pktmbuf_pkt_len(tx_pkt) < BNXT_MIN_PKT_SIZE)) {
151                 uint8_t pad = BNXT_MIN_PKT_SIZE - rte_pktmbuf_pkt_len(tx_pkt);
152                 char *seg = rte_pktmbuf_append(tx_pkt, pad);
153
154                 if (!seg) {
155                         PMD_DRV_LOG(ERR,
156                                     "Failed to pad mbuf by %d bytes\n",
157                                     pad);
158                         return -ENOMEM;
159                 }
160
161                 /* Note: data_len, pkt len are updated in rte_pktmbuf_append */
162                 memset(seg, 0, pad);
163         }
164
165         /* Check non zero data_len */
166         RTE_VERIFY(tx_pkt->data_len);
167
168         tx_buf = &txr->tx_buf_ring[txr->tx_prod];
169         tx_buf->mbuf = tx_pkt;
170         tx_buf->nr_bds = nr_bds;
171
172         txbd = &txr->tx_desc_ring[txr->tx_prod];
173         txbd->opaque = *coal_pkts;
174         txbd->flags_type = nr_bds << TX_BD_LONG_FLAGS_BD_CNT_SFT;
175         txbd->flags_type |= TX_BD_SHORT_FLAGS_COAL_NOW;
176         txbd->flags_type |= TX_BD_LONG_FLAGS_NO_CMPL;
177         txbd->len = tx_pkt->data_len;
178         if (tx_pkt->pkt_len >= 2014)
179                 txbd->flags_type |= TX_BD_LONG_FLAGS_LHINT_GTE2K;
180         else
181                 txbd->flags_type |= lhint_arr[tx_pkt->pkt_len >> 9];
182         txbd->address = rte_cpu_to_le_64(rte_mbuf_data_iova(tx_buf->mbuf));
183         *last_txbd = txbd;
184
185         if (long_bd) {
186                 txbd->flags_type |= TX_BD_LONG_TYPE_TX_BD_LONG;
187                 vlan_tag_flags = 0;
188                 cfa_action = 0;
189                 /* HW can accelerate only outer vlan in QinQ mode */
190                 if (tx_buf->mbuf->ol_flags & PKT_TX_QINQ_PKT) {
191                         vlan_tag_flags = TX_BD_LONG_CFA_META_KEY_VLAN_TAG |
192                                 tx_buf->mbuf->vlan_tci_outer;
193                         outer_tpid_bd = txq->bp->outer_tpid_bd &
194                                 BNXT_OUTER_TPID_BD_MASK;
195                         vlan_tag_flags |= outer_tpid_bd;
196                 } else if (tx_buf->mbuf->ol_flags & PKT_TX_VLAN_PKT) {
197                         /* shurd: Should this mask at
198                          * TX_BD_LONG_CFA_META_VLAN_VID_MASK?
199                          */
200                         vlan_tag_flags = TX_BD_LONG_CFA_META_KEY_VLAN_TAG |
201                                 tx_buf->mbuf->vlan_tci;
202                         /* Currently supports 8021Q, 8021AD vlan offloads
203                          * QINQ1, QINQ2, QINQ3 vlan headers are deprecated
204                          */
205                         /* DPDK only supports 802.11q VLAN packets */
206                         vlan_tag_flags |=
207                                         TX_BD_LONG_CFA_META_VLAN_TPID_TPID8100;
208                 }
209
210                 txr->tx_prod = RING_NEXT(txr->tx_ring_struct, txr->tx_prod);
211
212                 txbd1 = (struct tx_bd_long_hi *)
213                                         &txr->tx_desc_ring[txr->tx_prod];
214                 txbd1->lflags = 0;
215                 txbd1->cfa_meta = vlan_tag_flags;
216                 txbd1->cfa_action = cfa_action;
217
218                 if (tx_pkt->ol_flags & PKT_TX_TCP_SEG) {
219                         uint16_t hdr_size;
220
221                         /* TSO */
222                         txbd1->lflags |= TX_BD_LONG_LFLAGS_LSO |
223                                          TX_BD_LONG_LFLAGS_T_IPID;
224                         hdr_size = tx_pkt->l2_len + tx_pkt->l3_len +
225                                         tx_pkt->l4_len;
226                         hdr_size += (tx_pkt->ol_flags & PKT_TX_TUNNEL_MASK) ?
227                                     tx_pkt->outer_l2_len +
228                                     tx_pkt->outer_l3_len : 0;
229                         /* The hdr_size is multiple of 16bit units not 8bit.
230                          * Hence divide by 2.
231                          */
232                         txbd1->hdr_size = hdr_size >> 1;
233                         txbd1->mss = tx_pkt->tso_segsz;
234                         RTE_VERIFY(txbd1->mss);
235
236                 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_IIP_TCP_UDP_CKSUM) ==
237                            PKT_TX_OIP_IIP_TCP_UDP_CKSUM) {
238                         /* Outer IP, Inner IP, Inner TCP/UDP CSO */
239                         txbd1->lflags |= TX_BD_FLG_TIP_IP_TCP_UDP_CHKSUM;
240                         txbd1->mss = 0;
241                 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_IIP_TCP_CKSUM) ==
242                            PKT_TX_OIP_IIP_TCP_CKSUM) {
243                         /* Outer IP, Inner IP, Inner TCP/UDP CSO */
244                         txbd1->lflags |= TX_BD_FLG_TIP_IP_TCP_UDP_CHKSUM;
245                         txbd1->mss = 0;
246                 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_IIP_UDP_CKSUM) ==
247                            PKT_TX_OIP_IIP_UDP_CKSUM) {
248                         /* Outer IP, Inner IP, Inner TCP/UDP CSO */
249                         txbd1->lflags |= TX_BD_FLG_TIP_IP_TCP_UDP_CHKSUM;
250                         txbd1->mss = 0;
251                 } else if ((tx_pkt->ol_flags & PKT_TX_IIP_TCP_UDP_CKSUM) ==
252                            PKT_TX_IIP_TCP_UDP_CKSUM) {
253                         /* (Inner) IP, (Inner) TCP/UDP CSO */
254                         txbd1->lflags |= TX_BD_FLG_IP_TCP_UDP_CHKSUM;
255                         txbd1->mss = 0;
256                 } else if ((tx_pkt->ol_flags & PKT_TX_IIP_UDP_CKSUM) ==
257                            PKT_TX_IIP_UDP_CKSUM) {
258                         /* (Inner) IP, (Inner) TCP/UDP CSO */
259                         txbd1->lflags |= TX_BD_FLG_IP_TCP_UDP_CHKSUM;
260                         txbd1->mss = 0;
261                 } else if ((tx_pkt->ol_flags & PKT_TX_IIP_TCP_CKSUM) ==
262                            PKT_TX_IIP_TCP_CKSUM) {
263                         /* (Inner) IP, (Inner) TCP/UDP CSO */
264                         txbd1->lflags |= TX_BD_FLG_IP_TCP_UDP_CHKSUM;
265                         txbd1->mss = 0;
266                 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_TCP_UDP_CKSUM) ==
267                            PKT_TX_OIP_TCP_UDP_CKSUM) {
268                         /* Outer IP, (Inner) TCP/UDP CSO */
269                         txbd1->lflags |= TX_BD_FLG_TIP_TCP_UDP_CHKSUM;
270                         txbd1->mss = 0;
271                 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_UDP_CKSUM) ==
272                            PKT_TX_OIP_UDP_CKSUM) {
273                         /* Outer IP, (Inner) TCP/UDP CSO */
274                         txbd1->lflags |= TX_BD_FLG_TIP_TCP_UDP_CHKSUM;
275                         txbd1->mss = 0;
276                 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_TCP_CKSUM) ==
277                            PKT_TX_OIP_TCP_CKSUM) {
278                         /* Outer IP, (Inner) TCP/UDP CSO */
279                         txbd1->lflags |= TX_BD_FLG_TIP_TCP_UDP_CHKSUM;
280                         txbd1->mss = 0;
281                 } else if ((tx_pkt->ol_flags & PKT_TX_OIP_IIP_CKSUM) ==
282                            PKT_TX_OIP_IIP_CKSUM) {
283                         /* Outer IP, Inner IP CSO */
284                         txbd1->lflags |= TX_BD_FLG_TIP_IP_CHKSUM;
285                         txbd1->mss = 0;
286                 } else if ((tx_pkt->ol_flags & PKT_TX_TCP_UDP_CKSUM) ==
287                            PKT_TX_TCP_UDP_CKSUM) {
288                         /* TCP/UDP CSO */
289                         txbd1->lflags |= TX_BD_LONG_LFLAGS_TCP_UDP_CHKSUM;
290                         txbd1->mss = 0;
291                 } else if ((tx_pkt->ol_flags & PKT_TX_TCP_CKSUM) ==
292                            PKT_TX_TCP_CKSUM) {
293                         /* TCP/UDP CSO */
294                         txbd1->lflags |= TX_BD_LONG_LFLAGS_TCP_UDP_CHKSUM;
295                         txbd1->mss = 0;
296                 } else if ((tx_pkt->ol_flags & PKT_TX_UDP_CKSUM) ==
297                            PKT_TX_UDP_CKSUM) {
298                         /* TCP/UDP CSO */
299                         txbd1->lflags |= TX_BD_LONG_LFLAGS_TCP_UDP_CHKSUM;
300                         txbd1->mss = 0;
301                 } else if ((tx_pkt->ol_flags & PKT_TX_IP_CKSUM) ==
302                            PKT_TX_IP_CKSUM) {
303                         /* IP CSO */
304                         txbd1->lflags |= TX_BD_LONG_LFLAGS_IP_CHKSUM;
305                         txbd1->mss = 0;
306                 } else if ((tx_pkt->ol_flags & PKT_TX_OUTER_IP_CKSUM) ==
307                            PKT_TX_OUTER_IP_CKSUM) {
308                         /* IP CSO */
309                         txbd1->lflags |= TX_BD_LONG_LFLAGS_T_IP_CHKSUM;
310                         txbd1->mss = 0;
311                 } else if ((tx_pkt->ol_flags & PKT_TX_IEEE1588_TMST) ==
312                            PKT_TX_IEEE1588_TMST) {
313                         /* PTP */
314                         txbd1->lflags |= TX_BD_LONG_LFLAGS_STAMP;
315                         txbd1->mss = 0;
316                 }
317         } else {
318                 txbd->flags_type |= TX_BD_SHORT_TYPE_TX_BD_SHORT;
319         }
320
321         m_seg = tx_pkt->next;
322         while (m_seg) {
323                 /* Check non zero data_len */
324                 RTE_VERIFY(m_seg->data_len);
325                 txr->tx_prod = RING_NEXT(txr->tx_ring_struct, txr->tx_prod);
326                 tx_buf = &txr->tx_buf_ring[txr->tx_prod];
327                 tx_buf->mbuf = m_seg;
328
329                 txbd = &txr->tx_desc_ring[txr->tx_prod];
330                 txbd->address = rte_cpu_to_le_64(rte_mbuf_data_iova(m_seg));
331                 txbd->flags_type = TX_BD_SHORT_TYPE_TX_BD_SHORT;
332                 txbd->len = m_seg->data_len;
333
334                 m_seg = m_seg->next;
335         }
336
337         txbd->flags_type |= TX_BD_LONG_FLAGS_PACKET_END;
338
339         txr->tx_prod = RING_NEXT(txr->tx_ring_struct, txr->tx_prod);
340
341         return 0;
342 }
343
344 static void bnxt_tx_cmp(struct bnxt_tx_queue *txq, int nr_pkts)
345 {
346         struct bnxt_tx_ring_info *txr = txq->tx_ring;
347         struct rte_mempool *pool = NULL;
348         struct rte_mbuf **free = txq->free;
349         uint16_t cons = txr->tx_cons;
350         unsigned int blk = 0;
351         int i, j;
352
353         for (i = 0; i < nr_pkts; i++) {
354                 struct rte_mbuf *mbuf;
355                 struct bnxt_sw_tx_bd *tx_buf = &txr->tx_buf_ring[cons];
356                 unsigned short nr_bds = tx_buf->nr_bds;
357
358                 for (j = 0; j < nr_bds; j++) {
359                         mbuf = tx_buf->mbuf;
360                         tx_buf->mbuf = NULL;
361                         cons = RING_NEXT(txr->tx_ring_struct, cons);
362                         tx_buf = &txr->tx_buf_ring[cons];
363                         if (!mbuf)      /* long_bd's tx_buf ? */
364                                 continue;
365
366                         mbuf = rte_pktmbuf_prefree_seg(mbuf);
367                         if (unlikely(!mbuf))
368                                 continue;
369
370                         /* EW - no need to unmap DMA memory? */
371
372                         if (likely(mbuf->pool == pool)) {
373                                 /* Add mbuf to the bulk free array */
374                                 free[blk++] = mbuf;
375                         } else {
376                                 /* Found an mbuf from a different pool. Free
377                                  * mbufs accumulated so far to the previous
378                                  * pool
379                                  */
380                                 if (likely(pool != NULL))
381                                         rte_mempool_put_bulk(pool,
382                                                              (void *)free,
383                                                              blk);
384
385                                 /* Start accumulating mbufs in a new pool */
386                                 free[0] = mbuf;
387                                 pool = mbuf->pool;
388                                 blk = 1;
389                         }
390                 }
391         }
392         if (blk)
393                 rte_mempool_put_bulk(pool, (void *)free, blk);
394
395         txr->tx_cons = cons;
396 }
397
398 static int bnxt_handle_tx_cp(struct bnxt_tx_queue *txq)
399 {
400         struct bnxt_cp_ring_info *cpr = txq->cp_ring;
401         uint32_t raw_cons = cpr->cp_raw_cons;
402         uint32_t cons;
403         uint32_t nb_tx_pkts = 0;
404         struct tx_cmpl *txcmp;
405         struct cmpl_base *cp_desc_ring = cpr->cp_desc_ring;
406         struct bnxt_ring *cp_ring_struct = cpr->cp_ring_struct;
407         uint32_t ring_mask = cp_ring_struct->ring_mask;
408         uint32_t opaque = 0;
409
410         if (bnxt_tx_bds_in_hw(txq) < txq->tx_free_thresh)
411                 return 0;
412
413         do {
414                 cons = RING_CMPL(ring_mask, raw_cons);
415                 txcmp = (struct tx_cmpl *)&cpr->cp_desc_ring[cons];
416                 rte_prefetch_non_temporal(&cp_desc_ring[(cons + 2) &
417                                                         ring_mask]);
418
419                 if (!CMPL_VALID(txcmp, cpr->valid))
420                         break;
421                 opaque = rte_cpu_to_le_32(txcmp->opaque);
422                 NEXT_CMPL(cpr, cons, cpr->valid, 1);
423                 rte_prefetch0(&cp_desc_ring[cons]);
424
425                 if (CMP_TYPE(txcmp) == TX_CMPL_TYPE_TX_L2)
426                         nb_tx_pkts += opaque;
427                 else
428                         RTE_LOG_DP(ERR, PMD,
429                                         "Unhandled CMP type %02x\n",
430                                         CMP_TYPE(txcmp));
431                 raw_cons = cons;
432         } while (nb_tx_pkts < ring_mask);
433
434         if (nb_tx_pkts) {
435                 bnxt_tx_cmp(txq, nb_tx_pkts);
436                 cpr->cp_raw_cons = raw_cons;
437                 bnxt_db_cq(cpr);
438         }
439
440         return nb_tx_pkts;
441 }
442
443 uint16_t bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
444                                uint16_t nb_pkts)
445 {
446         int rc;
447         uint16_t nb_tx_pkts = 0;
448         uint16_t coal_pkts = 0;
449         struct bnxt_tx_queue *txq = tx_queue;
450         struct tx_bd_long *last_txbd = NULL;
451
452         /* Handle TX completions */
453         bnxt_handle_tx_cp(txq);
454
455         /* Tx queue was stopped; wait for it to be restarted */
456         if (unlikely(!txq->tx_started)) {
457                 PMD_DRV_LOG(DEBUG, "Tx q stopped;return\n");
458                 return 0;
459         }
460
461         /* Handle TX burst request */
462         for (nb_tx_pkts = 0; nb_tx_pkts < nb_pkts; nb_tx_pkts++) {
463                 coal_pkts++;
464                 rc = bnxt_start_xmit(tx_pkts[nb_tx_pkts], txq,
465                                      &coal_pkts, &last_txbd);
466
467                 if (unlikely(rc))
468                         break;
469         }
470
471         if (likely(nb_tx_pkts)) {
472                 /* Request a completion on the last packet */
473                 last_txbd->flags_type &= ~TX_BD_LONG_FLAGS_NO_CMPL;
474                 bnxt_db_write(&txq->tx_ring->tx_db, txq->tx_ring->tx_prod);
475         }
476
477         return nb_tx_pkts;
478 }
479
480 /*
481  * Dummy DPDK callback for TX.
482  *
483  * This function is used to temporarily replace the real callback during
484  * unsafe control operations on the queue, or in case of error.
485  */
486 uint16_t
487 bnxt_dummy_xmit_pkts(void *tx_queue __rte_unused,
488                      struct rte_mbuf **tx_pkts __rte_unused,
489                      uint16_t nb_pkts __rte_unused)
490 {
491         return 0;
492 }
493
494 int bnxt_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
495 {
496         struct bnxt *bp = dev->data->dev_private;
497         struct bnxt_tx_queue *txq = bp->tx_queues[tx_queue_id];
498         int rc = 0;
499
500         rc = is_bnxt_in_error(bp);
501         if (rc)
502                 return rc;
503
504         dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
505         txq->tx_started = true;
506         PMD_DRV_LOG(DEBUG, "Tx queue started\n");
507
508         return 0;
509 }
510
511 int bnxt_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
512 {
513         struct bnxt *bp = dev->data->dev_private;
514         struct bnxt_tx_queue *txq = bp->tx_queues[tx_queue_id];
515         int rc = 0;
516
517         rc = is_bnxt_in_error(bp);
518         if (rc)
519                 return rc;
520
521         /* Handle TX completions */
522         bnxt_handle_tx_cp(txq);
523
524         dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
525         txq->tx_started = false;
526         PMD_DRV_LOG(DEBUG, "Tx queue stopped\n");
527
528         return 0;
529 }