From: Andrew Lunn <andrew@lunn.ch>
To: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"Rob Herring" <robh+dt@kernel.org>,
"Andreas Färber" <afaerber@suse.de>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Philipp Zabel" <p.zabel@pengutronix.de>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-actions@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/3] net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver
Date: Tue, 23 Mar 2021 00:38:10 +0100 [thread overview]
Message-ID: <YFkqYqgwDhV/bBlc@lunn.ch> (raw)
In-Reply-To: <ab25bd143589d3c1894cdb3189670efa62ed1440.1616368101.git.cristian.ciocaltea@gmail.com>
> +static void owl_emac_set_multicast(struct net_device *netdev, int count)
> +{
> + struct owl_emac_priv *priv = netdev_priv(netdev);
> + struct netdev_hw_addr *ha;
> + int index = 0;
> +
> + if (count <= 0) {
> + priv->mcaddr_list.count = 0;
> + return;
> + }
> +
> + netdev_for_each_mc_addr(ha, netdev) {
> + if (!is_multicast_ether_addr(ha->addr))
> + continue;
Is this possible?
> +
> + WARN_ON(index >= OWL_EMAC_MAX_MULTICAST_ADDRS);
> + ether_addr_copy(priv->mcaddr_list.addrs[index++], ha->addr);
> + }
> +
> + priv->mcaddr_list.count = index;
> +
> + owl_emac_setup_frame_xmit(priv);
> +}
> +
> +static void owl_emac_ndo_set_rx_mode(struct net_device *netdev)
> +{
> + struct owl_emac_priv *priv = netdev_priv(netdev);
> + u32 status, val = 0;
> + int mcast_count = 0;
> +
> + if (netdev->flags & IFF_PROMISC) {
> + val = OWL_EMAC_BIT_MAC_CSR6_PR;
> + } else if (netdev->flags & IFF_ALLMULTI) {
> + val = OWL_EMAC_BIT_MAC_CSR6_PM;
> + } else if (netdev->flags & IFF_MULTICAST) {
> + mcast_count = netdev_mc_count(netdev);
> +
> + if (mcast_count > OWL_EMAC_MAX_MULTICAST_ADDRS) {
> + val = OWL_EMAC_BIT_MAC_CSR6_PM;
> + mcast_count = 0;
> + }
> + }
> +
> + spin_lock_bh(&priv->lock);
> +
> + /* Temporarily stop DMA TX & RX. */
> + status = owl_emac_dma_cmd_stop(priv);
> +
> + /* Update operation modes. */
> + owl_emac_reg_update(priv, OWL_EMAC_REG_MAC_CSR6,
> + OWL_EMAC_BIT_MAC_CSR6_PR | OWL_EMAC_BIT_MAC_CSR6_PM,
> + val);
> +
> + /* Restore DMA TX & RX status. */
> + owl_emac_dma_cmd_set(priv, status);
> +
> + spin_unlock_bh(&priv->lock);
> +
> + /* Set/reset multicast addr list. */
> + owl_emac_set_multicast(netdev, mcast_count);
> +}
I think this can be simplified. At least, you had me going around in
circles a while trying to see if WARN_ON() could be triggered from
user space.
If you have more than OWL_EMAC_MAX_MULTICAST_ADDRS MC addresses, you
go into promisc mode. Can you then skip calling
owl_emac_set_multicast(), which appears not to do too much useful when
passed 0?
Andrew
next prev parent reply other threads:[~2021-03-22 23:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-21 23:29 [PATCH v3 0/3] Add support for Actions Semi Owl Ethernet MAC Cristian Ciocaltea
2021-03-21 23:29 ` [PATCH v3 1/3] dt-bindings: net: Add Actions Semi Owl Ethernet MAC binding Cristian Ciocaltea
2021-03-21 23:29 ` [PATCH v3 2/3] net: ethernet: actions: Add Actions Semi Owl Ethernet MAC driver Cristian Ciocaltea
2021-03-22 3:30 ` Florian Fainelli
2021-03-22 8:44 ` Cristian Ciocaltea
2021-06-28 8:25 ` Amit Tomer
2021-06-28 9:57 ` Cristian Ciocaltea
2021-03-22 23:38 ` Andrew Lunn [this message]
2021-03-23 8:34 ` Cristian Ciocaltea
2021-03-21 23:29 ` [PATCH v3 3/3] MAINTAINERS: Add entries for Actions Semi Owl Ethernet MAC Cristian Ciocaltea
2021-03-22 20:00 ` [PATCH v3 0/3] Add support " patchwork-bot+netdevbpf
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=YFkqYqgwDhV/bBlc@lunn.ch \
--to=andrew@lunn.ch \
--cc=afaerber@suse.de \
--cc=cristian.ciocaltea@gmail.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-actions@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mani@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@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
all inboxes | Powered by JetHome®