Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f76c4b57 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'net-mvpp2-cls-Add-classification'

Maxime Chevallier says:

====================
net: mvpp2: cls: Add classification

This series is a rework of the previously standalone patch adding
classification support for mvpp2 :

https://lore.kernel.org/netdev/20190423075031.26074-1-maxime.chevallier@bootlin.com/



This patch has been reworked according to Saeed's review, to make sure
that the location of the rule is always respected and serves as a way to
prioritize rules between each other. This the 3rd iteration of this
submission, but since it's now a series, I reset the revision numbering.

This series implements that in a limited configuration for now, since we
limit the total number of rules per port to 4.

The main factors for this limitation are that :
 - We share the classification tables between all ports (4 max, although
   one is only used for internal loopback), hence we have to perform a
   logical separation between rules, which is done today by dedicated
   ranges for each port in each table

 - The "Flow table", which dictates which lookups operations are
   performed for an ingress packet, in subdivided into 22 "sub flows",
   each corresponding to a traffic type based on the L3 proto, L4
   proto, the presence or not of a VLAN tag and the L3 fragmentation.

   This makes so that when adding a rule, it has to be added into each
   of these subflows, introducing duplications of entries and limiting
   our max number of entries.

These limitations can be overcomed in several ways, but for readability
sake, I'd rather submit basic classification offload support for now,
and improve it gradually.

This series also adds a small cosmetic cleanup patch (1), and also adds
support for the "Drop" action compared to the first submission of this
feature. It is simple enough to be added with this basic support.

Compared to the first submissions, the NETIF_F_NTUPLE flag was also
removed, following Saeed's comment.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 2a369ae0 bec2d46d
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#include <linux/netdevice.h>
#include <linux/phy.h>
#include <linux/phylink.h>
#include <net/flow_offload.h>

/* Fifo Registers */
#define MVPP2_RX_DATA_FIFO_SIZE_REG(port)	(0x00 + 4 * (port))
@@ -126,6 +127,7 @@
#define MVPP22_CLS_C2_TCAM_DATA4		0x1b20
#define     MVPP22_CLS_C2_LU_TYPE(lu)		((lu) & 0x3f)
#define     MVPP22_CLS_C2_PORT_ID(port)		((port) << 8)
#define     MVPP22_CLS_C2_PORT_MASK		(0xff << 8)
#define MVPP22_CLS_C2_TCAM_INV			0x1b24
#define     MVPP22_CLS_C2_TCAM_INV_BIT		BIT(31)
#define MVPP22_CLS_C2_HIT_CTR			0x1b50
@@ -134,6 +136,7 @@
#define     MVPP22_CLS_C2_ACT_FWD(act)		(((act) & 0x7) << 13)
#define     MVPP22_CLS_C2_ACT_QHIGH(act)	(((act) & 0x3) << 11)
#define     MVPP22_CLS_C2_ACT_QLOW(act)		(((act) & 0x3) << 9)
#define     MVPP22_CLS_C2_ACT_COLOR(act)	((act) & 0x7)
#define MVPP22_CLS_C2_ATTR0			0x1b64
#define     MVPP22_CLS_C2_ATTR0_QHIGH(qh)	(((qh) & 0x1f) << 24)
#define     MVPP22_CLS_C2_ATTR0_QHIGH_MASK	0x1f
@@ -615,6 +618,10 @@
#define MVPP2_BIT_IN_WORD(bit)		((bit) % 32)

#define MVPP2_N_PRS_FLOWS		52
#define MVPP2_N_RFS_ENTRIES_PER_FLOW	4

/* There are 7 supported high-level flows */
#define MVPP2_N_RFS_RULES		(MVPP2_N_RFS_ENTRIES_PER_FLOW * 7)

/* RSS constants */
#define MVPP22_RSS_TABLE_ENTRIES	32
@@ -812,6 +819,37 @@ struct mvpp2_queue_vector {
	struct cpumask *mask;
};

/* Internal represention of a Flow Steering rule */
struct mvpp2_rfs_rule {
	/* Rule location inside the flow*/
	int loc;

	/* Flow type, such as TCP_V4_FLOW, IP6_FLOW, etc. */
	int flow_type;

	/* Index of the C2 TCAM entry handling this rule */
	int c2_index;

	/* Header fields that needs to be extracted to match this flow */
	u16 hek_fields;

	/* CLS engine : only c2 is supported for now. */
	u8 engine;

	/* TCAM key and mask for C2-based steering. These fields should be
	 * encapsulated in a union should we add more engines.
	 */
	u64 c2_tcam;
	u64 c2_tcam_mask;

	struct flow_rule *flow;
};

struct mvpp2_ethtool_fs {
	struct mvpp2_rfs_rule rule;
	struct ethtool_rxnfc rxnfc;
};

struct mvpp2_port {
	u8 id;

@@ -883,6 +921,10 @@ struct mvpp2_port {

	/* RSS indirection table */
	u32 indir[MVPP22_RSS_TABLE_ENTRIES];

	/* List of steering rules active on that port */
	struct mvpp2_ethtool_fs *rfs_rules[MVPP2_N_RFS_RULES];
	int n_rfs_rules;
};

/* The mvpp2_tx_desc and mvpp2_rx_desc structures describe the