igc: Fixes for ethertype filtering code
Subsystems (2)
cover igc: Fixes for ethertype filtering code
Hi,
This patch series provides some fixes and improvements to the ethertype filtering code from IGC driver.
The improvements focuses on aligning the code organization to follow the same rationale from the rest of the filtering code (MAC address and VLAN priority filtering).
Best regards,
Andre
Andre Guedes (5):
igc: Remove duplicated IGC_RXPBS macro
igc: Remove ethertype filter in ptp code
igc: Fix MAX_ETYPE_FILTER value
igc: Refactor ethertype filtering code
igc: Dump ETQF registers
drivers/net/ethernet/intel/igc/igc.h | 6 +- drivers/net/ethernet/intel/igc/igc_defines.h | 3 - drivers/net/ethernet/intel/igc/igc_ethtool.c | 70 +++------------ drivers/net/ethernet/intel/igc/igc_main.c | 93 ++++++++++++++++++++ drivers/net/ethernet/intel/igc/igc_ptp.c | 12 --- drivers/net/ethernet/intel/igc/igc_regs.h | 2 - 6 files changed, 107 insertions(+), 79 deletions(-)
Signature · 1 line
2.26.0
PATCH 1/5 igc: Remove duplicated IGC_RXPBS macro
This patch remove the IGC_RXPBS macro defined in line 233 since it is already defined in line 18 with the exactly same value.
--- drivers/net/ethernet/intel/igc/igc_regs.h | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/igc/igc_regs.h +0 -2
@@ -227,8 +227,6 @@#define IGC_FTQF (_n) (0x059E0 + (4 * (_n)))/* 5-tuple Queue Fltr */ -#define IGC_RXPBS 0x02404/* Rx Packet Buffer Size - RW */ -/* Transmit Scheduling Registers */ #define IGC_TQAVCTRL 0x3570#define IGC_TXQCTL (_n) (0x3344 + 0x4 * (_n))
Signature · 1 line
2.26.0
Brown
PATCH 1/5 igc: Remove duplicated IGC_RXPBS macro
Quoted 7 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Andre Guedes
Sent: Tuesday, April 7, 2020 2:07 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH 1/5] igc: Remove duplicatedIGC_RXPBSmacro
Quoted 7 lines
This patch remove the
IGC_RXPBSmacro defined in line 233 since it is already defined in line 18 with the exactly same value.Signed-off-by Andre Guedes <[email protected]>--- drivers/net/ethernet/intel/igc/igc_regs.h | 2 -- 1 file changed, 2 deletions(-)
PATCH 2/5 igc: Remove ethertype filter in ptp code
In reply to Andre GuedesThe driver only supports hardware timestamping for all incoming traffic (HWTSTAMP_FILTER_ALL) which is enabled via Rx Time Sync Control (TSYNCRXCTL) register already. Therefore, the ethertype filter set in in igc_ptp_set_timestamp_mode() is useless so this patch removes it.
--- drivers/net/ethernet/intel/igc/igc.h | 2 +- drivers/net/ethernet/intel/igc/igc_defines.h | 3 --- drivers/net/ethernet/intel/igc/igc_ptp.c | 12 ------------ 3 files changed, 1 insertion(+), 16 deletions(-)
drivers/net/ethernet/intel/igc/igc.h +1 -1
@@ -26,7 +26,7 @@ void igc_set_ethtool_ops(struct net_device *);#define MAX_Q_VECTORS 8#define MAX_STD_JUMBO_FRAME_SIZE 9216 -#define MAX_ETYPE_FILTER (4 - 1) +#define MAX_ETYPE_FILTER 4#define IGC_RETA_SIZE 128struct igc_tx_queue_stats {
drivers/net/ethernet/intel/igc/igc_defines.h +0 -3
@@ -384,9 +384,6 @@#define IGC_TSICR_INTERRUPTS IGC_TSICR_TXTS -/* PTP Queue Filter */ -#define IGC_ETQF_1588 BIT(30) -#define IGC_FTQF_VF_BP 0x00008000#define IGC_FTQF_1588_TIME_STAMP 0x08000000#define IGC_FTQF_MASK 0xF0000000
drivers/net/ethernet/intel/igc/igc_ptp.c +0 -12
@@ -305,7 +305,6 @@ static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter,struct igc_hw *hw = &adapter->hw;u32 tsync_rx_cfg =0 ;bool is_l4 = false; -bool is_l2 = false;u32 regval;/* reserved for future extensions */
@@ -346,7 +345,6 @@ static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter,case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ : tsync_rx_ctl |=IGC_TSYNCRXCTL_TYPE_EVENT_V2 ; config->rx_filter =HWTSTAMP_FILTER_PTP_V2_EVENT ; - is_l2 = true; is_l4 = true;break ;case HWTSTAMP_FILTER_PTP_V1_L4_EVENT :
@@ -370,7 +368,6 @@ static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter, tsync_rx_ctl |=IGC_TSYNCRXCTL_TYPE_ALL ; tsync_rx_ctl |=IGC_TSYNCRXCTL_RXSYNSIG ; config->rx_filter =HWTSTAMP_FILTER_ALL ; - is_l2 = true; is_l4 = true;if (hw->mac.type == igc_i225) {
@@ -405,15 +402,6 @@ static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter,/* define which PTP packets are time stamped */ wr32 (IGC_TSYNCRXCFG , tsync_rx_cfg); -/* define ethertype filter for timestamped packets */ -if (is_l2) -wr32 (IGC_ETQF (3 ), - (IGC_ETQF_FILTER_ENABLE |/* enable filter */ -IGC_ETQF_1588 |/* enable timestamping */ -ETH_P_1588 ));/* 1588 eth protocol type */ -else -wr32 (IGC_ETQF (3 ),0 ); -/* L4 Queue Filter[3]: filter by destination port and protocol */ if (is_l4) { u32 ftqf = (IPPROTO_UDP /* UDP */
Signature · 1 line
2.26.0
Brown
PATCH 2/5 igc: Remove ethertype filter in ptp code
Quoted 13 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Andre Guedes
Sent: Tuesday, April 7, 2020 2:07 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH 2/5] igc: Remove ethertype filter in ptp codeThe driver only supports hardware timestamping for all incoming traffic (
HWTSTAMP_FILTER_ALL) which is enabled via Rx Time Sync Control (TSYNCRXCTL) register already. Therefore, the ethertype filter set in inigc_ptp_set_timestamp_mode()is useless so this patch removes it.
Quoted 7 lines
Signed-off-by Andre Guedes <[email protected]>--- drivers/net/ethernet/intel/igc/igc.h | 2 +- drivers/net/ethernet/intel/igc/igc_defines.h | 3 --- drivers/net/ethernet/intel/igc/igc_ptp.c | 12 ------------ 3 files changed, 1 insertion(+), 16 deletions(-)
PATCH 3/5 igc: Fix MAX_ETYPE_FILTER value
In reply to Andre GuedesThe I225 controller has 8 ethertype filters, not 4. This patch fixes the MAX_ETYPE_FILTER macro accordingly.
--- drivers/net/ethernet/intel/igc/igc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc.h +1 -1
@@ -26,7 +26,7 @@ void igc_set_ethtool_ops(struct net_device *);#define MAX_Q_VECTORS 8#define MAX_STD_JUMBO_FRAME_SIZE 9216 -#define MAX_ETYPE_FILTER 4 +#define MAX_ETYPE_FILTER 8#define IGC_RETA_SIZE 128struct igc_tx_queue_stats {
Signature · 1 line
2.26.0
Brown
PATCH 3/5 igc: Fix MAX_ETYPE_FILTER value
Quoted 6 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Andre Guedes
Sent: Tuesday, April 7, 2020 2:07 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH 3/5] igc: FixMAX_ETYPE_FILTERvalue
Quoted 8 lines
The I225 controller has 8 ethertype filters, not 4. This patch fixes the
MAX_ETYPE_FILTERmacro accordingly.Signed-off-by Andre Guedes <[email protected]>--- drivers/net/ethernet/intel/igc/igc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 4/5 igc: Refactor ethertype filtering code
In reply to Andre GuedesThe whole ethertype filtering code is implemented in igc_ethtool.c and mixes logic from ethtool and core parts. This patch refactors it so core logic is moved to igc_main.c, aligning the ethertype filtering code organization with the rest of the filtering code from the driver (MAC address and VLAN priority).
Besides moving code to igc_main.c, this patch also does some minor improvements to the code. Below are some highlights.
In case all filters are already in use and the user tries to add another filter, we return -ENOSPC instead of -EINVAL so a more meaningful error code is provided. This also aligns with the behavior implemented in MAC address filtering code.
With this code refactoring, 'etype_bitmap' array in struct igc_adapter and 'etype_reg_index' in struct igc_nfc_filter are not needed anymore and are removed.
Log messages are added to help debugging the ethertype filtering code.
--- drivers/net/ethernet/intel/igc/igc.h | 4 +- drivers/net/ethernet/intel/igc/igc_ethtool.c | 67 ++------------ drivers/net/ethernet/intel/igc/igc_main.c | 93 ++++++++++++++++++++ 3 files changed, 103 insertions(+), 61 deletions(-)
drivers/net/ethernet/intel/igc/igc.h +2 -2
@@ -189,7 +189,6 @@ struct igc_adapter {/* lock for RX network flow classification filter */ spinlock_t nfc_lock; -bool etype_bitmap[MAX_ETYPE_FILTER ];struct igc_mac_addr *mac_table;
@@ -238,6 +237,8 @@ int igc_del_mac_filter(struct igc_adapter *adapter, const u8 *addr,int igc_add_vlan_prio_filter (struct igc_adapter *adapter,int prio,int queue);void igc_del_vlan_prio_filter (struct igc_adapter *adapter,int prio); +int igc_add_etype_filter (struct igc_adapter *adapter,u16 etype,int queue); +int igc_del_etype_filter (struct igc_adapter *adapter,u16 etype);void igc_update_stats (struct igc_adapter *adapter);/* igc_dump declarations */
@@ -466,7 +467,6 @@ struct igc_nfc_filter {struct hlist_node nfc_node;struct igc_nfc_input filter;unsigned long cookie; -u16 etype_reg_index;u16 sw_idx;u16 action; };
drivers/net/ethernet/intel/igc/igc_ethtool.c +8 -59
87 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_main.c +93 -0
99 lines not on this page · raw message
Signature · 1 line
2.26.0
Brown
PATCH 4/5 igc: Refactor ethertype filtering code
Quoted 24 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Andre Guedes
Sent: Tuesday, April 7, 2020 2:07 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH 4/5] igc: Refactor ethertype filtering codeThe whole ethertype filtering code is implemented in
igc_ethtool.cand mixes logic from ethtool and core parts. This patch refactors it so core logic is moved toigc_main.c, aligning the ethertype filtering code organization with the rest of the filtering code from the driver (MAC address and VLAN priority).Besides moving code to
igc_main.c, this patch also does some minor improvements to the code. Below are some highlights.In case all filters are already in use and the user tries to add another filter, we return
-ENOSPCinstead of-EINVALso a more meaningful error code is provided. This also aligns with the behavior implemented in MAC address filtering code.With this code refactoring, '
etype_bitmap' array in structigc_adapterand 'etype_reg_index' in structigc_nfc_filterare not needed anymore and are removed.
Quoted 9 lines
Log messages are added to help debugging the ethertype filtering code.
Signed-off-by Andre Guedes <[email protected]>--- drivers/net/ethernet/intel/igc/igc.h | 4 +- drivers/net/ethernet/intel/igc/igc_ethtool.c | 67 ++------------ drivers/net/ethernet/intel/igc/igc_main.c | 93 ++++++++++++++++++++ 3 files changed, 103 insertions(+), 61 deletions(-)
PATCH 5/5 igc: Dump ETQF registers
In reply to Andre GuedesThis patch adds the EType Queue Filter (ETQF) registers to the list of registers dumped by igc_get_regs().
--- drivers/net/ethernet/intel/igc/igc_ethtool.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/igc/igc_ethtool.c +3 -0
@@ -318,6 +318,9 @@ static void igc_get_regs(struct net_device *netdev, regs_buff[188 + i] =rd32 (IGC_RAH (i)); regs_buff[204 ] =rd32 (IGC_VLANPQF ); + +for (i =0 ; i <8 ; i++) + regs_buff[205 + i] =rd32 (IGC_ETQF (i)); }static void igc_get_wol (struct net_device *netdev,struct ethtool_wolinfo *wol)
Signature · 1 line
2.26.0
Brown
PATCH 5/5 igc: Dump ETQF registers
Quoted 6 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Andre Guedes
Sent: Tuesday, April 7, 2020 2:07 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH 5/5] igc: Dump ETQF registers
Quoted 8 lines
This patch adds the EType Queue Filter (ETQF) registers to the list of registers dumped by
igc_get_regs().Signed-off-by Andre Guedes <[email protected]>--- drivers/net/ethernet/intel/igc/igc_ethtool.c | 3 +++ 1 file changed, 3 insertions(+)