Lines Matching +full:route +full:- +full:ptp
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2018-2019, Vladimir Oltean <olteanv@gmail.com>
6 /* In the dynamic configuration interface, the switch exposes a register-like
13 * This file creates a per-switch-family abstraction called
15 * - sja1105_dynamic_config_write
16 * - sja1105_dynamic_config_read
25 * +-----------------------------------------+------------------+
27 * +-----------------------------------------+------------------+
29 * <----------------------- packed_size ------------------------>
33 * function is reused (bar exceptional cases - see
41 * The COMMAND BUFFER is always SJA1105_SIZE_DYN_CMD bytes (one 32-bit word) in
49 * - .entry_packing: A function that deals with packing an ENTRY structure
54 * - .cmd_packing: A function that deals with packing/unpacking the COMMAND
64 * or vice-versa (sja1105pqrs_l2_lookup_cmd_packing).
65 * - .access: A bitmap of:
79 * Only the TCAM-based FDB table on SJA1105 P/Q/R/S supports
81 * - .max_entry_count: The number of entries, counting from zero, that can be
86 * - .packed_size: The length in bytes of the compound ENTRY + COMMAND BUFFER.
91 * - .addr: The base SPI address at which the buffer must be written to the
94 * that of the COMMAND, since the other 32-bit words will follow along
176 sja1105_packing(buf, &cmd->valid, 31, 31, size, op); in sja1105_vl_lookup_cmd_packing()
177 sja1105_packing(buf, &cmd->errors, 30, 30, size, op); in sja1105_vl_lookup_cmd_packing()
178 sja1105_packing(buf, &cmd->rdwrset, 29, 29, size, op); in sja1105_vl_lookup_cmd_packing()
179 sja1105_packing(buf, &cmd->index, 9, 0, size, op); in sja1105_vl_lookup_cmd_packing()
188 sja1105_packing(buf, &entry->egrmirr, 21, 17, size, op); in sja1105et_vl_lookup_entry_packing()
189 sja1105_packing(buf, &entry->ingrmirr, 16, 16, size, op); in sja1105et_vl_lookup_entry_packing()
201 sja1105_packing(p, &cmd->valid, 31, 31, size, op); in sja1105pqrs_l2_lookup_cmd_packing()
202 sja1105_packing(p, &cmd->rdwrset, 30, 30, size, op); in sja1105pqrs_l2_lookup_cmd_packing()
203 sja1105_packing(p, &cmd->errors, 29, 29, size, op); in sja1105pqrs_l2_lookup_cmd_packing()
204 sja1105_packing(p, &cmd->valident, 27, 27, size, op); in sja1105pqrs_l2_lookup_cmd_packing()
207 * using it to delete a management route was unsupported. UM10944 in sja1105pqrs_l2_lookup_cmd_packing()
224 * at the same time achieve compatibility with the management route in sja1105pqrs_l2_lookup_cmd_packing()
227 if (cmd->rdwrset == SPI_READ) { in sja1105pqrs_l2_lookup_cmd_packing()
228 if (cmd->search) in sja1105pqrs_l2_lookup_cmd_packing()
234 if (cmd->valident) in sja1105pqrs_l2_lookup_cmd_packing()
241 /* Hack - The hardware takes the 'index' field within in sja1105pqrs_l2_lookup_cmd_packing()
246 * such that our API doesn't need to ask for a full-blown entry in sja1105pqrs_l2_lookup_cmd_packing()
249 sja1105_packing(buf, &cmd->index, 15, 6, in sja1105pqrs_l2_lookup_cmd_packing()
285 * only if it's dynamically learned" <- well how am I supposed to know?) and
290 * entry-related data as writeback through the command buffer.
295 * a peek outside of the caller-supplied @buf (the entry buffer), to reach the
306 sja1105_packing(cmd, &entry->lockeds, 28, 28, size, op); in sja1105pqrs_dyn_l2_lookup_entry_packing()
318 sja1105_packing(p, &cmd->valid, 31, 31, size, op); in sja1105et_l2_lookup_cmd_packing()
319 sja1105_packing(p, &cmd->rdwrset, 30, 30, size, op); in sja1105et_l2_lookup_cmd_packing()
320 sja1105_packing(p, &cmd->errors, 29, 29, size, op); in sja1105et_l2_lookup_cmd_packing()
321 sja1105_packing(p, &cmd->valident, 27, 27, size, op); in sja1105et_l2_lookup_cmd_packing()
322 /* Hack - see comments above. */ in sja1105et_l2_lookup_cmd_packing()
323 sja1105_packing(buf, &cmd->index, 29, 20, in sja1105et_l2_lookup_cmd_packing()
334 sja1105_packing(cmd, &entry->lockeds, 28, 28, size, op); in sja1105et_dyn_l2_lookup_entry_packing()
357 /* UM10944: To specify if a PTP egress timestamp shall be captured on in sja1105et_mgmt_route_entry_packing()
363 sja1105_packing(buf, &entry->tsreg, 85, 85, size, op); in sja1105et_mgmt_route_entry_packing()
364 sja1105_packing(buf, &entry->takets, 84, 84, size, op); in sja1105et_mgmt_route_entry_packing()
365 sja1105_packing(buf, &entry->macaddr, 83, 36, size, op); in sja1105et_mgmt_route_entry_packing()
366 sja1105_packing(buf, &entry->destports, 35, 31, size, op); in sja1105et_mgmt_route_entry_packing()
367 sja1105_packing(buf, &entry->enfport, 30, 30, size, op); in sja1105et_mgmt_route_entry_packing()
393 sja1105_packing(buf, &entry->tsreg, 71, 71, size, op); in sja1105pqrs_mgmt_route_entry_packing()
394 sja1105_packing(buf, &entry->takets, 70, 70, size, op); in sja1105pqrs_mgmt_route_entry_packing()
395 sja1105_packing(buf, &entry->macaddr, 69, 22, size, op); in sja1105pqrs_mgmt_route_entry_packing()
396 sja1105_packing(buf, &entry->destports, 21, 17, size, op); in sja1105pqrs_mgmt_route_entry_packing()
397 sja1105_packing(buf, &entry->enfport, 16, 16, size, op); in sja1105pqrs_mgmt_route_entry_packing()
401 /* In E/T, entry is at addresses 0x27-0x28. There is a 4 byte gap at 0x29,
412 sja1105_packing(p, &cmd->valid, 31, 31, size, op); in sja1105_vlan_lookup_cmd_packing()
413 sja1105_packing(p, &cmd->rdwrset, 30, 30, size, op); in sja1105_vlan_lookup_cmd_packing()
414 sja1105_packing(p, &cmd->valident, 27, 27, size, op); in sja1105_vlan_lookup_cmd_packing()
415 /* Hack - see comments above, applied for 'vlanid' field of in sja1105_vlan_lookup_cmd_packing()
418 sja1105_packing(buf, &cmd->index, 38, 27, in sja1105_vlan_lookup_cmd_packing()
429 sja1105_packing(p, &cmd->valid, 31, 31, size, op); in sja1105_l2_forwarding_cmd_packing()
430 sja1105_packing(p, &cmd->errors, 30, 30, size, op); in sja1105_l2_forwarding_cmd_packing()
431 sja1105_packing(p, &cmd->rdwrset, 29, 29, size, op); in sja1105_l2_forwarding_cmd_packing()
432 sja1105_packing(p, &cmd->index, 4, 0, size, op); in sja1105_l2_forwarding_cmd_packing()
443 sja1105_packing(reg1, &cmd->valid, 31, 31, size, op); in sja1105et_mac_config_cmd_packing()
444 sja1105_packing(reg1, &cmd->index, 26, 24, size, op); in sja1105et_mac_config_cmd_packing()
456 sja1105_packing(reg1, &entry->speed, 30, 29, size, op); in sja1105et_mac_config_entry_packing()
457 sja1105_packing(reg1, &entry->drpdtag, 23, 23, size, op); in sja1105et_mac_config_entry_packing()
458 sja1105_packing(reg1, &entry->drpuntag, 22, 22, size, op); in sja1105et_mac_config_entry_packing()
459 sja1105_packing(reg1, &entry->retag, 21, 21, size, op); in sja1105et_mac_config_entry_packing()
460 sja1105_packing(reg1, &entry->dyn_learn, 20, 20, size, op); in sja1105et_mac_config_entry_packing()
461 sja1105_packing(reg1, &entry->egress, 19, 19, size, op); in sja1105et_mac_config_entry_packing()
462 sja1105_packing(reg1, &entry->ingress, 18, 18, size, op); in sja1105et_mac_config_entry_packing()
463 sja1105_packing(reg1, &entry->ing_mirr, 17, 17, size, op); in sja1105et_mac_config_entry_packing()
464 sja1105_packing(reg1, &entry->egr_mirr, 16, 16, size, op); in sja1105et_mac_config_entry_packing()
465 sja1105_packing(reg1, &entry->vlanprio, 14, 12, size, op); in sja1105et_mac_config_entry_packing()
466 sja1105_packing(reg1, &entry->vlanid, 11, 0, size, op); in sja1105et_mac_config_entry_packing()
467 sja1105_packing(reg2, &entry->tp_delin, 31, 16, size, op); in sja1105et_mac_config_entry_packing()
468 sja1105_packing(reg2, &entry->tp_delout, 15, 0, size, op); in sja1105et_mac_config_entry_packing()
483 sja1105_packing(p, &cmd->valid, 31, 31, size, op); in sja1105pqrs_mac_config_cmd_packing()
484 sja1105_packing(p, &cmd->errors, 30, 30, size, op); in sja1105pqrs_mac_config_cmd_packing()
485 sja1105_packing(p, &cmd->rdwrset, 29, 29, size, op); in sja1105pqrs_mac_config_cmd_packing()
486 sja1105_packing(p, &cmd->index, 2, 0, size, op); in sja1105pqrs_mac_config_cmd_packing()
493 sja1105_packing(buf, &cmd->valid, 31, 31, in sja1105et_l2_lookup_params_cmd_packing()
503 sja1105_packing(buf, &entry->poly, 7, 0, in sja1105et_l2_lookup_params_entry_packing()
517 sja1105_packing(p, &cmd->valid, 31, 31, size, op); in sja1105pqrs_l2_lookup_params_cmd_packing()
518 sja1105_packing(p, &cmd->rdwrset, 30, 30, size, op); in sja1105pqrs_l2_lookup_params_cmd_packing()
527 sja1105_packing(buf, &cmd->valid, 31, 31, size, op); in sja1105et_general_params_cmd_packing()
528 sja1105_packing(buf, &cmd->errors, 30, 30, size, op); in sja1105et_general_params_cmd_packing()
538 sja1105_packing(buf, &entry->mirr_port, 2, 0, size, op); in sja1105et_general_params_entry_packing()
550 sja1105_packing(p, &cmd->valid, 31, 31, size, op); in sja1105pqrs_general_params_cmd_packing()
551 sja1105_packing(p, &cmd->errors, 30, 30, size, op); in sja1105pqrs_general_params_cmd_packing()
552 sja1105_packing(p, &cmd->rdwrset, 28, 28, size, op); in sja1105pqrs_general_params_cmd_packing()
562 sja1105_packing(p, &cmd->valid, 31, 31, size, op); in sja1105pqrs_avb_params_cmd_packing()
563 sja1105_packing(p, &cmd->errors, 30, 30, size, op); in sja1105pqrs_avb_params_cmd_packing()
564 sja1105_packing(p, &cmd->rdwrset, 29, 29, size, op); in sja1105pqrs_avb_params_cmd_packing()
574 sja1105_packing(p, &cmd->valid, 31, 31, size, op); in sja1105_retagging_cmd_packing()
575 sja1105_packing(p, &cmd->errors, 30, 30, size, op); in sja1105_retagging_cmd_packing()
576 sja1105_packing(p, &cmd->valident, 29, 29, size, op); in sja1105_retagging_cmd_packing()
577 sja1105_packing(p, &cmd->rdwrset, 28, 28, size, op); in sja1105_retagging_cmd_packing()
578 sja1105_packing(p, &cmd->index, 5, 0, size, op); in sja1105_retagging_cmd_packing()
587 sja1105_packing(p, &cmd->valid, 31, 31, size, op); in sja1105et_cbs_cmd_packing()
588 sja1105_packing(p, &cmd->index, 19, 16, size, op); in sja1105et_cbs_cmd_packing()
599 sja1105_packing(cmd, &entry->port, 5, 3, SJA1105_SIZE_DYN_CMD, op); in sja1105et_cbs_entry_packing()
600 sja1105_packing(cmd, &entry->prio, 2, 0, SJA1105_SIZE_DYN_CMD, op); in sja1105et_cbs_entry_packing()
601 sja1105_packing(p + 3, &entry->credit_lo, 31, 0, size, op); in sja1105et_cbs_entry_packing()
602 sja1105_packing(p + 2, &entry->credit_hi, 31, 0, size, op); in sja1105et_cbs_entry_packing()
603 sja1105_packing(p + 1, &entry->send_slope, 31, 0, size, op); in sja1105et_cbs_entry_packing()
604 sja1105_packing(p + 0, &entry->idle_slope, 31, 0, size, op); in sja1105et_cbs_entry_packing()
614 sja1105_packing(p, &cmd->valid, 31, 31, size, op); in sja1105pqrs_cbs_cmd_packing()
615 sja1105_packing(p, &cmd->rdwrset, 30, 30, size, op); in sja1105pqrs_cbs_cmd_packing()
616 sja1105_packing(p, &cmd->errors, 29, 29, size, op); in sja1105pqrs_cbs_cmd_packing()
617 sja1105_packing(p, &cmd->index, 3, 0, size, op); in sja1105pqrs_cbs_cmd_packing()
626 sja1105_packing(buf, &entry->port, 159, 157, size, op); in sja1105pqrs_cbs_entry_packing()
627 sja1105_packing(buf, &entry->prio, 156, 154, size, op); in sja1105pqrs_cbs_entry_packing()
628 sja1105_packing(buf, &entry->credit_lo, 153, 122, size, op); in sja1105pqrs_cbs_entry_packing()
629 sja1105_packing(buf, &entry->credit_hi, 121, 90, size, op); in sja1105pqrs_cbs_entry_packing()
630 sja1105_packing(buf, &entry->send_slope, 89, 58, size, op); in sja1105pqrs_cbs_entry_packing()
631 sja1105_packing(buf, &entry->idle_slope, 57, 26, size, op); in sja1105pqrs_cbs_entry_packing()
824 * @entry Type-casted to an unpacked structure that holds a table entry
827 * argument is used as input/output: it should be pre-populated
831 * will be returned (or left unmodified - thus negative - if not
846 return -ERANGE; in sja1105_dynamic_config_read()
848 ops = &priv->info->dyn_ops[blk_idx]; in sja1105_dynamic_config_read()
850 if (index >= 0 && index >= ops->max_entry_count) in sja1105_dynamic_config_read()
851 return -ERANGE; in sja1105_dynamic_config_read()
852 if (index < 0 && !(ops->access & OP_SEARCH)) in sja1105_dynamic_config_read()
853 return -EOPNOTSUPP; in sja1105_dynamic_config_read()
854 if (!(ops->access & OP_READ)) in sja1105_dynamic_config_read()
855 return -EOPNOTSUPP; in sja1105_dynamic_config_read()
856 if (ops->packed_size > SJA1105_MAX_DYN_CMD_SIZE) in sja1105_dynamic_config_read()
857 return -ERANGE; in sja1105_dynamic_config_read()
858 if (!ops->cmd_packing) in sja1105_dynamic_config_read()
859 return -EOPNOTSUPP; in sja1105_dynamic_config_read()
860 if (!ops->entry_packing) in sja1105_dynamic_config_read()
861 return -EOPNOTSUPP; in sja1105_dynamic_config_read()
874 ops->cmd_packing(packed_buf, &cmd, PACK); in sja1105_dynamic_config_read()
877 ops->entry_packing(packed_buf, entry, PACK); in sja1105_dynamic_config_read()
880 rc = sja1105_xfer_buf(priv, SPI_WRITE, ops->addr, packed_buf, in sja1105_dynamic_config_read()
881 ops->packed_size); in sja1105_dynamic_config_read()
889 memset(packed_buf, 0, ops->packed_size); in sja1105_dynamic_config_read()
892 rc = sja1105_xfer_buf(priv, SPI_READ, ops->addr, packed_buf, in sja1105_dynamic_config_read()
893 ops->packed_size); in sja1105_dynamic_config_read()
898 ops->cmd_packing(packed_buf, &cmd, UNPACK); in sja1105_dynamic_config_read()
904 return -ENOENT; in sja1105_dynamic_config_read()
906 } while (cmd.valid && --retries); in sja1105_dynamic_config_read()
909 return -ETIMEDOUT; in sja1105_dynamic_config_read()
911 /* Don't dereference possibly NULL pointer - maybe caller in sja1105_dynamic_config_read()
915 ops->entry_packing(packed_buf, entry, UNPACK); in sja1105_dynamic_config_read()
930 return -ERANGE; in sja1105_dynamic_config_write()
932 ops = &priv->info->dyn_ops[blk_idx]; in sja1105_dynamic_config_write()
934 if (index >= ops->max_entry_count) in sja1105_dynamic_config_write()
935 return -ERANGE; in sja1105_dynamic_config_write()
937 return -ERANGE; in sja1105_dynamic_config_write()
938 if (!(ops->access & OP_WRITE)) in sja1105_dynamic_config_write()
939 return -EOPNOTSUPP; in sja1105_dynamic_config_write()
940 if (!keep && !(ops->access & OP_DEL)) in sja1105_dynamic_config_write()
941 return -EOPNOTSUPP; in sja1105_dynamic_config_write()
942 if (ops->packed_size > SJA1105_MAX_DYN_CMD_SIZE) in sja1105_dynamic_config_write()
943 return -ERANGE; in sja1105_dynamic_config_write()
950 if (!ops->cmd_packing) in sja1105_dynamic_config_write()
951 return -EOPNOTSUPP; in sja1105_dynamic_config_write()
952 ops->cmd_packing(packed_buf, &cmd, PACK); in sja1105_dynamic_config_write()
954 if (!ops->entry_packing) in sja1105_dynamic_config_write()
955 return -EOPNOTSUPP; in sja1105_dynamic_config_write()
962 ops->entry_packing(packed_buf, entry, PACK); in sja1105_dynamic_config_write()
965 rc = sja1105_xfer_buf(priv, SPI_WRITE, ops->addr, packed_buf, in sja1105_dynamic_config_write()
966 ops->packed_size); in sja1105_dynamic_config_write()
971 ops->cmd_packing(packed_buf, &cmd, UNPACK); in sja1105_dynamic_config_write()
973 return -EINVAL; in sja1105_dynamic_config_write()
994 /* CRC8 algorithm with non-reversed input, non-reversed output,
1003 priv->static_config.tables[BLK_IDX_L2_LOOKUP_PARAMS].entries; in sja1105et_fdb_hash()
1004 u64 poly_koopman = l2_lookup_params->poly; in sja1105et_fdb_hash()
1007 u64 vlanid = l2_lookup_params->shared_learn ? 0 : vid; in sja1105et_fdb_hash()
1013 for (i = 56; i >= 0; i -= 8) { in sja1105et_fdb_hash()