diff options
author | Petri Savolainen <petri.savolainen@linaro.org> | 2014-07-01 11:08:27 +0300 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2014-07-02 13:12:36 +0400 |
commit | a73bd98afa1cc252dcb5382cf43954cd0011872d (patch) | |
tree | 2c567897554592c8faa1a1122738475ad015febb /include | |
parent | c5f37f05843453a5bab4f951f387355179f3597d (diff) |
Packet segment API started
Started buffer/packet/SG-list API harmonizartion. New API terminology
is introduced first in segments (SG list) API and buffer/packet APIs
are changed to use same terms in following patches. Segments are
introduced for packet type buffers only at this phase.
Term summary:
- xxx_addr = segment start address
- xxx_size = segment size
- xxx_data = data pointer (data start inside the segment)
- xxx_data_len = data length
Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/helper/odp_packet_helper.h | 14 | ||||
-rw-r--r-- | include/odp_buffer.h | 11 | ||||
-rw-r--r-- | include/odp_buffer_pool.h | 9 | ||||
-rw-r--r-- | include/odp_packet.h | 148 |
4 files changed, 156 insertions, 26 deletions
diff --git a/include/helper/odp_packet_helper.h b/include/helper/odp_packet_helper.h index eed866e4..db12028f 100644 --- a/include/helper/odp_packet_helper.h +++ b/include/helper/odp_packet_helper.h @@ -89,20 +89,6 @@ static inline size_t odp_packet_buf_size(odp_packet_t pkt) return odp_buffer_size(buf); } -/** - * Helper: Tests if packet is part of a scatter/gather list - * - * @param pkt Packet handle - * - * @return 1 if belongs to a scatter list, otherwise 0 - */ -static inline int odp_packet_is_scatter(odp_packet_t pkt) -{ - odp_buffer_t buf = odp_buffer_from_packet(pkt); - - return odp_buffer_is_scatter(buf); -} - #ifdef __cplusplus } diff --git a/include/odp_buffer.h b/include/odp_buffer.h index b3d6f4aa..d8577fd9 100644 --- a/include/odp_buffer.h +++ b/include/odp_buffer.h @@ -19,13 +19,10 @@ extern "C" { #endif - #include <odp_std_types.h> - - /** * ODP buffer */ @@ -68,14 +65,6 @@ int odp_buffer_type(odp_buffer_t buf); #define ODP_BUFFER_TYPE_PACKET 2 /**< Packet buffer */ #define ODP_BUFFER_TYPE_TIMEOUT 3 /**< Timeout buffer */ -/** - * Tests if buffer is part of a scatter/gather list - * - * @param buf Buffer handle - * - * @return 1 if belongs to a scatter list, otherwise 0 - */ -int odp_buffer_is_scatter(odp_buffer_t buf); /** * Tests if buffer is valid diff --git a/include/odp_buffer_pool.h b/include/odp_buffer_pool.h index 58deb3c4..26d9f14a 100644 --- a/include/odp_buffer_pool.h +++ b/include/odp_buffer_pool.h @@ -70,7 +70,6 @@ odp_buffer_pool_t odp_buffer_pool_lookup(const char *name); void odp_buffer_pool_print(odp_buffer_pool_t pool); - /** * Buffer alloc * @@ -91,6 +90,14 @@ odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t pool); void odp_buffer_free(odp_buffer_t buf); +/** + * Buffer pool of the buffer + * + * @param buf Buffer handle + * + * @return Buffer pool the buffer was allocated from + */ +odp_buffer_pool_t odp_buffer_pool(odp_buffer_t buf); #ifdef __cplusplus diff --git a/include/odp_packet.h b/include/odp_packet.h index 59759bb3..8ae6410f 100644 --- a/include/odp_packet.h +++ b/include/odp_packet.h @@ -220,6 +220,154 @@ void odp_packet_print(odp_packet_t pkt); */ int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src); +/** + * Tests if packet is segmented (a scatter/gather list) + * + * @param pkt Packet handle + * + * @return Non-zero if packet is segmented, otherwise 0 + */ +int odp_packet_is_segmented(odp_packet_t pkt); + +/** + * Segment count + * + * Returns number of segments in the packet. A packet has always at least one + * segment (the packet buffer itself). + * + * @param pkt Packet handle + * + * @return Segment count + */ +int odp_packet_seg_count(odp_packet_t pkt); + +/** + * Segment start address + * + * @param pkt Packet handle + * @param seg Segment index (0 ... seg_count-1) + * + * @return Segment start address + */ +void *odp_packet_seg_addr(odp_packet_t pkt, int seg); + +/** + * Segment maximum data size + * + * @param pkt Packet handle + * @param seg Segment index (0 ... seg_count-1) + * + * @return Segment maximum data size + */ +size_t odp_packet_seg_size(odp_packet_t pkt, int seg); + +/** + * Segment data address + * + * @param pkt Packet handle + * @param seg Segment index (0 ... seg_count-1) + * + * @return Segment data address + */ +void *odp_packet_seg_data(odp_packet_t pkt, int seg); + +/** + * Segment data length + * + * @param pkt Packet handle + * @param seg Segment index (0 ... seg_count-1) + * + * @return Segment data length + */ +size_t odp_packet_seg_data_len(odp_packet_t pkt, int seg); + +/** + * Segment headroom + * + * seg_headroom = seg_data - seg_addr + * + * @param pkt Packet handle + * @param seg Segment index (0 ... seg_count-1) + * + * @return Number of octets from seg_addr to seg_data + */ +size_t odp_packet_seg_headroom(odp_packet_t pkt, int seg); + +/** + * Segment tailroom + * + * seg_tailroom = seg_size - seg_headroom - seg_data_len + * + * @param pkt Packet handle + * @param seg Segment index (0 ... seg_count-1) + * + * @return Number of octets from end-of-data to end-of-segment + */ +size_t odp_packet_seg_tailroom(odp_packet_t pkt, int seg); + +/** + * Push out segment head + * + * Push out segment data address (away from data) and increase data length. + * + * seg_data -= len + * seg_data_len += len + * + * @param pkt Packet handle + * @param seg Segment index (0 ... seg_count-1) + * @param len Number of octets to push head (0 ... seg_headroom) + * + * @return New segment data address, or NULL on an error + */ +void *odp_packet_seg_push_head(odp_packet_t pkt, int seg, size_t len); + +/** + * Pull in segment head + * + * Pull in segment data address (towards data) and decrease data length. + * + * seg_data += len + * seg_data_len -= len + * + * @param pkt Packet handle + * @param seg Segment index (0 ... seg_count-1) + * @param len Number of octets to pull head (0 ... seg_data_len) + * + * @return New segment data address, or NULL on an error + */ +void *odp_packet_seg_pull_head(odp_packet_t pkt, int seg, size_t len); + +/** + * Push out segment tail + * + * Increase segment data length. + * + * seg_data_len += len + * + * @param pkt Packet handle + * @param seg Segment index (0 ... seg_count-1) + * @param len Number of octets to push tail (0 ... seg_tailroom) + * + * @return New segment data length, or -1 on an error + */ +int odp_packet_seg_push_tail(odp_packet_t pkt, int seg, size_t len); + +/** + * Pull in segment tail + * + * Decrease segment data length. + * + * seg_data_len -= len + * + * @param pkt Packet handle + * @param seg Segment index (0 ... seg_count-1) + * @param len Number of octets to pull tail (0 ... seg_data_len) + * + * @return New segment data length, or -1 on an error + */ +int odp_packet_seg_pull_tail(odp_packet_t pkt, int seg, size_t len); + + #ifdef __cplusplus } #endif |