Skip to content

Commit f76c4b5

Browse files
committed
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/[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]>
2 parents 2a369ae + bec2d46 commit f76c4b5

File tree

4 files changed

+545
-84
lines changed

4 files changed

+545
-84
lines changed

drivers/net/ethernet/marvell/mvpp2/mvpp2.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/netdevice.h>
1515
#include <linux/phy.h>
1616
#include <linux/phylink.h>
17+
#include <net/flow_offload.h>
1718

1819
/* Fifo Registers */
1920
#define MVPP2_RX_DATA_FIFO_SIZE_REG(port) (0x00 + 4 * (port))
@@ -126,6 +127,7 @@
126127
#define MVPP22_CLS_C2_TCAM_DATA4 0x1b20
127128
#define MVPP22_CLS_C2_LU_TYPE(lu) ((lu) & 0x3f)
128129
#define MVPP22_CLS_C2_PORT_ID(port) ((port) << 8)
130+
#define MVPP22_CLS_C2_PORT_MASK (0xff << 8)
129131
#define MVPP22_CLS_C2_TCAM_INV 0x1b24
130132
#define MVPP22_CLS_C2_TCAM_INV_BIT BIT(31)
131133
#define MVPP22_CLS_C2_HIT_CTR 0x1b50
@@ -134,6 +136,7 @@
134136
#define MVPP22_CLS_C2_ACT_FWD(act) (((act) & 0x7) << 13)
135137
#define MVPP22_CLS_C2_ACT_QHIGH(act) (((act) & 0x3) << 11)
136138
#define MVPP22_CLS_C2_ACT_QLOW(act) (((act) & 0x3) << 9)
139+
#define MVPP22_CLS_C2_ACT_COLOR(act) ((act) & 0x7)
137140
#define MVPP22_CLS_C2_ATTR0 0x1b64
138141
#define MVPP22_CLS_C2_ATTR0_QHIGH(qh) (((qh) & 0x1f) << 24)
139142
#define MVPP22_CLS_C2_ATTR0_QHIGH_MASK 0x1f
@@ -615,6 +618,10 @@
615618
#define MVPP2_BIT_IN_WORD(bit) ((bit) % 32)
616619

617620
#define MVPP2_N_PRS_FLOWS 52
621+
#define MVPP2_N_RFS_ENTRIES_PER_FLOW 4
622+
623+
/* There are 7 supported high-level flows */
624+
#define MVPP2_N_RFS_RULES (MVPP2_N_RFS_ENTRIES_PER_FLOW * 7)
618625

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

822+
/* Internal represention of a Flow Steering rule */
823+
struct mvpp2_rfs_rule {
824+
/* Rule location inside the flow*/
825+
int loc;
826+
827+
/* Flow type, such as TCP_V4_FLOW, IP6_FLOW, etc. */
828+
int flow_type;
829+
830+
/* Index of the C2 TCAM entry handling this rule */
831+
int c2_index;
832+
833+
/* Header fields that needs to be extracted to match this flow */
834+
u16 hek_fields;
835+
836+
/* CLS engine : only c2 is supported for now. */
837+
u8 engine;
838+
839+
/* TCAM key and mask for C2-based steering. These fields should be
840+
* encapsulated in a union should we add more engines.
841+
*/
842+
u64 c2_tcam;
843+
u64 c2_tcam_mask;
844+
845+
struct flow_rule *flow;
846+
};
847+
848+
struct mvpp2_ethtool_fs {
849+
struct mvpp2_rfs_rule rule;
850+
struct ethtool_rxnfc rxnfc;
851+
};
852+
815853
struct mvpp2_port {
816854
u8 id;
817855

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

884922
/* RSS indirection table */
885923
u32 indir[MVPP22_RSS_TABLE_ENTRIES];
924+
925+
/* List of steering rules active on that port */
926+
struct mvpp2_ethtool_fs *rfs_rules[MVPP2_N_RFS_RULES];
927+
int n_rfs_rules;
886928
};
887929

888930
/* The mvpp2_tx_desc and mvpp2_rx_desc structures describe the

0 commit comments

Comments
 (0)