Skip to content

Commit 90e2c7a

Browse files
committed
Merge branch 'hv_netvsc-minor-enhancements'
Stephen Hemminger says: ==================== hv_netvsc: minor enhancements A couple of small things for net-next ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a3a41d2 + ec96638 commit 90e2c7a

File tree

5 files changed

+223
-6
lines changed

5 files changed

+223
-6
lines changed

drivers/net/hyperv/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
obj-$(CONFIG_HYPERV_NET) += hv_netvsc.o
22

3-
hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
3+
hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o netvsc_trace.o

drivers/net/hyperv/netvsc.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <asm/sync_bitops.h>
3737

3838
#include "hyperv_net.h"
39+
#include "netvsc_trace.h"
3940

4041
/*
4142
* Switch the data path from the synthetic interface to the VF
@@ -57,6 +58,8 @@ void netvsc_switch_datapath(struct net_device *ndev, bool vf)
5758
init_pkt->msg.v4_msg.active_dp.active_datapath =
5859
NVSP_DATAPATH_SYNTHETIC;
5960

61+
trace_nvsp_send(ndev, init_pkt);
62+
6063
vmbus_sendpacket(dev->channel, init_pkt,
6164
sizeof(struct nvsp_message),
6265
(unsigned long)init_pkt,
@@ -124,6 +127,8 @@ static void netvsc_revoke_buf(struct hv_device *device,
124127
revoke_packet->msg.v1_msg.
125128
revoke_recv_buf.id = NETVSC_RECEIVE_BUFFER_ID;
126129

130+
trace_nvsp_send(ndev, revoke_packet);
131+
127132
ret = vmbus_sendpacket(device->channel,
128133
revoke_packet,
129134
sizeof(struct nvsp_message),
@@ -164,6 +169,8 @@ static void netvsc_revoke_buf(struct hv_device *device,
164169
revoke_packet->msg.v1_msg.revoke_send_buf.id =
165170
NETVSC_SEND_BUFFER_ID;
166171

172+
trace_nvsp_send(ndev, revoke_packet);
173+
167174
ret = vmbus_sendpacket(device->channel,
168175
revoke_packet,
169176
sizeof(struct nvsp_message),
@@ -305,6 +312,8 @@ static int netvsc_init_buf(struct hv_device *device,
305312
init_packet->msg.v1_msg.
306313
send_recv_buf.id = NETVSC_RECEIVE_BUFFER_ID;
307314

315+
trace_nvsp_send(ndev, init_packet);
316+
308317
/* Send the gpadl notification request */
309318
ret = vmbus_sendpacket(device->channel, init_packet,
310319
sizeof(struct nvsp_message),
@@ -384,6 +393,8 @@ static int netvsc_init_buf(struct hv_device *device,
384393
net_device->send_buf_gpadl_handle;
385394
init_packet->msg.v1_msg.send_send_buf.id = NETVSC_SEND_BUFFER_ID;
386395

396+
trace_nvsp_send(ndev, init_packet);
397+
387398
/* Send the gpadl notification request */
388399
ret = vmbus_sendpacket(device->channel, init_packet,
389400
sizeof(struct nvsp_message),
@@ -452,6 +463,8 @@ static int negotiate_nvsp_ver(struct hv_device *device,
452463
init_packet->msg.init_msg.init.min_protocol_ver = nvsp_ver;
453464
init_packet->msg.init_msg.init.max_protocol_ver = nvsp_ver;
454465

466+
trace_nvsp_send(ndev, init_packet);
467+
455468
/* Send the init request */
456469
ret = vmbus_sendpacket(device->channel, init_packet,
457470
sizeof(struct nvsp_message),
@@ -484,6 +497,8 @@ static int negotiate_nvsp_ver(struct hv_device *device,
484497
init_packet->msg.v2_msg.send_ndis_config.capability.teaming = 1;
485498
}
486499

500+
trace_nvsp_send(ndev, init_packet);
501+
487502
ret = vmbus_sendpacket(device->channel, init_packet,
488503
sizeof(struct nvsp_message),
489504
(unsigned long)init_packet,
@@ -496,6 +511,7 @@ static int netvsc_connect_vsp(struct hv_device *device,
496511
struct netvsc_device *net_device,
497512
const struct netvsc_device_info *device_info)
498513
{
514+
struct net_device *ndev = hv_get_drvdata(device);
499515
static const u32 ver_list[] = {
500516
NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2,
501517
NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5
@@ -536,6 +552,8 @@ static int netvsc_connect_vsp(struct hv_device *device,
536552
send_ndis_ver.ndis_minor_ver =
537553
ndis_version & 0xFFFF;
538554

555+
trace_nvsp_send(ndev, init_packet);
556+
539557
/* Send the init request */
540558
ret = vmbus_sendpacket(device->channel, init_packet,
541559
sizeof(struct nvsp_message),
@@ -747,7 +765,7 @@ static inline int netvsc_send_pkt(
747765
struct sk_buff *skb)
748766
{
749767
struct nvsp_message nvmsg;
750-
struct nvsp_1_message_send_rndis_packet * const rpkt =
768+
struct nvsp_1_message_send_rndis_packet *rpkt =
751769
&nvmsg.msg.v1_msg.send_rndis_pkt;
752770
struct netvsc_channel * const nvchan =
753771
&net_device->chan_table[packet->q_idx];
@@ -776,6 +794,8 @@ static inline int netvsc_send_pkt(
776794
if (out_channel->rescind)
777795
return -ENODEV;
778796

797+
trace_nvsp_send_pkt(ndev, out_channel, rpkt);
798+
779799
if (packet->page_buf_cnt) {
780800
if (packet->cp_partial)
781801
pb += packet->rmsg_pgcnt;
@@ -1079,6 +1099,8 @@ static int netvsc_receive(struct net_device *ndev,
10791099
+ vmxferpage_packet->ranges[i].byte_offset;
10801100
u32 buflen = vmxferpage_packet->ranges[i].byte_count;
10811101

1102+
trace_rndis_recv(ndev, q_idx, data);
1103+
10821104
/* Pass it to the upper layer */
10831105
status = rndis_filter_receive(ndev, net_device,
10841106
channel, data, buflen);
@@ -1143,6 +1165,8 @@ static int netvsc_process_raw_pkt(struct hv_device *device,
11431165
struct net_device_context *net_device_ctx = netdev_priv(ndev);
11441166
struct nvsp_message *nvmsg = hv_pkt_data(desc);
11451167

1168+
trace_nvsp_recv(ndev, channel, nvmsg);
1169+
11461170
switch (desc->type) {
11471171
case VM_PKT_COMP:
11481172
netvsc_send_completion(net_device, channel, device,

drivers/net/hyperv/netvsc_trace.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#include <linux/netdevice.h>
3+
4+
#include "hyperv_net.h"
5+
6+
#define CREATE_TRACE_POINTS
7+
#include "netvsc_trace.h"

drivers/net/hyperv/netvsc_trace.h

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#if !defined(_NETVSC_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
4+
#define _NETVSC_TRACE_H
5+
6+
#include <linux/tracepoint.h>
7+
8+
#undef TRACE_SYSTEM
9+
#define TRACE_SYSTEM netvsc
10+
#define TRACE_INCLUDE_FILE netvsc_trace
11+
12+
TRACE_DEFINE_ENUM(RNDIS_MSG_PACKET);
13+
TRACE_DEFINE_ENUM(RNDIS_MSG_INDICATE);
14+
TRACE_DEFINE_ENUM(RNDIS_MSG_INIT);
15+
TRACE_DEFINE_ENUM(RNDIS_MSG_INIT_C);
16+
TRACE_DEFINE_ENUM(RNDIS_MSG_HALT);
17+
TRACE_DEFINE_ENUM(RNDIS_MSG_QUERY);
18+
TRACE_DEFINE_ENUM(RNDIS_MSG_QUERY_C);
19+
TRACE_DEFINE_ENUM(RNDIS_MSG_SET);
20+
TRACE_DEFINE_ENUM(RNDIS_MSG_SET_C);
21+
TRACE_DEFINE_ENUM(RNDIS_MSG_RESET);
22+
TRACE_DEFINE_ENUM(RNDIS_MSG_RESET_C);
23+
TRACE_DEFINE_ENUM(RNDIS_MSG_KEEPALIVE);
24+
TRACE_DEFINE_ENUM(RNDIS_MSG_KEEPALIVE_C);
25+
26+
#define show_rndis_type(type) \
27+
__print_symbolic(type, \
28+
{ RNDIS_MSG_PACKET, "PACKET" }, \
29+
{ RNDIS_MSG_INDICATE, "INDICATE", }, \
30+
{ RNDIS_MSG_INIT, "INIT", }, \
31+
{ RNDIS_MSG_INIT_C, "INIT_C", }, \
32+
{ RNDIS_MSG_HALT, "HALT", }, \
33+
{ RNDIS_MSG_QUERY, "QUERY", }, \
34+
{ RNDIS_MSG_QUERY_C, "QUERY_C", }, \
35+
{ RNDIS_MSG_SET, "SET", }, \
36+
{ RNDIS_MSG_SET_C, "SET_C", }, \
37+
{ RNDIS_MSG_RESET, "RESET", }, \
38+
{ RNDIS_MSG_RESET_C, "RESET_C", }, \
39+
{ RNDIS_MSG_KEEPALIVE, "KEEPALIVE", }, \
40+
{ RNDIS_MSG_KEEPALIVE_C, "KEEPALIVE_C", })
41+
42+
DECLARE_EVENT_CLASS(rndis_msg_class,
43+
TP_PROTO(const struct net_device *ndev, u16 q,
44+
const struct rndis_message *msg),
45+
TP_ARGS(ndev, q, msg),
46+
TP_STRUCT__entry(
47+
__string( name, ndev->name )
48+
__field( u16, queue )
49+
__field( u32, req_id )
50+
__field( u32, msg_type )
51+
__field( u32, msg_len )
52+
),
53+
TP_fast_assign(
54+
__assign_str(name, ndev->name);
55+
__entry->queue = q;
56+
__entry->req_id = msg->msg.init_req.req_id;
57+
__entry->msg_type = msg->ndis_msg_type;
58+
__entry->msg_len = msg->msg_len;
59+
),
60+
TP_printk("dev=%s q=%u req=%#x type=%s msg_len=%u",
61+
__get_str(name), __entry->queue, __entry->req_id,
62+
show_rndis_type(__entry->msg_type), __entry->msg_len)
63+
);
64+
65+
DEFINE_EVENT(rndis_msg_class, rndis_send,
66+
TP_PROTO(const struct net_device *ndev, u16 q,
67+
const struct rndis_message *msg),
68+
TP_ARGS(ndev, q, msg)
69+
);
70+
71+
DEFINE_EVENT(rndis_msg_class, rndis_recv,
72+
TP_PROTO(const struct net_device *ndev, u16 q,
73+
const struct rndis_message *msg),
74+
TP_ARGS(ndev, q, msg)
75+
);
76+
77+
TRACE_DEFINE_ENUM(NVSP_MSG_TYPE_INIT);
78+
TRACE_DEFINE_ENUM(NVSP_MSG_TYPE_INIT_COMPLETE);
79+
TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_NDIS_VER);
80+
TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_RECV_BUF);
81+
TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE);
82+
TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_REVOKE_RECV_BUF);
83+
TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_SEND_BUF);
84+
TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE);
85+
TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_REVOKE_SEND_BUF);
86+
TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_RNDIS_PKT);
87+
TRACE_DEFINE_ENUM(NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE);
88+
TRACE_DEFINE_ENUM(NVSP_MSG2_TYPE_SEND_NDIS_CONFIG);
89+
90+
TRACE_DEFINE_ENUM(NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION);
91+
TRACE_DEFINE_ENUM(NVSP_MSG4_TYPE_SWITCH_DATA_PATH);
92+
93+
TRACE_DEFINE_ENUM(NVSP_MSG5_TYPE_SUBCHANNEL);
94+
TRACE_DEFINE_ENUM(NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE);
95+
96+
#define show_nvsp_type(type) \
97+
__print_symbolic(type, \
98+
{ NVSP_MSG_TYPE_INIT, "INIT" }, \
99+
{ NVSP_MSG_TYPE_INIT_COMPLETE, "INIT_COMPLETE" }, \
100+
{ NVSP_MSG1_TYPE_SEND_NDIS_VER, "SEND_NDIS_VER" }, \
101+
{ NVSP_MSG1_TYPE_SEND_RECV_BUF, "SEND_RECV_BUF" }, \
102+
{ NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE, "SEND_RECV_BUF_COMPLETE" }, \
103+
{ NVSP_MSG1_TYPE_REVOKE_RECV_BUF, "REVOKE_RECV_BUF" }, \
104+
{ NVSP_MSG1_TYPE_SEND_SEND_BUF, "SEND_SEND_BUF" }, \
105+
{ NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE, "SEND_SEND_BUF_COMPLETE" }, \
106+
{ NVSP_MSG1_TYPE_REVOKE_SEND_BUF, "REVOKE_SEND_BUF" }, \
107+
{ NVSP_MSG1_TYPE_SEND_RNDIS_PKT, "SEND_RNDIS_PKT" }, \
108+
{ NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE, "SEND_RNDIS_PKT_COMPLETE" },\
109+
{ NVSP_MSG2_TYPE_SEND_NDIS_CONFIG, "SEND_NDIS_CONFIG" }, \
110+
{ NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION, "SEND_VF_ASSOCIATION" }, \
111+
{ NVSP_MSG4_TYPE_SWITCH_DATA_PATH, "SWITCH_DATA_PATH" }, \
112+
{ NVSP_MSG5_TYPE_SUBCHANNEL, "SUBCHANNEL" }, \
113+
{ NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE, "SEND_INDIRECTION_TABLE" })
114+
115+
TRACE_EVENT(nvsp_send,
116+
TP_PROTO(const struct net_device *ndev,
117+
const struct nvsp_message *msg),
118+
TP_ARGS(ndev, msg),
119+
TP_STRUCT__entry(
120+
__string( name, ndev->name )
121+
__field( u32, msg_type )
122+
),
123+
TP_fast_assign(
124+
__assign_str(name, ndev->name);
125+
__entry->msg_type = msg->hdr.msg_type;
126+
),
127+
TP_printk("dev=%s type=%s",
128+
__get_str(name),
129+
show_nvsp_type(__entry->msg_type))
130+
);
131+
132+
TRACE_EVENT(nvsp_send_pkt,
133+
TP_PROTO(const struct net_device *ndev,
134+
const struct vmbus_channel *chan,
135+
const struct nvsp_1_message_send_rndis_packet *rpkt),
136+
TP_ARGS(ndev, chan, rpkt),
137+
TP_STRUCT__entry(
138+
__string( name, ndev->name )
139+
__field( u16, qid )
140+
__field( u32, channel_type )
141+
__field( u32, section_index )
142+
__field( u32, section_size )
143+
),
144+
TP_fast_assign(
145+
__assign_str(name, ndev->name);
146+
__entry->qid = chan->offermsg.offer.sub_channel_index;
147+
__entry->channel_type = rpkt->channel_type;
148+
__entry->section_index = rpkt->send_buf_section_index;
149+
__entry->section_size = rpkt->send_buf_section_size;
150+
),
151+
TP_printk("dev=%s qid=%u type=%s section=%u size=%d",
152+
__get_str(name), __entry->qid,
153+
__entry->channel_type ? "CONTROL" : "DATA",
154+
__entry->section_index, __entry->section_size)
155+
);
156+
157+
TRACE_EVENT(nvsp_recv,
158+
TP_PROTO(const struct net_device *ndev,
159+
const struct vmbus_channel *chan,
160+
const struct nvsp_message *msg),
161+
TP_ARGS(ndev, chan, msg),
162+
TP_STRUCT__entry(
163+
__string( name, ndev->name )
164+
__field( u16, qid )
165+
__field( u32, msg_type )
166+
),
167+
TP_fast_assign(
168+
__assign_str(name, ndev->name);
169+
__entry->qid = chan->offermsg.offer.sub_channel_index;
170+
__entry->msg_type = msg->hdr.msg_type;
171+
),
172+
TP_printk("dev=%s qid=%u type=%s",
173+
__get_str(name), __entry->qid,
174+
show_nvsp_type(__entry->msg_type))
175+
);
176+
177+
#endif /* _NETVSC_TRACE_H */
178+
179+
/* This part must be outside protection */
180+
#undef TRACE_INCLUDE_PATH
181+
#define TRACE_INCLUDE_PATH ../../drivers/net/hyperv
182+
#include <trace/define_trace.h>

drivers/net/hyperv/rndis_filter.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/rtnetlink.h>
3232

3333
#include "hyperv_net.h"
34+
#include "netvsc_trace.h"
3435

3536
static void rndis_set_multicast(struct work_struct *w);
3637

@@ -241,6 +242,8 @@ static int rndis_filter_send_request(struct rndis_device *dev,
241242
pb[0].len;
242243
}
243244

245+
trace_rndis_send(dev->ndev, 0, &req->request_msg);
246+
244247
rcu_read_lock_bh();
245248
ret = netvsc_send(dev->ndev, packet, NULL, pb, NULL);
246249
rcu_read_unlock_bh();
@@ -944,12 +947,11 @@ static bool netvsc_device_idle(const struct netvsc_device *nvdev)
944947
return true;
945948
}
946949

947-
static void rndis_filter_halt_device(struct rndis_device *dev)
950+
static void rndis_filter_halt_device(struct netvsc_device *nvdev,
951+
struct rndis_device *dev)
948952
{
949953
struct rndis_request *request;
950954
struct rndis_halt_request *halt;
951-
struct net_device_context *net_device_ctx = netdev_priv(dev->ndev);
952-
struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev);
953955

954956
/* Attempt to do a rndis device halt */
955957
request = get_rndis_request(dev, RNDIS_MSG_HALT,
@@ -1088,6 +1090,8 @@ void rndis_set_subchannel(struct work_struct *w)
10881090
init_packet->msg.v5_msg.subchn_req.op = NVSP_SUBCHANNEL_ALLOCATE;
10891091
init_packet->msg.v5_msg.subchn_req.num_subchannels =
10901092
nvdev->num_chn - 1;
1093+
trace_nvsp_send(ndev, init_packet);
1094+
10911095
ret = vmbus_sendpacket(hv_dev->channel, init_packet,
10921096
sizeof(struct nvsp_message),
10931097
(unsigned long)init_packet,
@@ -1348,7 +1352,7 @@ void rndis_filter_device_remove(struct hv_device *dev,
13481352
cancel_work_sync(&net_dev->subchan_work);
13491353

13501354
/* Halt and release the rndis device */
1351-
rndis_filter_halt_device(rndis_dev);
1355+
rndis_filter_halt_device(net_dev, rndis_dev);
13521356

13531357
net_dev->extension = NULL;
13541358

0 commit comments

Comments
 (0)