Commit fe21b269 authored by David S. Miller's avatar David S. Miller

Merge branch 'netvsc-minor-fixes-and-optimization'

Stephen Hemminger says:

====================
netvsc: minor fixes and optimization

This is a subset of earlier submission with a few more fixes
found during testing. The are two small optimizations, one is to
better manage the receive completion ring, and the other is removing
one unneeded level of indirection.

Will submit the improved VF support and buffer sizing in a later
patch so they get more review.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents a847135a f4e40363
...@@ -186,11 +186,12 @@ struct net_device_context; ...@@ -186,11 +186,12 @@ struct net_device_context;
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);
int netvsc_alloc_recv_comp_ring(struct netvsc_device *net_device, u32 q_idx);
void netvsc_device_remove(struct hv_device *device); void netvsc_device_remove(struct hv_device *device);
int netvsc_send(struct net_device_context *ndc, int netvsc_send(struct net_device_context *ndc,
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, struct hv_page_buffer *page_buffer,
struct sk_buff *skb); struct sk_buff *skb);
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);
...@@ -217,7 +218,8 @@ int rndis_filter_receive(struct net_device *ndev, ...@@ -217,7 +218,8 @@ int rndis_filter_receive(struct net_device *ndev,
struct vmbus_channel *channel, struct vmbus_channel *channel,
void *data, u32 buflen); void *data, u32 buflen);
int rndis_filter_set_device_mac(struct net_device *ndev, char *mac); int rndis_filter_set_device_mac(struct netvsc_device *ndev,
const char *mac);
void netvsc_switch_datapath(struct net_device *nv_dev, bool vf); void netvsc_switch_datapath(struct net_device *nv_dev, bool vf);
...@@ -656,11 +658,8 @@ struct recv_comp_data { ...@@ -656,11 +658,8 @@ struct recv_comp_data {
u32 status; u32 status;
}; };
/* Netvsc Receive Slots Max */
#define NETVSC_RECVSLOT_MAX (NETVSC_RECEIVE_BUFFER_SIZE / ETH_DATA_LEN + 1)
struct multi_recv_comp { struct multi_recv_comp {
void *buf; /* queued receive completions */ struct recv_comp_data *slots;
u32 first; /* first data entry */ u32 first; /* first data entry */
u32 next; /* next entry for writing */ u32 next; /* next entry for writing */
}; };
...@@ -749,7 +748,7 @@ struct netvsc_device { ...@@ -749,7 +748,7 @@ struct netvsc_device {
u32 recv_buf_size; u32 recv_buf_size;
u32 recv_buf_gpadl_handle; u32 recv_buf_gpadl_handle;
u32 recv_section_cnt; u32 recv_section_cnt;
struct nvsp_1_receive_buffer_section *recv_section; u32 recv_completion_cnt;
/* Send buffer allocated by us */ /* Send buffer allocated by us */
void *send_buf; void *send_buf;
...@@ -777,8 +776,6 @@ struct netvsc_device { ...@@ -777,8 +776,6 @@ struct netvsc_device {
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 */
atomic_t num_outstanding_recvs;
atomic_t open_cnt; atomic_t open_cnt;
struct netvsc_channel chan_table[VRSS_CHANNEL_MAX]; struct netvsc_channel chan_table[VRSS_CHANNEL_MAX];
......
This diff is collapsed.
...@@ -282,9 +282,8 @@ static u32 fill_pg_buf(struct page *page, u32 offset, u32 len, ...@@ -282,9 +282,8 @@ 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)
{ {
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;
...@@ -359,8 +358,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) ...@@ -359,8 +358,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
u32 rndis_msg_size; u32 rndis_msg_size;
struct rndis_per_packet_info *ppi; struct rndis_per_packet_info *ppi;
u32 hash; u32 hash;
struct hv_page_buffer page_buf[MAX_PAGE_BUFFER_COUNT]; struct hv_page_buffer pb[MAX_PAGE_BUFFER_COUNT];
struct hv_page_buffer *pb = page_buf;
/* We can only transmit MAX_PAGE_BUFFER_COUNT number /* We can only transmit MAX_PAGE_BUFFER_COUNT number
* of pages in a single packet. If skb is scattered around * of pages in a single packet. If skb is scattered around
...@@ -503,12 +501,12 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) ...@@ -503,12 +501,12 @@ 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, &pb); skb, packet, pb);
/* timestamp packet in software */ /* timestamp packet in software */
skb_tx_timestamp(skb); skb_tx_timestamp(skb);
ret = netvsc_send(net_device_ctx, packet, rndis_msg, &pb, skb); ret = netvsc_send(net_device_ctx, packet, rndis_msg, pb, skb);
if (likely(ret == 0)) if (likely(ret == 0))
return NETDEV_TX_OK; return NETDEV_TX_OK;
...@@ -758,8 +756,8 @@ static int netvsc_set_channels(struct net_device *net, ...@@ -758,8 +756,8 @@ static int netvsc_set_channels(struct net_device *net,
if (!IS_ERR(nvdev)) { if (!IS_ERR(nvdev)) {
netif_set_real_num_tx_queues(net, nvdev->num_chn); netif_set_real_num_tx_queues(net, nvdev->num_chn);
netif_set_real_num_rx_queues(net, nvdev->num_chn); netif_set_real_num_rx_queues(net, nvdev->num_chn);
ret = PTR_ERR(nvdev);
} else { } else {
ret = PTR_ERR(nvdev);
device_info.num_chn = orig; device_info.num_chn = orig;
rndis_filter_device_add(dev, &device_info); rndis_filter_device_add(dev, &device_info);
} }
...@@ -923,6 +921,8 @@ static void netvsc_get_stats64(struct net_device *net, ...@@ -923,6 +921,8 @@ static void netvsc_get_stats64(struct net_device *net,
static int netvsc_set_mac_addr(struct net_device *ndev, void *p) static int netvsc_set_mac_addr(struct net_device *ndev, void *p)
{ {
struct net_device_context *ndc = netdev_priv(ndev);
struct netvsc_device *nvdev = rtnl_dereference(ndc->nvdev);
struct sockaddr *addr = p; struct sockaddr *addr = p;
char save_adr[ETH_ALEN]; char save_adr[ETH_ALEN];
unsigned char save_aatype; unsigned char save_aatype;
...@@ -935,7 +935,10 @@ static int netvsc_set_mac_addr(struct net_device *ndev, void *p) ...@@ -935,7 +935,10 @@ static int netvsc_set_mac_addr(struct net_device *ndev, void *p)
if (err != 0) if (err != 0)
return err; return err;
err = rndis_filter_set_device_mac(ndev, addr->sa_data); if (!nvdev)
return -ENODEV;
err = rndis_filter_set_device_mac(nvdev, addr->sa_data);
if (err != 0) { if (err != 0) {
/* roll back to saved MAC */ /* roll back to saved MAC */
memcpy(ndev->dev_addr, save_adr, ETH_ALEN); memcpy(ndev->dev_addr, save_adr, ETH_ALEN);
...@@ -981,7 +984,7 @@ static void netvsc_get_ethtool_stats(struct net_device *dev, ...@@ -981,7 +984,7 @@ static void netvsc_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats, u64 *data) struct ethtool_stats *stats, u64 *data)
{ {
struct net_device_context *ndc = netdev_priv(dev); struct net_device_context *ndc = netdev_priv(dev);
struct netvsc_device *nvdev = rcu_dereference(ndc->nvdev); struct netvsc_device *nvdev = rtnl_dereference(ndc->nvdev);
const void *nds = &ndc->eth_stats; const void *nds = &ndc->eth_stats;
const struct netvsc_stats *qstats; const struct netvsc_stats *qstats;
unsigned int start; unsigned int start;
...@@ -1019,7 +1022,7 @@ static void netvsc_get_ethtool_stats(struct net_device *dev, ...@@ -1019,7 +1022,7 @@ static void netvsc_get_ethtool_stats(struct net_device *dev,
static void netvsc_get_strings(struct net_device *dev, u32 stringset, u8 *data) static void netvsc_get_strings(struct net_device *dev, u32 stringset, u8 *data)
{ {
struct net_device_context *ndc = netdev_priv(dev); struct net_device_context *ndc = netdev_priv(dev);
struct netvsc_device *nvdev = rcu_dereference(ndc->nvdev); struct netvsc_device *nvdev = rtnl_dereference(ndc->nvdev);
u8 *p = data; u8 *p = data;
int i; int i;
...@@ -1077,7 +1080,7 @@ netvsc_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info, ...@@ -1077,7 +1080,7 @@ netvsc_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
u32 *rules) u32 *rules)
{ {
struct net_device_context *ndc = netdev_priv(dev); struct net_device_context *ndc = netdev_priv(dev);
struct netvsc_device *nvdev = rcu_dereference(ndc->nvdev); struct netvsc_device *nvdev = rtnl_dereference(ndc->nvdev);
if (!nvdev) if (!nvdev)
return -ENODEV; return -ENODEV;
...@@ -1127,7 +1130,7 @@ static int netvsc_get_rxfh(struct net_device *dev, u32 *indir, u8 *key, ...@@ -1127,7 +1130,7 @@ static int netvsc_get_rxfh(struct net_device *dev, u32 *indir, u8 *key,
u8 *hfunc) u8 *hfunc)
{ {
struct net_device_context *ndc = netdev_priv(dev); struct net_device_context *ndc = netdev_priv(dev);
struct netvsc_device *ndev = rcu_dereference(ndc->nvdev); struct netvsc_device *ndev = rtnl_dereference(ndc->nvdev);
struct rndis_device *rndis_dev; struct rndis_device *rndis_dev;
int i; int i;
......
...@@ -85,14 +85,6 @@ static struct rndis_device *get_rndis_device(void) ...@@ -85,14 +85,6 @@ static struct rndis_device *get_rndis_device(void)
return device; return device;
} }
static struct netvsc_device *
net_device_to_netvsc_device(struct net_device *ndev)
{
struct net_device_context *net_device_ctx = netdev_priv(ndev);
return rtnl_dereference(net_device_ctx->nvdev);
}
static struct rndis_request *get_rndis_request(struct rndis_device *dev, static struct rndis_request *get_rndis_request(struct rndis_device *dev,
u32 msg_type, u32 msg_type,
u32 msg_len) u32 msg_len)
...@@ -222,11 +214,11 @@ static void dump_rndis_message(struct hv_device *hv_dev, ...@@ -222,11 +214,11 @@ static void dump_rndis_message(struct hv_device *hv_dev,
static int rndis_filter_send_request(struct rndis_device *dev, static int rndis_filter_send_request(struct rndis_device *dev,
struct rndis_request *req) struct rndis_request *req)
{ {
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; struct hv_page_buffer *pb = page_buf;
struct net_device_context *net_device_ctx = netdev_priv(dev->ndev); struct net_device_context *net_device_ctx = netdev_priv(dev->ndev);
int ret;
/* Setup the packet to send it */ /* Setup the packet to send it */
packet = &req->pkt; packet = &req->pkt;
...@@ -252,7 +244,10 @@ static int rndis_filter_send_request(struct rndis_device *dev, ...@@ -252,7 +244,10 @@ static int rndis_filter_send_request(struct rndis_device *dev,
pb[0].len; pb[0].len;
} }
ret = netvsc_send(net_device_ctx, packet, NULL, &pb, NULL); rcu_read_lock_bh();
ret = netvsc_send(net_device_ctx, packet, NULL, pb, NULL);
rcu_read_unlock_bh();
return ret; return ret;
} }
...@@ -452,8 +447,9 @@ int rndis_filter_receive(struct net_device *ndev, ...@@ -452,8 +447,9 @@ int rndis_filter_receive(struct net_device *ndev,
return 0; return 0;
} }
static int rndis_filter_query_device(struct rndis_device *dev, u32 oid, static int rndis_filter_query_device(struct rndis_device *dev,
void *result, u32 *result_size) struct netvsc_device *nvdev,
u32 oid, void *result, u32 *result_size)
{ {
struct rndis_request *request; struct rndis_request *request;
u32 inresult_size = *result_size; u32 inresult_size = *result_size;
...@@ -480,8 +476,6 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid, ...@@ -480,8 +476,6 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
query->dev_vc_handle = 0; query->dev_vc_handle = 0;
if (oid == OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES) { if (oid == OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES) {
struct net_device_context *ndevctx = netdev_priv(dev->ndev);
struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev);
struct ndis_offload *hwcaps; struct ndis_offload *hwcaps;
u32 nvsp_version = nvdev->nvsp_version; u32 nvsp_version = nvdev->nvsp_version;
u8 ndis_rev; u8 ndis_rev;
...@@ -550,14 +544,15 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid, ...@@ -550,14 +544,15 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
/* Get the hardware offload capabilities */ /* Get the hardware offload capabilities */
static int static int
rndis_query_hwcaps(struct rndis_device *dev, struct ndis_offload *caps) rndis_query_hwcaps(struct rndis_device *dev, struct netvsc_device *net_device,
struct ndis_offload *caps)
{ {
u32 caps_len = sizeof(*caps); u32 caps_len = sizeof(*caps);
int ret; int ret;
memset(caps, 0, sizeof(*caps)); memset(caps, 0, sizeof(*caps));
ret = rndis_filter_query_device(dev, ret = rndis_filter_query_device(dev, net_device,
OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES, OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES,
caps, &caps_len); caps, &caps_len);
if (ret) if (ret)
...@@ -586,11 +581,12 @@ rndis_query_hwcaps(struct rndis_device *dev, struct ndis_offload *caps) ...@@ -586,11 +581,12 @@ rndis_query_hwcaps(struct rndis_device *dev, struct ndis_offload *caps)
return 0; return 0;
} }
static int rndis_filter_query_device_mac(struct rndis_device *dev) static int rndis_filter_query_device_mac(struct rndis_device *dev,
struct netvsc_device *net_device)
{ {
u32 size = ETH_ALEN; u32 size = ETH_ALEN;
return rndis_filter_query_device(dev, return rndis_filter_query_device(dev, net_device,
RNDIS_OID_802_3_PERMANENT_ADDRESS, RNDIS_OID_802_3_PERMANENT_ADDRESS,
dev->hw_mac_adr, &size); dev->hw_mac_adr, &size);
} }
...@@ -598,9 +594,9 @@ static int rndis_filter_query_device_mac(struct rndis_device *dev) ...@@ -598,9 +594,9 @@ static int rndis_filter_query_device_mac(struct rndis_device *dev)
#define NWADR_STR "NetworkAddress" #define NWADR_STR "NetworkAddress"
#define NWADR_STRLEN 14 #define NWADR_STRLEN 14
int rndis_filter_set_device_mac(struct net_device *ndev, char *mac) int rndis_filter_set_device_mac(struct netvsc_device *nvdev,
const char *mac)
{ {
struct netvsc_device *nvdev = net_device_to_netvsc_device(ndev);
struct rndis_device *rdev = nvdev->extension; struct rndis_device *rdev = nvdev->extension;
struct rndis_request *request; struct rndis_request *request;
struct rndis_set_request *set; struct rndis_set_request *set;
...@@ -654,11 +650,8 @@ int rndis_filter_set_device_mac(struct net_device *ndev, char *mac) ...@@ -654,11 +650,8 @@ int rndis_filter_set_device_mac(struct net_device *ndev, char *mac)
wait_for_completion(&request->wait_event); wait_for_completion(&request->wait_event);
set_complete = &request->response_msg.msg.set_complete; set_complete = &request->response_msg.msg.set_complete;
if (set_complete->status != RNDIS_STATUS_SUCCESS) { if (set_complete->status != RNDIS_STATUS_SUCCESS)
netdev_err(ndev, "Fail to set MAC on host side:0x%x\n", ret = -EIO;
set_complete->status);
ret = -EINVAL;
}
cleanup: cleanup:
put_rndis_request(rdev, request); put_rndis_request(rdev, request);
...@@ -791,27 +784,27 @@ int rndis_filter_set_rss_param(struct rndis_device *rdev, ...@@ -791,27 +784,27 @@ int rndis_filter_set_rss_param(struct rndis_device *rdev,
return ret; return ret;
} }
static int rndis_filter_query_device_link_status(struct rndis_device *dev) static int rndis_filter_query_device_link_status(struct rndis_device *dev,
struct netvsc_device *net_device)
{ {
u32 size = sizeof(u32); u32 size = sizeof(u32);
u32 link_status; u32 link_status;
int ret;
ret = rndis_filter_query_device(dev, return rndis_filter_query_device(dev, net_device,
RNDIS_OID_GEN_MEDIA_CONNECT_STATUS, RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
&link_status, &size); &link_status, &size);
return ret;
} }
static int rndis_filter_query_link_speed(struct rndis_device *dev) static int rndis_filter_query_link_speed(struct rndis_device *dev,
struct netvsc_device *net_device)
{ {
u32 size = sizeof(u32); u32 size = sizeof(u32);
u32 link_speed; u32 link_speed;
struct net_device_context *ndc; struct net_device_context *ndc;
int ret; int ret;
ret = rndis_filter_query_device(dev, RNDIS_OID_GEN_LINK_SPEED, ret = rndis_filter_query_device(dev, net_device,
RNDIS_OID_GEN_LINK_SPEED,
&link_speed, &size); &link_speed, &size);
if (!ret) { if (!ret) {
...@@ -880,14 +873,14 @@ void rndis_filter_update(struct netvsc_device *nvdev) ...@@ -880,14 +873,14 @@ void rndis_filter_update(struct netvsc_device *nvdev)
schedule_work(&rdev->mcast_work); schedule_work(&rdev->mcast_work);
} }
static int rndis_filter_init_device(struct rndis_device *dev) static int rndis_filter_init_device(struct rndis_device *dev,
struct netvsc_device *nvdev)
{ {
struct rndis_request *request; struct rndis_request *request;
struct rndis_initialize_request *init; struct rndis_initialize_request *init;
struct rndis_initialize_complete *init_complete; struct rndis_initialize_complete *init_complete;
u32 status; u32 status;
int ret; int ret;
struct netvsc_device *nvdev = net_device_to_netvsc_device(dev->ndev);
request = get_rndis_request(dev, RNDIS_MSG_INIT, request = get_rndis_request(dev, RNDIS_MSG_INIT,
RNDIS_MESSAGE_SIZE(struct rndis_initialize_request)); RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
...@@ -935,12 +928,12 @@ static bool netvsc_device_idle(const struct netvsc_device *nvdev) ...@@ -935,12 +928,12 @@ static bool netvsc_device_idle(const struct netvsc_device *nvdev)
{ {
int i; int i;
if (atomic_read(&nvdev->num_outstanding_recvs) > 0)
return false;
for (i = 0; i < nvdev->num_chn; i++) { for (i = 0; i < nvdev->num_chn; i++) {
const struct netvsc_channel *nvchan = &nvdev->chan_table[i]; const struct netvsc_channel *nvchan = &nvdev->chan_table[i];
if (nvchan->mrc.first != nvchan->mrc.next)
return false;
if (atomic_read(&nvchan->queue_sends) > 0) if (atomic_read(&nvchan->queue_sends) > 0)
return false; return false;
} }
...@@ -1024,20 +1017,20 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc) ...@@ -1024,20 +1017,20 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
{ {
struct net_device *ndev = struct net_device *ndev =
hv_get_drvdata(new_sc->primary_channel->device_obj); hv_get_drvdata(new_sc->primary_channel->device_obj);
struct netvsc_device *nvscdev = net_device_to_netvsc_device(ndev); struct net_device_context *ndev_ctx = netdev_priv(ndev);
struct netvsc_device *nvscdev;
u16 chn_index = new_sc->offermsg.offer.sub_channel_index; u16 chn_index = new_sc->offermsg.offer.sub_channel_index;
struct netvsc_channel *nvchan; struct netvsc_channel *nvchan;
int ret; int ret;
if (chn_index >= nvscdev->num_chn) /* This is safe because this callback only happens when
* new device is being setup and waiting on the channel_init_wait.
*/
nvscdev = rcu_dereference_raw(ndev_ctx->nvdev);
if (!nvscdev || chn_index >= nvscdev->num_chn)
return; return;
nvchan = nvscdev->chan_table + chn_index; nvchan = nvscdev->chan_table + chn_index;
nvchan->mrc.buf
= vzalloc(NETVSC_RECVSLOT_MAX * sizeof(struct recv_comp_data));
if (!nvchan->mrc.buf)
return;
/* Because the device uses NAPI, all the interrupt batching and /* Because the device uses NAPI, all the interrupt batching and
* control is done via Net softirq, not the channel handling * control is done via Net softirq, not the channel handling
...@@ -1104,27 +1097,27 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, ...@@ -1104,27 +1097,27 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
rndis_device->ndev = net; rndis_device->ndev = net;
/* Send the rndis initialization message */ /* Send the rndis initialization message */
ret = rndis_filter_init_device(rndis_device); ret = rndis_filter_init_device(rndis_device, net_device);
if (ret != 0) if (ret != 0)
goto err_dev_remv; goto err_dev_remv;
/* Get the MTU from the host */ /* Get the MTU from the host */
size = sizeof(u32); size = sizeof(u32);
ret = rndis_filter_query_device(rndis_device, ret = rndis_filter_query_device(rndis_device, net_device,
RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE, RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE,
&mtu, &size); &mtu, &size);
if (ret == 0 && size == sizeof(u32) && mtu < net->mtu) if (ret == 0 && size == sizeof(u32) && mtu < net->mtu)
net->mtu = mtu; net->mtu = mtu;
/* Get the mac address */ /* Get the mac address */
ret = rndis_filter_query_device_mac(rndis_device); ret = rndis_filter_query_device_mac(rndis_device, net_device);
if (ret != 0) if (ret != 0)
goto err_dev_remv; goto err_dev_remv;
memcpy(device_info->mac_adr, rndis_device->hw_mac_adr, ETH_ALEN); memcpy(device_info->mac_adr, rndis_device->hw_mac_adr, ETH_ALEN);
/* Find HW offload capabilities */ /* Find HW offload capabilities */
ret = rndis_query_hwcaps(rndis_device, &hwcaps); ret = rndis_query_hwcaps(rndis_device, net_device, &hwcaps);
if (ret != 0) if (ret != 0)
goto err_dev_remv; goto err_dev_remv;
...@@ -1185,7 +1178,7 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, ...@@ -1185,7 +1178,7 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
if (ret) if (ret)
goto err_dev_remv; goto err_dev_remv;
rndis_filter_query_device_link_status(rndis_device); rndis_filter_query_device_link_status(rndis_device, net_device);
netdev_dbg(net, "Device MAC %pM link state %s\n", netdev_dbg(net, "Device MAC %pM link state %s\n",
rndis_device->hw_mac_adr, rndis_device->hw_mac_adr,
...@@ -1194,11 +1187,11 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, ...@@ -1194,11 +1187,11 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5) if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5)
return net_device; return net_device;
rndis_filter_query_link_speed(rndis_device); rndis_filter_query_link_speed(rndis_device, net_device);
/* vRSS setup */ /* vRSS setup */
memset(&rsscap, 0, rsscap_size); memset(&rsscap, 0, rsscap_size);
ret = rndis_filter_query_device(rndis_device, ret = rndis_filter_query_device(rndis_device, net_device,
OID_GEN_RECEIVE_SCALE_CAPABILITIES, OID_GEN_RECEIVE_SCALE_CAPABILITIES,
&rsscap, &rsscap_size); &rsscap, &rsscap_size);
if (ret || rsscap.num_recv_que < 2) if (ret || rsscap.num_recv_que < 2)
...@@ -1227,6 +1220,15 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, ...@@ -1227,6 +1220,15 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
if (num_rss_qs == 0) if (num_rss_qs == 0)
return net_device; return net_device;
for (i = 1; i < net_device->num_chn; i++) {
ret = netvsc_alloc_recv_comp_ring(net_device, i);
if (ret) {
while (--i != 0)
vfree(net_device->chan_table[i].mrc.slots);
goto out;
}
}
refcount_set(&net_device->sc_offered, num_rss_qs); refcount_set(&net_device->sc_offered, num_rss_qs);
vmbus_set_sc_create_callback(dev->channel, netvsc_sc_open); vmbus_set_sc_create_callback(dev->channel, netvsc_sc_open);
......
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