Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from alexngmsft/master
Browse files Browse the repository at this point in the history
Merge master into 4.2.3
  • Loading branch information
Alex Ng authored Aug 8, 2017
2 parents 708fd18 + 9013db7 commit e972f48
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
3 changes: 2 additions & 1 deletion hv-rhel7.x/hv/hyperv_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,8 @@ struct netvsc_device {
u32 max_chn;
u32 num_chn;

refcount_t sc_offered;
atomic_t open_chn;
wait_queue_head_t subchan_open;

struct rndis_device *extension;

Expand Down
28 changes: 14 additions & 14 deletions hv-rhel7.x/hv/netvsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ static struct netvsc_device *alloc_net_device(void)
net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
init_completion(&net_device->channel_init_wait);
init_waitqueue_head(&net_device->subchan_open);

return net_device;
}
Expand Down Expand Up @@ -757,8 +758,10 @@ static inline int netvsc_send_pkt(
struct sk_buff *skb)
{
struct nvsp_message nvmsg;
struct netvsc_channel *nvchan
= &net_device->chan_table[packet->q_idx];
struct nvsp_1_message_send_rndis_packet * const rpkt =
&nvmsg.msg.v1_msg.send_rndis_pkt;
struct netvsc_channel * const nvchan =
&net_device->chan_table[packet->q_idx];
struct vmbus_channel *out_channel = nvchan->channel;
struct net_device *ndev = hv_get_drvdata(device);
struct netdev_queue *txq = netdev_get_tx_queue(ndev, packet->q_idx);
Expand All @@ -767,21 +770,16 @@ static inline int netvsc_send_pkt(
u32 ring_avail = hv_ringbuf_avail_percent(&out_channel->outbound);

nvmsg.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT;
if (skb != NULL) {
/* 0 is RMC_DATA; */
nvmsg.msg.v1_msg.send_rndis_pkt.channel_type = 0;
} else {
/* 1 is RMC_CONTROL; */
nvmsg.msg.v1_msg.send_rndis_pkt.channel_type = 1;
}
if (skb)
rpkt->channel_type = 0; /* 0 is RMC_DATA */
else
rpkt->channel_type = 1; /* 1 is RMC_CONTROL */

nvmsg.msg.v1_msg.send_rndis_pkt.send_buf_section_index =
packet->send_buf_index;
rpkt->send_buf_section_index = packet->send_buf_index;
if (packet->send_buf_index == NETVSC_INVALID_INDEX)
nvmsg.msg.v1_msg.send_rndis_pkt.send_buf_section_size = 0;
rpkt->send_buf_section_size = 0;
else
nvmsg.msg.v1_msg.send_rndis_pkt.send_buf_section_size =
packet->total_data_buflen;
rpkt->send_buf_section_size = packet->total_data_buflen;

req_id = (ulong)skb;

Expand Down Expand Up @@ -1277,6 +1275,8 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,

nvchan->channel = device->channel;
nvchan->net_device = net_device;
u64_stats_init(&nvchan->tx_stats.syncp);
u64_stats_init(&nvchan->rx_stats.syncp);
}

/* Enable NAPI handler before init callbacks */
Expand Down
12 changes: 10 additions & 2 deletions hv-rhel7.x/hv/netvsc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,11 @@ static void netvsc_vf_setup(struct work_struct *w)
struct net_device *ndev = hv_get_drvdata(ndev_ctx->device_ctx);
struct net_device *vf_netdev;

rtnl_lock();
if (!rtnl_trylock()) {
schedule_work(w);
return;
}

vf_netdev = rtnl_dereference(ndev_ctx->vf_netdev);
if (vf_netdev)
__netvsc_vf_setup(ndev, vf_netdev);
Expand Down Expand Up @@ -1746,7 +1750,11 @@ static void netvsc_vf_update(struct work_struct *w)
struct net_device *vf_netdev;
bool vf_is_up;

rtnl_lock();
if (!rtnl_trylock()) {
schedule_work(w);
return;
}

vf_netdev = rtnl_dereference(ndev_ctx->vf_netdev);
if (!vf_netdev)
goto unlock;
Expand Down
14 changes: 8 additions & 6 deletions hv-rhel7.x/hv/rndis_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,8 +1055,8 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
else
netif_napi_del(&nvchan->napi);

if (refcount_dec_and_test(&nvscdev->sc_offered))
complete(&nvscdev->channel_init_wait);
atomic_inc(&nvscdev->open_chn);
wake_up(&nvscdev->subchan_open);
}

struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
Expand Down Expand Up @@ -1096,8 +1096,6 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
net_device->max_chn = 1;
net_device->num_chn = 1;

refcount_set(&net_device->sc_offered, 0);

net_device->extension = rndis_device;
rndis_device->ndev = net;

Expand Down Expand Up @@ -1221,6 +1219,7 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
rndis_device->ind_table[i] = ethtool_rxfh_indir_default(i,
net_device->num_chn);

atomic_set(&net_device->open_chn, 1);
num_rss_qs = net_device->num_chn - 1;
if (num_rss_qs == 0)
return net_device;
Expand All @@ -1234,7 +1233,6 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
}
}

refcount_set(&net_device->sc_offered, num_rss_qs);
vmbus_set_sc_create_callback(dev->channel, netvsc_sc_open);

init_packet = &net_device->channel_init_pkt;
Expand All @@ -1251,15 +1249,19 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
if (ret)
goto out;

wait_for_completion(&net_device->channel_init_wait);
if (init_packet->msg.v5_msg.subchn_comp.status != NVSP_STAT_SUCCESS) {
ret = -ENODEV;
goto out;
}
wait_for_completion(&net_device->channel_init_wait);

net_device->num_chn = 1 +
init_packet->msg.v5_msg.subchn_comp.num_subchannels;

/* wait for all sub channels to open */
wait_event(net_device->subchan_open,
atomic_read(&net_device->open_chn) == net_device->num_chn);

/* ignore failues from setting rss parameters, still have channels */
rndis_filter_set_rss_param(rndis_device, netvsc_hash_key,
net_device->num_chn);
Expand Down

0 comments on commit e972f48

Please sign in to comment.