From nobody Fri May 06 14:52:19 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9489F1ABF194 for ; Fri, 6 May 2022 14:52:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Kvtnv0WWQz3QZw for ; Fri, 6 May 2022 14:52:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E5F5D1DA3E for ; Fri, 6 May 2022 14:52:18 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 246EqItu085829 for ; Fri, 6 May 2022 14:52:18 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 246EqIq1085828 for bugs@FreeBSD.org; Fri, 6 May 2022 14:52:18 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 263817] dwc: dwc driver will re-count the number of uni-cast/multicast packets are sent/received Date: Fri, 06 May 2022 14:52:19 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: jiahali@blackberry.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651848739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PcHM7MTdUiwgsgFStzJrSgcI4I6oXe5olauwwMLBDAU=; b=wwdc/S78aNcr75ucVEFCj/QSXgQ3nEUNu8QMghRPXHh1FPiTZZVVDnNVwCCijT30YWI0vv 8LNqqxA5Ch2Cvk7iYDNKCQejsRNWkdZTbVGNnqh5mMnAmLN2Bx5+RxacZDZdHhGNOV/oQk OkKUVmPHLkC+/JI7Q9ybpOYJuFnpOrw7kPT8zxSUfcNq8DGAC9EQ4lnXpDSQvcP3FM4dyo SsuBGKoTstwC0AdHu3qecIORE4Ti3mEEWKyrjngj+f2N+LRtkdWNNwcHJIlQt1Mg2R2WXD wX1lwFX2wW3fSXYEa1v8kb7sh1AhK+x38N1H5Sdw5Ed7nYwIPPJmyQDhL5He9Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651848739; a=rsa-sha256; cv=none; b=gtpTFQliI4urnpOOnnVaHCQHB+FOY226tMFmb+PTV7fbtN+OK2Ldb6tp0siI/8yZ6Y3Cz8 3NzmQp4ETFwCkx/gmLdcvLOasaTXIvcuSfeIFW3GhBKTLgEQ0wZhd+Ly9QFDVEL28LVjYe Vt8v2wlpjC+teITEek1lf//ATojgn3BC46ki+S3Vdh+6XxNqQ4C9XQnsPwGNU0Ds5GfQIg OyeghL03Eki5kbXNkINceK5NYf1KvtSdE9IkqEKvYFHbSJj0LJr9BiFbcmuM+KHNEMVD/4 5P/h8dOYM8cKGNNN0EMQgQFOVKFZmqRi45L6RpwoKwBb80qrKgygh7BGCDq9Vg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D263817 Bug ID: 263817 Summary: dwc: dwc driver will re-count the number of uni-cast/multicast packets are sent/received Product: Base System Version: CURRENT Hardware: arm64 OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: jiahali@blackberry.com Overview -------- The number of unicast packets that the dwc driver sent/received will be recorded by using the IFCOUNTER_IPACKETS/IFCOUNTER_OPACKETS macros when the tx/rx interrupts are invoked.(See if_dwc.c/dwc_rxfinish_one() and if_dwc.c/dwc_txfinish_locked()) The number of multicast packets will also be recorded at the networking sta= ck using IFCOUNTER_IMCASTS/IFCOUNTER_OMCASTS macros.(For example, /trunk/io-sock/sys/net/if_ethersubr.c/ether_input_internal()) However, the dwc driver will register a callout function, dwc_tick(), which will read the driver's registers, dwc_harvest_stats, to count how many unicast/multicast packets are sent/received. The recalculation issue also exists in Freebsd's current release image. Actual Results -------------- Steps for reproducing 1. Set up In dwc driver's Freebsd terminal root@generic:~ # uname -a FreeBSD generic 14.0-CURRENT FreeBSD 14.0-CURRENT #0 main-n254961-b91a48693= a5: Thu Apr 21 09:35:51 UTC 2022=20=20=20=20 root@releng1.nyi.freebsd.org:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC arm= 64 root@generic:~ # ifconfig dwc0 dwc0: flags=3D8843 metric 0 mtu 1500 options=3D8000b ether fa:97:92:f6:f1:09 inet 0.0.0.0 netmask 0xff000000 broadcast 255.255.255.255 media: Ethernet autoselect (1000baseT ) status: active nd6 options=3D29 root@generic:~ # ifconfig dwc0 192.168.3.129/24 root@generic:~ # ifconfig dwc0 dwc0: flags=3D8843 metric 0 mtu 1500 options=3D8000b ether fa:97:92:f6:f1:09 inet 192.168.3.129 netmask 0xffffff00 broadcast 192.168.3.255 media: Ethernet autoselect (1000baseT ) status: active nd6 options=3D29 Host Terminal 1 Check interface config $ ifconfig enp0s31f6 enp0s31f6: flags=3D4163 mtu 1500 inet 192.168.3.2 netmask 255.255.255.0 broadcast 192.168.3.255 inet6 fe80::f897:92ff:fef6:f102 prefixlen 64 scopeid 0x20 ether 8c:8c:aa:c1:2b:c3 txqueuelen 1000 (Ethernet) RX packets 1662 bytes 516194 (516.1 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10885 bytes 1346113 (1.3 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 16 memory 0xae380000-ae3a0000 Run the tcpdump on interface 'enp0s31f6" sudo tcpdump -U -pi enp0s31f6 -en 2. Test Results In dwc driver's Freebsd terminal root@generic:~ # netstat -n -I dwc0 Name Mtu Network Address Ipkts Ierrs Idrop Opkts O= errs Coll dwc0 1500 fa:97:92:f6:f1:09 24 0 0 74 = 0 0 dwc0 - 192.168.3.0/2 192.168.3.129 6 - - 4 = - - root@generic:~ # ping -c 1 192.168.3.2 PING 192.168.3.2 (192.168.3.2): 56 data bytes 64 bytes from 192.168.3.2: icmp_seq=3D0 ttl=3D64 time=3D0.426 ms --- 192.168.3.2 ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss round-trip min/avg/max/stddev =3D 0.426/0.426/0.426/0.000 ms root@generic:~ # netstat -n -I dwc0 Name Mtu Network Address Ipkts Ierrs Idrop Opkts O= errs Coll dwc0 1500 fa:97:92:f6:f1:09 26 0 0 78 = 0 0 dwc0 - 192.168.3.0/2 192.168.3.129 7 - - 5 = - - Packets captured by the tcpdump at Host Terminal 1 $ sudo tcpdump -U -pi enp0s31f6 -en tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on enp0s31f6, link-type EN10MB (Ethernet), capture size 262144 by= tes 10:23:53.592175 fa:97:92:f6:f1:09 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x080= 6), length 60: Request who-has 192.168.3.2 tell 192.168.3.129, length 46 10:23:53.592188 8c:8c:aa:c1:2b:c3 > fa:97:92:f6:f1:09, ethertype ARP (0x080= 6), length 42: Reply 192.168.3.2 is-at 8c:8c:aa:c1:2b:c3, length 28 10:23:53.592320 fa:97:92:f6:f1:09 > 8c:8c:aa:c1:2b:c3, ethertype IPv4 (0x08= 00), length 98: 192.168.3.129 > 192.168.3.2: ICMP echo request, id 59653, seq 0, length 64 10:23:53.592342 8c:8c:aa:c1:2b:c3 > fa:97:92:f6:f1:09, ethertype IPv4 (0x08= 00), length 98: 192.168.3.2 > 192.168.3.129: ICMP echo reply, id 59653, seq 0, length 64 ^C 4 packets captured 4 packets received by filter 0 packets dropped by kernel Analysis -------------- The change in the netstat results, Ipkts and Opkts, shows that there were 4 packets sent and 4 packets received at the link-layer level, which is doubl= ed the actual number of packets. I tried to use the gdb debugger to go through the increments of the counters step by step. And I found that IFCOUNTER_IPACKETS, IFCOUNTER_OPACKETS, IFCOUNTER_IMCASTS, and IFCOUNTER_OMCASTS are involved. --=20 You are receiving this mail because: You are the assignee for the bug.=