Commit 0b307ebd authored by stephen hemminger's avatar stephen hemminger Committed by David S. Miller

netvsc: remove no longer needed receive staging buffers

The ring buffer mapping now handles the wraparound case
inside get_next_pkt_raw. Therefore it is not necessary to have an
additional special receive staging buffer.

See commit 1562edaed8c164ca5199 ("Drivers: hv: ring_buffer: count on
wrap around mappings")
Signed-off-by: default avatarStephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f2ceab0b
...@@ -748,11 +748,6 @@ struct netvsc_device { ...@@ -748,11 +748,6 @@ struct netvsc_device {
int ring_size; int ring_size;
/* The primary channel callback buffer */
unsigned char *cb_buffer;
/* The sub channel callback buffer */
unsigned char *sub_cb_buf;
struct multi_send_data msd[VRSS_CHANNEL_MAX]; struct multi_send_data msd[VRSS_CHANNEL_MAX];
u32 max_pkt; /* max number of pkt in one send, e.g. 8 */ u32 max_pkt; /* max number of pkt in one send, e.g. 8 */
u32 pkt_align; /* alignment bytes, e.g. 8 */ u32 pkt_align; /* alignment bytes, e.g. 8 */
......
...@@ -67,12 +67,6 @@ static struct netvsc_device *alloc_net_device(void) ...@@ -67,12 +67,6 @@ static struct netvsc_device *alloc_net_device(void)
if (!net_device) if (!net_device)
return NULL; return NULL;
net_device->cb_buffer = kzalloc(NETVSC_PACKET_SIZE, GFP_KERNEL);
if (!net_device->cb_buffer) {
kfree(net_device);
return NULL;
}
net_device->mrc[0].buf = vzalloc(NETVSC_RECVSLOT_MAX * net_device->mrc[0].buf = vzalloc(NETVSC_RECVSLOT_MAX *
sizeof(struct recv_comp_data)); sizeof(struct recv_comp_data));
...@@ -93,7 +87,6 @@ static void free_netvsc_device(struct netvsc_device *nvdev) ...@@ -93,7 +87,6 @@ static void free_netvsc_device(struct netvsc_device *nvdev)
for (i = 0; i < VRSS_CHANNEL_MAX; i++) for (i = 0; i < VRSS_CHANNEL_MAX; i++)
vfree(nvdev->mrc[i].buf); vfree(nvdev->mrc[i].buf);
kfree(nvdev->cb_buffer);
kfree(nvdev); kfree(nvdev);
} }
...@@ -584,7 +577,6 @@ void netvsc_device_remove(struct hv_device *device) ...@@ -584,7 +577,6 @@ void netvsc_device_remove(struct hv_device *device)
vmbus_close(device->channel); vmbus_close(device->channel);
/* Release all resources */ /* Release all resources */
vfree(net_device->sub_cb_buf);
free_netvsc_device(net_device); free_netvsc_device(net_device);
} }
...@@ -1271,16 +1263,11 @@ static void netvsc_process_raw_pkt(struct hv_device *device, ...@@ -1271,16 +1263,11 @@ static void netvsc_process_raw_pkt(struct hv_device *device,
void netvsc_channel_cb(void *context) void netvsc_channel_cb(void *context)
{ {
int ret; struct vmbus_channel *channel = context;
struct vmbus_channel *channel = (struct vmbus_channel *)context;
u16 q_idx = channel->offermsg.offer.sub_channel_index; u16 q_idx = channel->offermsg.offer.sub_channel_index;
struct hv_device *device; struct hv_device *device;
struct netvsc_device *net_device; struct netvsc_device *net_device;
u32 bytes_recvd;
u64 request_id;
struct vmpacket_descriptor *desc; struct vmpacket_descriptor *desc;
unsigned char *buffer;
int bufferlen = NETVSC_PACKET_SIZE;
struct net_device *ndev; struct net_device *ndev;
bool need_to_commit = false; bool need_to_commit = false;
...@@ -1292,65 +1279,19 @@ void netvsc_channel_cb(void *context) ...@@ -1292,65 +1279,19 @@ void netvsc_channel_cb(void *context)
net_device = get_inbound_net_device(device); net_device = get_inbound_net_device(device);
if (!net_device) if (!net_device)
return; return;
ndev = hv_get_drvdata(device); ndev = hv_get_drvdata(device);
buffer = get_per_channel_state(channel);
do {
desc = get_next_pkt_raw(channel);
if (desc != NULL) {
netvsc_process_raw_pkt(device,
channel,
net_device,
ndev,
desc->trans_id,
desc);
put_pkt_raw(channel, desc);
need_to_commit = true;
continue;
}
if (need_to_commit) {
need_to_commit = false;
commit_rd_index(channel);
}
ret = vmbus_recvpacket_raw(channel, buffer, bufferlen, while ((desc = get_next_pkt_raw(channel)) != NULL) {
&bytes_recvd, &request_id); netvsc_process_raw_pkt(device, channel, net_device,
if (ret == 0) { ndev, desc->trans_id, desc);
if (bytes_recvd > 0) {
desc = (struct vmpacket_descriptor *)buffer;
netvsc_process_raw_pkt(device,
channel,
net_device,
ndev,
request_id,
desc);
} else {
/*
* We are done for this pass.
*/
break;
}
} else if (ret == -ENOBUFS) {
if (bufferlen > NETVSC_PACKET_SIZE)
kfree(buffer);
/* Handle large packet */
buffer = kmalloc(bytes_recvd, GFP_ATOMIC);
if (buffer == NULL) {
/* Try again next time around */
netdev_err(ndev,
"unable to allocate buffer of size "
"(%d)!!\n", bytes_recvd);
break;
}
bufferlen = bytes_recvd;
}
} while (1);
if (bufferlen > NETVSC_PACKET_SIZE) put_pkt_raw(channel, desc);
kfree(buffer); need_to_commit = true;
}
if (need_to_commit)
commit_rd_index(channel);
netvsc_chk_recv_comp(net_device, channel, q_idx); netvsc_chk_recv_comp(net_device, channel, q_idx);
} }
...@@ -1374,8 +1315,6 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) ...@@ -1374,8 +1315,6 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
net_device->ring_size = ring_size; net_device->ring_size = ring_size;
set_per_channel_state(device->channel, net_device->cb_buffer);
/* Open the channel */ /* Open the channel */
ret = vmbus_open(device->channel, ring_size * PAGE_SIZE, ret = vmbus_open(device->channel, ring_size * PAGE_SIZE,
ring_size * PAGE_SIZE, NULL, 0, ring_size * PAGE_SIZE, NULL, 0,
......
...@@ -948,9 +948,6 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc) ...@@ -948,9 +948,6 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
if (chn_index >= nvscdev->num_chn) if (chn_index >= nvscdev->num_chn)
return; return;
set_per_channel_state(new_sc, nvscdev->sub_cb_buf + (chn_index - 1) *
NETVSC_PACKET_SIZE);
nvscdev->mrc[chn_index].buf = vzalloc(NETVSC_RECVSLOT_MAX * nvscdev->mrc[chn_index].buf = vzalloc(NETVSC_RECVSLOT_MAX *
sizeof(struct recv_comp_data)); sizeof(struct recv_comp_data));
...@@ -1099,14 +1096,6 @@ int rndis_filter_device_add(struct hv_device *dev, ...@@ -1099,14 +1096,6 @@ int rndis_filter_device_add(struct hv_device *dev,
if (net_device->num_chn == 1) if (net_device->num_chn == 1)
goto out; goto out;
net_device->sub_cb_buf = vzalloc((net_device->num_chn - 1) *
NETVSC_PACKET_SIZE);
if (!net_device->sub_cb_buf) {
net_device->num_chn = 1;
dev_info(&dev->device, "No memory for subchannels.\n");
goto out;
}
vmbus_set_sc_create_callback(dev->channel, netvsc_sc_open); vmbus_set_sc_create_callback(dev->channel, netvsc_sc_open);
init_packet = &net_device->channel_init_pkt; init_packet = &net_device->channel_init_pkt;
......
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