From: Brian Brooks <brian.bro...@arm.com>

odp_packet_hdr() and packet_hdr() are both internal-only functions that do
the same exact thing. Remove odp_packet_hdr() version since "odp_" prefix
is reserved for top-level API identifiers. This is also consistent with
other packet_xxx() internal-only functions.

Signed-off-by: Brian Brooks <brian.bro...@arm.com>
Reviewed-by: Yi He <yi...@arm.com>
Reviewed-by: Ola Liljedahl <ola.liljed...@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagaraha...@arm.com>
Reviewed-by: Kevin Wang <kevin.w...@arm.com>
---
/** Email created from pull request 354 (brbrooks:caterpillar)
 ** https://github.com/Linaro/odp/pull/354
 ** Patch: https://github.com/Linaro/odp/pull/354.patch
 ** Base sha: 4d17f8ae64aba0e6f24877be30f86ae5880cef7e
 ** Merge commit sha: 223d05c5b9ecf4986ec07a833a2630eafbbc3a4d
 **/
 .../linux-generic/include/odp_packet_internal.h    |  4 ++--
 platform/linux-generic/odp_crypto.c                |  2 +-
 platform/linux-generic/odp_ipsec.c                 |  6 +++---
 platform/linux-generic/odp_packet.c                |  5 -----
 platform/linux-generic/odp_packet_flags.c          | 22 +++++++++++-----------
 platform/linux-generic/odp_packet_io.c             |  4 ++--
 platform/linux-generic/pktio/dpdk.c                | 12 ++++++------
 platform/linux-generic/pktio/ipc.c                 | 14 +++++++-------
 platform/linux-generic/pktio/loopback.c            |  2 +-
 platform/linux-generic/pktio/netmap.c              |  2 +-
 platform/linux-generic/pktio/pcap.c                |  2 +-
 platform/linux-generic/pktio/socket.c              |  2 +-
 platform/linux-generic/pktio/socket_mmap.c         |  2 +-
 platform/linux-generic/pktio/tap.c                 |  2 +-
 14 files changed, 38 insertions(+), 43 deletions(-)

diff --git a/platform/linux-generic/include/odp_packet_internal.h 
b/platform/linux-generic/include/odp_packet_internal.h
index fed562aa3..3a86ce928 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -162,7 +162,7 @@ typedef struct {
 /**
  * Return the packet header
  */
-static inline odp_packet_hdr_t *odp_packet_hdr(odp_packet_t pkt)
+static inline odp_packet_hdr_t *packet_hdr(odp_packet_t pkt)
 {
        return (odp_packet_hdr_t *)(uintptr_t)pkt;
 }
@@ -174,7 +174,7 @@ static inline odp_packet_t packet_handle(odp_packet_hdr_t 
*pkt_hdr)
 
 static inline odp_buffer_hdr_t *packet_to_buf_hdr(odp_packet_t pkt)
 {
-       return &odp_packet_hdr(pkt)->buf_hdr;
+       return &packet_hdr(pkt)->buf_hdr;
 }
 
 static inline odp_packet_t packet_from_buf_hdr(odp_buffer_hdr_t *buf_hdr)
diff --git a/platform/linux-generic/odp_crypto.c 
b/platform/linux-generic/odp_crypto.c
index 3174feee0..2a85124ee 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -1127,7 +1127,7 @@ odp_event_t odp_crypto_packet_to_event(odp_packet_t pkt)
 static
 odp_crypto_packet_result_t *get_op_result_from_packet(odp_packet_t pkt)
 {
-       odp_packet_hdr_t *hdr = odp_packet_hdr(pkt);
+       odp_packet_hdr_t *hdr = packet_hdr(pkt);
 
        return &hdr->crypto_op_result;
 }
diff --git a/platform/linux-generic/odp_ipsec.c 
b/platform/linux-generic/odp_ipsec.c
index e57736c2a..23f86f69a 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -98,7 +98,7 @@ static odp_ipsec_packet_result_t 
*ipsec_pkt_result(odp_packet_t packet)
        ODP_ASSERT(ODP_EVENT_PACKET_IPSEC ==
                   odp_event_subtype(odp_packet_to_event(packet)));
 
-       return &odp_packet_hdr(packet)->ipsec_ctx;
+       return &packet_hdr(packet)->ipsec_ctx;
 }
 
 /**
@@ -541,7 +541,7 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
        }
 
        if (!status->error.all) {
-               odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+               odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
 
                packet_parse_reset(pkt_hdr);
 
@@ -1120,7 +1120,7 @@ int _odp_ipsec_try_inline(odp_packet_t pkt)
        result->status = status;
        result->sa = ipsec_sa->ipsec_sa_hdl;
 
-       pkt_hdr = odp_packet_hdr(pkt);
+       pkt_hdr = packet_hdr(pkt);
        pkt_hdr->p.input_flags.dst_queue = 1;
        pkt_hdr->dst_queue = queue_fn->from_ext(ipsec_sa->queue);
 
diff --git a/platform/linux-generic/odp_packet.c 
b/platform/linux-generic/odp_packet.c
index 853d3baa9..80ea0384e 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -45,11 +45,6 @@ const _odp_packet_inline_offset_t _odp_packet_inline 
ODP_ALIGNED_CACHE = {
 
 #include <odp/visibility_end.h>
 
-static inline odp_packet_hdr_t *packet_hdr(odp_packet_t pkt)
-{
-       return (odp_packet_hdr_t *)(uintptr_t)pkt;
-}
-
 static inline odp_buffer_t buffer_handle(odp_packet_hdr_t *pkt_hdr)
 {
        return (odp_buffer_t)pkt_hdr;
diff --git a/platform/linux-generic/odp_packet_flags.c 
b/platform/linux-generic/odp_packet_flags.c
index 2e26ad601..5beae933d 100644
--- a/platform/linux-generic/odp_packet_flags.c
+++ b/platform/linux-generic/odp_packet_flags.c
@@ -11,18 +11,18 @@
 #include <odp_packet_internal.h>
 
 #define retflag(pkt, x) do {                             \
-       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); \
+       odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); \
        return pkt_hdr->p.x;                             \
        } while (0)
 
 #define setflag(pkt, x, v) do {                          \
-       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); \
+       odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); \
        pkt_hdr->p.x = (v) & 1;                          \
        } while (0)
 
 int odp_packet_has_error(odp_packet_t pkt)
 {
-       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+       odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
 
        return pkt_hdr->p.error_flags.all != 0;
 }
@@ -31,7 +31,7 @@ int odp_packet_has_error(odp_packet_t pkt)
 
 int odp_packet_has_l2_error(odp_packet_t pkt)
 {
-       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+       odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
        /* L2 parsing is always done by default and hence
        no additional check is required */
        return pkt_hdr->p.error_flags.frame_len
@@ -46,7 +46,7 @@ int odp_packet_has_l3(odp_packet_t pkt)
 
 int odp_packet_has_l3_error(odp_packet_t pkt)
 {
-       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+       odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
 
        return pkt_hdr->p.error_flags.ip_err;
 }
@@ -58,7 +58,7 @@ int odp_packet_has_l4(odp_packet_t pkt)
 
 int odp_packet_has_l4_error(odp_packet_t pkt)
 {
-       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+       odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
 
        return pkt_hdr->p.error_flags.tcp_err | pkt_hdr->p.error_flags.udp_err;
 }
@@ -150,14 +150,14 @@ odp_packet_color_t odp_packet_color(odp_packet_t pkt)
 
 void odp_packet_color_set(odp_packet_t pkt, odp_packet_color_t color)
 {
-       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+       odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
 
        pkt_hdr->p.input_flags.color = color;
 }
 
 odp_bool_t odp_packet_drop_eligible(odp_packet_t pkt)
 {
-       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+       odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
 
        return !pkt_hdr->p.input_flags.nodrop;
 }
@@ -174,7 +174,7 @@ int8_t odp_packet_shaper_len_adjust(odp_packet_t pkt)
 
 void odp_packet_shaper_len_adjust_set(odp_packet_t pkt, int8_t adj)
 {
-       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+       odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
 
        pkt_hdr->p.output_flags.shaper_len_adj = adj;
 }
@@ -288,14 +288,14 @@ void odp_packet_has_icmp_set(odp_packet_t pkt, int val)
 
 void odp_packet_has_flow_hash_clr(odp_packet_t pkt)
 {
-       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+       odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
 
        pkt_hdr->p.input_flags.flow_hash = 0;
 }
 
 void odp_packet_has_ts_clr(odp_packet_t pkt)
 {
-       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+       odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
 
        pkt_hdr->p.input_flags.timestamp = 0;
 }
diff --git a/platform/linux-generic/odp_packet_io.c 
b/platform/linux-generic/odp_packet_io.c
index efeac0269..671422fae 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -553,7 +553,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);
+               pkt_hdr = packet_hdr(pkt);
                buf_hdr = packet_to_buf_hdr(pkt);
 
                if (pkt_hdr->p.input_flags.dst_queue) {
@@ -681,7 +681,7 @@ int pktin_poll_one(int pktio_index,
        num_rx = 0;
        for (i = 0; i < num_pkts; i++) {
                pkt = packets[i];
-               pkt_hdr = odp_packet_hdr(pkt);
+               pkt_hdr = packet_hdr(pkt);
                if (odp_unlikely(pkt_hdr->p.input_flags.dst_queue)) {
                        queue = pkt_hdr->dst_queue;
                        buf_hdr = packet_to_buf_hdr(pkt);
diff --git a/platform/linux-generic/pktio/dpdk.c 
b/platform/linux-generic/pktio/dpdk.c
index 7d39bb1bc..bdd12292f 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -244,7 +244,7 @@ static int pool_dequeue_bulk(struct rte_mempool *mp, void 
**obj_table,
 
        for (i = 0; i < pkts; i++) {
                odp_packet_t pkt = packet_tbl[i];
-               odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+               odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
                struct rte_mbuf *mbuf = (struct rte_mbuf *)
                                        (uintptr_t)pkt_hdr->extra;
                if (pkt_hdr->extra_type != PKT_EXTRA_TYPE_DPDK)
@@ -428,7 +428,7 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry,
                }
 
                pkt     = pkt_table[i];
-               pkt_hdr = odp_packet_hdr(pkt);
+               pkt_hdr = packet_hdr(pkt);
                pull_tail(pkt_hdr, alloc_len - pkt_len);
 
                if (odp_packet_copy_from_mem(pkt, 0, pkt_len, data) != 0)
@@ -591,7 +591,7 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry,
 
                if (pktout_cfg->all_bits)
                        pkt_set_ol_tx(pktout_cfg,
-                                     odp_packet_hdr(pkt_table[i]),
+                                     packet_hdr(pkt_table[i]),
                                      mbuf_table[i], data);
        }
        return i;
@@ -633,7 +633,7 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t 
*pktio_entry,
                pkt_len = rte_pktmbuf_pkt_len(mbuf);
 
                pkt = (odp_packet_t)mbuf->userdata;
-               pkt_hdr = odp_packet_hdr(pkt);
+               pkt_hdr = packet_hdr(pkt);
 
                if (pktio_cls_enabled(pktio_entry)) {
                        if (cls_classify_packet(pktio_entry,
@@ -688,7 +688,7 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t 
*pktio_entry,
 
        for (i = 0; i < num; i++) {
                odp_packet_t pkt = pkt_table[i];
-               odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+               odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
                struct rte_mbuf *mbuf = (struct rte_mbuf *)
                                        (uintptr_t)pkt_hdr->extra;
                uint16_t pkt_len = odp_packet_len(pkt);
@@ -1481,7 +1481,7 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int 
index,
 
                        for (i = 0; i < mbufs && freed != copy_count; i++) {
                                odp_packet_t pkt = pkt_table[i];
-                               odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+                               odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
 
                                if (pkt_hdr->buf_hdr.segcount > 1) {
                                        if (odp_likely(i < tx_pkts))
diff --git a/platform/linux-generic/pktio/ipc.c 
b/platform/linux-generic/pktio/ipc.c
index 9d928c72a..64c7606df 100644
--- a/platform/linux-generic/pktio/ipc.c
+++ b/platform/linux-generic/pktio/ipc.c
@@ -532,14 +532,14 @@ static int ipc_pktio_recv_lockless(pktio_entry_t 
*pktio_entry,
                memcpy(pkt_data, rmt_data_ptr, phdr->frame_len);
 
                /* Copy packets L2, L3 parsed offsets and size */
-               copy_packet_cls_metadata(phdr, odp_packet_hdr(pkt));
+               copy_packet_cls_metadata(phdr, packet_hdr(pkt));
 
-               odp_packet_hdr(pkt)->frame_len = phdr->frame_len;
-               odp_packet_hdr(pkt)->headroom = phdr->headroom;
-               odp_packet_hdr(pkt)->tailroom = phdr->tailroom;
+               packet_hdr(pkt)->frame_len = phdr->frame_len;
+               packet_hdr(pkt)->headroom = phdr->headroom;
+               packet_hdr(pkt)->tailroom = phdr->tailroom;
 
                /* Take classification fields */
-               odp_packet_hdr(pkt)->p = phdr->p;
+               packet_hdr(pkt)->p = phdr->p;
 
                pkt_table[i] = pkt;
        }
@@ -630,7 +630,7 @@ static int ipc_pktio_send_lockless(pktio_entry_t 
*pktio_entry,
                odp_packet_hdr_t *pkt_hdr;
                pool_t *pool;
 
-               pkt_hdr = odp_packet_hdr(pkt);
+               pkt_hdr = packet_hdr(pkt);
                pool = pkt_hdr->buf_hdr.pool_ptr;
 
                if (pool->pool_idx != ipc_pool->pool_idx ||
@@ -652,7 +652,7 @@ static int ipc_pktio_send_lockless(pktio_entry_t 
*pktio_entry,
        for (i = 0; i < len; i++) {
                uint64_t data_pool_off;
                odp_packet_t pkt = pkt_table_mapped[i];
-               odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+               odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
                odp_pool_t pool_hdl = odp_packet_pool(pkt);
                pool_t *pool = pool_entry_from_hdl(pool_hdl);
 
diff --git a/platform/linux-generic/pktio/loopback.c 
b/platform/linux-generic/pktio/loopback.c
index ff08364a2..8ac5e28c3 100644
--- a/platform/linux-generic/pktio/loopback.c
+++ b/platform/linux-generic/pktio/loopback.c
@@ -109,7 +109,7 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int 
index ODP_UNUSED,
 
                pkt = packet_from_buf_hdr(hdr_tbl[i]);
                pkt_len = odp_packet_len(pkt);
-               pkt_hdr = odp_packet_hdr(pkt);
+               pkt_hdr = packet_hdr(pkt);
 
                if (pktio_cls_enabled(pktio_entry)) {
                        odp_packet_t new_pkt;
diff --git a/platform/linux-generic/pktio/netmap.c 
b/platform/linux-generic/pktio/netmap.c
index 2631c816d..72626503d 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -676,7 +676,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t 
*pktio_entry,
                }
 
                pkt = pkt_tbl[i];
-               pkt_hdr = odp_packet_hdr(pkt);
+               pkt_hdr = packet_hdr(pkt);
                pull_tail(pkt_hdr, alloc_len - len);
 
                /* For now copy the data in the mbuf,
diff --git a/platform/linux-generic/pktio/pcap.c 
b/platform/linux-generic/pktio/pcap.c
index f3f000574..8cba047a6 100644
--- a/platform/linux-generic/pktio/pcap.c
+++ b/platform/linux-generic/pktio/pcap.c
@@ -259,7 +259,7 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int 
index ODP_UNUSED,
                if (ts != NULL)
                        ts_val = odp_time_global();
 
-               pkt_hdr = odp_packet_hdr(pkt);
+               pkt_hdr = packet_hdr(pkt);
 
                if (odp_packet_copy_from_mem(pkt, 0, hdr->caplen, data) != 0) {
                        ODP_ERR("failed to copy packet data\n");
diff --git a/platform/linux-generic/pktio/socket.c 
b/platform/linux-generic/pktio/socket.c
index 7e0485b99..111ce05d8 100644
--- a/platform/linux-generic/pktio/socket.c
+++ b/platform/linux-generic/pktio/socket.c
@@ -306,7 +306,7 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int 
index ODP_UNUSED,
                void *base = msgvec[i].msg_hdr.msg_iov->iov_base;
                struct ethhdr *eth_hdr = base;
                odp_packet_t pkt = pkt_table[i];
-               odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+               odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
                uint16_t pkt_len = msgvec[i].msg_len;
                int ret;
 
diff --git a/platform/linux-generic/pktio/socket_mmap.c 
b/platform/linux-generic/pktio/socket_mmap.c
index 271c2f0f7..70880272e 100644
--- a/platform/linux-generic/pktio/socket_mmap.c
+++ b/platform/linux-generic/pktio/socket_mmap.c
@@ -224,7 +224,7 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t 
*pktio_entry,
                        frame_num = next_frame_num;
                        continue;
                }
-               hdr = odp_packet_hdr(pkt_table[nb_rx]);
+               hdr = packet_hdr(pkt_table[nb_rx]);
                ret = odp_packet_copy_from_mem(pkt_table[nb_rx], 0,
                                               pkt_len, pkt_buf);
                if (ret != 0) {
diff --git a/platform/linux-generic/pktio/tap.c 
b/platform/linux-generic/pktio/tap.c
index bb404d914..2f2aca6ec 100644
--- a/platform/linux-generic/pktio/tap.c
+++ b/platform/linux-generic/pktio/tap.c
@@ -296,7 +296,7 @@ static odp_packet_t pack_odp_pkt(pktio_entry_t 
*pktio_entry, const void *data,
                return ODP_PACKET_INVALID;
        }
 
-       pkt_hdr = odp_packet_hdr(pkt);
+       pkt_hdr = packet_hdr(pkt);
 
        if (pktio_cls_enabled(pktio_entry))
                copy_packet_cls_metadata(&parsed_hdr, pkt_hdr);

Reply via email to