summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason King <jason.king@joyent.com>2020-06-03 21:04:29 +0000
committerJason King <jason.king@joyent.com>2020-06-03 21:04:29 +0000
commit64d631e5041790bd538ca51650ea2eda76c71576 (patch)
tree07086665fd21094e08c1cd47e37072ee13f9c6cb
parent71b43f2a12f58ef8bc5a1965a3b742749bb49231 (diff)
downloadillumos-joyent-64d631e5041790bd538ca51650ea2eda76c71576.tar.gz
OS-7458 bhyve should allow pci_slot addressing for NICs
-rw-r--r--usr/src/lib/brand/bhyve/zone/boot.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/usr/src/lib/brand/bhyve/zone/boot.c b/usr/src/lib/brand/bhyve/zone/boot.c
index 3d26e350d4..85df12082b 100644
--- a/usr/src/lib/brand/bhyve/zone/boot.c
+++ b/usr/src/lib/brand/bhyve/zone/boot.c
@@ -422,7 +422,7 @@ add_nets(int *argc, char **argv)
char *nets;
char *net;
char *lasts;
- int nextpcifn = 1; /* 0 reserved for primary */
+ uint_t nextpcifn = 1; /* 0 reserved for primary */
char slotconf[MAXNAMELEN];
char *primary = NULL;
@@ -433,7 +433,11 @@ add_nets(int *argc, char **argv)
for (net = strtok_r(nets, " ", &lasts); net != NULL;
net = strtok_r(NULL, " ", &lasts)) {
- int pcifn;
+ char *slotstr;
+ uint_t pcibus = 0;
+ uint_t pcislot = PCI_SLOT_NICS;
+ uint_t pcifn;
+ int ret;
/* zoneadmd is not careful about a trailing delimiter. */
if (net[0] == '\0') {
@@ -450,14 +454,27 @@ add_nets(int *argc, char **argv)
}
primary = net;
pcifn = 0;
+ } else if ((slotstr = get_zcfg_var("net", net,
+ "pci_slot")) != NULL) {
+ if (parse_pcislot(slotstr, &pcibus, &pcislot,
+ &pcifn) != 0) {
+ return (-1);
+ }
} else {
pcifn = nextpcifn;
nextpcifn++;
}
- if (snprintf(slotconf, sizeof (slotconf),
- "%d:%d,virtio-net-viona,%s", PCI_SLOT_NICS, pcifn, net) >=
- sizeof (slotconf)) {
+ if (pcibus > 0) {
+ ret = snprintf(slotconf, sizeof (slotconf),
+ "%u:%u:%u,virtio-net-viona,%s",
+ pcibus, pcislot, pcifn, net);
+ } else {
+ ret = snprintf(slotconf, sizeof (slotconf),
+ "%u:%u,virtio-net-viona,%s", pcislot, pcifn, net);
+ }
+
+ if (ret >= sizeof (slotconf)) {
(void) printf("Error: net '%s' too long\n", net);
return (-1);
}