Skip to content

Commit

Permalink
Merge branch 'net-mvpp2-cls-Add-classification'
Browse files Browse the repository at this point in the history
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/[email protected]/

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: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed May 1, 2019
2 parents 2a369ae + bec2d46 commit f76c4b5
Show file tree
Hide file tree
Showing 4 changed files with 545 additions and 84 deletions.
42 changes: 42 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 All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit f76c4b5

Please sign in to comment.