dinetwork: Add mtu paramter and remove unnecessary floating point calculations (#9742)

This commit is contained in:
tedgreen99 2022-05-12 21:08:25 -06:00 committed by GitHub
parent 4bb59254f6
commit bdc0d0dea1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 22 additions and 16 deletions

View File

@ -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)

View File

@ -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) */

View File

@ -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)

View File

@ -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;

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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<osd_netdev> m_dev;
int m_intf;
bool m_loopback_control;