* [PATCH net-next 1/5] igc: Use reverse xmas tree
2023-11-28 7:48 [PATCH net-next 0/5] igc: ethtool: Check VLAN TCI mask Kurt Kanzenbach
@ 2023-11-28 7:48 ` Kurt Kanzenbach
2023-11-28 7:48 ` [PATCH net-next 2/5] igc: Use netdev printing functions for flex filters Kurt Kanzenbach
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Kurt Kanzenbach @ 2023-11-28 7:48 UTC (permalink / raw)
To: Jesse Brandeburg, Tony Nguyen, Vinicius Costa Gomes
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
intel-wired-lan, netdev, Kurt Kanzenbach
Use reverse xmas tree coding style convention in igc_add_flex_filter().
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
drivers/net/ethernet/intel/igc/igc_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 61db1d3bfa0b..d4150542a5c5 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -3577,9 +3577,9 @@ static bool igc_flex_filter_in_use(struct igc_adapter *adapter)
static int igc_add_flex_filter(struct igc_adapter *adapter,
struct igc_nfc_rule *rule)
{
- struct igc_flex_filter flex = { };
struct igc_nfc_filter *filter = &rule->filter;
unsigned int eth_offset, user_offset;
+ struct igc_flex_filter flex = { };
int ret, index;
bool vlan;
--
2.39.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH net-next 2/5] igc: Use netdev printing functions for flex filters
2023-11-28 7:48 [PATCH net-next 0/5] igc: ethtool: Check VLAN TCI mask Kurt Kanzenbach
2023-11-28 7:48 ` [PATCH net-next 1/5] igc: Use reverse xmas tree Kurt Kanzenbach
@ 2023-11-28 7:48 ` Kurt Kanzenbach
2023-11-28 7:48 ` [PATCH net-next 3/5] igc: Unify filtering rule fields Kurt Kanzenbach
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Kurt Kanzenbach @ 2023-11-28 7:48 UTC (permalink / raw)
To: Jesse Brandeburg, Tony Nguyen, Vinicius Costa Gomes
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
intel-wired-lan, netdev, Kurt Kanzenbach
All igc filter implementations use netdev_*() printing functions except for the
flex filters. Unify it.
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
drivers/net/ethernet/intel/igc/igc_main.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index d4150542a5c5..4c562df0527d 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -3385,7 +3385,7 @@ static int igc_flex_filter_select(struct igc_adapter *adapter,
u32 fhftsl;
if (input->index >= MAX_FLEX_FILTER) {
- dev_err(&adapter->pdev->dev, "Wrong Flex Filter index selected!\n");
+ netdev_err(adapter->netdev, "Wrong Flex Filter index selected!\n");
return -EINVAL;
}
@@ -3420,7 +3420,6 @@ static int igc_flex_filter_select(struct igc_adapter *adapter,
static int igc_write_flex_filter_ll(struct igc_adapter *adapter,
struct igc_flex_filter *input)
{
- struct device *dev = &adapter->pdev->dev;
struct igc_hw *hw = &adapter->hw;
u8 *data = input->data;
u8 *mask = input->mask;
@@ -3434,7 +3433,7 @@ static int igc_write_flex_filter_ll(struct igc_adapter *adapter,
* out early to avoid surprises later.
*/
if (input->length % 8 != 0) {
- dev_err(dev, "The length of a flex filter has to be 8 byte aligned!\n");
+ netdev_err(adapter->netdev, "The length of a flex filter has to be 8 byte aligned!\n");
return -EINVAL;
}
@@ -3504,8 +3503,8 @@ static int igc_write_flex_filter_ll(struct igc_adapter *adapter,
}
wr32(IGC_WUFC, wufc);
- dev_dbg(&adapter->pdev->dev, "Added flex filter %u to HW.\n",
- input->index);
+ netdev_dbg(adapter->netdev, "Added flex filter %u to HW.\n",
+ input->index);
return 0;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH net-next 3/5] igc: Unify filtering rule fields
2023-11-28 7:48 [PATCH net-next 0/5] igc: ethtool: Check VLAN TCI mask Kurt Kanzenbach
2023-11-28 7:48 ` [PATCH net-next 1/5] igc: Use reverse xmas tree Kurt Kanzenbach
2023-11-28 7:48 ` [PATCH net-next 2/5] igc: Use netdev printing functions for flex filters Kurt Kanzenbach
@ 2023-11-28 7:48 ` Kurt Kanzenbach
2023-11-28 7:48 ` [PATCH net-next 4/5] igc: Report VLAN EtherType matching back to user Kurt Kanzenbach
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Kurt Kanzenbach @ 2023-11-28 7:48 UTC (permalink / raw)
To: Jesse Brandeburg, Tony Nguyen, Vinicius Costa Gomes
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
intel-wired-lan, netdev, Kurt Kanzenbach
All filtering parameters such as EtherType and VLAN TCI are stored in host byte
order except for the VLAN EtherType. Unify it.
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
drivers/net/ethernet/intel/igc/igc.h | 2 +-
drivers/net/ethernet/intel/igc/igc_ethtool.c | 2 +-
drivers/net/ethernet/intel/igc/igc_main.c | 10 ++++++----
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h
index ac7c861e83a0..c783355f99be 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -585,7 +585,7 @@ enum igc_filter_match_flags {
struct igc_nfc_filter {
u8 match_flags;
u16 etype;
- __be16 vlan_etype;
+ u16 vlan_etype;
u16 vlan_tci;
u8 src_addr[ETH_ALEN];
u8 dst_addr[ETH_ALEN];
diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index 785eaa8e0ba8..8e12ef362b23 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -1243,7 +1243,7 @@ static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule,
/* VLAN etype matching */
if ((fsp->flow_type & FLOW_EXT) && fsp->h_ext.vlan_etype) {
- rule->filter.vlan_etype = fsp->h_ext.vlan_etype;
+ rule->filter.vlan_etype = ntohs(fsp->h_ext.vlan_etype);
rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_ETYPE;
}
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 4c562df0527d..c4dbb8c50a4e 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -3614,10 +3614,12 @@ static int igc_add_flex_filter(struct igc_adapter *adapter,
ETH_ALEN, NULL);
/* Add VLAN etype */
- if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE)
- igc_flex_filter_add_field(&flex, &filter->vlan_etype, 12,
- sizeof(filter->vlan_etype),
- NULL);
+ if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) {
+ __be16 vlan_etype = cpu_to_be16(filter->vlan_etype);
+
+ igc_flex_filter_add_field(&flex, &vlan_etype, 12,
+ sizeof(vlan_etype), NULL);
+ }
/* Add VLAN TCI */
if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI)
--
2.39.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH net-next 4/5] igc: Report VLAN EtherType matching back to user
2023-11-28 7:48 [PATCH net-next 0/5] igc: ethtool: Check VLAN TCI mask Kurt Kanzenbach
` (2 preceding siblings ...)
2023-11-28 7:48 ` [PATCH net-next 3/5] igc: Unify filtering rule fields Kurt Kanzenbach
@ 2023-11-28 7:48 ` Kurt Kanzenbach
2023-11-28 7:48 ` [PATCH net-next 5/5] igc: Check VLAN TCI mask Kurt Kanzenbach
2023-11-28 23:37 ` [PATCH net-next 0/5] igc: ethtool: " Vinicius Costa Gomes
5 siblings, 0 replies; 8+ messages in thread
From: Kurt Kanzenbach @ 2023-11-28 7:48 UTC (permalink / raw)
To: Jesse Brandeburg, Tony Nguyen, Vinicius Costa Gomes
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
intel-wired-lan, netdev, Kurt Kanzenbach
Currently the driver allows to configure matching by VLAN EtherType. However,
the retrieval function does not report it back to the user. Add it.
Before:
|root@host:~# ethtool -N enp3s0 flow-type ether vlan-etype 0x8100 action 0
|Added rule with ID 63
|root@host:~# ethtool --show-ntuple enp3s0
|4 RX rings available
|Total 1 rules
|
|Filter: 63
| Flow Type: Raw Ethernet
| Src MAC addr: 00:00:00:00:00:00 mask: FF:FF:FF:FF:FF:FF
| Dest MAC addr: 00:00:00:00:00:00 mask: FF:FF:FF:FF:FF:FF
| Ethertype: 0x0 mask: 0xFFFF
| Action: Direct to queue 0
After:
|root@host:~# ethtool -N enp3s0 flow-type ether vlan-etype 0x8100 action 0
|Added rule with ID 63
|root@host:~# ethtool --show-ntuple enp3s0
|4 RX rings available
|Total 1 rules
|
|Filter: 63
| Flow Type: Raw Ethernet
| Src MAC addr: 00:00:00:00:00:00 mask: FF:FF:FF:FF:FF:FF
| Dest MAC addr: 00:00:00:00:00:00 mask: FF:FF:FF:FF:FF:FF
| Ethertype: 0x0 mask: 0xFFFF
| VLAN EtherType: 0x8100 mask: 0x0
| VLAN: 0x0 mask: 0xffff
| User-defined: 0x0 mask: 0xffffffffffffffff
| Action: Direct to queue 0
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
drivers/net/ethernet/intel/igc/igc_ethtool.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index 8e12ef362b23..b782fb2abf20 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -980,6 +980,12 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter,
fsp->m_u.ether_spec.h_proto = ETHER_TYPE_FULL_MASK;
}
+ if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) {
+ fsp->flow_type |= FLOW_EXT;
+ fsp->h_ext.vlan_etype = htons(rule->filter.vlan_etype);
+ fsp->m_ext.vlan_etype = ETHER_TYPE_FULL_MASK;
+ }
+
if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {
fsp->flow_type |= FLOW_EXT;
fsp->h_ext.vlan_tci = htons(rule->filter.vlan_tci);
--
2.39.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH net-next 5/5] igc: Check VLAN TCI mask
2023-11-28 7:48 [PATCH net-next 0/5] igc: ethtool: Check VLAN TCI mask Kurt Kanzenbach
` (3 preceding siblings ...)
2023-11-28 7:48 ` [PATCH net-next 4/5] igc: Report VLAN EtherType matching back to user Kurt Kanzenbach
@ 2023-11-28 7:48 ` Kurt Kanzenbach
2023-11-28 23:37 ` [PATCH net-next 0/5] igc: ethtool: " Vinicius Costa Gomes
5 siblings, 0 replies; 8+ messages in thread
From: Kurt Kanzenbach @ 2023-11-28 7:48 UTC (permalink / raw)
To: Jesse Brandeburg, Tony Nguyen, Vinicius Costa Gomes
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
intel-wired-lan, netdev, Kurt Kanzenbach
Currently the driver accepts VLAN TCI steering rules regardless of the
configured mask. And things might fail silently or with confusing error
messages to the user.
There are two ways to handle the VLAN TCI mask:
1. Match on the PCP field using a VLAN prio filter
2. Match on complete TCI field using a flex filter
Therefore, add checks and code for that.
For instance the following rule is invalid and will be converted into a VLAN
prio rule which is not correct:
|root@host:~# ethtool -N enp3s0 flow-type ether vlan 0x0001 m 0xf000 action 1
|Added rule with ID 61
|root@host:~# ethtool --show-ntuple enp3s0
|4 RX rings available
|Total 1 rules
|
|Filter: 61
| Flow Type: Raw Ethernet
| Src MAC addr: 00:00:00:00:00:00 mask: FF:FF:FF:FF:FF:FF
| Dest MAC addr: 00:00:00:00:00:00 mask: FF:FF:FF:FF:FF:FF
| Ethertype: 0x0 mask: 0xFFFF
| VLAN EtherType: 0x0 mask: 0xffff
| VLAN: 0x1 mask: 0x1fff
| User-defined: 0x0 mask: 0xffffffffffffffff
| Action: Direct to queue 1
After:
|root@host:~# ethtool -N enp3s0 flow-type ether vlan 0x0001 m 0xf000 action 1
|rmgr: Cannot insert RX class rule: Operation not supported
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
drivers/net/ethernet/intel/igc/igc.h | 1 +
drivers/net/ethernet/intel/igc/igc_ethtool.c | 28 +++++++++++++++++---
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h
index c783355f99be..158adb1594e9 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -587,6 +587,7 @@ struct igc_nfc_filter {
u16 etype;
u16 vlan_etype;
u16 vlan_tci;
+ u16 vlan_tci_mask;
u8 src_addr[ETH_ALEN];
u8 dst_addr[ETH_ALEN];
u8 user_data[8];
diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index b782fb2abf20..46de8fa01682 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -958,6 +958,7 @@ static int igc_ethtool_set_coalesce(struct net_device *netdev,
}
#define ETHER_TYPE_FULL_MASK ((__force __be16)~0)
+#define VLAN_TCI_FULL_MASK ((__force __be16)~0)
static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter,
struct ethtool_rxnfc *cmd)
{
@@ -989,7 +990,7 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter,
if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {
fsp->flow_type |= FLOW_EXT;
fsp->h_ext.vlan_tci = htons(rule->filter.vlan_tci);
- fsp->m_ext.vlan_tci = htons(VLAN_PRIO_MASK);
+ fsp->m_ext.vlan_tci = htons(rule->filter.vlan_tci_mask);
}
if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) {
@@ -1224,6 +1225,7 @@ static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule,
if ((fsp->flow_type & FLOW_EXT) && fsp->m_ext.vlan_tci) {
rule->filter.vlan_tci = ntohs(fsp->h_ext.vlan_tci);
+ rule->filter.vlan_tci_mask = ntohs(fsp->m_ext.vlan_tci);
rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_TCI;
}
@@ -1261,11 +1263,19 @@ static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule,
memcpy(rule->filter.user_mask, fsp->m_ext.data, sizeof(fsp->m_ext.data));
}
- /* When multiple filter options or user data or vlan etype is set, use a
- * flex filter.
+ /* The i225/i226 has various different filters. Flex filters provide a
+ * way to match up to the first 128 bytes of a packet. Use them for:
+ * a) For specific user data
+ * b) For VLAN EtherType
+ * c) For full TCI match
+ * d) Or in case multiple filter criteria are set
+ *
+ * Otherwise, use the simple MAC, VLAN PRIO or EtherType filters.
*/
if ((rule->filter.match_flags & IGC_FILTER_FLAG_USER_DATA) ||
(rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) ||
+ (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI &&
+ rule->filter.vlan_tci_mask == ntohs(VLAN_TCI_FULL_MASK)) ||
(rule->filter.match_flags & (rule->filter.match_flags - 1)))
rule->flex = true;
else
@@ -1335,6 +1345,18 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter,
return -EINVAL;
}
+ /* There are two ways to match the VLAN TCI:
+ * 1. Match on PCP field and use vlan prio filter for it
+ * 2. Match on complete TCI field and use flex filter for it
+ */
+ if ((fsp->flow_type & FLOW_EXT) &&
+ fsp->m_ext.vlan_tci &&
+ fsp->m_ext.vlan_tci != htons(VLAN_PRIO_MASK) &&
+ fsp->m_ext.vlan_tci != VLAN_TCI_FULL_MASK) {
+ netdev_dbg(netdev, "VLAN mask not supported\n");
+ return -EOPNOTSUPP;
+ }
+
if (fsp->location >= IGC_MAX_RXNFC_RULES) {
netdev_dbg(netdev, "Invalid location\n");
return -EINVAL;
--
2.39.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH net-next 0/5] igc: ethtool: Check VLAN TCI mask
2023-11-28 7:48 [PATCH net-next 0/5] igc: ethtool: Check VLAN TCI mask Kurt Kanzenbach
` (4 preceding siblings ...)
2023-11-28 7:48 ` [PATCH net-next 5/5] igc: Check VLAN TCI mask Kurt Kanzenbach
@ 2023-11-28 23:37 ` Vinicius Costa Gomes
2023-11-29 11:15 ` Kurt Kanzenbach
5 siblings, 1 reply; 8+ messages in thread
From: Vinicius Costa Gomes @ 2023-11-28 23:37 UTC (permalink / raw)
To: Kurt Kanzenbach, Jesse Brandeburg, Tony Nguyen
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
intel-wired-lan, netdev, Kurt Kanzenbach
Kurt Kanzenbach <kurt@linutronix.de> writes:
> Hi,
>
> currently it is possible to configure receive queue assignment using the VLAN
> TCI field with arbitrary masks. However, the hardware only supports steering
> either by full TCI or the priority (PCP) field. In case a wrong mask is given by
> the user the driver will silently convert it into a PCP filter which is not
> desired. Therefore, add a check for it.
>
> Patches #1 to #4 are minor things found along the way.
>
Some very minor things: patches 2,3 and 4 have extra long lines in their
commit messages that checkpatch.pl doesn't seem to like.
Patches 4 and 5 read more like fixes to me. I think they could be
proposed to -net, as they contain fixes to user visible issues. Do you
think that makes sense?
As for the code, feel free to add my Ack to the series:
Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Cheers,
--
Vinicius
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH net-next 0/5] igc: ethtool: Check VLAN TCI mask
2023-11-28 23:37 ` [PATCH net-next 0/5] igc: ethtool: " Vinicius Costa Gomes
@ 2023-11-29 11:15 ` Kurt Kanzenbach
0 siblings, 0 replies; 8+ messages in thread
From: Kurt Kanzenbach @ 2023-11-29 11:15 UTC (permalink / raw)
To: Vinicius Costa Gomes, Jesse Brandeburg, Tony Nguyen
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
intel-wired-lan, netdev
[-- Attachment #1: Type: text/plain, Size: 1282 bytes --]
On Tue Nov 28 2023, Vinicius Costa Gomes wrote:
> Kurt Kanzenbach <kurt@linutronix.de> writes:
>
>> Hi,
>>
>> currently it is possible to configure receive queue assignment using the VLAN
>> TCI field with arbitrary masks. However, the hardware only supports steering
>> either by full TCI or the priority (PCP) field. In case a wrong mask is given by
>> the user the driver will silently convert it into a PCP filter which is not
>> desired. Therefore, add a check for it.
>>
>> Patches #1 to #4 are minor things found along the way.
>>
>
> Some very minor things: patches 2,3 and 4 have extra long lines in their
> commit messages that checkpatch.pl doesn't seem to like.
OK. checkpatch wants 75 chars per line. These patches have 80 set. I'll
adjust it.
>
> Patches 4 and 5 read more like fixes to me. I think they could be
> proposed to -net, as they contain fixes to user visible issues. Do you
> think that makes sense?
Probably yes. I'll sent them to -net instead. Fixes tags would be:
- Patch 4: 2b477d057e33 ("igc: Integrate flex filter into ethtool ops")
- Patch 5: 7991487ecb2d ("igc: Allow for Flex Filters to be installed")
>
> As for the code, feel free to add my Ack to the series:
>
> Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
>
Thanks,
Kurt
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread