Skip to contentSkip to conversation

nfp: flower: add support for QinQ matching

PATCH In review Simon Horman 3 participants 5 messages Aug 20, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover nfp: flower: add support for QinQ matching

Louis says:

Add new feature to the Netronome flower driver to enable QinQ offload. This needed a bit of gymnastics in order to not break compatibility with older firmware as the flow key sent to the firmware had to be updated in order to make space for the extra field.

Louis Peens (2):
nfp: flower: check that we don't exceed the FW key size
nfp: flower: add support to offload QinQ match

 .../net/ethernet/netronome/nfp/flower/cmsg.h  | 17 ++++
 .../net/ethernet/netronome/nfp/flower/main.h  |  6 +-
 .../net/ethernet/netronome/nfp/flower/match.c | 73 +++++++++++++++-
 .../ethernet/netronome/nfp/flower/offload.c   | 85 ++++++++++++++++---
 4 files changed, 165 insertions(+), 16 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 nfp: flower: check that we don't exceed the FW key size

From: Louis Peens <[email protected]>

Add a check to make sure the total length of the flow key sent to the firmware stays within the supported limit.

---
 drivers/net/ethernet/netronome/nfp/flower/main.h  |  2 ++
 drivers/net/ethernet/netronome/nfp/flower/match.c | 11 +++++++++++
 2 files changed, 13 insertions(+)
drivers/net/ethernet/netronome/nfp/flower/main.h +2 -0
index 3bf9c1afa45e..4924a217f5ba 100644
@@ -30,6 +30,8 @@ struct nfp_app;
 #define NFP_FLOWER_MASK_ELEMENT_RS	1
 #define NFP_FLOWER_MASK_HASH_BITS	10
 
+#define NFP_FLOWER_KEY_MAX_LW		32
+
 #define NFP_FL_META_FLAG_MANAGE_MASK	BIT(7)
 
 #define NFP_FL_MASK_REUSE_TIME_NS	40000
drivers/net/ethernet/netronome/nfp/flower/match.c +11 -0
index f7f01e2e3dce..64690511e47b 100644
@@ -434,6 +434,7 @@ int nfp_flower_compile_flow_match(struct nfp_app *app,
 {
 	struct flow_rule *rule = flow_cls_offload_flow_rule(flow);
 	u32 port_id;
+	int ext_len;
 	int err;
 	u8 *ext;
 	u8 *msk;
@@ -589,5 +590,15 @@ int nfp_flower_compile_flow_match(struct nfp_app *app,
 		}
 	}
 
+	/* Check that the flow key does not exceed the maximum limit.
+	 * All structures in the key is multiples of 4 bytes, so use u32.
+	 */
+	ext_len = (u32 *)ext - (u32 *)nfp_flow->unmasked_data;
+	if (ext_len > NFP_FLOWER_KEY_MAX_LW) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "unsupported offload: flow key too long");
+		return -EOPNOTSUPP;
+	}
+
 	return 0;
 }
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/2 nfp: flower: add support to offload QinQ match

In reply to Simon Horman

From: Louis Peens <[email protected]>

When both the driver and the firmware supports QinQ the flow key structure that is send to the firmware is updated as the old method of matching on VLAN did not allow for space to add another VLAN tag. VLAN flows can now also match on the tpid field, not constrained to just 0x8100 as before.

---
 .../net/ethernet/netronome/nfp/flower/cmsg.h  | 17 ++++
 .../net/ethernet/netronome/nfp/flower/main.h  |  4 +-
 .../net/ethernet/netronome/nfp/flower/match.c | 62 +++++++++++++-
 .../ethernet/netronome/nfp/flower/offload.c   | 85 ++++++++++++++++---
 4 files changed, 152 insertions(+), 16 deletions(-)
drivers/net/ethernet/netronome/nfp/flower/cmsg.h +17 -0
index bf516285510f..a2926b1b3cff 100644
@@ -24,6 +24,7 @@
 #define NFP_FLOWER_LAYER_VXLAN		BIT(7)
 
 #define NFP_FLOWER_LAYER2_GRE		BIT(0)
+#define NFP_FLOWER_LAYER2_QINQ		BIT(4)
 #define NFP_FLOWER_LAYER2_GENEVE	BIT(5)
 #define NFP_FLOWER_LAYER2_GENEVE_OP	BIT(6)
 #define NFP_FLOWER_LAYER2_TUN_IPV6	BIT(7)
@@ -319,6 +320,22 @@ struct nfp_flower_mac_mpls {
 	__be32 mpls_lse;
 };
 
+/* VLAN details (2W/8B)
+ *    3                   2                   1
+ *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |           outer_tpid          |           outer_tci           |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |           inner_tpid          |           inner_tci           |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_flower_vlan {
+	__be16 outer_tpid;
+	__be16 outer_tci;
+	__be16 inner_tpid;
+	__be16 inner_tci;
+};
+
 /* L4 ports (for UDP, TCP, SCTP) (1W/4B)
  *    3                   2                   1
  *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
drivers/net/ethernet/netronome/nfp/flower/main.h +3 -1
index 4924a217f5ba..caf12eec9945 100644
@@ -46,6 +46,7 @@ struct nfp_app;
 #define NFP_FL_FEATS_FLOW_MOD		BIT(5)
 #define NFP_FL_FEATS_PRE_TUN_RULES	BIT(6)
 #define NFP_FL_FEATS_IPV6_TUN		BIT(7)
+#define NFP_FL_FEATS_VLAN_QINQ		BIT(8)
 #define NFP_FL_FEATS_HOST_ACK		BIT(31)
 
 #define NFP_FL_ENABLE_FLOW_MERGE	BIT(0)
@@ -59,7 +60,8 @@ struct nfp_app;
 	NFP_FL_FEATS_VF_RLIM | \
 	NFP_FL_FEATS_FLOW_MOD | \
 	NFP_FL_FEATS_PRE_TUN_RULES | \
-	NFP_FL_FEATS_IPV6_TUN)
+	NFP_FL_FEATS_IPV6_TUN | \
+	NFP_FL_FEATS_VLAN_QINQ)
 
 struct nfp_fl_mask_id {
 	struct circ_buf mask_id_free_list;
drivers/net/ethernet/netronome/nfp/flower/match.c +59 -3

100 lines not on this page · raw message

drivers/net/ethernet/netronome/nfp/flower/offload.c +73 -12

161 lines not on this page · raw message

Signature · 1 line
2.20.1
maintainer Acked-by on the v1 series
#3 lore raw
In reply to Simon Horman
Quoted 6 lines · On Thu, 20 Aug 2020 16:39:36 +0200 Simon Horman wrote:

Louis says:

Add new feature to the Netronome flower driver to enable QinQ offload. This needed a bit of gymnastics in order to not break compatibility with older firmware as the flow key sent to the firmware had to be updated in order to make space for the extra field.

maintainer
#4 lore raw
In reply to Simon Horman

From: Simon Horman <[email protected]>
Date: Thu, 20 Aug 2020 16:39:36 +0200

Quoted 6 lines

Louis says:

Add new feature to the Netronome flower driver to enable QinQ offload. This needed a bit of gymnastics in order to not break compatibility with older firmware as the flow key sent to the firmware had to be updated in order to make space for the extra field.

I'll apply this series, thanks Simon.