Skip to content

Commit

Permalink
net: mvpp2: cls: Add Classification offload support
Browse files Browse the repository at this point in the history
This commit introduces basic classification offloading support for the
PPv2 controller.

The PPv2 classifier has many classification engines, for now we only use
the C2 TCAM match engine.

This engine allows to perform ternary lookups on 64 bits keys (called
Header Extracted Key), that are built by extracting fields from the packet
header and concatenating them. At most 4 fields can be extracted for a
single lookup.

This basic implementation allows to build the HEK from the following
fields :
 - L4 source and destination ports (for UDP and TCP)

More fields are to be added in the future.

Classification flows are added through the ethtool interface, using the
newly introduced flow_rule infrastructure as an internal rule
representation, allowing to more easily implement tc flower rules if
need be.

The internal design for now allocates one range of 4 rules per port
due to the internal design of the flow table, which uses 22 sub-flows.

When inserting a classification rule, the rule is created in every
relevant sub-flow.

This low rule-count is a very simple design which reaches quickly the
limitations of the flow table ordering, but guarantees that the rule
ordering will always be respected.

This commit only introduces support for the "steer to rxq" action.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Maxime Chevallier authored and David S. Miller committed May 1, 2019
1 parent 84e90b0 commit 90b509b
Show file tree
Hide file tree
Showing 4 changed files with 410 additions and 12 deletions.
41 changes: 41 additions & 0 deletions drivers/net/ethernet/marvell/mvpp2/mvpp2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -615,6 +617,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
Expand Down Expand Up @@ -812,6 +818,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;

Expand Down Expand Up @@ -883,6 +920,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
Expand Down
Loading

0 comments on commit 90b509b

Please sign in to comment.