mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Intrdocue igb device emulation
This change introduces emulation for the Intel 82576 adapter, AKA igb.
The details of the device will be provided by the documentation that
will follow this change.
This initial implementation of igb does not cover the full feature set,
but it selectively implements changes necessary to pass tests of Linut
Test Project, and Windows HLK. The below is the list of the implemented
changes; anything not listed here is not implemented:
New features:
- igb advanced descriptor handling
- Support of 16 queues
- SRRCTL.BSIZEPACKET register field
- SRRCTL.RDMTS register field
- Tx descriptor completion writeback
- Extended RA registers
- VMDq feature
- MRQC "Multiple Receive Queues Enable" register field
- DTXSWC.Loopback_en register field
- VMOLR.ROMPE register field
- VMOLR.AUPE register field
- VLVF.VLAN_id register field
- VLVF.VI_En register field
- VF
- Mailbox
- Reset
- Extended interrupt registers
- Default values for IGP01E1000 PHY registers
Removed features:
- e1000e extended descriptor
- e1000e packet split descriptor
- Legacy descriptor
- PHY register paging
- MAC Registers
- Legacy interrupt timer registers
- Legacy EEPROM registers
- PBA/POEM registers
- RSRPD register
- RFCTL.ACKDIS
- RCTL.DTYPE
- Copper PHY registers
Misc:
- VET register format
- ICR register format
Signed-off-by: Gal Hammer <gal.hammer@sap.com>
Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
[Jason: don't abort on msi(x)_init()]
Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
committed by
Jason Wang
parent
c9653b77d5
commit
3a977deebe
@@ -2249,6 +2249,11 @@ F: tests/qtest/fuzz-e1000e-test.c
|
||||
F: tests/qtest/e1000e-test.c
|
||||
F: tests/qtest/libqos/e1000e.*
|
||||
|
||||
igb
|
||||
M: Akihiko Odaki <akihiko.odaki@daynix.com>
|
||||
S: Maintained
|
||||
F: hw/net/igb*
|
||||
|
||||
eepro100
|
||||
M: Stefan Weil <sw@weilnetz.de>
|
||||
S: Maintained
|
||||
|
||||
@@ -44,6 +44,11 @@ config E1000E_PCI_EXPRESS
|
||||
default y if PCI_DEVICES
|
||||
depends on PCI_EXPRESS && MSI_NONBROKEN
|
||||
|
||||
config IGB_PCI_EXPRESS
|
||||
bool
|
||||
default y if PCI_DEVICES
|
||||
depends on PCI_EXPRESS && MSI_NONBROKEN
|
||||
|
||||
config RTL8139_PCI
|
||||
bool
|
||||
default y if PCI_DEVICES
|
||||
|
||||
+623
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* QEMU igb emulation - shared definitions
|
||||
*
|
||||
* Copyright (c) 2020-2023 Red Hat, Inc.
|
||||
* Copyright (c) 2008 Qumranet
|
||||
*
|
||||
* Based on work done by:
|
||||
* Nir Peleg, Tutis Systems Ltd. for Qumranet Inc.
|
||||
* Copyright (c) 2007 Dan Aloni
|
||||
* Copyright (c) 2004 Antony T Curtis
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef HW_NET_IGB_COMMON_H
|
||||
#define HW_NET_IGB_COMMON_H
|
||||
|
||||
#include "igb_regs.h"
|
||||
|
||||
#define defreg(x) x = (E1000_##x >> 2)
|
||||
#define defreg_indexed(x, i) x##i = (E1000_##x(i) >> 2)
|
||||
#define defreg_indexeda(x, i) x##i##_A = (E1000_##x##_A(i) >> 2)
|
||||
|
||||
#define defregd(x) defreg_indexed(x, 0), defreg_indexed(x, 1), \
|
||||
defreg_indexed(x, 2), defreg_indexed(x, 3), \
|
||||
defreg_indexed(x, 4), defreg_indexed(x, 5), \
|
||||
defreg_indexed(x, 6), defreg_indexed(x, 7), \
|
||||
defreg_indexed(x, 8), defreg_indexed(x, 9), \
|
||||
defreg_indexed(x, 10), defreg_indexed(x, 11), \
|
||||
defreg_indexed(x, 12), defreg_indexed(x, 13), \
|
||||
defreg_indexed(x, 14), defreg_indexed(x, 15), \
|
||||
defreg_indexeda(x, 0), defreg_indexeda(x, 1), \
|
||||
defreg_indexeda(x, 2), defreg_indexeda(x, 3)
|
||||
|
||||
#define defregv(x) defreg_indexed(x, 0), defreg_indexed(x, 1), \
|
||||
defreg_indexed(x, 2), defreg_indexed(x, 3), \
|
||||
defreg_indexed(x, 4), defreg_indexed(x, 5), \
|
||||
defreg_indexed(x, 6), defreg_indexed(x, 7)
|
||||
|
||||
enum {
|
||||
defreg(CTRL), defreg(EECD), defreg(EERD), defreg(GPRC),
|
||||
defreg(GPTC), defreg(ICR), defreg(ICS), defreg(IMC),
|
||||
defreg(IMS), defreg(LEDCTL), defreg(MANC), defreg(MDIC),
|
||||
defreg(MPC), defreg(RCTL),
|
||||
defreg(STATUS), defreg(SWSM), defreg(TCTL),
|
||||
defreg(TORH), defreg(TORL), defreg(TOTH),
|
||||
defreg(TOTL), defreg(TPR), defreg(TPT),
|
||||
defreg(WUFC), defreg(RA), defreg(MTA), defreg(CRCERRS),
|
||||
defreg(VFTA), defreg(VET),
|
||||
defreg(SCC), defreg(ECOL),
|
||||
defreg(MCC), defreg(LATECOL), defreg(COLC), defreg(DC),
|
||||
defreg(TNCRS), defreg(RLEC),
|
||||
defreg(XONRXC), defreg(XONTXC), defreg(XOFFRXC), defreg(XOFFTXC),
|
||||
defreg(FCRUC), defreg(TDFH), defreg(TDFT),
|
||||
defreg(TDFHS), defreg(TDFTS), defreg(TDFPC), defreg(WUC),
|
||||
defreg(WUS), defreg(RDFH),
|
||||
defreg(RDFT), defreg(RDFHS), defreg(RDFTS), defreg(RDFPC),
|
||||
defreg(IPAV), defreg(IP4AT), defreg(IP6AT),
|
||||
defreg(WUPM), defreg(FFMT),
|
||||
defreg(IAM),
|
||||
defreg(GCR), defreg(TIMINCA), defreg(EIAC), defreg(CTRL_EXT),
|
||||
defreg(IVAR0), defreg(MANC2H),
|
||||
defreg(MFVAL), defreg(MDEF), defreg(FACTPS), defreg(FTFT),
|
||||
defreg(RUC), defreg(ROC), defreg(RFC), defreg(RJC),
|
||||
defreg(PRC64), defreg(PRC127), defreg(PRC255), defreg(PRC511),
|
||||
defreg(PRC1023), defreg(PRC1522), defreg(PTC64), defreg(PTC127),
|
||||
defreg(PTC255), defreg(PTC511), defreg(PTC1023), defreg(PTC1522),
|
||||
defreg(GORCL), defreg(GORCH), defreg(GOTCL), defreg(GOTCH),
|
||||
defreg(RNBC), defreg(BPRC), defreg(MPRC), defreg(RFCTL),
|
||||
defreg(MPTC), defreg(BPTC),
|
||||
defreg(IAC), defreg(MGTPRC), defreg(MGTPDC), defreg(MGTPTC),
|
||||
defreg(TSCTC), defreg(RXCSUM), defreg(FUNCTAG), defreg(GSCL_1),
|
||||
defreg(GSCL_2), defreg(GSCL_3), defreg(GSCL_4), defreg(GSCN_0),
|
||||
defreg(GSCN_1), defreg(GSCN_2), defreg(GSCN_3),
|
||||
defreg_indexed(EITR, 0),
|
||||
defreg(MRQC), defreg(RETA), defreg(RSSRK),
|
||||
defreg(PBACLR), defreg(FCAL), defreg(FCAH), defreg(FCT),
|
||||
defreg(FCRTH), defreg(FCRTL), defreg(FCTTV), defreg(FCRTV),
|
||||
defreg(FLA), defreg(FLOP),
|
||||
defreg(MAVTV0), defreg(MAVTV1), defreg(MAVTV2), defreg(MAVTV3),
|
||||
defreg(TXSTMPL), defreg(TXSTMPH), defreg(SYSTIML), defreg(SYSTIMH),
|
||||
defreg(TIMADJL), defreg(TIMADJH),
|
||||
defreg(RXSTMPH), defreg(RXSTMPL), defreg(RXSATRL), defreg(RXSATRH),
|
||||
defreg(TIPG),
|
||||
defreg(CTRL_DUP),
|
||||
defreg(EEMNGCTL),
|
||||
defreg(EEMNGDATA),
|
||||
defreg(FLMNGCTL),
|
||||
defreg(FLMNGDATA),
|
||||
defreg(FLMNGCNT),
|
||||
defreg(TSYNCRXCTL),
|
||||
defreg(TSYNCTXCTL),
|
||||
defreg(RLPML),
|
||||
defreg(UTA),
|
||||
|
||||
/* Aliases */
|
||||
defreg(RDFH_A), defreg(RDFT_A), defreg(TDFH_A), defreg(TDFT_A),
|
||||
defreg(RA_A), defreg(VFTA_A), defreg(FCRTL_A),
|
||||
|
||||
/* Additional regs used by IGB */
|
||||
defreg(FWSM), defreg(SW_FW_SYNC),
|
||||
|
||||
defreg(EICS), defreg(EIMS), defreg(EIMC), defreg(EIAM),
|
||||
defreg(EICR), defreg(IVAR_MISC), defreg(GPIE),
|
||||
|
||||
defreg(RXPBS), defregd(RDBAL), defregd(RDBAH), defregd(RDLEN),
|
||||
defregd(SRRCTL), defregd(RDH), defregd(RDT),
|
||||
defregd(RXDCTL), defregd(RXCTL), defregd(RQDPC), defreg(RA2),
|
||||
|
||||
defreg(TXPBS), defreg(TCTL_EXT), defreg(DTXCTL), defreg(HTCBDPC),
|
||||
defregd(TDBAL), defregd(TDBAH), defregd(TDLEN), defregd(TDH),
|
||||
defregd(TDT), defregd(TXDCTL), defregd(TXCTL),
|
||||
defregd(TDWBAL), defregd(TDWBAH),
|
||||
|
||||
defreg(VT_CTL),
|
||||
|
||||
defregv(P2VMAILBOX), defregv(V2PMAILBOX), defreg(MBVFICR), defreg(MBVFIMR),
|
||||
defreg(VFLRE), defreg(VFRE), defreg(VFTE), defreg(WVBR),
|
||||
defreg(QDE), defreg(DTXSWC), defreg_indexed(VLVF, 0),
|
||||
defregv(VMOLR), defreg(RPLOLR), defregv(VMBMEM), defregv(VMVIR),
|
||||
|
||||
defregv(PVTCTRL), defregv(PVTEICS), defregv(PVTEIMS), defregv(PVTEIMC),
|
||||
defregv(PVTEIAC), defregv(PVTEIAM), defregv(PVTEICR), defregv(PVFGPRC),
|
||||
defregv(PVFGPTC), defregv(PVFGORC), defregv(PVFGOTC), defregv(PVFMPRC),
|
||||
defregv(PVFGPRLBC), defregv(PVFGPTLBC), defregv(PVFGORLBC), defregv(PVFGOTLBC),
|
||||
|
||||
defreg(MTA_A),
|
||||
|
||||
defreg(VTIVAR), defreg(VTIVAR_MISC),
|
||||
};
|
||||
|
||||
uint64_t igb_mmio_read(void *opaque, hwaddr addr, unsigned size);
|
||||
void igb_mmio_write(void *opaque, hwaddr addr, uint64_t val, unsigned size);
|
||||
|
||||
#endif
|
||||
+4077
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Core code for QEMU igb emulation
|
||||
*
|
||||
* Datasheet:
|
||||
* https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/82576eg-gbe-datasheet.pdf
|
||||
*
|
||||
* Copyright (c) 2020-2023 Red Hat, Inc.
|
||||
* Copyright (c) 2015 Ravello Systems LTD (http://ravellosystems.com)
|
||||
* Developed by Daynix Computing LTD (http://www.daynix.com)
|
||||
*
|
||||
* Authors:
|
||||
* Akihiko Odaki <akihiko.odaki@daynix.com>
|
||||
* Gal Hammmer <gal.hammer@sap.com>
|
||||
* Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
|
||||
* Dmitry Fleytman <dmitry@daynix.com>
|
||||
* Leonid Bloch <leonid@daynix.com>
|
||||
* Yan Vugenfirer <yan@daynix.com>
|
||||
*
|
||||
* Based on work done by:
|
||||
* Nir Peleg, Tutis Systems Ltd. for Qumranet Inc.
|
||||
* Copyright (c) 2008 Qumranet
|
||||
* Based on work done by:
|
||||
* Copyright (c) 2007 Dan Aloni
|
||||
* Copyright (c) 2004 Antony T Curtis
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef HW_NET_IGB_CORE_H
|
||||
#define HW_NET_IGB_CORE_H
|
||||
|
||||
#define E1000E_MAC_SIZE (0x8000)
|
||||
#define IGB_EEPROM_SIZE (1024)
|
||||
|
||||
#define IGB_INTR_NUM (25)
|
||||
#define IGB_MSIX_VEC_NUM (10)
|
||||
#define IGBVF_MSIX_VEC_NUM (3)
|
||||
#define IGB_NUM_QUEUES (16)
|
||||
|
||||
typedef struct IGBCore IGBCore;
|
||||
|
||||
enum { PHY_R = BIT(0),
|
||||
PHY_W = BIT(1),
|
||||
PHY_RW = PHY_R | PHY_W };
|
||||
|
||||
typedef struct IGBIntrDelayTimer_st {
|
||||
QEMUTimer *timer;
|
||||
bool running;
|
||||
uint32_t delay_reg;
|
||||
uint32_t delay_resolution_ns;
|
||||
IGBCore *core;
|
||||
} IGBIntrDelayTimer;
|
||||
|
||||
struct IGBCore {
|
||||
uint32_t mac[E1000E_MAC_SIZE];
|
||||
uint16_t phy[MAX_PHY_REG_ADDRESS + 1];
|
||||
uint16_t eeprom[IGB_EEPROM_SIZE];
|
||||
|
||||
uint8_t rx_desc_len;
|
||||
|
||||
QEMUTimer *autoneg_timer;
|
||||
|
||||
struct igb_tx {
|
||||
uint16_t vlan; /* VLAN Tag */
|
||||
uint16_t mss; /* Maximum Segment Size */
|
||||
bool tse; /* TCP/UDP Segmentation Enable */
|
||||
bool ixsm; /* Insert IP Checksum */
|
||||
bool txsm; /* Insert TCP/UDP Checksum */
|
||||
|
||||
bool first;
|
||||
bool skip_cp;
|
||||
|
||||
struct NetTxPkt *tx_pkt;
|
||||
} tx[IGB_NUM_QUEUES];
|
||||
|
||||
struct NetRxPkt *rx_pkt;
|
||||
|
||||
bool has_vnet;
|
||||
int max_queue_num;
|
||||
|
||||
IGBIntrDelayTimer eitr[IGB_INTR_NUM];
|
||||
|
||||
VMChangeStateEntry *vmstate;
|
||||
|
||||
uint32_t eitr_guest_value[IGB_INTR_NUM];
|
||||
|
||||
uint8_t permanent_mac[ETH_ALEN];
|
||||
|
||||
NICState *owner_nic;
|
||||
PCIDevice *owner;
|
||||
void (*owner_start_recv)(PCIDevice *d);
|
||||
|
||||
int64_t timadj;
|
||||
};
|
||||
|
||||
void
|
||||
igb_core_write(IGBCore *core, hwaddr addr, uint64_t val, unsigned size);
|
||||
|
||||
uint64_t
|
||||
igb_core_read(IGBCore *core, hwaddr addr, unsigned size);
|
||||
|
||||
void
|
||||
igb_core_pci_realize(IGBCore *regs,
|
||||
const uint16_t *eeprom_templ,
|
||||
uint32_t eeprom_size,
|
||||
const uint8_t *macaddr);
|
||||
|
||||
void
|
||||
igb_core_reset(IGBCore *core);
|
||||
|
||||
void
|
||||
igb_core_pre_save(IGBCore *core);
|
||||
|
||||
int
|
||||
igb_core_post_load(IGBCore *core);
|
||||
|
||||
void
|
||||
igb_core_set_link_status(IGBCore *core);
|
||||
|
||||
void
|
||||
igb_core_pci_uninit(IGBCore *core);
|
||||
|
||||
bool
|
||||
igb_can_receive(IGBCore *core);
|
||||
|
||||
ssize_t
|
||||
igb_receive(IGBCore *core, const uint8_t *buf, size_t size);
|
||||
|
||||
ssize_t
|
||||
igb_receive_iov(IGBCore *core, const struct iovec *iov, int iovcnt);
|
||||
|
||||
void
|
||||
igb_start_recv(IGBCore *core);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
+327
@@ -0,0 +1,327 @@
|
||||
/*
|
||||
* QEMU Intel 82576 SR/IOV Ethernet Controller Emulation
|
||||
*
|
||||
* Datasheet:
|
||||
* https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/82576eg-gbe-datasheet.pdf
|
||||
*
|
||||
* Copyright (c) 2020-2023 Red Hat, Inc.
|
||||
* Copyright (c) 2015 Ravello Systems LTD (http://ravellosystems.com)
|
||||
* Developed by Daynix Computing LTD (http://www.daynix.com)
|
||||
*
|
||||
* Authors:
|
||||
* Akihiko Odaki <akihiko.odaki@daynix.com>
|
||||
* Gal Hammmer <gal.hammer@sap.com>
|
||||
* Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
|
||||
* Dmitry Fleytman <dmitry@daynix.com>
|
||||
* Leonid Bloch <leonid@daynix.com>
|
||||
* Yan Vugenfirer <yan@daynix.com>
|
||||
*
|
||||
* Based on work done by:
|
||||
* Nir Peleg, Tutis Systems Ltd. for Qumranet Inc.
|
||||
* Copyright (c) 2008 Qumranet
|
||||
* Based on work done by:
|
||||
* Copyright (c) 2007 Dan Aloni
|
||||
* Copyright (c) 2004 Antony T Curtis
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/hw.h"
|
||||
#include "hw/net/mii.h"
|
||||
#include "hw/pci/pci_device.h"
|
||||
#include "hw/pci/pcie.h"
|
||||
#include "hw/pci/msix.h"
|
||||
#include "net/eth.h"
|
||||
#include "net/net.h"
|
||||
#include "igb_common.h"
|
||||
#include "igb_core.h"
|
||||
#include "trace.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
#define TYPE_IGBVF "igbvf"
|
||||
OBJECT_DECLARE_SIMPLE_TYPE(IgbVfState, IGBVF)
|
||||
|
||||
#define IGBVF_MMIO_BAR_IDX (0)
|
||||
#define IGBVF_MSIX_BAR_IDX (3)
|
||||
|
||||
#define IGBVF_MMIO_SIZE (16 * 1024)
|
||||
#define IGBVF_MSIX_SIZE (16 * 1024)
|
||||
|
||||
struct IgbVfState {
|
||||
PCIDevice parent_obj;
|
||||
|
||||
MemoryRegion mmio;
|
||||
MemoryRegion msix;
|
||||
};
|
||||
|
||||
static hwaddr vf_to_pf_addr(hwaddr addr, uint16_t vfn, bool write)
|
||||
{
|
||||
switch (addr) {
|
||||
case E1000_CTRL:
|
||||
case E1000_CTRL_DUP:
|
||||
return E1000_PVTCTRL(vfn);
|
||||
case E1000_EICS:
|
||||
return E1000_PVTEICS(vfn);
|
||||
case E1000_EIMS:
|
||||
return E1000_PVTEIMS(vfn);
|
||||
case E1000_EIMC:
|
||||
return E1000_PVTEIMC(vfn);
|
||||
case E1000_EIAC:
|
||||
return E1000_PVTEIAC(vfn);
|
||||
case E1000_EIAM:
|
||||
return E1000_PVTEIAM(vfn);
|
||||
case E1000_EICR:
|
||||
return E1000_PVTEICR(vfn);
|
||||
case E1000_EITR(0):
|
||||
case E1000_EITR(1):
|
||||
case E1000_EITR(2):
|
||||
return E1000_EITR(22) + (addr - E1000_EITR(0)) - vfn * 0xC;
|
||||
case E1000_IVAR0:
|
||||
return E1000_VTIVAR + vfn * 4;
|
||||
case E1000_IVAR_MISC:
|
||||
return E1000_VTIVAR_MISC + vfn * 4;
|
||||
case 0x0F04: /* PBACL */
|
||||
return E1000_PBACLR;
|
||||
case 0x0F0C: /* PSRTYPE */
|
||||
return E1000_PSRTYPE(vfn);
|
||||
case E1000_V2PMAILBOX(0):
|
||||
return E1000_V2PMAILBOX(vfn);
|
||||
case E1000_VMBMEM(0) ... E1000_VMBMEM(0) + 0x3F:
|
||||
return addr + vfn * 0x40;
|
||||
case E1000_RDBAL_A(0):
|
||||
return E1000_RDBAL(vfn);
|
||||
case E1000_RDBAL_A(1):
|
||||
return E1000_RDBAL(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_RDBAH_A(0):
|
||||
return E1000_RDBAH(vfn);
|
||||
case E1000_RDBAH_A(1):
|
||||
return E1000_RDBAH(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_RDLEN_A(0):
|
||||
return E1000_RDLEN(vfn);
|
||||
case E1000_RDLEN_A(1):
|
||||
return E1000_RDLEN(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_SRRCTL_A(0):
|
||||
return E1000_SRRCTL(vfn);
|
||||
case E1000_SRRCTL_A(1):
|
||||
return E1000_SRRCTL(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_RDH_A(0):
|
||||
return E1000_RDH(vfn);
|
||||
case E1000_RDH_A(1):
|
||||
return E1000_RDH(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_RXCTL_A(0):
|
||||
return E1000_RXCTL(vfn);
|
||||
case E1000_RXCTL_A(1):
|
||||
return E1000_RXCTL(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_RDT_A(0):
|
||||
return E1000_RDT(vfn);
|
||||
case E1000_RDT_A(1):
|
||||
return E1000_RDT(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_RXDCTL_A(0):
|
||||
return E1000_RXDCTL(vfn);
|
||||
case E1000_RXDCTL_A(1):
|
||||
return E1000_RXDCTL(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_RQDPC_A(0):
|
||||
return E1000_RQDPC(vfn);
|
||||
case E1000_RQDPC_A(1):
|
||||
return E1000_RQDPC(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_TDBAL_A(0):
|
||||
return E1000_TDBAL(vfn);
|
||||
case E1000_TDBAL_A(1):
|
||||
return E1000_TDBAL(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_TDBAH_A(0):
|
||||
return E1000_TDBAH(vfn);
|
||||
case E1000_TDBAH_A(1):
|
||||
return E1000_TDBAH(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_TDLEN_A(0):
|
||||
return E1000_TDLEN(vfn);
|
||||
case E1000_TDLEN_A(1):
|
||||
return E1000_TDLEN(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_TDH_A(0):
|
||||
return E1000_TDH(vfn);
|
||||
case E1000_TDH_A(1):
|
||||
return E1000_TDH(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_TXCTL_A(0):
|
||||
return E1000_TXCTL(vfn);
|
||||
case E1000_TXCTL_A(1):
|
||||
return E1000_TXCTL(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_TDT_A(0):
|
||||
return E1000_TDT(vfn);
|
||||
case E1000_TDT_A(1):
|
||||
return E1000_TDT(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_TXDCTL_A(0):
|
||||
return E1000_TXDCTL(vfn);
|
||||
case E1000_TXDCTL_A(1):
|
||||
return E1000_TXDCTL(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_TDWBAL_A(0):
|
||||
return E1000_TDWBAL(vfn);
|
||||
case E1000_TDWBAL_A(1):
|
||||
return E1000_TDWBAL(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_TDWBAH_A(0):
|
||||
return E1000_TDWBAH(vfn);
|
||||
case E1000_TDWBAH_A(1):
|
||||
return E1000_TDWBAH(vfn + IGB_MAX_VF_FUNCTIONS);
|
||||
case E1000_VFGPRC:
|
||||
return E1000_PVFGPRC(vfn);
|
||||
case E1000_VFGPTC:
|
||||
return E1000_PVFGPTC(vfn);
|
||||
case E1000_VFGORC:
|
||||
return E1000_PVFGORC(vfn);
|
||||
case E1000_VFGOTC:
|
||||
return E1000_PVFGOTC(vfn);
|
||||
case E1000_VFMPRC:
|
||||
return E1000_PVFMPRC(vfn);
|
||||
case E1000_VFGPRLBC:
|
||||
return E1000_PVFGPRLBC(vfn);
|
||||
case E1000_VFGPTLBC:
|
||||
return E1000_PVFGPTLBC(vfn);
|
||||
case E1000_VFGORLBC:
|
||||
return E1000_PVFGORLBC(vfn);
|
||||
case E1000_VFGOTLBC:
|
||||
return E1000_PVFGOTLBC(vfn);
|
||||
case E1000_STATUS:
|
||||
case E1000_FRTIMER:
|
||||
if (write) {
|
||||
return HWADDR_MAX;
|
||||
}
|
||||
/* fallthrough */
|
||||
case 0x34E8: /* PBTWAC */
|
||||
case 0x24E8: /* PBRWAC */
|
||||
return addr;
|
||||
}
|
||||
|
||||
trace_igbvf_wrn_io_addr_unknown(addr);
|
||||
|
||||
return HWADDR_MAX;
|
||||
}
|
||||
|
||||
static void igbvf_write_config(PCIDevice *dev, uint32_t addr, uint32_t val,
|
||||
int len)
|
||||
{
|
||||
trace_igbvf_write_config(addr, val, len);
|
||||
pci_default_write_config(dev, addr, val, len);
|
||||
}
|
||||
|
||||
static uint64_t igbvf_mmio_read(void *opaque, hwaddr addr, unsigned size)
|
||||
{
|
||||
PCIDevice *vf = PCI_DEVICE(opaque);
|
||||
PCIDevice *pf = pcie_sriov_get_pf(vf);
|
||||
|
||||
addr = vf_to_pf_addr(addr, pcie_sriov_vf_number(vf), false);
|
||||
return addr == HWADDR_MAX ? 0 : igb_mmio_read(pf, addr, size);
|
||||
}
|
||||
|
||||
static void igbvf_mmio_write(void *opaque, hwaddr addr, uint64_t val,
|
||||
unsigned size)
|
||||
{
|
||||
PCIDevice *vf = PCI_DEVICE(opaque);
|
||||
PCIDevice *pf = pcie_sriov_get_pf(vf);
|
||||
|
||||
addr = vf_to_pf_addr(addr, pcie_sriov_vf_number(vf), true);
|
||||
if (addr != HWADDR_MAX) {
|
||||
igb_mmio_write(pf, addr, val, size);
|
||||
}
|
||||
}
|
||||
|
||||
static const MemoryRegionOps mmio_ops = {
|
||||
.read = igbvf_mmio_read,
|
||||
.write = igbvf_mmio_write,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
.impl = {
|
||||
.min_access_size = 4,
|
||||
.max_access_size = 4,
|
||||
},
|
||||
};
|
||||
|
||||
static void igbvf_pci_realize(PCIDevice *dev, Error **errp)
|
||||
{
|
||||
IgbVfState *s = IGBVF(dev);
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
dev->config_write = igbvf_write_config;
|
||||
|
||||
memory_region_init_io(&s->mmio, OBJECT(dev), &mmio_ops, s, "igbvf-mmio",
|
||||
IGBVF_MMIO_SIZE);
|
||||
pcie_sriov_vf_register_bar(dev, IGBVF_MMIO_BAR_IDX, &s->mmio);
|
||||
|
||||
memory_region_init(&s->msix, OBJECT(dev), "igbvf-msix", IGBVF_MSIX_SIZE);
|
||||
pcie_sriov_vf_register_bar(dev, IGBVF_MSIX_BAR_IDX, &s->msix);
|
||||
|
||||
ret = msix_init(dev, IGBVF_MSIX_VEC_NUM, &s->msix, IGBVF_MSIX_BAR_IDX, 0,
|
||||
&s->msix, IGBVF_MSIX_BAR_IDX, 0x2000, 0x70, errp);
|
||||
if (ret) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < IGBVF_MSIX_VEC_NUM; i++) {
|
||||
msix_vector_use(dev, i);
|
||||
}
|
||||
|
||||
if (pcie_endpoint_cap_init(dev, 0xa0) < 0) {
|
||||
hw_error("Failed to initialize PCIe capability");
|
||||
}
|
||||
|
||||
if (pcie_aer_init(dev, 1, 0x100, 0x40, errp) < 0) {
|
||||
hw_error("Failed to initialize AER capability");
|
||||
}
|
||||
|
||||
pcie_ari_init(dev, 0x150, 1);
|
||||
}
|
||||
|
||||
static void igbvf_pci_uninit(PCIDevice *dev)
|
||||
{
|
||||
IgbVfState *s = IGBVF(dev);
|
||||
|
||||
pcie_aer_exit(dev);
|
||||
pcie_cap_exit(dev);
|
||||
msix_unuse_all_vectors(dev);
|
||||
msix_uninit(dev, &s->msix, &s->msix);
|
||||
}
|
||||
|
||||
static void igbvf_class_init(ObjectClass *class, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(class);
|
||||
PCIDeviceClass *c = PCI_DEVICE_CLASS(class);
|
||||
|
||||
c->realize = igbvf_pci_realize;
|
||||
c->exit = igbvf_pci_uninit;
|
||||
c->vendor_id = PCI_VENDOR_ID_INTEL;
|
||||
c->device_id = E1000_DEV_ID_82576_VF;
|
||||
c->revision = 1;
|
||||
c->class_id = PCI_CLASS_NETWORK_ETHERNET;
|
||||
|
||||
dc->desc = "Intel 82576 Virtual Function";
|
||||
dc->user_creatable = false;
|
||||
|
||||
set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
|
||||
}
|
||||
|
||||
static const TypeInfo igbvf_info = {
|
||||
.name = TYPE_IGBVF,
|
||||
.parent = TYPE_PCI_DEVICE,
|
||||
.instance_size = sizeof(IgbVfState),
|
||||
.class_init = igbvf_class_init,
|
||||
.interfaces = (InterfaceInfo[]) {
|
||||
{ INTERFACE_PCIE_DEVICE },
|
||||
{ }
|
||||
},
|
||||
};
|
||||
|
||||
static void igb_register_types(void)
|
||||
{
|
||||
type_register_static(&igbvf_info);
|
||||
}
|
||||
|
||||
type_init(igb_register_types)
|
||||
@@ -10,6 +10,8 @@ softmmu_ss.add(when: 'CONFIG_PCNET_COMMON', if_true: files('pcnet.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_E1000_PCI', if_true: files('e1000.c', 'e1000x_common.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_E1000E_PCI_EXPRESS', if_true: files('net_tx_pkt.c', 'net_rx_pkt.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_E1000E_PCI_EXPRESS', if_true: files('e1000e.c', 'e1000e_core.c', 'e1000x_common.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_IGB_PCI_EXPRESS', if_true: files('net_tx_pkt.c', 'net_rx_pkt.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_IGB_PCI_EXPRESS', if_true: files('igb.c', 'igbvf.c', 'igb_core.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_RTL8139_PCI', if_true: files('rtl8139.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_TULIP', if_true: files('tulip.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_VMXNET3_PCI', if_true: files('net_tx_pkt.c', 'net_rx_pkt.c'))
|
||||
|
||||
@@ -270,6 +270,38 @@ e1000e_msix_use_vector_fail(uint32_t vec, int32_t res) "Failed to use MSI-X vect
|
||||
e1000e_mac_set_permanent(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4, uint8_t b5) "Set permanent MAC: %02x:%02x:%02x:%02x:%02x:%02x"
|
||||
e1000e_cfg_support_virtio(bool support) "Virtio header supported: %d"
|
||||
|
||||
# igb.c
|
||||
igb_write_config(uint32_t address, uint32_t val, int len) "CONFIG write 0x%"PRIx32", value: 0x%"PRIx32", len: %"PRId32
|
||||
igbvf_write_config(uint32_t address, uint32_t val, int len) "CONFIG write 0x%"PRIx32", value: 0x%"PRIx32", len: %"PRId32
|
||||
|
||||
# igb_core.c
|
||||
igb_core_mdic_read(uint32_t addr, uint32_t data) "MDIC READ: PHY[%u] = 0x%x"
|
||||
igb_core_mdic_read_unhandled(uint32_t addr) "MDIC READ: PHY[%u] UNHANDLED"
|
||||
igb_core_mdic_write(uint32_t addr, uint32_t data) "MDIC WRITE: PHY[%u] = 0x%x"
|
||||
igb_core_mdic_write_unhandled(uint32_t addr) "MDIC WRITE: PHY[%u] UNHANDLED"
|
||||
|
||||
igb_rx_desc_buff_size(uint32_t b) "buffer size: %u"
|
||||
igb_rx_desc_buff_write(uint64_t addr, uint16_t offset, const void* source, uint32_t len) "addr: 0x%"PRIx64", offset: %u, from: %p, length: %u"
|
||||
|
||||
igb_rx_metadata_rss(uint32_t rss) "RSS data: 0x%X"
|
||||
|
||||
igb_irq_icr_clear_gpie_nsicr(void) "Clearing ICR on read due to GPIE.NSICR enabled"
|
||||
igb_irq_icr_write(uint32_t bits, uint32_t old_icr, uint32_t new_icr) "Clearing ICR bits 0x%x: 0x%x --> 0x%x"
|
||||
igb_irq_set_iam(uint32_t icr) "Update IAM: 0x%x"
|
||||
igb_irq_read_iam(uint32_t icr) "Current IAM: 0x%x"
|
||||
igb_irq_write_eics(uint32_t val, bool msix) "Update EICS: 0x%x MSI-X: %d"
|
||||
igb_irq_write_eims(uint32_t val, bool msix) "Update EIMS: 0x%x MSI-X: %d"
|
||||
igb_irq_write_eimc(uint32_t val, uint32_t eims, bool msix) "Update EIMC: 0x%x EIMS: 0x%x MSI-X: %d"
|
||||
igb_irq_write_eiac(uint32_t val) "Update EIAC: 0x%x"
|
||||
igb_irq_write_eiam(uint32_t val, bool msix) "Update EIAM: 0x%x MSI-X: %d"
|
||||
igb_irq_write_eicr(uint32_t val, bool msix) "Update EICR: 0x%x MSI-X: %d"
|
||||
igb_irq_eitr_set(uint32_t eitr_num, uint32_t val) "EITR[%u] = 0x%x"
|
||||
igb_set_pfmailbox(uint32_t vf_num, uint32_t val) "PFMailbox[%d]: 0x%x"
|
||||
igb_set_vfmailbox(uint32_t vf_num, uint32_t val) "VFMailbox[%d]: 0x%x"
|
||||
|
||||
# igbvf.c
|
||||
igbvf_wrn_io_addr_unknown(uint64_t addr) "IO unknown register 0x%"PRIx64
|
||||
|
||||
# spapr_llan.c
|
||||
spapr_vlan_get_rx_bd_from_pool_found(int pool, int32_t count, uint32_t rx_bufs) "pool=%d count=%"PRId32" rxbufs=%"PRIu32
|
||||
spapr_vlan_get_rx_bd_from_page(int buf_ptr, uint64_t bd) "use_buf_ptr=%d bd=0x%016"PRIx64
|
||||
|
||||
Reference in New Issue
Block a user