netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Gerhard Engleder <gerhard@engleder-embedded.com>
Cc: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v5 3/3] tsnep: Add TSN endpoint Ethernet MAC driver
Date: Tue, 16 Nov 2021 00:04:36 +0100	[thread overview]
Message-ID: <YZLnhOUg7A66AL5p@lunn.ch> (raw)
In-Reply-To: <20211115205005.6132-4-gerhard@engleder-embedded.com>

> +static int tsnep_ethtool_get_regs_len(struct net_device *netdev)
> +{
> +	struct tsnep_adapter *adapter = netdev_priv(netdev);
> +	int len;
> +	int num_queues;
> +
> +	len = TSNEP_MAC_SIZE;
> +	num_queues = max(adapter->num_tx_queues, adapter->num_rx_queues);
> +	len += TSNEP_QUEUE_SIZE * (num_queues - 1);

Why the num_queues - 1 ? A comment here might be good explaining it.

> +
> +	return len;
> +}
> +
> +static void tsnep_ethtool_get_regs(struct net_device *netdev,
> +				   struct ethtool_regs *regs,
> +				   void *p)
> +{
> +	struct tsnep_adapter *adapter = netdev_priv(netdev);
> +
> +	regs->version = 1;
> +
> +	memcpy_fromio(p, adapter->addr, regs->len);
> +}

So the registers and the queues are contiguous?

> +static int tsnep_ethtool_get_ts_info(struct net_device *dev,
> +				     struct ethtool_ts_info *info)
> +{
> +	struct tsnep_adapter *adapter = netdev_priv(dev);
> +
> +	info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
> +				SOF_TIMESTAMPING_RX_SOFTWARE |
> +				SOF_TIMESTAMPING_SOFTWARE |
> +				SOF_TIMESTAMPING_TX_HARDWARE |
> +				SOF_TIMESTAMPING_RX_HARDWARE |
> +				SOF_TIMESTAMPING_RAW_HARDWARE;
> +
> +	if (adapter->ptp_clock)
> +		info->phc_index = ptp_clock_index(adapter->ptp_clock);
> +	else
> +		info->phc_index = -1;
> +
> +	info->tx_types = BIT(HWTSTAMP_TX_OFF) |
> +			 BIT(HWTSTAMP_TX_ON);
> +	info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) |
> +			   BIT(HWTSTAMP_FILTER_ALL);
> +
> +	return 0;
> +}

You should Cc: Richard Cochran <richardcochran@gmail.com> for the PTP
parts.

> +static int tsnep_mdio_init(struct tsnep_adapter *adapter)
> +{
> +	struct device_node *np = adapter->pdev->dev.of_node;
> +	int retval;
> +
> +	if (np) {
> +		np = of_get_child_by_name(np, "mdio");
> +		if (!np)
> +			return 0;
> +
> +		adapter->suppress_preamble =
> +			of_property_read_bool(np, "suppress-preamble");
> +	}
> +
> +	adapter->mdiobus = devm_mdiobus_alloc(&adapter->pdev->dev);
> +	if (!adapter->mdiobus) {
> +		retval = -ENOMEM;
> +
> +		goto out;
> +	}
> +
> +	adapter->mdiobus->priv = (void *)adapter;
> +	adapter->mdiobus->parent = &adapter->pdev->dev;
> +	adapter->mdiobus->read = tsnep_mdiobus_read;
> +	adapter->mdiobus->write = tsnep_mdiobus_write;
> +	adapter->mdiobus->name = TSNEP "-mdiobus";
> +	snprintf(adapter->mdiobus->id, MII_BUS_ID_SIZE, "%s",
> +		 adapter->pdev->name);
> +
> +	if (np) {
> +		retval = of_mdiobus_register(adapter->mdiobus, np);
> +
> +		of_node_put(np);
> +	} else {
> +		/* do not scan broadcast address */
> +		adapter->mdiobus->phy_mask = 0x0000001;
> +
> +		retval = mdiobus_register(adapter->mdiobus);

You can probably simply this. of_mdiobus_register() is happy to take a
NULL pointer for np, and will fall back to mdiobus_register().


> diff --git a/drivers/net/ethernet/engleder/tsnep_test.c b/drivers/net/ethernet/engleder/tsnep_test.c

You have quite a lot of code in this file. Could it either be

1) A loadable module which extends the base driver?
2) A build time configuration option?

What percentage of the overall driver binary does this test code take
up?

Apart from the minor comments above, ethtool, mdio, phy all looks
good.

	Andrew

  parent reply	other threads:[~2021-11-15 23:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15 20:50 [PATCH net-next v5 0/3] TSN endpoint Ethernet MAC driver Gerhard Engleder
2021-11-15 20:50 ` [PATCH net-next v5 1/3] dt-bindings: Add vendor prefix for Engleder Gerhard Engleder
2021-11-15 22:24   ` Andrew Lunn
2021-11-15 20:50 ` [PATCH net-next v5 2/3] dt-bindings: net: Add tsnep Ethernet controller Gerhard Engleder
2021-11-15 22:25   ` Andrew Lunn
2021-11-15 20:50 ` [PATCH net-next v5 3/3] tsnep: Add TSN endpoint Ethernet MAC driver Gerhard Engleder
2021-11-15 22:21   ` Heiner Kallweit
2021-11-16 21:47     ` Gerhard Engleder
2021-11-15 23:04   ` Andrew Lunn [this message]
2021-11-16 22:16     ` Gerhard Engleder
2021-11-16 23:41       ` Andrew Lunn
2021-11-18 17:31   ` kernel test robot

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=YZLnhOUg7A66AL5p@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=gerhard@engleder-embedded.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).