diff --git a/src/devices/machine/am79c90.cpp b/src/devices/machine/am79c90.cpp index 38da531a2cd..ce2fb4837fe 100644 --- a/src/devices/machine/am79c90.cpp +++ b/src/devices/machine/am79c90.cpp @@ -59,7 +59,7 @@ DEFINE_DEVICE_TYPE(AM79C90, am79c90_device, "am79c90", "Am79C90 C-LANCE Ethernet am7990_device_base::am7990_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, type, tag, owner, clock) - , device_network_interface(mconfig, *this, 10.0f) + , device_network_interface(mconfig, *this, 10) , m_intr_out_cb(*this) , m_dma_in_cb(*this) , m_dma_out_cb(*this) diff --git a/src/devices/machine/cs8900a.cpp b/src/devices/machine/cs8900a.cpp index 6f6535150f7..52e0808bb01 100644 --- a/src/devices/machine/cs8900a.cpp +++ b/src/devices/machine/cs8900a.cpp @@ -377,7 +377,7 @@ void cs8900a_device::device_start() cs8900a_device::cs8900a_device(const machine_config& mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, type, tag, owner, clock) - , device_network_interface(mconfig, *this, 10.0f) + , device_network_interface(mconfig, *this, 10) , cs8900_ia_mac{0, 0, 0, 0, 0, 0} , cs8900_packetpage_ptr(0) , cs8900_recv_control(0) /* copy of CC_RXCTL (contains all bits below) */ diff --git a/src/devices/machine/dp8390.cpp b/src/devices/machine/dp8390.cpp index 75217661215..49b98e94846 100644 --- a/src/devices/machine/dp8390.cpp +++ b/src/devices/machine/dp8390.cpp @@ -19,7 +19,7 @@ rtl8019a_device::rtl8019a_device(const machine_config &mconfig, const char *tag, { } -dp8390_device::dp8390_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, TYPE variant, float bandwidth) +dp8390_device::dp8390_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, TYPE variant, u32 bandwidth) : device_t(mconfig, type, tag, owner, clock) , device_network_interface(mconfig, *this, bandwidth) , m_variant(variant) diff --git a/src/devices/machine/dp8390.h b/src/devices/machine/dp8390.h index 64bc6436733..1dfde1f01a5 100644 --- a/src/devices/machine/dp8390.h +++ b/src/devices/machine/dp8390.h @@ -30,7 +30,7 @@ protected: }; // construction/destruction - dp8390_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, TYPE varian, float bandwidth); + dp8390_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, TYPE varian, u32 bandwidth); // device-level overrides virtual void device_start() override; diff --git a/src/devices/machine/dp83932c.cpp b/src/devices/machine/dp83932c.cpp index ef50d8ed4e0..cadef10e602 100644 --- a/src/devices/machine/dp83932c.cpp +++ b/src/devices/machine/dp83932c.cpp @@ -66,7 +66,7 @@ static u16 const regmask[] = dp83932c_device::dp83932c_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock) : device_t(mconfig, DP83932C, tag, owner, clock) - , device_network_interface(mconfig, *this, 10.0f) + , device_network_interface(mconfig, *this, 10) , m_bus(*this, finder_base::DUMMY_TAG, 0) , m_out_int(*this) , m_int_state(false) diff --git a/src/devices/machine/edlc.cpp b/src/devices/machine/edlc.cpp index 87f42602828..480b0520c03 100644 --- a/src/devices/machine/edlc.cpp +++ b/src/devices/machine/edlc.cpp @@ -39,7 +39,7 @@ static const u8 ETH_BROADCAST[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; seeq8003_device::seeq8003_device(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, u32 clock) : device_t(mconfig, type, tag, owner, clock) - , device_network_interface(mconfig, *this, 10.0f) + , device_network_interface(mconfig, *this, 10) , m_out_int(*this) , m_out_rxrdy(*this) , m_out_txrdy(*this) diff --git a/src/devices/machine/i82586.cpp b/src/devices/machine/i82586.cpp index 510acc4e9d2..360d404836c 100644 --- a/src/devices/machine/i82586.cpp +++ b/src/devices/machine/i82586.cpp @@ -111,7 +111,7 @@ CFG_PARAMS[] = i82586_base_device::i82586_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, endianness_t endian, u8 datawidth, u8 addrwidth) : device_t(mconfig, type, tag, owner, clock) , device_memory_interface(mconfig, *this) - , device_network_interface(mconfig, *this, 10.0f) + , device_network_interface(mconfig, *this, 10) , m_space_config("shared", endian, datawidth, addrwidth) , m_out_irq(*this) , m_cx(false) diff --git a/src/devices/machine/smc91c9x.cpp b/src/devices/machine/smc91c9x.cpp index 8b0d22f8c71..3b661933e42 100644 --- a/src/devices/machine/smc91c9x.cpp +++ b/src/devices/machine/smc91c9x.cpp @@ -62,7 +62,7 @@ smc91c96_device::smc91c96_device(const machine_config &mconfig, const char *tag, smc91c9x_device::smc91c9x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, dev_type device_type) : device_t(mconfig, type, tag, owner, clock) - , device_network_interface(mconfig, *this, 10.0f) + , device_network_interface(mconfig, *this, 10) , m_device_type(device_type) , m_num_ebuf(16) , m_irq_handler(*this) diff --git a/src/emu/dinetwork.cpp b/src/emu/dinetwork.cpp index 69cc7e9235f..3ad9f4c925b 100644 --- a/src/emu/dinetwork.cpp +++ b/src/emu/dinetwork.cpp @@ -3,11 +3,13 @@ #include "emu.h" #include "osdnet.h" -device_network_interface::device_network_interface(const machine_config &mconfig, device_t &device, float bandwidth) +device_network_interface::device_network_interface(const machine_config &mconfig, device_t &device, u32 bandwidth, u32 mtu) : device_interface(device, "network") { m_promisc = false; - m_bandwidth = bandwidth; + // Convert to Mibps to Bps + m_bandwidth = bandwidth << (20 - 3); + m_mtu = mtu; set_mac("\0\0\0\0\0\0"); m_intf = -1; m_loopback_control = false; @@ -44,7 +46,7 @@ int device_network_interface::send(u8 *buf, int len, int fcs) if (result) { // schedule receive complete callback - m_recv_timer->adjust(attotime::from_ticks(len, m_bandwidth * 1'000'000 / 8), result); + m_recv_timer->adjust(attotime::from_ticks(len, m_bandwidth), result); } } else if (m_dev) @@ -56,7 +58,7 @@ int device_network_interface::send(u8 *buf, int len, int fcs) } // schedule transmit complete callback - m_send_timer->adjust(attotime::from_ticks(len, m_bandwidth * 1'000'000 / 8), result); + m_send_timer->adjust(attotime::from_ticks(len, m_bandwidth), result); return result; } @@ -84,7 +86,7 @@ void device_network_interface::recv_cb(u8 *buf, int len) m_dev->stop(); // schedule receive complete callback - m_recv_timer->adjust(attotime::from_ticks(len, m_bandwidth * 1'000'000 / 8), result); + m_recv_timer->adjust(attotime::from_ticks(len, m_bandwidth), result); } } @@ -113,7 +115,8 @@ void device_network_interface::set_interface(int id) { if(m_dev) m_dev->stop(); - m_dev.reset(open_netdev(id, this, (int)(m_bandwidth*1000000/8.0f/1500))); + // Set device polling time to transfer time for one mtu + m_dev.reset(open_netdev(id, this, (int)(m_bandwidth / m_mtu))); if(!m_dev) { device().logerror("Network interface %d not found\n", id); id = -1; diff --git a/src/emu/dinetwork.h b/src/emu/dinetwork.h index 99909e93905..c2629f665fc 100644 --- a/src/emu/dinetwork.h +++ b/src/emu/dinetwork.h @@ -8,7 +8,7 @@ class osd_netdev; class device_network_interface : public device_interface { public: - device_network_interface(const machine_config &mconfig, device_t &device, float bandwidth); + device_network_interface(const machine_config &mconfig, device_t &device, u32 bandwidth, u32 mtu = 1500); virtual ~device_network_interface(); void interface_pre_start() override; @@ -39,7 +39,10 @@ protected: bool m_promisc; char m_mac[6]; - float m_bandwidth; + // bandwidth in bytes per second + u32 m_bandwidth; + // maximum transmission unit, used for device polling time + u32 m_mtu; std::unique_ptr m_dev; int m_intf; bool m_loopback_control;