Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: David Thompson <davthompson@nvidia.com>
To: Jakub Kicinski <kuba@kernel.org>,
David Thompson <dthompson@mellanox.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"davem@davemloft.net" <davem@davemloft.net>,
Jiri Pirko <jiri@mellanox.com>, Asmaa Mnebhi <Asmaa@mellanox.com>
Subject: RE: [PATCH net-next v2] Add Mellanox BlueField Gigabit Ethernet driver
Date: Thu, 20 Aug 2020 18:51:39 +0000 [thread overview]
Message-ID: <MN2PR12MB2975DAA7292C27DEB0B518A8C75A0@MN2PR12MB2975.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20200730173059.7440e21c@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
> > +config MLXBF_GIGE
> > + tristate "Mellanox Technologies BlueField Gigabit Ethernet support"
> > + depends on (ARM64 || COMPILE_TEST) && ACPI && INET
>
> Why do you depend on INET? :S
>
When I wrote the Kconfig definition I was thinking that "INET" is an
obvious functional dependency for an Ethernet driver. However, if
Kconfig is just intended to express build-time dependencies, then yes,
the "INET" keyword can be removed.
> > + for (i = 0; i < priv->rx_q_entries; i++) {
> > + /* Allocate a receive buffer for this RX WQE. The DMA
> > + * form (dma_addr_t) of the receive buffer address is
> > + * stored in the RX WQE array (via 'rx_wqe_ptr') where
> > + * it is accessible by the GigE device. The VA form of
> > + * the receive buffer is stored in 'rx_buf[]' array in
> > + * the driver private storage for housekeeping.
> > + */
> > + priv->rx_buf[i] = dma_alloc_coherent(priv->dev,
> > +
> MLXBF_GIGE_DEFAULT_BUF_SZ,
> > + &rx_buf_dma,
> > + GFP_KERNEL);
>
> Do the buffers have to be in coherent memory? That's kinda strange.
>
Yes, the mlxbf_gige silicon block needs to be programmed with the
buffer's physical address so that the silicon logic can DMA incoming
packet data into the buffer. The kernel API "dma_alloc_coherent()"
meets the driver's requirements in that it returns a CPU-useable address
as well as a bus/physical address (used by silicon).
> > +static void mlxbf_gige_get_ethtool_stats(struct net_device *netdev,
> > + struct ethtool_stats *estats,
> > + u64 *data)
> > +{
> > + struct mlxbf_gige *priv = netdev_priv(netdev);
> > + unsigned long flags;
> > +
> > + spin_lock_irqsave(&priv->lock, flags);
>
> Why do you take a lock around stats?
>
I wrote the logic with a lock so that it implements an atomic "snapshot"
of the driver's statistics. This is useful since the standard TX/RX stats
are being incremented in packet completion logic triggered by the
NAPI framework. Do you see a disadvantage to using a lock here?
> > + /* Fill data array with interface statistics
> > + *
> > + * NOTE: the data writes must be in
> > + * sync with the strings shown in
> > + * the mlxbf_gige_ethtool_stats_keys[] array
> > + *
> > + * NOTE2: certain statistics below are zeroed upon
> > + * port disable, so the calculation below
> > + * must include the "cached" value of the stat
> > + * plus the value read directly from hardware.
> > + * Cached statistics are currently:
> > + * rx_din_dropped_pkts
> > + * rx_filter_passed_pkts
> > + * rx_filter_discard_pkts
> > + */
> > + *data++ = netdev->stats.rx_bytes;
> > + *data++ = netdev->stats.rx_packets;
> > + *data++ = netdev->stats.tx_bytes;
> > + *data++ = netdev->stats.tx_packets;
>
> Please don't duplicate standard stats in ethtool.
>
Understood.
> > +static const struct net_device_ops mlxbf_gige_netdev_ops = {
> > + .ndo_open = mlxbf_gige_open,
> > + .ndo_stop = mlxbf_gige_stop,
> > + .ndo_start_xmit = mlxbf_gige_start_xmit,
> > + .ndo_set_mac_address = eth_mac_addr,
> > + .ndo_validate_addr = eth_validate_addr,
> > + .ndo_do_ioctl = mlxbf_gige_do_ioctl,
> > + .ndo_set_rx_mode = mlxbf_gige_set_rx_mode,
>
> You must report standard stats.
>
Are you referring to the three possible methods that a driver
must use the implement support of standard stats reporting:
From include/linux/netdevice.h -->
* void (*ndo_get_stats64)(struct net_device *dev,
* struct rtnl_link_stats64 *storage);
* struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
* Called when a user wants to get the network device usage
* statistics. Drivers must do one of the following:
* 1. Define @ndo_get_stats64 to fill in a zero-initialised
* rtnl_link_stats64 structure passed by the caller.
* 2. Define @ndo_get_stats to update a net_device_stats structure
* (which should normally be dev->stats) and return a pointer to
* it. The structure may be changed asynchronously only if each
* field is written atomically.
* 3. Update dev->stats asynchronously and atomically, and define
* neither operation.
The mlxbf_gige driver has implemented #3 above, as there is logic
in the RX and TX completion handlers that increments RX/TX packet
and byte counts in the net_device->stats structure. Is that sufficient
for support of standard stats?
next prev parent reply other threads:[~2020-08-20 18:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-30 22:53 David Thompson
2020-07-31 0:30 ` Jakub Kicinski
2020-08-20 18:51 ` David Thompson [this message]
2020-08-20 19:25 ` Jakub Kicinski
2020-08-20 22:48 ` David Miller
2020-08-20 23:04 ` Vladimir Oltean
2020-08-21 0:14 ` Jakub Kicinski
2020-08-21 10:35 ` Vladimir Oltean
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=MN2PR12MB2975DAA7292C27DEB0B518A8C75A0@MN2PR12MB2975.namprd12.prod.outlook.com \
--to=davthompson@nvidia.com \
--cc=Asmaa@mellanox.com \
--cc=davem@davemloft.net \
--cc=dthompson@mellanox.com \
--cc=jiri@mellanox.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--subject='RE: [PATCH net-next v2] Add Mellanox BlueField Gigabit Ethernet driver' \
/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
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).