diff options
-rw-r--r-- | example/ipsec/odp_ipsec_stream.c | 4 | ||||
-rw-r--r-- | platform/linux-generic/include/api/odp_packet.h | 32 | ||||
-rw-r--r-- | platform/linux-generic/odp_packet.c | 8 |
3 files changed, 20 insertions, 24 deletions
diff --git a/example/ipsec/odp_ipsec_stream.c b/example/ipsec/odp_ipsec_stream.c index de8305ac7..fba425c4c 100644 --- a/example/ipsec/odp_ipsec_stream.c +++ b/example/ipsec/odp_ipsec_stream.c @@ -193,8 +193,8 @@ odp_packet_t create_ipv4_packet(stream_db_entry_t *stream, return ODP_PACKET_INVALID; pkt = odp_packet_from_buffer(bfr); odp_packet_init(pkt); - base = odp_packet_start(pkt); - data = odp_packet_start(pkt); + base = odp_packet_data(pkt); + data = odp_packet_data(pkt); /* Ethernet */ odp_packet_set_inflag_eth(pkt, 1); diff --git a/platform/linux-generic/include/api/odp_packet.h b/platform/linux-generic/include/api/odp_packet.h index 83f345a82..316279b61 100644 --- a/platform/linux-generic/include/api/odp_packet.h +++ b/platform/linux-generic/include/api/odp_packet.h @@ -116,41 +116,37 @@ void odp_packet_set_ctx(odp_packet_t buf, const void *ctx); void *odp_packet_get_ctx(odp_packet_t buf); /** - * Get address to the start of the packet buffer + * Packet buffer start address + * + * Returns a pointer to the start of the packet buffer. The address is not + * necessarily the same as packet data address. E.g. on a received Ethernet + * frame, the protocol header may start 2 or 6 bytes within the buffer to + * ensure 32 or 64-bit alignment of the IP header. * - * The address of the packet buffer is not necessarily the same as the start - * address of the received frame, e.g. an eth frame may be offset by 2 or 6 - * bytes to ensure 32 or 64-bit alignment of the IP header. * Use odp_packet_l2(pkt) to get the start address of a received valid frame - * or odp_packet_start(pkt) to get the start address even if no valid L2 header - * could be found. + * or odp_packet_data(pkt) to get the current packet data address. * * @param pkt Packet handle * * @return Pointer to the start of the packet buffer * - * @see odp_packet_l2(), odp_packet_start() + * @see odp_packet_l2(), odp_packet_data() */ uint8_t *odp_packet_addr(odp_packet_t pkt); /** - * Get pointer to the start of the received frame - * - * The address of the packet buffer is not necessarily the same as the start - * address of the received frame, e.g. an eth frame may be offset by 2 or 6 - * bytes to ensure 32 or 64-bit alignment of the IP header. - * Use odp_packet_l2(pkt) to get the start address of a received valid eth frame + * Packet data address * - * odp_packet_start() will always return a pointer to the start of the frame, - * even if the frame is unrecognized and no valid L2 header could be found. + * Returns the current packet data address. When a packet is received from + * packet input, the data address points to the first byte of the packet. * * @param pkt Packet handle * - * @return Pointer to the start of the received frame + * @return Pointer to the packet data * * @see odp_packet_l2(), odp_packet_addr() */ -uint8_t *odp_packet_start(odp_packet_t pkt); +uint8_t *odp_packet_data(odp_packet_t pkt); /** * Get pointer to the start of the L2 frame @@ -162,7 +158,7 @@ uint8_t *odp_packet_start(odp_packet_t pkt); * * @return Pointer to L2 header or NULL if not found * - * @see odp_packet_addr(), odp_packet_start() + * @see odp_packet_addr(), odp_packet_data() */ uint8_t *odp_packet_l2(odp_packet_t pkt); diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 6cd61830b..435bc8b0d 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -61,7 +61,7 @@ uint8_t *odp_packet_addr(odp_packet_t pkt) return odp_buffer_addr(odp_buffer_from_packet(pkt)); } -uint8_t *odp_packet_start(odp_packet_t pkt) +uint8_t *odp_packet_data(odp_packet_t pkt) { return odp_packet_addr(pkt) + odp_packet_hdr(pkt)->frame_offset; } @@ -183,7 +183,7 @@ void odp_packet_parse(odp_packet_t pkt, size_t len, size_t frame_offset) pkt_hdr->input_flags.l2 = 1; pkt_hdr->l2_offset = frame_offset; - eth = (odph_ethhdr_t *)odp_packet_start(pkt); + eth = (odph_ethhdr_t *)odp_packet_data(pkt); ethtype = odp_be_to_cpu_16(eth->type); vlan = (odph_vlanhdr_t *)ð->type; @@ -372,8 +372,8 @@ int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src) memcpy(start_dst, start_src, len); /* Copy frame payload */ - start_dst = (uint8_t *)odp_packet_start(pkt_dst); - start_src = (uint8_t *)odp_packet_start(pkt_src); + start_dst = (uint8_t *)odp_packet_data(pkt_dst); + start_src = (uint8_t *)odp_packet_data(pkt_src); len = pkt_hdr_src->frame_len; memcpy(start_dst, start_src, len); |