|
29 | 29 | #include <linux/nls.h>
|
30 | 30 | #include <linux/vmalloc.h>
|
31 | 31 | #include <linux/rtnetlink.h>
|
| 32 | +#include <linux/ucs2_string.h> |
32 | 33 |
|
33 | 34 | #include "hyperv_net.h"
|
34 | 35 | #include "netvsc_trace.h"
|
@@ -1223,6 +1224,29 @@ static int rndis_netdev_set_hwcaps(struct rndis_device *rndis_device,
|
1223 | 1224 | return ret;
|
1224 | 1225 | }
|
1225 | 1226 |
|
| 1227 | +static void rndis_get_friendly_name(struct net_device *net, |
| 1228 | + struct rndis_device *rndis_device, |
| 1229 | + struct netvsc_device *net_device) |
| 1230 | +{ |
| 1231 | + ucs2_char_t wname[256]; |
| 1232 | + unsigned long len; |
| 1233 | + u8 ifalias[256]; |
| 1234 | + u32 size; |
| 1235 | + |
| 1236 | + size = sizeof(wname); |
| 1237 | + if (rndis_filter_query_device(rndis_device, net_device, |
| 1238 | + RNDIS_OID_GEN_FRIENDLY_NAME, |
| 1239 | + wname, &size) != 0) |
| 1240 | + return; |
| 1241 | + |
| 1242 | + /* Convert Windows Unicode string to UTF-8 */ |
| 1243 | + len = ucs2_as_utf8(ifalias, wname, sizeof(ifalias)); |
| 1244 | + |
| 1245 | + /* ignore the default value from host */ |
| 1246 | + if (strcmp(ifalias, "Network Adapter") != 0) |
| 1247 | + dev_set_alias(net, ifalias, len); |
| 1248 | +} |
| 1249 | + |
1226 | 1250 | struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
|
1227 | 1251 | struct netvsc_device_info *device_info)
|
1228 | 1252 | {
|
@@ -1276,6 +1300,10 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
|
1276 | 1300 |
|
1277 | 1301 | memcpy(device_info->mac_adr, rndis_device->hw_mac_adr, ETH_ALEN);
|
1278 | 1302 |
|
| 1303 | + /* Get friendly name as ifalias*/ |
| 1304 | + if (!net->ifalias) |
| 1305 | + rndis_get_friendly_name(net, rndis_device, net_device); |
| 1306 | + |
1279 | 1307 | /* Query and set hardware capabilities */
|
1280 | 1308 | ret = rndis_netdev_set_hwcaps(rndis_device, net_device);
|
1281 | 1309 | if (ret != 0)
|
|
0 commit comments