Skip to content

Commit

Permalink
hv_netvsc: simplify receive side calling arguments
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Hemminger authored and David S. Miller committed Apr 27, 2018
1 parent 4422cc0 commit c347b92
Showing 1 changed file with 26 additions and 32 deletions.
58 changes: 26 additions & 32 deletions drivers/net/hyperv/netvsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,16 +652,14 @@ static inline void netvsc_free_send_slot(struct netvsc_device *net_device,
sync_change_bit(index, net_device->send_section_map);
}

static void netvsc_send_tx_complete(struct netvsc_device *net_device,
struct vmbus_channel *incoming_channel,
struct hv_device *device,
static void netvsc_send_tx_complete(struct net_device *ndev,
struct netvsc_device *net_device,
struct vmbus_channel *channel,
const struct vmpacket_descriptor *desc,
int budget)
{
struct sk_buff *skb = (struct sk_buff *)(unsigned long)desc->trans_id;
struct net_device *ndev = hv_get_drvdata(device);
struct net_device_context *ndev_ctx = netdev_priv(ndev);
struct vmbus_channel *channel = device->channel;
u16 q_idx = 0;
int queue_sends;

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

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

Expand Down Expand Up @@ -705,14 +702,13 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device,
}
}

static void netvsc_send_completion(struct netvsc_device *net_device,
static void netvsc_send_completion(struct net_device *ndev,
struct netvsc_device *net_device,
struct vmbus_channel *incoming_channel,
struct hv_device *device,
const struct vmpacket_descriptor *desc,
int budget)
{
struct nvsp_message *nvsp_packet = hv_pkt_data(desc);
struct net_device *ndev = hv_get_drvdata(device);
const struct nvsp_message *nvsp_packet = hv_pkt_data(desc);

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

case NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE:
netvsc_send_tx_complete(net_device, incoming_channel,
device, desc, budget);
netvsc_send_tx_complete(ndev, net_device, incoming_channel,
desc, budget);
break;

default:
Expand Down Expand Up @@ -1092,12 +1088,11 @@ static void enq_receive_complete(struct net_device *ndev,

static int netvsc_receive(struct net_device *ndev,
struct netvsc_device *net_device,
struct net_device_context *net_device_ctx,
struct hv_device *device,
struct vmbus_channel *channel,
const struct vmpacket_descriptor *desc,
struct nvsp_message *nvsp)
const struct nvsp_message *nvsp)
{
struct net_device_context *net_device_ctx = netdev_priv(ndev);
const struct vmtransfer_page_packet_header *vmxferpage_packet
= container_of(desc, const struct vmtransfer_page_packet_header, d);
u16 q_idx = channel->offermsg.offer.sub_channel_index;
Expand Down Expand Up @@ -1158,13 +1153,12 @@ static int netvsc_receive(struct net_device *ndev,
return count;
}

static void netvsc_send_table(struct hv_device *hdev,
struct nvsp_message *nvmsg)
static void netvsc_send_table(struct net_device *ndev,
const struct nvsp_message *nvmsg)
{
struct net_device *ndev = hv_get_drvdata(hdev);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
int i;
u32 count, *tab;
int i;

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

static void netvsc_send_vf(struct net_device_context *net_device_ctx,
struct nvsp_message *nvmsg)
static void netvsc_send_vf(struct net_device *ndev,
const struct nvsp_message *nvmsg)
{
struct net_device_context *net_device_ctx = netdev_priv(ndev);

net_device_ctx->vf_alloc = nvmsg->msg.v4_msg.vf_assoc.allocated;
net_device_ctx->vf_serial = nvmsg->msg.v4_msg.vf_assoc.serial;
}

static inline void netvsc_receive_inband(struct hv_device *hdev,
struct net_device_context *net_device_ctx,
struct nvsp_message *nvmsg)
static void netvsc_receive_inband(struct net_device *ndev,
const struct nvsp_message *nvmsg)
{
switch (nvmsg->hdr.msg_type) {
case NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE:
netvsc_send_table(hdev, nvmsg);
netvsc_send_table(ndev, nvmsg);
break;

case NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION:
netvsc_send_vf(net_device_ctx, nvmsg);
netvsc_send_vf(ndev, nvmsg);
break;
}
}
Expand All @@ -1208,24 +1203,23 @@ static int netvsc_process_raw_pkt(struct hv_device *device,
const struct vmpacket_descriptor *desc,
int budget)
{
struct net_device_context *net_device_ctx = netdev_priv(ndev);
struct nvsp_message *nvmsg = hv_pkt_data(desc);
const struct nvsp_message *nvmsg = hv_pkt_data(desc);

trace_nvsp_recv(ndev, channel, nvmsg);

switch (desc->type) {
case VM_PKT_COMP:
netvsc_send_completion(net_device, channel, device,
netvsc_send_completion(ndev, net_device, channel,
desc, budget);
break;

case VM_PKT_DATA_USING_XFER_PAGES:
return netvsc_receive(ndev, net_device, net_device_ctx,
device, channel, desc, nvmsg);
return netvsc_receive(ndev, net_device, channel,
desc, nvmsg);
break;

case VM_PKT_DATA_INBAND:
netvsc_receive_inband(device, net_device_ctx, nvmsg);
netvsc_receive_inband(ndev, nvmsg);
break;

default:
Expand Down

0 comments on commit c347b92

Please sign in to comment.