Skip to content

Commit 0107bd5

Browse files
hechaoyongferruhy
authored andcommitted
net/nfp: support different flow steering rules limit
Get the flow steering rules limit from the firmware rather than the hard coded. Signed-off-by: Chaoyong He <[email protected]> Reviewed-by: Long Wu <[email protected]>
1 parent b53b2e2 commit 0107bd5

File tree

3 files changed

+47
-11
lines changed

3 files changed

+47
-11
lines changed

drivers/common/nfp/nfp_common_ctrl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ struct nfp_net_fw_ver {
219219
#define NFP_NET_CFG_CAP_WORD1 0x00a4
220220

221221
/* 16B reserved for future use (0x00b0 - 0x00c0). */
222-
#define NFP_NET_CFG_RESERVED 0x00b0
223-
#define NFP_NET_CFG_RESERVED_SZ 0x0010
222+
#define NFP_NET_CFG_MAX_FS_CAP 0x00b8
224223

225224
/*
226225
* RSS configuration (0x0100 - 0x01ac):

drivers/net/nfp/nfp_net_common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ struct nfp_net_flow_count {
186186
};
187187

188188
#define NFP_NET_HASH_REDUNDANCE (1.2)
189-
#define NFP_NET_FLOW_HASH_TBALE_SIZE ((NFP_NET_FLOW_LIMIT) * (NFP_NET_HASH_REDUNDANCE))
190189

191190
struct nfp_net_priv {
192191
uint32_t hash_seed; /**< Hash seed for hash tables in this structure. */
193192
struct rte_hash *flow_table; /**< Hash table to store flow rules. */
194193
struct nfp_net_flow_count flow_count; /**< Flow count in hash table */
195-
bool flow_position[NFP_NET_FLOW_LIMIT]; /**< Flow position array */
194+
uint32_t flow_limit; /**< Flow limit of hash table */
195+
bool *flow_position; /**< Flow position array */
196196
};
197197

198198
struct nfp_app_fw_nic {

drivers/net/nfp/nfp_net_flow.c

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,12 @@ nfp_net_flow_position_acquire(struct nfp_net_priv *priv,
8888
struct rte_flow *nfp_flow)
8989
{
9090
uint32_t i;
91+
uint32_t limit;
92+
93+
limit = priv->flow_limit;
9194

9295
if (priority != 0) {
93-
i = NFP_NET_FLOW_LIMIT - priority - 1;
96+
i = limit - priority - 1;
9497

9598
if (priv->flow_position[i]) {
9699
PMD_DRV_LOG(ERR, "There is already a flow rule in this place.");
@@ -102,19 +105,19 @@ nfp_net_flow_position_acquire(struct nfp_net_priv *priv,
102105
return 0;
103106
}
104107

105-
for (i = 0; i < NFP_NET_FLOW_LIMIT; i++) {
108+
for (i = 0; i < limit; i++) {
106109
if (!priv->flow_position[i]) {
107110
priv->flow_position[i] = true;
108111
break;
109112
}
110113
}
111114

112-
if (i == NFP_NET_FLOW_LIMIT) {
115+
if (i == limit) {
113116
PMD_DRV_LOG(ERR, "The limited flow number is reach.");
114117
return -ERANGE;
115118
}
116119

117-
nfp_flow->position = NFP_NET_FLOW_LIMIT - i - 1;
120+
nfp_flow->position = limit - i - 1;
118121

119122
return 0;
120123
}
@@ -1053,11 +1056,24 @@ nfp_net_flow_ops_get(struct rte_eth_dev *dev,
10531056
return 0;
10541057
}
10551058

1059+
static uint32_t
1060+
nfp_net_fs_max_entry_get(struct nfp_hw *hw)
1061+
{
1062+
uint32_t cnt;
1063+
1064+
cnt = nn_cfg_readl(hw, NFP_NET_CFG_MAX_FS_CAP);
1065+
if (cnt != 0)
1066+
return cnt;
1067+
1068+
return NFP_NET_FLOW_LIMIT;
1069+
}
1070+
10561071
int
10571072
nfp_net_flow_priv_init(struct nfp_pf_dev *pf_dev,
10581073
uint16_t port)
10591074
{
10601075
int ret = 0;
1076+
struct nfp_hw *hw;
10611077
struct nfp_net_priv *priv;
10621078
char flow_name[RTE_HASH_NAMESIZE];
10631079
struct nfp_app_fw_nic *app_fw_nic;
@@ -1067,7 +1083,6 @@ nfp_net_flow_priv_init(struct nfp_pf_dev *pf_dev,
10671083

10681084
struct rte_hash_parameters flow_hash_params = {
10691085
.name = flow_name,
1070-
.entries = NFP_NET_FLOW_HASH_TBALE_SIZE,
10711086
.hash_func = rte_jhash,
10721087
.socket_id = rte_socket_id(),
10731088
.key_len = sizeof(uint32_t),
@@ -1085,17 +1100,37 @@ nfp_net_flow_priv_init(struct nfp_pf_dev *pf_dev,
10851100
app_fw_nic->ports[port]->priv = priv;
10861101
priv->hash_seed = (uint32_t)rte_rand();
10871102

1103+
/* Flow limit */
1104+
hw = &app_fw_nic->ports[port]->super;
1105+
priv->flow_limit = nfp_net_fs_max_entry_get(hw);
1106+
if (priv->flow_limit == 0) {
1107+
PMD_INIT_LOG(ERR, "NFP app nic flow limit not right.");
1108+
ret = -EINVAL;
1109+
goto free_priv;
1110+
}
1111+
1112+
/* Flow position array */
1113+
priv->flow_position = rte_zmalloc(NULL, sizeof(bool) * priv->flow_limit, 0);
1114+
if (priv->flow_position == NULL) {
1115+
PMD_INIT_LOG(ERR, "NFP app nic flow position creation failed.");
1116+
ret = -ENOMEM;
1117+
goto free_priv;
1118+
}
1119+
10881120
/* Flow table */
10891121
flow_hash_params.hash_func_init_val = priv->hash_seed;
1122+
flow_hash_params.entries = priv->flow_limit * NFP_NET_HASH_REDUNDANCE;
10901123
priv->flow_table = rte_hash_create(&flow_hash_params);
10911124
if (priv->flow_table == NULL) {
10921125
PMD_INIT_LOG(ERR, "flow hash table creation failed");
10931126
ret = -ENOMEM;
1094-
goto free_priv;
1127+
goto free_flow_position;
10951128
}
10961129

10971130
return 0;
10981131

1132+
free_flow_position:
1133+
rte_free(priv->flow_position);
10991134
free_priv:
11001135
rte_free(priv);
11011136
exit:
@@ -1114,8 +1149,10 @@ nfp_net_flow_priv_uninit(struct nfp_pf_dev *pf_dev,
11141149

11151150
app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv);
11161151
priv = app_fw_nic->ports[port]->priv;
1117-
if (priv != NULL)
1152+
if (priv != NULL) {
11181153
rte_hash_free(priv->flow_table);
1154+
rte_free(priv->flow_position);
1155+
}
11191156

11201157
rte_free(priv);
11211158
}

0 commit comments

Comments
 (0)