Lines Matching refs:rule
10 struct sja1105_rule *rule;
12 list_for_each_entry(rule, &priv->flow_block.rules, list)
13 if (rule->cookie == cookie)
14 return rule;
36 struct sja1105_rule *rule = sja1105_rule_find(priv, cookie);
43 if (!rule) {
44 rule = kzalloc(sizeof(*rule), GFP_KERNEL);
45 if (!rule)
48 rule->cookie = cookie;
49 rule->type = SJA1105_RULE_BCAST_POLICER;
50 rule->bcast_pol.sharindx = sja1105_find_free_l2_policer(priv);
51 rule->key.type = SJA1105_KEY_BCAST;
55 if (rule->bcast_pol.sharindx == -1) {
70 rule->port_mask |= BIT(port);
75 for_each_set_bit(p, &rule->port_mask, SJA1105_MAX_NUM_PORTS) {
78 policing[bcast].sharindx = rule->bcast_pol.sharindx;
81 policing[rule->bcast_pol.sharindx].rate = div_u64(rate_bytes_per_sec *
83 policing[rule->bcast_pol.sharindx].smax = burst;
86 policing[rule->bcast_pol.sharindx].maxlen = VLAN_ETH_FRAME_LEN +
93 priv->flow_block.l2_policer_used[rule->bcast_pol.sharindx] = true;
94 list_add(&rule->list, &priv->flow_block.rules);
96 kfree(rule);
108 struct sja1105_rule *rule = sja1105_rule_find(priv, cookie);
114 if (!rule) {
115 rule = kzalloc(sizeof(*rule), GFP_KERNEL);
116 if (!rule)
119 rule->cookie = cookie;
120 rule->type = SJA1105_RULE_TC_POLICER;
121 rule->tc_pol.sharindx = sja1105_find_free_l2_policer(priv);
122 rule->key.type = SJA1105_KEY_TC;
123 rule->key.tc.pcp = tc;
127 if (rule->tc_pol.sharindx == -1) {
142 rule->port_mask |= BIT(port);
147 for_each_set_bit(p, &rule->port_mask, SJA1105_MAX_NUM_PORTS) {
150 policing[index].sharindx = rule->tc_pol.sharindx;
153 policing[rule->tc_pol.sharindx].rate = div_u64(rate_bytes_per_sec *
155 policing[rule->tc_pol.sharindx].smax = burst;
158 policing[rule->tc_pol.sharindx].maxlen = VLAN_ETH_FRAME_LEN +
165 priv->flow_block.l2_policer_used[rule->tc_pol.sharindx] = true;
166 list_add(&rule->list, &priv->flow_block.rules);
168 kfree(rule);
200 struct flow_rule *rule = flow_cls_offload_flow_rule(cls);
201 struct flow_dissector *dissector = rule->match.dissector;
217 if (flow_rule_match_has_control_flags(rule, extack))
220 if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {
223 flow_rule_match_basic(rule, &match);
231 if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
236 flow_rule_match_eth_addrs(rule, &match);
255 if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN)) {
258 flow_rule_match_vlan(rule, &match);
349 struct flow_rule *rule = flow_cls_offload_flow_rule(cls);
364 flow_action_for_each(i, act, &rule->action) {
367 rc = sja1105_policer_validate(&rule->action, act, extack);
466 struct sja1105_rule *rule = sja1105_rule_find(priv, cls->cookie);
470 if (!rule)
473 if (rule->type == SJA1105_RULE_VL)
474 return sja1105_vl_delete(priv, port, rule, cls->common.extack);
478 if (rule->type == SJA1105_RULE_BCAST_POLICER) {
483 } else if (rule->type == SJA1105_RULE_TC_POLICER) {
484 int index = (port * SJA1105_NUM_TC) + rule->key.tc.pcp;
492 rule->port_mask &= ~BIT(port);
493 if (!rule->port_mask) {
495 list_del(&rule->list);
496 kfree(rule);
506 struct sja1105_rule *rule = sja1105_rule_find(priv, cls->cookie);
509 if (!rule)
512 if (rule->type != SJA1105_RULE_VL)
515 rc = sja1105_vl_stats(priv, port, rule, &cls->stats,
537 struct sja1105_rule *rule;
541 rule = list_entry(pos, struct sja1105_rule, list);
542 list_del(&rule->list);
543 kfree(rule);