Intel-wired-lan Digest, Vol 411, Issue 1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Jakub,
Thanks for the feedback. Replied inline.
Quoted 385 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of [email protected]
Sent: Tuesday, 21 February, 2023 6:56 AM
To: [email protected]
Subject: Intel-wired-lan Digest, Vol 411, Issue 1Send Intel-wired-lan mailing list submissions to
[email protected]To subscribe or unsubscribe via the World Wide Web, visit
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
or, via email, send a message with subject or body 'help' to
[email protected]You can reach the person managing the list at
[email protected]When replying, please edit your Subject line so it is more specific than "Re:
Contents of Intel-wired-lan digest..."Today's Topics:
1. Re: [PATCH bpf-next V2] igc: enable and fix RX hash usage by netstack (Jesper Dangaard Brouer)
2. Re: [PATCH bpf-next V1] igc: enable and fix RX hash usage by netstack (Alexander Lobakin)
3. Re: [PATCH net-next v1] igc: Add transmission overrun counter (Jakub Kicinski)----------------------------------------------------------------------
Message: 1
Date: Sat, 18 Feb 2023 20:51:40 +0100
From: Jesper Dangaard Brouer <[email protected]>
To: Daniel Borkmann <[email protected]>, [email protected]
Cc: [email protected], [email protected], Stanislav Fomichev
<[email protected]>, [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], Jakub Kicinski <[email protected]>, [email protected], Jakub
Kicinski
<[email protected]>, "David S. Miller" <[email protected]>, Eric Dumazet <[email protected]>, Paolo Abeni
<[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH bpf-next V2] igc: enable and fix
RX hash usage by netstack
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowedQuoted 12 lines · Daniel Borkmann
Quoted 11 lines · Jesper Dangaard Brouer
When function
igc_rx_hash()was introduced in v4.20 via commit0507ef8a0372
("igc: Add transmit and receive fastpath and interrupt handlers"), the hardware wasn't configured to provide RSS hash, thus it made sense to not enablenet_deviceNETIF_F_RXHASHfeature bit.The NIC hardware was configured to enable RSS hash info in v5.2 via commit
2121c2712f82("igc: Add multiple receive queues control supporting"), but forgot to set theNETIF_F_RXHASHfeature bit.Quoted 5 lines
Quoted 5 lines
The original implementation of
igc_rx_hash()didn't extract the associatedpkt_hash_type, but statically setPKT_HASH_TYPE_L3. The largest portions of this patch are about extracting the RSS Type from the hardware and mapping this to enumpkt_hash_types. This was based on Foxville i225 software user manual rev-1.3.1 and tested on IntelEthernet Controller I225-LM (rev 03).
Quoted 8 lines
Quoted 8 lines
For UDP it's worth noting that RSS (type) hashing have been disabled both for
IPv4 and IPv6 (seeIGC_MRQC_RSS_FIELD_IPV4_UDP+IGC_MRQC_RSS_FIELD_IPV6_UDP) because hardware RSS doesn't handle fragmented pkts well when enabled (can cause out-of-order). This results inPKT_HASH_TYPE_L3for UDP packets, and hash value doesn't include UDP port numbers. Not beingPKT_HASH_TYPE_L4, have theeffect
Quoted 2 lines
Quoted 2 lines
that netstack will do a software based hash calc calling into
flow_dissect, but only when code callsskb_get_hash(), which doesn'tnecessary happen for local delivery.
Quoted 7 lines
Quoted 4 lines
Fixes 2121c2712f82 ("igc: Add multiple receive queues controlsupporting")
Signed-off-by Jesper Dangaard Brouer <[email protected]>I presume this should go via net-next, not bpf-next? (Didn't find specific dependencies, so moved to patchwork netdev bucket..)
Thanks for letting me/us know.
I posted against bpf-next, because I have patches (for kfunc XDP-hints) that depend on this patch. As we are at rc8, netdev maintainers feel free to simply drop the patch as the patch isn't critical. I will just include this patch as part of my kfunc XDP-hints series later.
--Jesper
------------------------------
Message: 2
Date: Mon, 20 Feb 2023 16:39:52 +0100
From: Alexander Lobakin <[email protected]>
To: Jesper Dangaard Brouer <[email protected]>
Cc: <[email protected]>, <[email protected]>,<[email protected]>, Stanislav Fomichev <[email protected]>, <[email protected]>, <[email protected]>,<[email protected]>,
<[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH bpf-next V1] igc: enable and fix
RX hash usage by netstack
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"From: Jesper Dangaard Brouer <[email protected]>
Date: Thu, 16 Feb 2023 17:46:53 +0100Quoted 11 lines · Alexander Lobakin
Quoted 9 lines
From: Jesper Dangaard Brouer <[email protected]>
Date: Fri, 10 Feb 2023 16:07:59 +0100Quoted 5 lines
When function
igc_rx_hash()was introduced in v4.20 via commit0507ef8a0372
("igc: Add transmit and receive fastpath and interrupt handlers"), the hardware wasn't configured to provide RSS hash, thus it made sense to not enablenet_deviceNETIF_F_RXHASHfeature bit.Quoted 5 lines
Quoted 5 lines
[...]
Quoted 3 lines
(quoted diff) +0
-0@@ -311,6 +311,58 @@ extern char igc_driver_name[]; ? #define
IGC_MRQC_RSS_FIELD_IPV4_UDP???0x00400000? #defineIGC_MRQC_RSS_FIELD_IPV6_UDP???0x00800000? +/* RX-desc Write-Back
Quoted 6 lines
Quoted 6 lines
Review
Quoted 6 lines
format RSS Type's */
(quoted diff) +5
-0+enum igc_rss_type_num { +??? IGC_RSS_TYPE_NO_HASH??????? = 0, ??? +IGC_RSS_TYPE_HASH_TCP_IPV4??? = 1, ??? +IGC_RSS_TYPE_HASH_IPV4??????? = 2, ??? +IGC_RSS_TYPE_HASH_TCP_IPV6??? = 3, ???
IGC_RSS_TYPE_HASH_IPV6_EX???Quoted 5 lines
Quoted 5 lines
Review
Quoted 5 lines
+= 4, ???
IGC_RSS_TYPE_HASH_IPV6??????? = 5, ???(quoted diff) +4
-0+IGC_RSS_TYPE_HASH_TCP_IPV6_EX??? = 6, ??? +IGC_RSS_TYPE_HASH_UDP_IPV4??? = 7, ??? +IGC_RSS_TYPE_HASH_UDP_IPV6??? = 8, ??? +IGC_RSS_TYPE_HASH_UDP_IPV6_EX??? = 9, ???
IGC_RSS_TYPE_MAX??????? =Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
+10, }; #define
IGC_RSS_TYPE_MAX_TABLE??????? 16 #define +IGC_RSS_TYPE_MASK???????0xF
GENMASK()?hmm...
GENMASK(3,0)looks more confusing to me. The mask we needhere
Quoted 23 lines
is so simple that I prefer not to complicate this with GENMASK.
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ +/* igc_rss_type - Rx descriptor RSS type field */ static inline u8 +igc_rss_type(union igc_adv_rx_desc *rx_desc)Why use types shorter than u32 on the stack?
Changing to u32 in V2
Quoted 1 line
Why this union is not const here, since there are no modifications?
Sure
Quoted 8 lines
Quoted 4 lines
(quoted diff) +3
-0+{ +??? /* RSS Type 4-bit number: 0-9 (above 9 is reserved) */ ??? +return rx_desc->wb.lower.lo_dword.hs_rss.pkt_info &
IGC_RSS_TYPE_MASK;The most important I wanted to mention: doesn't this function make the CPU read the uncached field again, while you could just read it once onto the stack and then extract all such data from there?
Quoted 3 lines
I really don't think this is an issues here. The
igc_adv_rx_descis only
16 bytes and it should be hot in CPU cache by now.Rx descriptors are located in the DMA coherent zone (allocated via
dma_alloc_coherent()), I am missing something? Because I was (I am) sure CPU doesn't cache anything from it (and doesn't reorder reads/writes from/to). I thought that's the point of coherent zones -- you may talk to hardware without needing for syncing...Quoted 19 lines
To avoid the movzx I have changed this to do a u32 read instead.
Quoted 8 lines
Quoted 8 lines
(quoted diff) +4
-0+} + +/* Packet header type identified by hardware (when BIT(11) is zero). + * Even when UDP ports are not part of RSS hash HW still parse andmark UDP bits
+ */
+enumigc_pkt_type_bits{
+???IGC_PKT_TYPE_HDR_IPV4??? =??? BIT(0), ???Quoted 8 lines
Review
Quoted 8 lines
+IGC_PKT_TYPE_HDR_IPV4_WITH_OPT=??? BIT(1), /* IPv4 Hdr includes IP options */
+???IGC_PKT_TYPE_HDR_IPV6??? =??? BIT(2), ??? +IGC_PKT_TYPE_HDR_IPV6_WITH_EXT=??? BIT(3), /* IPv6 Hdr includes extensions */
+???IGC_PKT_TYPE_HDR_L4_TCP??? =??? BIT(4), ???(quoted diff) +2
-0+IGC_PKT_TYPE_HDR_L4_UDP??? =??? BIT(5), ??? +IGC_PKT_TYPE_HDR_L4_SCTP=??? BIT(6), ???
IGC_PKT_TYPE_HDR_NFS???Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+=??? BIT(7), ??? /* Above only valid when BIT(11) is zero */ ??? +IGC_PKT_TYPE_L2??????? =??? BIT(11), ???
IGC_PKT_TYPE_VLAN???=???
Quoted 21 lines
Quoted 3 lines
Quoted 1 line
+BIT(12), ???
IGC_PKT_TYPE_MASK??? =???0x1FFF, /* 13-bits */Also
GENMASK().GENMASK would make more sense here.
Quoted 7 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+}; + +/* igc_pkt_type - Rx descriptor Packet type field */ static inline +u16 igc_pkt_type(union igc_adv_rx_desc *rx_desc)Also short types and consts.
Fixed in V2
Quoted 5 lines
Quoted 4 lines
+{
+??? u32 data =le32_to_cpu(rx_desc->wb.lower.lo_dword.data); +??? /* Packet type is 13-bits - as bits (16:4) in lower.lo_dword*/ +??? u16pkt_type= (data >> 4) &IGC_PKT_TYPE_MASK;Quoted 4 lines
Quoted 1 line
Perfect candidate for
FIELD_GET(). No, even forle32_get_bits().I adjusted this, but I could not find a central define for
FIELD_GET(but many drivers open code this).<
linux/bitfield.h>. It has FIELD_{GET,PREP}() and also builds {u,__le,__be}{8,16,32}_{encode,get,replace}_bits() via macro (the latter doesn't get indexed by Elixir, as it doesn't parse functions built via macros).Quoted 24 lines
Quoted 24 lines
Also my note above about excessive expensive reads.
Quoted 15 lines
(quoted diff) +4
-0+ +??? return pkt_type; +} +? /* Interrupt defines */
? #defineIGC_START_ITR??????????? 648 /* ~6000 ints/sec */ ? #defineIGC_4K_ITR??????????? 980 diff --gita/drivers/net/ethernet/intel/igc/igc_main.cb/drivers/net/ethernet/intel/igc/igc_main.c
index8b572cd2c350..42a072509d2a100644drivers/net/ethernet/intel/igc/igc_main.c +0
-0@@ -1677,14 +1677,40 @@ static void igc_rx_checksum(struct igc_ring *ring, ???????????? le32_to_cpu(rx_desc->wb.upper.status_error)); ? }Quoted 3 lines
? +/* Mapping HW RSS Type to enum
pkt_hash_types*/ +structigc_rss_type{
+??? u8hash_type; /* can contain enumpkt_hash_types*/Why make a struct for one field? + short type note
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+} igc_rss_type_table[IGC_RSS_TYPE_MAX_TABLE] = { ??? +[IGC_RSS_TYPE_NO_HASH].hash_type????? =
PKT_HASH_TYPE_L2,???
Quoted 1 line
Quoted 1 line
Quoted 1 line
+[IGC_RSS_TYPE_HASH_TCP_IPV4].hash_type????? =
PKT_HASH_TYPE_L4, ???Quoted 1 line
Quoted 1 line
Quoted 1 line
+[IGC_RSS_TYPE_HASH_IPV4].hash_type????? =
PKT_HASH_TYPE_L3,???
Quoted 1 line
Quoted 1 line
Quoted 1 line
+[IGC_RSS_TYPE_HASH_TCP_IPV6].hash_type????? =
PKT_HASH_TYPE_L4, ???Quoted 1 line
Quoted 1 line
Quoted 1 line
+[IGC_RSS_TYPE_HASH_IPV6_EX].hash_type????? =
PKT_HASH_TYPE_L3, ???Quoted 1 line
Quoted 1 line
Quoted 1 line
+[IGC_RSS_TYPE_HASH_IPV6].hash_type????? =
PKT_HASH_TYPE_L3,???
Quoted 1 line
Quoted 1 line
Quoted 1 line
+[IGC_RSS_TYPE_HASH_TCP_IPV6_EX].hash_type =
PKT_HASH_TYPE_L4, ???Quoted 1 line
Quoted 1 line
Quoted 1 line
+[IGC_RSS_TYPE_HASH_UDP_IPV4].hash_type????? =
PKT_HASH_TYPE_L4, ???Quoted 1 line
Quoted 1 line
Quoted 1 line
+[IGC_RSS_TYPE_HASH_UDP_IPV6].hash_type????? =
PKT_HASH_TYPE_L4, ???Quoted 1 line
Quoted 1 line
Quoted 1 line
+[IGC_RSS_TYPE_HASH_UDP_IPV6_EX].hash_type =
PKT_HASH_TYPE_L4, ???Quoted 10 lines
Quoted 9 lines
drivers/net/ethernet/intel/igc/igc_main.c
Quoted 6 lines
+[10].hash_type =
PKT_HASH_TYPE_L2, /* RSS Type above 9 "Reserved" by HW */
+??? [11].hash_type =PKT_HASH_TYPE_L2, ??? [12].hash_type =drivers/net/ethernet/intel/igc/igc_main.c +3
-0+PKT_HASH_TYPE_L2, ??? [13].hash_type = PKT_HASH_TYPE_L2, ??? +[14].hash_type = PKT_HASH_TYPE_L2, ??? [15].hash_type = +PKT_HASH_TYPE_L2,Why define those empty if you could do a bound check in the code instead? E.g.
if (unlikely(bigger_than_9)) return PKT_HASH_TYPE_L2.Quoted 2 lines
Having a branch for this is likely slower.? On godbolt I see that this generates suboptimal and larger code.
But you have to verify HW output anyway, right? Or would like to rely on that on some weird revision it won't spit BIT(69) on you?
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_main.c +2
-0+}; +? static inline void igc_rx_hash(struct
igc_ring*ring, ???????????????????? unionigc_adv_rx_desc*rx_desc, ???????????????????? structsk_buff*skb) ? { -??? if (ring->netdev->features&NETIF_F_RXHASH) -???????skb_set_hash(skb,
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
-????????????????
le32_to_cpu(rx_desc->wb.lower.hi_dword.rss), -????????????????PKT_HASH_TYPE_L3);
+??? if (ring->netdev->features&NETIF_F_RXHASH) {????if (!(feature & HASH))
??????? return;and -1 indent level?
Usually, yes, I also prefer early return style code. For one I just followed the existing style.
I'd not recommend "keep the existing style" of Intel drivers -- not something I'd like to keep as is :D
Quoted 19 lines
Second, I tried to code it up, but it looks ugly in this case, as the variable defines need to get moved outside the if statement.
Quoted 1 line
Quoted 1 line
+??????? u32
rss_hash= le32_to_cpu(rx_desc-wb.lower.hi_dword.rss);
Quoted 12 lines
Quoted 6 lines
+??????? u8?
rss_type=igc_rss_type(rx_desc); ??????? enumdrivers/net/ethernet/intel/igc/igc_main.c +4
-0+pkt_hash_types hash_type; + +??????? hash_type = igc_rss_type_table[rss_type].hash_type; +??????? skb_set_hash(skb, rss_hash, hash_type); ??? }? }
[...]
Thanks,
OlekThanks,
Olek------------------------------
Message: 3
Date: Mon, 20 Feb 2023 14:20:17 -0800
From: Jakub Kicinski <[email protected]>
To: "Zulkifli, Muhammad Husaini" <[email protected]>
Cc: "Nguyen, Anthony L" <[email protected]>,
"[email protected]" <[email protected]>,
"Gomes,
Vinicius" <[email protected]>, "Neftin, Sasha" <[email protected]>, "[email protected]" <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net-next v1] igc: Add
transmission overrun counter
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCIIQuoted 3 lines · Muhammad Husaini
Hi Jakub and Vinicius,
I would appreciate any early feedback or thoughts on this patch
submission.
Quoted 3 lines
History of the discussion:
https://lore.kernel.org/intel-wired-
Quoted 9 lines
lan/SJ1PR11MB6180D0D59EB01AD1E8FE4
Quoted 1 line
[email protected]/T/#r8db595a7b40 067d23
Quoted 1 line
15def91d41c9695454d6c9fTony asks very good questions. Driver specific counter always reported as 0 would be odd for Linux. The counter is of no practical importance.
I understand your concern. The counter will currently always report a value of zero. If we removed the strict end bit in the future, this counter might increase. We must somehow create a new counter statistics that the equipment can use for a certain test scenario. That is the reason I didn't try to update any code on the network stack(ethtool) and instead simply changed the driver code.
Quoted 10 lines
------------------------------
Subject: Digest Footer
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Quoted 4 lines
------------------------------
End of Intel-wired-lan Digest, Vol 411, Issue 1
***********************************************
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan