Skip to contentSkip to conversation

igb: add support of Rx ethertype filter and VLAN priority filter

PATCH New Gangfeng 2 participants 6 messages Dec 25, 2015 – Dec 30, 2015

Subsystems (2)
lore
Share & tools
lore

Gangfeng

author
#0 lore raw

cover igb: add support of Rx ethertype filter and VLAN priority filter

Gangfeng Huang (3):
igb: Enable the ethtool interface fo Rx filter
igb: add support of ethertype RX filters
igb: add support of Rx VLAN priority filters

 drivers/net/ethernet/intel/igb/e1000_82575.h   |    5 +
 drivers/net/ethernet/intel/igb/e1000_defines.h |    5 +
 drivers/net/ethernet/intel/igb/e1000_regs.h    |    1 +
 drivers/net/ethernet/intel/igb/igb.h           |   52 ++++
 drivers/net/ethernet/intel/igb/igb_ethtool.c   |  345 ++++++++++++++++++++++++
 drivers/net/ethernet/intel/igb/igb_main.c      |   57 ++++
 drivers/net/ethernet/intel/igb/igb_ptp.c       |    4 +-
 7 files changed, 467 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/3 igb: Enable the ethtool interface fo Rx filter

From: Gangfeng Huang <[email protected]>

This patch is meant to allow for nfc to insert and remove Rx filter by ethtool. Ethtool interface has it's own rules manager

Show all filters:

$ ethtool -n eth0
4 RX rings available
Total 2 rules
---
 drivers/net/ethernet/intel/igb/igb.h         |   31 +++++
 drivers/net/ethernet/intel/igb/igb_ethtool.c |  193 ++++++++++++++++++++++++++
 drivers/net/ethernet/intel/igb/igb_main.c    |   57 ++++++++
 3 files changed, 281 insertions(+)
drivers/net/ethernet/intel/igb/igb.h +31 -0
index e3cb93b..7bcdf94 100644
@@ -348,6 +348,19 @@ struct hwmon_buff {
 #define IGB_N_SDP	4
 #define IGB_RETA_SIZE	128
 
+enum igb_filter_match_flags {
+	IGB_FILTER_FLAG_NONE        = 0x0,
+};
+
+#define IGB_MAX_RXNFC_FILTERS 16
+
+struct igb_nfc_input {
+	/* Byte layout in order, all values with MSB first:
+	* match_flags - 1 byte
+	*/
+	u8     match_flags;
+};
+
 /* board specific private data structure */
 struct igb_adapter {
 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
@@ -465,6 +478,19 @@ struct igb_adapter {
 	int copper_tries;
 	struct e1000_info ei;
 	u16 eee_advert;
+
+	/* rxnfc support */
+	struct hlist_head nfc_filter_list;
+	unsigned int nfc_filter_count;
+	/* lock for nfc filter */
+	spinlock_t nfc_lock;
+};
+
+struct igb_nfc_filter {
+	struct hlist_node nfc_node;
+	struct igb_nfc_input filter;
+	u16 sw_idx;
+	u16 action;
 };
 
 #define IGB_FLAG_HAS_MSI		(1 << 0)
@@ -584,4 +610,9 @@ static inline struct netdev_queue *txring_txq(const struct igb_ring *tx_ring)
 	return netdev_get_tx_queue(tx_ring->netdev, tx_ring->queue_index);
 }
 
+int igb_add_filter(struct igb_adapter *adapter,
+		   struct igb_nfc_filter *input);
+int igb_erase_filter(struct igb_adapter *adapter,
+		     struct igb_nfc_filter *input);
+
 #endif /* _IGB_H_ */
drivers/net/ethernet/intel/igb/igb_ethtool.c +193 -0

217 lines not on this page · raw message

drivers/net/ethernet/intel/igb/igb_main.c +57 -0

97 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 1/3 igb: Enable the ethtool interface fo Rx filter

Quoted 10 lines · Gangfeng

From: Gangfeng Huang <[email protected]>

This patch is meant to allow for nfc to insert and remove Rx filter by ethtool. Ethtool interface has it's own rules manager

Show all filters:

$ ethtool -n eth0
4 RX rings available
Total 2 rules
Quoted 8 lines

---
?drivers/net/ethernet/intel/igb/igb.h???????? |?? 31 +++++ ?drivers/net/ethernet/intel/igb/igb_ethtool.c |? 193
++++++++++++++++++++++++++
?drivers/net/ethernet/intel/igb/igb_main.c??? |?? 57 ++++++++ ?3 files changed, 281 insertions(+)

This is getting ridiculous, this is not applying cleaning still. Are you checking out the dev-queue branch before rebasing your patches?

Here is what I get when I attempt to apply your patch by hand:
[20:15:07 @jtkirshe-linux:next-queue]$ patch -p1 <.apply/1-3-igb- Enable-the-ethtool-interface-fo-Rx-filter.patch?
patching file drivers/net/ethernet/intel/igb/igb.h
Hunk #1 succeeded at 353 (offset 5 lines).
Hunk #2 FAILED at 478.
Hunk #3 succeeded at 612 (offset 15 lines).
1 out of 3 hunks FAILED -- saving rejects to file drivers/net/ethernet/intel/igb/igb.h.rej
patching file drivers/net/ethernet/intel/igb/igb_ethtool.c
Hunk #1 succeeded at 2607 (offset 176 lines).
Hunk #2 succeeded at 2702 (offset 176 lines).
Hunk #3 succeeded at 2826 (offset 176 lines).
Hunk #4 succeeded at 2971 (offset 176 lines).
patching file drivers/net/ethernet/intel/igb/igb_main.c
Hunk #1 succeeded at 188 with fuzz 2 (offset 12 lines).
Hunk #2 succeeded at 1636 (offset 24 lines).
Hunk #3 succeeded at 2085 (offset 27 lines).
Hunk #4 succeeded at 2436 (offset 46 lines).
Hunk #5 FAILED at 3004.
Hunk #6 succeeded at 3259 (offset 69 lines).
Hunk #7 FAILED@8143.
2 out of 7 hunks FAILED -- saving rejects to file drivers/net/ethernet/intel/igb/igb_main.c.rej
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20151229/70f27e2a/attachment.asc>

#3 lore raw

PATCH 1/3 igb: Enable the ethtool interface fo Rx filter

Hi Jeff,

I have found the reason why my patch is failed: I send the patch in Dec.25 and there are many commit in Dec.29. I will recreate the patches and send it to you as soon as possible.

Thanks

-----Original Message-----
From: Jeff Kirsher [mailto:jeffrey.t.kirsher at intel.com]
Sent: 2015?12?30? 12:28
To: Gangfeng Huang <[email protected]>; intel-wired-lan at lists.osuosl.org
Cc: Ruhao Gao <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH next-queue 1/3] igb: Enable the ethtool interface fo Rx filter

Quoted 10 lines · Gangfeng

From: Gangfeng Huang <[email protected]>

This patch is meant to allow for nfc to insert and remove Rx filter by ethtool. Ethtool interface has it's own rules manager

Show all filters:

$ ethtool -n eth0
4 RX rings available
Total 2 rules
Quoted 8 lines

---
?drivers/net/ethernet/intel/igb/igb.h???????? |?? 31 +++++ ?drivers/net/ethernet/intel/igb/igb_ethtool.c |? 193
++++++++++++++++++++++++++
?drivers/net/ethernet/intel/igb/igb_main.c??? |?? 57 ++++++++ ?3 files changed, 281 insertions(+)

This is getting ridiculous, this is not applying cleaning still. Are you checking out the dev-queue branch before rebasing your patches?

Here is what I get when I attempt to apply your patch by hand:
[20:15:07 @jtkirshe-linux:next-queue]$ patch -p1 <.apply/1-3-igb- Enable-the-ethtool-interface-fo-Rx-filter.patch patching file drivers/net/ethernet/intel/igb/igb.h
Hunk #1 succeeded at 353 (offset 5 lines).
Hunk #2 FAILED at 478.
Hunk #3 succeeded at 612 (offset 15 lines).
1 out of 3 hunks FAILED -- saving rejects to file drivers/net/ethernet/intel/igb/igb.h.rej patching file drivers/net/ethernet/intel/igb/igb_ethtool.c
Hunk #1 succeeded at 2607 (offset 176 lines).
Hunk #2 succeeded at 2702 (offset 176 lines).
Hunk #3 succeeded at 2826 (offset 176 lines).
Hunk #4 succeeded at 2971 (offset 176 lines).
patching file drivers/net/ethernet/intel/igb/igb_main.c
Hunk #1 succeeded at 188 with fuzz 2 (offset 12 lines).
Hunk #2 succeeded at 1636 (offset 24 lines).
Hunk #3 succeeded at 2085 (offset 27 lines).
Hunk #4 succeeded at 2436 (offset 46 lines).
Hunk #5 FAILED at 3004.
Hunk #6 succeeded at 3259 (offset 69 lines).
Hunk #7 FAILED@8143.
2 out of 7 hunks FAILED -- saving rejects to file drivers/net/ethernet/intel/igb/igb_main.c.rej

author
#4 lore raw

PATCH 2/3 igb: add support of ethertype RX filters

In reply to Gangfeng

From: Gangfeng Huang <[email protected]>

This patch is meant to allow for nfc to insert and remove ethertype filter by ethtool

Example:
Add an ethertype filter:

$ ethtool -N eth0 flow-type ether proto 0x88F8 action 2

Show all filters:

$ ethtool -n eth0
4 RX rings available
Total 1 rules

Filter: 15

	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: 0x88F8 mask: 0x0
	Action: Direct to queue 2

Delete the filter by location:

$ ethtool -N delete 15
---
 drivers/net/ethernet/intel/igb/e1000_82575.h |    5 ++
 drivers/net/ethernet/intel/igb/igb.h         |   20 ++++++-
 drivers/net/ethernet/intel/igb/igb_ethtool.c |   77 +++++++++++++++++++++++++-
 drivers/net/ethernet/intel/igb/igb_ptp.c     |    4 +-
 4 files changed, 102 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igb/e1000_82575.h +5 -0
index 2154aea..c4a34e1 100644
@@ -187,7 +187,12 @@ struct e1000_adv_tx_context_desc {
 
 /* ETQF register bit definitions */
 #define E1000_ETQF_FILTER_ENABLE   (1 << 26)
+#define E1000_ETQF_IMM_INT         (1 << 29)
 #define E1000_ETQF_1588            (1 << 30)
+#define E1000_ETQF_QUEUE_ENABLE    (1 << 31)
+#define E1000_ETQF_QUEUE_SHIFT     16
+#define E1000_ETQF_QUEUE_MASK      0x00070000
+#define E1000_ETQF_ETYPE_MASK      0x0000FFFF
 
 /* FTQF register bit definitions */
 #define E1000_FTQF_VF_BP               0x00008000
drivers/net/ethernet/intel/igb/igb.h +19 -1
index 7bcdf94..950eed5 100644
@@ -343,13 +343,27 @@ struct hwmon_buff {
 	};
 #endif
 
+/* The number of L2 ether-type filter registers, Index 3 is reserved
+ * for PTP 1588 timestamp
+ */
+#define MAX_ETYPE_FILTER  (4 - 1)
+
+/* ETQF filter list: one static filter per filter consumer. This is
+ *                   to avoid filter collisions later. Add new filters
+ *                   here!!
+ *
+ * Current filters:
+ *    1588 (0x88f7):         Filter 3
+ */
+#define IGB_ETQF_FILTER_1588   3
+
 #define IGB_N_EXTTS	2
 #define IGB_N_PEROUT	2
 #define IGB_N_SDP	4
 #define IGB_RETA_SIZE	128
 
 enum igb_filter_match_flags {
-	IGB_FILTER_FLAG_NONE        = 0x0,
+	IGB_FILTER_FLAG_ETHER_TYPE  = 0x1,
 };
 
 #define IGB_MAX_RXNFC_FILTERS 16
@@ -357,8 +371,10 @@ enum igb_filter_match_flags {
 struct igb_nfc_input {
 	/* Byte layout in order, all values with MSB first:
 	* match_flags - 1 byte
+	* etype       - 2 bytes
 	*/
 	u8     match_flags;
+	__be16 etype;
 };
 
 /* board specific private data structure */
@@ -484,11 +500,13 @@ struct igb_adapter {
 	unsigned int nfc_filter_count;
 	/* lock for nfc filter */
 	spinlock_t nfc_lock;
+	bool etype_bitmap[MAX_ETYPE_FILTER];
 };
 
 struct igb_nfc_filter {
 	struct hlist_node nfc_node;
 	struct igb_nfc_input filter;
+	u16 etype_reg_index;
 	u16 sw_idx;
 	u16 action;
 };
drivers/net/ethernet/intel/igb/igb_ethtool.c +76 -1

111 lines not on this page · raw message

drivers/net/ethernet/intel/igb/igb_ptp.c +2 -2
index c44df87..84c4943 100644
@@ -940,12 +940,12 @@ static int igb_ptp_set_timestamp_mode(struct igb_adapter *adapter,
 
 	/* define ethertype filter for timestamped packets */
 	if (is_l2)
-		wr32(E1000_ETQF(3),
+		wr32(E1000_ETQF(IGB_ETQF_FILTER_1588),
 		     (E1000_ETQF_FILTER_ENABLE | /* enable filter */
 		      E1000_ETQF_1588 | /* enable timestamping */
 		      ETH_P_1588));     /* 1588 eth protocol type */
 	else
-		wr32(E1000_ETQF(3), 0);
+		wr32(E1000_ETQF(IGB_ETQF_FILTER_1588), 0);
 
 	/* L4 Queue Filter[3]: filter by destination port and protocol */
 	if (is_l4) {
Signature · 1 line
1.7.9.5
author
#5 lore raw

PATCH 3/3 igb: add support of Rx VLAN priority filters

In reply to Gangfeng

From: Gangfeng Huang <[email protected]>

This patch is meant to allow for nfc to insert and remove VLAN priority filter by ethtool

Example:
Add an VLAN priority filter:

$ ethtool -N eth0 flow-type ether vlan 0x6000 vlan-mask 0x1FFF action 2 loc 1

Show all filters:

$ ethtool -n eth0
4 RX rings available
Total 1 rules

Filter: 1

	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: 0x6000 mask: 0x1fff
	User-defined: 0x0 mask: 0xffffffffffffffff
	Action: Direct to queue 2

Delete the filter by location:

$ ethtool -N delete 1
---
 drivers/net/ethernet/intel/igb/e1000_defines.h |    5 ++
 drivers/net/ethernet/intel/igb/e1000_regs.h    |    1 +
 drivers/net/ethernet/intel/igb/igb.h           |    3 +
 drivers/net/ethernet/intel/igb/igb_ethtool.c   |   91 ++++++++++++++++++++++--
 4 files changed, 93 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/igb/e1000_defines.h +5 -0
index c3c598c..aed8664 100644
@@ -1023,4 +1023,9 @@
 #define E1000_RTTBCNRC_RF_INT_MASK	\
 	(E1000_RTTBCNRC_RF_DEC_MASK << E1000_RTTBCNRC_RF_INT_SHIFT)
 
+/* VLAN Priority Filter */
+#define E1000_VLAPQF_QUEUE_SEL(_n, q_idx) (q_idx << ((_n) * 4))
+#define E1000_VLAPQF_P_VALID(_n)          (0x1 << (3 + (_n) * 4))
+#define E1000_VLAPQF_QUEUE_MASK           0x03
+
 #endif
drivers/net/ethernet/intel/igb/e1000_regs.h +1 -0
index 21d9d02..9b66b6f 100644
@@ -309,6 +309,7 @@
 					(0x054E0 + ((_i - 16) * 8)))
 #define E1000_RAH(_i)  (((_i) <= 15) ? (0x05404 + ((_i) * 8)) : \
 					(0x054E4 + ((_i - 16) * 8)))
+#define E1000_VLAPQF   0x055B0  /* VLAN Priority Queue Filter VLAPQF */
 #define E1000_IP4AT_REG(_i)     (0x05840 + ((_i) * 8))
 #define E1000_IP6AT_REG(_i)     (0x05880 + ((_i) * 4))
 #define E1000_WUPM_REG(_i)      (0x05A00 + ((_i) * 4))
drivers/net/ethernet/intel/igb/igb.h +3 -0
index 950eed5..8622ed9 100644
@@ -364,6 +364,7 @@ struct hwmon_buff {
 
 enum igb_filter_match_flags {
 	IGB_FILTER_FLAG_ETHER_TYPE  = 0x1,
+	IGB_FILTER_FLAG_VLAN_TCI    = 0x2,
 };
 
 #define IGB_MAX_RXNFC_FILTERS 16
@@ -372,9 +373,11 @@ struct igb_nfc_input {
 	/* Byte layout in order, all values with MSB first:
 	* match_flags - 1 byte
 	* etype       - 2 bytes
+	* vlan_tci    - 2 bytes
 	*/
 	u8     match_flags;
 	__be16 etype;
+	__be16 vlan_tci;
 };
 
 /* board specific private data structure */
drivers/net/ethernet/intel/igb/igb_ethtool.c +84 -7

139 lines not on this page · raw message

Signature · 1 line
1.7.9.5