usbnet: use eth%d name for known ethernet devices

The documentation for the USB ethernet devices suggests that
only some devices are supposed to use usb0 as the network interface
name instead of eth0. The logic used there, and documented in
Kconfig for CDC is that eth0 will be used when the mac address
is a globally assigned one, but usb0 is used for the locally
managed range that is typically used on point-to-point links.

Unfortunately, this has caused a lot of pain on the smsc95xx
device that is used on the popular pandaboard without an
EEPROM to store the MAC address, which causes the driver to
call random_ether_address().

Obviously, there should be a proper MAC addressed assigned to
the device, and discussions are ongoing about how to solve
this, but this patch at least makes sure that the default
interface naming gets a little saner and matches what the
user can expect based on the documentation, including for
new devices.

The approach taken here is to flag whether a device might be a
point-to-point link with the new FLAG_POINTTOPOINT setting in
the usbnet driver_info. A driver can set both FLAG_POINTTOPOINT
and FLAG_ETHER if it is not sure (e.g. cdc_ether), or just one
of the two. The usbnet framework only looks at the MAC address
for device naming if both flags are set, otherwise it trusts the
flag.

Signed-off-by: Arnd Bergmann <arnd.bergmann@linaro.org>
Tested-by: Andy Green <andy.green@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Arnd Bergmann and committed by David S. Miller c261344d 1591cb60

+23 -12
+1 -1
drivers/net/usb/cdc_eem.c
··· 340 340 341 341 static const struct driver_info eem_info = { 342 342 .description = "CDC EEM Device", 343 - .flags = FLAG_ETHER, 343 + .flags = FLAG_ETHER | FLAG_POINTTOPOINT, 344 344 .bind = eem_bind, 345 345 .rx_fixup = eem_rx_fixup, 346 346 .tx_fixup = eem_tx_fixup,
+1 -1
drivers/net/usb/cdc_ether.c
··· 452 452 453 453 static const struct driver_info cdc_info = { 454 454 .description = "CDC Ethernet Device", 455 - .flags = FLAG_ETHER, 455 + .flags = FLAG_ETHER | FLAG_POINTTOPOINT, 456 456 // .check_connect = cdc_check_connect, 457 457 .bind = usbnet_cdc_bind, 458 458 .unbind = usbnet_cdc_unbind,
+1 -1
drivers/net/usb/cdc_ncm.c
··· 1237 1237 1238 1238 static const struct driver_info cdc_ncm_info = { 1239 1239 .description = "CDC NCM", 1240 - .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET, 1240 + .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET, 1241 1241 .bind = cdc_ncm_bind, 1242 1242 .unbind = cdc_ncm_unbind, 1243 1243 .check_connect = cdc_ncm_check_connect,
+8
drivers/net/usb/cdc_subset.c
··· 89 89 90 90 static const struct driver_info ali_m5632_info = { 91 91 .description = "ALi M5632", 92 + .flags = FLAG_POINTTOPOINT, 92 93 }; 93 94 94 95 #endif ··· 111 110 112 111 static const struct driver_info an2720_info = { 113 112 .description = "AnchorChips/Cypress 2720", 113 + .flags = FLAG_POINTTOPOINT, 114 114 // no reset available! 115 115 // no check_connect available! 116 116 ··· 134 132 135 133 static const struct driver_info belkin_info = { 136 134 .description = "Belkin, eTEK, or compatible", 135 + .flags = FLAG_POINTTOPOINT, 137 136 }; 138 137 139 138 #endif /* CONFIG_USB_BELKIN */ ··· 160 157 static const struct driver_info epson2888_info = { 161 158 .description = "Epson USB Device", 162 159 .check_connect = always_connected, 160 + .flags = FLAG_POINTTOPOINT, 163 161 164 162 .in = 4, .out = 3, 165 163 }; ··· 177 173 #define HAVE_HARDWARE 178 174 static const struct driver_info kc2190_info = { 179 175 .description = "KC Technology KC-190", 176 + .flags = FLAG_POINTTOPOINT, 180 177 }; 181 178 #endif /* CONFIG_USB_KC2190 */ 182 179 ··· 205 200 static const struct driver_info linuxdev_info = { 206 201 .description = "Linux Device", 207 202 .check_connect = always_connected, 203 + .flags = FLAG_POINTTOPOINT, 208 204 }; 209 205 210 206 static const struct driver_info yopy_info = { 211 207 .description = "Yopy", 212 208 .check_connect = always_connected, 209 + .flags = FLAG_POINTTOPOINT, 213 210 }; 214 211 215 212 static const struct driver_info blob_info = { 216 213 .description = "Boot Loader OBject", 217 214 .check_connect = always_connected, 215 + .flags = FLAG_POINTTOPOINT, 218 216 }; 219 217 220 218 #endif /* CONFIG_USB_ARMLINUX */
+1 -1
drivers/net/usb/gl620a.c
··· 193 193 194 194 static const struct driver_info genelink_info = { 195 195 .description = "Genesys GeneLink", 196 - .flags = FLAG_FRAMING_GL | FLAG_NO_SETINT, 196 + .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_GL | FLAG_NO_SETINT, 197 197 .bind = genelink_bind, 198 198 .rx_fixup = genelink_rx_fixup, 199 199 .tx_fixup = genelink_tx_fixup,
+1 -1
drivers/net/usb/net1080.c
··· 560 560 561 561 static const struct driver_info net1080_info = { 562 562 .description = "NetChip TurboCONNECT", 563 - .flags = FLAG_FRAMING_NC, 563 + .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_NC, 564 564 .bind = net1080_bind, 565 565 .reset = net1080_reset, 566 566 .check_connect = net1080_check_connect,
+1 -1
drivers/net/usb/plusb.c
··· 96 96 97 97 static const struct driver_info prolific_info = { 98 98 .description = "Prolific PL-2301/PL-2302", 99 - .flags = FLAG_NO_SETINT, 99 + .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT, 100 100 /* some PL-2302 versions seem to fail usb_set_interface() */ 101 101 .reset = pl_reset, 102 102 };
+1 -1
drivers/net/usb/rndis_host.c
··· 573 573 574 574 static const struct driver_info rndis_info = { 575 575 .description = "RNDIS device", 576 - .flags = FLAG_ETHER | FLAG_FRAMING_RN | FLAG_NO_SETINT, 576 + .flags = FLAG_ETHER | FLAG_POINTTOPOINT | FLAG_FRAMING_RN | FLAG_NO_SETINT, 577 577 .bind = rndis_bind, 578 578 .unbind = rndis_unbind, 579 579 .status = rndis_status,
+2 -1
drivers/net/usb/usbnet.c
··· 1380 1380 // else "eth%d" when there's reasonable doubt. userspace 1381 1381 // can rename the link if it knows better. 1382 1382 if ((dev->driver_info->flags & FLAG_ETHER) != 0 && 1383 - (net->dev_addr [0] & 0x02) == 0) 1383 + ((dev->driver_info->flags & FLAG_POINTTOPOINT) == 0 || 1384 + (net->dev_addr [0] & 0x02) == 0)) 1384 1385 strcpy (net->name, "eth%d"); 1385 1386 /* WLAN devices should always be named "wlan%d" */ 1386 1387 if ((dev->driver_info->flags & FLAG_WLAN) != 0)
+4 -4
drivers/net/usb/zaurus.c
··· 102 102 103 103 static const struct driver_info zaurus_sl5x00_info = { 104 104 .description = "Sharp Zaurus SL-5x00", 105 - .flags = FLAG_FRAMING_Z, 105 + .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_Z, 106 106 .check_connect = always_connected, 107 107 .bind = zaurus_bind, 108 108 .unbind = usbnet_cdc_unbind, ··· 112 112 113 113 static const struct driver_info zaurus_pxa_info = { 114 114 .description = "Sharp Zaurus, PXA-2xx based", 115 - .flags = FLAG_FRAMING_Z, 115 + .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_Z, 116 116 .check_connect = always_connected, 117 117 .bind = zaurus_bind, 118 118 .unbind = usbnet_cdc_unbind, ··· 122 122 123 123 static const struct driver_info olympus_mxl_info = { 124 124 .description = "Olympus R1000", 125 - .flags = FLAG_FRAMING_Z, 125 + .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_Z, 126 126 .check_connect = always_connected, 127 127 .bind = zaurus_bind, 128 128 .unbind = usbnet_cdc_unbind, ··· 258 258 259 259 static const struct driver_info bogus_mdlm_info = { 260 260 .description = "pseudo-MDLM (BLAN) device", 261 - .flags = FLAG_FRAMING_Z, 261 + .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_Z, 262 262 .check_connect = always_connected, 263 263 .tx_fixup = zaurus_tx_fixup, 264 264 .bind = blan_mdlm_bind,
+2
include/linux/usb/usbnet.h
··· 97 97 98 98 #define FLAG_LINK_INTR 0x0800 /* updates link (carrier) status */ 99 99 100 + #define FLAG_POINTTOPOINT 0x1000 /* possibly use "usb%d" names */ 101 + 100 102 /* 101 103 * Indicates to usbnet, that USB driver accumulates multiple IP packets. 102 104 * Affects statistic (counters) and short packet handling.