Skip to content

Commit b555cb6

Browse files
btw616jmberg-intel
authored andcommitted
um: vector: Eliminate the dependency on uml_net
The only dependency on uml_net (i.e., the legacy network transport infrastructure) is the call to uml_net_setup_etheraddr(). Implement it inside vector to eliminate the uml_net dependency completely. It will allow us to remove uml_net in the next step. Signed-off-by: Tiwei Bie <[email protected]> Acked-By: Anton Ivanov <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 65eaac5 commit b555cb6

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

arch/um/drivers/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ config UML_NET
145145

146146
config UML_NET_VECTOR
147147
bool "Vector I/O high performance network devices"
148-
depends on UML_NET
149148
select MAY_HAVE_RUNTIME_DEPS
150149
help
151150
This User-Mode Linux network driver uses multi-message send

arch/um/drivers/vector_kern.c

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <init.h>
2828
#include <irq_kern.h>
2929
#include <irq_user.h>
30-
#include <net_kern.h>
3130
#include <os.h>
3231
#include "mconsole_kern.h"
3332
#include "vector_user.h"
@@ -1539,7 +1538,56 @@ static void vector_timer_expire(struct timer_list *t)
15391538
napi_schedule(&vp->napi);
15401539
}
15411540

1541+
static void vector_setup_etheraddr(struct net_device *dev, char *str)
1542+
{
1543+
u8 addr[ETH_ALEN];
1544+
char *end;
1545+
int i;
15421546

1547+
if (str == NULL)
1548+
goto random;
1549+
1550+
for (i = 0; i < 6; i++) {
1551+
addr[i] = simple_strtoul(str, &end, 16);
1552+
if ((end == str) ||
1553+
((*end != ':') && (*end != ',') && (*end != '\0'))) {
1554+
printk(KERN_ERR
1555+
"setup_etheraddr: failed to parse '%s' "
1556+
"as an ethernet address\n", str);
1557+
goto random;
1558+
}
1559+
str = end + 1;
1560+
}
1561+
if (is_multicast_ether_addr(addr)) {
1562+
printk(KERN_ERR
1563+
"Attempt to assign a multicast ethernet address to a "
1564+
"device disallowed\n");
1565+
goto random;
1566+
}
1567+
if (!is_valid_ether_addr(addr)) {
1568+
printk(KERN_ERR
1569+
"Attempt to assign an invalid ethernet address to a "
1570+
"device disallowed\n");
1571+
goto random;
1572+
}
1573+
if (!is_local_ether_addr(addr)) {
1574+
printk(KERN_WARNING
1575+
"Warning: Assigning a globally valid ethernet "
1576+
"address to a device\n");
1577+
printk(KERN_WARNING "You should set the 2nd rightmost bit in "
1578+
"the first byte of the MAC,\n");
1579+
printk(KERN_WARNING "i.e. %02x:%02x:%02x:%02x:%02x:%02x\n",
1580+
addr[0] | 0x02, addr[1], addr[2], addr[3], addr[4],
1581+
addr[5]);
1582+
}
1583+
eth_hw_addr_set(dev, addr);
1584+
return;
1585+
1586+
random:
1587+
printk(KERN_INFO
1588+
"Choosing a random ethernet address for device %s\n", dev->name);
1589+
eth_hw_addr_random(dev);
1590+
}
15431591

15441592
static void vector_eth_configure(
15451593
int n,
@@ -1574,7 +1622,7 @@ static void vector_eth_configure(
15741622
* and fail.
15751623
*/
15761624
snprintf(dev->name, sizeof(dev->name), "vec%d", n);
1577-
uml_net_setup_etheraddr(dev, uml_vector_fetch_arg(def, "mac"));
1625+
vector_setup_etheraddr(dev, uml_vector_fetch_arg(def, "mac"));
15781626
vp = netdev_priv(dev);
15791627

15801628
/* sysfs register */

0 commit comments

Comments
 (0)