mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-26 14:14:01 +08:00
virtio_net: ethtool tx napi configuration
Implement ethtool .set_coalesce (-C) and .get_coalesce (-c) handlers. Interrupt moderation is currently not supported, so these accept and display the default settings of 0 usec and 1 frame. Toggle tx napi through setting tx-frames. So as to not interfere with possible future interrupt moderation, value 1 means tx napi while value 0 means not. Only allow the switching when device is down for simplicity. Link: https://patchwork.ozlabs.org/patch/948149/ Suggested-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
1a21cc507b
commit
0c465be183
@ -2170,6 +2170,53 @@ static int virtnet_get_link_ksettings(struct net_device *dev,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int virtnet_set_coalesce(struct net_device *dev,
|
||||||
|
struct ethtool_coalesce *ec)
|
||||||
|
{
|
||||||
|
struct ethtool_coalesce ec_default = {
|
||||||
|
.cmd = ETHTOOL_SCOALESCE,
|
||||||
|
.rx_max_coalesced_frames = 1,
|
||||||
|
};
|
||||||
|
struct virtnet_info *vi = netdev_priv(dev);
|
||||||
|
int i, napi_weight;
|
||||||
|
|
||||||
|
if (ec->tx_max_coalesced_frames > 1)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
ec_default.tx_max_coalesced_frames = ec->tx_max_coalesced_frames;
|
||||||
|
napi_weight = ec->tx_max_coalesced_frames ? NAPI_POLL_WEIGHT : 0;
|
||||||
|
|
||||||
|
/* disallow changes to fields not explicitly tested above */
|
||||||
|
if (memcmp(ec, &ec_default, sizeof(ec_default)))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (napi_weight ^ vi->sq[0].napi.weight) {
|
||||||
|
if (dev->flags & IFF_UP)
|
||||||
|
return -EBUSY;
|
||||||
|
for (i = 0; i < vi->max_queue_pairs; i++)
|
||||||
|
vi->sq[i].napi.weight = napi_weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int virtnet_get_coalesce(struct net_device *dev,
|
||||||
|
struct ethtool_coalesce *ec)
|
||||||
|
{
|
||||||
|
struct ethtool_coalesce ec_default = {
|
||||||
|
.cmd = ETHTOOL_GCOALESCE,
|
||||||
|
.rx_max_coalesced_frames = 1,
|
||||||
|
};
|
||||||
|
struct virtnet_info *vi = netdev_priv(dev);
|
||||||
|
|
||||||
|
memcpy(ec, &ec_default, sizeof(ec_default));
|
||||||
|
|
||||||
|
if (vi->sq[0].napi.weight)
|
||||||
|
ec->tx_max_coalesced_frames = 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void virtnet_init_settings(struct net_device *dev)
|
static void virtnet_init_settings(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct virtnet_info *vi = netdev_priv(dev);
|
struct virtnet_info *vi = netdev_priv(dev);
|
||||||
@ -2208,6 +2255,8 @@ static const struct ethtool_ops virtnet_ethtool_ops = {
|
|||||||
.get_ts_info = ethtool_op_get_ts_info,
|
.get_ts_info = ethtool_op_get_ts_info,
|
||||||
.get_link_ksettings = virtnet_get_link_ksettings,
|
.get_link_ksettings = virtnet_get_link_ksettings,
|
||||||
.set_link_ksettings = virtnet_set_link_ksettings,
|
.set_link_ksettings = virtnet_set_link_ksettings,
|
||||||
|
.set_coalesce = virtnet_set_coalesce,
|
||||||
|
.get_coalesce = virtnet_get_coalesce,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void virtnet_freeze_down(struct virtio_device *vdev)
|
static void virtnet_freeze_down(struct virtio_device *vdev)
|
||||||
|
Loading…
Reference in New Issue
Block a user