2007-04-02 14:35:34 +02:00
|
|
|
/*
|
|
|
|
* QEMU i8255x (PRO100) emulation
|
|
|
|
*
|
2011-04-30 22:40:04 +02:00
|
|
|
* Copyright (C) 2006-2011 Stefan Weil
|
2007-04-02 14:35:34 +02:00
|
|
|
*
|
|
|
|
* Portions of the code are copies from grub / etherboot eepro100.c
|
|
|
|
* and linux e100.c.
|
|
|
|
*
|
2010-03-02 22:37:47 +01:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2007-04-02 14:35:34 +02:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2010-03-02 22:37:47 +01:00
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) version 3 or any later version.
|
2007-04-02 14:35:34 +02:00
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2010-03-02 22:37:47 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2007-04-02 14:35:34 +02:00
|
|
|
*
|
|
|
|
* Tested features (i82559):
|
2011-04-30 22:40:08 +02:00
|
|
|
* PXE boot (i386 guest, i386 / mips / mipsel / ppc host) ok
|
2007-04-02 14:35:34 +02:00
|
|
|
* Linux networking (i386) ok
|
|
|
|
*
|
|
|
|
* Untested:
|
|
|
|
* Windows networking
|
|
|
|
*
|
|
|
|
* References:
|
|
|
|
*
|
|
|
|
* Intel 8255x 10/100 Mbps Ethernet Controller Family
|
|
|
|
* Open Source Software Developer Manual
|
2010-03-02 22:37:46 +01:00
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* * PHY emulation should be separated from nic emulation.
|
|
|
|
* Most nic emulations could share the same phy code.
|
|
|
|
* * i82550 is untested. It is programmed like the i82559.
|
|
|
|
* * i82562 is untested. It is programmed like the i82559.
|
|
|
|
* * Power management (i82558 and later) is not implemented.
|
|
|
|
* * Wake-on-LAN is not implemented.
|
2007-04-02 14:35:34 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:11 +01:00
|
|
|
#include "qemu/osdep.h"
|
2018-06-25 14:42:26 +02:00
|
|
|
#include "qemu/units.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/pci/pci.h"
|
2019-08-12 07:23:51 +02:00
|
|
|
#include "hw/qdev-properties.h"
|
2019-08-12 07:23:45 +02:00
|
|
|
#include "migration/vmstate.h"
|
2012-10-24 08:43:34 +02:00
|
|
|
#include "net/net.h"
|
2017-12-15 19:41:46 +01:00
|
|
|
#include "net/eth.h"
|
2013-02-05 17:06:20 +01:00
|
|
|
#include "hw/nvram/eeprom93xx.h"
|
2012-12-17 18:20:04 +01:00
|
|
|
#include "sysemu/sysemu.h"
|
|
|
|
#include "sysemu/dma.h"
|
2019-08-12 07:23:38 +02:00
|
|
|
#include "sysemu/reset.h"
|
2013-07-29 16:17:43 +02:00
|
|
|
#include "qemu/bitops.h"
|
2019-05-23 16:35:07 +02:00
|
|
|
#include "qemu/module.h"
|
2017-06-27 08:16:50 +02:00
|
|
|
#include "qapi/error.h"
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2011-04-30 22:40:07 +02:00
|
|
|
/* QEMU sends frames smaller than 60 bytes to ethernet nics.
|
|
|
|
* Such frames are rejected by real nics and their emulations.
|
|
|
|
* To avoid this behaviour, other nic emulations pad received
|
|
|
|
* frames. The following definition enables this padding for
|
|
|
|
* eepro100, too. We keep the define around in case it might
|
|
|
|
* become useful the future if the core networking is ever
|
|
|
|
* changed to pad short packets itself. */
|
|
|
|
#define CONFIG_PAD_RECEIVED_FRAMES
|
|
|
|
|
2009-09-19 12:11:36 +02:00
|
|
|
/* Debug EEPRO100 card. */
|
2010-03-02 22:37:41 +01:00
|
|
|
#if 0
|
|
|
|
# define DEBUG_EEPRO100
|
|
|
|
#endif
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
#ifdef DEBUG_EEPRO100
|
2009-05-13 19:53:17 +02:00
|
|
|
#define logout(fmt, ...) fprintf(stderr, "EE100\t%-24s" fmt, __func__, ## __VA_ARGS__)
|
2007-04-02 14:35:34 +02:00
|
|
|
#else
|
2009-05-13 19:53:17 +02:00
|
|
|
#define logout(fmt, ...) ((void)0)
|
2007-04-02 14:35:34 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Set flags to 0 to disable debug output. */
|
2009-09-19 12:11:36 +02:00
|
|
|
#define INT 1 /* interrupt related actions */
|
|
|
|
#define MDI 1 /* mdi related actions */
|
|
|
|
#define OTHER 1
|
|
|
|
#define RXTX 1
|
|
|
|
#define EEPROM 1 /* eeprom related actions */
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
#define TRACE(flag, command) ((flag) ? (command) : (void)0)
|
|
|
|
|
2009-09-23 17:42:42 +02:00
|
|
|
#define missing(text) fprintf(stderr, "eepro100: feature is missing in this emulation: " text "\n")
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
#define MAX_ETH_FRAME_SIZE 1514
|
|
|
|
|
|
|
|
/* This driver supports several different devices which are declared here. */
|
2009-09-19 13:02:09 +02:00
|
|
|
#define i82550 0x82550
|
2007-04-02 14:35:34 +02:00
|
|
|
#define i82551 0x82551
|
2009-09-19 13:02:09 +02:00
|
|
|
#define i82557A 0x82557a
|
2007-04-02 14:35:34 +02:00
|
|
|
#define i82557B 0x82557b
|
|
|
|
#define i82557C 0x82557c
|
2009-09-19 13:02:09 +02:00
|
|
|
#define i82558A 0x82558a
|
2007-04-02 14:35:34 +02:00
|
|
|
#define i82558B 0x82558b
|
2009-09-19 13:02:09 +02:00
|
|
|
#define i82559A 0x82559a
|
|
|
|
#define i82559B 0x82559b
|
2007-04-02 14:35:34 +02:00
|
|
|
#define i82559C 0x82559c
|
|
|
|
#define i82559ER 0x82559e
|
|
|
|
#define i82562 0x82562
|
2010-04-06 13:44:04 +02:00
|
|
|
#define i82801 0x82801
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2009-09-19 12:11:36 +02:00
|
|
|
/* Use 64 word EEPROM. TODO: could be a runtime option. */
|
2007-04-02 14:35:34 +02:00
|
|
|
#define EEPROM_SIZE 64
|
|
|
|
|
|
|
|
#define PCI_MEM_SIZE (4 * KiB)
|
|
|
|
#define PCI_IO_SIZE 64
|
|
|
|
#define PCI_FLASH_SIZE (128 * KiB)
|
|
|
|
|
|
|
|
#define BITS(n, m) (((0xffffffffU << (31 - n)) >> (31 - n + m)) << m)
|
|
|
|
|
|
|
|
/* The SCB accepts the following controls for the Tx and Rx units: */
|
|
|
|
#define CU_NOP 0x0000 /* No operation. */
|
|
|
|
#define CU_START 0x0010 /* CU start. */
|
|
|
|
#define CU_RESUME 0x0020 /* CU resume. */
|
|
|
|
#define CU_STATSADDR 0x0040 /* Load dump counters address. */
|
|
|
|
#define CU_SHOWSTATS 0x0050 /* Dump statistical counters. */
|
|
|
|
#define CU_CMD_BASE 0x0060 /* Load CU base address. */
|
|
|
|
#define CU_DUMPSTATS 0x0070 /* Dump and reset statistical counters. */
|
|
|
|
#define CU_SRESUME 0x00a0 /* CU static resume. */
|
|
|
|
|
|
|
|
#define RU_NOP 0x0000
|
|
|
|
#define RX_START 0x0001
|
|
|
|
#define RX_RESUME 0x0002
|
2010-03-02 22:37:53 +01:00
|
|
|
#define RU_ABORT 0x0004
|
2007-04-02 14:35:34 +02:00
|
|
|
#define RX_ADDR_LOAD 0x0006
|
|
|
|
#define RX_RESUMENR 0x0007
|
|
|
|
#define INT_MASK 0x0100
|
|
|
|
#define DRVR_INT 0x0200 /* Driver generated interrupt. */
|
|
|
|
|
2010-04-06 13:44:03 +02:00
|
|
|
typedef struct {
|
2011-12-08 04:34:16 +01:00
|
|
|
const char *name;
|
|
|
|
const char *desc;
|
2011-12-04 19:22:06 +01:00
|
|
|
uint16_t device_id;
|
|
|
|
uint8_t revision;
|
|
|
|
uint16_t subsystem_vendor_id;
|
|
|
|
uint16_t subsystem_id;
|
|
|
|
|
2010-04-06 13:44:03 +02:00
|
|
|
uint32_t device;
|
|
|
|
uint8_t stats_size;
|
|
|
|
bool has_extended_tcb_support;
|
|
|
|
bool power_management;
|
|
|
|
} E100PCIDeviceInfo;
|
|
|
|
|
2007-04-02 14:35:34 +02:00
|
|
|
/* Offsets to the various registers.
|
|
|
|
All accesses need not be longword aligned. */
|
2011-04-30 22:40:08 +02:00
|
|
|
typedef enum {
|
2010-03-02 22:37:42 +01:00
|
|
|
SCBStatus = 0, /* Status Word. */
|
2007-04-02 14:35:34 +02:00
|
|
|
SCBAck = 1,
|
|
|
|
SCBCmd = 2, /* Rx/Command Unit command and status. */
|
|
|
|
SCBIntmask = 3,
|
|
|
|
SCBPointer = 4, /* General purpose pointer. */
|
|
|
|
SCBPort = 8, /* Misc. commands and operands. */
|
2010-03-02 22:37:42 +01:00
|
|
|
SCBflash = 12, /* Flash memory control. */
|
|
|
|
SCBeeprom = 14, /* EEPROM control. */
|
2007-04-02 14:35:34 +02:00
|
|
|
SCBCtrlMDI = 16, /* MDI interface control. */
|
|
|
|
SCBEarlyRx = 20, /* Early receive byte count. */
|
2010-03-02 22:37:42 +01:00
|
|
|
SCBFlow = 24, /* Flow Control. */
|
|
|
|
SCBpmdr = 27, /* Power Management Driver. */
|
|
|
|
SCBgctrl = 28, /* General Control. */
|
|
|
|
SCBgstat = 29, /* General Status. */
|
2011-04-30 22:40:08 +02:00
|
|
|
} E100RegisterOffset;
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
/* A speedo3 transmit buffer descriptor with two buffers... */
|
|
|
|
typedef struct {
|
|
|
|
uint16_t status;
|
|
|
|
uint16_t command;
|
|
|
|
uint32_t link; /* void * */
|
2009-12-20 16:52:24 +01:00
|
|
|
uint32_t tbd_array_addr; /* transmit buffer descriptor array address. */
|
2007-04-02 14:35:34 +02:00
|
|
|
uint16_t tcb_bytes; /* transmit command block byte count (in lower 14 bits */
|
|
|
|
uint8_t tx_threshold; /* transmit threshold */
|
|
|
|
uint8_t tbd_count; /* TBD number */
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
|
|
|
/* This constitutes two "TBD" entries: hdr and data */
|
|
|
|
uint32_t tx_buf_addr0; /* void *, header of frame to be transmitted. */
|
|
|
|
int32_t tx_buf_size0; /* Length of Tx hdr. */
|
|
|
|
uint32_t tx_buf_addr1; /* void *, data to be transmitted. */
|
|
|
|
int32_t tx_buf_size1; /* Length of Tx data. */
|
|
|
|
#endif
|
2009-10-01 23:12:16 +02:00
|
|
|
} eepro100_tx_t;
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
/* Receive frame descriptor. */
|
|
|
|
typedef struct {
|
|
|
|
int16_t status;
|
|
|
|
uint16_t command;
|
|
|
|
uint32_t link; /* struct RxFD * */
|
|
|
|
uint32_t rx_buf_addr; /* void * */
|
|
|
|
uint16_t count;
|
|
|
|
uint16_t size;
|
2011-04-30 22:40:06 +02:00
|
|
|
/* Ethernet frame data follows. */
|
2009-10-01 23:12:16 +02:00
|
|
|
} eepro100_rx_t;
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2010-03-02 22:37:49 +01:00
|
|
|
typedef enum {
|
|
|
|
COMMAND_EL = BIT(15),
|
|
|
|
COMMAND_S = BIT(14),
|
|
|
|
COMMAND_I = BIT(13),
|
|
|
|
COMMAND_NC = BIT(4),
|
|
|
|
COMMAND_SF = BIT(3),
|
|
|
|
COMMAND_CMD = BITS(2, 0),
|
|
|
|
} scb_command_bit;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
STATUS_C = BIT(15),
|
|
|
|
STATUS_OK = BIT(13),
|
|
|
|
} scb_status_bit;
|
|
|
|
|
2007-04-02 14:35:34 +02:00
|
|
|
typedef struct {
|
|
|
|
uint32_t tx_good_frames, tx_max_collisions, tx_late_collisions,
|
2010-03-02 22:37:55 +01:00
|
|
|
tx_underruns, tx_lost_crs, tx_deferred, tx_single_collisions,
|
|
|
|
tx_multiple_collisions, tx_total_collisions;
|
2007-04-02 14:35:34 +02:00
|
|
|
uint32_t rx_good_frames, rx_crc_errors, rx_alignment_errors,
|
2010-03-02 22:37:55 +01:00
|
|
|
rx_resource_errors, rx_overrun_errors, rx_cdt_errors,
|
|
|
|
rx_short_frame_errors;
|
2007-04-02 14:35:34 +02:00
|
|
|
uint32_t fc_xmt_pause, fc_rcv_pause, fc_rcv_unsupported;
|
|
|
|
uint16_t xmt_tco_frames, rcv_tco_frames;
|
2009-10-30 13:36:21 +01:00
|
|
|
/* TODO: i82559 has six reserved statistics but a total of 24 dwords. */
|
|
|
|
uint32_t reserved[4];
|
2009-10-01 23:12:16 +02:00
|
|
|
} eepro100_stats_t;
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
cu_idle = 0,
|
|
|
|
cu_suspended = 1,
|
|
|
|
cu_active = 2,
|
|
|
|
cu_lpq_active = 2,
|
|
|
|
cu_hqp_active = 3
|
2009-10-01 23:12:16 +02:00
|
|
|
} cu_state_t;
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ru_idle = 0,
|
|
|
|
ru_suspended = 1,
|
|
|
|
ru_no_resources = 2,
|
|
|
|
ru_ready = 4
|
2009-10-01 23:12:16 +02:00
|
|
|
} ru_state_t;
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
typedef struct {
|
2009-08-24 18:42:37 +02:00
|
|
|
PCIDevice dev;
|
2010-09-29 21:59:55 +02:00
|
|
|
/* Hash register (multicast mask array, multiple individual addresses). */
|
|
|
|
uint8_t mult[8];
|
2011-08-08 15:09:09 +02:00
|
|
|
MemoryRegion mmio_bar;
|
|
|
|
MemoryRegion io_bar;
|
|
|
|
MemoryRegion flash_bar;
|
2009-11-25 19:49:16 +01:00
|
|
|
NICState *nic;
|
2009-10-21 15:25:36 +02:00
|
|
|
NICConf conf;
|
2007-04-02 14:35:34 +02:00
|
|
|
uint8_t scb_stat; /* SCB stat/ack byte */
|
|
|
|
uint8_t int_stat; /* PCI interrupt status */
|
2009-10-09 19:49:58 +02:00
|
|
|
/* region must not be saved by nic_save. */
|
2007-04-02 14:35:34 +02:00
|
|
|
uint16_t mdimem[32];
|
2009-10-01 23:12:16 +02:00
|
|
|
eeprom_t *eeprom;
|
2007-04-02 14:35:34 +02:00
|
|
|
uint32_t device; /* device variant */
|
|
|
|
/* (cu_base + cu_offset) address the next command block in the command block list. */
|
|
|
|
uint32_t cu_base; /* CU base address */
|
|
|
|
uint32_t cu_offset; /* CU address offset */
|
|
|
|
/* (ru_base + ru_offset) address the RFD in the Receive Frame Area. */
|
|
|
|
uint32_t ru_base; /* RU base address */
|
|
|
|
uint32_t ru_offset; /* RU address offset */
|
2009-10-01 23:12:16 +02:00
|
|
|
uint32_t statsaddr; /* pointer to eepro100_stats_t */
|
2009-10-30 13:36:21 +01:00
|
|
|
|
2009-12-20 16:52:22 +01:00
|
|
|
/* Temporary status information (no need to save these values),
|
|
|
|
* used while processing CU commands. */
|
|
|
|
eepro100_tx_t tx; /* transmit buffer descriptor */
|
|
|
|
uint32_t cb_address; /* = cu_base + cu_offset */
|
|
|
|
|
2009-10-30 13:36:21 +01:00
|
|
|
/* Statistical counters. Also used for wake-up packet (i82559). */
|
|
|
|
eepro100_stats_t statistics;
|
|
|
|
|
2011-04-30 22:40:08 +02:00
|
|
|
/* Data in mem is always in the byte order of the controller (le).
|
|
|
|
* It must be dword aligned to allow direct access to 32 bit values. */
|
2011-11-29 09:52:38 +01:00
|
|
|
uint8_t mem[PCI_MEM_SIZE] __attribute__((aligned(8)));
|
2011-04-30 22:40:08 +02:00
|
|
|
|
2007-04-02 14:35:34 +02:00
|
|
|
/* Configuration bytes. */
|
|
|
|
uint8_t configuration[22];
|
|
|
|
|
2009-10-19 15:37:57 +02:00
|
|
|
/* vmstate for each particular nic */
|
|
|
|
VMStateDescription *vmstate;
|
2009-10-30 13:36:21 +01:00
|
|
|
|
|
|
|
/* Quasi static device properties (no need to save them). */
|
|
|
|
uint16_t stats_size;
|
|
|
|
bool has_extended_tcb_support;
|
2007-04-02 14:35:34 +02:00
|
|
|
} EEPRO100State;
|
|
|
|
|
2010-03-02 22:37:43 +01:00
|
|
|
/* Word indices in EEPROM. */
|
|
|
|
typedef enum {
|
|
|
|
EEPROM_CNFG_MDIX = 0x03,
|
|
|
|
EEPROM_ID = 0x05,
|
|
|
|
EEPROM_PHY_ID = 0x06,
|
|
|
|
EEPROM_VENDOR_ID = 0x0c,
|
|
|
|
EEPROM_CONFIG_ASF = 0x0d,
|
|
|
|
EEPROM_DEVICE_ID = 0x23,
|
|
|
|
EEPROM_SMBUS_ADDR = 0x90,
|
|
|
|
} EEPROMOffset;
|
|
|
|
|
2010-03-02 22:37:51 +01:00
|
|
|
/* Bit values for EEPROM ID word. */
|
|
|
|
typedef enum {
|
|
|
|
EEPROM_ID_MDM = BIT(0), /* Modem */
|
|
|
|
EEPROM_ID_STB = BIT(1), /* Standby Enable */
|
|
|
|
EEPROM_ID_WMR = BIT(2), /* ??? */
|
|
|
|
EEPROM_ID_WOL = BIT(5), /* Wake on LAN */
|
|
|
|
EEPROM_ID_DPD = BIT(6), /* Deep Power Down */
|
|
|
|
EEPROM_ID_ALT = BIT(7), /* */
|
|
|
|
/* BITS(10, 8) device revision */
|
|
|
|
EEPROM_ID_BD = BIT(11), /* boot disable */
|
|
|
|
EEPROM_ID_ID = BIT(13), /* id bit */
|
|
|
|
/* BITS(15, 14) signature */
|
|
|
|
EEPROM_ID_VALID = BIT(14), /* signature for valid eeprom */
|
|
|
|
} eeprom_id_bit;
|
|
|
|
|
2007-04-02 14:35:34 +02:00
|
|
|
/* Default values for MDI (PHY) registers */
|
|
|
|
static const uint16_t eepro100_mdi_default[] = {
|
|
|
|
/* MDI Registers 0 - 6, 7 */
|
|
|
|
0x3000, 0x780d, 0x02a8, 0x0154, 0x05e1, 0x0000, 0x0000, 0x0000,
|
|
|
|
/* MDI Registers 8 - 15 */
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
/* MDI Registers 16 - 31 */
|
|
|
|
0x0003, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Readonly mask for MDI (PHY) registers */
|
|
|
|
static const uint16_t eepro100_mdi_mask[] = {
|
|
|
|
0x0000, 0xffff, 0xffff, 0xffff, 0xc01f, 0xffff, 0xffff, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0fff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
|
|
|
0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
};
|
|
|
|
|
2011-12-04 19:22:06 +01:00
|
|
|
static E100PCIDeviceInfo *eepro100_get_class(EEPRO100State *s);
|
|
|
|
|
2011-04-30 22:40:08 +02:00
|
|
|
/* Read a 16 bit control/status (CSR) register. */
|
|
|
|
static uint16_t e100_read_reg2(EEPRO100State *s, E100RegisterOffset addr)
|
|
|
|
{
|
|
|
|
assert(!((uintptr_t)&s->mem[addr] & 1));
|
2016-06-16 19:17:22 +02:00
|
|
|
return lduw_le_p(&s->mem[addr]);
|
2011-04-30 22:40:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read a 32 bit control/status (CSR) register. */
|
|
|
|
static uint32_t e100_read_reg4(EEPRO100State *s, E100RegisterOffset addr)
|
|
|
|
{
|
|
|
|
assert(!((uintptr_t)&s->mem[addr] & 3));
|
2016-06-16 19:17:22 +02:00
|
|
|
return ldl_le_p(&s->mem[addr]);
|
2011-04-30 22:40:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write a 16 bit control/status (CSR) register. */
|
|
|
|
static void e100_write_reg2(EEPRO100State *s, E100RegisterOffset addr,
|
|
|
|
uint16_t val)
|
|
|
|
{
|
|
|
|
assert(!((uintptr_t)&s->mem[addr] & 1));
|
2016-06-16 19:17:22 +02:00
|
|
|
stw_le_p(&s->mem[addr], val);
|
2011-04-30 22:40:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read a 32 bit control/status (CSR) register. */
|
|
|
|
static void e100_write_reg4(EEPRO100State *s, E100RegisterOffset addr,
|
|
|
|
uint32_t val)
|
|
|
|
{
|
|
|
|
assert(!((uintptr_t)&s->mem[addr] & 3));
|
2016-06-16 19:17:22 +02:00
|
|
|
stl_le_p(&s->mem[addr], val);
|
2011-04-30 22:40:08 +02:00
|
|
|
}
|
|
|
|
|
2007-04-02 14:35:34 +02:00
|
|
|
#if defined(DEBUG_EEPRO100)
|
|
|
|
static const char *nic_dump(const uint8_t * buf, unsigned size)
|
|
|
|
{
|
|
|
|
static char dump[3 * 16 + 1];
|
|
|
|
char *p = &dump[0];
|
2009-09-19 12:11:36 +02:00
|
|
|
if (size > 16) {
|
2007-04-02 14:35:34 +02:00
|
|
|
size = 16;
|
2009-09-19 12:11:36 +02:00
|
|
|
}
|
2007-04-02 14:35:34 +02:00
|
|
|
while (size-- > 0) {
|
|
|
|
p += sprintf(p, " %02x", *buf++);
|
|
|
|
}
|
|
|
|
return dump;
|
|
|
|
}
|
|
|
|
#endif /* DEBUG_EEPRO100 */
|
|
|
|
|
|
|
|
enum scb_stat_ack {
|
|
|
|
stat_ack_not_ours = 0x00,
|
|
|
|
stat_ack_sw_gen = 0x04,
|
|
|
|
stat_ack_rnr = 0x10,
|
|
|
|
stat_ack_cu_idle = 0x20,
|
|
|
|
stat_ack_frame_rx = 0x40,
|
|
|
|
stat_ack_cu_cmd_done = 0x80,
|
|
|
|
stat_ack_not_present = 0xFF,
|
|
|
|
stat_ack_rx = (stat_ack_sw_gen | stat_ack_rnr | stat_ack_frame_rx),
|
|
|
|
stat_ack_tx = (stat_ack_cu_idle | stat_ack_cu_cmd_done),
|
|
|
|
};
|
|
|
|
|
|
|
|
static void disable_interrupt(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
if (s->int_stat) {
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(INT, logout("interrupt disabled\n"));
|
2013-10-07 09:36:39 +02:00
|
|
|
pci_irq_deassert(&s->dev);
|
2007-04-02 14:35:34 +02:00
|
|
|
s->int_stat = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void enable_interrupt(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
if (!s->int_stat) {
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(INT, logout("interrupt enabled\n"));
|
2013-10-07 09:36:39 +02:00
|
|
|
pci_irq_assert(&s->dev);
|
2007-04-02 14:35:34 +02:00
|
|
|
s->int_stat = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eepro100_acknowledge(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
s->scb_stat &= ~s->mem[SCBAck];
|
|
|
|
s->mem[SCBAck] = s->scb_stat;
|
|
|
|
if (s->scb_stat == 0) {
|
|
|
|
disable_interrupt(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-02 22:37:52 +01:00
|
|
|
static void eepro100_interrupt(EEPRO100State * s, uint8_t status)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
|
|
|
uint8_t mask = ~s->mem[SCBIntmask];
|
2010-03-02 22:37:52 +01:00
|
|
|
s->mem[SCBAck] |= status;
|
|
|
|
status = s->scb_stat = s->mem[SCBAck];
|
|
|
|
status &= (mask | 0x0f);
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
|
|
|
status &= (~s->mem[SCBIntmask] | 0x0xf);
|
|
|
|
#endif
|
2010-03-02 22:37:52 +01:00
|
|
|
if (status && (mask & 0x01)) {
|
2007-04-02 14:35:34 +02:00
|
|
|
/* SCB mask and SCB Bit M do not disable interrupt. */
|
|
|
|
enable_interrupt(s);
|
|
|
|
} else if (s->int_stat) {
|
|
|
|
disable_interrupt(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eepro100_cx_interrupt(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
/* CU completed action command. */
|
|
|
|
/* Transmit not ok (82557 only, not in emulation). */
|
|
|
|
eepro100_interrupt(s, 0x80);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eepro100_cna_interrupt(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
/* CU left the active state. */
|
|
|
|
eepro100_interrupt(s, 0x20);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eepro100_fr_interrupt(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
/* RU received a complete frame. */
|
|
|
|
eepro100_interrupt(s, 0x40);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eepro100_rnr_interrupt(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
/* RU is not ready. */
|
|
|
|
eepro100_interrupt(s, 0x10);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eepro100_mdi_interrupt(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
/* MDI completed read or write cycle. */
|
|
|
|
eepro100_interrupt(s, 0x08);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eepro100_swi_interrupt(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
/* Software has requested an interrupt. */
|
|
|
|
eepro100_interrupt(s, 0x04);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static void eepro100_fcp_interrupt(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
/* Flow control pause interrupt (82558 and later). */
|
|
|
|
eepro100_interrupt(s, 0x01);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-06-27 08:16:50 +02:00
|
|
|
static void e100_pci_reset(EEPRO100State *s, Error **errp)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
2011-12-04 19:22:06 +01:00
|
|
|
E100PCIDeviceInfo *info = eepro100_get_class(s);
|
2007-04-02 14:35:34 +02:00
|
|
|
uint32_t device = s->device;
|
2009-08-24 18:42:37 +02:00
|
|
|
uint8_t *pci_conf = s->dev.config;
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("%p\n", s));
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
/* PCI Status */
|
2010-04-06 13:44:07 +02:00
|
|
|
pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
|
|
|
|
PCI_STATUS_FAST_BACK);
|
2007-04-02 14:35:34 +02:00
|
|
|
/* PCI Latency Timer */
|
2010-03-03 13:00:21 +01:00
|
|
|
pci_set_byte(pci_conf + PCI_LATENCY_TIMER, 0x20); /* latency timer = 32 clocks */
|
2010-04-06 13:44:07 +02:00
|
|
|
/* Capability Pointer is set by PCI framework. */
|
2010-04-06 13:44:09 +02:00
|
|
|
/* Interrupt Line */
|
|
|
|
/* Interrupt Pin */
|
|
|
|
pci_set_byte(pci_conf + PCI_INTERRUPT_PIN, 1); /* interrupt pin A */
|
2007-04-02 14:35:34 +02:00
|
|
|
/* Minimum Grant */
|
2010-03-03 13:00:21 +01:00
|
|
|
pci_set_byte(pci_conf + PCI_MIN_GNT, 0x08);
|
2007-04-02 14:35:34 +02:00
|
|
|
/* Maximum Latency */
|
2010-03-03 13:00:21 +01:00
|
|
|
pci_set_byte(pci_conf + PCI_MAX_LAT, 0x18);
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2011-12-04 19:22:06 +01:00
|
|
|
s->stats_size = info->stats_size;
|
|
|
|
s->has_extended_tcb_support = info->has_extended_tcb_support;
|
2010-04-06 13:44:03 +02:00
|
|
|
|
2007-04-02 14:35:34 +02:00
|
|
|
switch (device) {
|
2009-10-30 13:36:21 +01:00
|
|
|
case i82550:
|
2007-04-02 14:35:34 +02:00
|
|
|
case i82551:
|
2009-10-30 13:36:21 +01:00
|
|
|
case i82557A:
|
2007-04-02 14:35:34 +02:00
|
|
|
case i82557B:
|
|
|
|
case i82557C:
|
2009-10-30 13:36:21 +01:00
|
|
|
case i82558A:
|
2007-04-02 14:35:34 +02:00
|
|
|
case i82558B:
|
2009-10-30 13:36:21 +01:00
|
|
|
case i82559A:
|
|
|
|
case i82559B:
|
2010-04-06 13:44:03 +02:00
|
|
|
case i82559ER:
|
|
|
|
case i82562:
|
2010-04-06 13:44:04 +02:00
|
|
|
case i82801:
|
2007-04-02 14:35:34 +02:00
|
|
|
case i82559C:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
logout("Device %X is undefined!\n", device);
|
|
|
|
}
|
|
|
|
|
2010-04-06 13:44:05 +02:00
|
|
|
/* Standard TxCB. */
|
|
|
|
s->configuration[6] |= BIT(4);
|
|
|
|
|
2010-04-06 13:44:03 +02:00
|
|
|
/* Standard statistical counters. */
|
2009-10-30 13:36:21 +01:00
|
|
|
s->configuration[6] |= BIT(5);
|
|
|
|
|
|
|
|
if (s->stats_size == 80) {
|
|
|
|
/* TODO: check TCO Statistical Counters bit. Documentation not clear. */
|
|
|
|
if (s->configuration[6] & BIT(2)) {
|
|
|
|
/* TCO statistical counters. */
|
|
|
|
assert(s->configuration[6] & BIT(5));
|
|
|
|
} else {
|
|
|
|
if (s->configuration[6] & BIT(5)) {
|
|
|
|
/* No extended statistical counters, i82557 compatible. */
|
|
|
|
s->stats_size = 64;
|
|
|
|
} else {
|
|
|
|
/* i82558 compatible. */
|
|
|
|
s->stats_size = 76;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (s->configuration[6] & BIT(5)) {
|
|
|
|
/* No extended statistical counters. */
|
|
|
|
s->stats_size = 64;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(s->stats_size > 0 && s->stats_size <= sizeof(s->statistics));
|
|
|
|
|
2011-12-04 19:22:06 +01:00
|
|
|
if (info->power_management) {
|
2009-10-30 13:36:21 +01:00
|
|
|
/* Power Management Capabilities */
|
2010-04-07 09:55:47 +02:00
|
|
|
int cfg_offset = 0xdc;
|
2010-09-06 09:46:16 +02:00
|
|
|
int r = pci_add_capability(&s->dev, PCI_CAP_ID_PM,
|
2017-06-27 08:16:50 +02:00
|
|
|
cfg_offset, PCI_PM_SIZEOF,
|
|
|
|
errp);
|
|
|
|
if (r < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-07 09:55:47 +02:00
|
|
|
pci_set_word(pci_conf + cfg_offset + PCI_PM_PMC, 0x7e21);
|
2010-04-06 13:44:07 +02:00
|
|
|
#if 0 /* TODO: replace dummy code for power management emulation. */
|
2010-04-07 09:55:47 +02:00
|
|
|
/* TODO: Power Management Control / Status. */
|
|
|
|
pci_set_word(pci_conf + cfg_offset + PCI_PM_CTRL, 0x0000);
|
|
|
|
/* TODO: Ethernet Power Consumption Registers (i82559 and later). */
|
|
|
|
pci_set_byte(pci_conf + cfg_offset + PCI_PM_PPB_EXTENSIONS, 0x0000);
|
2010-04-06 13:44:07 +02:00
|
|
|
#endif
|
2009-10-30 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#if EEPROM_SIZE > 0
|
2007-04-02 14:35:34 +02:00
|
|
|
if (device == i82557C || device == i82558B || device == i82559C) {
|
2010-03-02 22:37:59 +01:00
|
|
|
/*
|
|
|
|
TODO: get vendor id from EEPROM for i82557C or later.
|
|
|
|
TODO: get device id from EEPROM for i82557C or later.
|
|
|
|
TODO: status bit 4 can be disabled by EEPROM for i82558, i82559.
|
|
|
|
TODO: header type is determined by EEPROM for i82559.
|
|
|
|
TODO: get subsystem id from EEPROM for i82557C or later.
|
|
|
|
TODO: get subsystem vendor id from EEPROM for i82557C or later.
|
|
|
|
TODO: exp. rom baddr depends on a bit in EEPROM for i82558 or later.
|
|
|
|
TODO: capability pointer depends on EEPROM for i82558.
|
|
|
|
*/
|
2007-04-02 14:35:34 +02:00
|
|
|
logout("Get device id and revision from EEPROM!!!\n");
|
|
|
|
}
|
2009-10-30 13:36:21 +01:00
|
|
|
#endif /* EEPROM_SIZE > 0 */
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void nic_selective_reset(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
uint16_t *eeprom_contents = eeprom93xx_data(s->eeprom);
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
|
|
|
eeprom93xx_reset(s->eeprom);
|
|
|
|
#endif
|
2009-10-21 15:25:36 +02:00
|
|
|
memcpy(eeprom_contents, s->conf.macaddr.a, 6);
|
2010-03-02 22:37:51 +01:00
|
|
|
eeprom_contents[EEPROM_ID] = EEPROM_ID_VALID;
|
2009-09-12 15:42:01 +02:00
|
|
|
if (s->device == i82557B || s->device == i82557C)
|
|
|
|
eeprom_contents[5] = 0x0100;
|
2010-03-02 22:37:43 +01:00
|
|
|
eeprom_contents[EEPROM_PHY_ID] = 1;
|
2007-04-02 14:35:34 +02:00
|
|
|
uint16_t sum = 0;
|
|
|
|
for (i = 0; i < EEPROM_SIZE - 1; i++) {
|
|
|
|
sum += eeprom_contents[i];
|
|
|
|
}
|
|
|
|
eeprom_contents[EEPROM_SIZE - 1] = 0xbaba - sum;
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(EEPROM, logout("checksum=0x%04x\n", eeprom_contents[EEPROM_SIZE - 1]));
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
memset(s->mem, 0, sizeof(s->mem));
|
2011-04-30 22:40:08 +02:00
|
|
|
e100_write_reg4(s, SCBCtrlMDI, BIT(21));
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
assert(sizeof(s->mdimem) == sizeof(eepro100_mdi_default));
|
|
|
|
memcpy(&s->mdimem[0], &eepro100_mdi_default[0], sizeof(s->mdimem));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nic_reset(void *opaque)
|
|
|
|
{
|
2009-08-24 18:42:36 +02:00
|
|
|
EEPRO100State *s = opaque;
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("%p\n", s));
|
2010-09-29 21:59:55 +02:00
|
|
|
/* TODO: Clearing of hash register for selective reset, too? */
|
2009-12-20 16:52:24 +01:00
|
|
|
memset(&s->mult[0], 0, sizeof(s->mult));
|
2007-04-02 14:35:34 +02:00
|
|
|
nic_selective_reset(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(DEBUG_EEPRO100)
|
2009-11-27 12:06:02 +01:00
|
|
|
static const char * const e100_reg[PCI_IO_SIZE / 4] = {
|
2007-04-02 14:35:34 +02:00
|
|
|
"Command/Status",
|
|
|
|
"General Pointer",
|
|
|
|
"Port",
|
|
|
|
"EEPROM/Flash Control",
|
|
|
|
"MDI Control",
|
|
|
|
"Receive DMA Byte Count",
|
2009-11-27 12:06:02 +01:00
|
|
|
"Flow Control",
|
2007-04-02 14:35:34 +02:00
|
|
|
"General Status/Control"
|
|
|
|
};
|
|
|
|
|
|
|
|
static char *regname(uint32_t addr)
|
|
|
|
{
|
2009-11-26 03:20:10 +01:00
|
|
|
static char buf[32];
|
2007-04-02 14:35:34 +02:00
|
|
|
if (addr < PCI_IO_SIZE) {
|
2009-11-27 12:06:02 +01:00
|
|
|
const char *r = e100_reg[addr / 4];
|
2007-04-02 14:35:34 +02:00
|
|
|
if (r != 0) {
|
2009-09-19 12:29:59 +02:00
|
|
|
snprintf(buf, sizeof(buf), "%s+%u", r, addr % 4);
|
2007-04-02 14:35:34 +02:00
|
|
|
} else {
|
2009-09-19 12:29:59 +02:00
|
|
|
snprintf(buf, sizeof(buf), "0x%02x", addr);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
} else {
|
2009-09-19 12:29:59 +02:00
|
|
|
snprintf(buf, sizeof(buf), "??? 0x%08x", addr);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
#endif /* DEBUG_EEPRO100 */
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* Command emulation.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static uint16_t eepro100_read_command(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
uint16_t val = 0xffff;
|
2010-03-02 22:37:59 +01:00
|
|
|
TRACE(OTHER, logout("val=0x%04x\n", val));
|
2007-04-02 14:35:34 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Commands that can be put in a command list entry. */
|
|
|
|
enum commands {
|
|
|
|
CmdNOp = 0,
|
|
|
|
CmdIASetup = 1,
|
|
|
|
CmdConfigure = 2,
|
|
|
|
CmdMulticastList = 3,
|
|
|
|
CmdTx = 4,
|
|
|
|
CmdTDR = 5, /* load microcode */
|
|
|
|
CmdDump = 6,
|
|
|
|
CmdDiagnose = 7,
|
|
|
|
|
|
|
|
/* And some extra flags: */
|
|
|
|
CmdSuspend = 0x4000, /* Suspend after completion. */
|
|
|
|
CmdIntr = 0x2000, /* Interrupt after completion. */
|
|
|
|
CmdTxFlex = 0x0008, /* Use "Flexible mode" for CmdTx command. */
|
|
|
|
};
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static cu_state_t get_cu_state(EEPRO100State * s)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
2010-03-02 22:37:49 +01:00
|
|
|
return ((s->mem[SCBStatus] & BITS(7, 6)) >> 6);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static void set_cu_state(EEPRO100State * s, cu_state_t state)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
2010-03-02 22:37:49 +01:00
|
|
|
s->mem[SCBStatus] = (s->mem[SCBStatus] & ~BITS(7, 6)) + (state << 6);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static ru_state_t get_ru_state(EEPRO100State * s)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
2010-03-02 22:37:49 +01:00
|
|
|
return ((s->mem[SCBStatus] & BITS(5, 2)) >> 2);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static void set_ru_state(EEPRO100State * s, ru_state_t state)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
2010-03-02 22:37:49 +01:00
|
|
|
s->mem[SCBStatus] = (s->mem[SCBStatus] & ~BITS(5, 2)) + (state << 2);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dump_statistics(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
/* Dump statistical data. Most data is never changed by the emulation
|
|
|
|
* and always 0, so we first just copy the whole block and then those
|
|
|
|
* values which really matter.
|
|
|
|
* Number of data should check configuration!!!
|
|
|
|
*/
|
2011-11-04 02:03:32 +01:00
|
|
|
pci_dma_write(&s->dev, s->statsaddr, &s->statistics, s->stats_size);
|
2011-10-31 07:06:49 +01:00
|
|
|
stl_le_pci_dma(&s->dev, s->statsaddr + 0,
|
|
|
|
s->statistics.tx_good_frames);
|
|
|
|
stl_le_pci_dma(&s->dev, s->statsaddr + 36,
|
|
|
|
s->statistics.rx_good_frames);
|
|
|
|
stl_le_pci_dma(&s->dev, s->statsaddr + 48,
|
|
|
|
s->statistics.rx_resource_errors);
|
|
|
|
stl_le_pci_dma(&s->dev, s->statsaddr + 60,
|
|
|
|
s->statistics.rx_short_frame_errors);
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
2011-10-31 07:06:49 +01:00
|
|
|
stw_le_pci_dma(&s->dev, s->statsaddr + 76, s->statistics.xmt_tco_frames);
|
|
|
|
stw_le_pci_dma(&s->dev, s->statsaddr + 78, s->statistics.rcv_tco_frames);
|
2010-03-02 22:37:59 +01:00
|
|
|
missing("CU dump statistical counters");
|
|
|
|
#endif
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
2010-03-02 22:37:57 +01:00
|
|
|
static void read_cb(EEPRO100State *s)
|
|
|
|
{
|
2011-11-04 02:03:32 +01:00
|
|
|
pci_dma_read(&s->dev, s->cb_address, &s->tx, sizeof(s->tx));
|
2010-03-02 22:37:57 +01:00
|
|
|
s->tx.status = le16_to_cpu(s->tx.status);
|
|
|
|
s->tx.command = le16_to_cpu(s->tx.command);
|
|
|
|
s->tx.link = le32_to_cpu(s->tx.link);
|
|
|
|
s->tx.tbd_array_addr = le32_to_cpu(s->tx.tbd_array_addr);
|
|
|
|
s->tx.tcb_bytes = le16_to_cpu(s->tx.tcb_bytes);
|
|
|
|
}
|
|
|
|
|
2009-12-20 16:52:22 +01:00
|
|
|
static void tx_command(EEPRO100State *s)
|
|
|
|
{
|
2017-11-16 22:16:54 +01:00
|
|
|
uint32_t tbd_array = s->tx.tbd_array_addr;
|
|
|
|
uint16_t tcb_bytes = s->tx.tcb_bytes & 0x3fff;
|
2009-12-20 16:52:22 +01:00
|
|
|
/* Sends larger than MAX_ETH_FRAME_SIZE are allowed, up to 2600 bytes. */
|
|
|
|
uint8_t buf[2600];
|
|
|
|
uint16_t size = 0;
|
|
|
|
uint32_t tbd_address = s->cb_address + 0x10;
|
|
|
|
TRACE(RXTX, logout
|
|
|
|
("transmit, TBD array address 0x%08x, TCB byte count 0x%04x, TBD count %u\n",
|
|
|
|
tbd_array, tcb_bytes, s->tx.tbd_count));
|
|
|
|
|
|
|
|
if (tcb_bytes > 2600) {
|
|
|
|
logout("TCB byte count too large, using 2600\n");
|
|
|
|
tcb_bytes = 2600;
|
|
|
|
}
|
|
|
|
if (!((tcb_bytes > 0) || (tbd_array != 0xffffffff))) {
|
|
|
|
logout
|
|
|
|
("illegal values of TBD array address and TCB byte count!\n");
|
|
|
|
}
|
|
|
|
assert(tcb_bytes <= sizeof(buf));
|
|
|
|
while (size < tcb_bytes) {
|
|
|
|
TRACE(RXTX, logout
|
|
|
|
("TBD (simplified mode): buffer address 0x%08x, size 0x%04x\n",
|
2017-11-07 19:35:02 +01:00
|
|
|
tbd_address, tcb_bytes));
|
|
|
|
pci_dma_read(&s->dev, tbd_address, &buf[size], tcb_bytes);
|
|
|
|
size += tcb_bytes;
|
2009-12-20 16:52:22 +01:00
|
|
|
}
|
|
|
|
if (tbd_array == 0xffffffff) {
|
|
|
|
/* Simplified mode. Was already handled by code above. */
|
|
|
|
} else {
|
|
|
|
/* Flexible mode. */
|
|
|
|
uint8_t tbd_count = 0;
|
|
|
|
if (s->has_extended_tcb_support && !(s->configuration[6] & BIT(4))) {
|
|
|
|
/* Extended Flexible TCB. */
|
|
|
|
for (; tbd_count < 2; tbd_count++) {
|
2011-10-31 07:06:49 +01:00
|
|
|
uint32_t tx_buffer_address = ldl_le_pci_dma(&s->dev,
|
|
|
|
tbd_address);
|
|
|
|
uint16_t tx_buffer_size = lduw_le_pci_dma(&s->dev,
|
|
|
|
tbd_address + 4);
|
|
|
|
uint16_t tx_buffer_el = lduw_le_pci_dma(&s->dev,
|
|
|
|
tbd_address + 6);
|
2009-12-20 16:52:22 +01:00
|
|
|
tbd_address += 8;
|
|
|
|
TRACE(RXTX, logout
|
|
|
|
("TBD (extended flexible mode): buffer address 0x%08x, size 0x%04x\n",
|
|
|
|
tx_buffer_address, tx_buffer_size));
|
|
|
|
tx_buffer_size = MIN(tx_buffer_size, sizeof(buf) - size);
|
2011-10-31 07:06:49 +01:00
|
|
|
pci_dma_read(&s->dev, tx_buffer_address,
|
|
|
|
&buf[size], tx_buffer_size);
|
2009-12-20 16:52:22 +01:00
|
|
|
size += tx_buffer_size;
|
|
|
|
if (tx_buffer_el & 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tbd_address = tbd_array;
|
|
|
|
for (; tbd_count < s->tx.tbd_count; tbd_count++) {
|
2011-10-31 07:06:49 +01:00
|
|
|
uint32_t tx_buffer_address = ldl_le_pci_dma(&s->dev, tbd_address);
|
|
|
|
uint16_t tx_buffer_size = lduw_le_pci_dma(&s->dev, tbd_address + 4);
|
|
|
|
uint16_t tx_buffer_el = lduw_le_pci_dma(&s->dev, tbd_address + 6);
|
2009-12-20 16:52:22 +01:00
|
|
|
tbd_address += 8;
|
|
|
|
TRACE(RXTX, logout
|
|
|
|
("TBD (flexible mode): buffer address 0x%08x, size 0x%04x\n",
|
|
|
|
tx_buffer_address, tx_buffer_size));
|
|
|
|
tx_buffer_size = MIN(tx_buffer_size, sizeof(buf) - size);
|
2011-10-31 07:06:49 +01:00
|
|
|
pci_dma_read(&s->dev, tx_buffer_address,
|
|
|
|
&buf[size], tx_buffer_size);
|
2009-12-20 16:52:22 +01:00
|
|
|
size += tx_buffer_size;
|
|
|
|
if (tx_buffer_el & 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE(RXTX, logout("%p sending frame, len=%d,%s\n", s, size, nic_dump(buf, size)));
|
2013-01-30 12:12:22 +01:00
|
|
|
qemu_send_packet(qemu_get_queue(s->nic), buf, size);
|
2009-12-20 16:52:22 +01:00
|
|
|
s->statistics.tx_good_frames++;
|
|
|
|
/* Transmit with bad status would raise an CX/TNO interrupt.
|
|
|
|
* (82557 only). Emulation never has bad status. */
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
|
|
|
eepro100_cx_interrupt(s);
|
|
|
|
#endif
|
2009-12-20 16:52:22 +01:00
|
|
|
}
|
|
|
|
|
2009-12-20 16:52:24 +01:00
|
|
|
static void set_multicast_list(EEPRO100State *s)
|
|
|
|
{
|
|
|
|
uint16_t multicast_count = s->tx.tbd_array_addr & BITS(13, 0);
|
|
|
|
uint16_t i;
|
|
|
|
memset(&s->mult[0], 0, sizeof(s->mult));
|
|
|
|
TRACE(OTHER, logout("multicast list, multicast count = %u\n", multicast_count));
|
|
|
|
for (i = 0; i < multicast_count; i += 6) {
|
|
|
|
uint8_t multicast_addr[6];
|
2011-10-31 07:06:49 +01:00
|
|
|
pci_dma_read(&s->dev, s->cb_address + 10 + i, multicast_addr, 6);
|
2009-12-20 16:52:24 +01:00
|
|
|
TRACE(OTHER, logout("multicast entry %s\n", nic_dump(multicast_addr, 6)));
|
2017-12-15 19:41:46 +01:00
|
|
|
unsigned mcast_idx = (net_crc32(multicast_addr, ETH_ALEN) &
|
|
|
|
BITS(7, 2)) >> 2;
|
2009-12-20 16:52:24 +01:00
|
|
|
assert(mcast_idx < 64);
|
|
|
|
s->mult[mcast_idx >> 3] |= (1 << (mcast_idx & 7));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-19 21:03:26 +02:00
|
|
|
static void action_command(EEPRO100State *s)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
2015-11-20 08:42:33 +01:00
|
|
|
/* The loop below won't stop if it gets special handcrafted data.
|
|
|
|
Therefore we limit the number of iterations. */
|
|
|
|
unsigned max_loop_count = 16;
|
|
|
|
|
2009-10-19 21:03:26 +02:00
|
|
|
for (;;) {
|
2010-03-02 22:37:57 +01:00
|
|
|
bool bit_el;
|
|
|
|
bool bit_s;
|
|
|
|
bool bit_i;
|
|
|
|
bool bit_nc;
|
2010-04-06 13:44:02 +02:00
|
|
|
uint16_t ok_status = STATUS_OK;
|
2010-03-02 22:37:57 +01:00
|
|
|
s->cb_address = s->cu_base + s->cu_offset;
|
|
|
|
read_cb(s);
|
|
|
|
bit_el = ((s->tx.command & COMMAND_EL) != 0);
|
|
|
|
bit_s = ((s->tx.command & COMMAND_S) != 0);
|
|
|
|
bit_i = ((s->tx.command & COMMAND_I) != 0);
|
|
|
|
bit_nc = ((s->tx.command & COMMAND_NC) != 0);
|
|
|
|
#if 0
|
|
|
|
bool bit_sf = ((s->tx.command & COMMAND_SF) != 0);
|
|
|
|
#endif
|
2015-11-20 08:42:33 +01:00
|
|
|
|
|
|
|
if (max_loop_count-- == 0) {
|
|
|
|
/* Prevent an endless loop. */
|
|
|
|
logout("loop in %s:%u\n", __FILE__, __LINE__);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-03-02 22:37:57 +01:00
|
|
|
s->cu_offset = s->tx.link;
|
|
|
|
TRACE(OTHER,
|
|
|
|
logout("val=(cu start), status=0x%04x, command=0x%04x, link=0x%08x\n",
|
|
|
|
s->tx.status, s->tx.command, s->tx.link));
|
|
|
|
switch (s->tx.command & COMMAND_CMD) {
|
2007-04-02 14:35:34 +02:00
|
|
|
case CmdNOp:
|
|
|
|
/* Do nothing. */
|
|
|
|
break;
|
|
|
|
case CmdIASetup:
|
2011-10-31 07:06:49 +01:00
|
|
|
pci_dma_read(&s->dev, s->cb_address + 8, &s->conf.macaddr.a[0], 6);
|
2010-03-02 22:37:41 +01:00
|
|
|
TRACE(OTHER, logout("macaddr: %s\n", nic_dump(&s->conf.macaddr.a[0], 6)));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case CmdConfigure:
|
2011-10-31 07:06:49 +01:00
|
|
|
pci_dma_read(&s->dev, s->cb_address + 8,
|
|
|
|
&s->configuration[0], sizeof(s->configuration));
|
2010-09-29 21:59:55 +02:00
|
|
|
TRACE(OTHER, logout("configuration: %s\n",
|
|
|
|
nic_dump(&s->configuration[0], 16)));
|
|
|
|
TRACE(OTHER, logout("configuration: %s\n",
|
|
|
|
nic_dump(&s->configuration[16],
|
|
|
|
ARRAY_SIZE(s->configuration) - 16)));
|
|
|
|
if (s->configuration[20] & BIT(6)) {
|
|
|
|
TRACE(OTHER, logout("Multiple IA bit\n"));
|
|
|
|
}
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case CmdMulticastList:
|
2009-12-20 16:52:24 +01:00
|
|
|
set_multicast_list(s);
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case CmdTx:
|
2009-09-23 17:42:42 +02:00
|
|
|
if (bit_nc) {
|
|
|
|
missing("CmdTx: NC = 0");
|
2010-04-06 13:44:02 +02:00
|
|
|
ok_status = 0;
|
2009-09-23 17:42:42 +02:00
|
|
|
break;
|
|
|
|
}
|
2009-12-20 16:52:22 +01:00
|
|
|
tx_command(s);
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case CmdTDR:
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("load microcode\n"));
|
2007-04-02 14:35:34 +02:00
|
|
|
/* Starting with offset 8, the command contains
|
|
|
|
* 64 dwords microcode which we just ignore here. */
|
|
|
|
break;
|
2010-03-02 22:37:58 +01:00
|
|
|
case CmdDiagnose:
|
|
|
|
TRACE(OTHER, logout("diagnose\n"));
|
|
|
|
/* Make sure error flag is not set. */
|
|
|
|
s->tx.status = 0;
|
|
|
|
break;
|
2007-04-02 14:35:34 +02:00
|
|
|
default:
|
|
|
|
missing("undefined command");
|
2010-04-06 13:44:02 +02:00
|
|
|
ok_status = 0;
|
2009-09-23 17:42:42 +02:00
|
|
|
break;
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
2009-09-23 17:42:42 +02:00
|
|
|
/* Write new status. */
|
2011-10-31 07:06:49 +01:00
|
|
|
stw_le_pci_dma(&s->dev, s->cb_address,
|
|
|
|
s->tx.status | ok_status | STATUS_C);
|
2007-04-02 14:35:34 +02:00
|
|
|
if (bit_i) {
|
|
|
|
/* CU completed action. */
|
|
|
|
eepro100_cx_interrupt(s);
|
|
|
|
}
|
|
|
|
if (bit_el) {
|
2009-09-19 12:11:36 +02:00
|
|
|
/* CU becomes idle. Terminate command loop. */
|
2007-04-02 14:35:34 +02:00
|
|
|
set_cu_state(s, cu_idle);
|
|
|
|
eepro100_cna_interrupt(s);
|
2009-10-19 21:03:26 +02:00
|
|
|
break;
|
2007-04-02 14:35:34 +02:00
|
|
|
} else if (bit_s) {
|
2009-10-19 21:03:26 +02:00
|
|
|
/* CU becomes suspended. Terminate command loop. */
|
2007-04-02 14:35:34 +02:00
|
|
|
set_cu_state(s, cu_suspended);
|
|
|
|
eepro100_cna_interrupt(s);
|
2009-10-19 21:03:26 +02:00
|
|
|
break;
|
2007-04-02 14:35:34 +02:00
|
|
|
} else {
|
|
|
|
/* More entries in list. */
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("CU list with at least one more entry\n"));
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
2009-10-19 21:03:26 +02:00
|
|
|
}
|
|
|
|
TRACE(OTHER, logout("CU list empty\n"));
|
|
|
|
/* List is empty. Now CU is idle or suspended. */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eepro100_cu_command(EEPRO100State * s, uint8_t val)
|
|
|
|
{
|
2010-03-02 22:37:54 +01:00
|
|
|
cu_state_t cu_state;
|
2009-10-19 21:03:26 +02:00
|
|
|
switch (val) {
|
|
|
|
case CU_NOP:
|
|
|
|
/* No operation. */
|
|
|
|
break;
|
|
|
|
case CU_START:
|
2010-03-02 22:37:54 +01:00
|
|
|
cu_state = get_cu_state(s);
|
|
|
|
if (cu_state != cu_idle && cu_state != cu_suspended) {
|
|
|
|
/* Intel documentation says that CU must be idle or suspended
|
|
|
|
* for the CU start command. */
|
|
|
|
logout("unexpected CU state is %u\n", cu_state);
|
2009-10-19 21:03:26 +02:00
|
|
|
}
|
|
|
|
set_cu_state(s, cu_active);
|
2011-04-30 22:40:10 +02:00
|
|
|
s->cu_offset = e100_read_reg4(s, SCBPointer);
|
2009-10-19 21:03:26 +02:00
|
|
|
action_command(s);
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case CU_RESUME:
|
|
|
|
if (get_cu_state(s) != cu_suspended) {
|
|
|
|
logout("bad CU resume from CU state %u\n", get_cu_state(s));
|
|
|
|
/* Workaround for bad Linux eepro100 driver which resumes
|
|
|
|
* from idle state. */
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
|
|
|
missing("cu resume");
|
|
|
|
#endif
|
2007-04-02 14:35:34 +02:00
|
|
|
set_cu_state(s, cu_suspended);
|
|
|
|
}
|
|
|
|
if (get_cu_state(s) == cu_suspended) {
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("CU resuming\n"));
|
2007-04-02 14:35:34 +02:00
|
|
|
set_cu_state(s, cu_active);
|
2009-10-19 21:03:26 +02:00
|
|
|
action_command(s);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CU_STATSADDR:
|
|
|
|
/* Load dump counters address. */
|
2011-04-30 22:40:10 +02:00
|
|
|
s->statsaddr = e100_read_reg4(s, SCBPointer);
|
2011-11-23 22:20:30 +01:00
|
|
|
TRACE(OTHER, logout("val=0x%02x (dump counters address)\n", val));
|
|
|
|
if (s->statsaddr & 3) {
|
|
|
|
/* Memory must be Dword aligned. */
|
|
|
|
logout("unaligned dump counters address\n");
|
|
|
|
/* Handling of misaligned addresses is undefined.
|
|
|
|
* Here we align the address by ignoring the lower bits. */
|
|
|
|
/* TODO: Test unaligned dump counter address on real hardware. */
|
|
|
|
s->statsaddr &= ~3;
|
|
|
|
}
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case CU_SHOWSTATS:
|
|
|
|
/* Dump statistical counters. */
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("val=0x%02x (dump stats)\n", val));
|
2007-04-02 14:35:34 +02:00
|
|
|
dump_statistics(s);
|
2011-10-31 07:06:49 +01:00
|
|
|
stl_le_pci_dma(&s->dev, s->statsaddr + s->stats_size, 0xa005);
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case CU_CMD_BASE:
|
|
|
|
/* Load CU base. */
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("val=0x%02x (CU base address)\n", val));
|
2011-04-30 22:40:10 +02:00
|
|
|
s->cu_base = e100_read_reg4(s, SCBPointer);
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case CU_DUMPSTATS:
|
|
|
|
/* Dump and reset statistical counters. */
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("val=0x%02x (dump stats and reset)\n", val));
|
2007-04-02 14:35:34 +02:00
|
|
|
dump_statistics(s);
|
2011-10-31 07:06:49 +01:00
|
|
|
stl_le_pci_dma(&s->dev, s->statsaddr + s->stats_size, 0xa007);
|
2007-04-02 14:35:34 +02:00
|
|
|
memset(&s->statistics, 0, sizeof(s->statistics));
|
|
|
|
break;
|
|
|
|
case CU_SRESUME:
|
|
|
|
/* CU static resume. */
|
|
|
|
missing("CU static resume");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
missing("Undefined CU command");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eepro100_ru_command(EEPRO100State * s, uint8_t val)
|
|
|
|
{
|
|
|
|
switch (val) {
|
|
|
|
case RU_NOP:
|
|
|
|
/* No operation. */
|
|
|
|
break;
|
|
|
|
case RX_START:
|
|
|
|
/* RU start. */
|
|
|
|
if (get_ru_state(s) != ru_idle) {
|
|
|
|
logout("RU state is %u, should be %u\n", get_ru_state(s), ru_idle);
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
|
|
|
assert(!"wrong RU state");
|
|
|
|
#endif
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
set_ru_state(s, ru_ready);
|
2011-04-30 22:40:10 +02:00
|
|
|
s->ru_offset = e100_read_reg4(s, SCBPointer);
|
2013-01-30 12:12:22 +01:00
|
|
|
qemu_flush_queued_packets(qemu_get_queue(s->nic));
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("val=0x%02x (rx start)\n", val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case RX_RESUME:
|
|
|
|
/* Restart RU. */
|
|
|
|
if (get_ru_state(s) != ru_suspended) {
|
|
|
|
logout("RU state is %u, should be %u\n", get_ru_state(s),
|
|
|
|
ru_suspended);
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
|
|
|
assert(!"wrong RU state");
|
|
|
|
#endif
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
set_ru_state(s, ru_ready);
|
|
|
|
break;
|
2010-03-02 22:37:53 +01:00
|
|
|
case RU_ABORT:
|
|
|
|
/* RU abort. */
|
|
|
|
if (get_ru_state(s) == ru_ready) {
|
|
|
|
eepro100_rnr_interrupt(s);
|
|
|
|
}
|
|
|
|
set_ru_state(s, ru_idle);
|
|
|
|
break;
|
2007-04-02 14:35:34 +02:00
|
|
|
case RX_ADDR_LOAD:
|
|
|
|
/* Load RU base. */
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("val=0x%02x (RU base address)\n", val));
|
2011-04-30 22:40:10 +02:00
|
|
|
s->ru_base = e100_read_reg4(s, SCBPointer);
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
logout("val=0x%02x (undefined RU command)\n", val);
|
|
|
|
missing("Undefined SU command");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eepro100_write_command(EEPRO100State * s, uint8_t val)
|
|
|
|
{
|
|
|
|
eepro100_ru_command(s, val & 0x0f);
|
|
|
|
eepro100_cu_command(s, val & 0xf0);
|
|
|
|
if ((val) == 0) {
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("val=0x%02x\n", val));
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
/* Clear command byte after command was accepted. */
|
|
|
|
s->mem[SCBCmd] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* EEPROM emulation.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#define EEPROM_CS 0x02
|
|
|
|
#define EEPROM_SK 0x01
|
|
|
|
#define EEPROM_DI 0x04
|
|
|
|
#define EEPROM_DO 0x08
|
|
|
|
|
|
|
|
static uint16_t eepro100_read_eeprom(EEPRO100State * s)
|
|
|
|
{
|
2011-04-30 22:40:08 +02:00
|
|
|
uint16_t val = e100_read_reg2(s, SCBeeprom);
|
2007-04-02 14:35:34 +02:00
|
|
|
if (eeprom93xx_read(s->eeprom)) {
|
|
|
|
val |= EEPROM_DO;
|
|
|
|
} else {
|
|
|
|
val &= ~EEPROM_DO;
|
|
|
|
}
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(EEPROM, logout("val=0x%04x\n", val));
|
2007-04-02 14:35:34 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static void eepro100_write_eeprom(eeprom_t * eeprom, uint8_t val)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(EEPROM, logout("val=0x%02x\n", val));
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2011-04-26 10:29:36 +02:00
|
|
|
/* mask unwritable bits */
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
|
|
|
val = SET_MASKED(val, 0x31, eeprom->value);
|
|
|
|
#endif
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
int eecs = ((val & EEPROM_CS) != 0);
|
|
|
|
int eesk = ((val & EEPROM_SK) != 0);
|
|
|
|
int eedi = ((val & EEPROM_DI) != 0);
|
|
|
|
eeprom93xx_write(eeprom, eecs, eesk, eedi);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* MDI emulation.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if defined(DEBUG_EEPRO100)
|
2009-09-12 17:20:24 +02:00
|
|
|
static const char * const mdi_op_name[] = {
|
2007-04-02 14:35:34 +02:00
|
|
|
"opcode 0",
|
|
|
|
"write",
|
|
|
|
"read",
|
|
|
|
"opcode 3"
|
|
|
|
};
|
|
|
|
|
2009-09-12 17:20:24 +02:00
|
|
|
static const char * const mdi_reg_name[] = {
|
2007-04-02 14:35:34 +02:00
|
|
|
"Control",
|
|
|
|
"Status",
|
|
|
|
"PHY Identification (Word 1)",
|
|
|
|
"PHY Identification (Word 2)",
|
|
|
|
"Auto-Negotiation Advertisement",
|
|
|
|
"Auto-Negotiation Link Partner Ability",
|
|
|
|
"Auto-Negotiation Expansion"
|
|
|
|
};
|
2009-09-19 12:11:36 +02:00
|
|
|
|
|
|
|
static const char *reg2name(uint8_t reg)
|
|
|
|
{
|
|
|
|
static char buffer[10];
|
|
|
|
const char *p = buffer;
|
|
|
|
if (reg < ARRAY_SIZE(mdi_reg_name)) {
|
|
|
|
p = mdi_reg_name[reg];
|
|
|
|
} else {
|
|
|
|
snprintf(buffer, sizeof(buffer), "reg=0x%02x", reg);
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
2007-04-02 14:35:34 +02:00
|
|
|
#endif /* DEBUG_EEPRO100 */
|
|
|
|
|
|
|
|
static uint32_t eepro100_read_mdi(EEPRO100State * s)
|
|
|
|
{
|
2011-04-30 22:40:08 +02:00
|
|
|
uint32_t val = e100_read_reg4(s, SCBCtrlMDI);
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
#ifdef DEBUG_EEPRO100
|
|
|
|
uint8_t raiseint = (val & BIT(29)) >> 29;
|
|
|
|
uint8_t opcode = (val & BITS(27, 26)) >> 26;
|
|
|
|
uint8_t phy = (val & BITS(25, 21)) >> 21;
|
|
|
|
uint8_t reg = (val & BITS(20, 16)) >> 16;
|
|
|
|
uint16_t data = (val & BITS(15, 0));
|
|
|
|
#endif
|
|
|
|
/* Emulation takes no time to finish MDI transaction. */
|
|
|
|
val |= BIT(28);
|
|
|
|
TRACE(MDI, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
|
|
|
|
val, raiseint, mdi_op_name[opcode], phy,
|
2009-09-19 12:11:36 +02:00
|
|
|
reg2name(reg), data));
|
2007-04-02 14:35:34 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2011-04-30 22:40:11 +02:00
|
|
|
static void eepro100_write_mdi(EEPRO100State *s)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
2011-04-30 22:40:11 +02:00
|
|
|
uint32_t val = e100_read_reg4(s, SCBCtrlMDI);
|
2007-04-02 14:35:34 +02:00
|
|
|
uint8_t raiseint = (val & BIT(29)) >> 29;
|
|
|
|
uint8_t opcode = (val & BITS(27, 26)) >> 26;
|
|
|
|
uint8_t phy = (val & BITS(25, 21)) >> 21;
|
|
|
|
uint8_t reg = (val & BITS(20, 16)) >> 16;
|
|
|
|
uint16_t data = (val & BITS(15, 0));
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(MDI, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
|
|
|
|
val, raiseint, mdi_op_name[opcode], phy, reg2name(reg), data));
|
2007-04-02 14:35:34 +02:00
|
|
|
if (phy != 1) {
|
|
|
|
/* Unsupported PHY address. */
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
|
|
|
logout("phy must be 1 but is %u\n", phy);
|
|
|
|
#endif
|
2007-04-02 14:35:34 +02:00
|
|
|
data = 0;
|
|
|
|
} else if (opcode != 1 && opcode != 2) {
|
|
|
|
/* Unsupported opcode. */
|
|
|
|
logout("opcode must be 1 or 2 but is %u\n", opcode);
|
|
|
|
data = 0;
|
|
|
|
} else if (reg > 6) {
|
|
|
|
/* Unsupported register. */
|
|
|
|
logout("register must be 0...6 but is %u\n", reg);
|
|
|
|
data = 0;
|
|
|
|
} else {
|
|
|
|
TRACE(MDI, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
|
|
|
|
val, raiseint, mdi_op_name[opcode], phy,
|
2009-09-19 12:11:36 +02:00
|
|
|
reg2name(reg), data));
|
2007-04-02 14:35:34 +02:00
|
|
|
if (opcode == 1) {
|
|
|
|
/* MDI write */
|
|
|
|
switch (reg) {
|
|
|
|
case 0: /* Control Register */
|
|
|
|
if (data & 0x8000) {
|
|
|
|
/* Reset status and control registers to default. */
|
|
|
|
s->mdimem[0] = eepro100_mdi_default[0];
|
|
|
|
s->mdimem[1] = eepro100_mdi_default[1];
|
|
|
|
data = s->mdimem[reg];
|
|
|
|
} else {
|
|
|
|
/* Restart Auto Configuration = Normal Operation */
|
|
|
|
data &= ~0x0200;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1: /* Status Register */
|
|
|
|
missing("not writable");
|
|
|
|
break;
|
|
|
|
case 2: /* PHY Identification Register (Word 1) */
|
|
|
|
case 3: /* PHY Identification Register (Word 2) */
|
|
|
|
missing("not implemented");
|
|
|
|
break;
|
|
|
|
case 4: /* Auto-Negotiation Advertisement Register */
|
|
|
|
case 5: /* Auto-Negotiation Link Partner Ability Register */
|
|
|
|
break;
|
|
|
|
case 6: /* Auto-Negotiation Expansion Register */
|
|
|
|
default:
|
|
|
|
missing("not implemented");
|
|
|
|
}
|
2014-06-09 17:03:08 +02:00
|
|
|
s->mdimem[reg] &= eepro100_mdi_mask[reg];
|
|
|
|
s->mdimem[reg] |= data & ~eepro100_mdi_mask[reg];
|
2007-04-02 14:35:34 +02:00
|
|
|
} else if (opcode == 2) {
|
|
|
|
/* MDI read */
|
|
|
|
switch (reg) {
|
|
|
|
case 0: /* Control Register */
|
|
|
|
if (data & 0x8000) {
|
|
|
|
/* Reset status and control registers to default. */
|
|
|
|
s->mdimem[0] = eepro100_mdi_default[0];
|
|
|
|
s->mdimem[1] = eepro100_mdi_default[1];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1: /* Status Register */
|
|
|
|
s->mdimem[reg] |= 0x0020;
|
|
|
|
break;
|
|
|
|
case 2: /* PHY Identification Register (Word 1) */
|
|
|
|
case 3: /* PHY Identification Register (Word 2) */
|
|
|
|
case 4: /* Auto-Negotiation Advertisement Register */
|
|
|
|
break;
|
|
|
|
case 5: /* Auto-Negotiation Link Partner Ability Register */
|
|
|
|
s->mdimem[reg] = 0x41fe;
|
|
|
|
break;
|
|
|
|
case 6: /* Auto-Negotiation Expansion Register */
|
|
|
|
s->mdimem[reg] = 0x0001;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
data = s->mdimem[reg];
|
|
|
|
}
|
|
|
|
/* Emulation takes no time to finish MDI transaction.
|
|
|
|
* Set MDI bit in SCB status register. */
|
|
|
|
s->mem[SCBAck] |= 0x08;
|
|
|
|
val |= BIT(28);
|
|
|
|
if (raiseint) {
|
|
|
|
eepro100_mdi_interrupt(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val = (val & 0xffff0000) + data;
|
2011-04-30 22:40:08 +02:00
|
|
|
e100_write_reg4(s, SCBCtrlMDI, val);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* Port emulation.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#define PORT_SOFTWARE_RESET 0
|
|
|
|
#define PORT_SELFTEST 1
|
|
|
|
#define PORT_SELECTIVE_RESET 2
|
|
|
|
#define PORT_DUMP 3
|
|
|
|
#define PORT_SELECTION_MASK 3
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint32_t st_sign; /* Self Test Signature */
|
|
|
|
uint32_t st_result; /* Self Test Results */
|
2009-10-01 23:12:16 +02:00
|
|
|
} eepro100_selftest_t;
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
static uint32_t eepro100_read_port(EEPRO100State * s)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-30 22:40:09 +02:00
|
|
|
static void eepro100_write_port(EEPRO100State *s)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
2011-04-30 22:40:09 +02:00
|
|
|
uint32_t val = e100_read_reg4(s, SCBPort);
|
2007-04-02 14:35:34 +02:00
|
|
|
uint32_t address = (val & ~PORT_SELECTION_MASK);
|
|
|
|
uint8_t selection = (val & PORT_SELECTION_MASK);
|
|
|
|
switch (selection) {
|
|
|
|
case PORT_SOFTWARE_RESET:
|
|
|
|
nic_reset(s);
|
|
|
|
break;
|
|
|
|
case PORT_SELFTEST:
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("selftest address=0x%08x\n", address));
|
2009-10-01 23:12:16 +02:00
|
|
|
eepro100_selftest_t data;
|
2011-10-31 07:06:49 +01:00
|
|
|
pci_dma_read(&s->dev, address, (uint8_t *) &data, sizeof(data));
|
2007-04-02 14:35:34 +02:00
|
|
|
data.st_sign = 0xffffffff;
|
|
|
|
data.st_result = 0;
|
2011-10-31 07:06:49 +01:00
|
|
|
pci_dma_write(&s->dev, address, (uint8_t *) &data, sizeof(data));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case PORT_SELECTIVE_RESET:
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("selective reset, selftest address=0x%08x\n", address));
|
2007-04-02 14:35:34 +02:00
|
|
|
nic_selective_reset(s);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
logout("val=0x%08x\n", val);
|
|
|
|
missing("unknown port selection");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* General hardware emulation.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static uint8_t eepro100_read1(EEPRO100State * s, uint32_t addr)
|
|
|
|
{
|
2010-10-13 20:38:07 +02:00
|
|
|
uint8_t val = 0;
|
2007-04-02 14:35:34 +02:00
|
|
|
if (addr <= sizeof(s->mem) - sizeof(val)) {
|
2011-04-30 22:40:08 +02:00
|
|
|
val = s->mem[addr];
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case SCBStatus:
|
|
|
|
case SCBAck:
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case SCBCmd:
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
|
|
|
val = eepro100_read_command(s);
|
|
|
|
#endif
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case SCBIntmask:
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case SCBPort + 3:
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case SCBeeprom:
|
|
|
|
val = eepro100_read_eeprom(s);
|
|
|
|
break;
|
2011-04-30 22:40:11 +02:00
|
|
|
case SCBCtrlMDI:
|
|
|
|
case SCBCtrlMDI + 1:
|
|
|
|
case SCBCtrlMDI + 2:
|
|
|
|
case SCBCtrlMDI + 3:
|
|
|
|
val = (uint8_t)(eepro100_read_mdi(s) >> (8 * (addr & 3)));
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
|
|
|
break;
|
2010-03-02 22:37:42 +01:00
|
|
|
case SCBpmdr: /* Power Management Driver Register */
|
2007-04-02 14:35:34 +02:00
|
|
|
val = 0;
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
2011-04-30 22:40:12 +02:00
|
|
|
case SCBgctrl: /* General Control Register */
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
|
|
|
break;
|
2010-03-02 22:37:42 +01:00
|
|
|
case SCBgstat: /* General Status Register */
|
2007-04-02 14:35:34 +02:00
|
|
|
/* 100 Mbps full duplex, valid link */
|
|
|
|
val = 0x07;
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("addr=General Status val=%02x\n", val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
logout("addr=%s val=0x%02x\n", regname(addr), val);
|
|
|
|
missing("unknown byte read");
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint16_t eepro100_read2(EEPRO100State * s, uint32_t addr)
|
|
|
|
{
|
2010-10-13 20:38:07 +02:00
|
|
|
uint16_t val = 0;
|
2007-04-02 14:35:34 +02:00
|
|
|
if (addr <= sizeof(s->mem) - sizeof(val)) {
|
2011-04-30 22:40:08 +02:00
|
|
|
val = e100_read_reg2(s, addr);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case SCBStatus:
|
2009-10-02 18:39:41 +02:00
|
|
|
case SCBCmd:
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case SCBeeprom:
|
|
|
|
val = eepro100_read_eeprom(s);
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
2011-04-30 22:40:11 +02:00
|
|
|
case SCBCtrlMDI:
|
|
|
|
case SCBCtrlMDI + 2:
|
|
|
|
val = (uint16_t)(eepro100_read_mdi(s) >> (8 * (addr & 3)));
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
|
|
|
|
break;
|
2007-04-02 14:35:34 +02:00
|
|
|
default:
|
|
|
|
logout("addr=%s val=0x%04x\n", regname(addr), val);
|
|
|
|
missing("unknown word read");
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t eepro100_read4(EEPRO100State * s, uint32_t addr)
|
|
|
|
{
|
2010-10-13 20:38:07 +02:00
|
|
|
uint32_t val = 0;
|
2007-04-02 14:35:34 +02:00
|
|
|
if (addr <= sizeof(s->mem) - sizeof(val)) {
|
2011-04-30 22:40:08 +02:00
|
|
|
val = e100_read_reg4(s, addr);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case SCBStatus:
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case SCBPointer:
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case SCBPort:
|
|
|
|
val = eepro100_read_port(s);
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
2011-04-30 22:40:13 +02:00
|
|
|
case SCBflash:
|
|
|
|
val = eepro100_read_eeprom(s);
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val));
|
|
|
|
break;
|
2007-04-02 14:35:34 +02:00
|
|
|
case SCBCtrlMDI:
|
|
|
|
val = eepro100_read_mdi(s);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
logout("addr=%s val=0x%08x\n", regname(addr), val);
|
|
|
|
missing("unknown longword read");
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eepro100_write1(EEPRO100State * s, uint32_t addr, uint8_t val)
|
|
|
|
{
|
2010-04-06 13:44:01 +02:00
|
|
|
/* SCBStatus is readonly. */
|
|
|
|
if (addr > SCBStatus && addr <= sizeof(s->mem) - sizeof(val)) {
|
2011-04-30 22:40:08 +02:00
|
|
|
s->mem[addr] = val;
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case SCBStatus:
|
2011-04-30 22:40:04 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case SCBAck:
|
2011-04-30 22:40:04 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
eepro100_acknowledge(s);
|
|
|
|
break;
|
|
|
|
case SCBCmd:
|
2011-04-30 22:40:04 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
eepro100_write_command(s, val);
|
|
|
|
break;
|
|
|
|
case SCBIntmask:
|
2011-04-30 22:40:04 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
if (val & BIT(1)) {
|
|
|
|
eepro100_swi_interrupt(s);
|
|
|
|
}
|
|
|
|
eepro100_interrupt(s, 0);
|
|
|
|
break;
|
2011-04-30 22:40:10 +02:00
|
|
|
case SCBPointer:
|
|
|
|
case SCBPointer + 1:
|
|
|
|
case SCBPointer + 2:
|
|
|
|
case SCBPointer + 3:
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
|
|
|
break;
|
2011-04-30 22:40:09 +02:00
|
|
|
case SCBPort:
|
|
|
|
case SCBPort + 1:
|
|
|
|
case SCBPort + 2:
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
|
|
|
break;
|
2007-04-02 14:35:34 +02:00
|
|
|
case SCBPort + 3:
|
2011-04-30 22:40:09 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
|
|
|
eepro100_write_port(s);
|
|
|
|
break;
|
2009-09-19 12:11:36 +02:00
|
|
|
case SCBFlow: /* does not exist on 82557 */
|
2007-09-15 00:22:13 +02:00
|
|
|
case SCBFlow + 1:
|
|
|
|
case SCBFlow + 2:
|
2010-03-02 22:37:42 +01:00
|
|
|
case SCBpmdr: /* does not exist on 82557 */
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case SCBeeprom:
|
2011-04-30 22:40:04 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
eepro100_write_eeprom(s->eeprom, val);
|
|
|
|
break;
|
2011-04-30 22:40:11 +02:00
|
|
|
case SCBCtrlMDI:
|
|
|
|
case SCBCtrlMDI + 1:
|
|
|
|
case SCBCtrlMDI + 2:
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
|
|
|
break;
|
|
|
|
case SCBCtrlMDI + 3:
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
|
|
|
|
eepro100_write_mdi(s);
|
|
|
|
break;
|
2007-04-02 14:35:34 +02:00
|
|
|
default:
|
|
|
|
logout("addr=%s val=0x%02x\n", regname(addr), val);
|
|
|
|
missing("unknown byte write");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eepro100_write2(EEPRO100State * s, uint32_t addr, uint16_t val)
|
|
|
|
{
|
2010-04-06 13:44:01 +02:00
|
|
|
/* SCBStatus is readonly. */
|
|
|
|
if (addr > SCBStatus && addr <= sizeof(s->mem) - sizeof(val)) {
|
2011-04-30 22:40:08 +02:00
|
|
|
e100_write_reg2(s, addr, val);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case SCBStatus:
|
2011-04-30 22:40:04 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
|
2010-04-06 13:44:01 +02:00
|
|
|
s->mem[SCBAck] = (val >> 8);
|
2007-04-02 14:35:34 +02:00
|
|
|
eepro100_acknowledge(s);
|
|
|
|
break;
|
|
|
|
case SCBCmd:
|
2011-04-30 22:40:04 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
eepro100_write_command(s, val);
|
|
|
|
eepro100_write1(s, SCBIntmask, val >> 8);
|
|
|
|
break;
|
2011-04-30 22:40:10 +02:00
|
|
|
case SCBPointer:
|
|
|
|
case SCBPointer + 2:
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
|
|
|
|
break;
|
2011-04-30 22:40:09 +02:00
|
|
|
case SCBPort:
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
|
|
|
|
break;
|
|
|
|
case SCBPort + 2:
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
|
|
|
|
eepro100_write_port(s);
|
|
|
|
break;
|
2007-04-02 14:35:34 +02:00
|
|
|
case SCBeeprom:
|
2011-04-30 22:40:04 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
eepro100_write_eeprom(s->eeprom, val);
|
|
|
|
break;
|
2011-04-30 22:40:11 +02:00
|
|
|
case SCBCtrlMDI:
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
|
|
|
|
break;
|
|
|
|
case SCBCtrlMDI + 2:
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
|
|
|
|
eepro100_write_mdi(s);
|
|
|
|
break;
|
2007-04-02 14:35:34 +02:00
|
|
|
default:
|
|
|
|
logout("addr=%s val=0x%04x\n", regname(addr), val);
|
|
|
|
missing("unknown word write");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eepro100_write4(EEPRO100State * s, uint32_t addr, uint32_t val)
|
|
|
|
{
|
|
|
|
if (addr <= sizeof(s->mem) - sizeof(val)) {
|
2011-04-30 22:40:08 +02:00
|
|
|
e100_write_reg4(s, addr, val);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case SCBPointer:
|
2011-04-30 22:40:10 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val));
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
case SCBPort:
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val));
|
2011-04-30 22:40:09 +02:00
|
|
|
eepro100_write_port(s);
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
2011-04-30 22:40:13 +02:00
|
|
|
case SCBflash:
|
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val));
|
|
|
|
val = val >> 16;
|
|
|
|
eepro100_write_eeprom(s->eeprom, val);
|
|
|
|
break;
|
2007-04-02 14:35:34 +02:00
|
|
|
case SCBCtrlMDI:
|
2011-04-30 22:40:11 +02:00
|
|
|
TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val));
|
|
|
|
eepro100_write_mdi(s);
|
2007-04-02 14:35:34 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
logout("addr=%s val=0x%08x\n", regname(addr), val);
|
|
|
|
missing("unknown longword write");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t eepro100_read(void *opaque, hwaddr addr,
|
2011-08-08 15:09:09 +02:00
|
|
|
unsigned size)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
|
|
|
EEPRO100State *s = opaque;
|
|
|
|
|
2011-08-08 15:09:09 +02:00
|
|
|
switch (size) {
|
|
|
|
case 1: return eepro100_read1(s, addr);
|
|
|
|
case 2: return eepro100_read2(s, addr);
|
|
|
|
case 4: return eepro100_read4(s, addr);
|
|
|
|
default: abort();
|
|
|
|
}
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void eepro100_write(void *opaque, hwaddr addr,
|
2011-08-08 15:09:09 +02:00
|
|
|
uint64_t data, unsigned size)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
|
|
|
EEPRO100State *s = opaque;
|
|
|
|
|
2011-08-08 15:09:09 +02:00
|
|
|
switch (size) {
|
2012-07-08 08:56:53 +02:00
|
|
|
case 1:
|
|
|
|
eepro100_write1(s, addr, data);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
eepro100_write2(s, addr, data);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
eepro100_write4(s, addr, data);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
2011-08-08 15:09:09 +02:00
|
|
|
}
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
2011-08-08 15:09:09 +02:00
|
|
|
static const MemoryRegionOps eepro100_ops = {
|
|
|
|
.read = eepro100_read,
|
|
|
|
.write = eepro100_write,
|
|
|
|
.endianness = DEVICE_LITTLE_ENDIAN,
|
2007-04-02 14:35:34 +02:00
|
|
|
};
|
|
|
|
|
2012-07-24 17:35:13 +02:00
|
|
|
static ssize_t nic_receive(NetClientState *nc, const uint8_t * buf, size_t size)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
|
|
|
/* TODO:
|
|
|
|
* - Magic packets should set bit 30 in power management driver register.
|
|
|
|
* - Interesting packets should set bit 29 in power management driver register.
|
|
|
|
*/
|
2013-01-30 12:12:23 +01:00
|
|
|
EEPRO100State *s = qemu_get_nic_opaque(nc);
|
2007-04-02 14:35:34 +02:00
|
|
|
uint16_t rfd_status = 0xa000;
|
2011-04-30 22:40:07 +02:00
|
|
|
#if defined(CONFIG_PAD_RECEIVED_FRAMES)
|
|
|
|
uint8_t min_buf[60];
|
|
|
|
#endif
|
2007-04-02 14:35:34 +02:00
|
|
|
static const uint8_t broadcast_macaddr[6] =
|
|
|
|
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
|
|
|
|
2011-04-30 22:40:07 +02:00
|
|
|
#if defined(CONFIG_PAD_RECEIVED_FRAMES)
|
|
|
|
/* Pad to minimum Ethernet frame length */
|
|
|
|
if (size < sizeof(min_buf)) {
|
|
|
|
memcpy(min_buf, buf, size);
|
|
|
|
memset(&min_buf[size], 0, sizeof(min_buf) - size);
|
|
|
|
buf = min_buf;
|
|
|
|
size = sizeof(min_buf);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-04-02 14:35:34 +02:00
|
|
|
if (s->configuration[8] & 0x80) {
|
|
|
|
/* CSMA is disabled. */
|
|
|
|
logout("%p received while CSMA is disabled\n", s);
|
2009-05-18 14:40:55 +02:00
|
|
|
return -1;
|
2011-04-30 22:40:07 +02:00
|
|
|
#if !defined(CONFIG_PAD_RECEIVED_FRAMES)
|
2010-03-02 22:37:49 +01:00
|
|
|
} else if (size < 64 && (s->configuration[7] & BIT(0))) {
|
2007-04-02 14:35:34 +02:00
|
|
|
/* Short frame and configuration byte 7/0 (discard short receive) set:
|
|
|
|
* Short frame is discarded */
|
2009-09-19 12:37:51 +02:00
|
|
|
logout("%p received short frame (%zu byte)\n", s, size);
|
2007-04-02 14:35:34 +02:00
|
|
|
s->statistics.rx_short_frame_errors++;
|
2010-03-02 22:37:59 +01:00
|
|
|
return -1;
|
|
|
|
#endif
|
2010-03-02 22:37:49 +01:00
|
|
|
} else if ((size > MAX_ETH_FRAME_SIZE + 4) && !(s->configuration[18] & BIT(3))) {
|
2007-04-02 14:35:34 +02:00
|
|
|
/* Long frame and configuration byte 18/3 (long receive ok) not set:
|
|
|
|
* Long frames are discarded. */
|
2009-09-19 12:37:51 +02:00
|
|
|
logout("%p received long frame (%zu byte), ignored\n", s, size);
|
2009-05-18 14:40:55 +02:00
|
|
|
return -1;
|
2010-03-02 22:37:59 +01:00
|
|
|
} else if (memcmp(buf, s->conf.macaddr.a, 6) == 0) { /* !!! */
|
2007-04-02 14:35:34 +02:00
|
|
|
/* Frame matches individual address. */
|
|
|
|
/* TODO: check configuration byte 15/4 (ignore U/L). */
|
2009-09-19 12:37:51 +02:00
|
|
|
TRACE(RXTX, logout("%p received frame for me, len=%zu\n", s, size));
|
2007-04-02 14:35:34 +02:00
|
|
|
} else if (memcmp(buf, broadcast_macaddr, 6) == 0) {
|
|
|
|
/* Broadcast frame. */
|
2009-09-19 12:37:51 +02:00
|
|
|
TRACE(RXTX, logout("%p received broadcast, len=%zu\n", s, size));
|
2007-04-02 14:35:34 +02:00
|
|
|
rfd_status |= 0x0002;
|
2009-12-20 16:52:24 +01:00
|
|
|
} else if (buf[0] & 0x01) {
|
2007-04-02 14:35:34 +02:00
|
|
|
/* Multicast frame. */
|
2009-12-20 16:52:24 +01:00
|
|
|
TRACE(RXTX, logout("%p received multicast, len=%zu,%s\n", s, size, nic_dump(buf, size)));
|
2009-09-23 17:42:42 +02:00
|
|
|
if (s->configuration[21] & BIT(3)) {
|
2009-12-20 16:52:24 +01:00
|
|
|
/* Multicast all bit is set, receive all multicast frames. */
|
|
|
|
} else {
|
2017-12-15 19:41:46 +01:00
|
|
|
unsigned mcast_idx = (net_crc32(buf, ETH_ALEN) & BITS(7, 2)) >> 2;
|
2009-12-20 16:52:24 +01:00
|
|
|
assert(mcast_idx < 64);
|
|
|
|
if (s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))) {
|
|
|
|
/* Multicast frame is allowed in hash table. */
|
2010-03-02 22:37:49 +01:00
|
|
|
} else if (s->configuration[15] & BIT(0)) {
|
2009-12-20 16:52:24 +01:00
|
|
|
/* Promiscuous: receive all. */
|
|
|
|
rfd_status |= 0x0004;
|
|
|
|
} else {
|
|
|
|
TRACE(RXTX, logout("%p multicast ignored\n", s));
|
|
|
|
return -1;
|
|
|
|
}
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
2009-12-20 16:52:24 +01:00
|
|
|
/* TODO: Next not for promiscuous mode? */
|
2007-04-02 14:35:34 +02:00
|
|
|
rfd_status |= 0x0002;
|
2010-03-02 22:37:49 +01:00
|
|
|
} else if (s->configuration[15] & BIT(0)) {
|
2007-04-02 14:35:34 +02:00
|
|
|
/* Promiscuous: receive all. */
|
2009-09-19 12:37:51 +02:00
|
|
|
TRACE(RXTX, logout("%p received frame in promiscuous mode, len=%zu\n", s, size));
|
2007-04-02 14:35:34 +02:00
|
|
|
rfd_status |= 0x0004;
|
2010-09-29 21:59:55 +02:00
|
|
|
} else if (s->configuration[20] & BIT(6)) {
|
|
|
|
/* Multiple IA bit set. */
|
2017-12-15 19:41:49 +01:00
|
|
|
unsigned mcast_idx = net_crc32(buf, ETH_ALEN) >> 26;
|
2010-09-29 21:59:55 +02:00
|
|
|
assert(mcast_idx < 64);
|
|
|
|
if (s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))) {
|
|
|
|
TRACE(RXTX, logout("%p accepted, multiple IA bit set\n", s));
|
|
|
|
} else {
|
|
|
|
TRACE(RXTX, logout("%p frame ignored, multiple IA bit set\n", s));
|
|
|
|
return -1;
|
|
|
|
}
|
2007-04-02 14:35:34 +02:00
|
|
|
} else {
|
2009-09-19 12:37:51 +02:00
|
|
|
TRACE(RXTX, logout("%p received frame, ignored, len=%zu,%s\n", s, size,
|
2009-09-19 12:11:36 +02:00
|
|
|
nic_dump(buf, size)));
|
2009-05-18 14:40:55 +02:00
|
|
|
return size;
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (get_ru_state(s) != ru_ready) {
|
2009-09-19 12:11:36 +02:00
|
|
|
/* No resources available. */
|
|
|
|
logout("no resources, state=%u\n", get_ru_state(s));
|
2010-03-02 22:37:53 +01:00
|
|
|
/* TODO: RNR interrupt only at first failed frame? */
|
|
|
|
eepro100_rnr_interrupt(s);
|
2007-04-02 14:35:34 +02:00
|
|
|
s->statistics.rx_resource_errors++;
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
|
|
|
assert(!"no resources");
|
|
|
|
#endif
|
2009-05-18 14:40:55 +02:00
|
|
|
return -1;
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
2010-03-02 22:37:59 +01:00
|
|
|
/* !!! */
|
2009-10-01 23:12:16 +02:00
|
|
|
eepro100_rx_t rx;
|
2011-10-31 07:06:49 +01:00
|
|
|
pci_dma_read(&s->dev, s->ru_base + s->ru_offset,
|
2011-11-04 02:03:32 +01:00
|
|
|
&rx, sizeof(eepro100_rx_t));
|
2007-04-02 14:35:34 +02:00
|
|
|
uint16_t rfd_command = le16_to_cpu(rx.command);
|
|
|
|
uint16_t rfd_size = le16_to_cpu(rx.size);
|
2009-09-23 17:42:42 +02:00
|
|
|
|
|
|
|
if (size > rfd_size) {
|
|
|
|
logout("Receive buffer (%" PRId16 " bytes) too small for data "
|
|
|
|
"(%zu bytes); data truncated\n", rfd_size, size);
|
|
|
|
size = rfd_size;
|
|
|
|
}
|
2011-04-30 22:40:07 +02:00
|
|
|
#if !defined(CONFIG_PAD_RECEIVED_FRAMES)
|
2007-04-02 14:35:34 +02:00
|
|
|
if (size < 64) {
|
|
|
|
rfd_status |= 0x0080;
|
|
|
|
}
|
2011-04-30 22:40:07 +02:00
|
|
|
#endif
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n",
|
|
|
|
rfd_command, rx.link, rx.rx_buf_addr, rfd_size));
|
2011-10-31 07:06:49 +01:00
|
|
|
stw_le_pci_dma(&s->dev, s->ru_base + s->ru_offset +
|
|
|
|
offsetof(eepro100_rx_t, status), rfd_status);
|
|
|
|
stw_le_pci_dma(&s->dev, s->ru_base + s->ru_offset +
|
|
|
|
offsetof(eepro100_rx_t, count), size);
|
2007-04-02 14:35:34 +02:00
|
|
|
/* Early receive interrupt not supported. */
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
|
|
|
eepro100_er_interrupt(s);
|
|
|
|
#endif
|
2007-04-02 14:35:34 +02:00
|
|
|
/* Receive CRC Transfer not supported. */
|
2010-03-02 22:37:49 +01:00
|
|
|
if (s->configuration[18] & BIT(2)) {
|
2009-09-23 17:42:42 +02:00
|
|
|
missing("Receive CRC Transfer");
|
|
|
|
return -1;
|
|
|
|
}
|
2007-04-02 14:35:34 +02:00
|
|
|
/* TODO: check stripping enable bit. */
|
2010-03-02 22:37:59 +01:00
|
|
|
#if 0
|
|
|
|
assert(!(s->configuration[17] & BIT(0)));
|
|
|
|
#endif
|
2011-10-31 07:06:49 +01:00
|
|
|
pci_dma_write(&s->dev, s->ru_base + s->ru_offset +
|
|
|
|
sizeof(eepro100_rx_t), buf, size);
|
2007-04-02 14:35:34 +02:00
|
|
|
s->statistics.rx_good_frames++;
|
|
|
|
eepro100_fr_interrupt(s);
|
|
|
|
s->ru_offset = le32_to_cpu(rx.link);
|
2010-03-02 22:37:49 +01:00
|
|
|
if (rfd_command & COMMAND_EL) {
|
2007-04-02 14:35:34 +02:00
|
|
|
/* EL bit is set, so this was the last frame. */
|
2009-09-23 17:42:42 +02:00
|
|
|
logout("receive: Running out of frames\n");
|
eepro100: Fix network hang when rx buffers run out
This is reported by QA. When installing os with pxe, after the initial
kernel and initrd are loaded, the procedure tries to copy files from install
server to local harddisk, the network becomes stall because of running out of
receive descriptor.
[Whitespace fixes and removed qemu_notify_event() because Paolo's
earlier net patches have moved it into qemu_flush_queued_packets().
Additional info:
I can reproduce the network hang with a tap device doing a iPXE HTTP
boot as follows:
$ qemu -enable-kvm -m 1024 \
-netdev tap,id=netdev0,script=no,downscript=no \
-device i82559er,netdev=netdev0,romfile=80861209.rom \
-drive if=virtio,cache=none,file=test.img
iPXE> ifopen net0
iPXE> config # set static network configuration
iPXE> kernel http://mirror.bytemark.co.uk/fedora/linux/releases/17/Fedora/x86_64/os/images/pxeboot/vmlinuz
I needed a vanilla iPXE ROM to get to the iPXE prompt. I think the boot
prompt has been disabled in the ROMs that ship with QEMU to reduce boot
time.
During the vmlinuz HTTP download there is a network hang. hw/eepro100.c
has reached the end of the rx descriptor list. When the iPXE driver
replenishes the rx descriptor list we don't kick the QEMU net subsystem
and event loop, thereby leaving the tap netdev without its file
descriptor in select(2).
Stefan Hajnoczi <stefanha@gmail.com>]
Signed-off-by: Bo Yang <boyang@suse.com>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2012-08-29 13:26:11 +02:00
|
|
|
set_ru_state(s, ru_no_resources);
|
|
|
|
eepro100_rnr_interrupt(s);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
2010-03-02 22:37:49 +01:00
|
|
|
if (rfd_command & COMMAND_S) {
|
2007-04-02 14:35:34 +02:00
|
|
|
/* S bit is set. */
|
|
|
|
set_ru_state(s, ru_suspended);
|
|
|
|
}
|
2009-05-18 14:40:55 +02:00
|
|
|
return size;
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
2009-10-19 15:37:57 +02:00
|
|
|
static const VMStateDescription vmstate_eepro100 = {
|
|
|
|
.version_id = 3,
|
|
|
|
.minimum_version_id = 2,
|
2014-04-16 15:32:32 +02:00
|
|
|
.fields = (VMStateField[]) {
|
2009-10-19 15:37:57 +02:00
|
|
|
VMSTATE_PCI_DEVICE(dev, EEPRO100State),
|
|
|
|
VMSTATE_UNUSED(32),
|
|
|
|
VMSTATE_BUFFER(mult, EEPRO100State),
|
|
|
|
VMSTATE_BUFFER(mem, EEPRO100State),
|
|
|
|
/* Save all members of struct between scb_stat and mem. */
|
|
|
|
VMSTATE_UINT8(scb_stat, EEPRO100State),
|
|
|
|
VMSTATE_UINT8(int_stat, EEPRO100State),
|
|
|
|
VMSTATE_UNUSED(3*4),
|
|
|
|
VMSTATE_MACADDR(conf.macaddr, EEPRO100State),
|
|
|
|
VMSTATE_UNUSED(19*4),
|
|
|
|
VMSTATE_UINT16_ARRAY(mdimem, EEPRO100State, 32),
|
|
|
|
/* The eeprom should be saved and restored by its own routines. */
|
|
|
|
VMSTATE_UINT32(device, EEPRO100State),
|
|
|
|
/* TODO check device. */
|
|
|
|
VMSTATE_UINT32(cu_base, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(cu_offset, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(ru_base, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(ru_offset, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statsaddr, EEPRO100State),
|
2009-10-30 13:36:21 +01:00
|
|
|
/* Save eepro100_stats_t statistics. */
|
2009-10-19 15:37:57 +02:00
|
|
|
VMSTATE_UINT32(statistics.tx_good_frames, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.tx_max_collisions, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.tx_late_collisions, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.tx_underruns, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.tx_lost_crs, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.tx_deferred, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.tx_single_collisions, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.tx_multiple_collisions, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.tx_total_collisions, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.rx_good_frames, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.rx_crc_errors, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.rx_alignment_errors, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.rx_resource_errors, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.rx_overrun_errors, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.rx_cdt_errors, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.rx_short_frame_errors, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.fc_xmt_pause, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.fc_rcv_pause, EEPRO100State),
|
|
|
|
VMSTATE_UINT32(statistics.fc_rcv_unsupported, EEPRO100State),
|
|
|
|
VMSTATE_UINT16(statistics.xmt_tco_frames, EEPRO100State),
|
|
|
|
VMSTATE_UINT16(statistics.rcv_tco_frames, EEPRO100State),
|
|
|
|
/* Configuration bytes. */
|
|
|
|
VMSTATE_BUFFER(configuration, EEPRO100State),
|
|
|
|
VMSTATE_END_OF_LIST()
|
2009-09-19 12:11:36 +02:00
|
|
|
}
|
2009-10-19 15:37:57 +02:00
|
|
|
};
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2012-07-04 06:39:27 +02:00
|
|
|
static void pci_nic_uninit(PCIDevice *pci_dev)
|
2009-04-17 19:11:08 +02:00
|
|
|
{
|
2009-09-19 13:02:09 +02:00
|
|
|
EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
|
2009-04-17 19:11:08 +02:00
|
|
|
|
2010-06-25 19:09:07 +02:00
|
|
|
vmstate_unregister(&pci_dev->qdev, s->vmstate, s);
|
2016-10-08 14:07:25 +02:00
|
|
|
g_free(s->vmstate);
|
2010-06-25 19:09:21 +02:00
|
|
|
eeprom93xx_free(&pci_dev->qdev, s->eeprom);
|
2013-01-30 12:12:24 +01:00
|
|
|
qemu_del_nic(s->nic);
|
2009-04-17 19:11:08 +02:00
|
|
|
}
|
|
|
|
|
2009-11-25 19:49:16 +01:00
|
|
|
static NetClientInfo net_eepro100_info = {
|
qapi: Change Netdev into a flat union
This is a mostly-mechanical conversion that creates a new flat
union 'Netdev' QAPI type that covers all the branches of the
former 'NetClientOptions' simple union, where the branches are
now listed in a new 'NetClientDriver' enum rather than generated
from the simple union. The existence of a flat union has no
change to the command line syntax accepted for new code, and
will make it possible for a future patch to switch the QMP
command to parse a boxed union for no change to valid QMP; but
it does have some ripple effect on the C code when dealing with
the new types.
While making the conversion, note that the 'NetLegacy' type
remains unchanged: it applies only to legacy command line options,
and will not be ported to QMP, so it should remain a wrapper
around a simple union; to avoid confusion, the type named
'NetClientOptions' is now gone, and we introduce 'NetLegacyOptions'
in its place. Then, in the C code, we convert from NetLegacy to
Netdev as soon as possible, so that the bulk of the net stack
only has to deal with one QAPI type, not two. Note that since
the old legacy code always rejected 'hubport', we can just omit
that branch from the new 'NetLegacyOptions' simple union.
Based on an idea originally by Zoltán Kővágó <DirtY.iCE.hu@gmail.com>:
Message-Id: <01a527fbf1a5de880091f98cf011616a78adeeee.1441627176.git.DirtY.iCE.hu@gmail.com>
although the sed script in that patch no longer applies due to
other changes in the tree since then, and I also did some manual
cleanups (such as fixing whitespace to keep checkpatch happy).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1468468228-27827-13-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Fixup from Eric squashed in]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-07-14 05:50:23 +02:00
|
|
|
.type = NET_CLIENT_DRIVER_NIC,
|
2009-11-25 19:49:16 +01:00
|
|
|
.size = sizeof(NICState),
|
|
|
|
.receive = nic_receive,
|
|
|
|
};
|
|
|
|
|
2015-01-19 15:52:30 +01:00
|
|
|
static void e100_nic_realize(PCIDevice *pci_dev, Error **errp)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
2009-08-24 18:42:37 +02:00
|
|
|
EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
|
2011-12-04 19:22:06 +01:00
|
|
|
E100PCIDeviceInfo *info = eepro100_get_class(s);
|
2017-06-27 08:16:50 +02:00
|
|
|
Error *local_err = NULL;
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2009-09-19 12:11:36 +02:00
|
|
|
TRACE(OTHER, logout("\n"));
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2011-12-04 19:22:06 +01:00
|
|
|
s->device = info->device;
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2017-06-27 08:16:50 +02:00
|
|
|
e100_pci_reset(s, &local_err);
|
|
|
|
if (local_err) {
|
|
|
|
error_propagate(errp, local_err);
|
|
|
|
return;
|
|
|
|
}
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
/* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM,
|
|
|
|
* i82559 and later support 64 or 256 word EEPROM. */
|
2010-06-25 19:09:21 +02:00
|
|
|
s->eeprom = eeprom93xx_new(&pci_dev->qdev, EEPROM_SIZE);
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
/* Handler for memory-mapped I/O */
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&s->mmio_bar, OBJECT(s), &eepro100_ops, s,
|
|
|
|
"eepro100-mmio", PCI_MEM_SIZE);
|
2011-08-08 15:09:31 +02:00
|
|
|
pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->mmio_bar);
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&s->io_bar, OBJECT(s), &eepro100_ops, s,
|
|
|
|
"eepro100-io", PCI_IO_SIZE);
|
2011-08-08 15:09:31 +02:00
|
|
|
pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->io_bar);
|
2011-08-08 15:09:09 +02:00
|
|
|
/* FIXME: flash aliases to mmio?! */
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&s->flash_bar, OBJECT(s), &eepro100_ops, s,
|
|
|
|
"eepro100-flash", PCI_FLASH_SIZE);
|
2011-08-08 15:09:31 +02:00
|
|
|
pci_register_bar(&s->dev, 2, 0, &s->flash_bar);
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2009-10-21 15:25:36 +02:00
|
|
|
qemu_macaddr_default_if_unset(&s->conf.macaddr);
|
2010-03-02 22:37:41 +01:00
|
|
|
logout("macaddr: %s\n", nic_dump(&s->conf.macaddr.a[0], 6));
|
2007-04-02 14:35:34 +02:00
|
|
|
|
|
|
|
nic_reset(s);
|
|
|
|
|
2009-11-25 19:49:16 +01:00
|
|
|
s->nic = qemu_new_nic(&net_eepro100_info, &s->conf,
|
2011-12-04 18:17:51 +01:00
|
|
|
object_get_typename(OBJECT(pci_dev)), pci_dev->qdev.id, s);
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2013-01-30 12:12:22 +01:00
|
|
|
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
|
|
|
|
TRACE(OTHER, logout("%s\n", qemu_get_queue(s->nic)->info_str));
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2009-06-27 09:25:07 +02:00
|
|
|
qemu_register_reset(nic_reset, s);
|
2007-04-02 14:35:34 +02:00
|
|
|
|
2017-06-06 22:45:43 +02:00
|
|
|
s->vmstate = g_memdup(&vmstate_eepro100, sizeof(vmstate_eepro100));
|
2013-01-30 12:12:22 +01:00
|
|
|
s->vmstate->name = qemu_get_queue(s->nic)->model;
|
2010-06-25 19:09:07 +02:00
|
|
|
vmstate_register(&pci_dev->qdev, -1, s->vmstate, s);
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 10:00:14 +02:00
|
|
|
static void eepro100_instance_init(Object *obj)
|
|
|
|
{
|
|
|
|
EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, PCI_DEVICE(obj));
|
|
|
|
device_add_bootindex_property(obj, &s->conf.bootindex,
|
|
|
|
"bootindex", "/ethernet-phy@0",
|
|
|
|
DEVICE(s), NULL);
|
|
|
|
}
|
|
|
|
|
2010-04-06 13:44:03 +02:00
|
|
|
static E100PCIDeviceInfo e100_devices[] = {
|
2009-06-30 14:12:07 +02:00
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "i82550",
|
|
|
|
.desc = "Intel i82550 Ethernet",
|
2010-04-06 13:44:03 +02:00
|
|
|
.device = i82550,
|
|
|
|
/* TODO: check device id. */
|
2011-12-04 19:22:06 +01:00
|
|
|
.device_id = PCI_DEVICE_ID_INTEL_82551IT,
|
2010-04-06 13:44:03 +02:00
|
|
|
/* Revision ID: 0x0c, 0x0d, 0x0e. */
|
2011-12-04 19:22:06 +01:00
|
|
|
.revision = 0x0e,
|
2010-04-06 13:44:03 +02:00
|
|
|
/* TODO: check size of statistical counters. */
|
|
|
|
.stats_size = 80,
|
|
|
|
/* TODO: check extended tcb support. */
|
|
|
|
.has_extended_tcb_support = true,
|
|
|
|
.power_management = true,
|
2009-09-19 13:02:09 +02:00
|
|
|
},{
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "i82551",
|
|
|
|
.desc = "Intel i82551 Ethernet",
|
2010-04-06 13:44:03 +02:00
|
|
|
.device = i82551,
|
2011-12-04 19:22:06 +01:00
|
|
|
.device_id = PCI_DEVICE_ID_INTEL_82551IT,
|
2010-04-06 13:44:03 +02:00
|
|
|
/* Revision ID: 0x0f, 0x10. */
|
2011-12-04 19:22:06 +01:00
|
|
|
.revision = 0x0f,
|
2010-04-06 13:44:03 +02:00
|
|
|
/* TODO: check size of statistical counters. */
|
|
|
|
.stats_size = 80,
|
|
|
|
.has_extended_tcb_support = true,
|
|
|
|
.power_management = true,
|
2009-06-30 14:12:07 +02:00
|
|
|
},{
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "i82557a",
|
|
|
|
.desc = "Intel i82557A Ethernet",
|
2010-04-06 13:44:03 +02:00
|
|
|
.device = i82557A,
|
2011-12-04 19:22:06 +01:00
|
|
|
.device_id = PCI_DEVICE_ID_INTEL_82557,
|
|
|
|
.revision = 0x01,
|
2010-04-06 13:44:03 +02:00
|
|
|
.power_management = false,
|
2009-09-19 13:02:09 +02:00
|
|
|
},{
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "i82557b",
|
|
|
|
.desc = "Intel i82557B Ethernet",
|
2010-04-06 13:44:03 +02:00
|
|
|
.device = i82557B,
|
2011-12-04 19:22:06 +01:00
|
|
|
.device_id = PCI_DEVICE_ID_INTEL_82557,
|
|
|
|
.revision = 0x02,
|
2010-04-06 13:44:03 +02:00
|
|
|
.power_management = false,
|
2009-09-19 13:02:09 +02:00
|
|
|
},{
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "i82557c",
|
|
|
|
.desc = "Intel i82557C Ethernet",
|
2010-04-06 13:44:03 +02:00
|
|
|
.device = i82557C,
|
2011-12-04 19:22:06 +01:00
|
|
|
.device_id = PCI_DEVICE_ID_INTEL_82557,
|
|
|
|
.revision = 0x03,
|
2010-04-06 13:44:03 +02:00
|
|
|
.power_management = false,
|
2009-09-19 13:02:09 +02:00
|
|
|
},{
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "i82558a",
|
|
|
|
.desc = "Intel i82558A Ethernet",
|
2010-04-06 13:44:03 +02:00
|
|
|
.device = i82558A,
|
2011-12-04 19:22:06 +01:00
|
|
|
.device_id = PCI_DEVICE_ID_INTEL_82557,
|
|
|
|
.revision = 0x04,
|
2010-04-06 13:44:03 +02:00
|
|
|
.stats_size = 76,
|
|
|
|
.has_extended_tcb_support = true,
|
|
|
|
.power_management = true,
|
2009-09-19 13:02:09 +02:00
|
|
|
},{
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "i82558b",
|
|
|
|
.desc = "Intel i82558B Ethernet",
|
2010-04-06 13:44:03 +02:00
|
|
|
.device = i82558B,
|
2011-12-04 19:22:06 +01:00
|
|
|
.device_id = PCI_DEVICE_ID_INTEL_82557,
|
|
|
|
.revision = 0x05,
|
2010-04-06 13:44:03 +02:00
|
|
|
.stats_size = 76,
|
|
|
|
.has_extended_tcb_support = true,
|
|
|
|
.power_management = true,
|
2009-09-19 13:02:09 +02:00
|
|
|
},{
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "i82559a",
|
|
|
|
.desc = "Intel i82559A Ethernet",
|
2010-04-06 13:44:03 +02:00
|
|
|
.device = i82559A,
|
2011-12-04 19:22:06 +01:00
|
|
|
.device_id = PCI_DEVICE_ID_INTEL_82557,
|
|
|
|
.revision = 0x06,
|
2010-04-06 13:44:03 +02:00
|
|
|
.stats_size = 80,
|
|
|
|
.has_extended_tcb_support = true,
|
|
|
|
.power_management = true,
|
2009-09-19 13:02:09 +02:00
|
|
|
},{
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "i82559b",
|
|
|
|
.desc = "Intel i82559B Ethernet",
|
2010-04-06 13:44:03 +02:00
|
|
|
.device = i82559B,
|
2011-12-04 19:22:06 +01:00
|
|
|
.device_id = PCI_DEVICE_ID_INTEL_82557,
|
|
|
|
.revision = 0x07,
|
2010-04-06 13:44:03 +02:00
|
|
|
.stats_size = 80,
|
|
|
|
.has_extended_tcb_support = true,
|
|
|
|
.power_management = true,
|
2009-06-30 14:12:07 +02:00
|
|
|
},{
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "i82559c",
|
|
|
|
.desc = "Intel i82559C Ethernet",
|
2010-04-06 13:44:03 +02:00
|
|
|
.device = i82559C,
|
2011-12-04 19:22:06 +01:00
|
|
|
.device_id = PCI_DEVICE_ID_INTEL_82557,
|
2010-04-06 13:44:03 +02:00
|
|
|
#if 0
|
2011-12-04 19:22:06 +01:00
|
|
|
.revision = 0x08,
|
2010-04-06 13:44:03 +02:00
|
|
|
#endif
|
|
|
|
/* TODO: Windows wants revision id 0x0c. */
|
2011-12-04 19:22:06 +01:00
|
|
|
.revision = 0x0c,
|
2011-05-25 03:58:00 +02:00
|
|
|
#if EEPROM_SIZE > 0
|
2011-12-04 19:22:06 +01:00
|
|
|
.subsystem_vendor_id = PCI_VENDOR_ID_INTEL,
|
|
|
|
.subsystem_id = 0x0040,
|
2011-05-25 03:58:00 +02:00
|
|
|
#endif
|
2010-04-06 13:44:03 +02:00
|
|
|
.stats_size = 80,
|
|
|
|
.has_extended_tcb_support = true,
|
|
|
|
.power_management = true,
|
2009-09-19 13:02:09 +02:00
|
|
|
},{
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "i82559er",
|
|
|
|
.desc = "Intel i82559ER Ethernet",
|
2010-04-06 13:44:03 +02:00
|
|
|
.device = i82559ER,
|
2011-12-04 19:22:06 +01:00
|
|
|
.device_id = PCI_DEVICE_ID_INTEL_82551IT,
|
|
|
|
.revision = 0x09,
|
2010-04-06 13:44:03 +02:00
|
|
|
.stats_size = 80,
|
|
|
|
.has_extended_tcb_support = true,
|
|
|
|
.power_management = true,
|
2009-06-30 14:12:07 +02:00
|
|
|
},{
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "i82562",
|
|
|
|
.desc = "Intel i82562 Ethernet",
|
2010-04-06 13:44:03 +02:00
|
|
|
.device = i82562,
|
|
|
|
/* TODO: check device id. */
|
2011-12-04 19:22:06 +01:00
|
|
|
.device_id = PCI_DEVICE_ID_INTEL_82551IT,
|
2010-04-06 13:44:03 +02:00
|
|
|
/* TODO: wrong revision id. */
|
2011-12-04 19:22:06 +01:00
|
|
|
.revision = 0x0e,
|
2010-04-06 13:44:03 +02:00
|
|
|
.stats_size = 80,
|
|
|
|
.has_extended_tcb_support = true,
|
|
|
|
.power_management = true,
|
2010-04-06 13:44:04 +02:00
|
|
|
},{
|
|
|
|
/* Toshiba Tecra 8200. */
|
2011-12-08 04:34:16 +01:00
|
|
|
.name = "i82801",
|
|
|
|
.desc = "Intel i82801 Ethernet",
|
2010-04-06 13:44:04 +02:00
|
|
|
.device = i82801,
|
2011-12-04 19:22:06 +01:00
|
|
|
.device_id = 0x2449,
|
|
|
|
.revision = 0x03,
|
2010-04-06 13:44:04 +02:00
|
|
|
.stats_size = 80,
|
|
|
|
.has_extended_tcb_support = true,
|
|
|
|
.power_management = true,
|
2009-06-30 14:12:07 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-12-04 19:22:06 +01:00
|
|
|
static E100PCIDeviceInfo *eepro100_get_class_by_name(const char *typename)
|
|
|
|
{
|
|
|
|
E100PCIDeviceInfo *info = NULL;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* This is admittedly awkward but also temporary. QOM allows for
|
|
|
|
* parameterized typing and for subclassing both of which would suitable
|
|
|
|
* handle what's going on here. But class_data is already being used as
|
|
|
|
* a stop-gap hack to allow incremental qdev conversion so we cannot use it
|
|
|
|
* right now. Once we merge the final QOM series, we can come back here and
|
|
|
|
* do this in a much more elegant fashion.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < ARRAY_SIZE(e100_devices); i++) {
|
2011-12-08 04:34:16 +01:00
|
|
|
if (strcmp(e100_devices[i].name, typename) == 0) {
|
2011-12-04 19:22:06 +01:00
|
|
|
info = &e100_devices[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(info != NULL);
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
static E100PCIDeviceInfo *eepro100_get_class(EEPRO100State *s)
|
|
|
|
{
|
|
|
|
return eepro100_get_class_by_name(object_get_typename(OBJECT(s)));
|
|
|
|
}
|
|
|
|
|
2011-12-08 04:34:16 +01:00
|
|
|
static Property e100_properties[] = {
|
|
|
|
DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
|
|
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
|
|
};
|
|
|
|
|
2011-12-04 19:22:06 +01:00
|
|
|
static void eepro100_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2011-12-04 19:22:06 +01:00
|
|
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
|
|
|
E100PCIDeviceInfo *info;
|
|
|
|
|
|
|
|
info = eepro100_get_class_by_name(object_class_get_name(klass));
|
|
|
|
|
2013-07-29 16:17:45 +02:00
|
|
|
set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
|
2011-12-08 04:34:16 +01:00
|
|
|
dc->props = e100_properties;
|
|
|
|
dc->desc = info->desc;
|
2011-12-04 19:22:06 +01:00
|
|
|
k->vendor_id = PCI_VENDOR_ID_INTEL;
|
|
|
|
k->class_id = PCI_CLASS_NETWORK_ETHERNET;
|
|
|
|
k->romfile = "pxe-eepro100.rom";
|
2015-01-19 15:52:30 +01:00
|
|
|
k->realize = e100_nic_realize;
|
2011-12-04 19:22:06 +01:00
|
|
|
k->exit = pci_nic_uninit;
|
|
|
|
k->device_id = info->device_id;
|
|
|
|
k->revision = info->revision;
|
|
|
|
k->subsystem_vendor_id = info->subsystem_vendor_id;
|
|
|
|
k->subsystem_id = info->subsystem_id;
|
|
|
|
}
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
static void eepro100_register_types(void)
|
2007-04-02 14:35:34 +02:00
|
|
|
{
|
2010-04-06 13:44:03 +02:00
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(e100_devices); i++) {
|
2011-12-08 04:34:16 +01:00
|
|
|
TypeInfo type_info = {};
|
|
|
|
E100PCIDeviceInfo *info = &e100_devices[i];
|
2011-12-04 19:22:06 +01:00
|
|
|
|
2011-12-08 04:34:16 +01:00
|
|
|
type_info.name = info->name;
|
|
|
|
type_info.parent = TYPE_PCI_DEVICE;
|
|
|
|
type_info.class_init = eepro100_class_init;
|
|
|
|
type_info.instance_size = sizeof(EEPRO100State);
|
2014-10-07 10:00:14 +02:00
|
|
|
type_info.instance_init = eepro100_instance_init;
|
2017-09-27 21:56:34 +02:00
|
|
|
type_info.interfaces = (InterfaceInfo[]) {
|
|
|
|
{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
|
|
|
|
{ },
|
|
|
|
};
|
2014-10-07 10:00:14 +02:00
|
|
|
|
2011-12-08 04:34:16 +01:00
|
|
|
type_register(&type_info);
|
2010-04-06 13:44:03 +02:00
|
|
|
}
|
2007-04-02 14:35:34 +02:00
|
|
|
}
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
type_init(eepro100_register_types)
|