Please ignore this version. I will resend the patch.

> -----Original Message-----
> From: Amit Prakash Shukla <amitpraka...@marvell.com>
> Sent: Thursday, February 9, 2023 3:26 PM
> To: Reshma Pattan <reshma.pat...@intel.com>; Stephen Hemminger
> <step...@networkplumber.org>
> Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran <jer...@marvell.com>;
> david.march...@redhat.com; Amit Prakash Shukla
> <amitpraka...@marvell.com>
> Subject: [PATCH v6 1/4] pcapng: comment option support for epb
> 
> This change enhances rte_pcapng_copy to have comment in enhanced
> packet block.
> 
> Signed-off-by: Amit Prakash Shukla <amitpraka...@marvell.com>
> ---
> v2:
>  - Fixed code style issue
>  - Fixed CI compilation issue on github-robot
> 
> v3:
>  - Code review suggestion from Stephen
>  - Fixed potential memory leak
> 
> v4:
>  - Code review suggestion from Jerin
> 
> v5:
>  - Code review suggestion from Jerin
> 
> v6:
>  - Squashing test graph param initialize fix
> 
>  app/test/test_pcapng.c                 |  4 ++--
>  doc/guides/rel_notes/release_23_03.rst |  2 ++
>  lib/pcapng/rte_pcapng.c                | 10 +++++++++-
>  lib/pcapng/rte_pcapng.h                |  4 +++-
>  lib/pdump/rte_pdump.c                  |  2 +-
>  5 files changed, 17 insertions(+), 5 deletions(-)
> 
> diff --git a/app/test/test_pcapng.c b/app/test/test_pcapng.c index
> edba46d1fe..b8429a02f1 100644
> --- a/app/test/test_pcapng.c
> +++ b/app/test/test_pcapng.c
> @@ -146,7 +146,7 @@ test_write_packets(void)
>               struct rte_mbuf *mc;
> 
>               mc = rte_pcapng_copy(port_id, 0, orig, mp, pkt_len,
> -                             rte_get_tsc_cycles(), 0);
> +                             rte_get_tsc_cycles(), 0, NULL);
>               if (mc == NULL) {
>                       fprintf(stderr, "Cannot copy packet\n");
>                       return -1;
> @@ -262,7 +262,7 @@ test_write_over_limit_iov_max(void)
>               struct rte_mbuf *mc;
> 
>               mc = rte_pcapng_copy(port_id, 0, orig, mp, pkt_len,
> -                             rte_get_tsc_cycles(), 0);
> +                             rte_get_tsc_cycles(), 0, NULL);
>               if (mc == NULL) {
>                       fprintf(stderr, "Cannot copy packet\n");
>                       return -1;
> diff --git a/doc/guides/rel_notes/release_23_03.rst
> b/doc/guides/rel_notes/release_23_03.rst
> index 1fa101c420..bb435dde32 100644
> --- a/doc/guides/rel_notes/release_23_03.rst
> +++ b/doc/guides/rel_notes/release_23_03.rst
> @@ -116,6 +116,8 @@ API Changes
>     Also, make sure to start the actual text at the margin.
>     =======================================================
> 
> +* Experimental function ``rte_pcapng_copy`` was updated to support
> +comment
> +  section in enhanced packet block in pcapng library.
> 
>  ABI Changes
>  -----------
> diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c index
> ea004939e6..65c8c77fa4 100644
> --- a/lib/pcapng/rte_pcapng.c
> +++ b/lib/pcapng/rte_pcapng.c
> @@ -466,7 +466,8 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue,
>               const struct rte_mbuf *md,
>               struct rte_mempool *mp,
>               uint32_t length, uint64_t cycles,
> -             enum rte_pcapng_direction direction)
> +             enum rte_pcapng_direction direction,
> +             const char *comment)
>  {
>       struct pcapng_enhance_packet_block *epb;
>       uint32_t orig_len, data_len, padding, flags; @@ -527,6 +528,9 @@
> rte_pcapng_copy(uint16_t port_id, uint32_t queue,
>       if (rss_hash)
>               optlen += pcapng_optlen(sizeof(uint8_t) + sizeof(uint32_t));
> 
> +     if (comment)
> +             optlen += pcapng_optlen(strlen(comment));
> +
>       /* reserve trailing options and block length */
>       opt = (struct pcapng_option *)
>               rte_pktmbuf_append(mc, optlen + sizeof(uint32_t)); @@ -
> 564,6 +568,10 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue,
>                                       &hash_opt, sizeof(hash_opt));
>       }
> 
> +     if (comment)
> +             opt = pcapng_add_option(opt, PCAPNG_OPT_COMMENT,
> comment,
> +                                     strlen(comment));
> +
>       /* Note: END_OPT necessary here. Wireshark doesn't do it. */
> 
>       /* Add PCAPNG packet header */
> diff --git a/lib/pcapng/rte_pcapng.h b/lib/pcapng/rte_pcapng.h index
> 86b7996e29..4afdec22ef 100644
> --- a/lib/pcapng/rte_pcapng.h
> +++ b/lib/pcapng/rte_pcapng.h
> @@ -125,6 +125,8 @@ enum rte_pcapng_direction {
>   *   The timestamp in TSC cycles.
>   * @param direction
>   *   The direction of the packer: receive, transmit or unknown.
> + * @param comment
> + *   Packet comment.
>   *
>   * @return
>   *   - The pointer to the new mbuf formatted for pcapng_write
> @@ -136,7 +138,7 @@ struct rte_mbuf *
>  rte_pcapng_copy(uint16_t port_id, uint32_t queue,
>               const struct rte_mbuf *m, struct rte_mempool *mp,
>               uint32_t length, uint64_t timestamp,
> -             enum rte_pcapng_direction direction);
> +             enum rte_pcapng_direction direction, const char
> *comment);
> 
> 
>  /**
> diff --git a/lib/pdump/rte_pdump.c b/lib/pdump/rte_pdump.c index
> a81544cb57..9bc4bab4f2 100644
> --- a/lib/pdump/rte_pdump.c
> +++ b/lib/pdump/rte_pdump.c
> @@ -122,7 +122,7 @@ pdump_copy(uint16_t port_id, uint16_t queue,
>               if (cbs->ver == V2)
>                       p = rte_pcapng_copy(port_id, queue,
>                                           pkts[i], mp, cbs->snaplen,
> -                                         ts, direction);
> +                                         ts, direction, NULL);
>               else
>                       p = rte_pktmbuf_copy(pkts[i], mp, 0, cbs->snaplen);
> 
> --
> 2.25.1

Reply via email to