net/af_packet: make qdisc bypass configurable
[dpdk.git] / drivers / net / ark / ark_ethdev_rx.c
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright (c) 2015-2017 Atomic Rules LLC
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #include <unistd.h>
35
36 #include "ark_ethdev_rx.h"
37 #include "ark_global.h"
38 #include "ark_logs.h"
39 #include "ark_mpu.h"
40 #include "ark_udm.h"
41
42 #define ARK_RX_META_SIZE 32
43 #define ARK_RX_META_OFFSET (RTE_PKTMBUF_HEADROOM - ARK_RX_META_SIZE)
44 #define ARK_RX_MAX_NOCHAIN (RTE_MBUF_DEFAULT_DATAROOM)
45
46 /* Forward declarations */
47 struct ark_rx_queue;
48 struct ark_rx_meta;
49
50 static void dump_mbuf_data(struct rte_mbuf *mbuf, uint16_t lo, uint16_t hi);
51 static void ark_ethdev_rx_dump(const char *name, struct ark_rx_queue *queue);
52 static uint32_t eth_ark_rx_jumbo(struct ark_rx_queue *queue,
53                                  struct ark_rx_meta *meta,
54                                  struct rte_mbuf *mbuf0,
55                                  uint32_t cons_index);
56 static inline int eth_ark_rx_seed_mbufs(struct ark_rx_queue *queue);
57
58 /* ************************************************************************* */
59 struct ark_rx_queue {
60         /* array of mbufs to populate */
61         struct rte_mbuf **reserve_q;
62         /* array of physical addresses of the mbuf data pointer */
63         /* This point is a virtual address */
64         phys_addr_t *paddress_q;
65         struct rte_mempool *mb_pool;
66
67         struct ark_udm_t *udm;
68         struct ark_mpu_t *mpu;
69
70         uint32_t queue_size;
71         uint32_t queue_mask;
72
73         uint32_t seed_index;            /* step 1 set with empty mbuf */
74         uint32_t cons_index;            /* step 3 consumed by driver */
75
76         /* The queue Id is used to identify the HW Q */
77         uint16_t phys_qid;
78
79         /* The queue Index is used within the dpdk device structures */
80         uint16_t queue_index;
81
82         uint32_t pad1;
83
84         /* separate cache line */
85         /* second cache line - fields only used in slow path */
86         MARKER cacheline1 __rte_cache_min_aligned;
87
88         volatile uint32_t prod_index;   /* step 2 filled by FPGA */
89 } __rte_cache_aligned;
90
91
92 /* ************************************************************************* */
93 static int
94 eth_ark_rx_hw_setup(struct rte_eth_dev *dev,
95                     struct ark_rx_queue *queue,
96                     uint16_t rx_queue_id __rte_unused, uint16_t rx_queue_idx)
97 {
98         phys_addr_t queue_base;
99         phys_addr_t phys_addr_q_base;
100         phys_addr_t phys_addr_prod_index;
101
102         queue_base = rte_malloc_virt2phy(queue);
103         phys_addr_prod_index = queue_base +
104                 offsetof(struct ark_rx_queue, prod_index);
105
106         phys_addr_q_base = rte_malloc_virt2phy(queue->paddress_q);
107
108         /* Verify HW */
109         if (ark_mpu_verify(queue->mpu, sizeof(phys_addr_t))) {
110                 PMD_DRV_LOG(ERR, "Illegal configuration rx queue\n");
111                 return -1;
112         }
113
114         /* Stop and Reset and configure MPU */
115         ark_mpu_configure(queue->mpu, phys_addr_q_base, queue->queue_size, 0);
116
117         ark_udm_write_addr(queue->udm, phys_addr_prod_index);
118
119         /* advance the valid pointer, but don't start until the queue starts */
120         ark_mpu_reset_stats(queue->mpu);
121
122         /* The seed is the producer index for the HW */
123         ark_mpu_set_producer(queue->mpu, queue->seed_index);
124         dev->data->rx_queue_state[rx_queue_idx] = RTE_ETH_QUEUE_STATE_STOPPED;
125
126         return 0;
127 }
128
129 static inline void
130 eth_ark_rx_update_cons_index(struct ark_rx_queue *queue, uint32_t cons_index)
131 {
132         queue->cons_index = cons_index;
133         eth_ark_rx_seed_mbufs(queue);
134         ark_mpu_set_producer(queue->mpu, queue->seed_index);
135 }
136
137 /* ************************************************************************* */
138 int
139 eth_ark_dev_rx_queue_setup(struct rte_eth_dev *dev,
140                            uint16_t queue_idx,
141                            uint16_t nb_desc,
142                            unsigned int socket_id,
143                            const struct rte_eth_rxconf *rx_conf,
144                            struct rte_mempool *mb_pool)
145 {
146         static int warning1;            /* = 0 */
147         struct ark_adapter *ark = (struct ark_adapter *)dev->data->dev_private;
148
149         struct ark_rx_queue *queue;
150         uint32_t i;
151         int status;
152
153         /* Future works: divide the Q's evenly with multi-ports */
154         int port = dev->data->port_id;
155         int qidx = port + queue_idx;
156
157         /* We may already be setup, free memory prior to re-allocation */
158         if (dev->data->rx_queues[queue_idx] != NULL) {
159                 eth_ark_dev_rx_queue_release(dev->data->rx_queues[queue_idx]);
160                 dev->data->rx_queues[queue_idx] = NULL;
161         }
162
163         if (rx_conf != NULL && warning1 == 0) {
164                 warning1 = 1;
165                 PMD_DRV_LOG(INFO,
166                             "Arkville ignores rte_eth_rxconf argument.\n");
167         }
168
169         if (RTE_PKTMBUF_HEADROOM < ARK_RX_META_SIZE) {
170                 PMD_DRV_LOG(ERR,
171                             "Error: DPDK Arkville requires head room > %d bytes (%s)\n",
172                             ARK_RX_META_SIZE, __func__);
173                 return -1;              /* ERROR CODE */
174         }
175
176         if (!rte_is_power_of_2(nb_desc)) {
177                 PMD_DRV_LOG(ERR,
178                             "DPDK Arkville configuration queue size must be power of two %u (%s)\n",
179                             nb_desc, __func__);
180                 return -1;              /* ERROR CODE */
181         }
182
183         /* Allocate queue struct */
184         queue = rte_zmalloc_socket("Ark_rxqueue",
185                                    sizeof(struct ark_rx_queue),
186                                    64,
187                                    socket_id);
188         if (queue == 0) {
189                 PMD_DRV_LOG(ERR, "Failed to allocate memory in %s\n", __func__);
190                 return -ENOMEM;
191         }
192
193         /* NOTE zmalloc is used, no need to 0 indexes, etc. */
194         queue->mb_pool = mb_pool;
195         queue->phys_qid = qidx;
196         queue->queue_index = queue_idx;
197         queue->queue_size = nb_desc;
198         queue->queue_mask = nb_desc - 1;
199
200         queue->reserve_q =
201                 rte_zmalloc_socket("Ark_rx_queue mbuf",
202                                    nb_desc * sizeof(struct rte_mbuf *),
203                                    64,
204                                    socket_id);
205         queue->paddress_q =
206                 rte_zmalloc_socket("Ark_rx_queue paddr",
207                                    nb_desc * sizeof(phys_addr_t),
208                                    64,
209                                    socket_id);
210
211         if (queue->reserve_q == 0 || queue->paddress_q == 0) {
212                 PMD_DRV_LOG(ERR,
213                             "Failed to allocate queue memory in %s\n",
214                             __func__);
215                 rte_free(queue->reserve_q);
216                 rte_free(queue->paddress_q);
217                 rte_free(queue);
218                 return -ENOMEM;
219         }
220
221         dev->data->rx_queues[queue_idx] = queue;
222         queue->udm = RTE_PTR_ADD(ark->udm.v, qidx * ARK_UDM_QOFFSET);
223         queue->mpu = RTE_PTR_ADD(ark->mpurx.v, qidx * ARK_MPU_QOFFSET);
224
225         /* populate mbuf reserve */
226         status = eth_ark_rx_seed_mbufs(queue);
227
228         /* MPU Setup */
229         if (status == 0)
230                 status = eth_ark_rx_hw_setup(dev, queue, qidx, queue_idx);
231
232         if (unlikely(status != 0)) {
233                 struct rte_mbuf *mbuf;
234
235                 PMD_DRV_LOG(ERR, "Failed to initialize RX queue %d %s\n",
236                             qidx,
237                             __func__);
238                 /* Free the mbufs allocated */
239                 for (i = 0, mbuf = queue->reserve_q[0];
240                      i < nb_desc; ++i, mbuf++) {
241                         rte_pktmbuf_free(mbuf);
242                 }
243                 rte_free(queue->reserve_q);
244                 rte_free(queue->paddress_q);
245                 rte_free(queue);
246                 return -1;              /* ERROR CODE */
247         }
248
249         return 0;
250 }
251
252 /* ************************************************************************* */
253 uint16_t
254 eth_ark_recv_pkts_noop(void *rx_queue __rte_unused,
255                        struct rte_mbuf **rx_pkts __rte_unused,
256                        uint16_t nb_pkts __rte_unused)
257 {
258         return 0;
259 }
260
261 /* ************************************************************************* */
262 uint16_t
263 eth_ark_recv_pkts(void *rx_queue,
264                   struct rte_mbuf **rx_pkts,
265                   uint16_t nb_pkts)
266 {
267         struct ark_rx_queue *queue;
268         register uint32_t cons_index, prod_index;
269         uint16_t nb;
270         struct rte_mbuf *mbuf;
271         struct ark_rx_meta *meta;
272
273         queue = (struct ark_rx_queue *)rx_queue;
274         if (unlikely(queue == 0))
275                 return 0;
276         if (unlikely(nb_pkts == 0))
277                 return 0;
278         prod_index = queue->prod_index;
279         cons_index = queue->cons_index;
280         nb = 0;
281
282         while (prod_index != cons_index) {
283                 mbuf = queue->reserve_q[cons_index & queue->queue_mask];
284                 /* prefetch mbuf */
285                 rte_mbuf_prefetch_part1(mbuf);
286                 rte_mbuf_prefetch_part2(mbuf);
287
288                 /* META DATA embedded in headroom */
289                 meta = RTE_PTR_ADD(mbuf->buf_addr, ARK_RX_META_OFFSET);
290
291                 mbuf->port = meta->port;
292                 mbuf->pkt_len = meta->pkt_len;
293                 mbuf->data_len = meta->pkt_len;
294                 mbuf->timestamp = meta->timestamp;
295                 mbuf->udata64 = meta->user_data;
296
297                 if (ARK_RX_DEBUG) {     /* debug sanity checks */
298                         if ((meta->pkt_len > (1024 * 16)) ||
299                             (meta->pkt_len == 0)) {
300                                 PMD_RX_LOG(DEBUG, "RX: Bad Meta Q: %u"
301                                            " cons: %" PRIU32
302                                            " prod: %" PRIU32
303                                            " seed_index %" PRIU32
304                                            "\n",
305                                            queue->phys_qid,
306                                            cons_index,
307                                            queue->prod_index,
308                                            queue->seed_index);
309
310
311                                 PMD_RX_LOG(DEBUG, "       :  UDM"
312                                            " prod: %" PRIU32
313                                            " len: %u\n",
314                                            queue->udm->rt_cfg.prod_idx,
315                                            meta->pkt_len);
316                                 ark_mpu_dump(queue->mpu,
317                                              "    ",
318                                              queue->phys_qid);
319                                 dump_mbuf_data(mbuf, 0, 256);
320                                 /* its FUBAR so fix it */
321                                 mbuf->pkt_len = 63;
322                                 meta->pkt_len = 63;
323                         }
324                         /* seqn is only set under debug */
325                         mbuf->seqn = cons_index;
326                 }
327
328                 if (unlikely(meta->pkt_len > ARK_RX_MAX_NOCHAIN))
329                         cons_index = eth_ark_rx_jumbo
330                                 (queue, meta, mbuf, cons_index + 1);
331                 else
332                         cons_index += 1;
333
334                 rx_pkts[nb] = mbuf;
335                 nb++;
336                 if (nb >= nb_pkts)
337                         break;
338         }
339
340         if (unlikely(nb != 0))
341                 /* report next free to FPGA */
342                 eth_ark_rx_update_cons_index(queue, cons_index);
343
344         return nb;
345 }
346
347 /* ************************************************************************* */
348 static uint32_t
349 eth_ark_rx_jumbo(struct ark_rx_queue *queue,
350                  struct ark_rx_meta *meta,
351                  struct rte_mbuf *mbuf0,
352                  uint32_t cons_index)
353 {
354         struct rte_mbuf *mbuf_prev;
355         struct rte_mbuf *mbuf;
356
357         uint16_t remaining;
358         uint16_t data_len;
359         uint8_t segments;
360
361         /* first buf populated by called */
362         mbuf_prev = mbuf0;
363         segments = 1;
364         data_len = RTE_MIN(meta->pkt_len, RTE_MBUF_DEFAULT_DATAROOM);
365         remaining = meta->pkt_len - data_len;
366         mbuf0->data_len = data_len;
367
368         /* HW guarantees that the data does not exceed prod_index! */
369         while (remaining != 0) {
370                 data_len = RTE_MIN(remaining,
371                                    RTE_MBUF_DEFAULT_DATAROOM +
372                                    RTE_PKTMBUF_HEADROOM);
373
374                 remaining -= data_len;
375                 segments += 1;
376
377                 mbuf = queue->reserve_q[cons_index & queue->queue_mask];
378                 mbuf_prev->next = mbuf;
379                 mbuf_prev = mbuf;
380                 mbuf->data_len = data_len;
381                 mbuf->data_off = 0;
382                 if (ARK_RX_DEBUG)
383                         mbuf->seqn = cons_index;        /* for debug only */
384
385                 cons_index += 1;
386         }
387
388         mbuf0->nb_segs = segments;
389         return cons_index;
390 }
391
392 /* Drain the internal queue allowing hw to clear out. */
393 static void
394 eth_ark_rx_queue_drain(struct ark_rx_queue *queue)
395 {
396         register uint32_t cons_index;
397         struct rte_mbuf *mbuf;
398
399         cons_index = queue->cons_index;
400
401         /* NOT performance optimized, since this is a one-shot call */
402         while ((cons_index ^ queue->prod_index) & queue->queue_mask) {
403                 mbuf = queue->reserve_q[cons_index & queue->queue_mask];
404                 rte_pktmbuf_free(mbuf);
405                 cons_index++;
406                 eth_ark_rx_update_cons_index(queue, cons_index);
407         }
408 }
409
410 uint32_t
411 eth_ark_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_id)
412 {
413         struct ark_rx_queue *queue;
414
415         queue = dev->data->rx_queues[queue_id];
416         return (queue->prod_index - queue->cons_index); /* mod arith */
417 }
418
419 /* ************************************************************************* */
420 int
421 eth_ark_rx_start_queue(struct rte_eth_dev *dev, uint16_t queue_id)
422 {
423         struct ark_rx_queue *queue;
424
425         queue = dev->data->rx_queues[queue_id];
426         if (queue == 0)
427                 return -1;
428
429         dev->data->rx_queue_state[queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
430
431         ark_mpu_set_producer(queue->mpu, queue->seed_index);
432         ark_mpu_start(queue->mpu);
433
434         ark_udm_queue_enable(queue->udm, 1);
435
436         return 0;
437 }
438
439 /* ************************************************************************* */
440
441 /* Queue can be restarted.   data remains
442  */
443 int
444 eth_ark_rx_stop_queue(struct rte_eth_dev *dev, uint16_t queue_id)
445 {
446         struct ark_rx_queue *queue;
447
448         queue = dev->data->rx_queues[queue_id];
449         if (queue == 0)
450                 return -1;
451
452         ark_udm_queue_enable(queue->udm, 0);
453
454         dev->data->rx_queue_state[queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
455
456         return 0;
457 }
458
459 /* ************************************************************************* */
460 static inline int
461 eth_ark_rx_seed_mbufs(struct ark_rx_queue *queue)
462 {
463         uint32_t limit = queue->cons_index + queue->queue_size;
464         uint32_t seed_index = queue->seed_index;
465
466         uint32_t count = 0;
467         uint32_t seed_m = queue->seed_index & queue->queue_mask;
468
469         uint32_t nb = limit - seed_index;
470
471         /* Handle wrap around -- remainder is filled on the next call */
472         if (unlikely(seed_m + nb > queue->queue_size))
473                 nb = queue->queue_size - seed_m;
474
475         struct rte_mbuf **mbufs = &queue->reserve_q[seed_m];
476         int status = rte_pktmbuf_alloc_bulk(queue->mb_pool, mbufs, nb);
477
478         if (unlikely(status != 0))
479                 return -1;
480
481         if (ARK_RX_DEBUG) {             /* DEBUG */
482                 while (count != nb) {
483                         struct rte_mbuf *mbuf_init =
484                                 queue->reserve_q[seed_m + count];
485
486                         memset(mbuf_init->buf_addr, -1, 512);
487                         *((uint32_t *)mbuf_init->buf_addr) =
488                                 seed_index + count;
489                         *(uint16_t *)RTE_PTR_ADD(mbuf_init->buf_addr, 4) =
490                                 queue->phys_qid;
491                         count++;
492                 }
493                 count = 0;
494         } /* DEBUG */
495         queue->seed_index += nb;
496
497         /* Duff's device https://en.wikipedia.org/wiki/Duff's_device */
498         switch (nb % 4) {
499         case 0:
500                 while (count != nb) {
501                         queue->paddress_q[seed_m++] =
502                                 (*mbufs++)->buf_physaddr;
503                         count++;
504                 /* FALLTHROUGH */
505         case 3:
506                 queue->paddress_q[seed_m++] =
507                         (*mbufs++)->buf_physaddr;
508                 count++;
509                 /* FALLTHROUGH */
510         case 2:
511                 queue->paddress_q[seed_m++] =
512                         (*mbufs++)->buf_physaddr;
513                 count++;
514                 /* FALLTHROUGH */
515         case 1:
516                 queue->paddress_q[seed_m++] =
517                         (*mbufs++)->buf_physaddr;
518                 count++;
519                 /* FALLTHROUGH */
520
521                 } /* while (count != nb) */
522         } /* switch */
523
524         return 0;
525 }
526
527 void
528 eth_ark_rx_dump_queue(struct rte_eth_dev *dev, uint16_t queue_id,
529                       const char *msg)
530 {
531         struct ark_rx_queue *queue;
532
533         queue = dev->data->rx_queues[queue_id];
534
535         ark_ethdev_rx_dump(msg, queue);
536 }
537
538 /* ************************************************************************* */
539 /* Call on device closed no user API, queue is stopped */
540 void
541 eth_ark_dev_rx_queue_release(void *vqueue)
542 {
543         struct ark_rx_queue *queue;
544         uint32_t i;
545
546         queue = (struct ark_rx_queue *)vqueue;
547         if (queue == 0)
548                 return;
549
550         ark_udm_queue_enable(queue->udm, 0);
551         /* Stop the MPU since pointer are going away */
552         ark_mpu_stop(queue->mpu);
553
554         /* Need to clear out mbufs here, dropping packets along the way */
555         eth_ark_rx_queue_drain(queue);
556
557         for (i = 0; i < queue->queue_size; ++i)
558                 rte_pktmbuf_free(queue->reserve_q[i]);
559
560         rte_free(queue->reserve_q);
561         rte_free(queue->paddress_q);
562         rte_free(queue);
563 }
564
565 void
566 eth_rx_queue_stats_get(void *vqueue, struct rte_eth_stats *stats)
567 {
568         struct ark_rx_queue *queue;
569         struct ark_udm_t *udm;
570
571         queue = vqueue;
572         if (queue == 0)
573                 return;
574         udm = queue->udm;
575
576         uint64_t ibytes = ark_udm_bytes(udm);
577         uint64_t ipackets = ark_udm_packets(udm);
578         uint64_t idropped = ark_udm_dropped(queue->udm);
579
580         stats->q_ipackets[queue->queue_index] = ipackets;
581         stats->q_ibytes[queue->queue_index] = ibytes;
582         stats->q_errors[queue->queue_index] = idropped;
583         stats->ipackets += ipackets;
584         stats->ibytes += ibytes;
585         stats->imissed += idropped;
586 }
587
588 void
589 eth_rx_queue_stats_reset(void *vqueue)
590 {
591         struct ark_rx_queue *queue;
592
593         queue = vqueue;
594         if (queue == 0)
595                 return;
596
597         ark_mpu_reset_stats(queue->mpu);
598         ark_udm_queue_stats_reset(queue->udm);
599 }
600
601 void
602 eth_ark_udm_force_close(struct rte_eth_dev *dev)
603 {
604         struct ark_adapter *ark = (struct ark_adapter *)dev->data->dev_private;
605         struct ark_rx_queue *queue;
606         uint32_t index;
607         uint16_t i;
608
609         if (!ark_udm_is_flushed(ark->udm.v)) {
610                 /* restart the MPUs */
611                 PMD_DRV_LOG(ERR, "ARK: %s UDM not flushed\n", __func__);
612                 for (i = 0; i < dev->data->nb_rx_queues; i++) {
613                         queue = (struct ark_rx_queue *)dev->data->rx_queues[i];
614                         if (queue == 0)
615                                 continue;
616
617                         ark_mpu_start(queue->mpu);
618                         /* Add some buffers */
619                         index = 100000 + queue->seed_index;
620                         ark_mpu_set_producer(queue->mpu, index);
621                 }
622                 /* Wait to allow data to pass */
623                 usleep(100);
624
625                 PMD_DEBUG_LOG(DEBUG, "UDM forced flush attempt, stopped = %d\n",
626                                 ark_udm_is_flushed(ark->udm.v));
627         }
628         ark_udm_reset(ark->udm.v);
629 }
630
631 static void
632 ark_ethdev_rx_dump(const char *name, struct ark_rx_queue *queue)
633 {
634         if (queue == NULL)
635                 return;
636         PMD_DEBUG_LOG(DEBUG, "RX QUEUE %d -- %s", queue->phys_qid, name);
637         PMD_DEBUG_LOG(DEBUG, ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 "\n",
638                         "queue_size", queue->queue_size,
639                         "seed_index", queue->seed_index,
640                         "prod_index", queue->prod_index,
641                         "cons_index", queue->cons_index);
642
643         ark_mpu_dump(queue->mpu, name, queue->phys_qid);
644         ark_mpu_dump_setup(queue->mpu, queue->phys_qid);
645         ark_udm_dump(queue->udm, name);
646         ark_udm_dump_setup(queue->udm, queue->phys_qid);
647 }
648
649 /* Only used in debug.
650  * This function is a raw memory dump of a portion of an mbuf's memory
651  * region.  The usual function, rte_pktmbuf_dump() only shows data
652  * with respect to the data_off field.  This function show data
653  * anywhere in the mbuf's buffer.  This is useful for examining
654  * data in the headroom or tailroom portion of an mbuf.
655  */
656 static void
657 dump_mbuf_data(struct rte_mbuf *mbuf, uint16_t lo, uint16_t hi)
658 {
659         uint16_t i, j;
660
661         PMD_DRV_LOG(INFO, " MBUF: %p len %d, off: %d, seq: %" PRIU32 "\n", mbuf,
662                 mbuf->pkt_len, mbuf->data_off, mbuf->seqn);
663         for (i = lo; i < hi; i += 16) {
664                 uint8_t *dp = RTE_PTR_ADD(mbuf->buf_addr, i);
665
666                 PMD_DRV_LOG(INFO, "  %6d:  ", i);
667                 for (j = 0; j < 16; j++)
668                         PMD_DRV_LOG(INFO, " %02x", dp[j]);
669
670                 PMD_DRV_LOG(INFO, "\n");
671         }
672 }