Commit a9f2e2d6 authored by KY Srinivasan's avatar KY Srinivasan Committed by David S. Miller

hv_netvsc: Eliminate page_buf from struct hv_netvsc_packet

Eliminate page_buf from struct hv_netvsc_packet.
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2a04ae8a
...@@ -149,7 +149,6 @@ struct hv_netvsc_packet { ...@@ -149,7 +149,6 @@ struct hv_netvsc_packet {
u64 send_completion_tid; u64 send_completion_tid;
struct hv_page_buffer *page_buf;
}; };
struct netvsc_device_info { struct netvsc_device_info {
...@@ -187,7 +186,8 @@ int netvsc_device_add(struct hv_device *device, void *additional_info); ...@@ -187,7 +186,8 @@ int netvsc_device_add(struct hv_device *device, void *additional_info);
int netvsc_device_remove(struct hv_device *device); int netvsc_device_remove(struct hv_device *device);
int netvsc_send(struct hv_device *device, int netvsc_send(struct hv_device *device,
struct hv_netvsc_packet *packet, struct hv_netvsc_packet *packet,
struct rndis_message *rndis_msg); struct rndis_message *rndis_msg,
struct hv_page_buffer **page_buffer);
void netvsc_linkstatus_callback(struct hv_device *device_obj, void netvsc_linkstatus_callback(struct hv_device *device_obj,
struct rndis_message *resp); struct rndis_message *resp);
void netvsc_xmit_completion(void *context); void netvsc_xmit_completion(void *context);
......
...@@ -702,7 +702,8 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device, ...@@ -702,7 +702,8 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device,
unsigned int section_index, unsigned int section_index,
u32 pend_size, u32 pend_size,
struct hv_netvsc_packet *packet, struct hv_netvsc_packet *packet,
struct rndis_message *rndis_msg) struct rndis_message *rndis_msg,
struct hv_page_buffer **pb)
{ {
char *start = net_device->send_buf; char *start = net_device->send_buf;
char *dest = start + (section_index * net_device->send_section_size) char *dest = start + (section_index * net_device->send_section_size)
...@@ -723,9 +724,9 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device, ...@@ -723,9 +724,9 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device,
} }
for (i = 0; i < page_count; i++) { for (i = 0; i < page_count; i++) {
char *src = phys_to_virt(packet->page_buf[i].pfn << PAGE_SHIFT); char *src = phys_to_virt((*pb)[i].pfn << PAGE_SHIFT);
u32 offset = packet->page_buf[i].offset; u32 offset = (*pb)[i].offset;
u32 len = packet->page_buf[i].len; u32 len = (*pb)[i].len;
memcpy(dest, (src + offset), len); memcpy(dest, (src + offset), len);
msg_size += len; msg_size += len;
...@@ -742,7 +743,8 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device, ...@@ -742,7 +743,8 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device,
static inline int netvsc_send_pkt( static inline int netvsc_send_pkt(
struct hv_netvsc_packet *packet, struct hv_netvsc_packet *packet,
struct netvsc_device *net_device) struct netvsc_device *net_device,
struct hv_page_buffer **pb)
{ {
struct nvsp_message nvmsg; struct nvsp_message nvmsg;
u16 q_idx = packet->q_idx; u16 q_idx = packet->q_idx;
...@@ -789,8 +791,8 @@ static inline int netvsc_send_pkt( ...@@ -789,8 +791,8 @@ static inline int netvsc_send_pkt(
packet->xmit_more = false; packet->xmit_more = false;
if (packet->page_buf_cnt) { if (packet->page_buf_cnt) {
pgbuf = packet->cp_partial ? packet->page_buf + pgbuf = packet->cp_partial ? (*pb) +
packet->rmsg_pgcnt : packet->page_buf; packet->rmsg_pgcnt : (*pb);
ret = vmbus_sendpacket_pagebuffer_ctl(out_channel, ret = vmbus_sendpacket_pagebuffer_ctl(out_channel,
pgbuf, pgbuf,
packet->page_buf_cnt, packet->page_buf_cnt,
...@@ -838,7 +840,8 @@ static inline int netvsc_send_pkt( ...@@ -838,7 +840,8 @@ static inline int netvsc_send_pkt(
int netvsc_send(struct hv_device *device, int netvsc_send(struct hv_device *device,
struct hv_netvsc_packet *packet, struct hv_netvsc_packet *packet,
struct rndis_message *rndis_msg) struct rndis_message *rndis_msg,
struct hv_page_buffer **pb)
{ {
struct netvsc_device *net_device; struct netvsc_device *net_device;
int ret = 0, m_ret = 0; int ret = 0, m_ret = 0;
...@@ -891,7 +894,7 @@ int netvsc_send(struct hv_device *device, ...@@ -891,7 +894,7 @@ int netvsc_send(struct hv_device *device,
if (section_index != NETVSC_INVALID_INDEX) { if (section_index != NETVSC_INVALID_INDEX) {
netvsc_copy_to_send_buf(net_device, netvsc_copy_to_send_buf(net_device,
section_index, msd_len, section_index, msd_len,
packet, rndis_msg); packet, rndis_msg, pb);
packet->send_buf_index = section_index; packet->send_buf_index = section_index;
...@@ -922,7 +925,7 @@ int netvsc_send(struct hv_device *device, ...@@ -922,7 +925,7 @@ int netvsc_send(struct hv_device *device,
} }
if (msd_send) { if (msd_send) {
m_ret = netvsc_send_pkt(msd_send, net_device); m_ret = netvsc_send_pkt(msd_send, net_device, pb);
if (m_ret != 0) { if (m_ret != 0) {
netvsc_free_send_slot(net_device, netvsc_free_send_slot(net_device,
...@@ -932,7 +935,7 @@ int netvsc_send(struct hv_device *device, ...@@ -932,7 +935,7 @@ int netvsc_send(struct hv_device *device,
} }
if (cur_send) if (cur_send)
ret = netvsc_send_pkt(cur_send, net_device); ret = netvsc_send_pkt(cur_send, net_device, pb);
if (ret != 0 && section_index != NETVSC_INVALID_INDEX) if (ret != 0 && section_index != NETVSC_INVALID_INDEX)
netvsc_free_send_slot(net_device, section_index); netvsc_free_send_slot(net_device, section_index);
......
...@@ -324,9 +324,10 @@ static u32 fill_pg_buf(struct page *page, u32 offset, u32 len, ...@@ -324,9 +324,10 @@ static u32 fill_pg_buf(struct page *page, u32 offset, u32 len,
} }
static u32 init_page_array(void *hdr, u32 len, struct sk_buff *skb, static u32 init_page_array(void *hdr, u32 len, struct sk_buff *skb,
struct hv_netvsc_packet *packet) struct hv_netvsc_packet *packet,
struct hv_page_buffer **page_buf)
{ {
struct hv_page_buffer *pb = packet->page_buf; struct hv_page_buffer *pb = *page_buf;
u32 slots_used = 0; u32 slots_used = 0;
char *data = skb->data; char *data = skb->data;
int frags = skb_shinfo(skb)->nr_frags; int frags = skb_shinfo(skb)->nr_frags;
...@@ -437,6 +438,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) ...@@ -437,6 +438,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
u32 hash; u32 hash;
u32 skb_length; u32 skb_length;
struct hv_page_buffer page_buf[MAX_PAGE_BUFFER_COUNT]; struct hv_page_buffer page_buf[MAX_PAGE_BUFFER_COUNT];
struct hv_page_buffer *pb = page_buf;
struct netvsc_stats *tx_stats = this_cpu_ptr(net_device_ctx->tx_stats); struct netvsc_stats *tx_stats = this_cpu_ptr(net_device_ctx->tx_stats);
/* We will atmost need two pages to describe the rndis /* We will atmost need two pages to describe the rndis
...@@ -483,7 +485,6 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) ...@@ -483,7 +485,6 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
packet->xmit_more = skb->xmit_more; packet->xmit_more = skb->xmit_more;
packet->vlan_tci = skb->vlan_tci; packet->vlan_tci = skb->vlan_tci;
packet->page_buf = page_buf;
packet->q_idx = skb_get_queue_mapping(skb); packet->q_idx = skb_get_queue_mapping(skb);
...@@ -622,9 +623,9 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) ...@@ -622,9 +623,9 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
rndis_msg->msg_len += rndis_msg_size; rndis_msg->msg_len += rndis_msg_size;
packet->total_data_buflen = rndis_msg->msg_len; packet->total_data_buflen = rndis_msg->msg_len;
packet->page_buf_cnt = init_page_array(rndis_msg, rndis_msg_size, packet->page_buf_cnt = init_page_array(rndis_msg, rndis_msg_size,
skb, packet); skb, packet, &pb);
ret = netvsc_send(net_device_ctx->device_ctx, packet, rndis_msg); ret = netvsc_send(net_device_ctx->device_ctx, packet, rndis_msg, &pb);
drop: drop:
if (ret == 0) { if (ret == 0) {
......
...@@ -210,6 +210,7 @@ static int rndis_filter_send_request(struct rndis_device *dev, ...@@ -210,6 +210,7 @@ static int rndis_filter_send_request(struct rndis_device *dev,
int ret; int ret;
struct hv_netvsc_packet *packet; struct hv_netvsc_packet *packet;
struct hv_page_buffer page_buf[2]; struct hv_page_buffer page_buf[2];
struct hv_page_buffer *pb = page_buf;
/* Setup the packet to send it */ /* Setup the packet to send it */
packet = &req->pkt; packet = &req->pkt;
...@@ -217,30 +218,29 @@ static int rndis_filter_send_request(struct rndis_device *dev, ...@@ -217,30 +218,29 @@ static int rndis_filter_send_request(struct rndis_device *dev,
packet->is_data_pkt = false; packet->is_data_pkt = false;
packet->total_data_buflen = req->request_msg.msg_len; packet->total_data_buflen = req->request_msg.msg_len;
packet->page_buf_cnt = 1; packet->page_buf_cnt = 1;
packet->page_buf = page_buf;
packet->page_buf[0].pfn = virt_to_phys(&req->request_msg) >> pb[0].pfn = virt_to_phys(&req->request_msg) >>
PAGE_SHIFT; PAGE_SHIFT;
packet->page_buf[0].len = req->request_msg.msg_len; pb[0].len = req->request_msg.msg_len;
packet->page_buf[0].offset = pb[0].offset =
(unsigned long)&req->request_msg & (PAGE_SIZE - 1); (unsigned long)&req->request_msg & (PAGE_SIZE - 1);
/* Add one page_buf when request_msg crossing page boundary */ /* Add one page_buf when request_msg crossing page boundary */
if (packet->page_buf[0].offset + packet->page_buf[0].len > PAGE_SIZE) { if (pb[0].offset + pb[0].len > PAGE_SIZE) {
packet->page_buf_cnt++; packet->page_buf_cnt++;
packet->page_buf[0].len = PAGE_SIZE - pb[0].len = PAGE_SIZE -
packet->page_buf[0].offset; pb[0].offset;
packet->page_buf[1].pfn = virt_to_phys((void *)&req->request_msg pb[1].pfn = virt_to_phys((void *)&req->request_msg
+ packet->page_buf[0].len) >> PAGE_SHIFT; + pb[0].len) >> PAGE_SHIFT;
packet->page_buf[1].offset = 0; pb[1].offset = 0;
packet->page_buf[1].len = req->request_msg.msg_len - pb[1].len = req->request_msg.msg_len -
packet->page_buf[0].len; pb[0].len;
} }
packet->completion_func = 0; packet->completion_func = 0;
packet->xmit_more = false; packet->xmit_more = false;
ret = netvsc_send(dev->net_dev->dev, packet, NULL); ret = netvsc_send(dev->net_dev->dev, packet, NULL, &pb);
return ret; return ret;
} }
......
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