[PATCH net-next V2 03/17] hv_netvsc: Eliminate the channel field in hv_netvsc_packet structure

2015-11-28 Thread K. Y. Srinivasan
Eliminate the channel field in hv_netvsc_packet structure.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/hyperv_net.h   |   22 ++
 drivers/net/hyperv/netvsc.c   |   19 ---
 drivers/net/hyperv/netvsc_drv.c   |5 +++--
 drivers/net/hyperv/rndis_filter.c |   10 ++
 4 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 7435673..ac24091 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -144,7 +144,6 @@ struct hv_netvsc_packet {
u32 total_data_buflen;
u32 pad1;
 
-   struct vmbus_channel *channel;
 
u64 send_completion_tid;
void *send_completion_ctx;
@@ -199,7 +198,8 @@ void netvsc_linkstatus_callback(struct hv_device 
*device_obj,
 void netvsc_xmit_completion(void *context);
 int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet,
-   struct ndis_tcp_ip_checksum_info *csum_info);
+   struct ndis_tcp_ip_checksum_info *csum_info,
+   struct vmbus_channel *channel);
 void netvsc_channel_cb(void *context);
 int rndis_filter_open(struct hv_device *dev);
 int rndis_filter_close(struct hv_device *dev);
@@ -207,12 +207,12 @@ int rndis_filter_device_add(struct hv_device *dev,
void *additional_info);
 void rndis_filter_device_remove(struct hv_device *dev);
 int rndis_filter_receive(struct hv_device *dev,
-   struct hv_netvsc_packet *pkt);
+   struct hv_netvsc_packet *pkt,
+   struct vmbus_channel *channel);
 
 int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);
 int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac);
 
-
 #define NVSP_INVALID_PROTOCOL_VERSION  ((u32)0x)
 
 #define NVSP_PROTOCOL_VERSION_12
@@ -1262,5 +1262,19 @@ struct rndis_message {
 #define TRANSPORT_INFO_IPV6_TCP ((INFO_IPV6 << 16) | INFO_TCP)
 #define TRANSPORT_INFO_IPV6_UDP ((INFO_IPV6 << 16) | INFO_UDP)
 
+static inline struct vmbus_channel *get_channel(struct hv_netvsc_packet 
*packet,
+   struct netvsc_device *net_device)
+
+{
+   struct vmbus_channel *out_channel;
+
+   out_channel = net_device->chn_table[packet->q_idx];
+   if (!out_channel) {
+   out_channel = net_device->dev->channel;
+   packet->q_idx = 0;
+   }
+   return out_channel;
+}
+
 
 #endif /* _HYPERV_NET_H */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 51e4c0f..52533ed 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -610,6 +610,7 @@ static inline void netvsc_free_send_slot(struct 
netvsc_device *net_device,
 }
 
 static void netvsc_send_completion(struct netvsc_device *net_device,
+  struct vmbus_channel *incoming_channel,
   struct hv_device *device,
   struct vmpacket_descriptor *packet)
 {
@@ -651,7 +652,7 @@ static void netvsc_send_completion(struct netvsc_device 
*net_device,
if (send_index != NETVSC_INVALID_INDEX)
netvsc_free_send_slot(net_device, send_index);
q_idx = nvsc_packet->q_idx;
-   channel = nvsc_packet->channel;
+   channel = incoming_channel;
nvsc_packet->send_completion(nvsc_packet->
 send_completion_ctx);
}
@@ -748,7 +749,7 @@ static inline int netvsc_send_pkt(
struct netvsc_device *net_device)
 {
struct nvsp_message nvmsg;
-   struct vmbus_channel *out_channel = packet->channel;
+   struct vmbus_channel *out_channel = get_channel(packet, net_device);
u16 q_idx = packet->q_idx;
struct net_device *ndev = net_device->ndev;
u64 req_id;
@@ -857,13 +858,9 @@ int netvsc_send(struct hv_device *device,
if (!net_device)
return -ENODEV;
 
-   out_channel = net_device->chn_table[q_idx];
-   if (!out_channel) {
-   out_channel = device->channel;
-   q_idx = 0;
-   packet->q_idx = 0;
-   }
-   packet->channel = out_channel;
+   out_channel = get_channel(packet, net_device);
+   q_idx = packet->q_idx;
+
packet->send_buf_index = NETVSC_INVALID_INDEX;
packet->cp_partial = false;
 
@@ -1043,7 +1040,6 @@ static void netvsc_receive(struct netvsc_device 
*net_device,
}
 
count = vmxferpage_packet->range_cnt;
-   netvsc_packet->channel = channel;
 
/* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */
for (i = 0; i < count; i++) {
@@ -1055,7 

[PATCH net-next V2 03/17] hv_netvsc: Eliminate the channel field in hv_netvsc_packet structure

2015-11-28 Thread K. Y. Srinivasan
Eliminate the channel field in hv_netvsc_packet structure.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/hyperv_net.h   |   22 ++
 drivers/net/hyperv/netvsc.c   |   19 ---
 drivers/net/hyperv/netvsc_drv.c   |5 +++--
 drivers/net/hyperv/rndis_filter.c |   10 ++
 4 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 7435673..ac24091 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -144,7 +144,6 @@ struct hv_netvsc_packet {
u32 total_data_buflen;
u32 pad1;
 
-   struct vmbus_channel *channel;
 
u64 send_completion_tid;
void *send_completion_ctx;
@@ -199,7 +198,8 @@ void netvsc_linkstatus_callback(struct hv_device 
*device_obj,
 void netvsc_xmit_completion(void *context);
 int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet,
-   struct ndis_tcp_ip_checksum_info *csum_info);
+   struct ndis_tcp_ip_checksum_info *csum_info,
+   struct vmbus_channel *channel);
 void netvsc_channel_cb(void *context);
 int rndis_filter_open(struct hv_device *dev);
 int rndis_filter_close(struct hv_device *dev);
@@ -207,12 +207,12 @@ int rndis_filter_device_add(struct hv_device *dev,
void *additional_info);
 void rndis_filter_device_remove(struct hv_device *dev);
 int rndis_filter_receive(struct hv_device *dev,
-   struct hv_netvsc_packet *pkt);
+   struct hv_netvsc_packet *pkt,
+   struct vmbus_channel *channel);
 
 int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);
 int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac);
 
-
 #define NVSP_INVALID_PROTOCOL_VERSION  ((u32)0x)
 
 #define NVSP_PROTOCOL_VERSION_12
@@ -1262,5 +1262,19 @@ struct rndis_message {
 #define TRANSPORT_INFO_IPV6_TCP ((INFO_IPV6 << 16) | INFO_TCP)
 #define TRANSPORT_INFO_IPV6_UDP ((INFO_IPV6 << 16) | INFO_UDP)
 
+static inline struct vmbus_channel *get_channel(struct hv_netvsc_packet 
*packet,
+   struct netvsc_device *net_device)
+
+{
+   struct vmbus_channel *out_channel;
+
+   out_channel = net_device->chn_table[packet->q_idx];
+   if (!out_channel) {
+   out_channel = net_device->dev->channel;
+   packet->q_idx = 0;
+   }
+   return out_channel;
+}
+
 
 #endif /* _HYPERV_NET_H */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 51e4c0f..52533ed 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -610,6 +610,7 @@ static inline void netvsc_free_send_slot(struct 
netvsc_device *net_device,
 }
 
 static void netvsc_send_completion(struct netvsc_device *net_device,
+  struct vmbus_channel *incoming_channel,
   struct hv_device *device,
   struct vmpacket_descriptor *packet)
 {
@@ -651,7 +652,7 @@ static void netvsc_send_completion(struct netvsc_device 
*net_device,
if (send_index != NETVSC_INVALID_INDEX)
netvsc_free_send_slot(net_device, send_index);
q_idx = nvsc_packet->q_idx;
-   channel = nvsc_packet->channel;
+   channel = incoming_channel;
nvsc_packet->send_completion(nvsc_packet->
 send_completion_ctx);
}
@@ -748,7 +749,7 @@ static inline int netvsc_send_pkt(
struct netvsc_device *net_device)
 {
struct nvsp_message nvmsg;
-   struct vmbus_channel *out_channel = packet->channel;
+   struct vmbus_channel *out_channel = get_channel(packet, net_device);
u16 q_idx = packet->q_idx;
struct net_device *ndev = net_device->ndev;
u64 req_id;
@@ -857,13 +858,9 @@ int netvsc_send(struct hv_device *device,
if (!net_device)
return -ENODEV;
 
-   out_channel = net_device->chn_table[q_idx];
-   if (!out_channel) {
-   out_channel = device->channel;
-   q_idx = 0;
-   packet->q_idx = 0;
-   }
-   packet->channel = out_channel;
+   out_channel = get_channel(packet, net_device);
+   q_idx = packet->q_idx;
+
packet->send_buf_index = NETVSC_INVALID_INDEX;
packet->cp_partial = false;
 
@@ -1043,7 +1040,6 @@ static void netvsc_receive(struct netvsc_device 
*net_device,
}
 
count = vmxferpage_packet->range_cnt;
-   netvsc_packet->channel = channel;
 
/* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */