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