i40e: report VF tx_dropped with tx_errors instead of tx_discards
Subsystems (3)
PATCH 1/1 i40e: report VF tx_dropped with tx_errors instead of tx_discards
Currently the tx_dropped field in VF stats is not updated correctly when reading stats from the PF. This is because it reads from i40e_eth_stats.tx_discards which seems to be unused for per VSI stats, as it is not updated by i40e_update_eth_stats() and the corresponding register, GLV_TDPC, is not implemented[1].
Use i40e_eth_stats.tx_errors instead, which is actually updated by i40e_update_eth_stats() by reading from GLV_TEPC.
To test, create a VF and try to send bad packets through it:
$ echo 1 > /sys/class/net/enp2s0f0/device/sriov_numvfs $ cat test.py from scapy.all import *
vlan_pkt = Ether(dst="ff:ff:ff:ff:ff:ff") / Dot1Q(vlan=999) / IP(dst="192.168.0.1") / ICMP() ttl_pkt = IP(dst="8.8.8.8", ttl=0) / ICMP()
print("Send packet with bad VLAN tag")sendp(vlan_pkt, iface="enp2s0f0v0")print("Send packet with TTL=0")sendp(ttl_pkt, iface="enp2s0f0v0")
$ ip -s link show dev enp2s0f0
16: enp2s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 3c:ec:ef:b7:e0:ac brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped missed mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
vf 0 link/ether e2:c6:fd:c1:1e:92 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off
RX: bytes packets mcast bcast dropped
0 0 0 0 0
TX: bytes packets dropped
0 0 0
$ python test.py
Send packet with bad VLAN tag
.
Sent 1 packets.
Send packet with TTL=0
.
Sent 1 packets.
$ ip -s link show dev enp2s0f0
16: enp2s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 3c:ec:ef:b7:e0:ac brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped missed mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
vf 0 link/ether e2:c6:fd:c1:1e:92 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off
RX: bytes packets mcast bcast dropped
0 0 0 0 0
TX: bytes packets dropped
0 0 0A packet with non-existent VLAN tag and a packet with TTL = 0 are sent, but tx_dropped is not incremented.
After patch:
$ ip -s link show dev enp2s0f0
19: enp2s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 3c:ec:ef:b7:e0:ac brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped missed mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
vf 0 link/ether 4a:b7:3d:37:f7:56 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off
RX: bytes packets mcast bcast dropped
0 0 0 0 0
TX: bytes packets dropped
0 0 2--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +1 -1
@@ -5006,7 +5006,7 @@ int i40e_get_vf_stats(struct net_device *netdev, int vf_id, vf_stats->broadcast = stats->rx_broadcast; vf_stats->multicast = stats->rx_multicast; vf_stats->rx_dropped = stats->rx_discards + stats->rx_discards_other; - vf_stats->tx_dropped = stats->tx_discards; + vf_stats->tx_dropped = stats->tx_errors;return 0 ; }
Signature · 1 line
2.49.0
Quoted 8 lines · Dennis Chen
Currently the
tx_droppedfield in VF stats is not updated correctly when reading stats from the PF. This is because it reads from i40e_eth_stats.tx_discards which seems to be unused for per VSI stats, as it is not updated byi40e_update_eth_stats()and the corresponding register,GLV_TDPC, is not implemented[1].Use i40e_eth_stats.tx_errors instead, which is actually updated by
i40e_update_eth_stats()by reading fromGLV_TEPC.
...
Quoted 3 lines
Fixes dc645daef9af5bcbd9c ("i40e: implement VF stats NDO")Signed-off-by Dennis Chen <[email protected]>
Hi Dennis,
Thanks for the detailed explanation, it's very much appreciated.
One minor nit, is that there are some leading spaces before "Link: " a few lines above. But I suspect you don't need to repost just to address that.
Romanowski, Rafal
Tested-byQuoted 30 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Simon Horman
Sent: Monday, June 30, 2025 6:50 PM
To: Dennis Chen <[email protected]>
Cc: [email protected]; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Intel-wired-lan] [PATCH net] i40e: report VFtx_droppedwithtx_errorsinstead oftx_discardsQuoted 8 lines · Dennis Chen
Currently the
tx_droppedfield in VF stats is not updated correctly when reading stats from the PF. This is because it reads from i40e_eth_stats.tx_discards which seems to be unused for per VSI stats, as it is not updated byi40e_update_eth_stats()and the corresponding register,GLV_TDPC, is not implemented[1].Use i40e_eth_stats.tx_errors instead, which is actually updated by
i40e_update_eth_stats()by reading fromGLV_TEPC....
Quoted 5 lines
Fixes dc645daef9af5bcbd9c ("i40e: implement VF stats NDO")Signed-off-by Dennis Chen <[email protected]>Link:
https://www.intel.com/content/www/us/en/content-details/596333/intel-e
thernet-controller-x710-tm4-at2-carlsville-datasheet.html
Quoted 8 lines
Hi Dennis,
Thanks for the detailed explanation, it's very much appreciated.
One minor nit, is that there are some leading spaces before "Link: " a few lines above. But I suspect you don't need to repost just to address that.
Reviewed-by Simon Horman <[email protected]>
Quoted 94 lines · Dennis Chen
Currently the
tx_droppedfield in VF stats is not updated correctly when reading stats from the PF. This is because it reads from i40e_eth_stats.tx_discards which seems to be unused for per VSI stats, as it is not updated byi40e_update_eth_stats()and the corresponding register,GLV_TDPC, is not implemented[1].Use i40e_eth_stats.tx_errors instead, which is actually updated by
i40e_update_eth_stats()by reading fromGLV_TEPC.To test, create a VF and try to send bad packets through it:
$ echo 1 > /sys/class/net/enp2s0f0/device/sriov_numvfs $ cat test.py from scapy.all import *
vlan_pkt=Ether(dst="ff:ff:ff:ff:ff:ff")/ Dot1Q(vlan=999) /IP(dst="192.168.0.1")/ICMP()ttl_pkt=IP(dst="8.8.8.8", ttl=0)/ICMP()
print("Send packet with bad VLAN tag")sendp(vlan_pkt, iface="enp2s0f0v0")print("Send packet with TTL=0")sendp(ttl_pkt, iface="enp2s0f0v0")$ ip -s link show dev enp2s0f0 16: enp2s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 3c:ec:ef:b7:e0:ac brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped missed mcast 0 0 0 0 0 0 TX: bytes packets errors dropped carrier collsns 0 0 0 0 0 0 vf 0 link/ether e2:c6:fd:c1:1e:92 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off RX: bytes packets mcast bcast dropped 0 0 0 0 0 TX: bytes packets dropped 0 0 0 $ python test.py Send packet with bad VLAN tag . Sent 1 packets. Send packet with TTL=0 . Sent 1 packets. $ ip -s link show dev enp2s0f0 16: enp2s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 3c:ec:ef:b7:e0:ac brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped missed mcast 0 0 0 0 0 0 TX: bytes packets errors dropped carrier collsns 0 0 0 0 0 0 vf 0 link/ether e2:c6:fd:c1:1e:92 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off RX: bytes packets mcast bcast dropped 0 0 0 0 0 TX: bytes packets dropped 0 0 0A packet with non-existent VLAN tag and a packet with TTL = 0 are sent, but
tx_droppedis not incremented.After patch:
$ ip -s link show dev enp2s0f0 19: enp2s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 3c:ec:ef:b7:e0:ac brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped missed mcast 0 0 0 0 0 0 TX: bytes packets errors dropped carrier collsns 0 0 0 0 0 0 vf 0 link/ether 4a:b7:3d:37:f7:56 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off RX: bytes packets mcast bcast dropped 0 0 0 0 0 TX: bytes packets dropped 0 0 2Fixes dc645daef9af5bcbd9c ("i40e: implement VF stats NDO")Signed-off-by Dennis Chen <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +1
-2@@ -5006,7 +5006,7 @@ int i40e_get_vf_stats(struct net_device *netdev, int vf_id, vf_stats->broadcast = stats->rx_broadcast; vf_stats->multicast = stats->rx_multicast; vf_stats->rx_dropped = stats->rx_discards + stats->rx_discards_other; - vf_stats->tx_dropped = stats->tx_discards; + vf_stats->tx_dropped = stats->tx_errors;return 0 ; } --
Quoted 2 lines
2.49.0
Hello,
Any update here?
Dennis Chen
Tony Nguyen
maintainerQuoted 92 lines · Dennis Chen
Quoted 91 lines · Dennis Chen
Currently the
tx_droppedfield in VF stats is not updated correctly when reading stats from the PF. This is because it reads from i40e_eth_stats.tx_discards which seems to be unused for per VSI stats, as it is not updated byi40e_update_eth_stats()and the corresponding register,GLV_TDPC, is not implemented[1].Use i40e_eth_stats.tx_errors instead, which is actually updated by
i40e_update_eth_stats()by reading fromGLV_TEPC.To test, create a VF and try to send bad packets through it:
$ echo 1 > /sys/class/net/enp2s0f0/device/sriov_numvfs $ cat test.py from scapy.all import *
vlan_pkt=Ether(dst="ff:ff:ff:ff:ff:ff")/ Dot1Q(vlan=999) /IP(dst="192.168.0.1")/ICMP()ttl_pkt=IP(dst="8.8.8.8", ttl=0)/ICMP()
print("Send packet with bad VLAN tag")sendp(vlan_pkt, iface="enp2s0f0v0")print("Send packet with TTL=0")sendp(ttl_pkt, iface="enp2s0f0v0")$ ip -s link show dev enp2s0f0 16: enp2s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 3c:ec:ef:b7:e0:ac brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped missed mcast 0 0 0 0 0 0 TX: bytes packets errors dropped carrier collsns 0 0 0 0 0 0 vf 0 link/ether e2:c6:fd:c1:1e:92 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off RX: bytes packets mcast bcast dropped 0 0 0 0 0 TX: bytes packets dropped 0 0 0 $ python test.py Send packet with bad VLAN tag . Sent 1 packets. Send packet with TTL=0 . Sent 1 packets. $ ip -s link show dev enp2s0f0 16: enp2s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 3c:ec:ef:b7:e0:ac brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped missed mcast 0 0 0 0 0 0 TX: bytes packets errors dropped carrier collsns 0 0 0 0 0 0 vf 0 link/ether e2:c6:fd:c1:1e:92 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off RX: bytes packets mcast bcast dropped 0 0 0 0 0 TX: bytes packets dropped 0 0 0A packet with non-existent VLAN tag and a packet with TTL = 0 are sent, but
tx_droppedis not incremented.After patch:
$ ip -s link show dev enp2s0f0 19: enp2s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 3c:ec:ef:b7:e0:ac brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped missed mcast 0 0 0 0 0 0 TX: bytes packets errors dropped carrier collsns 0 0 0 0 0 0 vf 0 link/ether 4a:b7:3d:37:f7:56 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off RX: bytes packets mcast bcast dropped 0 0 0 0 0 TX: bytes packets dropped 0 0 2Fixes dc645daef9af5bcbd9c ("i40e: implement VF stats NDO")Signed-off-by Dennis Chen <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +1
-1@@ -5006,7 +5006,7 @@ int i40e_get_vf_stats(struct net_device *netdev, int vf_id, vf_stats->broadcast = stats->rx_broadcast; vf_stats->multicast = stats->rx_multicast; vf_stats->rx_dropped = stats->rx_discards + stats->rx_discards_other; - vf_stats->tx_dropped = stats->tx_discards; + vf_stats->tx_dropped = stats->tx_errors;
Quoted 8 lines
Quoted 5 lines
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +0
-1return 0 ; } --2.49.0
Hello,
Any update here?
Hi Dennis,
Let me check with our validation team and get their status on this.
Thanks,
Tony
Romanowski, Rafal
Tested-byQuoted 13 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Thursday, July 17, 2025 10:06 PM
To: Dennis Chen <[email protected]>; [email protected]
Cc: Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Intel-wired-lan] [PATCH net] i40e: report VFtx_droppedwithtx_errorsinstead oftx_discards
Quoted 1 line
On 7/17/2025 9:46 AM, Dennis Chen wrote: