Commit 6b1f8376 authored by Long Li's avatar Long Li Committed by Martin K. Petersen

scsi: netvsc: Use the vmbus function to calculate ring buffer percentage

In Vmbus, we have defined a function to calculate available ring buffer
percentage to write.

Use that function and remove netvsc's private version.

[mkp: typo]
Signed-off-by: default avatarLong Li <longli@microsoft.com>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 63273cb4
...@@ -189,7 +189,6 @@ struct netvsc_device; ...@@ -189,7 +189,6 @@ struct netvsc_device;
struct net_device_context; struct net_device_context;
extern u32 netvsc_ring_bytes; extern u32 netvsc_ring_bytes;
extern struct reciprocal_value netvsc_ring_reciprocal;
struct netvsc_device *netvsc_device_add(struct hv_device *device, struct netvsc_device *netvsc_device_add(struct hv_device *device,
const struct netvsc_device_info *info); const struct netvsc_device_info *info);
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/prefetch.h> #include <linux/prefetch.h>
#include <linux/reciprocal_div.h>
#include <asm/sync_bitops.h> #include <asm/sync_bitops.h>
...@@ -634,17 +633,6 @@ void netvsc_device_remove(struct hv_device *device) ...@@ -634,17 +633,6 @@ void netvsc_device_remove(struct hv_device *device)
#define RING_AVAIL_PERCENT_HIWATER 20 #define RING_AVAIL_PERCENT_HIWATER 20
#define RING_AVAIL_PERCENT_LOWATER 10 #define RING_AVAIL_PERCENT_LOWATER 10
/*
* Get the percentage of available bytes to write in the ring.
* The return value is in range from 0 to 100.
*/
static u32 hv_ringbuf_avail_percent(const struct hv_ring_buffer_info *ring_info)
{
u32 avail_write = hv_get_bytes_to_write(ring_info);
return reciprocal_divide(avail_write * 100, netvsc_ring_reciprocal);
}
static inline void netvsc_free_send_slot(struct netvsc_device *net_device, static inline void netvsc_free_send_slot(struct netvsc_device *net_device,
u32 index) u32 index)
{ {
...@@ -696,8 +684,8 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device, ...@@ -696,8 +684,8 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device,
struct netdev_queue *txq = netdev_get_tx_queue(ndev, q_idx); struct netdev_queue *txq = netdev_get_tx_queue(ndev, q_idx);
if (netif_tx_queue_stopped(txq) && if (netif_tx_queue_stopped(txq) &&
(hv_ringbuf_avail_percent(&channel->outbound) > RING_AVAIL_PERCENT_HIWATER || (hv_get_avail_to_write_percent(&channel->outbound) >
queue_sends < 1)) { RING_AVAIL_PERCENT_HIWATER || queue_sends < 1)) {
netif_tx_wake_queue(txq); netif_tx_wake_queue(txq);
ndev_ctx->eth_stats.wake_queue++; ndev_ctx->eth_stats.wake_queue++;
} }
...@@ -805,7 +793,7 @@ static inline int netvsc_send_pkt( ...@@ -805,7 +793,7 @@ static inline int netvsc_send_pkt(
struct netdev_queue *txq = netdev_get_tx_queue(ndev, packet->q_idx); struct netdev_queue *txq = netdev_get_tx_queue(ndev, packet->q_idx);
u64 req_id; u64 req_id;
int ret; int ret;
u32 ring_avail = hv_ringbuf_avail_percent(&out_channel->outbound); u32 ring_avail = hv_get_avail_to_write_percent(&out_channel->outbound);
nvmsg.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT; nvmsg.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT;
if (skb) if (skb)
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/netpoll.h> #include <linux/netpoll.h>
#include <linux/reciprocal_div.h>
#include <net/arp.h> #include <net/arp.h>
#include <net/route.h> #include <net/route.h>
...@@ -58,7 +57,6 @@ static unsigned int ring_size __ro_after_init = 128; ...@@ -58,7 +57,6 @@ static unsigned int ring_size __ro_after_init = 128;
module_param(ring_size, uint, 0444); module_param(ring_size, uint, 0444);
MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)"); MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
unsigned int netvsc_ring_bytes __ro_after_init; unsigned int netvsc_ring_bytes __ro_after_init;
struct reciprocal_value netvsc_ring_reciprocal __ro_after_init;
static const u32 default_msg = NETIF_MSG_DRV | NETIF_MSG_PROBE | static const u32 default_msg = NETIF_MSG_DRV | NETIF_MSG_PROBE |
NETIF_MSG_LINK | NETIF_MSG_IFUP | NETIF_MSG_LINK | NETIF_MSG_IFUP |
...@@ -2218,7 +2216,6 @@ static int __init netvsc_drv_init(void) ...@@ -2218,7 +2216,6 @@ static int __init netvsc_drv_init(void)
ring_size); ring_size);
} }
netvsc_ring_bytes = ring_size * PAGE_SIZE; netvsc_ring_bytes = ring_size * PAGE_SIZE;
netvsc_ring_reciprocal = reciprocal_value(netvsc_ring_bytes);
ret = vmbus_driver_register(&netvsc_drv); ret = vmbus_driver_register(&netvsc_drv);
if (ret) if (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