Lines Matching +full:port +full:- +full:mapping

1 // SPDX-License-Identifier: GPL-2.0
54 /* ksz_supported_apptrust[] - Supported apptrust selectors and Priority Order
58 * the index within the array indicates the priority of the selector - lower
65 * non-configurable precedence where certain types of priority information
68 * 1. Tail Tag - Highest priority, overrides ACL, VLAN PCP, and DSCP priorities.
69 * 2. ACL - Overrides VLAN PCP and DSCP priorities.
70 * 3. VLAN PCP - Overrides DSCP priority.
71 * 4. DSCP - Lowest priority, does not override any other priority source.
77 * DCB_APP_SEL_PCP - Priority Code Point selector
78 * IEEE_8021QAZ_APP_SEL_DSCP - Differentiated Services Code Point selector
104 * ksz_get_dscp_prio_reg - Retrieves the DSCP-to-priority-mapping register
110 * This function retrieves the DSCP to priority mapping register, the number of
132 * ksz_get_apptrust_map_and_reg - Retrieves the apptrust map and register
158 * ksz_port_get_default_prio - Retrieves the default priority for a port on a
161 * @port: Port number from which to get the default priority
163 * This function fetches the default priority for the specified port on a KSZ
166 * Return: The default priority of the port on success, or a negative error
169 int ksz_port_get_default_prio(struct dsa_switch *ds, int port) in ksz_port_get_default_prio() argument
171 struct ksz_device *dev = ds->priv; in ksz_port_get_default_prio()
177 ret = ksz_pread8(dev, port, reg, &data); in ksz_port_get_default_prio()
185 * ksz88x3_port_set_default_prio_quirks - Quirks for default priority
187 * @port: Port number for which to set the default priority
191 * devices. On Port 2, no other priority providers are working
192 * except of PCP. So, configuring default priority on Port 2 is not possible.
193 * On Port 1, it is not possible to configure port priority if PCP
194 * apptrust on Port 2 is disabled. Since we disable multiple queues on the
195 * switch to disable PCP on Port 2, we need to ensure that the default priority
196 * configuration on Port 1 is in agreement with the configuration on Port 2.
200 static int ksz88x3_port_set_default_prio_quirks(struct ksz_device *dev, int port, in ksz88x3_port_set_default_prio_quirks() argument
206 if (port == KSZ_PORT_2) { in ksz88x3_port_set_default_prio_quirks()
207 dev_err(dev->dev, "Port priority configuration is not working on Port 2\n"); in ksz88x3_port_set_default_prio_quirks()
208 return -EINVAL; in ksz88x3_port_set_default_prio_quirks()
209 } else if (port == KSZ_PORT_1) { in ksz88x3_port_set_default_prio_quirks()
219 …dev_err(dev->dev, "Not possible to configure port priority on Port 1 if PCP apptrust on Port 2 is … in ksz88x3_port_set_default_prio_quirks()
220 return -EINVAL; in ksz88x3_port_set_default_prio_quirks()
228 * ksz_port_set_default_prio - Sets the default priority for a port on a KSZ
231 * @port: Port number for which to set the default priority
234 * This function sets the default priority for the specified port on a KSZ
239 int ksz_port_set_default_prio(struct dsa_switch *ds, int port, u8 prio) in ksz_port_set_default_prio() argument
241 struct ksz_device *dev = ds->priv; in ksz_port_set_default_prio()
245 if (prio >= dev->info->num_ipms) in ksz_port_set_default_prio()
246 return -EINVAL; in ksz_port_set_default_prio()
249 ret = ksz88x3_port_set_default_prio_quirks(dev, port, prio); in ksz_port_set_default_prio()
256 return ksz_prmw8(dev, port, reg, mask, (prio << shift) & mask); in ksz_port_set_default_prio()
260 * ksz_port_get_dscp_prio - Retrieves the priority for a DSCP value on a KSZ
263 * @port: Port number for which to get the priority
266 * This function fetches the priority value from switch global DSCP-to-priorty
267 * mapping table for the specified DSCP value.
272 int ksz_port_get_dscp_prio(struct dsa_switch *ds, int port, u8 dscp) in ksz_port_get_dscp_prio() argument
274 struct ksz_device *dev = ds->priv; in ksz_port_get_dscp_prio()
280 /* If DSCP remapping is disabled, DSCP bits 3-5 are used as Internal in ksz_port_get_dscp_prio()
288 /* If DSCP remapping is disabled, DSCP bits 3-5 are used as in ksz_port_get_dscp_prio()
297 * priority mapping table. in ksz_port_get_dscp_prio()
310 * ksz_set_global_dscp_entry - Sets the global DSCP-to-priority mapping entry
315 * This function sets the global DSCP-to-priority mapping entry for the
334 * ksz_init_global_dscp_map - Initializes the global DSCP-to-priority mapping
337 * This function initializes the global DSCP-to-priority mapping table for the
375 ipm = ieee8021q_tt_to_tc(tt, dev->info->num_tx_queues); in ksz_init_global_dscp_map()
388 * ksz_port_add_dscp_prio - Adds a DSCP-to-priority mapping entry for a port on
391 * @port: Port number for which to add the DSCP-to-priority mapping entry
397 int ksz_port_add_dscp_prio(struct dsa_switch *ds, int port, u8 dscp, u8 prio) in ksz_port_add_dscp_prio() argument
399 struct ksz_device *dev = ds->priv; in ksz_port_add_dscp_prio()
401 if (prio >= dev->info->num_ipms) in ksz_port_add_dscp_prio()
402 return -ERANGE; in ksz_port_add_dscp_prio()
408 * ksz_port_del_dscp_prio - Deletes a DSCP-to-priority mapping entry for a port
411 * @port: Port number for which to delete the DSCP-to-priority mapping entry
417 int ksz_port_del_dscp_prio(struct dsa_switch *ds, int port, u8 dscp, u8 prio) in ksz_port_del_dscp_prio() argument
419 struct ksz_device *dev = ds->priv; in ksz_port_del_dscp_prio()
422 if (ksz_port_get_dscp_prio(ds, port, dscp) != prio) in ksz_port_del_dscp_prio()
427 dev->info->num_tx_queues); in ksz_port_del_dscp_prio()
438 * ksz_apptrust_error - Prints an error message for an invalid apptrust selector
459 dev_err(dev->dev, "Invalid apptrust selector or priority order. Supported: %s\n", in ksz_apptrust_error()
464 * ksz_port_set_apptrust_validate - Validates the apptrust selectors
466 * @port: Port number for which to set the apptrust selectors
476 * 1. DCB_APP_SEL_PCP - Priority Code Point selector (highest priority)
477 * 2. IEEE_8021QAZ_APP_SEL_DSCP - Differentiated Services Code Point selector
482 static int ksz_port_set_apptrust_validate(struct ksz_device *dev, int port, in ksz_port_set_apptrust_validate() argument
518 return -EINVAL; in ksz_port_set_apptrust_validate()
522 * ksz88x3_port1_apptrust_quirk - Quirk for apptrust configuration on Port 1
525 * @port: Port number for which to set the apptrust selectors
529 * This function implements a quirk for apptrust configuration on Port 1 of
530 * KSZ88x3 devices. It ensures that apptrust configuration on Port 1 is not
531 * possible if PCP apptrust on Port 2 is disabled. This is because the Port 2
533 * do Port 1 configuration always in agreement with Port 2 configuration.
537 static int ksz88x3_port1_apptrust_quirk(struct ksz_device *dev, int port, in ksz88x3_port1_apptrust_quirk() argument
543 /* If no apptrust is requested for Port 1, no need to care about Port 2 in ksz88x3_port1_apptrust_quirk()
549 /* We got request to enable any apptrust on Port 1. To make it possible, in ksz88x3_port1_apptrust_quirk()
551 * multiqueue support, PCP classification on Port 2 will be in ksz88x3_port1_apptrust_quirk()
558 /* If KSZ8_PORT_802_1P_ENABLE bit is set on Port 2, the driver showed in ksz88x3_port1_apptrust_quirk()
559 * the interest in PCP classification on Port 2. In this case, in ksz88x3_port1_apptrust_quirk()
561 * Port 1. in ksz88x3_port1_apptrust_quirk()
562 * If KSZ8_PORT_802_1P_ENABLE bit is not set on Port 2, the PCP in ksz88x3_port1_apptrust_quirk()
563 * classification on Port 2 is still active, but the driver disabled in ksz88x3_port1_apptrust_quirk()
565 * all ports. In this case, we can't enable any apptrust on Port 1. in ksz88x3_port1_apptrust_quirk()
568 …dev_err(dev->dev, "Not possible to enable any apptrust on Port 1 if PCP apptrust on Port 2 is disa… in ksz88x3_port1_apptrust_quirk()
569 return -EINVAL; in ksz88x3_port1_apptrust_quirk()
576 * ksz88x3_port2_apptrust_quirk - Quirk for apptrust configuration on Port 2
579 * @port: Port number for which to set the apptrust selectors
583 * This function implements a quirk for apptrust configuration on Port 2 of
584 * KSZ88x3 devices. It ensures that DSCP apptrust is not working on Port 2 and
585 * that it is not possible to disable PCP on Port 2. The only way to disable PCP
586 * on Port 2 is to disable multiple queues on the switch.
590 static int ksz88x3_port2_apptrust_quirk(struct ksz_device *dev, int port, in ksz88x3_port2_apptrust_quirk() argument
593 struct dsa_switch *ds = dev->ds; in ksz88x3_port2_apptrust_quirk()
597 /* First validate Port 2 configuration. DiffServ/DSCP is not working in ksz88x3_port2_apptrust_quirk()
598 * on this port. in ksz88x3_port2_apptrust_quirk()
601 dev_err(dev->dev, "DSCP apptrust is not working on Port 2\n"); in ksz88x3_port2_apptrust_quirk()
602 return -EINVAL; in ksz88x3_port2_apptrust_quirk()
606 * switch to make PCP priority working on Port 2. in ksz88x3_port2_apptrust_quirk()
609 return ksz8_all_queues_split(dev, dev->info->num_tx_queues); in ksz88x3_port2_apptrust_quirk()
611 /* We got request to disable PCP priority on Port 2. in ksz88x3_port2_apptrust_quirk()
612 * Now, we need to compare Port 2 configuration with Port 1 in ksz88x3_port2_apptrust_quirk()
619 /* If Port 1 has any apptrust enabled, we can't disable multiple queues in ksz88x3_port2_apptrust_quirk()
620 * on the switch, so we can't disable PCP on Port 2. in ksz88x3_port2_apptrust_quirk()
623 dev_err(dev->dev, "Not possible to disable PCP on Port 2 if any apptrust is enabled on Port 1\n"); in ksz88x3_port2_apptrust_quirk()
624 return -EINVAL; in ksz88x3_port2_apptrust_quirk()
627 /* Now we need to ensure that default priority on Port 1 is set to 0 in ksz88x3_port2_apptrust_quirk()
634 …dev_err(dev->dev, "Not possible to disable PCP on Port 2 if non zero default priority is set on Po… in ksz88x3_port2_apptrust_quirk()
635 return -EINVAL; in ksz88x3_port2_apptrust_quirk()
638 /* Port 1 has no apptrust or default priority set and we got request to in ksz88x3_port2_apptrust_quirk()
639 * disable PCP on Port 2. We can disable multiqueue support to disable in ksz88x3_port2_apptrust_quirk()
640 * PCP on Port 2. in ksz88x3_port2_apptrust_quirk()
646 * ksz88x3_port_apptrust_quirk - Quirk for apptrust configuration on KSZ88x3
649 * @port: Port number for which to set the apptrust selectors
654 * devices. It ensures that apptrust configuration on Port 1 and
655 * Port 2 is done in agreement with each other.
659 static int ksz88x3_port_apptrust_quirk(struct ksz_device *dev, int port, in ksz88x3_port_apptrust_quirk() argument
662 if (port == KSZ_PORT_1) in ksz88x3_port_apptrust_quirk()
663 return ksz88x3_port1_apptrust_quirk(dev, port, reg, data); in ksz88x3_port_apptrust_quirk()
664 else if (port == KSZ_PORT_2) in ksz88x3_port_apptrust_quirk()
665 return ksz88x3_port2_apptrust_quirk(dev, port, reg, data); in ksz88x3_port_apptrust_quirk()
671 * ksz_port_set_apptrust - Sets the apptrust selectors for a port on a KSZ
674 * @port: Port number for which to set the apptrust selectors
678 * This function sets the apptrust selectors for the specified port on a KSZ
683 int ksz_port_set_apptrust(struct dsa_switch *ds, int port, in ksz_port_set_apptrust() argument
687 struct ksz_device *dev = ds->priv; in ksz_port_set_apptrust()
692 ret = ksz_port_set_apptrust_validate(dev, port, sel, nsel); in ksz_port_set_apptrust()
711 ret = ksz88x3_port_apptrust_quirk(dev, port, reg, data); in ksz_port_set_apptrust()
716 return ksz_prmw8(dev, port, reg, mask, data); in ksz_port_set_apptrust()
720 * ksz_port_get_apptrust - Retrieves the apptrust selectors for a port on a KSZ
723 * @port: Port number for which to get the apptrust selectors
727 * This function fetches the apptrust selectors for the specified port on a KSZ
732 int ksz_port_get_apptrust(struct dsa_switch *ds, int port, u8 *sel, int *nsel) in ksz_port_get_apptrust() argument
735 struct ksz_device *dev = ds->priv; in ksz_port_get_apptrust()
742 ret = ksz_pread8(dev, port, reg, &data); in ksz_port_get_apptrust()
756 * ksz_dcb_init_port - Initializes the DCB configuration for a port on a KSZ
758 * @port: Port number for which to initialize the DCB configuration
760 * This function initializes the DCB configuration for the specified port on a
761 * KSZ switch. Particular DCB configuration is set for the port, including the
768 int ksz_dcb_init_port(struct ksz_device *dev, int port) in ksz_dcb_init_port() argument
775 dev->info->num_tx_queues); in ksz_dcb_init_port()
782 /* Set the default priority for the port to Best Effort */ in ksz_dcb_init_port()
783 ret = ksz_port_set_default_prio(dev->ds, port, ipm); in ksz_dcb_init_port()
787 return ksz_port_set_apptrust(dev->ds, port, ksz_default_apptrust, in ksz_dcb_init_port()
792 * ksz_dcb_init - Initializes the DCB configuration for a KSZ switch
796 * DSCP-to-priority mapping table is initialized.
808 /* Enable 802.1p priority control on Port 2 during switch initialization. in ksz_dcb_init()
809 * This setup is critical for the apptrust functionality on Port 1, which in ksz_dcb_init()
810 * relies on the priority settings of Port 2. Note: Port 1 is naturally in ksz_dcb_init()
811 * configured before Port 2, necessitating this configuration order. in ksz_dcb_init()