Skip to content

Commit

Permalink
netvsc: optimize receive completions
Browse files Browse the repository at this point in the history
Optimize how receive completion ring are managed.
   * Allocate only as many slots as needed for all buffers from host
   * Allocate before setting up sub channel for better error detection
   * Don't need to keep copy of initial receive section message
   * Precompute the watermark for when receive flushing is needed
   * Replace division with conditional test
   * Replace atomic per-device variable with per-channel check.
   * Handle corner case where receive completion send
     fails if ring buffer to host is full.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
shemminger authored and davem330 committed Jul 29, 2017
1 parent 02b6de0 commit 7426b1a
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 175 deletions.
14 changes: 5 additions & 9 deletions drivers/net/hyperv/hyperv_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ struct net_device_context;

struct netvsc_device *netvsc_device_add(struct hv_device *device,
const struct netvsc_device_info *info);
int netvsc_alloc_recv_comp_ring(struct netvsc_device *net_device, u32 q_idx);
void netvsc_device_remove(struct hv_device *device);
int netvsc_send(struct net_device_context *ndc,
struct hv_netvsc_packet *packet,
Expand Down Expand Up @@ -657,13 +658,10 @@ struct recv_comp_data {
u32 status;
};

/* Netvsc Receive Slots Max */
#define NETVSC_RECVSLOT_MAX (NETVSC_RECEIVE_BUFFER_SIZE / ETH_DATA_LEN + 1)

struct multi_recv_comp {
void *buf; /* queued receive completions */
u32 first; /* first data entry */
u32 next; /* next entry for writing */
struct recv_comp_data *slots;
u32 first; /* first data entry */
u32 next; /* next entry for writing */
};

struct netvsc_stats {
Expand Down Expand Up @@ -750,7 +748,7 @@ struct netvsc_device {
u32 recv_buf_size;
u32 recv_buf_gpadl_handle;
u32 recv_section_cnt;
struct nvsp_1_receive_buffer_section *recv_section;
u32 recv_completion_cnt;

/* Send buffer allocated by us */
void *send_buf;
Expand Down Expand Up @@ -778,8 +776,6 @@ struct netvsc_device {
u32 max_pkt; /* max number of pkt in one send, e.g. 8 */
u32 pkt_align; /* alignment bytes, e.g. 8 */

atomic_t num_outstanding_recvs;

atomic_t open_cnt;

struct netvsc_channel chan_table[VRSS_CHANNEL_MAX];
Expand Down
Loading

0 comments on commit 7426b1a

Please sign in to comment.