Skip to content

Commit 64730e9

Browse files
hechaoyongferruhy
authored andcommitted
net/nfp: prepare for flow merge
Move data structure and macro from source file to header file. Export the needed function to header file. We add two more parameter for 'nfp_flow_process()' to prepare for the flow merge. The 'cookie' moved as parameter is because the flow merge logic need this cookie. The 'install' parameter is needed because in flow merge, some flow are not need install to the hardware. Signed-off-by: Chaoyong He <[email protected]>
1 parent b79d825 commit 64730e9

File tree

2 files changed

+50
-23
lines changed

2 files changed

+50
-23
lines changed

drivers/net/nfp/nfp_flow.c

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@
8989
/* Tunnel ports */
9090
#define NFP_FL_PORT_TYPE_TUN 0x50000000
9191

92-
/*
93-
* Maximum number of items in struct rte_flow_action_vxlan_encap.
94-
* ETH / IPv4(6) / UDP / VXLAN / END
95-
*/
96-
#define ACTION_VXLAN_ENCAP_ITEMS_NUM 5
97-
98-
struct vxlan_data {
99-
struct rte_flow_action_vxlan_encap conf;
100-
struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
101-
};
102-
10392
/* Static initializer for a list of subsequent item types */
10493
#define NEXT_ITEM(...) \
10594
((const enum rte_flow_item_type []){ \
@@ -359,7 +348,7 @@ nfp_check_mask_remove(struct nfp_flow_priv *priv,
359348
return true;
360349
}
361350

362-
static int
351+
int
363352
nfp_flow_table_add(struct nfp_flow_priv *priv,
364353
struct rte_flow *nfp_flow)
365354
{
@@ -440,7 +429,7 @@ nfp_flow_alloc(struct nfp_fl_key_ls *key_layer, uint32_t port_id)
440429
return NULL;
441430
}
442431

443-
static void
432+
void
444433
nfp_flow_free(struct rte_flow *nfp_flow)
445434
{
446435
rte_free(nfp_flow->payload.meta);
@@ -721,7 +710,8 @@ static void
721710
nfp_flow_compile_metadata(struct nfp_flow_priv *priv,
722711
struct rte_flow *nfp_flow,
723712
struct nfp_fl_key_ls *key_layer,
724-
uint32_t stats_ctx)
713+
uint32_t stats_ctx,
714+
uint64_t cookie)
725715
{
726716
struct nfp_fl_rule_metadata *nfp_flow_meta;
727717
char *mbuf_off_exact;
@@ -737,7 +727,7 @@ nfp_flow_compile_metadata(struct nfp_flow_priv *priv,
737727
nfp_flow_meta->act_len = key_layer->act_size >> NFP_FL_LW_SIZ;
738728
nfp_flow_meta->flags = 0;
739729
nfp_flow_meta->host_ctx_id = rte_cpu_to_be_32(stats_ctx);
740-
nfp_flow_meta->host_cookie = rte_rand();
730+
nfp_flow_meta->host_cookie = rte_cpu_to_be_64(cookie);
741731
nfp_flow_meta->flow_version = rte_cpu_to_be_64(priv->flower_version);
742732

743733
mbuf_off_exact = nfp_flow->payload.unmasked_data;
@@ -1958,7 +1948,7 @@ nfp_flow_is_tun_item(const struct rte_flow_item *item)
19581948
return false;
19591949
}
19601950

1961-
static bool
1951+
bool
19621952
nfp_flow_inner_item_get(const struct rte_flow_item items[],
19631953
const struct rte_flow_item **inner_item)
19641954
{
@@ -3650,11 +3640,13 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor,
36503640
return 0;
36513641
}
36523642

3653-
static struct rte_flow *
3643+
struct rte_flow *
36543644
nfp_flow_process(struct nfp_flower_representor *representor,
36553645
const struct rte_flow_item items[],
36563646
const struct rte_flow_action actions[],
3657-
bool validate_flag)
3647+
bool validate_flag,
3648+
uint64_t cookie,
3649+
bool install_flag)
36583650
{
36593651
int ret;
36603652
char *hash_data;
@@ -3690,9 +3682,9 @@ nfp_flow_process(struct nfp_flower_representor *representor,
36903682
goto free_stats;
36913683
}
36923684

3693-
nfp_flow->install_flag = true;
3685+
nfp_flow->install_flag = install_flag;
36943686

3695-
nfp_flow_compile_metadata(priv, nfp_flow, &key_layer, stats_ctx);
3687+
nfp_flow_compile_metadata(priv, nfp_flow, &key_layer, stats_ctx, cookie);
36963688

36973689
ret = nfp_flow_compile_items(representor, items, nfp_flow);
36983690
if (ret != 0) {
@@ -3755,6 +3747,8 @@ nfp_flow_setup(struct nfp_flower_representor *representor,
37553747
__rte_unused struct rte_flow_error *error,
37563748
bool validate_flag)
37573749
{
3750+
uint64_t cookie;
3751+
37583752
if (attr->group != 0)
37593753
PMD_DRV_LOG(INFO, "Pretend we support group attribute.");
37603754

@@ -3764,10 +3758,12 @@ nfp_flow_setup(struct nfp_flower_representor *representor,
37643758
if (attr->transfer != 0)
37653759
PMD_DRV_LOG(INFO, "Pretend we support transfer attribute.");
37663760

3767-
return nfp_flow_process(representor, items, actions, validate_flag);
3761+
cookie = rte_rand();
3762+
3763+
return nfp_flow_process(representor, items, actions, validate_flag, cookie, true);
37683764
}
37693765

3770-
static int
3766+
int
37713767
nfp_flow_teardown(struct nfp_flow_priv *priv,
37723768
struct rte_flow *nfp_flow,
37733769
bool validate_flag)
@@ -3895,7 +3891,7 @@ nfp_flow_create(struct rte_eth_dev *dev,
38953891
return NULL;
38963892
}
38973893

3898-
static int
3894+
int
38993895
nfp_flow_destroy(struct rte_eth_dev *dev,
39003896
struct rte_flow *nfp_flow,
39013897
struct rte_flow_error *error)

drivers/net/nfp/nfp_flow.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@
1111
/* The firmware expects lengths in units of long words */
1212
#define NFP_FL_LW_SIZ 2
1313

14+
/*
15+
* Maximum number of items in struct rte_flow_action_vxlan_encap.
16+
* ETH / IPv4(6) / UDP / VXLAN / END
17+
*/
18+
#define ACTION_VXLAN_ENCAP_ITEMS_NUM 5
19+
20+
struct vxlan_data {
21+
struct rte_flow_action_vxlan_encap conf;
22+
struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
23+
};
24+
1425
enum nfp_flower_tun_type {
1526
NFP_FL_TUN_NONE = 0,
1627
NFP_FL_TUN_GRE = 1,
@@ -153,8 +164,28 @@ struct rte_flow {
153164
enum nfp_flow_type type;
154165
};
155166

167+
/* Forward declaration */
168+
struct nfp_flower_representor;
169+
156170
int nfp_flow_priv_init(struct nfp_pf_dev *pf_dev);
157171
void nfp_flow_priv_uninit(struct nfp_pf_dev *pf_dev);
158172
int nfp_net_flow_ops_get(struct rte_eth_dev *dev, const struct rte_flow_ops **ops);
173+
bool nfp_flow_inner_item_get(const struct rte_flow_item items[],
174+
const struct rte_flow_item **inner_item);
175+
struct rte_flow *nfp_flow_process(struct nfp_flower_representor *representor,
176+
const struct rte_flow_item items[],
177+
const struct rte_flow_action actions[],
178+
bool validate_flag,
179+
uint64_t cookie,
180+
bool install_flag);
181+
int nfp_flow_table_add(struct nfp_flow_priv *priv,
182+
struct rte_flow *nfp_flow);
183+
int nfp_flow_teardown(struct nfp_flow_priv *priv,
184+
struct rte_flow *nfp_flow,
185+
bool validate_flag);
186+
void nfp_flow_free(struct rte_flow *nfp_flow);
187+
int nfp_flow_destroy(struct rte_eth_dev *dev,
188+
struct rte_flow *nfp_flow,
189+
struct rte_flow_error *error);
159190

160191
#endif /* _NFP_FLOW_H_ */

0 commit comments

Comments
 (0)