Skip to content

Commit cad5c19

Browse files
shemmingerdavem330
authored andcommitted
netvsc: keep track of some non-fatal overload conditions
Add ethtool statistics for case where send chimmeny buffer is exhausted and driver has to fall back to doing scatter/gather send. Also, add statistic for case where ring buffer is full and receive completions are delayed. Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8b53279 commit cad5c19

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

drivers/net/hyperv/hyperv_net.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,8 @@ struct netvsc_ethtool_stats {
680680
unsigned long tx_no_space;
681681
unsigned long tx_too_big;
682682
unsigned long tx_busy;
683+
unsigned long tx_send_full;
684+
unsigned long rx_comp_busy;
683685
};
684686

685687
struct netvsc_vf_pcpu_stats {

drivers/net/hyperv/netvsc.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,9 @@ int netvsc_send(struct net_device_context *ndev_ctx,
883883
} else if (pktlen + net_device->pkt_align <
884884
net_device->send_section_size) {
885885
section_index = netvsc_get_next_send_section(net_device);
886-
if (section_index != NETVSC_INVALID_INDEX) {
886+
if (unlikely(section_index == NETVSC_INVALID_INDEX)) {
887+
++ndev_ctx->eth_stats.tx_send_full;
888+
} else {
887889
move_pkt_msd(&msd_send, &msd_skb, msdp);
888890
msd_len = 0;
889891
}
@@ -949,9 +951,10 @@ int netvsc_send(struct net_device_context *ndev_ctx,
949951
}
950952

951953
/* Send pending recv completions */
952-
static int send_recv_completions(struct netvsc_channel *nvchan)
954+
static int send_recv_completions(struct net_device *ndev,
955+
struct netvsc_device *nvdev,
956+
struct netvsc_channel *nvchan)
953957
{
954-
struct netvsc_device *nvdev = nvchan->net_device;
955958
struct multi_recv_comp *mrc = &nvchan->mrc;
956959
struct recv_comp_msg {
957960
struct nvsp_message_header hdr;
@@ -969,8 +972,12 @@ static int send_recv_completions(struct netvsc_channel *nvchan)
969972
msg.status = rcd->status;
970973
ret = vmbus_sendpacket(nvchan->channel, &msg, sizeof(msg),
971974
rcd->tid, VM_PKT_COMP, 0);
972-
if (unlikely(ret))
975+
if (unlikely(ret)) {
976+
struct net_device_context *ndev_ctx = netdev_priv(ndev);
977+
978+
++ndev_ctx->eth_stats.rx_comp_busy;
973979
return ret;
980+
}
974981

975982
if (++mrc->first == nvdev->recv_completion_cnt)
976983
mrc->first = 0;
@@ -1011,7 +1018,7 @@ static void enq_receive_complete(struct net_device *ndev,
10111018
recv_comp_slot_avail(nvdev, mrc, &filled, &avail);
10121019

10131020
if (unlikely(filled > NAPI_POLL_WEIGHT)) {
1014-
send_recv_completions(nvchan);
1021+
send_recv_completions(ndev, nvdev, nvchan);
10151022
recv_comp_slot_avail(nvdev, mrc, &filled, &avail);
10161023
}
10171024

@@ -1194,7 +1201,7 @@ int netvsc_poll(struct napi_struct *napi, int budget)
11941201
* then re-enable host interrupts
11951202
* and reschedule if ring is not empty.
11961203
*/
1197-
if (send_recv_completions(nvchan) == 0 &&
1204+
if (send_recv_completions(ndev, net_device, nvchan) == 0 &&
11981205
work_done < budget &&
11991206
napi_complete_done(napi, work_done) &&
12001207
hv_end_read(&channel->inbound)) {

drivers/net/hyperv/netvsc_drv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,8 @@ static const struct {
11121112
{ "tx_no_space", offsetof(struct netvsc_ethtool_stats, tx_no_space) },
11131113
{ "tx_too_big", offsetof(struct netvsc_ethtool_stats, tx_too_big) },
11141114
{ "tx_busy", offsetof(struct netvsc_ethtool_stats, tx_busy) },
1115+
{ "tx_send_full", offsetof(struct netvsc_ethtool_stats, tx_send_full) },
1116+
{ "rx_comp_busy", offsetof(struct netvsc_ethtool_stats, rx_comp_busy) },
11151117
}, vf_stats[] = {
11161118
{ "vf_rx_packets", offsetof(struct netvsc_vf_pcpu_stats, rx_packets) },
11171119
{ "vf_rx_bytes", offsetof(struct netvsc_vf_pcpu_stats, rx_bytes) },

0 commit comments

Comments
 (0)