NetBSD Problem Report #48568

From msaitoh@execsw.org  Mon Feb  3 05:27:50 2014
Return-Path: <msaitoh@execsw.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 59A0CA5673
	for <gnats-bugs@gnats.NetBSD.org>; Mon,  3 Feb 2014 05:27:50 +0000 (UTC)
Message-Id: <20140203052748.0C5EC31A58A@vslock.execsw.org>
Date: Mon,  3 Feb 2014 14:27:48 +0900 (JST)
From: msaitoh@execsw.org
Reply-To: msaitoh@execsw.org
To: gnats-bugs@gnats.NetBSD.org
Subject: return value handling of xxx_encap() and IFF_OACTIVE.
X-Send-Pr-Version: 3.95

>Number:         48568
>Category:       kern
>Synopsis:       return value handling of xxx_encap() and IFF_OACTIVE.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 03 05:30:00 +0000 2014
>Last-Modified:  Mon Feb 03 06:00:01 +0000 2014
>Originator:     msaitoh@execsw.org
>Release:        
>Organization:
>Environment:
all
Architecture: all
Machine: all
>Description:

>How-To-Repeat:
	A lot of Ethernet driver have the following code in xxx_start():

		/*
		 * Pack the data into the transmit ring. If we
		 * don't have room, set the OACTIVE flag and wait
		 * for the NIC to drain the ring.
		 */
		if (xxx_encap(sc, m_head, &prodidx)) {
			ifp->if_flags |= IFF_OACTIVE;
			break;
		}

	For some drivers, it's incorrect because xxx_encap() may return
	error when the TX ring ISN'T full. If the TX ring is empty,
	no one disable IFF_OACTIVE because the driver don't get any
	TX complete interrupt.
>Fix:
	Check all network driver's code.

	Patch for mvgbe(4):

--- if_mvgbe.c	23 Dec 2013 02:23:25 -0000	1.35
+++ if_mvgbe.c	3 Feb 2014 05:25:01 -0000
@@ -1059,7 +1059,8 @@
 		 * for the NIC to drain the ring.
 		 */
 		if (mvgbe_encap(sc, m_head, &idx)) {
-			ifp->if_flags |= IFF_OACTIVE;
+			if (sc->sc_cdata.mvgbe_tx_cnt > 0)
+				ifp->if_flags |= IFF_OACTIVE;
 			break;
 		}


>Audit-Trail:
From: "SAITOH Masanobu" <msaitoh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48568 CVS commit: src/sys/dev/marvell
Date: Mon, 3 Feb 2014 05:56:24 +0000

 Module Name:	src
 Committed By:	msaitoh
 Date:		Mon Feb  3 05:56:23 UTC 2014

 Modified Files:
 	src/sys/dev/marvell: if_mvgbe.c

 Log Message:
  Carefully set IFF_OACTIVE in mvgbe_start(). Even if mvgbe_encap()
 returns other than 0, the TX ring might not full. Check whether
 the TX ring has one or more packets. If the ring is empty,
 dont' set IFF_OACTIVE because an TX complete interrupt never
 occur and IFF_OACTIVE flags is left. The interface's timer
 isn't reset, so a device timeout desn't occur.

  Fixes a bug that IFF_OACTIVE flag is left on heavy load.
 Part of PR#48568.


 To generate a diff of this commit:
 cvs rdiff -u -r1.35 -r1.36 src/sys/dev/marvell/if_mvgbe.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.