diff mbox series

[net-next,01/18] gve: Get and set Rx copybreak via ethtool

Message ID 20200818194417.2003932-2-awogbemila@google.com
State Changes Requested
Delegated to: David Miller
Headers show
Series GVE Driver v1.1.0 Features. | expand

Commit Message

David Awogbemila Aug. 18, 2020, 7:44 p.m. UTC
From: Kuo Zhao <kuozhao@google.com>

This adds support for getting and setting the RX copybreak
value via ethtool.

Reviewed-by: Yangchun Fu <yangchun@google.com>
Signed-off-by: Kuo Zhao <kuozhao@google.com>
Signed-off-by: David Awogbemila <awogbemila@google.com>
---
 drivers/net/ethernet/google/gve/gve_ethtool.c | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)

Comments

Andrew Lunn Aug. 18, 2020, 8 p.m. UTC | #1
On Tue, Aug 18, 2020 at 12:44:00PM -0700, David Awogbemila wrote:
> From: Kuo Zhao <kuozhao@google.com>
> 
> This adds support for getting and setting the RX copybreak
> value via ethtool.
> 
> Reviewed-by: Yangchun Fu <yangchun@google.com>
> Signed-off-by: Kuo Zhao <kuozhao@google.com>
> Signed-off-by: David Awogbemila <awogbemila@google.com>
> ---
>  drivers/net/ethernet/google/gve/gve_ethtool.c | 34 +++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/drivers/net/ethernet/google/gve/gve_ethtool.c b/drivers/net/ethernet/google/gve/gve_ethtool.c
> index d8fa816f4473..469d3332bcd6 100644
> --- a/drivers/net/ethernet/google/gve/gve_ethtool.c
> +++ b/drivers/net/ethernet/google/gve/gve_ethtool.c
> @@ -230,6 +230,38 @@ static int gve_user_reset(struct net_device *netdev, u32 *flags)
>  	return -EOPNOTSUPP;
>  }


Hi David.

> +static int gve_get_tunable(struct net_device *netdev,
> +			   const struct ethtool_tunable *etuna, void *value)
> +{
> +	struct gve_priv *priv = netdev_priv(netdev);
> +
> +	switch (etuna->id) {
> +	case ETHTOOL_RX_COPYBREAK:
> +		*(u32 *)value = priv->rx_copybreak;
> +		return 0;
> +	default:
> +		return -EINVAL;

EOPNOTSUPP would be better. Other tunables are not invalid, they are
simply not supported by this driver.

> +	}
> +}
> +
> +static int gve_set_tunable(struct net_device *netdev,
> +			   const struct ethtool_tunable *etuna, const void *value)
> +{
> +	struct gve_priv *priv = netdev_priv(netdev);
> +	u32 len;
> +
> +	switch (etuna->id) {
> +	case ETHTOOL_RX_COPYBREAK:
> +		len = *(u32 *)value;
> +		if (len > PAGE_SIZE / 2)
> +			return -EINVAL;
> +		priv->rx_copybreak = len;
> +		return 0;
> +	default:
> +		return -EINVAL;

Same here.

     Andrew
diff mbox series

Patch

diff --git a/drivers/net/ethernet/google/gve/gve_ethtool.c b/drivers/net/ethernet/google/gve/gve_ethtool.c
index d8fa816f4473..469d3332bcd6 100644
--- a/drivers/net/ethernet/google/gve/gve_ethtool.c
+++ b/drivers/net/ethernet/google/gve/gve_ethtool.c
@@ -230,6 +230,38 @@  static int gve_user_reset(struct net_device *netdev, u32 *flags)
 	return -EOPNOTSUPP;
 }
 
+static int gve_get_tunable(struct net_device *netdev,
+			   const struct ethtool_tunable *etuna, void *value)
+{
+	struct gve_priv *priv = netdev_priv(netdev);
+
+	switch (etuna->id) {
+	case ETHTOOL_RX_COPYBREAK:
+		*(u32 *)value = priv->rx_copybreak;
+		return 0;
+	default:
+		return -EINVAL;
+	}
+}
+
+static int gve_set_tunable(struct net_device *netdev,
+			   const struct ethtool_tunable *etuna, const void *value)
+{
+	struct gve_priv *priv = netdev_priv(netdev);
+	u32 len;
+
+	switch (etuna->id) {
+	case ETHTOOL_RX_COPYBREAK:
+		len = *(u32 *)value;
+		if (len > PAGE_SIZE / 2)
+			return -EINVAL;
+		priv->rx_copybreak = len;
+		return 0;
+	default:
+		return -EINVAL;
+	}
+}
+
 const struct ethtool_ops gve_ethtool_ops = {
 	.get_drvinfo = gve_get_drvinfo,
 	.get_strings = gve_get_strings,
@@ -242,4 +274,6 @@  const struct ethtool_ops gve_ethtool_ops = {
 	.get_link = ethtool_op_get_link,
 	.get_ringparam = gve_get_ringparam,
 	.reset = gve_user_reset,
+	.get_tunable = gve_get_tunable,
+	.set_tunable = gve_set_tunable,
 };