mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-07 20:26:20 +00:00
qemu/net: flag to control the number of vectors a nic has
Add an option to specify the number of MSI-X vectors for PCI NIC cards. This can also be used to disable MSI-X, for compatibility with old qemu. This option currently only affects virtio cards. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
566e2d3e88
commit
ffe6370c9f
@ -745,7 +745,10 @@ VirtIODevice *virtio_net_init(DeviceState *dev)
|
|||||||
n->mac_table.macs = qemu_mallocz(MAC_TABLE_ENTRIES * ETH_ALEN);
|
n->mac_table.macs = qemu_mallocz(MAC_TABLE_ENTRIES * ETH_ALEN);
|
||||||
|
|
||||||
n->vlans = qemu_mallocz(MAX_VLAN >> 3);
|
n->vlans = qemu_mallocz(MAX_VLAN >> 3);
|
||||||
n->vdev.nvectors = 3;
|
if (dev->nd->nvectors == NIC_NVECTORS_UNSPECIFIED)
|
||||||
|
n->vdev.nvectors = 3;
|
||||||
|
else
|
||||||
|
n->vdev.nvectors = dev->nd->nvectors;
|
||||||
|
|
||||||
register_savevm("virtio-net", virtio_net_id++, VIRTIO_NET_VM_VERSION,
|
register_savevm("virtio-net", virtio_net_id++, VIRTIO_NET_VM_VERSION,
|
||||||
virtio_net_save, virtio_net_load, n);
|
virtio_net_save, virtio_net_load, n);
|
||||||
|
18
net.c
18
net.c
@ -2169,7 +2169,7 @@ int net_client_init(Monitor *mon, const char *device, const char *p)
|
|||||||
}
|
}
|
||||||
if (!strcmp(device, "nic")) {
|
if (!strcmp(device, "nic")) {
|
||||||
static const char * const nic_params[] = {
|
static const char * const nic_params[] = {
|
||||||
"vlan", "name", "macaddr", "model", "addr", NULL
|
"vlan", "name", "macaddr", "model", "addr", "vectors", NULL
|
||||||
};
|
};
|
||||||
NICInfo *nd;
|
NICInfo *nd;
|
||||||
uint8_t *macaddr;
|
uint8_t *macaddr;
|
||||||
@ -2207,6 +2207,22 @@ int net_client_init(Monitor *mon, const char *device, const char *p)
|
|||||||
if (get_param_value(buf, sizeof(buf), "addr", p)) {
|
if (get_param_value(buf, sizeof(buf), "addr", p)) {
|
||||||
nd->devaddr = strdup(buf);
|
nd->devaddr = strdup(buf);
|
||||||
}
|
}
|
||||||
|
nd->nvectors = NIC_NVECTORS_UNSPECIFIED;
|
||||||
|
if (get_param_value(buf, sizeof(buf), "vectors", p)) {
|
||||||
|
char *endptr;
|
||||||
|
long vectors = strtol(buf, &endptr, 0);
|
||||||
|
if (*endptr) {
|
||||||
|
config_error(mon, "invalid syntax for # of vectors\n");
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (vectors < 0 || vectors > 0x7ffffff) {
|
||||||
|
config_error(mon, "invalid # of vectors\n");
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
nd->nvectors = vectors;
|
||||||
|
}
|
||||||
nd->vlan = vlan;
|
nd->vlan = vlan;
|
||||||
nd->name = name;
|
nd->name = name;
|
||||||
nd->used = 1;
|
nd->used = 1;
|
||||||
|
4
net.h
4
net.h
@ -84,6 +84,9 @@ int do_set_link(Monitor *mon, const char *name, const char *up_or_down);
|
|||||||
/* NIC info */
|
/* NIC info */
|
||||||
|
|
||||||
#define MAX_NICS 8
|
#define MAX_NICS 8
|
||||||
|
enum {
|
||||||
|
NIC_NVECTORS_UNSPECIFIED = -1
|
||||||
|
};
|
||||||
|
|
||||||
struct NICInfo {
|
struct NICInfo {
|
||||||
uint8_t macaddr[6];
|
uint8_t macaddr[6];
|
||||||
@ -94,6 +97,7 @@ struct NICInfo {
|
|||||||
void *private;
|
void *private;
|
||||||
int used;
|
int used;
|
||||||
int bootable;
|
int bootable;
|
||||||
|
int nvectors;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int nb_nics;
|
extern int nb_nics;
|
||||||
|
@ -736,7 +736,7 @@ STEXI
|
|||||||
ETEXI
|
ETEXI
|
||||||
|
|
||||||
DEF("net", HAS_ARG, QEMU_OPTION_net,
|
DEF("net", HAS_ARG, QEMU_OPTION_net,
|
||||||
"-net nic[,vlan=n][,macaddr=mac][,model=type][,name=str][,addr=str]\n"
|
"-net nic[,vlan=n][,macaddr=mac][,model=type][,name=str][,addr=str][,vectors=v]\n"
|
||||||
" create a new Network Interface Card and connect it to VLAN 'n'\n"
|
" create a new Network Interface Card and connect it to VLAN 'n'\n"
|
||||||
#ifdef CONFIG_SLIRP
|
#ifdef CONFIG_SLIRP
|
||||||
"-net user[,vlan=n][,name=str][,hostname=host]\n"
|
"-net user[,vlan=n][,name=str][,hostname=host]\n"
|
||||||
@ -777,16 +777,18 @@ DEF("net", HAS_ARG, QEMU_OPTION_net,
|
|||||||
"-net none use it alone to have zero network devices; if no -net option\n"
|
"-net none use it alone to have zero network devices; if no -net option\n"
|
||||||
" is provided, the default is '-net nic -net user'\n")
|
" is provided, the default is '-net nic -net user'\n")
|
||||||
STEXI
|
STEXI
|
||||||
@item -net nic[,vlan=@var{n}][,macaddr=@var{mac}][,model=@var{type}][,name=@var{name}][,addr=@var{addr}]
|
@item -net nic[,vlan=@var{n}][,macaddr=@var{mac}][,model=@var{type}][,name=@var{name}][,addr=@var{addr}][,vectors=@var{v}]
|
||||||
Create a new Network Interface Card and connect it to VLAN @var{n} (@var{n}
|
Create a new Network Interface Card and connect it to VLAN @var{n} (@var{n}
|
||||||
= 0 is the default). The NIC is an ne2k_pci by default on the PC
|
= 0 is the default). The NIC is an ne2k_pci by default on the PC
|
||||||
target. Optionally, the MAC address can be changed to @var{mac}, the
|
target. Optionally, the MAC address can be changed to @var{mac}, the
|
||||||
device address set to @var{addr} (PCI cards only),
|
device address set to @var{addr} (PCI cards only),
|
||||||
and a @var{name} can be assigned for use in monitor commands. If no
|
and a @var{name} can be assigned for use in monitor commands.
|
||||||
@option{-net} option is specified, a single NIC is created.
|
Optionally, for PCI cards, you can specify the number @var{v} of MSI-X vectors
|
||||||
Qemu can emulate several different models of network card.
|
that the card should have; this option currently only affects virtio cards; set
|
||||||
|
@var{v} = 0 to disable MSI-X. If no @option{-net} option is specified, a single
|
||||||
|
NIC is created. Qemu can emulate several different models of network card.
|
||||||
Valid values for @var{type} are
|
Valid values for @var{type} are
|
||||||
@code{i82551}, @code{i82557b}, @code{i82559er},
|
@code{virtio}, @code{i82551}, @code{i82557b}, @code{i82559er},
|
||||||
@code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139},
|
@code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139},
|
||||||
@code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}.
|
@code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}.
|
||||||
Not all devices are supported on all targets. Use -net nic,model=?
|
Not all devices are supported on all targets. Use -net nic,model=?
|
||||||
|
Loading…
Reference in New Issue
Block a user