Skip to content

Commit ce09f91

Browse files
azaki1NipaLocal
authored and
NipaLocal
committed
ice: refactor the FD and RSS flow ID generation
The flow director and RSS blocks use separate methods to generate a unique 64 bit ID for the flow. This is not extendable, especially for the RSS that already uses all 64 bit space. Refactor the flow generation API so that the ID is generated within ice_flow_add_prof(). The FD and RSS blocks caches the generated ID for later use. Suggested-by: Dan Nowlin <[email protected]> Reviewed-by: Wojciech Drewek <[email protected]> Signed-off-by: Ahmed Zaki <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 7767080 commit ce09f91

File tree

8 files changed

+55
-81
lines changed

8 files changed

+55
-81
lines changed

drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c

+13-18
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,7 @@ void ice_fdir_rem_adq_chnl(struct ice_hw *hw, u16 vsi_idx)
302302
continue;
303303

304304
for (tun = 0; tun < ICE_FD_HW_SEG_MAX; tun++) {
305-
u64 prof_id;
306-
307-
prof_id = flow + tun * ICE_FLTR_PTYPE_MAX;
305+
u64 prof_id = prof->prof_id[tun];
308306

309307
for (i = 0; i < prof->cnt; i++) {
310308
if (prof->vsi_h[i] != vsi_idx)
@@ -362,10 +360,9 @@ ice_fdir_erase_flow_from_hw(struct ice_hw *hw, enum ice_block blk, int flow)
362360
return;
363361

364362
for (tun = 0; tun < ICE_FD_HW_SEG_MAX; tun++) {
365-
u64 prof_id;
363+
u64 prof_id = prof->prof_id[tun];
366364
int j;
367365

368-
prof_id = flow + tun * ICE_FLTR_PTYPE_MAX;
369366
for (j = 0; j < prof->cnt; j++) {
370367
u16 vsi_num;
371368

@@ -439,12 +436,10 @@ void ice_fdir_replay_flows(struct ice_hw *hw)
439436
for (tun = 0; tun < ICE_FD_HW_SEG_MAX; tun++) {
440437
struct ice_flow_prof *hw_prof;
441438
struct ice_fd_hw_prof *prof;
442-
u64 prof_id;
443439
int j;
444440

445441
prof = hw->fdir_prof[flow];
446-
prof_id = flow + tun * ICE_FLTR_PTYPE_MAX;
447-
ice_flow_add_prof(hw, ICE_BLK_FD, ICE_FLOW_RX, prof_id,
442+
ice_flow_add_prof(hw, ICE_BLK_FD, ICE_FLOW_RX,
448443
prof->fdir_seg[tun], TNL_SEG_CNT(tun),
449444
&hw_prof);
450445
for (j = 0; j < prof->cnt; j++) {
@@ -454,7 +449,7 @@ void ice_fdir_replay_flows(struct ice_hw *hw)
454449

455450
prio = ICE_FLOW_PRIO_NORMAL;
456451
err = ice_flow_add_entry(hw, ICE_BLK_FD,
457-
prof_id,
452+
hw_prof->id,
458453
prof->vsi_h[0],
459454
prof->vsi_h[j],
460455
prio, prof->fdir_seg,
@@ -464,6 +459,7 @@ void ice_fdir_replay_flows(struct ice_hw *hw)
464459
flow);
465460
continue;
466461
}
462+
prof->prof_id[tun] = hw_prof->id;
467463
prof->entry_h[j][tun] = entry_h;
468464
}
469465
}
@@ -638,7 +634,6 @@ ice_fdir_set_hw_fltr_rule(struct ice_pf *pf, struct ice_flow_seg_info *seg,
638634
u64 entry1_h = 0;
639635
u64 entry2_h = 0;
640636
bool del_last;
641-
u64 prof_id;
642637
int err;
643638
int idx;
644639

@@ -686,23 +681,23 @@ ice_fdir_set_hw_fltr_rule(struct ice_pf *pf, struct ice_flow_seg_info *seg,
686681
* That is the final parameters are 1 header (segment), no
687682
* actions (NULL) and zero actions 0.
688683
*/
689-
prof_id = flow + tun * ICE_FLTR_PTYPE_MAX;
690-
err = ice_flow_add_prof(hw, ICE_BLK_FD, ICE_FLOW_RX, prof_id, seg,
684+
err = ice_flow_add_prof(hw, ICE_BLK_FD, ICE_FLOW_RX, seg,
691685
TNL_SEG_CNT(tun), &prof);
692686
if (err)
693687
return err;
694-
err = ice_flow_add_entry(hw, ICE_BLK_FD, prof_id, main_vsi->idx,
688+
err = ice_flow_add_entry(hw, ICE_BLK_FD, prof->id, main_vsi->idx,
695689
main_vsi->idx, ICE_FLOW_PRIO_NORMAL,
696690
seg, &entry1_h);
697691
if (err)
698692
goto err_prof;
699-
err = ice_flow_add_entry(hw, ICE_BLK_FD, prof_id, main_vsi->idx,
693+
err = ice_flow_add_entry(hw, ICE_BLK_FD, prof->id, main_vsi->idx,
700694
ctrl_vsi->idx, ICE_FLOW_PRIO_NORMAL,
701695
seg, &entry2_h);
702696
if (err)
703697
goto err_entry;
704698

705699
hw_prof->fdir_seg[tun] = seg;
700+
hw_prof->prof_id[tun] = prof->id;
706701
hw_prof->entry_h[0][tun] = entry1_h;
707702
hw_prof->entry_h[1][tun] = entry2_h;
708703
hw_prof->vsi_h[0] = main_vsi->idx;
@@ -719,7 +714,7 @@ ice_fdir_set_hw_fltr_rule(struct ice_pf *pf, struct ice_flow_seg_info *seg,
719714

720715
entry1_h = 0;
721716
vsi_h = main_vsi->tc_map_vsi[idx]->idx;
722-
err = ice_flow_add_entry(hw, ICE_BLK_FD, prof_id,
717+
err = ice_flow_add_entry(hw, ICE_BLK_FD, prof->id,
723718
main_vsi->idx, vsi_h,
724719
ICE_FLOW_PRIO_NORMAL, seg,
725720
&entry1_h);
@@ -756,7 +751,7 @@ ice_fdir_set_hw_fltr_rule(struct ice_pf *pf, struct ice_flow_seg_info *seg,
756751

757752
if (!hw_prof->entry_h[idx][tun])
758753
continue;
759-
ice_rem_prof_id_flow(hw, ICE_BLK_FD, vsi_num, prof_id);
754+
ice_rem_prof_id_flow(hw, ICE_BLK_FD, vsi_num, prof->id);
760755
ice_flow_rem_entry(hw, ICE_BLK_FD, hw_prof->entry_h[idx][tun]);
761756
hw_prof->entry_h[idx][tun] = 0;
762757
if (del_last)
@@ -766,10 +761,10 @@ ice_fdir_set_hw_fltr_rule(struct ice_pf *pf, struct ice_flow_seg_info *seg,
766761
hw_prof->cnt = 0;
767762
err_entry:
768763
ice_rem_prof_id_flow(hw, ICE_BLK_FD,
769-
ice_get_hw_vsi_num(hw, main_vsi->idx), prof_id);
764+
ice_get_hw_vsi_num(hw, main_vsi->idx), prof->id);
770765
ice_flow_rem_entry(hw, ICE_BLK_FD, entry1_h);
771766
err_prof:
772-
ice_flow_rem_prof(hw, ICE_BLK_FD, prof_id);
767+
ice_flow_rem_prof(hw, ICE_BLK_FD, prof->id);
773768
dev_err(dev, "Failed to add filter. Flow director filters on each port must have the same input set.\n");
774769

775770
return err;

drivers/net/ethernet/intel/ice/ice_flex_pipe.c

+11
Original file line numberDiff line numberDiff line change
@@ -2118,6 +2118,7 @@ void ice_free_hw_tbls(struct ice_hw *hw)
21182118
devm_kfree(ice_hw_to_dev(hw), hw->blk[i].es.ref_count);
21192119
devm_kfree(ice_hw_to_dev(hw), hw->blk[i].es.written);
21202120
devm_kfree(ice_hw_to_dev(hw), hw->blk[i].es.mask_ena);
2121+
devm_kfree(ice_hw_to_dev(hw), hw->blk[i].prof_id.id);
21212122
}
21222123

21232124
list_for_each_entry_safe(r, rt, &hw->rss_list_head, l_entry) {
@@ -2150,6 +2151,7 @@ void ice_clear_hw_tbls(struct ice_hw *hw)
21502151

21512152
for (i = 0; i < ICE_BLK_COUNT; i++) {
21522153
struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir;
2154+
struct ice_prof_id *prof_id = &hw->blk[i].prof_id;
21532155
struct ice_prof_tcam *prof = &hw->blk[i].prof;
21542156
struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1;
21552157
struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2;
@@ -2180,6 +2182,8 @@ void ice_clear_hw_tbls(struct ice_hw *hw)
21802182
memset(es->ref_count, 0, es->count * sizeof(*es->ref_count));
21812183
memset(es->written, 0, es->count * sizeof(*es->written));
21822184
memset(es->mask_ena, 0, es->count * sizeof(*es->mask_ena));
2185+
2186+
memset(prof_id->id, 0, prof_id->count * sizeof(*prof_id->id));
21832187
}
21842188
}
21852189

@@ -2196,6 +2200,7 @@ int ice_init_hw_tbls(struct ice_hw *hw)
21962200
ice_init_all_prof_masks(hw);
21972201
for (i = 0; i < ICE_BLK_COUNT; i++) {
21982202
struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir;
2203+
struct ice_prof_id *prof_id = &hw->blk[i].prof_id;
21992204
struct ice_prof_tcam *prof = &hw->blk[i].prof;
22002205
struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1;
22012206
struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2;
@@ -2301,6 +2306,12 @@ int ice_init_hw_tbls(struct ice_hw *hw)
23012306
sizeof(*es->mask_ena), GFP_KERNEL);
23022307
if (!es->mask_ena)
23032308
goto err;
2309+
2310+
prof_id->count = blk_sizes[i].prof_id;
2311+
prof_id->id = devm_kcalloc(ice_hw_to_dev(hw), prof_id->count,
2312+
sizeof(*prof_id->id), GFP_KERNEL);
2313+
if (!prof_id->id)
2314+
goto err;
23042315
}
23052316
return 0;
23062317

drivers/net/ethernet/intel/ice/ice_flex_type.h

+6
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,16 @@ struct ice_masks {
304304
struct ice_mask masks[ICE_PROF_MASK_COUNT];
305305
};
306306

307+
struct ice_prof_id {
308+
unsigned long *id;
309+
int count;
310+
};
311+
307312
/* Tables per block */
308313
struct ice_blk_info {
309314
struct ice_xlt1 xlt1;
310315
struct ice_xlt2 xlt2;
316+
struct ice_prof_id prof_id;
311317
struct ice_prof_tcam prof;
312318
struct ice_prof_redir prof_redir;
313319
struct ice_es es;

drivers/net/ethernet/intel/ice/ice_flow.c

+13-34
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,6 @@ ice_flow_rem_entry_sync(struct ice_hw *hw, enum ice_block __always_unused blk,
13281328
* @hw: pointer to the HW struct
13291329
* @blk: classification stage
13301330
* @dir: flow direction
1331-
* @prof_id: unique ID to identify this flow profile
13321331
* @segs: array of one or more packet segments that describe the flow
13331332
* @segs_cnt: number of packet segments provided
13341333
* @prof: stores the returned flow profile added
@@ -1337,17 +1336,24 @@ ice_flow_rem_entry_sync(struct ice_hw *hw, enum ice_block __always_unused blk,
13371336
*/
13381337
static int
13391338
ice_flow_add_prof_sync(struct ice_hw *hw, enum ice_block blk,
1340-
enum ice_flow_dir dir, u64 prof_id,
1339+
enum ice_flow_dir dir,
13411340
struct ice_flow_seg_info *segs, u8 segs_cnt,
13421341
struct ice_flow_prof **prof)
13431342
{
13441343
struct ice_flow_prof_params *params;
1344+
struct ice_prof_id *ids;
13451345
int status;
1346+
u64 prof_id;
13461347
u8 i;
13471348

13481349
if (!prof)
13491350
return -EINVAL;
13501351

1352+
ids = &hw->blk[blk].prof_id;
1353+
prof_id = find_first_zero_bit(ids->id, ids->count);
1354+
if (prof_id >= ids->count)
1355+
return -ENOSPC;
1356+
13511357
params = kzalloc(sizeof(*params), GFP_KERNEL);
13521358
if (!params)
13531359
return -ENOMEM;
@@ -1393,6 +1399,7 @@ ice_flow_add_prof_sync(struct ice_hw *hw, enum ice_block blk,
13931399

13941400
INIT_LIST_HEAD(&params->prof->entries);
13951401
mutex_init(&params->prof->entries_lock);
1402+
set_bit(prof_id, ids->id);
13961403
*prof = params->prof;
13971404

13981405
out:
@@ -1436,6 +1443,7 @@ ice_flow_rem_prof_sync(struct ice_hw *hw, enum ice_block blk,
14361443
/* Remove all hardware profiles associated with this flow profile */
14371444
status = ice_rem_prof(hw, blk, prof->id);
14381445
if (!status) {
1446+
clear_bit(prof->id, hw->blk[blk].prof_id.id);
14391447
list_del(&prof->l_entry);
14401448
mutex_destroy(&prof->entries_lock);
14411449
devm_kfree(ice_hw_to_dev(hw), prof);
@@ -1511,14 +1519,13 @@ ice_flow_disassoc_prof(struct ice_hw *hw, enum ice_block blk,
15111519
* @hw: pointer to the HW struct
15121520
* @blk: classification stage
15131521
* @dir: flow direction
1514-
* @prof_id: unique ID to identify this flow profile
15151522
* @segs: array of one or more packet segments that describe the flow
15161523
* @segs_cnt: number of packet segments provided
15171524
* @prof: stores the returned flow profile added
15181525
*/
15191526
int
15201527
ice_flow_add_prof(struct ice_hw *hw, enum ice_block blk, enum ice_flow_dir dir,
1521-
u64 prof_id, struct ice_flow_seg_info *segs, u8 segs_cnt,
1528+
struct ice_flow_seg_info *segs, u8 segs_cnt,
15221529
struct ice_flow_prof **prof)
15231530
{
15241531
int status;
@@ -1538,8 +1545,7 @@ ice_flow_add_prof(struct ice_hw *hw, enum ice_block blk, enum ice_flow_dir dir,
15381545

15391546
mutex_lock(&hw->fl_profs_locks[blk]);
15401547

1541-
status = ice_flow_add_prof_sync(hw, blk, dir, prof_id, segs, segs_cnt,
1542-
prof);
1548+
status = ice_flow_add_prof_sync(hw, blk, dir, segs, segs_cnt, prof);
15431549
if (!status)
15441550
list_add(&(*prof)->l_entry, &hw->fl_profs[blk]);
15451551

@@ -2066,28 +2072,6 @@ ice_add_rss_list(struct ice_hw *hw, u16 vsi_handle, struct ice_flow_prof *prof)
20662072
return 0;
20672073
}
20682074

2069-
#define ICE_FLOW_PROF_HASH_S 0
2070-
#define ICE_FLOW_PROF_HASH_M GENMASK_ULL(31, 0)
2071-
#define ICE_FLOW_PROF_HDR_S 32
2072-
#define ICE_FLOW_PROF_HDR_M GENMASK_ULL(61, 32)
2073-
#define ICE_FLOW_PROF_ENCAP_S 62
2074-
#define ICE_FLOW_PROF_ENCAP_M GENMASK_ULL(63, 62)
2075-
2076-
/* Flow profile ID format:
2077-
* [0:31] - Packet match fields
2078-
* [32:61] - Protocol header
2079-
* [62:63] - Encapsulation flag:
2080-
* 0 if non-tunneled
2081-
* 1 if tunneled
2082-
* 2 for tunneled with outer ipv4
2083-
* 3 for tunneled with outer ipv6
2084-
*/
2085-
#define ICE_FLOW_GEN_PROFID(hash, hdr, encap) \
2086-
((u64)(((u64)(hash) & ICE_FLOW_PROF_HASH_M) | \
2087-
(((u64)(hdr) << ICE_FLOW_PROF_HDR_S) & ICE_FLOW_PROF_HDR_M) | \
2088-
(((u64)(encap) << ICE_FLOW_PROF_ENCAP_S) & \
2089-
ICE_FLOW_PROF_ENCAP_M)))
2090-
20912075
/**
20922076
* ice_add_rss_cfg_sync - add an RSS configuration
20932077
* @hw: pointer to the hardware structure
@@ -2165,13 +2149,8 @@ ice_add_rss_cfg_sync(struct ice_hw *hw, u16 vsi_handle,
21652149
goto exit;
21662150
}
21672151

2168-
/* Create a new flow profile with generated profile and packet
2169-
* segment information.
2170-
*/
2152+
/* Create a new flow profile with packet segment information. */
21712153
status = ice_flow_add_prof(hw, blk, ICE_FLOW_RX,
2172-
ICE_FLOW_GEN_PROFID(cfg->hash_flds,
2173-
segs[segs_cnt - 1].hdrs,
2174-
cfg->hdr_type),
21752154
segs, segs_cnt, &prof);
21762155
if (status)
21772156
goto exit;

drivers/net/ethernet/intel/ice/ice_flow.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ struct ice_rss_cfg {
403403

404404
int
405405
ice_flow_add_prof(struct ice_hw *hw, enum ice_block blk, enum ice_flow_dir dir,
406-
u64 prof_id, struct ice_flow_seg_info *segs, u8 segs_cnt,
406+
struct ice_flow_seg_info *segs, u8 segs_cnt,
407407
struct ice_flow_prof **prof);
408408
int ice_flow_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id);
409409
int

drivers/net/ethernet/intel/ice/ice_main.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -8147,13 +8147,12 @@ static int ice_add_vsi_to_fdir(struct ice_pf *pf, struct ice_vsi *vsi)
81478147

81488148
for (tun = 0; tun < ICE_FD_HW_SEG_MAX; tun++) {
81498149
enum ice_flow_priority prio;
8150-
u64 prof_id;
81518150

81528151
/* add this VSI to FDir profile for this flow */
81538152
prio = ICE_FLOW_PRIO_NORMAL;
81548153
prof = hw->fdir_prof[flow];
8155-
prof_id = flow + tun * ICE_FLTR_PTYPE_MAX;
8156-
status = ice_flow_add_entry(hw, ICE_BLK_FD, prof_id,
8154+
status = ice_flow_add_entry(hw, ICE_BLK_FD,
8155+
prof->prof_id[tun],
81578156
prof->vsi_h[0], vsi->idx,
81588157
prio, prof->fdir_seg[tun],
81598158
&entry_h);

drivers/net/ethernet/intel/ice/ice_type.h

+1
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ struct ice_fd_hw_prof {
246246
int cnt;
247247
u64 entry_h[ICE_MAX_FDIR_VSI_PER_FILTER][ICE_FD_HW_SEG_MAX];
248248
u16 vsi_h[ICE_MAX_FDIR_VSI_PER_FILTER];
249+
u64 prof_id[ICE_FD_HW_SEG_MAX];
249250
};
250251

251252
/* Common HW capabilities for SW use */

0 commit comments

Comments
 (0)