mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
i82596: Added core infrastructure and helper functions
As a part of GSOC 2025 I have done a massive rewrite of what was the 82596 NIC. This has been done to add the missing functionality according to the 82596 Manual and making the code production ready. This patch adds: - comprehensive 82596 constants and configuration macros - address translation for segmented/linear memory modes - error recording and statistics tracking infrastructure - CRC-16/32 calculation and appending functions - CSMA/CD collision detection and backoff logic - bus throttle timer framework - enhanced reset with full state initialization - receive_iov and polling support functions - updated VMState for migration of all new fields Note: This patch primarily includes placeholder code. To achieve full 82596 emulation, the complete 82596 patch series is required. Nevertheless, QEMU is able to load and boot successfully with this patch. Signed-off-by: Soumyajyotii Ssarkar <soumyajyotisarkar23@gmail.com> Tested-by: Helge Deller <deller@gmx.de> Tested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Helge Deller <deller@gmx.de>
This commit is contained in:
committed by
Helge Deller
parent
b2d0bf872d
commit
cbf62eef84
+588
-75
File diff suppressed because it is too large
Load Diff
+59
-15
@@ -6,11 +6,15 @@
|
||||
#include "system/memory.h"
|
||||
#include "system/address-spaces.h"
|
||||
|
||||
#define PORT_RESET 0x00 /* reset 82596 */
|
||||
#define PORT_SELFTEST 0x01 /* selftest */
|
||||
#define PORT_ALTSCP 0x02 /* alternate SCB address */
|
||||
#define PORT_ALTDUMP 0x03 /* Alternate DUMP address */
|
||||
#define PORT_CA 0x10 /* QEMU-internal CA signal */
|
||||
#define PACKET_QUEUE_SIZE 64
|
||||
#define RX_RING_SIZE 16
|
||||
#define PKT_BUF_SZ 1536
|
||||
|
||||
#define PORT_RESET 0x00
|
||||
#define PORT_SELFTEST 0x01
|
||||
#define PORT_ALTSCP 0x02
|
||||
#define PORT_ALTDUMP 0x03
|
||||
#define PORT_CA 0x10
|
||||
|
||||
typedef struct I82596State_st I82596State;
|
||||
|
||||
@@ -21,35 +25,75 @@ struct I82596State_st {
|
||||
NICState *nic;
|
||||
NICConf conf;
|
||||
QEMUTimer *flush_queue_timer;
|
||||
uint8_t mode;
|
||||
|
||||
hwaddr scp; /* pointer to SCP */
|
||||
QEMUTimer *throttle_timer;
|
||||
uint16_t t_on;
|
||||
uint16_t t_off;
|
||||
bool throttle_state;
|
||||
|
||||
hwaddr scp;
|
||||
uint32_t iscp;
|
||||
uint8_t sysbus;
|
||||
uint32_t scb; /* SCB */
|
||||
uint32_t scb;
|
||||
uint32_t scb_base;
|
||||
uint16_t scb_status;
|
||||
uint8_t cu_status, rx_status;
|
||||
uint16_t lnkst;
|
||||
uint32_t last_tx_len;
|
||||
uint32_t collision_events;
|
||||
uint32_t total_collisions;
|
||||
|
||||
uint32_t cmd_p; /* addr of current command */
|
||||
uint32_t tx_retry_addr;
|
||||
int tx_retry_count;
|
||||
uint32_t tx_good_frames;
|
||||
uint32_t tx_collisions;
|
||||
uint32_t tx_aborted_errors;
|
||||
|
||||
uint32_t cmd_p;
|
||||
int ca;
|
||||
int ca_active;
|
||||
int send_irq;
|
||||
|
||||
/* Hash register (multicast mask array, multiple individual addresses). */
|
||||
uint8_t mult[8];
|
||||
uint8_t config[14]; /* config bytes from CONFIGURE command */
|
||||
uint8_t config[14];
|
||||
|
||||
uint8_t tx_buffer[0x4000];
|
||||
uint32_t crc_err;
|
||||
uint32_t align_err;
|
||||
uint32_t resource_err;
|
||||
uint32_t over_err;
|
||||
uint32_t rcvdt_err;
|
||||
uint32_t short_fr_error;
|
||||
uint32_t total_frames;
|
||||
uint32_t total_good_frames;
|
||||
|
||||
uint8_t tx_buffer[PKT_BUF_SZ];
|
||||
uint8_t rx_buffer[PKT_BUF_SZ];
|
||||
uint16_t tx_frame_len;
|
||||
uint16_t rx_frame_len;
|
||||
|
||||
hwaddr current_tx_desc;
|
||||
hwaddr current_rx_desc;
|
||||
uint32_t last_good_rfa;
|
||||
uint8_t packet_queue[PACKET_QUEUE_SIZE][PKT_BUF_SZ];
|
||||
size_t packet_queue_len[PACKET_QUEUE_SIZE];
|
||||
int queue_head;
|
||||
int queue_tail;
|
||||
int queue_count;
|
||||
bool rnr_signaled;
|
||||
bool flushing_queue;
|
||||
};
|
||||
|
||||
void i82596_h_reset(void *opaque);
|
||||
void i82596_ioport_writew(void *opaque, uint32_t addr, uint32_t val);
|
||||
uint32_t i82596_ioport_readw(void *opaque, uint32_t addr);
|
||||
void i82596_ioport_writel(void *opaque, uint32_t addr, uint32_t val);
|
||||
uint32_t i82596_ioport_readl(void *opaque, uint32_t addr);
|
||||
uint32_t i82596_bcr_readw(I82596State *s, uint32_t rap);
|
||||
ssize_t i82596_receive(NetClientState *nc, const uint8_t *buf, size_t size_);
|
||||
ssize_t i82596_receive_iov(NetClientState *nc, const struct iovec *iov,
|
||||
int iovcnt);
|
||||
bool i82596_can_receive(NetClientState *nc);
|
||||
void i82596_set_link_status(NetClientState *nc);
|
||||
void i82596_common_init(DeviceState *dev, I82596State *s, NetClientInfo *info);
|
||||
void i82596_poll(NetClientState *nc, bool enable);
|
||||
void i82596_common_init(DeviceState *dev, I82596State *s,
|
||||
NetClientInfo *info);
|
||||
extern const VMStateDescription vmstate_i82596;
|
||||
#endif
|
||||
|
||||
@@ -86,6 +86,10 @@ static const MemoryRegionOps lasi_82596_mem_ops = {
|
||||
.min_access_size = 4,
|
||||
.max_access_size = 4,
|
||||
},
|
||||
.impl = {
|
||||
.min_access_size = 4,
|
||||
.max_access_size = 4,
|
||||
},
|
||||
};
|
||||
|
||||
static NetClientInfo net_lasi_82596_info = {
|
||||
@@ -93,6 +97,8 @@ static NetClientInfo net_lasi_82596_info = {
|
||||
.size = sizeof(NICState),
|
||||
.can_receive = i82596_can_receive,
|
||||
.receive = i82596_receive,
|
||||
.receive_iov = i82596_receive_iov,
|
||||
.poll = i82596_poll,
|
||||
.link_status_changed = i82596_set_link_status,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user