Commit c347b927 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

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: default avatarStephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4422cc0d
...@@ -652,16 +652,14 @@ static inline void netvsc_free_send_slot(struct netvsc_device *net_device, ...@@ -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); sync_change_bit(index, net_device->send_section_map);
} }
static void netvsc_send_tx_complete(struct netvsc_device *net_device, static void netvsc_send_tx_complete(struct net_device *ndev,
struct vmbus_channel *incoming_channel, struct netvsc_device *net_device,
struct hv_device *device, struct vmbus_channel *channel,
const struct vmpacket_descriptor *desc, const struct vmpacket_descriptor *desc,
int budget) int budget)
{ {
struct sk_buff *skb = (struct sk_buff *)(unsigned long)desc->trans_id; 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 net_device_context *ndev_ctx = netdev_priv(ndev);
struct vmbus_channel *channel = device->channel;
u16 q_idx = 0; u16 q_idx = 0;
int queue_sends; int queue_sends;
...@@ -675,7 +673,6 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device, ...@@ -675,7 +673,6 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device,
if (send_index != NETVSC_INVALID_INDEX) if (send_index != NETVSC_INVALID_INDEX)
netvsc_free_send_slot(net_device, send_index); netvsc_free_send_slot(net_device, send_index);
q_idx = packet->q_idx; q_idx = packet->q_idx;
channel = incoming_channel;
tx_stats = &net_device->chan_table[q_idx].tx_stats; tx_stats = &net_device->chan_table[q_idx].tx_stats;
...@@ -705,14 +702,13 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device, ...@@ -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 vmbus_channel *incoming_channel,
struct hv_device *device,
const struct vmpacket_descriptor *desc, const struct vmpacket_descriptor *desc,
int budget) int budget)
{ {
struct nvsp_message *nvsp_packet = hv_pkt_data(desc); const struct nvsp_message *nvsp_packet = hv_pkt_data(desc);
struct net_device *ndev = hv_get_drvdata(device);
switch (nvsp_packet->hdr.msg_type) { switch (nvsp_packet->hdr.msg_type) {
case NVSP_MSG_TYPE_INIT_COMPLETE: case NVSP_MSG_TYPE_INIT_COMPLETE:
...@@ -726,8 +722,8 @@ static void netvsc_send_completion(struct netvsc_device *net_device, ...@@ -726,8 +722,8 @@ static void netvsc_send_completion(struct netvsc_device *net_device,
break; break;
case NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE: case NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE:
netvsc_send_tx_complete(net_device, incoming_channel, netvsc_send_tx_complete(ndev, net_device, incoming_channel,
device, desc, budget); desc, budget);
break; break;
default: default:
...@@ -1092,12 +1088,11 @@ static void enq_receive_complete(struct net_device *ndev, ...@@ -1092,12 +1088,11 @@ static void enq_receive_complete(struct net_device *ndev,
static int netvsc_receive(struct net_device *ndev, static int netvsc_receive(struct net_device *ndev,
struct netvsc_device *net_device, struct netvsc_device *net_device,
struct net_device_context *net_device_ctx,
struct hv_device *device,
struct vmbus_channel *channel, struct vmbus_channel *channel,
const struct vmpacket_descriptor *desc, 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 const struct vmtransfer_page_packet_header *vmxferpage_packet
= container_of(desc, const struct vmtransfer_page_packet_header, d); = container_of(desc, const struct vmtransfer_page_packet_header, d);
u16 q_idx = channel->offermsg.offer.sub_channel_index; u16 q_idx = channel->offermsg.offer.sub_channel_index;
...@@ -1158,13 +1153,12 @@ static int netvsc_receive(struct net_device *ndev, ...@@ -1158,13 +1153,12 @@ static int netvsc_receive(struct net_device *ndev,
return count; return count;
} }
static void netvsc_send_table(struct hv_device *hdev, static void netvsc_send_table(struct net_device *ndev,
struct nvsp_message *nvmsg) const struct nvsp_message *nvmsg)
{ {
struct net_device *ndev = hv_get_drvdata(hdev);
struct net_device_context *net_device_ctx = netdev_priv(ndev); struct net_device_context *net_device_ctx = netdev_priv(ndev);
int i;
u32 count, *tab; u32 count, *tab;
int i;
count = nvmsg->msg.v5_msg.send_table.count; count = nvmsg->msg.v5_msg.send_table.count;
if (count != VRSS_SEND_TAB_SIZE) { if (count != VRSS_SEND_TAB_SIZE) {
...@@ -1179,24 +1173,25 @@ static void netvsc_send_table(struct hv_device *hdev, ...@@ -1179,24 +1173,25 @@ static void netvsc_send_table(struct hv_device *hdev,
net_device_ctx->tx_table[i] = tab[i]; net_device_ctx->tx_table[i] = tab[i];
} }
static void netvsc_send_vf(struct net_device_context *net_device_ctx, static void netvsc_send_vf(struct net_device *ndev,
struct nvsp_message *nvmsg) 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_alloc = nvmsg->msg.v4_msg.vf_assoc.allocated;
net_device_ctx->vf_serial = nvmsg->msg.v4_msg.vf_assoc.serial; net_device_ctx->vf_serial = nvmsg->msg.v4_msg.vf_assoc.serial;
} }
static inline void netvsc_receive_inband(struct hv_device *hdev, static void netvsc_receive_inband(struct net_device *ndev,
struct net_device_context *net_device_ctx, const struct nvsp_message *nvmsg)
struct nvsp_message *nvmsg)
{ {
switch (nvmsg->hdr.msg_type) { switch (nvmsg->hdr.msg_type) {
case NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE: case NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE:
netvsc_send_table(hdev, nvmsg); netvsc_send_table(ndev, nvmsg);
break; break;
case NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION: case NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION:
netvsc_send_vf(net_device_ctx, nvmsg); netvsc_send_vf(ndev, nvmsg);
break; break;
} }
} }
...@@ -1208,24 +1203,23 @@ static int netvsc_process_raw_pkt(struct hv_device *device, ...@@ -1208,24 +1203,23 @@ static int netvsc_process_raw_pkt(struct hv_device *device,
const struct vmpacket_descriptor *desc, const struct vmpacket_descriptor *desc,
int budget) int budget)
{ {
struct net_device_context *net_device_ctx = netdev_priv(ndev); const struct nvsp_message *nvmsg = hv_pkt_data(desc);
struct nvsp_message *nvmsg = hv_pkt_data(desc);
trace_nvsp_recv(ndev, channel, nvmsg); trace_nvsp_recv(ndev, channel, nvmsg);
switch (desc->type) { switch (desc->type) {
case VM_PKT_COMP: case VM_PKT_COMP:
netvsc_send_completion(net_device, channel, device, netvsc_send_completion(ndev, net_device, channel,
desc, budget); desc, budget);
break; break;
case VM_PKT_DATA_USING_XFER_PAGES: case VM_PKT_DATA_USING_XFER_PAGES:
return netvsc_receive(ndev, net_device, net_device_ctx, return netvsc_receive(ndev, net_device, channel,
device, channel, desc, nvmsg); desc, nvmsg);
break; break;
case VM_PKT_DATA_INBAND: case VM_PKT_DATA_INBAND:
netvsc_receive_inband(device, net_device_ctx, nvmsg); netvsc_receive_inband(ndev, nvmsg);
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment