Skip to content

Commit c347b92

Browse files
shemmingerdavem330
authored andcommitted
hv_netvsc: simplify receive side calling arguments
The calls up from the napi poll reading the receive ring had many places where an argument was being recreated. I.e the caller already had the value and wasn't passing it, then the callee would use known relationship to determine the same value. Simpler and faster to just pass arguments needed. Also, add const in a couple places where message is being only read. Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4422cc0 commit c347b92

File tree

1 file changed

+26
-32
lines changed

1 file changed

+26
-32
lines changed

drivers/net/hyperv/netvsc.c

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -652,16 +652,14 @@ static inline void netvsc_free_send_slot(struct netvsc_device *net_device,
652652
sync_change_bit(index, net_device->send_section_map);
653653
}
654654

655-
static void netvsc_send_tx_complete(struct netvsc_device *net_device,
656-
struct vmbus_channel *incoming_channel,
657-
struct hv_device *device,
655+
static void netvsc_send_tx_complete(struct net_device *ndev,
656+
struct netvsc_device *net_device,
657+
struct vmbus_channel *channel,
658658
const struct vmpacket_descriptor *desc,
659659
int budget)
660660
{
661661
struct sk_buff *skb = (struct sk_buff *)(unsigned long)desc->trans_id;
662-
struct net_device *ndev = hv_get_drvdata(device);
663662
struct net_device_context *ndev_ctx = netdev_priv(ndev);
664-
struct vmbus_channel *channel = device->channel;
665663
u16 q_idx = 0;
666664
int queue_sends;
667665

@@ -675,7 +673,6 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device,
675673
if (send_index != NETVSC_INVALID_INDEX)
676674
netvsc_free_send_slot(net_device, send_index);
677675
q_idx = packet->q_idx;
678-
channel = incoming_channel;
679676

680677
tx_stats = &net_device->chan_table[q_idx].tx_stats;
681678

@@ -705,14 +702,13 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device,
705702
}
706703
}
707704

708-
static void netvsc_send_completion(struct netvsc_device *net_device,
705+
static void netvsc_send_completion(struct net_device *ndev,
706+
struct netvsc_device *net_device,
709707
struct vmbus_channel *incoming_channel,
710-
struct hv_device *device,
711708
const struct vmpacket_descriptor *desc,
712709
int budget)
713710
{
714-
struct nvsp_message *nvsp_packet = hv_pkt_data(desc);
715-
struct net_device *ndev = hv_get_drvdata(device);
711+
const struct nvsp_message *nvsp_packet = hv_pkt_data(desc);
716712

717713
switch (nvsp_packet->hdr.msg_type) {
718714
case NVSP_MSG_TYPE_INIT_COMPLETE:
@@ -726,8 +722,8 @@ static void netvsc_send_completion(struct netvsc_device *net_device,
726722
break;
727723

728724
case NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE:
729-
netvsc_send_tx_complete(net_device, incoming_channel,
730-
device, desc, budget);
725+
netvsc_send_tx_complete(ndev, net_device, incoming_channel,
726+
desc, budget);
731727
break;
732728

733729
default:
@@ -1092,12 +1088,11 @@ static void enq_receive_complete(struct net_device *ndev,
10921088

10931089
static int netvsc_receive(struct net_device *ndev,
10941090
struct netvsc_device *net_device,
1095-
struct net_device_context *net_device_ctx,
1096-
struct hv_device *device,
10971091
struct vmbus_channel *channel,
10981092
const struct vmpacket_descriptor *desc,
1099-
struct nvsp_message *nvsp)
1093+
const struct nvsp_message *nvsp)
11001094
{
1095+
struct net_device_context *net_device_ctx = netdev_priv(ndev);
11011096
const struct vmtransfer_page_packet_header *vmxferpage_packet
11021097
= container_of(desc, const struct vmtransfer_page_packet_header, d);
11031098
u16 q_idx = channel->offermsg.offer.sub_channel_index;
@@ -1158,13 +1153,12 @@ static int netvsc_receive(struct net_device *ndev,
11581153
return count;
11591154
}
11601155

1161-
static void netvsc_send_table(struct hv_device *hdev,
1162-
struct nvsp_message *nvmsg)
1156+
static void netvsc_send_table(struct net_device *ndev,
1157+
const struct nvsp_message *nvmsg)
11631158
{
1164-
struct net_device *ndev = hv_get_drvdata(hdev);
11651159
struct net_device_context *net_device_ctx = netdev_priv(ndev);
1166-
int i;
11671160
u32 count, *tab;
1161+
int i;
11681162

11691163
count = nvmsg->msg.v5_msg.send_table.count;
11701164
if (count != VRSS_SEND_TAB_SIZE) {
@@ -1179,24 +1173,25 @@ static void netvsc_send_table(struct hv_device *hdev,
11791173
net_device_ctx->tx_table[i] = tab[i];
11801174
}
11811175

1182-
static void netvsc_send_vf(struct net_device_context *net_device_ctx,
1183-
struct nvsp_message *nvmsg)
1176+
static void netvsc_send_vf(struct net_device *ndev,
1177+
const struct nvsp_message *nvmsg)
11841178
{
1179+
struct net_device_context *net_device_ctx = netdev_priv(ndev);
1180+
11851181
net_device_ctx->vf_alloc = nvmsg->msg.v4_msg.vf_assoc.allocated;
11861182
net_device_ctx->vf_serial = nvmsg->msg.v4_msg.vf_assoc.serial;
11871183
}
11881184

1189-
static inline void netvsc_receive_inband(struct hv_device *hdev,
1190-
struct net_device_context *net_device_ctx,
1191-
struct nvsp_message *nvmsg)
1185+
static void netvsc_receive_inband(struct net_device *ndev,
1186+
const struct nvsp_message *nvmsg)
11921187
{
11931188
switch (nvmsg->hdr.msg_type) {
11941189
case NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE:
1195-
netvsc_send_table(hdev, nvmsg);
1190+
netvsc_send_table(ndev, nvmsg);
11961191
break;
11971192

11981193
case NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION:
1199-
netvsc_send_vf(net_device_ctx, nvmsg);
1194+
netvsc_send_vf(ndev, nvmsg);
12001195
break;
12011196
}
12021197
}
@@ -1208,24 +1203,23 @@ static int netvsc_process_raw_pkt(struct hv_device *device,
12081203
const struct vmpacket_descriptor *desc,
12091204
int budget)
12101205
{
1211-
struct net_device_context *net_device_ctx = netdev_priv(ndev);
1212-
struct nvsp_message *nvmsg = hv_pkt_data(desc);
1206+
const struct nvsp_message *nvmsg = hv_pkt_data(desc);
12131207

12141208
trace_nvsp_recv(ndev, channel, nvmsg);
12151209

12161210
switch (desc->type) {
12171211
case VM_PKT_COMP:
1218-
netvsc_send_completion(net_device, channel, device,
1212+
netvsc_send_completion(ndev, net_device, channel,
12191213
desc, budget);
12201214
break;
12211215

12221216
case VM_PKT_DATA_USING_XFER_PAGES:
1223-
return netvsc_receive(ndev, net_device, net_device_ctx,
1224-
device, channel, desc, nvmsg);
1217+
return netvsc_receive(ndev, net_device, channel,
1218+
desc, nvmsg);
12251219
break;
12261220

12271221
case VM_PKT_DATA_INBAND:
1228-
netvsc_receive_inband(device, net_device_ctx, nvmsg);
1222+
netvsc_receive_inband(ndev, nvmsg);
12291223
break;
12301224

12311225
default:

0 commit comments

Comments
 (0)