1
0
Fork 0

net: mvpp2: cls: Use iterators to go through the cls_table

The cls_table is a global read-only table containing the different
parameters that are used by various tables in the classifier. It
describes the links between the Header Parser, the decoding table and
the flow_table.

There are several possible way we want to iterate over that table,
depending on wich classifier engine we want to configure. For the Header
Parser, we want to iterate over each entry. For the Decoding table, we
want to iterate over each entry having a unique flow_id. Finally, when
configuring an ethtool flow, we want to iterate over each entry having a
unique flow_id and that has a given flow_type.

This commit introduces some iterator to both provide syntactic sugar and
also clarify the way we want to iterate over the table.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
hifive-unleashed-5.2
Maxime Chevallier 2019-03-27 09:44:14 +01:00 committed by David S. Miller
parent b607cc61be
commit e4bfb4aced
2 changed files with 25 additions and 8 deletions

View File

@ -625,14 +625,11 @@ static int mvpp2_port_rss_hash_opts_set(struct mvpp2_port *port, int flow_type,
int i, engine, flow_index;
u16 hash_opts;
for (i = 0; i < MVPP2_N_PRS_FLOWS; i++) {
for_each_cls_flow_id_with_type(i, flow_type) {
flow = mvpp2_cls_flow_get(i);
if (!flow)
return -EINVAL;
if (flow->flow_type != flow_type)
continue;
flow_index = MVPP2_PORT_FLOW_HASH_ENTRY(port->id,
flow->flow_id);
@ -714,14 +711,11 @@ static u16 mvpp2_port_rss_hash_opts_get(struct mvpp2_port *port, int flow_type)
int i, flow_index;
u16 hash_opts = 0;
for (i = 0; i < MVPP2_N_PRS_FLOWS; i++) {
for_each_cls_flow_id_with_type(i, flow_type) {
flow = mvpp2_cls_flow_get(i);
if (!flow)
return 0;
if (flow->flow_type != flow_type)
continue;
flow_index = MVPP2_PORT_FLOW_HASH_ENTRY(port->id,
flow->flow_id);

View File

@ -192,6 +192,29 @@ struct mvpp2_cls_flow {
#define MVPP2_PORT_FLOW_HASH_ENTRY(port, id) (MVPP2_FLOW_C2_ENTRY(id) + \
1 + (port))
/* Iterate on each classifier flow id. Sets 'i' to be the index of the first
* entry in the cls_flows table for each different flow_id.
* This relies on entries having the same flow_id in the cls_flows table being
* contiguous.
*/
#define for_each_cls_flow_id(i) \
for ((i) = 0; (i) < MVPP2_N_PRS_FLOWS; (i)++) \
if ((i) > 0 && \
cls_flows[(i)].flow_id == cls_flows[(i) - 1].flow_id) \
continue; \
else
/* Iterate on each classifier flow that has a given flow_type. Sets 'i' to be
* the index of the first entry in the cls_flow table for each different flow_id
* that has the given flow_type. This allows to operate on all flows that
* matches a given ethtool flow type.
*/
#define for_each_cls_flow_id_with_type(i, type) \
for_each_cls_flow_id((i)) \
if (cls_flows[(i)].flow_type != (type)) \
continue; \
else
struct mvpp2_cls_flow_entry {
u32 index;
u32 data[MVPP2_CLS_FLOWS_TBL_DATA_WORDS];