Date: Tue, 24 Jul 2012 14:18:27 -0400 From: Arnaud Lacombe <lacombar@gmail.com> To: FreeBSD Net <freebsd-net@freebsd.org> Cc: FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: Generic queue's KPI to manipulate mbuf's queue Message-ID: <CACqU3MW1cOSQcocR3QSTNYYYvBMu_ndmk%2Byp2M%2Bo=H0aCMPPTg@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hi,
AFAIK, there is no proper KPI for managing mbuf queue. All users have
to re-implements the queue logic from scratch, which is less than
optimal. From a preeminent FreeBSD developer at BSDCan 2009: "we do
not need a new list implementation". There has been a few attempt of
providing a queue API, namely <dev/cxgb/sys/mbufq.h>, but that is
nothing more than an ad-hoc solution to something which _has_to_be_
generic. For the sake of adding more mess in the tree, this
implementation has been duplicated in <dev/xen/netfront/mbufq.h>...
Now, I understand, or at least merely witness without power, the
reluctance of kernel hackers to have 'struct mbuf` evolves, especially
wrt. their desire to keep binary compatibility of KPI[0]. Now, none of
the current ad-hoc API matched my needs, and I really did NOT want to
re-implement a new list implementation for missing basic operation,
such as deleting an element of the list, so I came with the attached
patch. The main idea is to be able to use already existing code from
<sys/queue.h> for mbuf queuing management. It is not the best which
can be done. I am not a huge fan of keeping `m_nextpkt' and
introducing a `m_nextelm', I would have preferred to use TAILQs, and I
do not like the dwelling in SLIST internal implementation details.
However, this change is relatively lightweight, and change neither ABI
or API.
Any comment appreciated.
- Arnaud
[0]: taking care of having a stable kernel ABI and *not* a stable
userland ABI is beyond my understanding, but this is not the subject
of this mail.
[-- Attachment #2 --]
diff --git a/freebsd/sys/sys/mbuf.h b/freebsd/sys/sys/mbuf.h
index 907b77a..ea9afeb 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -88,7 +88,7 @@ struct mb_args {
*/
struct m_hdr {
struct mbuf *mh_next; /* next buffer in chain */
- struct mbuf *mh_nextpkt; /* next chain in queue/record */
+ SLIST_ENTRY(mbuf) mh_nextpkt; /* next chain in queue/record */
caddr_t mh_data; /* location of data */
int mh_len; /* amount of data in this mbuf */
int mh_flags; /* flags; see below */
@@ -159,7 +159,8 @@ struct mbuf {
#define m_data m_hdr.mh_data
#define m_type m_hdr.mh_type
#define m_flags m_hdr.mh_flags
-#define m_nextpkt m_hdr.mh_nextpkt
+#define m_nextpkt m_hdr.mh_nextpkt.sle_next
+#define m_nextelm m_hdr.mh_nextpkt
#define m_act m_nextpkt
#define m_pkthdr M_dat.MH.MH_pkthdr
#define m_ext M_dat.MH.MH_dat.MH_ext
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACqU3MW1cOSQcocR3QSTNYYYvBMu_ndmk%2Byp2M%2Bo=H0aCMPPTg>
