Lines Matching +full:0 +full:- +full:indexed
1 // SPDX-License-Identifier: GPL-2.0
21 return -ENOMEM; in sja1105_insert_gate_entry()
23 e->rule = rule; in sja1105_insert_gate_entry()
24 e->gate_state = gate_state; in sja1105_insert_gate_entry()
25 e->interval = entry_time; in sja1105_insert_gate_entry()
27 if (list_empty(&gating_cfg->entries)) { in sja1105_insert_gate_entry()
28 list_add(&e->list, &gating_cfg->entries); in sja1105_insert_gate_entry()
32 list_for_each_entry(p, &gating_cfg->entries, list) { in sja1105_insert_gate_entry()
33 if (p->interval == e->interval) { in sja1105_insert_gate_entry()
36 rc = -EBUSY; in sja1105_insert_gate_entry()
40 if (e->interval < p->interval) in sja1105_insert_gate_entry()
43 list_add(&e->list, p->list.prev); in sja1105_insert_gate_entry()
46 gating_cfg->num_entries++; in sja1105_insert_gate_entry()
48 return 0; in sja1105_insert_gate_entry()
54 /* The gate entries contain absolute times in their e->interval field. Convert
55 * that to proper intervals (i.e. "0, 5, 10, 15" to "5, 5, 5, 5").
65 list_for_each_entry(e, &gating_cfg->entries, list) { in sja1105_gating_cfg_time_to_interval()
68 prev = e->list.prev; in sja1105_gating_cfg_time_to_interval()
70 if (prev == &gating_cfg->entries) in sja1105_gating_cfg_time_to_interval()
74 p->interval = e->interval - p->interval; in sja1105_gating_cfg_time_to_interval()
76 last_e = list_last_entry(&gating_cfg->entries, in sja1105_gating_cfg_time_to_interval()
78 last_e->interval = cycle_time - last_e->interval; in sja1105_gating_cfg_time_to_interval()
85 list_for_each_entry_safe(e, n, &gating_cfg->entries, list) { in sja1105_free_gating_config()
86 list_del(&e->list); in sja1105_free_gating_config()
94 struct sja1105_gating_config *gating_cfg = &priv->tas_data.gating_cfg; in sja1105_compose_gating_subschedule()
96 s64 max_cycle_time = 0; in sja1105_compose_gating_subschedule()
97 s64 its_base_time = 0; in sja1105_compose_gating_subschedule()
98 int i, rc = 0; in sja1105_compose_gating_subschedule()
102 list_for_each_entry(rule, &priv->flow_block.rules, list) { in sja1105_compose_gating_subschedule()
103 if (rule->type != SJA1105_RULE_VL) in sja1105_compose_gating_subschedule()
105 if (rule->vl.type != SJA1105_VL_TIME_TRIGGERED) in sja1105_compose_gating_subschedule()
108 if (max_cycle_time < rule->vl.cycle_time) { in sja1105_compose_gating_subschedule()
109 max_cycle_time = rule->vl.cycle_time; in sja1105_compose_gating_subschedule()
110 its_base_time = rule->vl.base_time; in sja1105_compose_gating_subschedule()
115 return 0; in sja1105_compose_gating_subschedule()
117 dev_dbg(priv->ds->dev, "max_cycle_time %lld its_base_time %lld\n", in sja1105_compose_gating_subschedule()
120 gating_cfg->base_time = its_base_time; in sja1105_compose_gating_subschedule()
121 gating_cfg->cycle_time = max_cycle_time; in sja1105_compose_gating_subschedule()
122 gating_cfg->num_entries = 0; in sja1105_compose_gating_subschedule()
124 list_for_each_entry(rule, &priv->flow_block.rules, list) { in sja1105_compose_gating_subschedule()
128 if (rule->type != SJA1105_RULE_VL) in sja1105_compose_gating_subschedule()
130 if (rule->vl.type != SJA1105_VL_TIME_TRIGGERED) in sja1105_compose_gating_subschedule()
137 rbt = future_base_time(rule->vl.base_time, rule->vl.cycle_time, in sja1105_compose_gating_subschedule()
139 rbt -= its_base_time; in sja1105_compose_gating_subschedule()
143 for (i = 0; i < rule->vl.num_entries; i++) { in sja1105_compose_gating_subschedule()
144 u8 gate_state = rule->vl.entries[i].gate_state; in sja1105_compose_gating_subschedule()
155 entry_time += rule->vl.cycle_time; in sja1105_compose_gating_subschedule()
157 time += rule->vl.entries[i].interval; in sja1105_compose_gating_subschedule()
163 return 0; in sja1105_compose_gating_subschedule()
171 * However it also has one other operating mode (VLLUPFORMAT=0) where it acts
172 * somewhat closer to a pre-standard implementation of IEEE 802.1Qci
173 * (Per-Stream Filtering and Policing), which is what the driver is going to be
177 * Key = {DMAC && VLANID +---------+ Key = { (DMAC[47:16] & VLMASK ==
179 * && INGRESS PORT} +---------+ (both fixed)
180 * (exact match, | && DMAC[15:0] == VLID
183 * ------------
184 * 0 (PSFP) / \ 1 (ARINC664)
185 * +-----------/ VLLUPFORMAT \----------+
188 * 0 (forwarding) v ------------ |
189 * ------------ |
191 * +---/ ISCRITICAL \-----------+ |
194 * v ------------ index of rule contents of rule
197 * | +---------+--------+
201 * | (indexed by VLID)
202 * | +---------+
203 * | +--------------| |
204 * | | select TYPE +---------+
206 * | 0 (rate ------------ 1 (time
208 * | +------/ TYPE \------------+
211 * | VL Policing ------------ VL Policing
212 * | (indexed by VLID) (indexed by VLID)
213 * | +---------+ +---------+
214 * | | TYPE=0 | | TYPE=1 |
215 * | +---------+ +---------+
217 * | to rate-limit re-enter VL Forwarding
221 * | select MAXLEN -> exceed => drop select MAXLEN -> exceed => drop
225 * | (indexed by SHARINDX) (indexed by SHARINDX)
226 * | +---------+ +---------+
227 * | | TYPE=0 | | TYPE=1 |
228 * | +---------+ +---------+
234 * | (indexed by SHARINDX) (indexed by SHARINDX)
235 * | +---------+ +---------+
236 * | | TYPE=0 | | TYPE=1 |
237 * | +---------+ +---------+
240 * | select BAG, -> exceed => drop |
242 * | | ----------------------------------------------
246 * | | +----/ \-+
251 * | | | ---------------------------------------------- |
258 * The per-port classification key is always composed of {DMAC, VID, PCP} and
259 * is non-maskable. This 'looks like' the NULL stream identification function
261 * ports operate as VLAN-unaware, we do allow the user to not specify the VLAN
262 * ID and PCP, and then the port-based defaults will be used.
269 * b. 'police': turn it into a rate-constrained VL, with bandwidth limitation
272 * c. 'gate': turn it into a time-triggered VL, which can be only be received
279 if (a->macaddr < b->macaddr) in sja1105_vl_key_lower()
281 if (a->macaddr > b->macaddr) in sja1105_vl_key_lower()
283 if (a->vlanid < b->vlanid) in sja1105_vl_key_lower()
285 if (a->vlanid > b->vlanid) in sja1105_vl_key_lower()
287 if (a->port < b->port) in sja1105_vl_key_lower()
289 if (a->port > b->port) in sja1105_vl_key_lower()
291 if (a->vlanprior < b->vlanprior) in sja1105_vl_key_lower()
293 if (a->vlanprior > b->vlanprior) in sja1105_vl_key_lower()
308 int num_virtual_links = 0; in sja1105_init_virtual_links()
309 int max_sharindx = 0; in sja1105_init_virtual_links()
313 list_for_each_entry(rule, &priv->flow_block.rules, list) { in sja1105_init_virtual_links()
314 if (rule->type != SJA1105_RULE_VL) in sja1105_init_virtual_links()
317 num_virtual_links += hweight_long(rule->port_mask); in sja1105_init_virtual_links()
319 if (rule->vl.type != SJA1105_VL_NONCRITICAL) in sja1105_init_virtual_links()
321 if (max_sharindx < rule->vl.sharindx) in sja1105_init_virtual_links()
322 max_sharindx = rule->vl.sharindx; in sja1105_init_virtual_links()
327 return -ENOSPC; in sja1105_init_virtual_links()
332 return -ENOSPC; in sja1105_init_virtual_links()
338 table = &priv->static_config.tables[BLK_IDX_VL_LOOKUP]; in sja1105_init_virtual_links()
339 if (table->entry_count) { in sja1105_init_virtual_links()
340 kfree(table->entries); in sja1105_init_virtual_links()
341 table->entry_count = 0; in sja1105_init_virtual_links()
345 table = &priv->static_config.tables[BLK_IDX_VL_POLICING]; in sja1105_init_virtual_links()
346 if (table->entry_count) { in sja1105_init_virtual_links()
347 kfree(table->entries); in sja1105_init_virtual_links()
348 table->entry_count = 0; in sja1105_init_virtual_links()
352 table = &priv->static_config.tables[BLK_IDX_VL_FORWARDING]; in sja1105_init_virtual_links()
353 if (table->entry_count) { in sja1105_init_virtual_links()
354 kfree(table->entries); in sja1105_init_virtual_links()
355 table->entry_count = 0; in sja1105_init_virtual_links()
359 table = &priv->static_config.tables[BLK_IDX_VL_FORWARDING_PARAMS]; in sja1105_init_virtual_links()
360 if (table->entry_count) { in sja1105_init_virtual_links()
361 kfree(table->entries); in sja1105_init_virtual_links()
362 table->entry_count = 0; in sja1105_init_virtual_links()
367 return 0; in sja1105_init_virtual_links()
369 /* Pre-allocate space in the static config tables */ in sja1105_init_virtual_links()
372 table = &priv->static_config.tables[BLK_IDX_VL_LOOKUP]; in sja1105_init_virtual_links()
373 table->entries = kcalloc(num_virtual_links, in sja1105_init_virtual_links()
374 table->ops->unpacked_entry_size, in sja1105_init_virtual_links()
376 if (!table->entries) in sja1105_init_virtual_links()
377 return -ENOMEM; in sja1105_init_virtual_links()
378 table->entry_count = num_virtual_links; in sja1105_init_virtual_links()
379 vl_lookup = table->entries; in sja1105_init_virtual_links()
381 k = 0; in sja1105_init_virtual_links()
383 list_for_each_entry(rule, &priv->flow_block.rules, list) { in sja1105_init_virtual_links()
386 if (rule->type != SJA1105_RULE_VL) in sja1105_init_virtual_links()
389 for_each_set_bit(port, &rule->port_mask, SJA1105_MAX_NUM_PORTS) { in sja1105_init_virtual_links()
392 vl_lookup[k].macaddr = rule->key.vl.dmac; in sja1105_init_virtual_links()
393 if (rule->key.type == SJA1105_KEY_VLAN_AWARE_VL) { in sja1105_init_virtual_links()
394 vl_lookup[k].vlanid = rule->key.vl.vid; in sja1105_init_virtual_links()
395 vl_lookup[k].vlanprior = rule->key.vl.pcp; in sja1105_init_virtual_links()
397 u16 vid = dsa_8021q_rx_vid(priv->ds, port); in sja1105_init_virtual_links()
400 vl_lookup[k].vlanprior = 0; in sja1105_init_virtual_links()
406 if (rule->vl.type == SJA1105_VL_NONCRITICAL) in sja1105_init_virtual_links()
407 vl_lookup[k].destports = rule->vl.destports; in sja1105_init_virtual_links()
410 vl_lookup[k].flow_cookie = rule->cookie; in sja1105_init_virtual_links()
420 for (i = 0; i < num_virtual_links; i++) { in sja1105_init_virtual_links()
436 return 0; in sja1105_init_virtual_links()
439 table = &priv->static_config.tables[BLK_IDX_VL_POLICING]; in sja1105_init_virtual_links()
440 table->entries = kcalloc(max_sharindx, table->ops->unpacked_entry_size, in sja1105_init_virtual_links()
442 if (!table->entries) in sja1105_init_virtual_links()
443 return -ENOMEM; in sja1105_init_virtual_links()
444 table->entry_count = max_sharindx; in sja1105_init_virtual_links()
445 vl_policing = table->entries; in sja1105_init_virtual_links()
448 table = &priv->static_config.tables[BLK_IDX_VL_FORWARDING]; in sja1105_init_virtual_links()
449 table->entries = kcalloc(max_sharindx, table->ops->unpacked_entry_size, in sja1105_init_virtual_links()
451 if (!table->entries) in sja1105_init_virtual_links()
452 return -ENOMEM; in sja1105_init_virtual_links()
453 table->entry_count = max_sharindx; in sja1105_init_virtual_links()
454 vl_fwd = table->entries; in sja1105_init_virtual_links()
457 table = &priv->static_config.tables[BLK_IDX_VL_FORWARDING_PARAMS]; in sja1105_init_virtual_links()
458 table->entries = kcalloc(1, table->ops->unpacked_entry_size, in sja1105_init_virtual_links()
460 if (!table->entries) in sja1105_init_virtual_links()
461 return -ENOMEM; in sja1105_init_virtual_links()
462 table->entry_count = 1; in sja1105_init_virtual_links()
464 for (i = 0; i < num_virtual_links; i++) { in sja1105_init_virtual_links()
468 if (rule->vl.type == SJA1105_VL_NONCRITICAL) in sja1105_init_virtual_links()
470 if (rule->vl.type == SJA1105_VL_TIME_TRIGGERED) { in sja1105_init_virtual_links()
471 int sharindx = rule->vl.sharindx; in sja1105_init_virtual_links()
475 vl_policing[i].maxlen = rule->vl.maxlen; in sja1105_init_virtual_links()
480 vl_fwd[sharindx].priority = rule->vl.ipv; in sja1105_init_virtual_links()
481 vl_fwd[sharindx].partition = 0; in sja1105_init_virtual_links()
482 vl_fwd[sharindx].destports = rule->vl.destports; in sja1105_init_virtual_links()
488 return 0; in sja1105_init_virtual_links()
499 if (!priv->vlan_aware && key->type != SJA1105_KEY_VLAN_UNAWARE_VL) { in sja1105_vl_redirect()
502 return -EOPNOTSUPP; in sja1105_vl_redirect()
503 } else if (priv->vlan_aware && key->type != SJA1105_KEY_VLAN_AWARE_VL) { in sja1105_vl_redirect()
506 return -EOPNOTSUPP; in sja1105_vl_redirect()
512 return -ENOMEM; in sja1105_vl_redirect()
514 rule->cookie = cookie; in sja1105_vl_redirect()
515 rule->type = SJA1105_RULE_VL; in sja1105_vl_redirect()
516 rule->key = *key; in sja1105_vl_redirect()
517 list_add(&rule->list, &priv->flow_block.rules); in sja1105_vl_redirect()
520 rule->port_mask |= BIT(port); in sja1105_vl_redirect()
522 rule->vl.destports |= destports; in sja1105_vl_redirect()
524 rule->vl.destports = destports; in sja1105_vl_redirect()
528 rule->port_mask &= ~BIT(port); in sja1105_vl_redirect()
529 if (!rule->port_mask) { in sja1105_vl_redirect()
530 list_del(&rule->list); in sja1105_vl_redirect()
543 rule->port_mask &= ~BIT(port); in sja1105_vl_delete()
544 if (!rule->port_mask) { in sja1105_vl_delete()
545 list_del(&rule->list); in sja1105_vl_delete()
558 if (rc < 0) in sja1105_vl_delete()
571 int ipv = -1; in sja1105_vl_gate()
578 return -EOPNOTSUPP; in sja1105_vl_gate()
585 return -ERANGE; in sja1105_vl_gate()
592 return -ERANGE; in sja1105_vl_gate()
595 if (!priv->vlan_aware && key->type != SJA1105_KEY_VLAN_UNAWARE_VL) { in sja1105_vl_gate()
598 return -EOPNOTSUPP; in sja1105_vl_gate()
599 } else if (priv->vlan_aware && key->type != SJA1105_KEY_VLAN_AWARE_VL) { in sja1105_vl_gate()
602 return -EOPNOTSUPP; in sja1105_vl_gate()
608 return -ENOMEM; in sja1105_vl_gate()
610 list_add(&rule->list, &priv->flow_block.rules); in sja1105_vl_gate()
611 rule->cookie = cookie; in sja1105_vl_gate()
612 rule->type = SJA1105_RULE_VL; in sja1105_vl_gate()
613 rule->key = *key; in sja1105_vl_gate()
614 rule->vl.type = SJA1105_VL_TIME_TRIGGERED; in sja1105_vl_gate()
615 rule->vl.sharindx = index; in sja1105_vl_gate()
616 rule->vl.base_time = base_time; in sja1105_vl_gate()
617 rule->vl.cycle_time = cycle_time; in sja1105_vl_gate()
618 rule->vl.num_entries = num_entries; in sja1105_vl_gate()
619 rule->vl.entries = kcalloc(num_entries, in sja1105_vl_gate()
622 if (!rule->vl.entries) { in sja1105_vl_gate()
623 rc = -ENOMEM; in sja1105_vl_gate()
627 for (i = 0; i < num_entries; i++) { in sja1105_vl_gate()
633 rc = -ERANGE; in sja1105_vl_gate()
640 rc = -ERANGE; in sja1105_vl_gate()
648 rc = -ERANGE; in sja1105_vl_gate()
652 if (entries[i].maxoctets != -1) { in sja1105_vl_gate()
655 rc = -EOPNOTSUPP; in sja1105_vl_gate()
659 if (ipv == -1) { in sja1105_vl_gate()
664 rc = -EOPNOTSUPP; in sja1105_vl_gate()
668 rule->vl.entries[i] = entries[i]; in sja1105_vl_gate()
671 if (ipv == -1) { in sja1105_vl_gate()
672 if (key->type == SJA1105_KEY_VLAN_AWARE_VL) in sja1105_vl_gate()
673 ipv = key->vl.pcp; in sja1105_vl_gate()
675 ipv = 0; in sja1105_vl_gate()
678 /* TODO: support per-flow MTU */ in sja1105_vl_gate()
679 rule->vl.maxlen = VLAN_ETH_FRAME_LEN + ETH_FCS_LEN; in sja1105_vl_gate()
680 rule->vl.ipv = ipv; in sja1105_vl_gate()
683 rule->port_mask |= BIT(port); in sja1105_vl_gate()
693 if (sja1105_gating_check_conflicts(priv, -1, extack)) { in sja1105_vl_gate()
694 NL_SET_ERR_MSG_MOD(extack, "Conflict with tc-taprio schedule"); in sja1105_vl_gate()
695 rc = -ERANGE; in sja1105_vl_gate()
701 rule->port_mask &= ~BIT(port); in sja1105_vl_gate()
702 if (!rule->port_mask) { in sja1105_vl_gate()
703 list_del(&rule->list); in sja1105_vl_gate()
704 kfree(rule->vl.entries); in sja1105_vl_gate()
719 if (WARN_ON(key->type != SJA1105_KEY_VLAN_AWARE_VL && in sja1105_find_vlid()
720 key->type != SJA1105_KEY_VLAN_UNAWARE_VL)) in sja1105_find_vlid()
721 return -1; in sja1105_find_vlid()
723 table = &priv->static_config.tables[BLK_IDX_VL_LOOKUP]; in sja1105_find_vlid()
724 vl_lookup = table->entries; in sja1105_find_vlid()
726 for (i = 0; i < table->entry_count; i++) { in sja1105_find_vlid()
727 if (key->type == SJA1105_KEY_VLAN_AWARE_VL) { in sja1105_find_vlid()
729 vl_lookup[i].macaddr == key->vl.dmac && in sja1105_find_vlid()
730 vl_lookup[i].vlanid == key->vl.vid && in sja1105_find_vlid()
731 vl_lookup[i].vlanprior == key->vl.pcp) in sja1105_find_vlid()
735 vl_lookup[i].macaddr == key->vl.dmac) in sja1105_find_vlid()
740 return -1; in sja1105_find_vlid()
747 const struct sja1105_regs *regs = priv->info->regs; in sja1105_vl_stats()
748 u8 buf[SJA1105_SIZE_VL_STATUS] = {0}; in sja1105_vl_stats()
755 if (rule->vl.type != SJA1105_VL_TIME_TRIGGERED) in sja1105_vl_stats()
756 return 0; in sja1105_vl_stats()
758 vlid = sja1105_find_vlid(priv, port, &rule->key); in sja1105_vl_stats()
759 if (vlid < 0) in sja1105_vl_stats()
760 return 0; in sja1105_vl_stats()
762 rc = sja1105_xfer_buf(priv, SPI_READ, regs->vl_status + 2 * vlid, buf, in sja1105_vl_stats()
770 sja1105_unpack(buf, &unreleased, 15, 0, SJA1105_SIZE_VL_STATUS); in sja1105_vl_stats()
775 flow_stats_update(stats, 0, pkts - rule->vl.stats.pkts, 0, in sja1105_vl_stats()
776 jiffies - rule->vl.stats.lastused, in sja1105_vl_stats()
779 rule->vl.stats.pkts = pkts; in sja1105_vl_stats()
780 rule->vl.stats.lastused = jiffies; in sja1105_vl_stats()
782 return 0; in sja1105_vl_stats()