Skip to content

Commit

Permalink
net: mhi: Improve MBIM packet counting
Browse files Browse the repository at this point in the history
Packets are aggregated over the MBIM link and currently the MHI net
device will count each aggregated packet rather then the actual
packets themselves.

If a protocol handler module is specified, use that to count the
packets rather than directly in the MHI net device. This is in line
with the behaviour of the USB net cdc_mbim driver.

Signed-off-by: Richard Laing <richard.laing@alliedtelesis.co.nz>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Richard Laing authored and David S. Miller committed Jul 26, 2021
1 parent a0302ff commit e129f6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/net/mhi/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ static void mhi_net_dl_callback(struct mhi_device *mhi_dev,
mhi_netdev->skbagg_head = NULL;
}

u64_stats_update_begin(&mhi_netdev->stats.rx_syncp);
u64_stats_inc(&mhi_netdev->stats.rx_packets);
u64_stats_add(&mhi_netdev->stats.rx_bytes, skb->len);
u64_stats_update_end(&mhi_netdev->stats.rx_syncp);

switch (skb->data[0] & 0xf0) {
case 0x40:
skb->protocol = htons(ETH_P_IP);
Expand All @@ -222,10 +217,15 @@ static void mhi_net_dl_callback(struct mhi_device *mhi_dev,
break;
}

if (proto && proto->rx)
if (proto && proto->rx) {
proto->rx(mhi_netdev, skb);
else
} else {
u64_stats_update_begin(&mhi_netdev->stats.rx_syncp);
u64_stats_inc(&mhi_netdev->stats.rx_packets);
u64_stats_add(&mhi_netdev->stats.rx_bytes, skb->len);
u64_stats_update_end(&mhi_netdev->stats.rx_syncp);
netif_rx(skb);
}
}

/* Refill if RX buffers queue becomes low */
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/mhi/proto_mbim.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ static void mbim_rx(struct mhi_net_dev *mhi_netdev, struct sk_buff *skb)
continue;
}

u64_stats_update_begin(&mhi_netdev->stats.rx_syncp);
u64_stats_inc(&mhi_netdev->stats.rx_packets);
u64_stats_add(&mhi_netdev->stats.rx_bytes, skbn->len);
u64_stats_update_end(&mhi_netdev->stats.rx_syncp);
netif_rx(skbn);
}
next_ndp:
Expand Down

0 comments on commit e129f6b

Please sign in to comment.