Subject: Re: RTL8169 hw IP4CSUM_Tx workaround
To: None <pavel@NetBSD.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: tech-net
Date: 10/21/2006 21:19:45
pavel@NetBSD.org wrote:

> M_TRAILINGSPACE returns 0 if the mbuf is read-only.

Hmm, indeed. Should we fix pci/if_bge.c as well?
---
Izumi Tsutsui


Index: if_bge.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_bge.c,v
retrieving revision 1.112
diff -u -r1.112 if_bge.c
--- if_bge.c	12 Oct 2006 01:31:29 -0000	1.112
+++ if_bge.c	21 Oct 2006 12:16:37 -0000
@@ -3274,7 +3274,7 @@
 
 	/* if there's only the packet-header and we can pad there, use it. */
 	if (pkt->m_pkthdr.len == pkt->m_len &&
-	    !M_READONLY(pkt) && M_TRAILINGSPACE(pkt) >= padlen) {
+	    M_TRAILINGSPACE(pkt) >= padlen) {
 		last = pkt;
 	} else {
 		/*
@@ -3287,7 +3287,7 @@
 		}
 
 		/* `last' now points to last in chain. */
-		if (!M_READONLY(last) && M_TRAILINGSPACE(last) >= padlen) {
+		if (M_TRAILINGSPACE(last) >= padlen) {
 			(void) 0; /* we can pad here, in-place. */
 		} else {
 			/* Allocate new empty mbuf, pad it. Compact later. */
@@ -3340,8 +3340,7 @@
 		 */
 
 		/* Internal frag. If fits in prev, copy it there. */
-		if (prev && !M_READONLY(prev) &&
-		      M_TRAILINGSPACE(prev) >= m->m_len) {
+		if (prev && M_TRAILINGSPACE(prev) >= m->m_len) {
 		  	bcopy(m->m_data,
 			      prev->m_data+prev->m_len,
 			      mlen);
@@ -3352,7 +3351,7 @@
 			m = prev;
 			continue;
 		}
-		else if (m->m_next != NULL && !M_READONLY(m) &&
+		else if (m->m_next != NULL &&
 			     M_TRAILINGSPACE(m) >= shortfall &&
 			     m->m_next->m_len >= (8 + shortfall)) {
 		    /* m is writable and have enough data in next, pull up. */