Bug 210211

Summary: ifstat does not report correct bandwidth for wlan on iwn (maybe others)
Product: Base System Reporter: Dave Cameron (puddingpimp) <dave>
Component: kernAssignee: Andriy Voskoboinyk <avos>
Status: Closed FIXED    
Severity: Affects Only Me CC: avos, linimon, marek
Priority: --- Keywords: regression
Version: 11.2-STABLE   
Hardware: Any   
OS: Any   

Description Dave Cameron (puddingpimp) 2016-06-11 13:11:45 UTC
Steps to reproduce:

run ifstat with an iwn wireless interface, ping something, no usage appears.

Also this code in my own application doesn't work for the same reason (works on 10.3):

void get_if_bytes(char *if_name)
{
	struct ifaddrs *ifap, *ifa;

	getifaddrs(&ifap);
	for(ifa = ifap; ifa; ifa = ifa->ifa_next) {
  		if(!strcmp(ifa->ifa_name, if_name))
			break;
	}
	if(!ifa) return; // interface not found
	in_bytes = ((struct if_data *)ifa->ifa_data)->ifi_ibytes;
	out_bytes = ((struct if_data *)ifa->ifa_data)->ifi_obytes;
	freeifaddrs(ifap);
	return;
}
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2018-08-29 19:30:02 UTC
Does this report apply to 11, or to 12?

Also, is this report still seen?
Comment 2 marek 2018-08-29 21:12:57 UTC
I can confirm, that the bug still exists on 11.2-RELEASE and only if the wireless network is 802.11n (2.4GHz and 5GHz). If the network type is 802.11abg, the statistics shows correctly. I am using Levono Thinkpad X201 with "Intel Centrino Ultimate-N 6300" wireless adapter.
Comment 3 commit-hook freebsd_committer freebsd_triage 2019-01-16 12:33:18 UTC
A commit references this bug:

Author: avos
Date: Wed Jan 16 12:33:07 UTC 2019
New revision: 343094
URL: https://svnweb.freebsd.org/changeset/base/343094

Log:
  iwn(4): (partially) rewrite A-MPDU Tx path

  Generic Tx stats fixes:
  - do not try to parse "aggregation status" for single frames; send them
  to iwn_tx_done() instead;
  - try to attach mbuf / node reference pair to reported BA events;
  allows to fix reported status for ieee80211_tx_complete() and ifnet counters
  (previously all A-MPDU frames were counted as failed - see PR 210211);
  requires few more firmware bug workarounds;
  - preserve short / long retry counters for wlan_amrr(4)
  (disabled for now - causes significant performance degradation).
  - Add new IWN_DEBUG_AMPDU debug category.
  - Add one more check into iwn_tx_data() to prevent aggregation ring
  overflow.
  - Workaround 'seqno % 256' != 'current Tx slot' case (until D9195 is not
  in the tree).
  - Improve watchdog timer updates (previously watchdog check was omitted
  when at least one frame was transmitted).
  - Stop Tx when memory leak in currently used ring was detected (unlikely
  to happen).
  - Few other minor fixes.

  Was previously tested with:
   - Intel 6205, STA mode (Tx aggregation behaves much better now).
   - Intel 4965AGN, STA mode (still unstable).

  PR:		192641, 210211
  Reviewed by:	adrian, dhw
  MFC after:	1 month
  Differential Revision:	https://reviews.freebsd.org/D10728

Changes:
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/iwn/if_iwn_debug.h
  head/sys/dev/iwn/if_iwnreg.h
  head/sys/dev/iwn/if_iwnvar.h
Comment 4 commit-hook freebsd_committer freebsd_triage 2019-02-16 01:19:50 UTC
A commit references this bug:

Author: avos
Date: Sat Feb 16 01:19:15 UTC 2019
New revision: 344197
URL: https://svnweb.freebsd.org/changeset/base/344197

Log:
  MFC r343094:
  iwn(4): (partially) rewrite A-MPDU Tx path

  The change fixes ifnet counters and improves Tx stability when A-MPDU
  is used.

  MFC r343292:
  iwn(4): drop i_seq field initialization for A-MPDU frames

  It is done by net80211 since r319460.

  PR:		192641, 210211
  Reviewed by:	adrian, dhw
  Differential Revision:	https://reviews.freebsd.org/D10728

Changes:
_U  stable/12/
  stable/12/sys/dev/iwn/if_iwn.c
  stable/12/sys/dev/iwn/if_iwn_debug.h
  stable/12/sys/dev/iwn/if_iwnreg.h
  stable/12/sys/dev/iwn/if_iwnvar.h
Comment 5 Andriy Voskoboinyk freebsd_committer freebsd_triage 2019-02-16 01:27:22 UTC
Fixed on CURRENT / 12.0-STABLE (sorry, but the patch can not be easily merged to 11-STABLE, so it was skipped).