On Tue, Jun 6, 2017 at 3:24 AM, Joyce Kong <[email protected]> wrote:
> Signed-off-by: Joyce Kong <[email protected]>
> ---
>  platform/linux-generic/include/odp_packet_internal.h | 10 ++++++++++
>  platform/linux-generic/odp_packet_io.c               |  8 +++-----
>  platform/linux-generic/pktio/loop.c                  |  4 ++--
>  3 files changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/platform/linux-generic/include/odp_packet_internal.h 
> b/platform/linux-generic/include/odp_packet_internal.h
> index 0a9f177..8083b6a 100644
> --- a/platform/linux-generic/include/odp_packet_internal.h
> +++ b/platform/linux-generic/include/odp_packet_internal.h
> @@ -168,6 +168,16 @@ static inline odp_packet_t 
> packet_handle(odp_packet_hdr_t *pkt_hdr)
>         return (odp_packet_t)pkt_hdr;
>  }
>
> +static inline odp_buffer_hdr_t *packet_to_buf_hdr(odp_packet_t pkt)
> +{
> +       return &odp_packet_hdr(pkt)->buf_hdr;
> +}
> +
> +static inline odp_packet_t buf_hdr_to_packet(odp_buffer_hdr_t *buf_hdr)
> +{
> +       return (odp_packet_t)(odp_packet_hdr_t *)buf_hdr;
> +}
> +

The ODP convention is that conversion functions in the xxx component
take the form xxx_to_yyy() and xxx_from_yyy() rather than
yyy_to_xxx(), so this should be packet_from_buf_hdr().

>  static inline void copy_packet_parser_metadata(odp_packet_hdr_t *src_hdr,
>                                                odp_packet_hdr_t *dst_hdr)
>  {
> diff --git a/platform/linux-generic/odp_packet_io.c 
> b/platform/linux-generic/odp_packet_io.c
> index 50a000e..2f6ce5c 100644
> --- a/platform/linux-generic/odp_packet_io.c
> +++ b/platform/linux-generic/odp_packet_io.c
> @@ -552,7 +552,6 @@ static inline int pktin_recv_buf(odp_pktin_queue_t queue,
>         odp_packet_t packets[num];
>         odp_packet_hdr_t *pkt_hdr;
>         odp_buffer_hdr_t *buf_hdr;
> -       odp_buffer_t buf;
>         int i;
>         int pkts;
>         int num_rx = 0;
> @@ -562,8 +561,7 @@ static inline int pktin_recv_buf(odp_pktin_queue_t queue,
>         for (i = 0; i < pkts; i++) {
>                 pkt = packets[i];
>                 pkt_hdr = odp_packet_hdr(pkt);
> -               buf = _odp_packet_to_buffer(pkt);
> -               buf_hdr = buf_hdl_to_hdr(buf);
> +               buf_hdr = packet_to_buf_hdr(pkt);
>
>                 if (pkt_hdr->p.input_flags.dst_queue) {
>                         queue_entry_t *dst_queue;
> @@ -582,7 +580,7 @@ static inline int pktin_recv_buf(odp_pktin_queue_t queue,
>
>  int pktout_enqueue(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr)
>  {
> -       odp_packet_t pkt = _odp_packet_from_buffer(buf_hdr->handle.handle);
> +       odp_packet_t pkt = buf_hdr_to_packet(buf_hdr);
>         int len = 1;
>         int nbr;
>
> @@ -612,7 +610,7 @@ int pktout_enq_multi(queue_entry_t *qentry, 
> odp_buffer_hdr_t *buf_hdr[],
>                 return nbr;
>
>         for (i = 0; i < num; ++i)
> -               pkt_tbl[i] = 
> _odp_packet_from_buffer(buf_hdr[i]->handle.handle);
> +               pkt_tbl[i] = buf_hdr_to_packet(buf_hdr[i]);
>
>         nbr = odp_pktout_send(qentry->s.pktout, pkt_tbl, num);
>         return nbr;
> diff --git a/platform/linux-generic/pktio/loop.c 
> b/platform/linux-generic/pktio/loop.c
> index 61e98ad..a495a40 100644
> --- a/platform/linux-generic/pktio/loop.c
> +++ b/platform/linux-generic/pktio/loop.c
> @@ -81,7 +81,7 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int 
> index ODP_UNUSED,
>         for (i = 0; i < nbr; i++) {
>                 uint32_t pkt_len;
>
> -               pkt = _odp_packet_from_buffer(odp_hdr_to_buf(hdr_tbl[i]));
> +               pkt = buf_hdr_to_packet(hdr_tbl[i]);
>                 pkt_len = odp_packet_len(pkt);
>
>
> @@ -162,7 +162,7 @@ static int loopback_send(pktio_entry_t *pktio_entry, int 
> index ODP_UNUSED,
>                 len = QUEUE_MULTI_MAX;
>
>         for (i = 0; i < len; ++i) {
> -               hdr_tbl[i] = 
> buf_hdl_to_hdr(_odp_packet_to_buffer(pkt_tbl[i]));
> +               hdr_tbl[i] = packet_to_buf_hdr(pkt_tbl[i]);
>                 bytes += odp_packet_len(pkt_tbl[i]);
>         }
>
> --
> 2.7.4
>
>

Reply via email to