]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/sys/kpi_mbuf.h
xnu-1504.9.37.tar.gz
[apple/xnu.git] / bsd / sys / kpi_mbuf.h
index 4e2b57329e57ad940d11a29771ca455fcc857638..00134b226e6f6c49834c494b98dca3d1716cc7ef 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004-2007 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2010 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
        @header kpi_mbuf.h
        This header defines an API for interacting with mbufs. mbufs are the
        primary method of storing packets in the networking stack.
-       
+
        mbufs are used to store various items in the networking stack. The
        most common usage of an mbuf is to store a packet or data on a
        socket waiting to be sent or received. The mbuf is a contiguous
        structure with some header followed by some data. To store more data
        than would fit in an mbuf, external data is used. Most mbufs with
        external data use clusters to store the external data.
-       
+
        mbufs can be chained, contiguous data in a packet can be found by
        following the m_next chain. Packets may be bundled together using
        m_nextpacket. Many parts of the stack do not properly handle chains
                being passed to any interface filters.
 */
 enum {
-       MBUF_EXT                = 0x0001,       /* has associated external storage */
-       MBUF_PKTHDR             = 0x0002,       /* start of record */
-       MBUF_EOR                = 0x0004,       /* end of record */
-       
-       MBUF_BCAST              = 0x0100,       /* send/received as link-level broadcast */
-       MBUF_MCAST              = 0x0200,       /* send/received as link-level multicast */
-       MBUF_FRAG               = 0x0400,       /* packet is a fragment of a larger packet */
+       MBUF_EXT        = 0x0001,       /* has associated external storage */
+       MBUF_PKTHDR     = 0x0002,       /* start of record */
+       MBUF_EOR        = 0x0004,       /* end of record */
+
+       MBUF_BCAST      = 0x0100,       /* send/received as link-level broadcast */
+       MBUF_MCAST      = 0x0200,       /* send/received as link-level multicast */
+       MBUF_FRAG       = 0x0400,       /* packet is a fragment of a larger packet */
        MBUF_FIRSTFRAG  = 0x0800,       /* packet is first fragment */
        MBUF_LASTFRAG   = 0x1000,       /* packet is last fragment */
        MBUF_PROMISC    = 0x2000        /* packet is promiscuous */
@@ -119,7 +119,7 @@ enum {
        MBUF_TYPE_PCB           = 4,    /* protocol control block */
        MBUF_TYPE_RTABLE        = 5,    /* routing tables */
        MBUF_TYPE_HTABLE        = 6,    /* IMP host tables */
-       MBUF_TYPE_ATABLE        = 7,    /* address resolution tables */ 
+       MBUF_TYPE_ATABLE        = 7,    /* address resolution tables */
        MBUF_TYPE_SONAME        = 8,    /* socket name */
        MBUF_TYPE_SOOPTS        = 10,   /* socket options */
        MBUF_TYPE_FTABLE        = 11,   /* fragment reassembly header */
@@ -146,10 +146,16 @@ typedef u_int32_t mbuf_type_t;
        @constant MBUF_CSUM_REQ_UDP Indicates the UDP checksum has not been
                calculated yet.
 */
+enum {
+       MBUF_TSO_IPV4           = 0x100000,
+       MBUF_TSO_IPV6           = 0x200000
+};
+typedef u_int32_t mbuf_tso_request_flags_t;
+
 enum {
 #ifdef KERNEL_PRIVATE
        MBUF_CSUM_REQ_SUM16     = 0x1000, /* Weird apple hardware checksum */
-#endif KERNEL_PRIVATE
+#endif /* KERNEL_PRIVATE */
        MBUF_CSUM_REQ_IP        = 0x0001,
        MBUF_CSUM_REQ_TCP       = 0x0002,
        MBUF_CSUM_REQ_UDP       = 0x0004
@@ -181,11 +187,11 @@ typedef u_int32_t mbuf_csum_request_flags_t;
 */
 enum {
 #ifdef KERNEL_PRIVATE
-       MBUF_CSUM_TCP_SUM16             = MBUF_CSUM_REQ_SUM16,  /* Weird apple hardware checksum */
-#endif
-       MBUF_CSUM_DID_IP                = 0x0100,
-       MBUF_CSUM_IP_GOOD               = 0x0200,
-       MBUF_CSUM_DID_DATA              = 0x0400,
+       MBUF_CSUM_TCP_SUM16     = MBUF_CSUM_REQ_SUM16,  /* Weird apple hardware checksum */
+#endif /* KERNEL_PRIVATE */
+       MBUF_CSUM_DID_IP        = 0x0100,
+       MBUF_CSUM_IP_GOOD       = 0x0200,
+       MBUF_CSUM_DID_DATA      = 0x0400,
        MBUF_CSUM_PSEUDO_HDR    = 0x0800
 };
 typedef u_int32_t mbuf_csum_performed_flags_t;
@@ -204,8 +210,8 @@ typedef u_int32_t mbuf_csum_performed_flags_t;
                block, if blocking is necessary fail and return immediately.
 */
 enum {
-       MBUF_WAITOK             = 0,    /* Ok to block to get memory */
-       MBUF_DONTWAIT   = 1             /* Don't block, fail if blocking would be required */
+       MBUF_WAITOK     = 0,    /* Ok to block to get memory */
+       MBUF_DONTWAIT   = 1     /* Don't block, fail if blocking would be required */
 };
 typedef u_int32_t mbuf_how_t;
 
@@ -235,23 +241,23 @@ typedef   u_int16_t mbuf_tag_type_t;
        @field bigmclbytes Length of a big mbuf cluster.
 */
 struct mbuf_stat {
-       u_long  mbufs;                  /* mbufs obtained from page pool */
-       u_long  clusters;               /* clusters obtained from page pool */
-       u_long  clfree;                 /* free clusters */
-       u_long  drops;                  /* times failed to find space */
-       u_long  wait;                   /* times waited for space */
-       u_long  drain;                  /* times drained protocols for space */
-       u_short mtypes[256];    /* type specific mbuf allocations */
-       u_long  mcfail;                 /* times m_copym failed */
-       u_long  mpfail;                 /* times m_pullup failed */
-       u_long  msize;                  /* length of an mbuf */
-       u_long  mclbytes;               /* length of an mbuf cluster */
-       u_long  minclsize;              /* min length of data to allocate a cluster */
-       u_long  mlen;                   /* length of data in an mbuf */
-       u_long  mhlen;                  /* length of data in a header mbuf */
-       u_long  bigclusters;    /* number of big clusters */
-       u_long  bigclfree;              /* number of big clustser free */
-       u_long  bigmclbytes;    /* length of data in a big cluster */
+       u_int32_t       mbufs;          /* mbufs obtained from page pool */
+       u_int32_t       clusters;       /* clusters obtained from page pool */
+       u_int32_t       clfree;         /* free clusters */
+       u_int32_t       drops;          /* times failed to find space */
+       u_int32_t       wait;           /* times waited for space */
+       u_int32_t       drain;          /* times drained protocols for space */
+       u_short         mtypes[256];    /* type specific mbuf allocations */
+       u_int32_t       mcfail;         /* times m_copym failed */
+       u_int32_t       mpfail;         /* times m_pullup failed */
+       u_int32_t       msize;          /* length of an mbuf */
+       u_int32_t       mclbytes;       /* length of an mbuf cluster */
+       u_int32_t       minclsize;      /* min length of data to allocate a cluster */
+       u_int32_t       mlen;           /* length of data in an mbuf */
+       u_int32_t       mhlen;          /* length of data in a header mbuf */
+       u_int32_t       bigclusters;    /* number of big clusters */
+       u_int32_t       bigclfree;      /* number of big clustser free */
+       u_int32_t       bigmclbytes;    /* length of data in a big cluster */
 };
 
 /* Parameter for m_copym to copy all bytes */
@@ -277,7 +283,7 @@ __BEGIN_DECLS
        @param mbuf The mbuf.
        @result A pointer to the data in the mbuf.
  */
-void*          mbuf_data(mbuf_t mbuf);
+extern void *mbuf_data(mbuf_t mbuf);
 
 /*!
        @function mbuf_datastart
@@ -285,12 +291,12 @@ void*             mbuf_data(mbuf_t mbuf);
                data in an mbuf. An mbuf's data may come from a cluster or be
                embedded in the mbuf structure itself. The data pointer
                retrieved by mbuf_data may not be at the start of the data
-               (mbuf_leadingspace will be non-zero). This function will return to
-               you a pointer that matches mbuf_data() - mbuf_leadingspace().
+               (mbuf_leadingspace will be non-zero). This function will return
+               a pointer that matches mbuf_data() - mbuf_leadingspace().
        @param mbuf The mbuf.
        @result A pointer to smallest possible value for data.
  */
-void*          mbuf_datastart(mbuf_t mbuf);
+extern void *mbuf_datastart(mbuf_t mbuf);
 
 /*!
        @function mbuf_setdata
@@ -306,7 +312,7 @@ void*               mbuf_datastart(mbuf_t mbuf);
        @param len The new length of data in the mbuf.
        @result 0 on success, errno error on failure.
  */
-errno_t                mbuf_setdata(mbuf_t mbuf, void *data, size_t len);
+extern errno_t mbuf_setdata(mbuf_t mbuf, void *data, size_t len);
 
 /*!
        @function mbuf_align_32
@@ -319,7 +325,7 @@ errno_t             mbuf_setdata(mbuf_t mbuf, void *data, size_t len);
                data location.
        @result 0 on success, errno error on failure.
  */
-errno_t                mbuf_align_32(mbuf_t mbuf, size_t len);
+extern errno_t mbuf_align_32(mbuf_t mbuf, size_t len);
 
 /*!
        @function mbuf_data_to_physical
@@ -338,7 +344,7 @@ errno_t             mbuf_align_32(mbuf_t mbuf, size_t len);
        @result The 64 bit physical address of the mbuf data or NULL if ptr
                does not point to data stored in an mbuf.
  */
-addr64_t       mbuf_data_to_physical(void* ptr);
+extern addr64_t mbuf_data_to_physical(void *ptr);
 
 
 /* Allocation */
@@ -351,7 +357,7 @@ addr64_t    mbuf_data_to_physical(void* ptr);
        @param mbuf The mbuf.
        @result 0 on success, errno error on failure.
  */
-errno_t                mbuf_get(mbuf_how_t how, mbuf_type_t type, mbuf_t* mbuf);
+extern errno_t mbuf_get(mbuf_how_t how, mbuf_type_t type, mbuf_t *mbuf);
 
 /*!
        @function mbuf_gethdr
@@ -363,7 +369,7 @@ errno_t             mbuf_get(mbuf_how_t how, mbuf_type_t type, mbuf_t* mbuf);
        @param mbuf The mbuf.
        @result 0 on success, errno error on failure.
  */
-errno_t                mbuf_gethdr(mbuf_how_t how, mbuf_type_t type, mbuf_t* mbuf);
+extern errno_t mbuf_gethdr(mbuf_how_t how, mbuf_type_t type, mbuf_t *mbuf);
 
 /*!
        @function mbuf_attachcluster
@@ -391,9 +397,8 @@ errno_t             mbuf_gethdr(mbuf_how_t how, mbuf_type_t type, mbuf_t* mbuf);
                EINVAL - Invalid parameter
                ENOMEM - Not enough memory available
  */
-errno_t
-mbuf_attachcluster(mbuf_how_t how, mbuf_type_t type, mbuf_t *mbuf,
-    caddr_t extbuf, void (*extfree)(caddr_t , u_int, caddr_t),
+extern errno_t mbuf_attachcluster(mbuf_how_t how, mbuf_type_t type,
+    mbuf_t *mbuf, caddr_t extbuf, void (*extfree)(caddr_t , u_int, caddr_t),
     size_t extsize, caddr_t extarg);
 
 /*!
@@ -419,7 +424,7 @@ mbuf_attachcluster(mbuf_how_t how, mbuf_type_t type, mbuf_t *mbuf,
                In this case, the caller is advised to use 4096 bytes or
                smaller during subseqent requests.
  */
-errno_t mbuf_alloccluster(mbuf_how_t how, size_t *size, caddr_t *addr);
+extern errno_t mbuf_alloccluster(mbuf_how_t how, size_t *size, caddr_t *addr);
 
 /*!
        @function mbuf_freecluster
@@ -430,7 +435,7 @@ errno_t mbuf_alloccluster(mbuf_how_t how, size_t *size, caddr_t *addr);
        @param addr The address of the cluster.
        @param size The actual size of the cluster.
  */
-void mbuf_freecluster(caddr_t addr, size_t size);
+extern void mbuf_freecluster(caddr_t addr, size_t size);
 
 /*!
        @function mbuf_getcluster
@@ -459,7 +464,8 @@ void mbuf_freecluster(caddr_t addr, size_t size);
                    In this case, the caller is advised to use 4096 bytes or
                    smaller during subsequent requests.
  */
-errno_t                mbuf_getcluster(mbuf_how_t how, mbuf_type_t type, size_t size, mbuf_t* mbuf);
+extern errno_t mbuf_getcluster(mbuf_how_t how, mbuf_type_t type, size_t size,
+    mbuf_t *mbuf);
 
 /*!
        @function mbuf_mclget
@@ -476,7 +482,7 @@ errno_t             mbuf_getcluster(mbuf_how_t how, mbuf_type_t type, size_t size, mbuf_t*
                will be freed. If you specify an mbuf value in *mbuf,
                mbuf_mclget will not free it.
  */
-errno_t                mbuf_mclget(mbuf_how_t how, mbuf_type_t type, mbuf_t* mbuf);
+extern errno_t mbuf_mclget(mbuf_how_t how, mbuf_type_t type, mbuf_t *mbuf);
 
 /*!
        @function mbuf_allocpacket
@@ -513,7 +519,8 @@ errno_t             mbuf_mclget(mbuf_how_t how, mbuf_type_t type, mbuf_t* mbuf);
                ENOBUFS - Buffers not big enough for the maximum number of
                    chunks requested
 */
-errno_t        mbuf_allocpacket(mbuf_how_t how, size_t packetlen, unsigned int * maxchunks, mbuf_t *mbuf);
+extern errno_t mbuf_allocpacket(mbuf_how_t how, size_t packetlen,
+    unsigned int * maxchunks, mbuf_t *mbuf);
 
 /*!
        @function mbuf_allocpacket_list
@@ -551,7 +558,8 @@ errno_t     mbuf_allocpacket(mbuf_how_t how, size_t packetlen, unsigned int * maxchu
                ENOBUFS - Buffers not big enough for the maximum number of
                    chunks requested
 */
-errno_t        mbuf_allocpacket_list(unsigned int numpkts, mbuf_how_t how, size_t packetlen, unsigned int * maxchunks, mbuf_t *mbuf);
+extern errno_t mbuf_allocpacket_list(unsigned int numpkts, mbuf_how_t how,
+    size_t packetlen, unsigned int * maxchunks, mbuf_t *mbuf);
 
 
 /*!
@@ -562,7 +570,7 @@ errno_t     mbuf_allocpacket_list(unsigned int numpkts, mbuf_how_t how, size_t packe
        @param mbuf Upon success, *mbuf will be a reference to the new mbuf.
        @result 0 on success, errno error on failure.
  */
-errno_t                mbuf_getpacket(mbuf_how_t how, mbuf_t* mbuf);
+extern errno_t mbuf_getpacket(mbuf_how_t how, mbuf_t *mbuf);
 
 /*!
        @function mbuf_free
@@ -571,14 +579,14 @@ errno_t           mbuf_getpacket(mbuf_how_t how, mbuf_t* mbuf);
        @param mbuf The mbuf to free.
        @result The next mbuf in the chain.
  */
-mbuf_t         mbuf_free(mbuf_t mbuf);
+extern mbuf_t mbuf_free(mbuf_t mbuf);
 
 /*!
        @function mbuf_freem
        @discussion Frees a chain of mbufs link through mnext.
        @param mbuf The first mbuf in the chain to free.
  */
-void           mbuf_freem(mbuf_t mbuf);
+extern void mbuf_freem(mbuf_t mbuf);
 
 /*!
        @function mbuf_freem_list
@@ -587,7 +595,7 @@ void                mbuf_freem(mbuf_t mbuf);
        @param mbuf The first mbuf in the linked list to free.
        @result The number of mbufs freed.
  */
-int                    mbuf_freem_list(mbuf_t mbuf);
+extern int mbuf_freem_list(mbuf_t mbuf);
 
 /*!
        @function mbuf_leadingspace
@@ -596,7 +604,7 @@ int                 mbuf_freem_list(mbuf_t mbuf);
        @param mbuf The mbuf.
        @result The number of unused bytes at the start of the mbuf.
  */
-size_t         mbuf_leadingspace(const mbuf_t mbuf);
+extern size_t mbuf_leadingspace(const mbuf_t mbuf);
 
 /*!
        @function mbuf_trailingspace
@@ -605,7 +613,7 @@ size_t              mbuf_leadingspace(const mbuf_t mbuf);
        @param mbuf The mbuf.
        @result The number of unused bytes following the current data.
  */
-size_t         mbuf_trailingspace(const mbuf_t mbuf);
+extern size_t mbuf_trailingspace(const mbuf_t mbuf);
 
 /* Manipulation */
 
@@ -623,8 +631,8 @@ size_t              mbuf_trailingspace(const mbuf_t mbuf);
        @param new_mbuf Upon success, the newly allocated mbuf.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_copym(const mbuf_t src, size_t offset, size_t len,
-                                               mbuf_how_t how, mbuf_t* new_mbuf);
+extern errno_t mbuf_copym(const mbuf_t src, size_t offset, size_t len,
+    mbuf_how_t how, mbuf_t *new_mbuf);
 
 /*!
        @function mbuf_dup
@@ -637,7 +645,7 @@ errno_t             mbuf_copym(const mbuf_t src, size_t offset, size_t len,
        @param new_mbuf Upon success, the newly allocated mbuf.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_dup(const mbuf_t src, mbuf_how_t how, mbuf_t* new_mbuf);
+extern errno_t mbuf_dup(const mbuf_t src, mbuf_how_t how, mbuf_t *new_mbuf);
 
 /*!
        @function mbuf_prepend
@@ -652,7 +660,7 @@ errno_t             mbuf_dup(const mbuf_t src, mbuf_how_t how, mbuf_t* new_mbuf);
        @param how Blocking or non-blocking.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_prepend(mbuf_t* mbuf, size_t len, mbuf_how_t how);
+extern errno_t mbuf_prepend(mbuf_t *mbuf, size_t len, mbuf_how_t how);
 
 /*!
        @function mbuf_split
@@ -667,8 +675,8 @@ errno_t             mbuf_prepend(mbuf_t* mbuf, size_t len, mbuf_how_t how);
                failure, the original mbuf chain passed in to src will be
                preserved.
  */
-errno_t                mbuf_split(mbuf_t src, size_t offset,
-                                               mbuf_how_t how, mbuf_t* new_mbuf);
+extern errno_t mbuf_split(mbuf_t src, size_t offset, mbuf_how_t how,
+    mbuf_t *new_mbuf);
 
 /*!
        @function mbuf_pullup
@@ -681,7 +689,7 @@ errno_t             mbuf_split(mbuf_t src, size_t offset,
        @result 0 upon success otherwise the errno error. In the case of an
                error, the mbuf chain has been freed.
  */
-errno_t                mbuf_pullup(mbuf_t* mbuf, size_t len);
+extern errno_t mbuf_pullup(mbuf_t *mbuf, size_t len);
 
 /*!
        @function mbuf_pulldown
@@ -701,7 +709,8 @@ errno_t             mbuf_pullup(mbuf_t* mbuf, size_t len);
                in.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_pulldown(mbuf_t src, size_t *offset, size_t length, mbuf_t *location);
+extern errno_t mbuf_pulldown(mbuf_t src, size_t *offset, size_t length,
+    mbuf_t *location);
 
 /*!
        @function mbuf_adj
@@ -712,7 +721,7 @@ errno_t             mbuf_pulldown(mbuf_t src, size_t *offset, size_t length, mbuf_t *locati
        @param mbuf The mbuf chain to trim.
        @param len The number of bytes to trim from the mbuf chain.
  */
-void           mbuf_adj(mbuf_t mbuf, int len);
+extern void mbuf_adj(mbuf_t mbuf, int len);
 
 /*!
        @function mbuf_adjustlen
@@ -725,7 +734,26 @@ void               mbuf_adj(mbuf_t mbuf, int len);
        @param amount The number of bytes increment the length by.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_adjustlen(mbuf_t mbuf, int amount);
+extern errno_t mbuf_adjustlen(mbuf_t mbuf, int amount);
+
+/*!
+       @function mbuf_concatenate
+       @discussion Concatenate mbuf chain src to dst using m_next and return
+               a chain which represents the concatenated chain.  The routine
+               does not prevent two chains of different mbuf types to be
+               concatenated, nor does it modify any packet header in the
+               destination chain.  Therefore, it's the responsibility of the
+               caller to ensure that the resulted concatenated mbuf chain is
+               correct for further usages.
+       @param dst The destination mbuf chain.
+       @param src The source mbuf chain.
+       @result A pointer to the head of the concatenated mbuf chain.  This
+               should be treated as the updated destination mbuf chain; the
+               caller must no longer refer to the original src or dst mbuf
+               chain.  Otherwise it returns NULL if the original dst mbuf
+               chain is NULL.
+ */
+extern mbuf_t mbuf_concatenate(mbuf_t dst, mbuf_t src);
 
 /*!
        @function mbuf_copydata
@@ -739,18 +767,19 @@ errno_t           mbuf_adjustlen(mbuf_t mbuf, int amount);
                copied.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_copydata(const mbuf_t mbuf, size_t offset, size_t length, void* out_data);
+extern errno_t mbuf_copydata(const mbuf_t mbuf, size_t offset, size_t length,
+    void *out_data);
 
 /*!
        @function mbuf_copyback
        @discussion Copies data from a buffer to an mbuf chain.
                mbuf_copyback will grow the chain to fit the specified buffer.
-               
+
                If mbuf_copydata is unable to allocate enough mbufs to grow the
                chain, ENOBUFS will be returned. The mbuf chain will be shorter
                than expected but all of the data up to the end of the mbuf
                chain will be valid.
-               
+
                If an offset is specified, mbuf_copyback will skip that many
                bytes in the mbuf chain before starting to write the buffer in
                to the chain. If the mbuf chain does not contain this many
@@ -763,8 +792,8 @@ errno_t             mbuf_copydata(const mbuf_t mbuf, size_t offset, size_t length, void* ou
        @param how Blocking or non-blocking.
        @result 0 upon success, EINVAL or ENOBUFS upon failure.
  */
-errno_t                mbuf_copyback(mbuf_t mbuf, size_t offset, size_t length,
-                                                 const void *data, mbuf_how_t how);
+extern errno_t mbuf_copyback(mbuf_t mbuf, size_t offset, size_t length,
+    const void *data, mbuf_how_t how);
 
 /*!
        @function mbuf_mclhasreference
@@ -774,7 +803,7 @@ errno_t             mbuf_copyback(mbuf_t mbuf, size_t offset, size_t length,
        @param mbuf The mbuf with the cluster to test.
        @result 0 if there is no reference by another mbuf, 1 otherwise.
  */
-int                    mbuf_mclhasreference(mbuf_t mbuf);
+extern int mbuf_mclhasreference(mbuf_t mbuf);
 
 
 /* mbuf header */
@@ -785,7 +814,7 @@ int                 mbuf_mclhasreference(mbuf_t mbuf);
        @param mbuf The mbuf.
        @result The next mbuf in the chain.
  */
-mbuf_t         mbuf_next(const mbuf_t mbuf);
+extern mbuf_t mbuf_next(const mbuf_t mbuf);
 
 /*!
        @function mbuf_setnext
@@ -794,7 +823,7 @@ mbuf_t              mbuf_next(const mbuf_t mbuf);
        @param next The new next mbuf.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_setnext(mbuf_t mbuf, mbuf_t next);
+extern errno_t mbuf_setnext(mbuf_t mbuf, mbuf_t next);
 
 /*!
        @function mbuf_nextpkt
@@ -802,7 +831,7 @@ errno_t             mbuf_setnext(mbuf_t mbuf, mbuf_t next);
        @param mbuf The mbuf.
        @result The nextpkt.
  */
-mbuf_t         mbuf_nextpkt(const mbuf_t mbuf);
+extern mbuf_t mbuf_nextpkt(const mbuf_t mbuf);
 
 /*!
        @function mbuf_setnextpkt
@@ -810,7 +839,7 @@ mbuf_t              mbuf_nextpkt(const mbuf_t mbuf);
        @param mbuf The mbuf.
        @param nextpkt The new next packet.
  */
-void           mbuf_setnextpkt(mbuf_t mbuf, mbuf_t nextpkt);
+extern void mbuf_setnextpkt(mbuf_t mbuf, mbuf_t nextpkt);
 
 /*!
        @function mbuf_len
@@ -818,7 +847,7 @@ void                mbuf_setnextpkt(mbuf_t mbuf, mbuf_t nextpkt);
        @param mbuf The mbuf.
        @result The length.
  */
-size_t         mbuf_len(const mbuf_t mbuf);
+extern size_t mbuf_len(const mbuf_t mbuf);
 
 /*!
        @function mbuf_setlen
@@ -828,7 +857,7 @@ size_t              mbuf_len(const mbuf_t mbuf);
        @param len The new length.
        @result 0 upon success otherwise the errno error.
  */
-void           mbuf_setlen(mbuf_t mbuf, size_t len);
+extern void mbuf_setlen(mbuf_t mbuf, size_t len);
 
 /*!
        @function mbuf_maxlen
@@ -839,7 +868,7 @@ void                mbuf_setlen(mbuf_t mbuf, size_t len);
        @param mbuf The mbuf.
        @result The maximum lenght of data for this mbuf.
  */
-size_t         mbuf_maxlen(const mbuf_t mbuf);
+extern size_t mbuf_maxlen(const mbuf_t mbuf);
 
 /*!
        @function mbuf_type
@@ -847,7 +876,7 @@ size_t              mbuf_maxlen(const mbuf_t mbuf);
        @param mbuf The mbuf.
        @result The type.
  */
-mbuf_type_t    mbuf_type(const mbuf_t mbuf);
+extern mbuf_type_t mbuf_type(const mbuf_t mbuf);
 
 /*!
        @function mbuf_settype
@@ -856,7 +885,7 @@ mbuf_type_t mbuf_type(const mbuf_t mbuf);
        @param new_type The new type.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_settype(mbuf_t mbuf, mbuf_type_t new_type);
+extern errno_t mbuf_settype(mbuf_t mbuf, mbuf_type_t new_type);
 
 /*!
        @function mbuf_flags
@@ -864,7 +893,7 @@ errno_t             mbuf_settype(mbuf_t mbuf, mbuf_type_t new_type);
        @param mbuf The mbuf.
        @result The flags.
  */
-mbuf_flags_t   mbuf_flags(const mbuf_t mbuf);
+extern mbuf_flags_t mbuf_flags(const mbuf_t mbuf);
 
 /*!
        @function mbuf_setflags
@@ -873,7 +902,7 @@ mbuf_flags_t        mbuf_flags(const mbuf_t mbuf);
        @param flags The flags that should be set, all other flags will be cleared.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_setflags(mbuf_t mbuf, mbuf_flags_t flags);
+extern errno_t mbuf_setflags(mbuf_t mbuf, mbuf_flags_t flags);
 
 /*!
        @function mbuf_setflags_mask
@@ -884,8 +913,8 @@ errno_t             mbuf_setflags(mbuf_t mbuf, mbuf_flags_t flags);
        @param mask The mask controlling which flags will be modified.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_setflags_mask(mbuf_t mbuf, mbuf_flags_t flags,
-                                                          mbuf_flags_t mask);
+extern errno_t mbuf_setflags_mask(mbuf_t mbuf, mbuf_flags_t flags,
+    mbuf_flags_t mask);
 
 /*!
        @function mbuf_copy_pkthdr
@@ -894,7 +923,7 @@ errno_t             mbuf_setflags_mask(mbuf_t mbuf, mbuf_flags_t flags,
        @param mbuf The mbuf to which the packet header will be copied.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_copy_pkthdr(mbuf_t dest, const mbuf_t src);
+extern errno_t mbuf_copy_pkthdr(mbuf_t dest, const mbuf_t src);
 
 /*!
        @function mbuf_pkthdr_len
@@ -903,7 +932,7 @@ errno_t             mbuf_copy_pkthdr(mbuf_t dest, const mbuf_t src);
                be changed.
        @result The length, in bytes, of the packet.
  */
-size_t         mbuf_pkthdr_len(const mbuf_t mbuf);
+extern size_t mbuf_pkthdr_len(const mbuf_t mbuf);
 
 /*!
        @function mbuf_pkthdr_setlen
@@ -911,7 +940,7 @@ size_t              mbuf_pkthdr_len(const mbuf_t mbuf);
        @param mbuf The mbuf containing the packet header.
        @param len The new length of the packet.
  */
-void           mbuf_pkthdr_setlen(mbuf_t mbuf, size_t len);
+extern void mbuf_pkthdr_setlen(mbuf_t mbuf, size_t len);
 
 /*!
        @function mbuf_pkthdr_adjustlen
@@ -920,7 +949,7 @@ void                mbuf_pkthdr_setlen(mbuf_t mbuf, size_t len);
        @param amount The number of bytes to adjust the packet header length
                field by.
  */
-void           mbuf_pkthdr_adjustlen(mbuf_t mbuf, int amount);
+extern void mbuf_pkthdr_adjustlen(mbuf_t mbuf, int amount);
 
 /*!
        @function mbuf_pkthdr_rcvif
@@ -934,7 +963,7 @@ void                mbuf_pkthdr_adjustlen(mbuf_t mbuf, int amount);
        @param mbuf The mbuf containing the packet header.
        @result A reference to the interface.
  */
-ifnet_t                mbuf_pkthdr_rcvif(const mbuf_t mbuf);
+extern ifnet_t mbuf_pkthdr_rcvif(const mbuf_t mbuf);
 
 /*!
        @function mbuf_pkthdr_setrcvif
@@ -943,7 +972,7 @@ ifnet_t             mbuf_pkthdr_rcvif(const mbuf_t mbuf);
        @param ifnet A reference to an interface.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_pkthdr_setrcvif(mbuf_t mbuf, ifnet_t ifp);
+extern errno_t mbuf_pkthdr_setrcvif(mbuf_t mbuf, ifnet_t ifp);
 
 /*!
        @function mbuf_pkthdr_header
@@ -951,7 +980,7 @@ errno_t             mbuf_pkthdr_setrcvif(mbuf_t mbuf, ifnet_t ifp);
        @param mbuf The mbuf containing the packet header.
        @result A pointer to the packet header.
  */
-void*          mbuf_pkthdr_header(const mbuf_t mbuf);
+extern void *mbuf_pkthdr_header(const mbuf_t mbuf);
 
 /*!
        @function mbuf_pkthdr_setheader
@@ -960,7 +989,7 @@ void*               mbuf_pkthdr_header(const mbuf_t mbuf);
        @param ifnet A pointer to the header.
        @result 0 upon success otherwise the errno error.
  */
-void           mbuf_pkthdr_setheader(mbuf_t mbuf, void* header);
+extern void mbuf_pkthdr_setheader(mbuf_t mbuf, void *header);
 
 /* Checksums */
 
@@ -977,13 +1006,13 @@ void             mbuf_pkthdr_setheader(mbuf_t mbuf, void* header);
                original checksum was valid.
        @param mbuf The mbuf that has been modified.
  */
-void           mbuf_inbound_modified(mbuf_t mbuf);
+extern void mbuf_inbound_modified(mbuf_t mbuf);
 
 /*!
        @function mbuf_outbound_finalize
        @discussion This function will "finalize" the packet allowing your
                code to inspect the final packet.
-               
+
                There are a number of operations that are performed in hardware,
                such as calculating checksums. This function will perform in
                software the various opterations that were scheduled to be done
@@ -997,10 +1026,10 @@ void             mbuf_inbound_modified(mbuf_t mbuf);
                hardware, you must call this function to get an aproximate final
                packet. If you plan to modify the packet in any way, you should
                call this function.
-               
+
                This function should be called before modifying any outbound
                packets.
-               
+
                This function may be called at various levels, in some cases
                additional headers may have already been prepended, such as the
                case of a packet seen by an interface filter. To handle this,
@@ -1014,8 +1043,8 @@ void              mbuf_inbound_modified(mbuf_t mbuf);
                protocol header. For an IP packet with an ethernet header, this
                would be the length of an ethernet header.
  */
-void           mbuf_outbound_finalize(mbuf_t mbuf, u_long protocol_family,
-                               size_t protocol_offset);
+extern void mbuf_outbound_finalize(mbuf_t mbuf, u_int32_t protocol_family,
+    size_t protocol_offset);
 
 /*!
        @function mbuf_set_vlan_tag
@@ -1026,7 +1055,7 @@ void              mbuf_outbound_finalize(mbuf_t mbuf, u_long protocol_family,
        @param vlan The protocol family of the aux data to add.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_set_vlan_tag(mbuf_t mbuf, u_int16_t vlan);
+extern errno_t mbuf_set_vlan_tag(mbuf_t mbuf, u_int16_t vlan);
 
 /*!
        @function mbuf_get_vlan_tag
@@ -1040,7 +1069,7 @@ errno_t           mbuf_set_vlan_tag(mbuf_t mbuf, u_int16_t vlan);
        @result 0 upon success otherwise the errno error. ENXIO indicates
                that the vlan tag is not set.
  */
-errno_t                mbuf_get_vlan_tag(mbuf_t mbuf, u_int16_t *vlan);
+extern errno_t mbuf_get_vlan_tag(mbuf_t mbuf, u_int16_t *vlan);
 
 /*!
        @function mbuf_clear_vlan_tag
@@ -1049,7 +1078,7 @@ errno_t           mbuf_get_vlan_tag(mbuf_t mbuf, u_int16_t *vlan);
        @param mbuf The mbuf containing the packet.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_clear_vlan_tag(mbuf_t mbuf);
+extern errno_t mbuf_clear_vlan_tag(mbuf_t mbuf);
 
 #ifdef KERNEL_PRIVATE
 /*
@@ -1066,9 +1095,9 @@ errno_t           mbuf_clear_vlan_tag(mbuf_t mbuf);
        @param value This parameter is currently unsupported.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_set_csum_requested(mbuf_t mbuf,
-                               mbuf_csum_request_flags_t request, u_int32_t value);
-#endif
+extern errno_t mbuf_set_csum_requested(mbuf_t mbuf,
+    mbuf_csum_request_flags_t request, u_int32_t value);
+#endif /* KERNEL_PRIVATE */
 
 /*!
        @function mbuf_get_csum_requested
@@ -1080,8 +1109,21 @@ errno_t          mbuf_set_csum_requested(mbuf_t mbuf,
        @param value This parameter is currently unsupported.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_get_csum_requested(mbuf_t mbuf,
-                               mbuf_csum_request_flags_t *request, u_int32_t *value);
+extern errno_t mbuf_get_csum_requested(mbuf_t mbuf,
+    mbuf_csum_request_flags_t *request, u_int32_t *value);
+
+/*!
+       @function mbuf_get_tso_requested
+       @discussion This function is used by the driver to determine which
+               checksum operations should be performed in hardware.
+       @param mbuf The mbuf containing the packet.
+       @param request Flags indicating which values are being requested
+               for this packet.
+       @param value The requested value.
+       @result 0 upon success otherwise the errno error.
+ */
+extern errno_t mbuf_get_tso_requested(mbuf_t mbuf,
+    mbuf_tso_request_flags_t *request, u_int32_t *value);
 
 /*!
        @function mbuf_clear_csum_requested
@@ -1089,7 +1131,7 @@ errno_t           mbuf_get_csum_requested(mbuf_t mbuf,
        @param mbuf The mbuf containing the packet.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_clear_csum_requested(mbuf_t mbuf);
+extern errno_t mbuf_clear_csum_requested(mbuf_t mbuf);
 
 /*!
        @function mbuf_set_csum_performed
@@ -1103,8 +1145,8 @@ errno_t           mbuf_clear_csum_requested(mbuf_t mbuf);
                hardware.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_set_csum_performed(mbuf_t mbuf,
-                               mbuf_csum_performed_flags_t flags, u_int32_t value);
+extern errno_t mbuf_set_csum_performed(mbuf_t mbuf,
+    mbuf_csum_performed_flags_t flags, u_int32_t value);
 
 #ifdef KERNEL_PRIVATE
 /*
@@ -1119,9 +1161,27 @@ errno_t          mbuf_set_csum_performed(mbuf_t mbuf,
                hardware.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_get_csum_performed(mbuf_t mbuf,
-                               mbuf_csum_performed_flags_t *flags, u_int32_t *value);
-#endif
+extern errno_t mbuf_get_csum_performed(mbuf_t mbuf,
+    mbuf_csum_performed_flags_t *flags, u_int32_t *value);
+#endif /* KERNEL_PRIVATE */
+
+/*!
+       @function mbuf_get_mlen
+       @discussion This routine returns the number of data bytes in a normal
+               mbuf, i.e. an mbuf that is not a packet header, nor one with
+               an external cluster attached to it.  This is equivalent to the
+               legacy MLEN macro.
+       @result The number of bytes of available data.
+ */
+extern u_int32_t mbuf_get_mlen(void);
+
+/*!
+       @function mbuf_get_mhlen
+       @discussion This routine returns the number of data bytes in a packet
+               header mbuf.  This is equivalent to the legacy MHLEN macro.
+       @result The number of bytes of available data.
+ */
+extern u_int32_t mbuf_get_mhlen(void);
 
 /*!
        @function mbuf_clear_csum_performed
@@ -1129,7 +1189,7 @@ errno_t           mbuf_get_csum_performed(mbuf_t mbuf,
        @param mbuf The mbuf containing the packet.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_clear_csum_performed(mbuf_t mbuf);
+extern errno_t mbuf_clear_csum_performed(mbuf_t mbuf);
 
 /*!
        @function mbuf_inet_cksum
@@ -1157,8 +1217,8 @@ errno_t           mbuf_clear_csum_performed(mbuf_t mbuf);
                this variable.  The caller must set it to a non-NULL value.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_inet_cksum(mbuf_t mbuf, int protocol, u_int32_t offset,
-                   u_int32_t length, u_int16_t *csum);
+extern errno_t mbuf_inet_cksum(mbuf_t mbuf, int protocol, u_int32_t offset,
+    u_int32_t length, u_int16_t *csum);
 
 /*!
        @function mbuf_inet6_cksum
@@ -1186,8 +1246,8 @@ errno_t           mbuf_inet_cksum(mbuf_t mbuf, int protocol, u_int32_t offset,
                this variable.  The caller must set it to a non-NULL value.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_inet6_cksum(mbuf_t mbuf, int protocol, u_int32_t offset,
-                   u_int32_t length, u_int16_t *csum);
+extern errno_t mbuf_inet6_cksum(mbuf_t mbuf, int protocol, u_int32_t offset,
+    u_int32_t length, u_int16_t *csum);
 
 /* mbuf tags */
 
@@ -1196,12 +1256,12 @@ errno_t         mbuf_inet6_cksum(mbuf_t mbuf, int protocol, u_int32_t offset,
        @discussion Lookup the module id for a string. If there is no module
                id assigned to this string, a new module id will be assigned.
                The string should be the bundle id of the kext. In the case of a
-               tag that will be shared across multiple kexts, a common bundle id
-               style string should be used.
-               
+               tag that will be shared across multiple kexts, a common bundle
+               id style string should be used.
+
                The lookup operation is not optimized. A module should call this
-               function once during startup and chache the module id. The module id
-               will not be resassigned until the machine reboots.
+               function once during startup and chache the module id. The
+               module id will not be resassigned until the machine reboots.
        @param module_string A unique string identifying your module.
                Example: com.apple.nke.SharedIP.
        @param module_id Upon return, a unique identifier for use with
@@ -1209,16 +1269,16 @@ errno_t         mbuf_inet6_cksum(mbuf_t mbuf, int protocol, u_int32_t offset,
                is rebooted.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_tag_id_find(const char *module_string,
-                                                        mbuf_tag_id_t *module_id);
+extern errno_t mbuf_tag_id_find(const char *module_string,
+    mbuf_tag_id_t *module_id);
 
 /*!
        @function mbuf_tag_allocate
        @discussion Allocate an mbuf tag. Mbuf tags allow various portions
                of the stack to tag mbufs with data that will travel with the
                mbuf through the stack.
-               
-               Tags may only be added to mbufs with packet headers 
+
+               Tags may only be added to mbufs with packet headers
                (MBUF_PKTHDR flag is set). Mbuf tags are freed when the mbuf is
                freed or when mbuf_tag_free is called.
        @param mbuf The mbuf to attach this tag to.
@@ -1233,9 +1293,8 @@ errno_t           mbuf_tag_id_find(const char *module_string,
                buffer allocated for the mtag.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_tag_allocate(mbuf_t mbuf, mbuf_tag_id_t module_id,
-                                                         mbuf_tag_type_t type, size_t length,
-                                                         mbuf_how_t how, void** data_p);
+extern errno_t mbuf_tag_allocate(mbuf_t mbuf, mbuf_tag_id_t module_id,
+    mbuf_tag_type_t type, size_t length, mbuf_how_t how, void **data_p);
 
 /*!
        @function mbuf_tag_find
@@ -1249,8 +1308,8 @@ errno_t           mbuf_tag_allocate(mbuf_t mbuf, mbuf_tag_id_t module_id,
                buffer allocated for the mtag.
        @result 0 upon success otherwise the errno error.
  */
-errno_t                mbuf_tag_find(mbuf_t mbuf, mbuf_tag_id_t module_id,
-                                                 mbuf_tag_type_t type, size_t *length, void** data_p);
+extern errno_t mbuf_tag_find(mbuf_t mbuf, mbuf_tag_id_t module_id,
+    mbuf_tag_type_t type, size_t *length, void **data_p);
 
 /*!
        @function mbuf_tag_free
@@ -1259,8 +1318,8 @@ errno_t           mbuf_tag_find(mbuf_t mbuf, mbuf_tag_id_t module_id,
        @param module_id The ID of the tag to free.
        @param type The type of the tag to free.
  */
-void           mbuf_tag_free(mbuf_t mbuf, mbuf_tag_id_t module_id,
-                                                 mbuf_tag_type_t type);
+extern void mbuf_tag_free(mbuf_t mbuf, mbuf_tag_id_t module_id,
+    mbuf_tag_type_t type);
 
 /* mbuf stats */
 
@@ -1269,37 +1328,100 @@ void           mbuf_tag_free(mbuf_t mbuf, mbuf_tag_id_t module_id,
        @discussion Get the mbuf statistics.
        @param stats Storage to copy the stats in to.
  */
-void           mbuf_stats(struct mbuf_stat* stats);
+extern void mbuf_stats(struct mbuf_stat *stats);
 
+#ifdef KERNEL_PRIVATE
+/*
+       @enum mbuf_priority_t
+       @abstract Priority of a packet.
+       @discussion Some mbufs represent packets containing application data.
+               The priority of the application data is represented by the
+               mbuf priority, as determined by the system.
+       @constant MBUF_PRIORITY_NORMAL Indicates the packet contains
+               normal priority data.
+       @constant MBUF_PRIORITY_BACKGROUND Indicates the packet contains
+               background priority data.
+ */
+typedef enum {
+       MBUF_PRIORITY_NORMAL            = 0,
+       MBUF_PRIORITY_BACKGROUND        = 1
+} mbuf_priority_t;
 
+/*
+       @function mbuf_get_priority
+       @discussion Get the priority value of the packet.
+       @param mbuf The mbuf to obtain the priority value from.
+       @result The priority value of the packet.
+ */
+extern mbuf_priority_t mbuf_get_priority(mbuf_t mbuf);
+
+/*
+       @enum mbuf_traffic_class_t
+       @abstract Traffic class of a packet
+       @discussion Property that represent the category of traffic of a packet. 
+               This information may be used by the driver and at the link level.
+       @constant MBUF_TC_BE Best effort, normal class.
+       @constant MBUF_TC_BK Background, low priority or bulk traffic.
+       @constant MBUF_TC_VI Interactive video, constant bit rate, low latency.
+       @constant MBUF_TC_VO Interactive voice, constant bit rate, lowest latency.
+*/
+typedef enum {
+#ifdef XNU_KERNEL_PRIVATE
+       MBUF_TC_NONE    = -1,
+#endif
+       MBUF_TC_BE              = 0,
+       MBUF_TC_BK              = 1,
+       MBUF_TC_VI              = 2,
+       MBUF_TC_VO              = 3
+} mbuf_traffic_class_t;
+
+/*
+       @function mbuf_get_traffic_class
+       @discussion Get the traffic class of an mbuf packet
+       @param mbuf The mbuf to get the traffic class of.
+       @result The traffic class
+*/
+extern mbuf_traffic_class_t mbuf_get_traffic_class(mbuf_t mbuf);
+
+/*
+       @function mbuf_set_traffic_class
+       @discussion Set the traffic class of an mbuf packet.
+       @param mbuf The mbuf to set the traffic class on.
+       @ac The traffic class
+       @result 0 on success, EINVAL if bad paramater is passed
+*/
+extern errno_t mbuf_set_traffic_class(mbuf_t mbuf, mbuf_traffic_class_t tc);
+#endif /* KERNEL_PRIVATE */
 
 /* IF_QUEUE interaction */
 
-#define IF_ENQUEUE_MBUF(ifq, m) { \
-       mbuf_setnextpkt((m), 0); \
-       if ((ifq)->ifq_tail == 0) \
-               (ifq)->ifq_head = (m); \
-       else \
-               mbuf_setnextpkt((mbuf_t)(ifq)->ifq_tail, (m)); \
-       (ifq)->ifq_tail = (m); \
-       (ifq)->ifq_len++; \
+#define IF_ENQUEUE_MBUF(ifq, m) {                                      \
+       mbuf_setnextpkt((m), 0);                                        \
+       if ((ifq)->ifq_tail == 0)                                       \
+               (ifq)->ifq_head = (m);                                  \
+       else                                                            \
+               mbuf_setnextpkt((mbuf_t)(ifq)->ifq_tail, (m));          \
+       (ifq)->ifq_tail = (m);                                          \
+       (ifq)->ifq_len++;                                               \
 }
-#define        IF_PREPEND_MBUF(ifq, m) { \
-       mbuf_setnextpkt((m), (ifq)->ifq_head); \
-       if ((ifq)->ifq_tail == 0) \
-               (ifq)->ifq_tail = (m); \
-       (ifq)->ifq_head = (m); \
-       (ifq)->ifq_len++; \
+
+#define        IF_PREPEND_MBUF(ifq, m) {                                       \
+       mbuf_setnextpkt((m), (ifq)->ifq_head);                          \
+       if ((ifq)->ifq_tail == 0)                                       \
+               (ifq)->ifq_tail = (m);                                  \
+       (ifq)->ifq_head = (m);                                          \
+       (ifq)->ifq_len++;                                               \
 }
-#define        IF_DEQUEUE_MBUF(ifq, m) { \
-       (m) = (ifq)->ifq_head; \
-       if (m) { \
-               if (((ifq)->ifq_head = mbuf_nextpkt((m))) == 0) \
-                       (ifq)->ifq_tail = 0; \
-               mbuf_setnextpkt((m), 0); \
-               (ifq)->ifq_len--; \
-       } \
+
+#define        IF_DEQUEUE_MBUF(ifq, m) {                                       \
+       (m) = (ifq)->ifq_head;                                          \
+       if (m) {                                                        \
+               if (((ifq)->ifq_head = mbuf_nextpkt((m))) == 0)         \
+                       (ifq)->ifq_tail = 0;                            \
+               mbuf_setnextpkt((m), 0);                                \
+               (ifq)->ifq_len--;                                       \
+       }                                                               \
 }
 
 __END_DECLS
-#endif
+#endif /* __KPI_MBUF__ */