Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3824396pxf; Mon, 22 Mar 2021 16:40:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysdQzJ088nnmCSe3Jg0CJJxbgBjIQvsBB94oQAh+K8dy2+92bdIMFSqr7bOUIoHrSTsYEg X-Received: by 2002:a05:6402:1c98:: with SMTP id cy24mr1998215edb.296.1616456433094; Mon, 22 Mar 2021 16:40:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616456433; cv=none; d=google.com; s=arc-20160816; b=xS+zcV5Cno7rQoha9Vs/UNH7V0ZJZkk/Y/AMl9Mcm20k0Tb9Y6CU2RsFk6UQYaJoZM Th8M7ghku2wIVrDwJgbW93NaNlPl7qmtf4wEcMLQHmOEXMXswlGQfwPmB2qO4OYEOxXJ 08/8BVdst/pwY/PdDMW8PCwAPgY0FyJ17YSLkTbRlXA2qj8t6rAZfwyXq5sXOcy27/sf aoW4jRkJRyTewH6AfCHrSmLixoknEtRcV6uXjpiNCP9+HSFOvQ3ysGIhcaJzJRHvaaXc xXsHDBxrMTzD3++tg9HcH+UtkXu4DWHIAS8EDiWlyd6HaRf9Svy8bUkgHi4HCbprxvd+ gmjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=s333tvcEizos1cKTU/3scSuP/Iu7Y3e3K2ZqwyY643Y=; b=V4M5oxPU+qXDkDozuHOKaaRK4Gj6CwzsPwdCL8B8kjZpi59wk4SFNpd40Idnt+JL/B SPwhiRKb6EEJo/mKWRg82Ic+5r3hlAPbsLK2CLDYes9ANuTuEAwt3vr5EBZzxKelp1Y3 9asDVJfZDU7LfvnYVyrEMMOPj1mgQh98kfekkCv+pbVRD5BzHFXFXIXGj5eJ433zeELY WOjc0P85qCcE4iPSMa+7UraS+bKOt12pt6NX3Vk7yEDnedd82/rl7IreMB0LAqq3Wpki ttIBYMDWat+9eORowM4+fs+hLyHi0CBmbpd8cTjYUqr/YH9ZBuTCGAUClZczO/cggaTg S8BA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt5si12167847ejb.181.2021.03.22.16.40.08; Mon, 22 Mar 2021 16:40:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230284AbhCVXjL (ORCPT + 99 others); Mon, 22 Mar 2021 19:39:11 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:41772 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230009AbhCVXil (ORCPT ); Mon, 22 Mar 2021 19:38:41 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1lOU7e-00CUJd-OG; Tue, 23 Mar 2021 00:38:10 +0100 Date: Tue, 23 Mar 2021 00:38:10 +0100 From: Andrew Lunn To: Cristian Ciocaltea Cc: "David S. Miller" , Jakub Kicinski , Rob Herring , Andreas =?iso-8859-1?Q?F=E4rber?= , Manivannan Sadhasivam , Philipp Zabel , 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 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +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