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