Skip to content

Conversation

@JannePeltonen
Copy link
Collaborator

Current API regarding dynamic packet references is not easy to efficiently support in some ODP implementations with HW accelerated packet output due to the need to update reference counts after TX completion and based on that conditionally free packet buffers. odp_packet_ref() has been implemented only as a full packet copy in all ODP implementation.

Redefine the semantics of odp_packet_ref() and the packets involved in packet data sharing in a way that hopefully makes it simpler to support packet data sharing with restrictions in packet output and with per-packet reference counting instead of per-segment reference counting. The new semantics also enable use cases that were not previously possible.

Specify better the rules regarding packet data layout manipulation operations, allowing private packet data also in the tail of the packets that reference other packets. Pull and truncate operations may involve shared packet data, in which case they just remove that data from the packet, not affecting the packet owning the data. All extend and truncate operations always produce non-shared packet data.

Change odp_packet_has_ref() to indicate whether a packet is referenced by another packet, not whether the packet shares data with another packet. In partivular, odp_packet_ref() returns a packet that shares data with the given packet but is not itself referenced by other packets. Specify that packet data and layout of packets referenced by other packets can not be modified at all.

Introduce pktio capability bits to indicate whether a pktio supports sending packets with shared data without using the dont_free flag. Sending with the dont_free flag is supported with all types of packets.

@odpbuild odpbuild changed the title api: packet: redefine packet data sharing [PATCH v1] api: packet: redefine packet data sharing Nov 11, 2025
@MatiasElo MatiasElo added this to the v1.49.0 milestone Nov 19, 2025
* Packets returned by this function can be used normally in ODP API functions
* unless otherwise noted. There are restrictions in packet output.
*
* Referenced packets can be used in ODP API functions that treat packet data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use one word to refer. Either base packet or referenced packet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in v2 so that we talk about referenced packets, not base packets.

* of a static reference it also shares metadata. Packet data and data layout
* of packet that have references must be treated as read only.
*
* Packets created through odp_packet_ref() or odp_packet_ref_hdr() share data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odp_packet_ref_hdr() --> odp_packet_ref_pkt()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in v2

Current API regarding dynamic packet references is not easy to
efficiently support in some ODP implementations with HW accelerated
packet output due to the need to update reference counts after TX
completion and based on that conditionally free packet buffers.
odp_packet_ref() has been implemented only as a full packet copy in
all ODP implementation.

Redefine the semantics of odp_packet_ref() and the packets involved
in packet data sharing in a way that hopefully makes it simpler to
support packet data sharing with restrictions in packet output and
with per-packet reference counting instead of per-segment reference
counting. The new semantics also enable use cases that were not
previously possible.

Specify better the rules regarding packet data layout manipulation
operations, allowing private packet data also in the tail of the
packets that reference other packets. Pull and truncate operations may
involve shared packet data, in which case they just remove that data
from the packet, not affecting the packet owning the data. All extend
and truncate operations always produce non-shared packet data.

Change odp_packet_has_ref() to indicate whether a packet is referenced
by another packet, not whether the packet shares data with another
packet. In partivular, odp_packet_ref() returns a packet that shares
data with the given packet but is not itself referenced by other
packets. Specify that packet data and layout of packets referenced by
other packets can not be modified at all.

Add new odp_packet_is_referencing() to test whether a packet
references another packet.

Introduce pktio capability bits to indicate whether a pktio supports
sending packets with shared data without using the dont_free flag.
Sending with the dont_free flag is supported with all types of packets.

Signed-off-by: Janne Peltonen <janne.peltonen@nokia.com>
@odpbuild odpbuild changed the title [PATCH v1] api: packet: redefine packet data sharing [PATCH v2] api: packet: redefine packet data sharing Dec 2, 2025
@JannePeltonen
Copy link
Collaborator Author

v2: Many text clarifications and typo fixes. Removed base packet from terminology. Made the packet I/O capabilities more granular. Added reference related text in odp_packet_concat() specification. Added a new function to test whether a packet is a referencing packet. Mentioned that the functions that create referencing packets and static references can be called simultaneously in multiple threads for the same packet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants