Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Move m_align and m_append into iee80211_netbsd.c. They a...



details:   https://anonhg.NetBSD.org/src/rev/68af066e2ab1
branches:  trunk
changeset: 361374:68af066e2ab1
user:      maxv <maxv%NetBSD.org@localhost>
date:      Fri Apr 27 06:56:21 2018 +0000

description:
Move m_align and m_append into iee80211_netbsd.c. They are part of
net80211, and shouldn't be used outside.

diffstat:

 sys/kern/uipc_mbuf.c            |  73 +--------------------------------------
 sys/net80211/ieee80211_netbsd.c |  75 +++++++++++++++++++++++++++++++++++++++-
 sys/net80211/ieee80211_netbsd.h |   5 ++-
 sys/sys/mbuf.h                  |   4 +-
 4 files changed, 80 insertions(+), 77 deletions(-)

diffs (222 lines):

diff -r 6b84ab76e4a2 -r 68af066e2ab1 sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c      Fri Apr 27 06:36:32 2018 +0000
+++ b/sys/kern/uipc_mbuf.c      Fri Apr 27 06:56:21 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_mbuf.c,v 1.200 2018/04/27 06:36:16 maxv Exp $     */
+/*     $NetBSD: uipc_mbuf.c,v 1.201 2018/04/27 06:56:21 maxv Exp $     */
 
 /*
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.200 2018/04/27 06:36:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.201 2018/04/27 06:56:21 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -488,75 +488,6 @@
        return c;
 }
 
-/*
- * Set the m_data pointer of a newly-allocated mbuf
- * to place an object of the specified size at the
- * end of the mbuf, longword aligned.
- */
-void
-m_align(struct mbuf *m, int len)
-{
-       int adjust;
-
-       KASSERT(len != M_COPYALL);
-
-       if (m->m_flags & M_EXT)
-               adjust = m->m_ext.ext_size - len;
-       else if (m->m_flags & M_PKTHDR)
-               adjust = MHLEN - len;
-       else
-               adjust = MLEN - len;
-       m->m_data += adjust &~ (sizeof(long)-1);
-}
-
-/*
- * Append the specified data to the indicated mbuf chain,
- * Extend the mbuf chain if the new data does not fit in
- * existing space.
- *
- * Return 1 if able to complete the job; otherwise 0.
- */
-int
-m_append(struct mbuf *m0, int len, const void *cpv)
-{
-       struct mbuf *m, *n;
-       int remainder, space;
-       const char *cp = cpv;
-
-       KASSERT(len != M_COPYALL);
-       for (m = m0; m->m_next != NULL; m = m->m_next)
-               continue;
-       remainder = len;
-       space = M_TRAILINGSPACE(m);
-       if (space > 0) {
-               /*
-                * Copy into available space.
-                */
-               if (space > remainder)
-                       space = remainder;
-               memmove(mtod(m, char *) + m->m_len, cp, space);
-               m->m_len += space;
-               cp = cp + space, remainder -= space;
-       }
-       while (remainder > 0) {
-               /*
-                * Allocate a new mbuf; could check space
-                * and allocate a cluster instead.
-                */
-               n = m_get(M_DONTWAIT, m->m_type);
-               if (n == NULL)
-                       break;
-               n->m_len = min(MLEN, remainder);
-               memmove(mtod(n, void *), cp, n->m_len);
-               cp += n->m_len, remainder -= n->m_len;
-               m->m_next = n;
-               m = n;
-       }
-       if (m0->m_flags & M_PKTHDR)
-               m0->m_pkthdr.len += len - remainder;
-       return (remainder == 0);
-}
-
 void
 m_reclaim(void *arg, int flags)
 {
diff -r 6b84ab76e4a2 -r 68af066e2ab1 sys/net80211/ieee80211_netbsd.c
--- a/sys/net80211/ieee80211_netbsd.c   Fri Apr 27 06:36:32 2018 +0000
+++ b/sys/net80211/ieee80211_netbsd.c   Fri Apr 27 06:56:21 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_netbsd.c,v 1.30 2018/01/18 17:57:49 maxv Exp $ */
+/* $NetBSD: ieee80211_netbsd.c,v 1.31 2018/04/27 06:56:21 maxv Exp $ */
 
 /*
  * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
@@ -31,7 +31,7 @@
 #ifdef __FreeBSD__
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_freebsd.c,v 1.8 2005/08/08 18:46:35 sam Exp $");
 #else
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.30 2018/01/18 17:57:49 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.31 2018/04/27 06:56:21 maxv Exp $");
 #endif
 
 /*
@@ -720,3 +720,74 @@
        printf("%s: load the %s module by hand for now.\n", __func__, modname);
 #endif
 }
+
+/* -------------------------------------------------------------------------- */
+
+/*
+ * Set the m_data pointer of a newly-allocated mbuf
+ * to place an object of the specified size at the
+ * end of the mbuf, longword aligned.
+ */
+void
+m_align(struct mbuf *m, int len)
+{
+       int adjust;
+
+       KASSERT(len != M_COPYALL);
+
+       if (m->m_flags & M_EXT)
+               adjust = m->m_ext.ext_size - len;
+       else if (m->m_flags & M_PKTHDR)
+               adjust = MHLEN - len;
+       else
+               adjust = MLEN - len;
+       m->m_data += adjust &~ (sizeof(long)-1);
+}
+
+/*
+ * Append the specified data to the indicated mbuf chain,
+ * Extend the mbuf chain if the new data does not fit in
+ * existing space.
+ *
+ * Return 1 if able to complete the job; otherwise 0.
+ */
+int
+m_append(struct mbuf *m0, int len, const void *cpv)
+{
+       struct mbuf *m, *n;
+       int remainder, space;
+       const char *cp = cpv;
+
+       KASSERT(len != M_COPYALL);
+       for (m = m0; m->m_next != NULL; m = m->m_next)
+               continue;
+       remainder = len;
+       space = M_TRAILINGSPACE(m);
+       if (space > 0) {
+               /*
+                * Copy into available space.
+                */
+               if (space > remainder)
+                       space = remainder;
+               memmove(mtod(m, char *) + m->m_len, cp, space);
+               m->m_len += space;
+               cp = cp + space, remainder -= space;
+       }
+       while (remainder > 0) {
+               /*
+                * Allocate a new mbuf; could check space
+                * and allocate a cluster instead.
+                */
+               n = m_get(M_DONTWAIT, m->m_type);
+               if (n == NULL)
+                       break;
+               n->m_len = min(MLEN, remainder);
+               memmove(mtod(n, void *), cp, n->m_len);
+               cp += n->m_len, remainder -= n->m_len;
+               m->m_next = n;
+               m = n;
+       }
+       if (m0->m_flags & M_PKTHDR)
+               m0->m_pkthdr.len += len - remainder;
+       return (remainder == 0);
+}
diff -r 6b84ab76e4a2 -r 68af066e2ab1 sys/net80211/ieee80211_netbsd.h
--- a/sys/net80211/ieee80211_netbsd.h   Fri Apr 27 06:36:32 2018 +0000
+++ b/sys/net80211/ieee80211_netbsd.h   Fri Apr 27 06:56:21 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_netbsd.h,v 1.19 2014/04/07 00:07:40 pooka Exp $ */
+/* $NetBSD: ieee80211_netbsd.h,v 1.20 2018/04/27 06:56:21 maxv Exp $ */
 /*-
  * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
  * All rights reserved.
@@ -249,4 +249,7 @@
        static void name(void)
 #endif
 
+void   m_align(struct mbuf *, int);
+int    m_append(struct mbuf *, int, const void *);
+
 #endif /* !_NET80211_IEEE80211_NETBSD_H_ */
diff -r 6b84ab76e4a2 -r 68af066e2ab1 sys/sys/mbuf.h
--- a/sys/sys/mbuf.h    Fri Apr 27 06:36:32 2018 +0000
+++ b/sys/sys/mbuf.h    Fri Apr 27 06:56:21 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mbuf.h,v 1.190 2018/04/26 19:13:34 maxv Exp $  */
+/*     $NetBSD: mbuf.h,v 1.191 2018/04/27 06:56:21 maxv Exp $  */
 
 /*
  * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -875,8 +875,6 @@
 
 bool   m_ensure_contig(struct mbuf **, int);
 struct mbuf *m_add(struct mbuf *, struct mbuf *);
-void   m_align(struct mbuf *, int);
-int    m_append(struct mbuf *, int, const void *);
 
 /* Inline routines. */
 static __inline u_int m_length(const struct mbuf *) __unused;



Home | Main Index | Thread Index | Old Index