#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct CoalesceConfiguration
{
#[serde(default)] pub adaptive_coalescing: Option<AdaptiveCoalescingConfiguration>,
pub receive_transmit: ReceiveTransmitCoalescing,
pub receive_transmit_whilst_irq_is_being_serviced_by_the_host: ReceiveTransmitCoalescing,
#[serde(default)] pub low_packet_rate_packets_per_second_threshold: Option<NonZeroU32>,
pub receive_transmit_at_low_packet_rate: ReceiveTransmitCoalescing,
#[serde(default)] pub high_packet_rate_packets_per_second_threshold: Option<NonZeroU32>,
pub receive_transmit_at_high_packet_rate: ReceiveTransmitCoalescing,
#[serde(default)] pub statistics_block_coalesce_microseconds: Option<NonZeroU32>,
}
impl CoalesceConfiguration
{
#[inline(always)]
pub(crate) fn as_ethtool_coalesce(&self) -> ethtool_coalesce
{
let (rate_sample_interval, use_adaptive_rx_coalesce, use_adaptive_tx_coalesce) = AdaptiveCoalescingConfiguration::to_values(&self.adaptive_coalescing);
let (rx_coalesce_usecs, rx_max_coalesced_frames, tx_coalesce_usecs, tx_max_coalesced_frames) = self.receive_transmit.destructure();
let (rx_coalesce_usecs_irq, rx_max_coalesced_frames_irq, tx_coalesce_usecs_irq, tx_max_coalesced_frames_irq) = self.receive_transmit_whilst_irq_is_being_serviced_by_the_host.destructure();
let (rx_coalesce_usecs_low, rx_max_coalesced_frames_low, tx_coalesce_usecs_low, tx_max_coalesced_frames_low) = self.receive_transmit_at_low_packet_rate.destructure();
let (rx_coalesce_usecs_high, rx_max_coalesced_frames_high, tx_coalesce_usecs_high, tx_max_coalesced_frames_high) = self.receive_transmit_at_high_packet_rate.destructure();
ethtool_coalesce
{
cmd: ETHTOOL_SCOALESCE,
rx_coalesce_usecs,
rx_max_coalesced_frames,
rx_coalesce_usecs_irq,
rx_max_coalesced_frames_irq,
tx_coalesce_usecs,
tx_max_coalesced_frames,
tx_coalesce_usecs_irq,
tx_max_coalesced_frames_irq,
stats_block_coalesce_usecs: self.statistics_block_coalesce_microseconds,
use_adaptive_rx_coalesce,
use_adaptive_tx_coalesce,
pkt_rate_low: self.low_packet_rate_packets_per_second_threshold,
rx_coalesce_usecs_low,
rx_max_coalesced_frames_low,
tx_coalesce_usecs_low,
tx_max_coalesced_frames_low,
pkt_rate_high: self.high_packet_rate_packets_per_second_threshold,
rx_coalesce_usecs_high,
rx_max_coalesced_frames_high,
tx_coalesce_usecs_high,
tx_max_coalesced_frames_high,
rate_sample_interval,
}
}
}