-
Notifications
You must be signed in to change notification settings - Fork 140
[PATCH v6] api: packet: redefine packet data sharing with packet references #2287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| * 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
include/odp/api/spec/packet.h
Outdated
| * 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 |
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in v2
fc5ce20 to
3a94a2c
Compare
|
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. |
3a94a2c to
3a39a0c
Compare
|
v3: Specified that sending shared packets to TM must obey the restrictions of the egress pktio (but currently TM does not support the dont_free flag, which maybe needs to change). |
3a39a0c to
a728f44
Compare
|
v4:
|
include/odp/api/spec/packet_io.h
Outdated
| * Packets that share data with other packets may be sent without the | ||
| * dont_free option only if the relevant packet_ref capability is set | ||
| * (see odp_pktout_packet_ref_capability_t). | ||
| * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use the same text as in odp_pktout_event_queue() and odp_pktout_send() spec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in v5
include/odp/api/spec/packet.h
Outdated
| * | ||
| * Packets that participate in packet data sharing (see odp_packet_ref() | ||
| * and odp_packet_ref_static()) may not get freed back to the packet pool | ||
| * immediately when this function is called: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since reference to a packet is a special case, only minimal documentation of it should be here and majority under e.g. odp_packet_ref().
E.g. here we could just say: "In case of packet references, the referenced packet(s) is freed back to the packet pool only after there are no more references to it."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shortened and reworded in v5.
I avoided saying that the packet won't be freed until references to it disappear so that the text cannot be interpreted to mean that everything gets postponed until that point and that the packet could still be used (and be in a not-freed state) until that.
a728f44 to
1fec78c
Compare
|
v5: Updated based on review comments. Text clarifications only, no semantic changes. |
include/odp/api/spec/packet.h
Outdated
| * | ||
| * The packet passed to this function must not reference another packet or | ||
| * be a static reference (see odp_packet_ref_static()). It can already be | ||
| * a referenced packet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function documentation would be cleared for the (first time) reader, if this limitation is stated in the beginning. I'd move this just after the first paragraph (definition of referenced/referencing) and change:
"... must not reference another packet..." -> "...must not be a referencing packet or a static reference..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved and changed in v6
include/odp/api/spec/packet.h
Outdated
| * reference. Must be a unique reference. | ||
| * @param hdr Handle of the header packet to be prefixed | ||
| * | ||
| * @return New reference the reference packet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something wrong in our current return value documentation. This and odp_packet_ref() return value could be documented as "Handle of the newly created referencing packet".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in v6
|
v6: cosmetic changes based on review comments, rebased |
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 implementations. 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 particular, 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 cannot 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>
1fec78c to
25f5e64
Compare
| * | ||
| * Packets that reference or are referenced by other packets may be sent | ||
| * using this function only if the pktout to be used has the relevant | ||
| * capability. See odp_pktio_capability_t::packet_ref. XXX dontfree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"XXX dontfree" some leftover?
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.