Skip to content

Commit e10989e

Browse files
Marcin Szycikanguy11
authored andcommitted
ice: Add tracepoint for adding and removing switch rules
Track the number of rules and recipes added to switch. Add a tracepoint to ice_aq_sw_rules(), which shows both rule and recipe count. This information can be helpful when designing a set of rules to program to the hardware, as it shows where the practical limit is. Actual limits are known (64 recipes, 32k rules), but it's hard to translate these values to how many rules the *user* can actually create, because of extra metadata being implicitly added, and recipe/rule chaining. Chaining combines several recipes/rules to create a larger recipe/rule, so one large rule added by the user might actually consume multiple rules from hardware perspective. Rule counter is simply incremented/decremented in ice_aq_sw_rules(), since all rules are added or removed via it. Counting recipes is harder, as recipes can't be removed (only overwritten). Recipes added via ice_aq_add_recipe() could end up being unused, when there is an error in later stages of rule creation. Instead, track the allocation and freeing of recipes, which should reflect the actual usage of recipes (if something fails after recipe(s) were created, caller should free them). Also, a number of recipes are loaded from NVM by default - initialize the recipe counter with the number of these recipes on switch initialization. Example configuration: cd /sys/kernel/tracing echo function > current_tracer echo ice_aq_sw_rules > set_ftrace_filter echo ice_aq_sw_rules > set_event echo 1 > tracing_on cat trace Example output: tc-4097 [069] ...1. 787.595536: ice_aq_sw_rules <-ice_rem_adv_rule tc-4097 [069] ..... 787.595705: ice_aq_sw_rules: rules=9 recipes=15 tc-4098 [057] ...1. 787.652033: ice_aq_sw_rules <-ice_add_adv_rule tc-4098 [057] ..... 787.652201: ice_aq_sw_rules: rules=10 recipes=16 Reviewed-by: Michal Swiatkowski <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Signed-off-by: Marcin Szycik <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Sujai Buvaneswaran <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 1d2ac12 commit e10989e

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,9 @@ static int ice_init_fltr_mgmt_struct(struct ice_hw *hw)
934934
INIT_LIST_HEAD(&sw->vsi_list_map_head);
935935
sw->prof_res_bm_init = 0;
936936

937+
/* Initialize recipe count with default recipes read from NVM */
938+
sw->recp_cnt = ICE_SW_LKUP_LAST;
939+
937940
status = ice_init_def_sw_recp(hw);
938941
if (status) {
939942
devm_kfree(ice_hw_to_dev(hw), hw->switch_info);

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "ice_lib.h"
55
#include "ice_switch.h"
6+
#include "ice_trace.h"
67

78
#define ICE_ETH_DA_OFFSET 0
89
#define ICE_ETH_ETHTYPE_OFFSET 12
@@ -1961,6 +1962,15 @@ ice_aq_sw_rules(struct ice_hw *hw, void *rule_list, u16 rule_list_sz,
19611962
hw->adminq.sq_last_status == ICE_AQ_RC_ENOENT)
19621963
status = -ENOENT;
19631964

1965+
if (!status) {
1966+
if (opc == ice_aqc_opc_add_sw_rules)
1967+
hw->switch_info->rule_cnt += num_rules;
1968+
else if (opc == ice_aqc_opc_remove_sw_rules)
1969+
hw->switch_info->rule_cnt -= num_rules;
1970+
}
1971+
1972+
trace_ice_aq_sw_rules(hw->switch_info);
1973+
19641974
return status;
19651975
}
19661976

@@ -2181,8 +2191,10 @@ int ice_alloc_recipe(struct ice_hw *hw, u16 *rid)
21812191
sw_buf->res_type = cpu_to_le16(res_type);
21822192
status = ice_aq_alloc_free_res(hw, sw_buf, buf_len,
21832193
ice_aqc_opc_alloc_res);
2184-
if (!status)
2194+
if (!status) {
21852195
*rid = le16_to_cpu(sw_buf->elem[0].e.sw_resp);
2196+
hw->switch_info->recp_cnt++;
2197+
}
21862198

21872199
return status;
21882200
}
@@ -2196,7 +2208,13 @@ int ice_alloc_recipe(struct ice_hw *hw, u16 *rid)
21962208
*/
21972209
static int ice_free_recipe_res(struct ice_hw *hw, u16 rid)
21982210
{
2199-
return ice_free_hw_res(hw, ICE_AQC_RES_TYPE_RECIPE, 1, &rid);
2211+
int status;
2212+
2213+
status = ice_free_hw_res(hw, ICE_AQC_RES_TYPE_RECIPE, 1, &rid);
2214+
if (!status)
2215+
hw->switch_info->recp_cnt--;
2216+
2217+
return status;
22002218
}
22012219

22022220
/**

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,24 @@ DEFINE_EVENT(ice_esw_br_port_template,
330330
TP_ARGS(port)
331331
);
332332

333+
DECLARE_EVENT_CLASS(ice_switch_stats_template,
334+
TP_PROTO(struct ice_switch_info *sw_info),
335+
TP_ARGS(sw_info),
336+
TP_STRUCT__entry(__field(u16, rule_cnt)
337+
__field(u8, recp_cnt)),
338+
TP_fast_assign(__entry->rule_cnt = sw_info->rule_cnt;
339+
__entry->recp_cnt = sw_info->recp_cnt;),
340+
TP_printk("rules=%u recipes=%u",
341+
__entry->rule_cnt,
342+
__entry->recp_cnt)
343+
);
344+
345+
DEFINE_EVENT(ice_switch_stats_template,
346+
ice_aq_sw_rules,
347+
TP_PROTO(struct ice_switch_info *sw_info),
348+
TP_ARGS(sw_info)
349+
);
350+
333351
/* End tracepoints */
334352

335353
#endif /* _ICE_TRACE_H_ */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ struct ice_switch_info {
761761
struct ice_sw_recipe *recp_list;
762762
u16 prof_res_bm_init;
763763
u16 max_used_prof_index;
764+
u16 rule_cnt;
765+
u8 recp_cnt;
764766

765767
DECLARE_BITMAP(prof_res_bm[ICE_MAX_NUM_PROFILES], ICE_MAX_FV_WORDS);
766768
};

0 commit comments

Comments
 (0)