netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Oded Gabbay <oded.gabbay@gmail.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	SW_Drivers@habana.ai, gregkh@linuxfoundation.org,
	davem@davemloft.net, kuba@kernel.org,
	Omer Shpigelman <oshpigelman@habana.ai>
Subject: Re: [PATCH 13/15] habanalabs/gaudi: Add ethtool support using coresight
Date: Thu, 10 Sep 2020 22:19:51 +0200	[thread overview]
Message-ID: <20200910201951.GG3354160@lunn.ch> (raw)
In-Reply-To: <20200910161126.30948-14-oded.gabbay@gmail.com>

> +static int gaudi_nic_get_link_ksettings(struct net_device *netdev,
> +					struct ethtool_link_ksettings *cmd)
> +{
> +	struct gaudi_nic_device **ptr = netdev_priv(netdev);
> +	struct gaudi_nic_device *gaudi_nic = *ptr;
> +	struct hl_device *hdev = gaudi_nic->hdev;
> +	u32 port = gaudi_nic->port, speed = gaudi_nic->speed;

Please go through the code and fixup Reverse Christmas tree.

> +
> +	cmd->base.speed = speed;
> +	cmd->base.duplex = DUPLEX_FULL;
> +
> +	ethtool_link_ksettings_zero_link_mode(cmd, supported);
> +	ethtool_link_ksettings_zero_link_mode(cmd, advertising);
> +
> +	ethtool_add_mode(cmd, supported, 100000baseCR4_Full);
> +	ethtool_add_mode(cmd, supported, 100000baseSR4_Full);
> +	ethtool_add_mode(cmd, supported, 100000baseKR4_Full);
> +	ethtool_add_mode(cmd, supported, 100000baseLR4_ER4_Full);
> +
> +	ethtool_add_mode(cmd, supported, 50000baseSR2_Full);
> +	ethtool_add_mode(cmd, supported, 50000baseCR2_Full);
> +	ethtool_add_mode(cmd, supported, 50000baseKR2_Full);
> +
> +	if (speed == SPEED_100000) {
> +		ethtool_add_mode(cmd, advertising, 100000baseCR4_Full);
> +		ethtool_add_mode(cmd, advertising, 100000baseSR4_Full);
> +		ethtool_add_mode(cmd, advertising, 100000baseKR4_Full);
> +		ethtool_add_mode(cmd, advertising, 100000baseLR4_ER4_Full);
> +
> +		cmd->base.port = PORT_FIBRE;
> +
> +		ethtool_add_mode(cmd, supported, FIBRE);
> +		ethtool_add_mode(cmd, advertising, FIBRE);
> +
> +		ethtool_add_mode(cmd, supported, Backplane);
> +		ethtool_add_mode(cmd, advertising, Backplane);
> +	} else if (speed == SPEED_50000) {
> +		ethtool_add_mode(cmd, advertising, 50000baseSR2_Full);
> +		ethtool_add_mode(cmd, advertising, 50000baseCR2_Full);
> +		ethtool_add_mode(cmd, advertising, 50000baseKR2_Full);
> +	} else {
> +		dev_err(hdev->dev, "unknown speed %d, port %d\n", speed, port);
> +		return -EFAULT;
> +	}
> +
> +	ethtool_add_mode(cmd, supported, Autoneg);
> +
> +	if (gaudi_nic->auto_neg_enable) {
> +		ethtool_add_mode(cmd, advertising, Autoneg);
> +		cmd->base.autoneg = AUTONEG_ENABLE;
> +		if (gaudi_nic->auto_neg_resolved)
> +			ethtool_add_mode(cmd, lp_advertising, Autoneg);
> +	} else {
> +		cmd->base.autoneg = AUTONEG_DISABLE;
> +	}
> +
> +	ethtool_add_mode(cmd, supported, Pause);
> +
> +	if (gaudi_nic->pfc_enable)
> +		ethtool_add_mode(cmd, advertising, Pause);
> +
> +	return 0;
> +}
> +
> +static int gaudi_nic_set_link_ksettings(struct net_device *netdev,
> +				const struct ethtool_link_ksettings *cmd)
> +{
> +	struct gaudi_nic_device **ptr = netdev_priv(netdev);
> +	struct gaudi_nic_device *gaudi_nic = *ptr;
> +	struct hl_device *hdev = gaudi_nic->hdev;
> +	u32 port = gaudi_nic->port;
> +	int rc = 0, speed = cmd->base.speed;
> +	bool auto_neg = cmd->base.autoneg == AUTONEG_ENABLE;

It appears you only support speed and auto_neg. You should check that
all other things which could be configured are empty, e.g. none of the
bits are set in cmd->link_modes.advertising. If you are requested to
configure something which is not supported, you need to return
-EOPNOTSUPP.

	Andrew

  reply	other threads:[~2020-09-10 20:21 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10 16:11 [PATCH 00/15] Adding GAUDI NIC code to habanalabs driver Oded Gabbay
2020-09-10 16:11 ` [PATCH 01/15] habanalabs/gaudi: add NIC H/W and registers definitions Oded Gabbay
2020-09-10 16:11 ` [PATCH 02/15] habanalabs/gaudi: add NIC firmware-related definitions Oded Gabbay
2020-09-10 16:11 ` [PATCH 03/15] habanalabs/gaudi: add NIC security configuration Oded Gabbay
2020-09-10 16:11 ` [PATCH 04/15] habanalabs/gaudi: add support for NIC QMANs Oded Gabbay
2020-09-10 16:11 ` [PATCH 05/15] habanalabs/gaudi: add NIC Ethernet support Oded Gabbay
2020-09-10 20:03   ` Jakub Kicinski
2020-09-10 20:18     ` Oded Gabbay
2020-09-14  9:52     ` Omer Shpigelman
2020-09-14 16:47       ` Jakub Kicinski
2020-09-10 16:11 ` [PATCH 06/15] habanalabs/gaudi: add NIC PHY code Oded Gabbay
2020-09-10 16:11 ` [PATCH 07/15] habanalabs/gaudi: allow user to get MAC addresses in INFO IOCTL Oded Gabbay
2020-09-10 16:11 ` [PATCH 08/15] habanalabs/gaudi: add a new IOCTL for NIC control operations Oded Gabbay
2020-09-10 16:11 ` [PATCH 09/15] habanalabs/gaudi: add CQ " Oded Gabbay
2020-09-10 16:11 ` [PATCH 10/15] habanalabs/gaudi: add WQ " Oded Gabbay
2020-09-10 16:11 ` [PATCH 11/15] habanalabs/gaudi: add QP error handling Oded Gabbay
2020-09-10 16:11 ` [PATCH 12/15] habanalabs/gaudi: add debugfs entries for the NIC Oded Gabbay
2020-09-10 20:01   ` Jakub Kicinski
2020-09-10 20:10     ` Oded Gabbay
2020-09-10 20:16       ` Jakub Kicinski
2020-09-10 20:17         ` Oded Gabbay
2020-09-10 20:30           ` Jakub Kicinski
2020-09-10 20:33             ` Oded Gabbay
2020-09-14 13:48             ` Omer Shpigelman
2020-09-14 16:50               ` Jakub Kicinski
2020-09-15 12:57                 ` Oded Gabbay
2020-09-16 16:38                   ` Jakub Kicinski
2020-09-10 16:11 ` [PATCH 13/15] habanalabs/gaudi: Add ethtool support using coresight Oded Gabbay
2020-09-10 20:19   ` Andrew Lunn [this message]
2020-09-10 20:22     ` Oded Gabbay
2020-09-10 16:11 ` [PATCH 14/15] habanalabs/gaudi: support DCB protocol Oded Gabbay
2020-09-10 16:11 ` [PATCH 15/15] habanalabs/gaudi: add NIC init/fini calls from common code Oded Gabbay
2020-09-10 20:01 ` [PATCH 00/15] Adding GAUDI NIC code to habanalabs driver Jakub Kicinski
2020-09-10 20:16   ` Oded Gabbay
2020-09-10 20:25     ` Andrew Lunn
2020-09-10 20:30       ` Oded Gabbay
2020-09-10 20:38         ` Andrew Lunn
2020-09-10 20:52           ` Oded Gabbay
2020-09-11  6:22           ` Greg Kroah-Hartman
2020-09-10 20:28     ` Jakub Kicinski
2020-09-10 20:32       ` Oded Gabbay
2020-09-10 21:05         ` Florian Fainelli
2020-09-10 21:15           ` Oded Gabbay
2020-09-10 21:23             ` 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=20200910201951.GG3354160@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=SW_Drivers@habana.ai \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oded.gabbay@gmail.com \
    --cc=oshpigelman@habana.ai \
    /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).