Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v5 02/18] net: dsa: sja1105: remove use of iterator after list_for_each_entry() loop
From: Jakob Koschel @ 2022-04-27 16:06 UTC (permalink / raw)
  To: David S. Miller
  Cc: Jakub Kicinski, Paolo Abeni, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Lars Povlsen, Steen Hegelund,
	UNGLinuxDriver, Ariel Elior, Manish Chopra, Edward Cree,
	Martin Habets, Michael Ellerman, Benjamin Herrenschmidt,
	Paul Mackerras, Jiri Pirko, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Casper Andersson, Jakob Koschel,
	Arnd Bergmann, Jason Gunthorpe, Christophe JAILLET,
	Colin Ian King, Eric Dumazet, Xu Wang, netdev, linux-kernel,
	linux-arm-kernel, linuxppc-dev, bpf, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.,
	Vladimir Oltean
In-Reply-To: <20220427160635.420492-1-jakobkoschel@gmail.com>

From: Vladimir Oltean <vladimir.oltean@nxp.com>

The link below explains that there is a desire to syntactically change
list_for_each_entry() and list_for_each() such that it becomes
impossible to use the iterator variable outside the scope of the loop.

Although sja1105_insert_gate_entry() makes legitimate use of the
iterator pointer when it breaks out, the pattern it uses may become
illegal, so it needs to change.

It is deemed acceptable to use a copy of the loop iterator, and
sja1105_insert_gate_entry() only needs to know the list_head element
before which the list insertion should be made. So let's profit from the
occasion and refactor the list iteration to a dedicated function.

An additional benefit is given by the fact that with the helper function
in place, we no longer need to special-case the empty list, since it is
equivalent to not having found any gating entry larger than the
specified interval in the list. We just need to insert at the tail of
that list (list_add vs list_add_tail on an empty list does the same
thing).

Link: https://patchwork.kernel.org/project/netdevbpf/patch/20220407102900.3086255-3-jakobkoschel@gmail.com/#24810127
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/sja1105/sja1105_vl.c | 46 ++++++++++++++++++----------
 1 file changed, 29 insertions(+), 17 deletions(-)

diff --git a/drivers/net/dsa/sja1105/sja1105_vl.c b/drivers/net/dsa/sja1105/sja1105_vl.c
index b7e95d60a6e4..369be2ac3587 100644
--- a/drivers/net/dsa/sja1105/sja1105_vl.c
+++ b/drivers/net/dsa/sja1105/sja1105_vl.c
@@ -7,6 +7,27 @@
 
 #define SJA1105_SIZE_VL_STATUS			8
 
+static struct list_head *
+sja1105_first_entry_longer_than(struct list_head *entries,
+				s64 interval,
+				struct netlink_ext_ack *extack)
+{
+	struct sja1105_gate_entry *p;
+
+	list_for_each_entry(p, entries, list) {
+		if (p->interval == interval) {
+			NL_SET_ERR_MSG_MOD(extack, "Gate conflict");
+			return ERR_PTR(-EBUSY);
+		}
+
+		if (interval < p->interval)
+			return &p->list;
+	}
+
+	/* Empty list, or specified interval is largest within the list */
+	return entries;
+}
+
 /* Insert into the global gate list, sorted by gate action time. */
 static int sja1105_insert_gate_entry(struct sja1105_gating_config *gating_cfg,
 				     struct sja1105_rule *rule,
@@ -14,6 +35,7 @@ static int sja1105_insert_gate_entry(struct sja1105_gating_config *gating_cfg,
 				     struct netlink_ext_ack *extack)
 {
 	struct sja1105_gate_entry *e;
+	struct list_head *pos;
 	int rc;
 
 	e = kzalloc(sizeof(*e), GFP_KERNEL);
@@ -24,25 +46,15 @@ static int sja1105_insert_gate_entry(struct sja1105_gating_config *gating_cfg,
 	e->gate_state = gate_state;
 	e->interval = entry_time;
 
-	if (list_empty(&gating_cfg->entries)) {
-		list_add(&e->list, &gating_cfg->entries);
-	} else {
-		struct sja1105_gate_entry *p;
-
-		list_for_each_entry(p, &gating_cfg->entries, list) {
-			if (p->interval == e->interval) {
-				NL_SET_ERR_MSG_MOD(extack,
-						   "Gate conflict");
-				rc = -EBUSY;
-				goto err;
-			}
-
-			if (e->interval < p->interval)
-				break;
-		}
-		list_add(&e->list, p->list.prev);
+	pos = sja1105_first_entry_longer_than(&gating_cfg->entries,
+					      e->interval, extack);
+	if (IS_ERR(pos)) {
+		rc = PTR_ERR(pos);
+		goto err;
 	}
 
+	list_add(&e->list, pos->prev);
+
 	gating_cfg->num_entries++;
 
 	return 0;
-- 
2.25.1


^ permalink raw reply related

* [PATCH net-next v5 00/18] Remove use of list iterator after loop body
From: Jakob Koschel @ 2022-04-27 16:06 UTC (permalink / raw)
  To: David S. Miller
  Cc: Jakub Kicinski, Paolo Abeni, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, Lars Povlsen, Steen Hegelund,
	UNGLinuxDriver, Ariel Elior, Manish Chopra, Edward Cree,
	Martin Habets, Michael Ellerman, Benjamin Herrenschmidt,
	Paul Mackerras, Jiri Pirko, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Casper Andersson, Jakob Koschel,
	Arnd Bergmann, Jason Gunthorpe, Christophe JAILLET,
	Colin Ian King, Eric Dumazet, Xu Wang, netdev, linux-kernel,
	linux-arm-kernel, linuxppc-dev, bpf, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

When the list iterator loop does not exit early the list iterator variable
contains a type-confused pointer to a 'bogus' list element computed based
on the head [1].

Often a 'found' variable is used to ensure the list iterator
variable is only accessed after the loop body if the loop did exit early
(using a break or goto).

In other cases that list iterator variable is used in
combination to access the list member which reverses the invocation of
container_of() and brings back a "safe" pointer to the head of the list.

Since, due to this code patten, there were quite a few bugs discovered [2],
Linus concluded that the rule should be to never use the list iterator
after the loop and introduce a dedicated pointer for that [3].

With the new gnu11 standard, it will now be possible to limit the scope
of the list iterator variable to the traversal loop itself by defining
the variable within the for loop.
This, however, requires to remove all uses of the list iterator after
the loop.

Based on input from Paolo Abeni [4], Vinicius Costa Gomes [5], and
Jakub Kicinski [6], I've splitted all the net-next related changes into
two patch sets, where this is part 1.a

v4->v5:
- fix reverse-xmas tree in efx_alloc_rss_context_entry() (Martin Habets)

v3->v4:
- fix build issue in efx_alloc_rss_context_entry() (Jakub Kicinski)

v2->v3:
- fix commit authors and signed-off order regarding Vladimir's patches
  (Sorry about that, wasn't intentional.)

v1->v2:
- Fixed commit message for PATCH 14/18 and used dedicated variable
  pointing to the position (Edward Cree)
- Removed redundant check in mv88e6xxx_port_vlan() (Vladimir Oltean)
- Refactor mv88e6xxx_port_vlan() using separate list iterator functions
  (Vladimir Oltean)
- Refactor sja1105_insert_gate_entry() to use separate list iterator
  functions (Vladimir Oltean)
- Allow early return in sja1105_insert_gate_entry() if
  sja1105_first_entry_longer_than() didn't find any element
  (Vladimir Oltean)
- Use list_add_tail() instead of list_add() in sja1105_insert_gate_entry()
  (Jakub Kicinski)
- net: netcp: also use separate 'pos' variable instead of duplicating list_add()

Link: https://lwn.net/Articles/887097/ [1]
Link: https://lore.kernel.org/linux-kernel/20220217184829.1991035-4-jakobkoschel@gmail.com/ [2]
Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [3]
Link: https://lore.kernel.org/linux-kernel/7393b673c626fd75f2b4f8509faa5459254fb87c.camel@redhat.com/ [4]
Link: https://lore.kernel.org/linux-kernel/877d8a3sww.fsf@intel.com/ [5]
Link: https://lore.kernel.org/linux-kernel/20220403205502.1b34415d@kernel.org/ [6]


^ permalink raw reply

* RE: [PATCH net-next v2 1/2] net: phy: microchip: update LAN88xx phy ID and phy ID mask.
From: Yuiko.Oshino @ 2022-04-27 16:02 UTC (permalink / raw)
  To: andrew; +Cc: Woojung.Huh, davem, netdev, Ravi.Hegde, UNGLinuxDriver
In-Reply-To: <YmljDTD9j3REqi47@lunn.ch>

>-----Original Message-----
>From: Andrew Lunn <andrew@lunn.ch>
>Sent: Wednesday, April 27, 2022 11:37 AM
>To: Yuiko Oshino - C18177 <Yuiko.Oshino@microchip.com>
>Cc: Woojung Huh - C21699 <Woojung.Huh@microchip.com>;
>davem@davemloft.net; netdev@vger.kernel.org; Ravi Hegde - C21689
><Ravi.Hegde@microchip.com>; UNGLinuxDriver
><UNGLinuxDriver@microchip.com>
>Subject: Re: [PATCH net-next v2 1/2] net: phy: microchip: update LAN88xx phy ID
>and phy ID mask.
>
>EXTERNAL EMAIL: Do not click links or open attachments unless you know the
>content is safe
>
>On Wed, Apr 27, 2022 at 05:19:56AM -0700, Yuiko Oshino wrote:
>> update LAN88xx phy ID and phy ID mask because the existing code conflicts
>with the LAN8742 phy.
>>
>> The current phy IDs on the available hardware.
>>         LAN8742 0x0007C130, 0x0007C131
>>         LAN88xx 0x0007C132
>>
>> Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
>> ---
>>  drivers/net/phy/microchip.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/phy/microchip.c b/drivers/net/phy/microchip.c
>> index 9f1f2b6c97d4..131caf659ed2 100644
>> --- a/drivers/net/phy/microchip.c
>> +++ b/drivers/net/phy/microchip.c
>> @@ -344,8 +344,8 @@ static int lan88xx_config_aneg(struct phy_device
>> *phydev)
>>
>>  static struct phy_driver microchip_phy_driver[] = {  {
>> -     .phy_id         = 0x0007c130,
>> -     .phy_id_mask    = 0xfffffff0,
>> +     .phy_id         = 0x0007c132,
>> +     .phy_id_mask    = 0xfffffff2,
>
>Just so my comment on the previous version does not get lost, is this the correct
>mask, because it is very odd. I think you really want 0xfffffffe?
>
>    Andrew

Hi Andrew,

thank you for your review.
Yes, 0xfffffff2 is correct for us.
We would like to have bits for future revisions of the hardware without updating the driver source code in the future.
If we use 0xfffffffe, then we need to submit a patch again when we have a new hardware revision.

Yuiko

^ permalink raw reply

* Re: [PATCH iproute2-next v3 0/2] f_flower: match on the number of vlan tags
From: Stephen Hemminger @ 2022-04-27 16:01 UTC (permalink / raw)
  To: Boris Sukholitko; +Cc: netdev, David Ahern, Ilya Lifshits, Jamal Hadi Salim
In-Reply-To: <20220427143200.GA23481@noodle>

On Wed, 27 Apr 2022 17:32:00 +0300
Boris Sukholitko <boris.sukholitko@broadcom.com> wrote:

> Hi Stephen,
> 
> On Tue, Apr 26, 2022 at 08:11:42AM -0700, Stephen Hemminger wrote:
> > On Tue, 26 Apr 2022 12:14:15 +0300
> > Boris Sukholitko <boris.sukholitko@broadcom.com> wrote:
> >   
> > > Hi,
> > > 
> > > Our customers in the fiber telecom world have network configurations
> > > where they would like to control their traffic according to the number
> > > of tags appearing in the packet.
> > > 
> > > For example, TR247 GPON conformance test suite specification mostly
> > > talks about untagged, single, double tagged packets and gives lax
> > > guidelines on the vlan protocol vs. number of vlan tags.
> > > 
> > > This is different from the common IT networks where 802.1Q and 802.1ad
> > > protocols are usually describe single and double tagged packet. GPON
> > > configurations that we work with have arbitrary mix the above protocols
> > > and number of vlan tags in the packet.
> > > 
> > > The following patch series implement number of vlans flower filter. They
> > > add num_of_vlans flower filter as an alternative to vlan ethtype protocol
> > > matching. The end result is that the following command becomes possible:
> > > 
> > > tc filter add dev eth1 ingress flower \
> > >   num_of_vlans 1 vlan_prio 5 action drop
> > > 
> > > Also, from our logs, we have redirect rules such that:
> > > 
> > > tc filter add dev $GPON ingress flower num_of_vlans $N \
> > >      action mirred egress redirect dev $DEV
> > > 
> > > where N can range from 0 to 3 and $DEV is the function of $N.
> > > 
> > > Also there are rules setting skb mark based on the number of vlans:
> > > 
> > > tc filter add dev $GPON ingress flower num_of_vlans $N vlan_prio \
> > >     $P action skbedit mark $M
> > > 
> > > Thanks,
> > > Boris.
> > > 
> > > - v3: rebased to the latest iproute2-next
> > > - v2: add missing f_flower subject prefix
> > > 
> > > Boris Sukholitko (2):
> > >   f_flower: Add num of vlans parameter
> > >   f_flower: Check args with num_of_vlans
> > > 
> > >  tc/f_flower.c | 57 ++++++++++++++++++++++++++++++++++++---------------
> > >  1 file changed, 41 insertions(+), 16 deletions(-)  
> > 
> > Can you do this with BPF? instead of kernel change?  
> 
> You may have missed my reply to this question at:
> 
> https://lore.kernel.org/netdev/20220412104514.GB27480@noodle/
> 
> There is also Jamal's reply further at the thread:
> 
> https://lore.kernel.org/netdev/b2c83f63-a2e9-92a2-f262-3aae3491dfc3@mojatatu.com/
> 
> Thanks,
> Boris.

Thanks, there is a tradeoff here, if you add more logic to the kernel, it
impacts every user and creates long term technical debt. Your use case seemed
quite specific to single use case.

But also, it is an example of something where kernel already has the state
information and it might be hard to get with BPF.

Surprised that the people who do BPF at scale did not chime in on this discussion.

^ permalink raw reply

* Re: [PATCH bpf-next 08/11] samples: bpf: fix shifting unsigned long by 32 positions
From: Yonghong Song @ 2022-04-27 15:54 UTC (permalink / raw)
  To: Andrii Nakryiko, Alexander Lobakin
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Martin KaFai Lau, Song Liu, John Fastabend, KP Singh,
	David S. Miller, Jakub Kicinski, Jesper Dangaard Brouer,
	Björn Töpel, Magnus Karlsson, Jonathan Lemon,
	Nathan Chancellor, Nick Desaulniers, Dmitrii Dolgov,
	Quentin Monnet, Tiezhu Yang, Kumar Kartikeya Dwivedi, Chenbo Feng,
	Willem de Bruijn, Daniel Wagner, Thomas Graf, Ong Boon Leong,
	linux-perf-use., open list, Networking, bpf, llvm
In-Reply-To: <CAEf4BzZVohaHdCTz_KFVdEus2pndLTZvg=BHfujpgt29qbio3Q@mail.gmail.com>



On 4/20/22 10:18 AM, Andrii Nakryiko wrote:
> On Thu, Apr 14, 2022 at 3:46 PM Alexander Lobakin <alobakin@pm.me> wrote:
>>
>> On 32 bit systems, shifting an unsigned long by 32 positions
>> yields the following warning:
>>
>> samples/bpf/tracex2_kern.c:60:23: warning: shift count >= width of type [-Wshift-count-overflow]
>>          unsigned int hi = v >> 32;
>>                              ^  ~~
>>
> 
> long is always 64-bit in BPF, but I suspect this is due to
> samples/bpf/Makefile still using this clang + llc combo, where clang
> is called with native target and llc for -target bpf. Not sure if we
> are ready to ditch that complicated combination. Yonghong, do we still
> need that or can we just use -target bpf in samples/bpf?

Current most bpf programs in samples/bpf do not use vmlinux.h and CO-RE.
They direct use kernel header files. That is why clang C -> IR 
compilation still needs to be native.

We could just use -target bpf for the whole compilation but that needs 
to change the code to use vmlinux.h and CO-RE. There are already a 
couple of sample bpf programs did this.

> 
> 
>> The usual way to avoid this is to shift by 16 two times (see
>> upper_32_bits() macro in the kernel). Use it across the BPF sample
>> code as well.
>>
>> Fixes: d822a1926849 ("samples/bpf: Add counting example for kfree_skb() function calls and the write() syscall")
>> Fixes: 0fb1170ee68a ("bpf: BPF based latency tracing")
>> Fixes: f74599f7c530 ("bpf: Add tests and samples for LWT-BPF")
>> Signed-off-by: Alexander Lobakin <alobakin@pm.me>
>> ---
>>   samples/bpf/lathist_kern.c      | 2 +-
>>   samples/bpf/lwt_len_hist_kern.c | 2 +-
>>   samples/bpf/tracex2_kern.c      | 2 +-
>>   3 files changed, 3 insertions(+), 3 deletions(-)
>>
> 
> [...]

^ permalink raw reply

* Re: [PATCH net 3/7] tcp: resalt the secret every 10 seconds
From: Stephen Hemminger @ 2022-04-27 15:56 UTC (permalink / raw)
  To: Willy Tarreau
  Cc: netdev, David Miller, Jakub Kicinski, Eric Dumazet, Moshe Kol,
	Yossi Gilad, Amit Klein, linux-kernel
In-Reply-To: <20220427065233.2075-4-w@1wt.eu>

On Wed, 27 Apr 2022 08:52:29 +0200
Willy Tarreau <w@1wt.eu> wrote:

> From: Eric Dumazet <edumazet@google.com>
> 
> In order to limit the ability for an observer to recognize the source
> ports sequence used to contact a set of destinations, we should
> periodically shuffle the secret. 10 seconds looks effective enough
> without causing particular issues.
> 
> Cc: Moshe Kol <moshe.kol@mail.huji.ac.il>
> Cc: Yossi Gilad <yossi.gilad@mail.huji.ac.il>
> Cc: Amit Klein <aksecurity@gmail.com>
> Tested-by: Willy Tarreau <w@1wt.eu>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
>  net/core/secure_seq.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
> index 2cdd43a63f64..200ab4686275 100644
> --- a/net/core/secure_seq.c
> +++ b/net/core/secure_seq.c
> @@ -22,6 +22,8 @@
>  static siphash_aligned_key_t net_secret;
>  static siphash_aligned_key_t ts_secret;
>  

Rather than hard coding, why not have a sysctl knob for this?
That way the tinfoil types can set it smaller.

^ permalink raw reply

* Re: [PATCH net 1/2] ptp: ptp_clockmatrix: Add PTP_CLK_REQ_EXTTS support
From: Jakub Kicinski @ 2022-04-27 15:55 UTC (permalink / raw)
  To: Min Li
  Cc: richardcochran@gmail.com, lee.jones@linaro.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
In-Reply-To: <OS3PR01MB6593BE917485C87E32D1E5FDBAFA9@OS3PR01MB6593.jpnprd01.prod.outlook.com>

On Wed, 27 Apr 2022 14:32:03 +0000 Min Li wrote:
> > On Tue, 26 Apr 2022 15:32:53 -0400 Min Li wrote:  
> > > Use TOD_READ_SECONDARY for extts to keep TOD_READ_PRIMARY for  
> > gettime  
> > > and settime exclusively  
> > 
> > Does not build on 32 bit.
> >   
> 
> Hi Jakub
> 
> I compiled with arm-linux-gnueabi-
> 
> By 32 bit, did you mean x86?

Yup! I think arm does not have the 64b division problems x86 has.
We hit the dreaded 

ERROR: modpost: "__divdi3" [drivers/ptp/ptp_clockmatrix.ko] undefined!
ERROR: modpost: "__udivdi3" [drivers/ptp/ptp_clockmatrix.ko] undefined!

on 32b x86 builds. Sorry for lack of clarity.

^ permalink raw reply

* Re: [PATCH net-next 03/14] eth: cpsw: remove a copy of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:53 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: davem@davemloft.net, pabeni@redhat.com, netdev@vger.kernel.org,
	grygorii.strashko@ti.com, chi.minghao@zte.com.cn, toke@redhat.com,
	chenhao288@hisilicon.com, moyufeng@huawei.com,
	linux-omap@vger.kernel.org
In-Reply-To: <20220427154702.fbpxfjp4h7ey5ea2@skbuf>

On Wed, 27 Apr 2022 15:47:03 +0000 Vladimir Oltean wrote:
> On Wed, Apr 27, 2022 at 08:41:00AM -0700, Jakub Kicinski wrote:
> > Defining local versions of NAPI_POLL_WEIGHT with the same
> > values in the drivers just makes refactoring harder.
> > 
> > Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> > ---
> > CC: grygorii.strashko@ti.com
> > CC: chi.minghao@zte.com.cn
> > CC: vladimir.oltean@nxp.com  
> 
> Fine with me (I mean, I don't even know why I'm copied on cpsw changes).

get_maintainer, I didn't bother filtering this time

> Why is the weight even an argument to netif_napi_add() anyway?

Right, not sure, see the cover letter.

^ permalink raw reply

* Re: [PATCH bpf-next 2/4] libbpf: Add helpers for pinning bpf prog through bpf object skeleton
From: Yafang Shao @ 2022-04-27 15:47 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Daniel Borkmann, Alexei Starovoitov, Andrii Nakryiko, Martin Lau,
	Song Liu, Yonghong Song, john fastabend, KP Singh, netdev, bpf
In-Reply-To: <CALOAHbAPZVDKXE-0fBkDMdbcTZSQZjto7sjpDnG0X_cSBCV8Pw@mail.gmail.com>

On Wed, Apr 27, 2022 at 10:45 PM Yafang Shao <laoar.shao@gmail.com> wrote:
>
> On Wed, Apr 27, 2022 at 7:16 AM Andrii Nakryiko
> <andrii.nakryiko@gmail.com> wrote:
> >
> > On Tue, Apr 26, 2022 at 8:59 AM Yafang Shao <laoar.shao@gmail.com> wrote:
> > >
> > > On Mon, Apr 25, 2022 at 9:57 PM Daniel Borkmann <daniel@iogearbox.net> wrote:
> > > >
> > > > On 4/23/22 4:00 PM, Yafang Shao wrote:
> > > > > Currently there're helpers for allowing to open/load/attach BPF object
> > > > > through BPF object skeleton. Let's also add helpers for pinning through
> > > > > BPF object skeleton. It could simplify BPF userspace code which wants to
> > > > > pin the progs into bpffs.
> > > >
> > > > Please elaborate some more on your use case/rationale for the commit message,
> > > > do you have orchestration code that will rely on these specifically?
> > > >
> > >
> > > We have a bpf manager on our production environment to maintain the
> > > bpf programs, some of which need to be pinned in bpffs, for example
> > > tracing bpf programs, perf_event programs and other bpf hooks added by
> > > ourselves for performance tuning.  These bpf programs don't need a
> > > user agent, while they really work like a kernel module, that is why
> > > we pin them. For these kinds of bpf programs, the bpf manager can help
> > > to simplify the development and deployment.  Take the improvement on
> > > development for example,  the user doesn't need to write userspace
> > > code while he focuses on the kernel side only, and then bpf manager
> > > will do all the other things. Below is a simple example,
> > >    Step1, gen the skeleton for the user provided bpf object file,
> > >               $ bpftool gen skeleton  test.bpf.o > simple.skel.h
> > >    Step2, Compile the bpf object file into a runnable binary
> > >               #include "simple.skel.h"
> > >
> > >               #define SIMPLE_BPF_PIN(name, path)  \
> > >               ({                                                              \
> > >                   struct name##_bpf *obj;                      \
> > >                   int err = 0;                                            \
> > >                                                                               \
> > >                   obj = name##_bpf__open();                \
> > >                    if (!obj) {                                              \
> > >                        err = -errno;                                    \
> > >                        goto cleanup;                                 \
> > >                     }                                                         \
> > >                                                                               \
> > >                     err = name##_bpf__load(obj);           \
> > >                     if (err)                                                 \
> > >                         goto cleanup;                                 \
> > >                                                                                \
> > >                      err = name##_bpf__attach(obj);       \
> > >                      if (err)                                                \
> > >                          goto cleanup;                                \
> > >                                                                                \
> > >                      err = name##_bpf__pin_prog(obj, path);      \
> > >                      if (err)                                                \
> > >                          goto cleanup;                                \
> > >                                                                               \
> > >                       goto end;                                         \
> > >                                                                               \
> > >                   cleanup:                                              \
> > >                       name##_bpf__destroy(obj);            \
> > >                   end:                                                     \
> > >                       err;                                                  \
> > >                    })
> > >
> > >                    SIMPLE_BPF_PIN(test, "/sys/fs/bpf");
> > >
> > >                As the userspace code of FD-based bpf objects are all
> > > the same,  so we can abstract them as above.  The pathset means to add
> > > the non-exist "name##_bpf__pin_prog(obj, path)" for it.
> > >
> >
> > Your BPF manager is user-space code that you control, right? I'm not
> > sure how skeleton is helpful here given your BPF manager is generic
> > and doesn't work with any specific skeleton, if I understand the idea.
> > But let's assume that you use skeleton to also embed BPF ELF bytes and
> > pass them to your manager for "activation". Once you open and load
> > bpf_object, your BPF manager can generically iterate all BPF programs
> > using bpf_object_for_each_program(), attempt to attach them with
> > bpf_program__attach() (see how bpf_object__attach_skeleton is handling
> > non-auto-attachable programs) and immediately pin the link (no need to
> > even store it, you can destroy it after pinning immediately). All this
> > is using generic libbpf APIs and requires no code generation.
>
> Many thanks for the detailed explanation. Your suggestion can also
> work, but with the skeleton we can also generate a binary which can
> run independently.  (Technically speaking, the binary is the same as
> './bpf_install target.bpf.o').
>

Forgot to mention that with skeleton we can also modify the global
data defined in bpf object file, that may need to be abstracted as a
new common helper.  The bpf_object__* functions can't do it, right ?

> >  But keep
> > in mind that not all struct bpf_link in libbpf are pinnable (not all
> > links have FD-based BPF link in kernel associated with them), so
> > you'll have to deal with that somehow (and what you didn't do in this
> > patch for libbpf implementation).
> >
>
> Right, I have found it. If I understand it correctly, only the link
> types defined in enum bpf_link_type (which is in
> include/uapi/linux/bpf.h) are pinnable, right?
>
> BTW, is it possible to support pinning all struct bpf_link in libbpf ?
>
>
> --
> Regards
> Yafang



-- 
Regards
Yafang

^ permalink raw reply

* Re: [PATCH net-next 03/14] eth: cpsw: remove a copy of the NAPI_POLL_WEIGHT define
From: Vladimir Oltean @ 2022-04-27 15:47 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem@davemloft.net, pabeni@redhat.com, netdev@vger.kernel.org,
	grygorii.strashko@ti.com, chi.minghao@zte.com.cn, toke@redhat.com,
	chenhao288@hisilicon.com, moyufeng@huawei.com,
	linux-omap@vger.kernel.org
In-Reply-To: <20220427154111.529975-4-kuba@kernel.org>

On Wed, Apr 27, 2022 at 08:41:00AM -0700, Jakub Kicinski wrote:
> Defining local versions of NAPI_POLL_WEIGHT with the same
> values in the drivers just makes refactoring harder.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: grygorii.strashko@ti.com
> CC: chi.minghao@zte.com.cn
> CC: vladimir.oltean@nxp.com

Fine with me (I mean, I don't even know why I'm copied on cpsw changes).

Why is the weight even an argument to netif_napi_add() anyway?

> CC: toke@redhat.com
> CC: chenhao288@hisilicon.com
> CC: moyufeng@huawei.com
> CC: linux-omap@vger.kernel.org
> ---

^ permalink raw reply

* Re: [PATCH net] usbnet: smsc95xx: Fix deadlock on runtime resume
From: Lukas Wunner @ 2022-04-27 15:45 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Steve Glendinning, UNGLinuxDriver, Oliver Neukum, David S. Miller,
	Jakub Kicinski, Paolo Abeni, netdev, linux-usb, Andre Edich,
	Oleksij Rempel, Martyn Welch, Gabriel Hojda, Christoph Fritz,
	Lino Sanfilippo, Philipp Rosenberger, Heiner Kallweit,
	Russell King
In-Reply-To: <YmlgQhauzZ/tkX/v@lunn.ch>

On Wed, Apr 27, 2022 at 05:24:50PM +0200, Andrew Lunn wrote:
> You have looked at this code, tried a few different things, so this is
> probably a dumb question.
> 
> Do you actually need to call phy_init_hw()?

I should add that the PHY register state may not be preserved on
runtime PM if woken via the ->reset_resume hook and I believe
that's the case when phy_init_hw() is necessary.

smsc95xx_suspend() currently accesses PHY registers behind the
PHY driver's back to enable Energy Detect Powerdown and it
uses smsc95xx_mdio_write_nopm() for that, hence that doesn't
deadlock *currently*, but the code should be moved to the PHY
driver, and then it will.

Thanks,

Lukas

^ permalink raw reply

* [PATCH net-next 14/14] eth: velocity: remove a copy of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:41 UTC (permalink / raw)
  To: davem, pabeni; +Cc: netdev, Jakub Kicinski, romieu
In-Reply-To: <20220427154111.529975-1-kuba@kernel.org>

Defining local versions of NAPI_POLL_WEIGHT with the same
values in the drivers just makes refactoring harder.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: romieu@fr.zoreil.com
---
 drivers/net/ethernet/via/via-velocity.c | 3 +--
 drivers/net/ethernet/via/via-velocity.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c
index be2b992f24d9..ff0c102cb578 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -2846,8 +2846,7 @@ static int velocity_probe(struct device *dev, int irq,
 
 	netdev->netdev_ops = &velocity_netdev_ops;
 	netdev->ethtool_ops = &velocity_ethtool_ops;
-	netif_napi_add(netdev, &vptr->napi, velocity_poll,
-							VELOCITY_NAPI_WEIGHT);
+	netif_napi_add(netdev, &vptr->napi, velocity_poll, NAPI_POLL_WEIGHT);
 
 	netdev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG |
 			   NETIF_F_HW_VLAN_CTAG_TX;
diff --git a/drivers/net/ethernet/via/via-velocity.h b/drivers/net/ethernet/via/via-velocity.h
index d3f960cc7c6e..c02a9654dce6 100644
--- a/drivers/net/ethernet/via/via-velocity.h
+++ b/drivers/net/ethernet/via/via-velocity.h
@@ -23,7 +23,6 @@
 #define VELOCITY_VERSION       "1.15"
 
 #define VELOCITY_IO_SIZE	256
-#define VELOCITY_NAPI_WEIGHT	64
 
 #define PKT_BUF_SZ          1540
 
-- 
2.34.1


^ permalink raw reply related

* [PATCH net-next 09/14] eth: atlantic: remove a copy of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:41 UTC (permalink / raw)
  To: davem, pabeni; +Cc: netdev, Jakub Kicinski, irusskikh, epomozov
In-Reply-To: <20220427154111.529975-1-kuba@kernel.org>

Defining local versions of NAPI_POLL_WEIGHT with the same
values in the drivers just makes refactoring harder.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: irusskikh@marvell.com
CC: epomozov@marvell.com
---
 drivers/net/ethernet/aquantia/atlantic/aq_cfg.h | 2 --
 drivers/net/ethernet/aquantia/atlantic/aq_ptp.c | 2 +-
 drivers/net/ethernet/aquantia/atlantic/aq_vec.c | 2 +-
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h b/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h
index 8bcda2cb3a2e..7e9c74b141ef 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h
@@ -65,8 +65,6 @@
  */
 #define AQ_CFG_RESTART_DESC_THRES   (AQ_CFG_SKB_FRAGS_MAX * 2)
 
-#define AQ_CFG_NAPI_WEIGHT     64U
-
 /*#define AQ_CFG_MAC_ADDR_PERMANENT {0x30, 0x0E, 0xE3, 0x12, 0x34, 0x56}*/
 
 #define AQ_CFG_FC_MODE AQ_NIC_FC_FULL
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
index 06de19f63287..275324c9e51e 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
@@ -1218,7 +1218,7 @@ int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec)
 	atomic_set(&aq_ptp->offset_ingress, 0);
 
 	netif_napi_add(aq_nic_get_ndev(aq_nic), &aq_ptp->napi,
-		       aq_ptp_poll, AQ_CFG_NAPI_WEIGHT);
+		       aq_ptp_poll, NAPI_POLL_WEIGHT);
 
 	aq_ptp->idx_vector = idx_vec;
 
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_vec.c b/drivers/net/ethernet/aquantia/atlantic/aq_vec.c
index e839e1002ec7..f0fdf20f01c1 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_vec.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_vec.c
@@ -120,7 +120,7 @@ struct aq_vec_s *aq_vec_alloc(struct aq_nic_s *aq_nic, unsigned int idx,
 	self->rx_rings = 0;
 
 	netif_napi_add(aq_nic_get_ndev(aq_nic), &self->napi,
-		       aq_vec_poll, AQ_CFG_NAPI_WEIGHT);
+		       aq_vec_poll, NAPI_POLL_WEIGHT);
 
 err_exit:
 	return self;
-- 
2.34.1


^ permalink raw reply related

* [PATCH net-next 07/14] slic: remove a copy of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:41 UTC (permalink / raw)
  To: davem, pabeni; +Cc: netdev, Jakub Kicinski, LinoSanfilippo
In-Reply-To: <20220427154111.529975-1-kuba@kernel.org>

Defining local versions of NAPI_POLL_WEIGHT with the same
values in the drivers just makes refactoring harder.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: LinoSanfilippo@gmx.de
---
 drivers/net/ethernet/alacritech/slic.h    | 2 --
 drivers/net/ethernet/alacritech/slicoss.c | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/alacritech/slic.h b/drivers/net/ethernet/alacritech/slic.h
index 3add305d34b4..4eecbdfff3ff 100644
--- a/drivers/net/ethernet/alacritech/slic.h
+++ b/drivers/net/ethernet/alacritech/slic.h
@@ -265,8 +265,6 @@
 #define SLIC_NUM_STAT_DESC_ARRAYS	4
 #define SLIC_INVALID_STAT_DESC_IDX	0xffffffff
 
-#define SLIC_NAPI_WEIGHT		64
-
 #define SLIC_UPR_LSTAT			0
 #define SLIC_UPR_CONFIG			1
 
diff --git a/drivers/net/ethernet/alacritech/slicoss.c b/drivers/net/ethernet/alacritech/slicoss.c
index 1fc9a1cd3ef8..ce353b0c02a3 100644
--- a/drivers/net/ethernet/alacritech/slicoss.c
+++ b/drivers/net/ethernet/alacritech/slicoss.c
@@ -1803,7 +1803,7 @@ static int slic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto unmap;
 	}
 
-	netif_napi_add(dev, &sdev->napi, slic_poll, SLIC_NAPI_WEIGHT);
+	netif_napi_add(dev, &sdev->napi, slic_poll, NAPI_POLL_WEIGHT);
 	netif_carrier_off(dev);
 
 	err = register_netdev(dev);
-- 
2.34.1


^ permalink raw reply related

* [PATCH net-next 13/14] eth: spider: remove a copy of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:41 UTC (permalink / raw)
  To: davem, pabeni; +Cc: netdev, Jakub Kicinski, kou.ishizaki, geoff, linuxppc-dev
In-Reply-To: <20220427154111.529975-1-kuba@kernel.org>

Defining local versions of NAPI_POLL_WEIGHT with the same
values in the drivers just makes refactoring harder.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: kou.ishizaki@toshiba.co.jp
CC: geoff@infradead.org
CC: linuxppc-dev@lists.ozlabs.org
---
 drivers/net/ethernet/toshiba/spider_net.c | 2 +-
 drivers/net/ethernet/toshiba/spider_net.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/toshiba/spider_net.c b/drivers/net/ethernet/toshiba/spider_net.c
index f47b8358669d..c09cd961edbb 100644
--- a/drivers/net/ethernet/toshiba/spider_net.c
+++ b/drivers/net/ethernet/toshiba/spider_net.c
@@ -2270,7 +2270,7 @@ spider_net_setup_netdev(struct spider_net_card *card)
 	timer_setup(&card->aneg_timer, spider_net_link_phy, 0);
 
 	netif_napi_add(netdev, &card->napi,
-		       spider_net_poll, SPIDER_NET_NAPI_WEIGHT);
+		       spider_net_poll, NAPI_POLL_WEIGHT);
 
 	spider_net_setup_netdev_ops(netdev);
 
diff --git a/drivers/net/ethernet/toshiba/spider_net.h b/drivers/net/ethernet/toshiba/spider_net.h
index 05b1a0736835..51948e2b3a34 100644
--- a/drivers/net/ethernet/toshiba/spider_net.h
+++ b/drivers/net/ethernet/toshiba/spider_net.h
@@ -44,7 +44,6 @@ extern char spider_net_driver_name[];
 #define SPIDER_NET_RX_CSUM_DEFAULT		1
 
 #define SPIDER_NET_WATCHDOG_TIMEOUT		50*HZ
-#define SPIDER_NET_NAPI_WEIGHT			64
 
 #define SPIDER_NET_FIRMWARE_SEQS	6
 #define SPIDER_NET_FIRMWARE_SEQWORDS	1024
-- 
2.34.1


^ permalink raw reply related

* [PATCH net-next 01/14] eth: remove copies of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:40 UTC (permalink / raw)
  To: davem, pabeni
  Cc: netdev, Jakub Kicinski, ulli.kroll, linus.walleij, mlindner,
	stephen, nbd, john, sean.wang, Mark-MC.Lee, matthias.bgg,
	grygorii.strashko, wei.liu, paul, prabhakar.mahadev-lad.rj,
	linux-arm-kernel, linux-mediatek, linux-omap, xen-devel
In-Reply-To: <20220427154111.529975-1-kuba@kernel.org>

Defining local versions of NAPI_POLL_WEIGHT with the same
values in the drivers just makes refactoring harder.

Drop the special defines in a bunch of drivers where the
removal is relatively simple so grouping into one patch
does not impact reviewability.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: ulli.kroll@googlemail.com
CC: linus.walleij@linaro.org
CC: mlindner@marvell.com
CC: stephen@networkplumber.org
CC: nbd@nbd.name
CC: john@phrozen.org
CC: sean.wang@mediatek.com
CC: Mark-MC.Lee@mediatek.com
CC: matthias.bgg@gmail.com
CC: grygorii.strashko@ti.com
CC: wei.liu@kernel.org
CC: paul@xen.org
CC: prabhakar.mahadev-lad.rj@bp.renesas.com
CC: linux-arm-kernel@lists.infradead.org
CC: linux-mediatek@lists.infradead.org
CC: linux-omap@vger.kernel.org
CC: xen-devel@lists.xenproject.org
---
 drivers/net/ethernet/cortina/gemini.c         | 4 +---
 drivers/net/ethernet/marvell/skge.c           | 3 +--
 drivers/net/ethernet/marvell/sky2.c           | 3 +--
 drivers/net/ethernet/mediatek/mtk_star_emac.c | 3 +--
 drivers/net/ethernet/ti/davinci_emac.c        | 3 +--
 drivers/net/ethernet/ti/netcp_core.c          | 5 ++---
 drivers/net/xen-netback/interface.c           | 3 +--
 7 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index 8014eb33937c..9e6de2f968fa 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -68,7 +68,6 @@ MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
 #define DEFAULT_GMAC_RXQ_ORDER		9
 #define DEFAULT_GMAC_TXQ_ORDER		8
 #define DEFAULT_RX_BUF_ORDER		11
-#define DEFAULT_NAPI_WEIGHT		64
 #define TX_MAX_FRAGS			16
 #define TX_QUEUE_NUM			1	/* max: 6 */
 #define RX_MAX_ALLOC_ORDER		2
@@ -2472,8 +2471,7 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
 	netdev->max_mtu = 10236 - VLAN_ETH_HLEN;
 
 	port->freeq_refill = 0;
-	netif_napi_add(netdev, &port->napi, gmac_napi_poll,
-		       DEFAULT_NAPI_WEIGHT);
+	netif_napi_add(netdev, &port->napi, gmac_napi_poll, NAPI_POLL_WEIGHT);
 
 	ret = of_get_mac_address(np, mac);
 	if (!ret) {
diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index cf03c67fbf40..c1e985416c0e 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -50,7 +50,6 @@
 #define PHY_RETRIES	        1000
 #define ETH_JUMBO_MTU		9000
 #define TX_WATCHDOG		(5 * HZ)
-#define NAPI_WEIGHT		64
 #define BLINK_MS		250
 #define LINK_HZ			HZ
 
@@ -3833,7 +3832,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
 		dev->features |= NETIF_F_HIGHDMA;
 
 	skge = netdev_priv(dev);
-	netif_napi_add(dev, &skge->napi, skge_poll, NAPI_WEIGHT);
+	netif_napi_add(dev, &skge->napi, skge_poll, NAPI_POLL_WEIGHT);
 	skge->netdev = dev;
 	skge->hw = hw;
 	skge->msg_enable = netif_msg_init(debug, default_msg);
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index ea16b1dd6a98..a1e907c85217 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -63,7 +63,6 @@
 #define TX_DEF_PENDING		63
 
 #define TX_WATCHDOG		(5 * HZ)
-#define NAPI_WEIGHT		64
 #define PHY_RETRIES		1000
 
 #define SKY2_EEPROM_MAGIC	0x9955aabb
@@ -4938,7 +4937,7 @@ static int sky2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		}
 	}
 
-	netif_napi_add(dev, &hw->napi, sky2_poll, NAPI_WEIGHT);
+	netif_napi_add(dev, &hw->napi, sky2_poll, NAPI_POLL_WEIGHT);
 
 	err = register_netdev(dev);
 	if (err) {
diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c
index 4cd0747edaff..95839fd84dab 100644
--- a/drivers/net/ethernet/mediatek/mtk_star_emac.c
+++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c
@@ -30,7 +30,6 @@
 #define MTK_STAR_WAIT_TIMEOUT			300
 #define MTK_STAR_MAX_FRAME_SIZE			1514
 #define MTK_STAR_SKB_ALIGNMENT			16
-#define MTK_STAR_NAPI_WEIGHT			64
 #define MTK_STAR_HASHTABLE_MC_LIMIT		256
 #define MTK_STAR_HASHTABLE_SIZE_MAX		512
 
@@ -1551,7 +1550,7 @@ static int mtk_star_probe(struct platform_device *pdev)
 	ndev->netdev_ops = &mtk_star_netdev_ops;
 	ndev->ethtool_ops = &mtk_star_ethtool_ops;
 
-	netif_napi_add(ndev, &priv->napi, mtk_star_poll, MTK_STAR_NAPI_WEIGHT);
+	netif_napi_add(ndev, &priv->napi, mtk_star_poll, NAPI_POLL_WEIGHT);
 
 	return devm_register_netdev(dev, ndev);
 }
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 9d1e98db308b..2a3e4e842fa5 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -113,7 +113,6 @@ static const char emac_version_string[] = "TI DaVinci EMAC Linux v6.1";
 #define EMAC_DEF_RX_NUM_DESC		(128)
 #define EMAC_DEF_MAX_TX_CH		(1) /* Max TX channels configured */
 #define EMAC_DEF_MAX_RX_CH		(1) /* Max RX channels configured */
-#define EMAC_POLL_WEIGHT		(64) /* Default NAPI poll weight */
 
 /* Buffer descriptor parameters */
 #define EMAC_DEF_TX_MAX_SERVICE		(32) /* TX max service BD's */
@@ -1949,7 +1948,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
 
 	ndev->netdev_ops = &emac_netdev_ops;
 	ndev->ethtool_ops = &ethtool_ops;
-	netif_napi_add(ndev, &priv->napi, emac_poll, EMAC_POLL_WEIGHT);
+	netif_napi_add(ndev, &priv->napi, emac_poll, NAPI_POLL_WEIGHT);
 
 	pm_runtime_enable(&pdev->dev);
 	rc = pm_runtime_resume_and_get(&pdev->dev);
diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index 16507bff652a..21b0e961eab5 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -24,7 +24,6 @@
 #include "netcp.h"
 
 #define NETCP_SOP_OFFSET	(NET_IP_ALIGN + NET_SKB_PAD)
-#define NETCP_NAPI_WEIGHT	64
 #define NETCP_TX_TIMEOUT	(5 * HZ)
 #define NETCP_PACKET_SIZE	(ETH_FRAME_LEN + ETH_FCS_LEN)
 #define NETCP_MIN_PACKET_SIZE	ETH_ZLEN
@@ -2096,8 +2095,8 @@ static int netcp_create_interface(struct netcp_device *netcp_device,
 	}
 
 	/* NAPI register */
-	netif_napi_add(ndev, &netcp->rx_napi, netcp_rx_poll, NETCP_NAPI_WEIGHT);
-	netif_tx_napi_add(ndev, &netcp->tx_napi, netcp_tx_poll, NETCP_NAPI_WEIGHT);
+	netif_napi_add(ndev, &netcp->rx_napi, netcp_rx_poll, NAPI_POLL_WEIGHT);
+	netif_tx_napi_add(ndev, &netcp->tx_napi, netcp_tx_poll, NAPI_POLL_WEIGHT);
 
 	/* Register the network device */
 	ndev->dev_id		= 0;
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index fe8e21ad8ed9..8e035374a370 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -42,7 +42,6 @@
 #include <xen/balloon.h>
 
 #define XENVIF_QUEUE_LENGTH 32
-#define XENVIF_NAPI_WEIGHT  64
 
 /* Number of bytes allowed on the internal guest Rx queue. */
 #define XENVIF_RX_QUEUE_BYTES (XEN_NETIF_RX_RING_SIZE/2 * PAGE_SIZE)
@@ -739,7 +738,7 @@ int xenvif_connect_data(struct xenvif_queue *queue,
 	atomic_set(&queue->inflight_packets, 0);
 
 	netif_napi_add(queue->vif->dev, &queue->napi, xenvif_poll,
-			XENVIF_NAPI_WEIGHT);
+			NAPI_POLL_WEIGHT);
 
 	queue->stalled = true;
 
-- 
2.34.1


^ permalink raw reply related

* [PATCH net-next 12/14] eth: vxge: remove a copy of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:41 UTC (permalink / raw)
  To: davem, pabeni
  Cc: netdev, Jakub Kicinski, jdmason, zhengyongjun3,
	christophe.jaillet
In-Reply-To: <20220427154111.529975-1-kuba@kernel.org>

Defining local versions of NAPI_POLL_WEIGHT with the same
values in the drivers just makes refactoring harder.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: jdmason@kudzu.us
CC: zhengyongjun3@huawei.com
CC: christophe.jaillet@wanadoo.fr
---
 drivers/net/ethernet/neterion/vxge/vxge-main.c | 2 +-
 drivers/net/ethernet/neterion/vxge/vxge-main.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c
index aa7c093f1f91..db4dfae8c01d 100644
--- a/drivers/net/ethernet/neterion/vxge/vxge-main.c
+++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c
@@ -4351,7 +4351,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
 	}
 	ll_config->tx_steering_type = TX_MULTIQ_STEERING;
 	ll_config->intr_type = MSI_X;
-	ll_config->napi_weight = NEW_NAPI_WEIGHT;
+	ll_config->napi_weight = NAPI_POLL_WEIGHT;
 	ll_config->rth_steering = RTH_STEERING;
 
 	/* get the default configuration parameters */
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.h b/drivers/net/ethernet/neterion/vxge/vxge-main.h
index 63f65193dd49..da9d2c191828 100644
--- a/drivers/net/ethernet/neterion/vxge/vxge-main.h
+++ b/drivers/net/ethernet/neterion/vxge/vxge-main.h
@@ -167,8 +167,6 @@ struct macInfo {
 struct vxge_config {
 	int		tx_pause_enable;
 	int		rx_pause_enable;
-
-#define	NEW_NAPI_WEIGHT	64
 	int		napi_weight;
 	int		intr_type;
 #define INTA	0
-- 
2.34.1


^ permalink raw reply related

* [PATCH net-next 04/14] eth: pch_gbe: remove a copy of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:41 UTC (permalink / raw)
  To: davem, pabeni; +Cc: netdev, Jakub Kicinski, andriy.shevchenko
In-Reply-To: <20220427154111.529975-1-kuba@kernel.org>

Defining local versions of NAPI_POLL_WEIGHT with the same
values in the drivers just makes refactoring harder.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: andriy.shevchenko@linux.intel.com
---
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 1dc40c537281..46da937ad27f 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -32,8 +32,6 @@
 #define PCI_DEVICE_ID_ROHM_ML7223_GBE		0x8013
 #define PCI_DEVICE_ID_ROHM_ML7831_GBE		0x8802
 
-#define PCH_GBE_TX_WEIGHT         64
-#define PCH_GBE_RX_WEIGHT         64
 #define PCH_GBE_RX_BUFFER_WRITE   16
 
 /* Initialize the wake-on-LAN settings */
@@ -1469,7 +1467,7 @@ pch_gbe_clean_tx(struct pch_gbe_adapter *adapter,
 		   tx_desc->gbec_status, tx_desc->dma_status);
 
 	unused = PCH_GBE_DESC_UNUSED(tx_ring);
-	thresh = tx_ring->count - PCH_GBE_TX_WEIGHT;
+	thresh = tx_ring->count - NAPI_POLL_WEIGHT;
 	if ((tx_desc->gbec_status == DSC_INIT16) && (unused < thresh))
 	{  /* current marked clean, tx queue filling up, do extra clean */
 		int j, k;
@@ -1482,13 +1480,13 @@ pch_gbe_clean_tx(struct pch_gbe_adapter *adapter,
 
 		/* current marked clean, scan for more that need cleaning. */
 		k = i;
-		for (j = 0; j < PCH_GBE_TX_WEIGHT; j++)
+		for (j = 0; j < NAPI_POLL_WEIGHT; j++)
 		{
 			tx_desc = PCH_GBE_TX_DESC(*tx_ring, k);
 			if (tx_desc->gbec_status != DSC_INIT16) break; /*found*/
 			if (++k >= tx_ring->count) k = 0;  /*increment, wrap*/
 		}
-		if (j < PCH_GBE_TX_WEIGHT) {
+		if (j < NAPI_POLL_WEIGHT) {
 			netdev_dbg(adapter->netdev,
 				   "clean_tx: unused=%d loops=%d found tx_desc[%x,%x:%x].gbec_status=%04x\n",
 				   unused, j, i, k, tx_ring->next_to_use,
@@ -1547,7 +1545,7 @@ pch_gbe_clean_tx(struct pch_gbe_adapter *adapter,
 		tx_desc = PCH_GBE_TX_DESC(*tx_ring, i);
 
 		/* weight of a sort for tx, to avoid endless transmit cleanup */
-		if (cleaned_count++ == PCH_GBE_TX_WEIGHT) {
+		if (cleaned_count++ == NAPI_POLL_WEIGHT) {
 			cleaned = false;
 			break;
 		}
@@ -2519,7 +2517,7 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 	netdev->netdev_ops = &pch_gbe_netdev_ops;
 	netdev->watchdog_timeo = PCH_GBE_WATCHDOG_PERIOD;
 	netif_napi_add(netdev, &adapter->napi,
-		       pch_gbe_napi_poll, PCH_GBE_RX_WEIGHT);
+		       pch_gbe_napi_poll, NAPI_POLL_WEIGHT);
 	netdev->hw_features = NETIF_F_RXCSUM |
 		NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
 	netdev->features = netdev->hw_features;
-- 
2.34.1


^ permalink raw reply related

* [PATCH net-next 08/14] eth: bgnet: remove a copy of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:41 UTC (permalink / raw)
  To: davem, pabeni; +Cc: netdev, Jakub Kicinski, rafal, bcm-kernel-feedback-list
In-Reply-To: <20220427154111.529975-1-kuba@kernel.org>

Defining local versions of NAPI_POLL_WEIGHT with the same
values in the drivers just makes refactoring harder.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: rafal@milecki.pl
CC: bcm-kernel-feedback-list@broadcom.com
---
 drivers/net/ethernet/broadcom/bgmac.c | 2 +-
 drivers/net/ethernet/broadcom/bgmac.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 7b525c65bacb..2dfc1e32bbb3 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1527,7 +1527,7 @@ int bgmac_enet_probe(struct bgmac *bgmac)
 	if (bcm47xx_nvram_getenv("et0_no_txint", NULL, 0) == 0)
 		bgmac->int_mask &= ~BGMAC_IS_TX_MASK;
 
-	netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
+	netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, NAPI_POLL_WEIGHT);
 
 	err = bgmac_phy_connect(bgmac);
 	if (err) {
diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h
index 110088e662ea..e05ac92c0650 100644
--- a/drivers/net/ethernet/broadcom/bgmac.h
+++ b/drivers/net/ethernet/broadcom/bgmac.h
@@ -364,8 +364,6 @@
 #define BGMAC_CHIPCTL_7_IF_TYPE_MII		0x00000040
 #define BGMAC_CHIPCTL_7_IF_TYPE_RGMII		0x00000080
 
-#define BGMAC_WEIGHT	64
-
 #define ETHER_MAX_LEN	(ETH_FRAME_LEN + ETH_FCS_LEN)
 
 /* Feature Flags */
-- 
2.34.1


^ permalink raw reply related

* [PATCH net-next 10/14] eth: benet: remove a copy of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:41 UTC (permalink / raw)
  To: davem, pabeni
  Cc: netdev, Jakub Kicinski, ajit.khaparde, sriharsha.basavapatna,
	somnath.kotur
In-Reply-To: <20220427154111.529975-1-kuba@kernel.org>

Defining local versions of NAPI_POLL_WEIGHT with the same
values in the drivers just makes refactoring harder.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: ajit.khaparde@broadcom.com
CC: sriharsha.basavapatna@broadcom.com
CC: somnath.kotur@broadcom.com
---
 drivers/net/ethernet/emulex/benet/be.h      | 3 +--
 drivers/net/ethernet/emulex/benet/be_main.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index 8689d4a51fe5..61fe9625bed1 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -101,8 +101,7 @@
 #define MAX_ROCE_EQS		5
 #define MAX_MSIX_VECTORS	32
 #define MIN_MSIX_VECTORS	1
-#define BE_NAPI_WEIGHT		64
-#define MAX_RX_POST		BE_NAPI_WEIGHT /* Frags posted at a time */
+#define MAX_RX_POST		NAPI_POLL_WEIGHT /* Frags posted at a time */
 #define RX_FRAGS_REFILL_WM	(RX_Q_LEN - MAX_RX_POST)
 #define MAX_NUM_POST_ERX_DB	255u
 
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index d0c262f2695a..5939068a8f62 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2983,7 +2983,7 @@ static int be_evt_queues_create(struct be_adapter *adapter)
 		cpumask_set_cpu(cpumask_local_spread(i, numa_node),
 				eqo->affinity_mask);
 		netif_napi_add(adapter->netdev, &eqo->napi, be_poll,
-			       BE_NAPI_WEIGHT);
+			       NAPI_POLL_WEIGHT);
 	}
 	return 0;
 }
-- 
2.34.1


^ permalink raw reply related

* [PATCH net-next 03/14] eth: cpsw: remove a copy of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:41 UTC (permalink / raw)
  To: davem, pabeni
  Cc: netdev, Jakub Kicinski, grygorii.strashko, chi.minghao,
	vladimir.oltean, toke, chenhao288, moyufeng, linux-omap
In-Reply-To: <20220427154111.529975-1-kuba@kernel.org>

Defining local versions of NAPI_POLL_WEIGHT with the same
values in the drivers just makes refactoring harder.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: grygorii.strashko@ti.com
CC: chi.minghao@zte.com.cn
CC: vladimir.oltean@nxp.com
CC: toke@redhat.com
CC: chenhao288@hisilicon.com
CC: moyufeng@huawei.com
CC: linux-omap@vger.kernel.org
---
 drivers/net/ethernet/ti/cpsw.c      |  4 ++--
 drivers/net/ethernet/ti/cpsw_new.c  |  4 ++--
 drivers/net/ethernet/ti/cpsw_priv.c | 12 ++++++------
 drivers/net/ethernet/ti/cpsw_priv.h |  1 -
 4 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index e6ad2e53f1cd..662435e36805 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1639,10 +1639,10 @@ static int cpsw_probe(struct platform_device *pdev)
 	ndev->ethtool_ops = &cpsw_ethtool_ops;
 	netif_napi_add(ndev, &cpsw->napi_rx,
 		       cpsw->quirk_irq ? cpsw_rx_poll : cpsw_rx_mq_poll,
-		       CPSW_POLL_WEIGHT);
+		       NAPI_POLL_WEIGHT);
 	netif_tx_napi_add(ndev, &cpsw->napi_tx,
 			  cpsw->quirk_irq ? cpsw_tx_poll : cpsw_tx_mq_poll,
-			  CPSW_POLL_WEIGHT);
+			  NAPI_POLL_WEIGHT);
 
 	/* register the network device */
 	SET_NETDEV_DEV(ndev, dev);
diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c
index 0f31cb4168bb..b33781ed760e 100644
--- a/drivers/net/ethernet/ti/cpsw_new.c
+++ b/drivers/net/ethernet/ti/cpsw_new.c
@@ -1416,11 +1416,11 @@ static int cpsw_create_ports(struct cpsw_common *cpsw)
 			netif_napi_add(ndev, &cpsw->napi_rx,
 				       cpsw->quirk_irq ?
 				       cpsw_rx_poll : cpsw_rx_mq_poll,
-				       CPSW_POLL_WEIGHT);
+				       NAPI_POLL_WEIGHT);
 			netif_tx_napi_add(ndev, &cpsw->napi_tx,
 					  cpsw->quirk_irq ?
 					  cpsw_tx_poll : cpsw_tx_mq_poll,
-					  CPSW_POLL_WEIGHT);
+					  NAPI_POLL_WEIGHT);
 		}
 
 		napi_ndev = ndev;
diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c
index 887285c57db8..758295c898ac 100644
--- a/drivers/net/ethernet/ti/cpsw_priv.c
+++ b/drivers/net/ethernet/ti/cpsw_priv.c
@@ -364,7 +364,7 @@ void cpsw_split_res(struct cpsw_common *cpsw)
 	if (cpsw->tx_ch_num == rlim_ch_num) {
 		max_rate = consumed_rate;
 	} else if (!rlim_ch_num) {
-		ch_budget = CPSW_POLL_WEIGHT / cpsw->tx_ch_num;
+		ch_budget = NAPI_POLL_WEIGHT / cpsw->tx_ch_num;
 		bigest_rate = 0;
 		max_rate = consumed_rate;
 	} else {
@@ -379,19 +379,19 @@ void cpsw_split_res(struct cpsw_common *cpsw)
 		if (max_rate < consumed_rate)
 			max_rate *= 10;
 
-		ch_budget = (consumed_rate * CPSW_POLL_WEIGHT) / max_rate;
-		ch_budget = (CPSW_POLL_WEIGHT - ch_budget) /
+		ch_budget = (consumed_rate * NAPI_POLL_WEIGHT) / max_rate;
+		ch_budget = (NAPI_POLL_WEIGHT - ch_budget) /
 			    (cpsw->tx_ch_num - rlim_ch_num);
 		bigest_rate = (max_rate - consumed_rate) /
 			      (cpsw->tx_ch_num - rlim_ch_num);
 	}
 
 	/* split tx weight/budget */
-	budget = CPSW_POLL_WEIGHT;
+	budget = NAPI_POLL_WEIGHT;
 	for (i = 0; i < cpsw->tx_ch_num; i++) {
 		ch_rate = cpdma_chan_get_rate(txv[i].ch);
 		if (ch_rate) {
-			txv[i].budget = (ch_rate * CPSW_POLL_WEIGHT) / max_rate;
+			txv[i].budget = (ch_rate * NAPI_POLL_WEIGHT) / max_rate;
 			if (!txv[i].budget)
 				txv[i].budget++;
 			if (ch_rate > bigest_rate) {
@@ -417,7 +417,7 @@ void cpsw_split_res(struct cpsw_common *cpsw)
 		txv[bigest_rate_ch].budget += budget;
 
 	/* split rx budget */
-	budget = CPSW_POLL_WEIGHT;
+	budget = NAPI_POLL_WEIGHT;
 	ch_budget = budget / cpsw->rx_ch_num;
 	for (i = 0; i < cpsw->rx_ch_num; i++) {
 		cpsw->rxv[i].budget = ch_budget;
diff --git a/drivers/net/ethernet/ti/cpsw_priv.h b/drivers/net/ethernet/ti/cpsw_priv.h
index fc591f5ebe18..34230145ca0b 100644
--- a/drivers/net/ethernet/ti/cpsw_priv.h
+++ b/drivers/net/ethernet/ti/cpsw_priv.h
@@ -89,7 +89,6 @@ do {								\
 #define CPDMA_TXCP		0x40
 #define CPDMA_RXCP		0x60
 
-#define CPSW_POLL_WEIGHT	64
 #define CPSW_RX_VLAN_ENCAP_HDR_SIZE		4
 #define CPSW_MIN_PACKET_SIZE_VLAN	(VLAN_ETH_ZLEN)
 #define CPSW_MIN_PACKET_SIZE	(ETH_ZLEN)
-- 
2.34.1


^ permalink raw reply related

* [PATCH net-next 05/14] eth: mtk_eth_soc: remove a copy of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:41 UTC (permalink / raw)
  To: davem, pabeni
  Cc: netdev, Jakub Kicinski, nbd, john, sean.wang, Mark-MC.Lee,
	matthias.bgg, linux-arm-kernel, linux-mediatek
In-Reply-To: <20220427154111.529975-1-kuba@kernel.org>

Defining local versions of NAPI_POLL_WEIGHT with the same
values in the drivers just makes refactoring harder.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: nbd@nbd.name
CC: john@phrozen.org
CC: sean.wang@mediatek.com
CC: Mark-MC.Lee@mediatek.com
CC: matthias.bgg@gmail.com
CC: linux-arm-kernel@lists.infradead.org
CC: linux-mediatek@lists.infradead.org
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++--
 drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 18eebcaa6a76..31c5da5d6b72 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -3298,9 +3298,9 @@ static int mtk_probe(struct platform_device *pdev)
 	 */
 	init_dummy_netdev(&eth->dummy_dev);
 	netif_napi_add(&eth->dummy_dev, &eth->tx_napi, mtk_napi_tx,
-		       MTK_NAPI_WEIGHT);
+		       NAPI_POLL_WEIGHT);
 	netif_napi_add(&eth->dummy_dev, &eth->rx_napi, mtk_napi_rx,
-		       MTK_NAPI_WEIGHT);
+		       NAPI_POLL_WEIGHT);
 
 	platform_set_drvdata(pdev, eth);
 
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index c98c7ee42c6f..b04977fa84f6 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -24,7 +24,6 @@
 #define MTK_MAX_RX_LENGTH_2K	2048
 #define MTK_TX_DMA_BUF_LEN	0x3fff
 #define MTK_DMA_SIZE		512
-#define MTK_NAPI_WEIGHT		64
 #define MTK_MAC_COUNT		2
 #define MTK_RX_ETH_HLEN		(ETH_HLEN + ETH_FCS_LEN)
 #define MTK_RX_HLEN		(NET_SKB_PAD + MTK_RX_ETH_HLEN + NET_IP_ALIGN)
-- 
2.34.1


^ permalink raw reply related

* [PATCH net-next 06/14] usb: lan78xx: remove a copy of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:41 UTC (permalink / raw)
  To: davem, pabeni
  Cc: netdev, Jakub Kicinski, woojung.huh, UNGLinuxDriver, linux-usb
In-Reply-To: <20220427154111.529975-1-kuba@kernel.org>

Defining local versions of NAPI_POLL_WEIGHT with the same
values in the drivers just makes refactoring harder.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: woojung.huh@microchip.com
CC: UNGLinuxDriver@microchip.com
CC: linux-usb@vger.kernel.org
---
 drivers/net/usb/lan78xx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 415f16662f88..94e571fb61da 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -92,8 +92,6 @@
 					 WAKE_MCAST | WAKE_BCAST | \
 					 WAKE_ARP | WAKE_MAGIC)
 
-#define LAN78XX_NAPI_WEIGHT		64
-
 #define TX_URB_NUM			10
 #define TX_SS_URB_NUM			TX_URB_NUM
 #define TX_HS_URB_NUM			TX_URB_NUM
@@ -4376,7 +4374,7 @@ static int lan78xx_probe(struct usb_interface *intf,
 
 	netif_set_gso_max_size(netdev, LAN78XX_TSO_SIZE(dev));
 
-	netif_napi_add(netdev, &dev->napi, lan78xx_poll, LAN78XX_NAPI_WEIGHT);
+	netif_napi_add(netdev, &dev->napi, lan78xx_poll, NAPI_POLL_WEIGHT);
 
 	INIT_DELAYED_WORK(&dev->wq, lan78xx_delayedwork);
 	init_usb_anchor(&dev->deferred);
-- 
2.34.1


^ permalink raw reply related

* [PATCH net-next 11/14] eth: gfar: remove a copy of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:41 UTC (permalink / raw)
  To: davem, pabeni; +Cc: netdev, Jakub Kicinski, claudiu.manoil
In-Reply-To: <20220427154111.529975-1-kuba@kernel.org>

Defining local versions of NAPI_POLL_WEIGHT with the same
values in the drivers just makes refactoring harder.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: claudiu.manoil@nxp.com
---
 drivers/net/ethernet/freescale/gianfar.c | 2 +-
 drivers/net/ethernet/freescale/gianfar.h | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 206b7a35eaf5..f0b652a65043 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -3232,7 +3232,7 @@ static int gfar_probe(struct platform_device *ofdev)
 	/* Register for napi ...We are registering NAPI for each grp */
 	for (i = 0; i < priv->num_grps; i++) {
 		netif_napi_add(dev, &priv->gfargrp[i].napi_rx,
-			       gfar_poll_rx_sq, GFAR_DEV_WEIGHT);
+			       gfar_poll_rx_sq, NAPI_POLL_WEIGHT);
 		netif_tx_napi_add(dev, &priv->gfargrp[i].napi_tx,
 				  gfar_poll_tx_sq, 2);
 	}
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
index ca5e14f908fe..68b59d3202e3 100644
--- a/drivers/net/ethernet/freescale/gianfar.h
+++ b/drivers/net/ethernet/freescale/gianfar.h
@@ -52,9 +52,6 @@ struct ethtool_rx_list {
 	unsigned int count;
 };
 
-/* The maximum number of packets to be handled in one call of gfar_poll */
-#define GFAR_DEV_WEIGHT 64
-
 /* Length for FCB */
 #define GMAC_FCB_LEN 8
 
-- 
2.34.1


^ permalink raw reply related

* [PATCH net-next 00/14] remove copies of the NAPI_POLL_WEIGHT define
From: Jakub Kicinski @ 2022-04-27 15:40 UTC (permalink / raw)
  To: davem, pabeni; +Cc: netdev, Jakub Kicinski

netif_napi_add() takes weight as the last argument. The value of
that parameter is hard to come up with and depends on many factors,
so driver authors are encouraged to use NAPI_POLL_WEIGHT.

We should probably move weight to an "advanced" version of the API
(__netif_napi_add()?) and simplify the life of most driver authors.

In preparation for such API changes this series removes local
defines equivalent to NAPI_POLL_WEIGHT from drivers, so that a simple
coccinelle / spatch script does not get thrown off by them.

Jakub Kicinski (14):
  eth: remove copies of the NAPI_POLL_WEIGHT define
  eth: remove NAPI_WEIGHT defines
  eth: cpsw: remove a copy of the NAPI_POLL_WEIGHT define
  eth: pch_gbe: remove a copy of the NAPI_POLL_WEIGHT define
  eth: mtk_eth_soc: remove a copy of the NAPI_POLL_WEIGHT define
  usb: lan78xx: remove a copy of the NAPI_POLL_WEIGHT define
  slic: remove a copy of the NAPI_POLL_WEIGHT define
  eth: bgnet: remove a copy of the NAPI_POLL_WEIGHT define
  eth: atlantic: remove a copy of the NAPI_POLL_WEIGHT define
  eth: benet: remove a copy of the NAPI_POLL_WEIGHT define
  eth: gfar: remove a copy of the NAPI_POLL_WEIGHT define
  eth: vxge: remove a copy of the NAPI_POLL_WEIGHT define
  eth: spider: remove a copy of the NAPI_POLL_WEIGHT define
  eth: velocity: remove a copy of the NAPI_POLL_WEIGHT define

 drivers/net/ethernet/alacritech/slic.h               |  2 --
 drivers/net/ethernet/alacritech/slicoss.c            |  2 +-
 drivers/net/ethernet/aquantia/atlantic/aq_cfg.h      |  2 --
 drivers/net/ethernet/aquantia/atlantic/aq_ptp.c      |  2 +-
 drivers/net/ethernet/aquantia/atlantic/aq_vec.c      |  2 +-
 drivers/net/ethernet/broadcom/bgmac.c                |  2 +-
 drivers/net/ethernet/broadcom/bgmac.h                |  2 --
 drivers/net/ethernet/cortina/gemini.c                |  4 +---
 drivers/net/ethernet/emulex/benet/be.h               |  3 +--
 drivers/net/ethernet/emulex/benet/be_main.c          |  2 +-
 drivers/net/ethernet/freescale/gianfar.c             |  2 +-
 drivers/net/ethernet/freescale/gianfar.h             |  3 ---
 drivers/net/ethernet/marvell/skge.c                  |  3 +--
 drivers/net/ethernet/marvell/sky2.c                  |  3 +--
 drivers/net/ethernet/mediatek/mtk_eth_soc.c          |  4 ++--
 drivers/net/ethernet/mediatek/mtk_eth_soc.h          |  1 -
 drivers/net/ethernet/mediatek/mtk_star_emac.c        |  3 +--
 drivers/net/ethernet/neterion/vxge/vxge-main.c       |  2 +-
 drivers/net/ethernet/neterion/vxge/vxge-main.h       |  2 --
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 12 +++++-------
 drivers/net/ethernet/smsc/smsc9420.c                 |  2 +-
 drivers/net/ethernet/smsc/smsc9420.h                 |  1 -
 drivers/net/ethernet/ti/cpsw.c                       |  4 ++--
 drivers/net/ethernet/ti/cpsw_new.c                   |  4 ++--
 drivers/net/ethernet/ti/cpsw_priv.c                  | 12 ++++++------
 drivers/net/ethernet/ti/cpsw_priv.h                  |  1 -
 drivers/net/ethernet/ti/davinci_emac.c               |  3 +--
 drivers/net/ethernet/ti/netcp_core.c                 |  5 ++---
 drivers/net/ethernet/toshiba/spider_net.c            |  2 +-
 drivers/net/ethernet/toshiba/spider_net.h            |  1 -
 drivers/net/ethernet/via/via-velocity.c              |  3 +--
 drivers/net/ethernet/via/via-velocity.h              |  1 -
 drivers/net/usb/lan78xx.c                            |  4 +---
 drivers/net/xen-netback/interface.c                  |  3 +--
 drivers/staging/unisys/visornic/visornic_main.c      |  4 ++--
 35 files changed, 39 insertions(+), 69 deletions(-)

-- 
2.34.1


^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox