#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ReceiveSysfsQueue<'a>
{
network_interface_name: &'a NetworkInterfaceName,
queue_identifier: QueueIdentifier,
}
impl<'a> SysfsQueue<'a> for ReceiveSysfsQueue<'a>
{
const Prefix: &'static str = "rx";
fn new(network_interface_name: &'a NetworkInterfaceName, queue_identifier: QueueIdentifier) -> Self
{
Self
{
network_interface_name,
queue_identifier,
}
}
#[inline(always)]
fn network_interface_name(&self) -> &'a NetworkInterfaceName
{
self.network_interface_name
}
#[inline(always)]
fn queue_identifier(&self) -> QueueIdentifier
{
self.queue_identifier
}
}
impl<'a> ReceiveSysfsQueue<'a>
{
#[inline(always)]
pub fn receive_packet_steering_affinity(&self, sys_path: &SysPath) -> io::Result<HyperThreads>
{
self.rps_cpus_file_path(sys_path).parse_comma_separated_bit_set().map(HyperThreads)
}
#[inline(always)]
pub fn set_receive_packet_steering_affinity(&self, sys_path: &SysPath, hyper_threads: &HyperThreads) -> io::Result<()>
{
assert_effective_user_id_is_root("write /sys/class/net/<network_interface_name>/queues/rx-<queue_identifier/rps_cpus");
let file_path = self.rps_cpus_file_path(sys_path);
if file_path.exists()
{
let mask = IntoBitMask(hyper_threads);
file_path.write_value(mask)
}
else
{
Ok(())
}
}
#[inline(always)]
pub fn receive_packet_steering_flow_table_count(&self, sys_path: &SysPath) -> io::Result<usize>
{
self.rps_flow_cnt_file_path(sys_path).read_value()
}
#[inline(always)]
pub fn set_receive_packet_steering_flow_table_count(&self, sys_path: &SysPath, flow_table_count: usize) -> io::Result<()>
{
assert_effective_user_id_is_root("write /sys/class/net/<network_interface_name>/queues/rx-<queue_identifier/rps_flow_cnt");
let file_path = self.rps_flow_cnt_file_path(sys_path);
if file_path.exists()
{
file_path.write_value(UnpaddedDecimalInteger(flow_table_count))
}
else
{
Ok(())
}
}
#[inline(always)]
fn rps_flow_cnt_file_path(&self, sys_path: &SysPath) -> PathBuf
{
self.file_path(sys_path, "rps_flow_cnt")
}
#[inline(always)]
fn rps_cpus_file_path(&self, sys_path: &SysPath) -> PathBuf
{
self.file_path(sys_path, "rps_cpus")
}
}