Page MenuHomeFreeBSD

Add M_START(), M_SIZE() mbuf macros; update M_LEADINGSPACE(), M_TRAILINGSPACE() to use them
ClosedPublic

Authored by rwatson on Sep 10 2014, 12:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 17, 2:11 PM
Unknown Object (File)
Sun, Nov 17, 10:28 AM
Unknown Object (File)
Wed, Nov 13, 8:37 AM
Unknown Object (File)
Oct 7 2024, 11:39 PM
Unknown Object (File)
Oct 7 2024, 11:39 PM
Unknown Object (File)
Oct 7 2024, 11:05 PM
Unknown Object (File)
Oct 5 2024, 1:47 PM
Unknown Object (File)
Oct 4 2024, 3:04 AM
Subscribers
None

Details

Summary

Add new M_START() and M_SIZE() macros mbufs that return a pointer to the start of an mbuf's storage, and return its size (in contrast to m_data and m_len that are with respect to data in the buffer). Rewrite M_LEADINGSPACE() and M_TRAILINGSPACE() in terms of M_START() and M_SIZE().

This is done as we currently have many instances of using mbuf flags to generate pointers or lengths for internal storage in header and regular mbufs, as well as to external storage. Rather than replicate this logic throughout the network stack, centralising the implementation will make it easier for us to refine mbuf storage. It should also help reduce bugs by limiting the amount of mbuf-type-specific pointer arithmetic. Followup changes will propagate use of the macros throughout the stack.

M_SIZE() conflicts with one macro in the Chelsio driver; rename that macro in a slightly unsatisfying way to eliminate the collision.

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
Reviewed by: bz, glebius

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

rwatson retitled this revision from to Add M_START(), M_SIZE() mbuf macros; update M_LEADINGSPACE(), M_TRAILINGSPACE() to use them.
rwatson updated this object.
rwatson edited the test plan for this revision. (Show Details)
rwatson added reviewers: bz, glebius.
rwatson set the repository for this revision to rS FreeBSD src repository - subversion.
glebius edited edge metadata.
glebius added inline comments.
sys/sys/mbuf.h
856

s/packet-buffer/packet-header/

This revision is now accepted and ready to land.Sep 10 2014, 1:05 PM
bz edited edge metadata.

Glebius found the comment; apart form that looks good to me as well.

sys/dev/cxgbe/common/t4_regs.h
1076

I'd run this past np@; just because ;-) I am sure he's fine with it but it might be good to consider proper prefixing of #defines in the future.