Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Dedup. m_defrag is already a common function, no...



details:   https://anonhg.NetBSD.org/src/rev/48dd6b56fc5a
branches:  trunk
changeset: 829011:48dd6b56fc5a
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Jan 14 17:43:55 2018 +0000

description:
Dedup. m_defrag is already a common function, no need to reimplement it
there. Meanwhile this should fix two bugs (that I couldn't investigate
more than that since I don't have this hardware): the mbuf passed to
vge_m_defrag was leaked, and the tags were not copied in the returned
mbuf.

diffstat:

 sys/dev/pci/if_vge.c |  62 +--------------------------------------------------
 1 files changed, 2 insertions(+), 60 deletions(-)

diffs (83 lines):

diff -r 99d64973376e -r 48dd6b56fc5a sys/dev/pci/if_vge.c
--- a/sys/dev/pci/if_vge.c      Sun Jan 14 17:16:58 2018 +0000
+++ b/sys/dev/pci/if_vge.c      Sun Jan 14 17:43:55 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vge.c,v 1.61 2017/09/26 07:42:06 knakahara Exp $ */
+/* $NetBSD: if_vge.c,v 1.62 2018/01/14 17:43:55 maxv Exp $ */
 
 /*-
  * Copyright (c) 2004
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.61 2017/09/26 07:42:06 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.62 2018/01/14 17:43:55 maxv Exp $");
 
 /*
  * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver.
@@ -358,64 +358,6 @@
 }
 
 /*
- * Defragment mbuf chain contents to be as linear as possible.
- * Returns new mbuf chain on success, NULL on failure. Old mbuf
- * chain is always freed.
- * XXX temporary until there would be generic function doing this.
- */
-#define m_defrag       vge_m_defrag
-struct mbuf * vge_m_defrag(struct mbuf *, int);
-
-struct mbuf *
-vge_m_defrag(struct mbuf *mold, int flags)
-{
-       struct mbuf *m0, *mn, *n;
-       size_t sz = mold->m_pkthdr.len;
-
-#ifdef DIAGNOSTIC
-       if ((mold->m_flags & M_PKTHDR) == 0)
-               panic("m_defrag: not a mbuf chain header");
-#endif
-
-       MGETHDR(m0, flags, MT_DATA);
-       if (m0 == NULL)
-               return NULL;
-       m0->m_pkthdr.len = mold->m_pkthdr.len;
-       mn = m0;
-
-       do {
-               if (sz > MHLEN) {
-                       MCLGET(mn, M_DONTWAIT);
-                       if ((mn->m_flags & M_EXT) == 0) {
-                               m_freem(m0);
-                               return NULL;
-                       }
-               }
-
-               mn->m_len = MIN(sz, MCLBYTES);
-
-               m_copydata(mold, mold->m_pkthdr.len - sz, mn->m_len,
-                    mtod(mn, void *));
-
-               sz -= mn->m_len;
-
-               if (sz > 0) {
-                       /* need more mbufs */
-                       MGET(n, M_NOWAIT, MT_DATA);
-                       if (n == NULL) {
-                               m_freem(m0);
-                               return NULL;
-                       }
-
-                       mn->m_next = n;
-                       mn = n;
-               }
-       } while (sz > 0);
-
-       return m0;
-}
-
-/*
  * Read a word of data stored in the EEPROM at address 'addr.'
  */
 static uint16_t



Home | Main Index | Thread Index | Old Index