forked from illumos/illumos-gate
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OS-7458 bhyve should allow pci_slot addressing for NICs #309
Open
jasonbking
wants to merge
3
commits into
master
Choose a base branch
from
OS-7458
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also be explicitly set the bus to 0 while we're here?
Currently the nics are the only one that get passed without the bus, sure bhyve itself wil use 0 in that case. But given we pass it for all other arguments we add, we should be consistant. |
||
} | ||
|
||
if (ret >= sizeof (slotconf)) { | ||
(void) printf("Error: net '%s' too long\n", net); | ||
return (-1); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no way to avoid collisions here?
I can add a nic without pci_slot set and mark it primary and then add a 2nd one set to 0:6:0 an they will end up in the same slot. (Or am I missing a check for that somewhere?