Skip to content

Commit 52105c6

Browse files
committed
Merge tag 'net-pull-request' of https://github.com/jasowang/qemu into staging
# -----BEGIN PGP SIGNATURE----- # Version: GnuPG v1 # # iQEcBAABAgAGBQJlUt3jAAoJEO8Ells5jWIRX30H/iATyz+77w3Zd2rVfOpyHLhM # lgvhTwVCltsWdZSZLu6zrLYh419NNcAOyb9/Ci7hKR+x4OmWbP6pme772LRH2Mhz # zWzVoMXJeW1unjGvBcA8eAIsu3PUKoHLQ1J2dNwHheupMb2LkrWMaEMj10605aZ9 # WnjCFRIiejq4s2JGhofDTa0GCHcFmq2/Nzghb6MMzdPa99QTFnPmYRdIg2bGWd4L # PmoueuiA/zoDZjx+Y1nC2IzXRq7SvFIAyz91J/zaUtZLD+7QKV/bP+JACTnyzhOY # coUZnVzFc7q0Gv9wjw2oTNQo5CgKDyw7aDUB8oWsQLR1UvqEICbMhhz29YCWhok= # =10qX # -----END PGP SIGNATURE----- # gpg: Signature made Mon 13 Nov 2023 21:39:31 EST # gpg: using RSA key EF04965B398D6211 # gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>" [full] # Primary key fingerprint: 215D 46F4 8246 689E C77F 3562 EF04 965B 398D 6211 * tag 'net-pull-request' of https://github.com/jasowang/qemu: igb: Add Function Level Reset to PF and VF igb: Add a VF reset handler Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2 parents 9f7c4f6 + d90014f commit 52105c6

File tree

7 files changed

+45
-3
lines changed

7 files changed

+45
-3
lines changed

hw/core/machine.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
GlobalProperty hw_compat_8_1[] = {
3636
{ TYPE_PCI_BRIDGE, "x-pci-express-writeable-slt-bug", "true" },
3737
{ "ramfb", "x-migrate", "off" },
38-
{ "vfio-pci-nohotplug", "x-ramfb-migrate", "off" }
38+
{ "vfio-pci-nohotplug", "x-ramfb-migrate", "off" },
39+
{ "igb", "x-pcie-flr-init", "off" },
3940
};
4041
const size_t hw_compat_8_1_len = G_N_ELEMENTS(hw_compat_8_1);
4142

hw/net/igb.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct IGBState {
7878
uint32_t ioaddr;
7979

8080
IGBCore core;
81+
bool has_flr;
8182
};
8283

8384
#define IGB_CAP_SRIOV_OFFSET (0x160)
@@ -101,6 +102,9 @@ static void igb_write_config(PCIDevice *dev, uint32_t addr,
101102

102103
trace_igb_write_config(addr, val, len);
103104
pci_default_write_config(dev, addr, val, len);
105+
if (s->has_flr) {
106+
pcie_cap_flr_write_config(dev, addr, val, len);
107+
}
104108

105109
if (range_covers_byte(addr, len, PCI_COMMAND) &&
106110
(dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER)) {
@@ -122,6 +126,12 @@ igb_mmio_write(void *opaque, hwaddr addr, uint64_t val, unsigned size)
122126
igb_core_write(&s->core, addr, val, size);
123127
}
124128

129+
void igb_vf_reset(void *opaque, uint16_t vfn)
130+
{
131+
IGBState *s = opaque;
132+
igb_core_vf_reset(&s->core, vfn);
133+
}
134+
125135
static bool
126136
igb_io_get_reg_index(IGBState *s, uint32_t *idx)
127137
{
@@ -427,6 +437,10 @@ static void igb_pci_realize(PCIDevice *pci_dev, Error **errp)
427437
}
428438

429439
/* PCIe extended capabilities (in order) */
440+
if (s->has_flr) {
441+
pcie_cap_flr_init(pci_dev);
442+
}
443+
430444
if (pcie_aer_init(pci_dev, 1, 0x100, 0x40, errp) < 0) {
431445
hw_error("Failed to initialize AER capability");
432446
}
@@ -582,6 +596,7 @@ static const VMStateDescription igb_vmstate = {
582596

583597
static Property igb_properties[] = {
584598
DEFINE_NIC_PROPERTIES(IGBState, conf),
599+
DEFINE_PROP_BOOL("x-pcie-flr-init", IGBState, has_flr, true),
585600
DEFINE_PROP_END_OF_LIST(),
586601
};
587602

hw/net/igb_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,6 @@ enum {
152152

153153
uint64_t igb_mmio_read(void *opaque, hwaddr addr, unsigned size);
154154
void igb_mmio_write(void *opaque, hwaddr addr, uint64_t val, unsigned size);
155+
void igb_vf_reset(void *opaque, uint16_t vfn);
155156

156157
#endif

hw/net/igb_core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2477,11 +2477,13 @@ static void igb_set_vfmailbox(IGBCore *core, int index, uint32_t val)
24772477
}
24782478
}
24792479

2480-
static void igb_vf_reset(IGBCore *core, uint16_t vfn)
2480+
void igb_core_vf_reset(IGBCore *core, uint16_t vfn)
24812481
{
24822482
uint16_t qn0 = vfn;
24832483
uint16_t qn1 = vfn + IGB_NUM_VM_POOLS;
24842484

2485+
trace_igb_core_vf_reset(vfn);
2486+
24852487
/* disable Rx and Tx for the VF*/
24862488
core->mac[RXDCTL0 + (qn0 * 16)] &= ~E1000_RXDCTL_QUEUE_ENABLE;
24872489
core->mac[RXDCTL0 + (qn1 * 16)] &= ~E1000_RXDCTL_QUEUE_ENABLE;
@@ -2560,7 +2562,7 @@ static void igb_set_vtctrl(IGBCore *core, int index, uint32_t val)
25602562

25612563
if (val & E1000_CTRL_RST) {
25622564
vfn = (index - PVTCTRL0) / 0x40;
2563-
igb_vf_reset(core, vfn);
2565+
igb_core_vf_reset(core, vfn);
25642566
}
25652567
}
25662568

hw/net/igb_core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ igb_core_set_link_status(IGBCore *core);
130130
void
131131
igb_core_pci_uninit(IGBCore *core);
132132

133+
void
134+
igb_core_vf_reset(IGBCore *core, uint16_t vfn);
135+
133136
bool
134137
igb_can_receive(IGBCore *core);
135138

hw/net/igbvf.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ static void igbvf_write_config(PCIDevice *dev, uint32_t addr, uint32_t val,
204204
{
205205
trace_igbvf_write_config(addr, val, len);
206206
pci_default_write_config(dev, addr, val, len);
207+
if (object_property_get_bool(OBJECT(pcie_sriov_get_pf(dev)),
208+
"x-pcie-flr-init", &error_abort)) {
209+
pcie_cap_flr_write_config(dev, addr, val, len);
210+
}
207211
}
208212

209213
static uint64_t igbvf_mmio_read(void *opaque, hwaddr addr, unsigned size)
@@ -266,13 +270,25 @@ static void igbvf_pci_realize(PCIDevice *dev, Error **errp)
266270
hw_error("Failed to initialize PCIe capability");
267271
}
268272

273+
if (object_property_get_bool(OBJECT(pcie_sriov_get_pf(dev)),
274+
"x-pcie-flr-init", &error_abort)) {
275+
pcie_cap_flr_init(dev);
276+
}
277+
269278
if (pcie_aer_init(dev, 1, 0x100, 0x40, errp) < 0) {
270279
hw_error("Failed to initialize AER capability");
271280
}
272281

273282
pcie_ari_init(dev, 0x150);
274283
}
275284

285+
static void igbvf_qdev_reset_hold(Object *obj)
286+
{
287+
PCIDevice *vf = PCI_DEVICE(obj);
288+
289+
igb_vf_reset(pcie_sriov_get_pf(vf), pcie_sriov_vf_number(vf));
290+
}
291+
276292
static void igbvf_pci_uninit(PCIDevice *dev)
277293
{
278294
IgbVfState *s = IGBVF(dev);
@@ -287,6 +303,7 @@ static void igbvf_class_init(ObjectClass *class, void *data)
287303
{
288304
DeviceClass *dc = DEVICE_CLASS(class);
289305
PCIDeviceClass *c = PCI_DEVICE_CLASS(class);
306+
ResettableClass *rc = RESETTABLE_CLASS(class);
290307

291308
c->realize = igbvf_pci_realize;
292309
c->exit = igbvf_pci_uninit;
@@ -295,6 +312,8 @@ static void igbvf_class_init(ObjectClass *class, void *data)
295312
c->revision = 1;
296313
c->class_id = PCI_CLASS_NETWORK_ETHERNET;
297314

315+
rc->phases.hold = igbvf_qdev_reset_hold;
316+
298317
dc->desc = "Intel 82576 Virtual Function";
299318
dc->user_creatable = false;
300319

hw/net/trace-events

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ igb_core_mdic_read(uint32_t addr, uint32_t data) "MDIC READ: PHY[%u] = 0x%x"
274274
igb_core_mdic_read_unhandled(uint32_t addr) "MDIC READ: PHY[%u] UNHANDLED"
275275
igb_core_mdic_write(uint32_t addr, uint32_t data) "MDIC WRITE: PHY[%u] = 0x%x"
276276
igb_core_mdic_write_unhandled(uint32_t addr) "MDIC WRITE: PHY[%u] UNHANDLED"
277+
igb_core_vf_reset(uint16_t vfn) "VF%d"
277278

278279
igb_link_set_ext_params(bool asd_check, bool speed_select_bypass, bool pfrstd) "Set extended link params: ASD check: %d, Speed select bypass: %d, PF reset done: %d"
279280

0 commit comments

Comments
 (0)