netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Alexander Loktionov <Alexander.Loktionov@aquantia.com>,
	netdev@vger.kernel.org, David VomLehn <vomlehn@texas.net>
Cc: "David S . Miller" <davem@davemloft.net>,
	Simon Edelhaus <Simon.Edelhaus@aquantia.com>,
	Dmitrii Tarakanov <Dmitrii.Tarakanov@aquantia.com>,
	Pavel Belous <Pavel.Belous@aquantia.com>,
	Dmitry Bezrukov <Dmitry.Bezrukov@aquantia.com>
Subject: Re: [PATCH v5 11/13] net: ethernet: aquantia: Ethtool support
Date: Fri, 13 Jan 2017 17:47:15 -0800	[thread overview]
Message-ID: <a47675a9-8878-5a00-9adc-5dcac909c8d3@gmail.com> (raw)
In-Reply-To: <b2236a13fcf9ac65f15cfc084de670948517e003.1484283610.git.vomlehn@texas.net>

On 01/12/2017 09:02 PM, Alexander Loktionov wrote:
> From: David VomLehn <vomlehn@texas.net>
> 
> Add the driver interfaces required for support by the ethtool utility.
> 
> Signed-off-by: Alexander Loktionov <Alexander.Loktionov@aquantia.com>
> Signed-off-by: Dmitrii Tarakanov <Dmitrii.Tarakanov@aquantia.com>
> Signed-off-by: Pavel Belous <Pavel.Belous@aquantia.com>
> Signed-off-by: Dmitry Bezrukov <Dmitry.Bezrukov@aquantia.com>
> Signed-off-by: David M. VomLehn <vomlehn@texas.net>
> ---
>  drivers/net/ethernet/aquantia/aq_ethtool.c | 250 +++++++++++++++++++++++++++++
>  drivers/net/ethernet/aquantia/aq_ethtool.h |  19 +++
>  2 files changed, 269 insertions(+)
>  create mode 100644 drivers/net/ethernet/aquantia/aq_ethtool.c
>  create mode 100644 drivers/net/ethernet/aquantia/aq_ethtool.h
> 
> diff --git a/drivers/net/ethernet/aquantia/aq_ethtool.c b/drivers/net/ethernet/aquantia/aq_ethtool.c
> new file mode 100644
> index 0000000..f11bdb1
> --- /dev/null
> +++ b/drivers/net/ethernet/aquantia/aq_ethtool.c
> @@ -0,0 +1,250 @@
> +/*
> + * aQuantia Corporation Network Driver
> + * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + */
> +
> +/* File aq_ethtool.c: Definition of ethertool related functions. */
> +
> +#include "aq_ethtool.h"
> +#include "aq_nic.h"
> +
> +static void aq_ethtool_get_regs(struct net_device *ndev,
> +				struct ethtool_regs *regs, void *p)
> +{
> +	struct aq_nic_s *aq_nic = (struct aq_nic_s *)netdev_priv(ndev);

netdev_priv() returns a void * which requires no casting, please fix
this through the entire 13 patches.

> +	u32 regs_count = aq_nic_get_regs_count(aq_nic);
> +
> +	memset(p, 0, regs_count * sizeof(u32));
> +	aq_nic_get_regs(aq_nic, regs, p);
> +}
> +
> +static int aq_ethtool_get_regs_len(struct net_device *ndev)
> +{
> +	struct aq_nic_s *aq_nic = (struct aq_nic_s *)netdev_priv(ndev);
> +	u32 regs_count = aq_nic_get_regs_count(aq_nic);
> +
> +	return regs_count * sizeof(u32);
> +}
> +
> +static u32 aq_ethtool_get_link(struct net_device *ndev)
> +{
> +	struct aq_nic_s *aq_nic = (struct aq_nic_s *)netdev_priv(ndev);
> +
> +	return aq_nic_get_link_speed(aq_nic) ? 1U : 0U;

Can you either use PHYLIB to interface to your PHY (which does all the
nice state machine management) or at the very least ethtool_op_get_link()?

> +}
> +
> +static int aq_ethtool_get_settings(struct net_device *ndev,
> +				   struct ethtool_cmd *cmd)
> +{
> +	struct aq_nic_s *aq_nic = (struct aq_nic_s *)netdev_priv(ndev);
> +
> +	cmd->port = PORT_TP;
> +	cmd->transceiver = XCVR_EXTERNAL;
> +
> +	ethtool_cmd_speed_set(cmd, netif_carrier_ok(ndev) ?
> +				aq_nic_get_link_speed(aq_nic) : 0U);
> +
> +	cmd->duplex = DUPLEX_FULL;
> +	aq_nic_get_link_settings(aq_nic, cmd);
> +	return 0;

Consider switching to the new ksettings API and filling in a bit more
information like cmd->autoneg?

> +}
> +
> +static int aq_ethtool_set_settings(struct net_device *ndev,
> +				   struct ethtool_cmd *cmd)
> +{
> +	struct aq_nic_s *aq_nic = (struct aq_nic_s *)netdev_priv(ndev);
> +
> +	return aq_nic_set_link_settings(aq_nic, cmd);
> +}
> +
> +static const char aq_ethtool_stat_names[][ETH_GSTRING_LEN] = {
> +	"InPackets",
> +	"InUCast",
> +	"InMCast",
> +	"InBCast",
> +	"InErrors",
> +	"OutPackets",
> +	"OutUCast",
> +	"OutMCast",
> +	"OutBCast",
> +	"InUCastOctects",
> +	"OutUCastOctects",
> +	"InMCastOctects",
> +	"OutMCastOctects",
> +	"InBCastOctects",
> +	"OutBCastOctects",
> +	"InOctects",
> +	"OutOctects",
> +	"InPacketsDma",
> +	"OutPacketsDma",
> +	"InOctetsDma",
> +	"OutOctetsDma",
> +	"InDroppedDma",
> +	"Queue[0] InPackets",
> +	"Queue[0] OutPackets",
> +	"Queue[0] InJumboPackets",
> +	"Queue[0] InLroPackets",
> +	"Queue[0] InErrors",
> +#if 1 < AQ_CFG_VECS_DEF

Yoda notations are usually frowned upon. Instead of making this decision
here, can you push that down to the actual function reading the statistics?

> +static void aq_ethtool_get_strings(struct net_device *ndev,
> +				   u32 stringset, u8 *data)
> +{

You need to check that stringset == ETH_SS_STATS here since that's the
only thing you support. ethtool usually does not do it if the ioctl()
returning the data does not exist, but other bogus applications might.

> +	memcpy(data, *aq_ethtool_stat_names, sizeof(aq_ethtool_stat_names));
> +}
> +
> +static int aq_ethtool_get_sset_count(struct net_device *ndev, int stringset)
> +{

Same here.

> +	return ARRAY_SIZE(aq_ethtool_stat_names);

> +#ifndef AQ_ETHTOOL_H
> +#define AQ_ETHTOOL_H
> +
> +#include "aq_common.h"
> +
> +extern const struct ethtool_ops aq_ethtool_ops;

The extern does not appear necessary here. Alternatively you may define
all the ethtool function pointers in this header file, but leave the
struct ethtool_ops in the main driver file which registers them at the
time of the netdev creation, up to you.

> +
> +#endif /* AQ_ETHTOOL_H */
> 


-- 
Florian

  parent reply	other threads:[~2017-01-14  1:47 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-13  5:02 [PATCH v5 00/13] net: ethernet: aquantia: Add AQtion 2.5/5 GB NIC driver Alexander Loktionov
2017-01-13  5:02 ` [PATCH v5 01/13] net: ethernet: aquantia: Make and configuration files Alexander Loktionov
2017-01-13  5:02   ` [PATCH v5 02/13] net: ethernet: aquantia: Common functions and definitions Alexander Loktionov
2017-01-13  5:02     ` [PATCH v5 03/13] net: ethernet: aquantia: Add ring support code Alexander Loktionov
2017-01-13  5:02       ` [PATCH v5 04/13] net: ethernet: aquantia: Low-level hardware interfaces Alexander Loktionov
2017-01-13  5:02         ` [PATCH v5 05/13] net: ethernet: aquantia: Support for NIC-specific code Alexander Loktionov
2017-01-13  5:02           ` [PATCH v5 06/13] net: ethernet: aquantia: Atlantic A0 and B0 specific functions Alexander Loktionov
2017-01-13  5:02             ` [PATCH v5 07/13] net: ethernet: aquantia: Vector operations Alexander Loktionov
2017-01-13  5:02               ` [PATCH v5 08/13] net: ethernet: aquantia: PCI operations Alexander Loktionov
2017-01-13  5:02                 ` [PATCH v5 09/13] net: ethernet: aquantia: Atlantic hardware abstraction layer Alexander Loktionov
2017-01-13  5:02                   ` [PATCH v5 10/13] net: ethernet: aquantia: Hardware interface and utility functions Alexander Loktionov
2017-01-13  5:02                     ` [PATCH v5 11/13] net: ethernet: aquantia: Ethtool support Alexander Loktionov
2017-01-13  5:02                       ` [PATCH v5 12/13] net: ethernet: aquantia: Receive side scaling Alexander Loktionov
2017-01-13  5:02                         ` [PATCH v5 13/13] net: ethernet: aquantia: Integrate AQtion 2.5/5 GB NIC driver Alexander Loktionov
2017-01-14  1:47                       ` Florian Fainelli [this message]
2017-01-14  1:48                 ` [PATCH v5 08/13] net: ethernet: aquantia: PCI operations Florian Fainelli
2017-01-14  2:00           ` [PATCH v5 05/13] net: ethernet: aquantia: Support for NIC-specific code Florian Fainelli
2017-01-14 22:55             ` Rami Rosen
2017-01-15  1:15               ` Andrew Lunn
2017-01-14  1:32     ` [PATCH v5 02/13] net: ethernet: aquantia: Common functions and definitions David Miller
2017-01-13  5:06   ` [PATCH v5 01/13] net: ethernet: aquantia: Make and configuration files Joe Perches
2017-01-13  5:24     ` David VomLehn
2017-01-13  5:59       ` Joe Perches
2017-01-13  6:57         ` David VomLehn
2017-01-13  7:28           ` Joe Perches
2017-01-14  2:01   ` Florian Fainelli
2017-01-14 18:39   ` Florian Fainelli
2017-01-14 18:42     ` David VomLehn
2017-01-14 18:48       ` Florian Fainelli
2017-01-14 19:04         ` David VomLehn
2017-01-14  1:38 ` [PATCH v5 00/13] net: ethernet: aquantia: Add AQtion 2.5/5 GB NIC driver Florian Fainelli
2017-01-14  3:41   ` David VomLehn
2017-01-14  2:05 ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a47675a9-8878-5a00-9adc-5dcac909c8d3@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=Alexander.Loktionov@aquantia.com \
    --cc=Dmitrii.Tarakanov@aquantia.com \
    --cc=Dmitry.Bezrukov@aquantia.com \
    --cc=Pavel.Belous@aquantia.com \
    --cc=Simon.Edelhaus@aquantia.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=vomlehn@texas.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).