From: Ben Hutchings <bhutchings@solarflare.com>
To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: netdev@vger.kernel.org, gospo@redhat.com,
Greg Rose <gregory.v.rose@intel.com>,
Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Subject: Re: [RFC PATCH 10/12] ixgbevf: Driver main and ethool interface module and main header
Date: Wed, 09 Dec 2009 17:57:14 +0000 [thread overview]
Message-ID: <1260381434.2786.47.camel@achroite.uk.solarflarecom.com> (raw)
In-Reply-To: <20091208221612.28373.74512.stgit@localhost.localdomain>
I had a look at the ethtool part of this:
On Tue, 2009-12-08 at 14:16 -0800, Jeff Kirsher wrote:
[...]
> +#ifdef SIOCETHTOOL
What?!
> +#include <linux/uaccess.h>
> +
> +#include "ixgbevf.h"
> +
> +#ifndef ETH_GSTRING_LEN
> +#define ETH_GSTRING_LEN 32
> +#endif
You can omit most of these #ifdefs in the in-tree driver.
[...]
> +static int ixgbevf_get_settings(struct net_device *netdev,
> + struct ethtool_cmd *ecmd)
> +{
> + struct ixgbevf_adapter *adapter = netdev_priv(netdev);
> + struct ixgbe_hw *hw = &adapter->hw;
> + u32 link_speed = 0;
> + bool link_up;
> +
> + ecmd->supported = SUPPORTED_10000baseT_Full;
Not likely...
> + ecmd->autoneg = AUTONEG_DISABLE;
> + ecmd->transceiver = XCVR_DUMMY1;
> + ecmd->port = -1;
> +
> + if (!in_interrupt()) {
This is bogus; get_settings() must be called in process context with
rtnl_lock held. (If this is a workaround for the old bonding driver
locking bugs, it doesn't belong in an in-tree driver.)
> + hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
> + } else {
> + /*
> + * this is a special workaround for cases where bonding
> + * calls this routine from interrupt context
> + */
> + link_speed = adapter->link_speed;
> + link_up = adapter->link_up;
> + }
> +
> + if (link_up) {
> + ecmd->speed = (link_speed == IXGBE_LINK_SPEED_10GB_FULL) ?
> + SPEED_10000 : SPEED_1000;
> + ecmd->duplex = DUPLEX_FULL;
> + } else {
> + ecmd->speed = -1;
> + ecmd->duplex = -1;
> + }
> +
> + return 0;
> +}
> +
> +static int ixgbevf_set_settings(struct net_device *netdev,
> + struct ethtool_cmd *ecmd)
> +{
> + return -EINVAL;
> +}
Should be -EOPNOTSUPP; the settings may or may not be valid. In fact,
you should just not fill in the set_settings operation.
[...]
> +static u32 ixgbevf_get_tx_csum(struct net_device *netdev)
> +{
> + return (netdev->features & NETIF_F_IP_CSUM) != 0;
> +}
This is redundant; the default implementation does the right thing.
> +static int ixgbevf_set_tx_csum(struct net_device *netdev, u32 data)
> +{
> + if (data)
> +#ifdef NETIF_F_IPV6_CSUM
> + netdev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
> + else
> + netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
> +#else
> + netdev->features |= NETIF_F_IP_CSUM;
> + else
> + netdev->features &= ~NETIF_F_IP_CSUM;
> +#endif
> +
> + return 0;
> +}
Use ethtool_op_set_tx_ipv6_csum.
> +#undef ethtool_op_set_tso
> +#ifdef NETIF_F_TSO
> +static int ixgbevf_set_tso(struct net_device *netdev, u32 data)
> +{
> +#ifndef HAVE_NETDEV_VLAN_FEATURES
> + struct ixgbevf_adapter *adapter = netdev_priv(netdev);
> +#endif /* HAVE_NETDEV_VLAN_FEATURES */
> + if (data) {
> + netdev->features |= NETIF_F_TSO;
> +#ifdef NETIF_F_TSO6
> + netdev->features |= NETIF_F_TSO6;
> +#endif
> + } else {
> + netif_tx_stop_all_queues(netdev);
> + netdev->features &= ~NETIF_F_TSO;
> +#ifdef NETIF_F_TSO6
> + netdev->features &= ~NETIF_F_TSO6;
> +#endif
> +#ifndef HAVE_NETDEV_VLAN_FEATURES
> +#ifdef NETIF_F_HW_VLAN_TX
> + /* disable TSO on all VLANs if they're present */
> + if (adapter->vlgrp) {
> + int i;
> + struct net_device *v_netdev;
> + for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
> + v_netdev =
> + vlan_group_get_device(adapter->vlgrp, i);
> + if (v_netdev) {
> + v_netdev->features &= ~NETIF_F_TSO;
> +#ifdef NETIF_F_TSO6
> + v_netdev->features &= ~NETIF_F_TSO6;
> +#endif
> + vlan_group_set_device(adapter->vlgrp, i,
> + v_netdev);
> + }
> + }
> + }
> +#endif
> +#endif /* HAVE_NETDEV_VLAN_FEATURES */
> + netif_tx_start_all_queues(netdev);
> + }
> + return 0;
> +}
> +#endif /* NETIF_F_TSO */
Ew.
[...]
> +static int ixgbevf_get_regs_len(struct net_device *netdev)
> +{
> +#define IXGBE_REGS_LEN 45
> + return IXGBE_REGS_LEN * sizeof(u32);
> +}
> +
> +#define IXGBE_GET_STAT(_A_, _R_) (_A_->stats._R_)
> +
> +static char *ixgbevf_reg_names[] = {
> + "IXGBE_VFCTRL",
> + "IXGBE_VFSTATUS",
[...]
If you move ixgbevf_get_regs_len() after ixgbevf_reg_names() you can
then use ARRAY_SIZE() instead of having to keep IXGBE_REGS_LEN in sync
manually.
> +static int ixgbevf_get_eeprom(struct net_device *netdev,
> + struct ethtool_eeprom *eeprom, u8 *bytes)
> +{
> + return -EOPNOTSUPP;
> +}
> +
> +static int ixgbevf_set_eeprom(struct net_device *netdev,
> + struct ethtool_eeprom *eeprom, u8 *bytes)
> +{
> + return -EOPNOTSUPP;
> +}
Just don't fill in the operations.
> +static void ixgbevf_get_drvinfo(struct net_device *netdev,
> + struct ethtool_drvinfo *drvinfo)
> +{
> + struct ixgbevf_adapter *adapter = netdev_priv(netdev);
> +
> + strncpy(drvinfo->driver, ixgbevf_driver_name, 32);
> + strncpy(drvinfo->version, ixgbevf_driver_version, 32);
> +
> + strncpy(drvinfo->fw_version, "N/A", 4);
> + strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
These are expected to be null-terminated, so use strlcpy().
> + drvinfo->n_stats = IXGBEVF_STATS_LEN;
> + drvinfo->testinfo_len = IXGBE_TEST_LEN;
> + drvinfo->regdump_len = ixgbevf_get_regs_len(netdev);
The ethtool core initialises these.
[...]
> +static int ixgbevf_link_test(struct ixgbevf_adapter *adapter, u64
> *data)
> +{
> + struct ixgbe_hw *hw = &adapter->hw;
> + bool link_up;
> + u32 link_speed = 0;
> + *data = 0;
> +
> + hw->mac.ops.check_link(hw, &link_speed, &link_up, true);
> + if (link_up)
> + return *data;
> + else
> + *data = 1;
> + return *data;
This is just messy.
[...]
> +static u32 ixgbevf_get_link(struct net_device *dev)
> +{
> + return netif_carrier_ok(dev) ? 1 : 0;
> +}
[...]
Use ethtool_op_get_link().
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
next prev parent reply other threads:[~2009-12-09 17:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-08 22:13 [RFC PATCH 01/12] ixgbe: Mailbox header and code module Jeff Kirsher
2009-12-08 22:13 ` [RFC PATCH 02/12] ixgbe: Add SR-IOV specific features Jeff Kirsher
2009-12-08 22:13 ` [RFC PATCH 03/12] ixgbe: Add SR-IOV register, structure and bit defines Jeff Kirsher
2009-12-10 0:06 ` Simon Horman
2009-12-08 22:14 ` [RFC PATCH 04/12] ixgbe: Add SR-IOV feature enablement code Jeff Kirsher
2009-12-08 22:14 ` [RFC PATCH 05/12] ixgbe: Add SR-IOV features to main module Jeff Kirsher
2009-12-10 0:45 ` Simon Horman
2009-12-10 0:49 ` Rose, Gregory V
2009-12-10 1:04 ` Simon Horman
2009-12-08 22:14 ` [RFC PATCH 06/12] ixgbe: Add SR-IOV specific modules to driver Makefile Jeff Kirsher
2009-12-10 0:17 ` Simon Horman
2009-12-08 22:15 ` [RFC PATCH 07/12] ixgbevf: Macros, data structures, useful defines and registers Jeff Kirsher
2009-12-08 22:15 ` [RFC PATCH 08/12] ixgbevf: 82599 Virtual Function core functions and header Jeff Kirsher
2009-12-08 22:15 ` [RFC PATCH 09/12] ixgbevf: Mailbox communication Jeff Kirsher
2009-12-08 22:16 ` [RFC PATCH 10/12] ixgbevf: Driver main and ethool interface module and main header Jeff Kirsher
2009-12-09 17:57 ` Ben Hutchings [this message]
2009-12-09 18:02 ` Rose, Gregory V
2009-12-08 22:16 ` [RFC PATCH 11/12] ixgbevf: Driver Makefile Jeff Kirsher
2009-12-08 22:16 ` [RFC PATCH 12/12] ixgbevf: Kconfig, Makefile and Documentation Jeff Kirsher
2009-12-08 22:41 ` Randy Dunlap
2009-12-08 22:49 ` Rose, Gregory V
2009-12-10 0:59 ` Simon Horman
2009-12-10 1:04 ` Rose, Gregory V
2009-12-10 0:50 ` [RFC PATCH 01/12] ixgbe: Mailbox header and code module Simon Horman
2009-12-10 0:53 ` Rose, Gregory V
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=1260381434.2786.47.camel@achroite.uk.solarflarecom.com \
--to=bhutchings@solarflare.com \
--cc=gospo@redhat.com \
--cc=gregory.v.rose@intel.com \
--cc=jeffrey.t.kirsher@intel.com \
--cc=netdev@vger.kernel.org \
--cc=peter.p.waskiewicz.jr@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.