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