Skip to content

Commit

Permalink
ethtool: insert channels into Ethtool cls
Browse files Browse the repository at this point in the history
  • Loading branch information
sohorx committed Mar 27, 2024
1 parent ee6856b commit b12acc6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pyroute2/ethtool/ethtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ def to_ioctl(ioctl_features, eth_features):
ioctl_features[feature.name] = feature.enable


class EthtoolChannels(namedtuple('EthtoolChannels', (
"max_rx", "max_tx", "max_other", "max_combined",
"rx_count", "tx_count", "other_count", "combined_count",
))):
@classmethod
def from_ioctl(cls, channels):
return cls(**{k: getattr(channels, k) for k in cls._fields})

@staticmethod
def to_ioctl(ioctl_channels, eth_channel):
for key, val in eth_channel.items():
setattr(ioctl_channels, key, val)


class EthtoolWakeOnLan(namedtuple('EthtoolWolMode', ('modes', 'sopass'))):
@classmethod
def from_netlink(cls, nl_wol):
Expand Down Expand Up @@ -465,6 +479,16 @@ def set_features(self, ifname, features):
EthtoolFeatures.to_ioctl(ioctl_features, features)
self._with_ioctl.set_features(ioctl_features)

def get_channels(self, ifname):
self._with_ioctl.change_ifname(ifname)
return EthtoolChannels.from_ioctl(self._with_ioctl.get_channels())

def set_channels(self, ifname, channels):
self._with_ioctl.change_ifname(ifname)
ioctl_channels = self._with_ioctl.get_channels()
EthtoolChannels.to_ioctl(ioctl_channels, channels)
self._with_ioctl.set_channels(ioctl_channels)

def get_coalesce(self, ifname):
self._with_ioctl.change_ifname(ifname)
return EthtoolCoalesce.from_ioctl(self._with_ioctl.get_coalesce())
Expand Down

0 comments on commit b12acc6

Please sign in to comment.