net: qualcomm: rmnet: add ethtool support for configuring tx aggregation
authorDaniele Palmas <dnlplm@gmail.com>
Wed, 11 Jan 2023 13:05:20 +0000 (14:05 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 13 Jan 2023 10:23:52 +0000 (10:23 +0000)
Add support for ETHTOOL_COALESCE_TX_AGGR for configuring the tx
aggregation settings.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c

index 6d8b8fdb9d03b9f2a60ab7313e515ce06af95cb0..046b5f7d8e7cab33a9f09079858bac2a972e968a 100644 (file)
@@ -215,7 +215,52 @@ static void rmnet_get_ethtool_stats(struct net_device *dev,
        memcpy(data, st, ARRAY_SIZE(rmnet_gstrings_stats) * sizeof(u64));
 }
 
+static int rmnet_get_coalesce(struct net_device *dev,
+                             struct ethtool_coalesce *coal,
+                             struct kernel_ethtool_coalesce *kernel_coal,
+                             struct netlink_ext_ack *extack)
+{
+       struct rmnet_priv *priv = netdev_priv(dev);
+       struct rmnet_port *port;
+
+       port = rmnet_get_port_rtnl(priv->real_dev);
+
+       memset(kernel_coal, 0, sizeof(*kernel_coal));
+       kernel_coal->tx_aggr_max_bytes = port->egress_agg_params.bytes;
+       kernel_coal->tx_aggr_max_frames = port->egress_agg_params.count;
+       kernel_coal->tx_aggr_time_usecs = div_u64(port->egress_agg_params.time_nsec,
+                                                 NSEC_PER_USEC);
+
+       return 0;
+}
+
+static int rmnet_set_coalesce(struct net_device *dev,
+                             struct ethtool_coalesce *coal,
+                             struct kernel_ethtool_coalesce *kernel_coal,
+                             struct netlink_ext_ack *extack)
+{
+       struct rmnet_priv *priv = netdev_priv(dev);
+       struct rmnet_port *port;
+
+       port = rmnet_get_port_rtnl(priv->real_dev);
+
+       if (kernel_coal->tx_aggr_max_frames < 1 || kernel_coal->tx_aggr_max_frames > 64)
+               return -EINVAL;
+
+       if (kernel_coal->tx_aggr_max_bytes > 32768)
+               return -EINVAL;
+
+       rmnet_map_update_ul_agg_config(port, kernel_coal->tx_aggr_max_bytes,
+                                      kernel_coal->tx_aggr_max_frames,
+                                      kernel_coal->tx_aggr_time_usecs);
+
+       return 0;
+}
+
 static const struct ethtool_ops rmnet_ethtool_ops = {
+       .supported_coalesce_params = ETHTOOL_COALESCE_TX_AGGR,
+       .get_coalesce = rmnet_get_coalesce,
+       .set_coalesce = rmnet_set_coalesce,
        .get_ethtool_stats = rmnet_get_ethtool_stats,
        .get_strings = rmnet_get_strings,
        .get_sset_count = rmnet_get_sset_count,