felix.c (70d39a6e62d31a4a7372a712ccc6f8063bbb1550) felix.c (f59fd9cab7305266f4148776c3b66329551a2a3a)
1// SPDX-License-Identifier: GPL-2.0
2/* Copyright 2019 NXP Semiconductors
3 *
4 * This is an umbrella module for all network switches that are
5 * register-compatible with Ocelot and that perform I/O to their host CPU
6 * through an NPI (Node Processor Interface) Ethernet port.
7 */
8#include <uapi/linux/if_bridge.h>

--- 413 unchanged lines hidden (view full) ---

422 ocelot->map = felix->info->map;
423 ocelot->stats_layout = felix->info->stats_layout;
424 ocelot->num_stats = felix->info->num_stats;
425 ocelot->num_mact_rows = felix->info->num_mact_rows;
426 ocelot->vcap = felix->info->vcap;
427 ocelot->ops = felix->info->ops;
428 ocelot->inj_prefix = OCELOT_TAG_PREFIX_SHORT;
429 ocelot->xtr_prefix = OCELOT_TAG_PREFIX_SHORT;
1// SPDX-License-Identifier: GPL-2.0
2/* Copyright 2019 NXP Semiconductors
3 *
4 * This is an umbrella module for all network switches that are
5 * register-compatible with Ocelot and that perform I/O to their host CPU
6 * through an NPI (Node Processor Interface) Ethernet port.
7 */
8#include <uapi/linux/if_bridge.h>

--- 413 unchanged lines hidden (view full) ---

422 ocelot->map = felix->info->map;
423 ocelot->stats_layout = felix->info->stats_layout;
424 ocelot->num_stats = felix->info->num_stats;
425 ocelot->num_mact_rows = felix->info->num_mact_rows;
426 ocelot->vcap = felix->info->vcap;
427 ocelot->ops = felix->info->ops;
428 ocelot->inj_prefix = OCELOT_TAG_PREFIX_SHORT;
429 ocelot->xtr_prefix = OCELOT_TAG_PREFIX_SHORT;
430 ocelot->devlink = felix->ds->devlink;
430
431 port_phy_modes = kcalloc(num_phys_ports, sizeof(phy_interface_t),
432 GFP_KERNEL);
433 if (!port_phy_modes)
434 return -ENOMEM;
435
436 err = felix_parse_dt(felix, port_phy_modes);
437 if (err) {

--- 145 unchanged lines hidden (view full) ---

583 felix_npi_port_init(ocelot, port);
584
585 /* Set the default QoS Classification based on PCP and DEI
586 * bits of vlan tag.
587 */
588 felix_port_qos_map_init(ocelot, port);
589 }
590
431
432 port_phy_modes = kcalloc(num_phys_ports, sizeof(phy_interface_t),
433 GFP_KERNEL);
434 if (!port_phy_modes)
435 return -ENOMEM;
436
437 err = felix_parse_dt(felix, port_phy_modes);
438 if (err) {

--- 145 unchanged lines hidden (view full) ---

584 felix_npi_port_init(ocelot, port);
585
586 /* Set the default QoS Classification based on PCP and DEI
587 * bits of vlan tag.
588 */
589 felix_port_qos_map_init(ocelot, port);
590 }
591
592 err = ocelot_devlink_sb_register(ocelot);
593 if (err)
594 return err;
595
591 /* Include the CPU port module in the forwarding mask for unknown
592 * unicast - the hardware default value for ANA_FLOODING_FLD_UNICAST
593 * excludes BIT(ocelot->num_phys_ports), and so does ocelot_init, since
594 * Ocelot relies on whitelisting MAC addresses towards PGID_CPU.
595 */
596 ocelot_write_rix(ocelot,
597 ANA_PGID_PGID_PGID(GENMASK(ocelot->num_phys_ports, 0)),
598 ANA_PGID_PGID, PGID_UC);

--- 5 unchanged lines hidden (view full) ---

604}
605
606static void felix_teardown(struct dsa_switch *ds)
607{
608 struct ocelot *ocelot = ds->priv;
609 struct felix *felix = ocelot_to_felix(ocelot);
610 int port;
611
596 /* Include the CPU port module in the forwarding mask for unknown
597 * unicast - the hardware default value for ANA_FLOODING_FLD_UNICAST
598 * excludes BIT(ocelot->num_phys_ports), and so does ocelot_init, since
599 * Ocelot relies on whitelisting MAC addresses towards PGID_CPU.
600 */
601 ocelot_write_rix(ocelot,
602 ANA_PGID_PGID_PGID(GENMASK(ocelot->num_phys_ports, 0)),
603 ANA_PGID_PGID, PGID_UC);

--- 5 unchanged lines hidden (view full) ---

609}
610
611static void felix_teardown(struct dsa_switch *ds)
612{
613 struct ocelot *ocelot = ds->priv;
614 struct felix *felix = ocelot_to_felix(ocelot);
615 int port;
616
617 ocelot_devlink_sb_unregister(ocelot);
612 ocelot_deinit_timestamp(ocelot);
613 ocelot_deinit(ocelot);
614
615 for (port = 0; port < ocelot->num_phys_ports; port++)
616 ocelot_deinit_port(ocelot, port);
617
618 if (felix->info->mdio_bus_free)
619 felix->info->mdio_bus_free(ocelot);

--- 125 unchanged lines hidden (view full) ---

745 struct felix *felix = ocelot_to_felix(ocelot);
746
747 if (felix->info->port_setup_tc)
748 return felix->info->port_setup_tc(ds, port, type, type_data);
749 else
750 return -EOPNOTSUPP;
751}
752
618 ocelot_deinit_timestamp(ocelot);
619 ocelot_deinit(ocelot);
620
621 for (port = 0; port < ocelot->num_phys_ports; port++)
622 ocelot_deinit_port(ocelot, port);
623
624 if (felix->info->mdio_bus_free)
625 felix->info->mdio_bus_free(ocelot);

--- 125 unchanged lines hidden (view full) ---

751 struct felix *felix = ocelot_to_felix(ocelot);
752
753 if (felix->info->port_setup_tc)
754 return felix->info->port_setup_tc(ds, port, type, type_data);
755 else
756 return -EOPNOTSUPP;
757}
758
759static int felix_sb_pool_get(struct dsa_switch *ds, unsigned int sb_index,
760 u16 pool_index,
761 struct devlink_sb_pool_info *pool_info)
762{
763 struct ocelot *ocelot = ds->priv;
764
765 return ocelot_sb_pool_get(ocelot, sb_index, pool_index, pool_info);
766}
767
768static int felix_sb_pool_set(struct dsa_switch *ds, unsigned int sb_index,
769 u16 pool_index, u32 size,
770 enum devlink_sb_threshold_type threshold_type,
771 struct netlink_ext_ack *extack)
772{
773 struct ocelot *ocelot = ds->priv;
774
775 return ocelot_sb_pool_set(ocelot, sb_index, pool_index, size,
776 threshold_type, extack);
777}
778
779static int felix_sb_port_pool_get(struct dsa_switch *ds, int port,
780 unsigned int sb_index, u16 pool_index,
781 u32 *p_threshold)
782{
783 struct ocelot *ocelot = ds->priv;
784
785 return ocelot_sb_port_pool_get(ocelot, port, sb_index, pool_index,
786 p_threshold);
787}
788
789static int felix_sb_port_pool_set(struct dsa_switch *ds, int port,
790 unsigned int sb_index, u16 pool_index,
791 u32 threshold, struct netlink_ext_ack *extack)
792{
793 struct ocelot *ocelot = ds->priv;
794
795 return ocelot_sb_port_pool_set(ocelot, port, sb_index, pool_index,
796 threshold, extack);
797}
798
799static int felix_sb_tc_pool_bind_get(struct dsa_switch *ds, int port,
800 unsigned int sb_index, u16 tc_index,
801 enum devlink_sb_pool_type pool_type,
802 u16 *p_pool_index, u32 *p_threshold)
803{
804 struct ocelot *ocelot = ds->priv;
805
806 return ocelot_sb_tc_pool_bind_get(ocelot, port, sb_index, tc_index,
807 pool_type, p_pool_index,
808 p_threshold);
809}
810
811static int felix_sb_tc_pool_bind_set(struct dsa_switch *ds, int port,
812 unsigned int sb_index, u16 tc_index,
813 enum devlink_sb_pool_type pool_type,
814 u16 pool_index, u32 threshold,
815 struct netlink_ext_ack *extack)
816{
817 struct ocelot *ocelot = ds->priv;
818
819 return ocelot_sb_tc_pool_bind_set(ocelot, port, sb_index, tc_index,
820 pool_type, pool_index, threshold,
821 extack);
822}
823
824static int felix_sb_occ_snapshot(struct dsa_switch *ds,
825 unsigned int sb_index)
826{
827 struct ocelot *ocelot = ds->priv;
828
829 return ocelot_sb_occ_snapshot(ocelot, sb_index);
830}
831
832static int felix_sb_occ_max_clear(struct dsa_switch *ds,
833 unsigned int sb_index)
834{
835 struct ocelot *ocelot = ds->priv;
836
837 return ocelot_sb_occ_max_clear(ocelot, sb_index);
838}
839
840static int felix_sb_occ_port_pool_get(struct dsa_switch *ds, int port,
841 unsigned int sb_index, u16 pool_index,
842 u32 *p_cur, u32 *p_max)
843{
844 struct ocelot *ocelot = ds->priv;
845
846 return ocelot_sb_occ_port_pool_get(ocelot, port, sb_index, pool_index,
847 p_cur, p_max);
848}
849
850static int felix_sb_occ_tc_port_bind_get(struct dsa_switch *ds, int port,
851 unsigned int sb_index, u16 tc_index,
852 enum devlink_sb_pool_type pool_type,
853 u32 *p_cur, u32 *p_max)
854{
855 struct ocelot *ocelot = ds->priv;
856
857 return ocelot_sb_occ_tc_port_bind_get(ocelot, port, sb_index, tc_index,
858 pool_type, p_cur, p_max);
859}
860
753const struct dsa_switch_ops felix_switch_ops = {
754 .get_tag_protocol = felix_get_tag_protocol,
755 .setup = felix_setup,
756 .teardown = felix_teardown,
757 .set_ageing_time = felix_set_ageing_time,
758 .get_strings = felix_get_strings,
759 .get_ethtool_stats = felix_get_ethtool_stats,
760 .get_sset_count = felix_get_sset_count,

--- 22 unchanged lines hidden (view full) ---

783 .port_change_mtu = felix_change_mtu,
784 .port_max_mtu = felix_get_max_mtu,
785 .port_policer_add = felix_port_policer_add,
786 .port_policer_del = felix_port_policer_del,
787 .cls_flower_add = felix_cls_flower_add,
788 .cls_flower_del = felix_cls_flower_del,
789 .cls_flower_stats = felix_cls_flower_stats,
790 .port_setup_tc = felix_port_setup_tc,
861const struct dsa_switch_ops felix_switch_ops = {
862 .get_tag_protocol = felix_get_tag_protocol,
863 .setup = felix_setup,
864 .teardown = felix_teardown,
865 .set_ageing_time = felix_set_ageing_time,
866 .get_strings = felix_get_strings,
867 .get_ethtool_stats = felix_get_ethtool_stats,
868 .get_sset_count = felix_get_sset_count,

--- 22 unchanged lines hidden (view full) ---

891 .port_change_mtu = felix_change_mtu,
892 .port_max_mtu = felix_get_max_mtu,
893 .port_policer_add = felix_port_policer_add,
894 .port_policer_del = felix_port_policer_del,
895 .cls_flower_add = felix_cls_flower_add,
896 .cls_flower_del = felix_cls_flower_del,
897 .cls_flower_stats = felix_cls_flower_stats,
898 .port_setup_tc = felix_port_setup_tc,
899 .devlink_sb_pool_get = felix_sb_pool_get,
900 .devlink_sb_pool_set = felix_sb_pool_set,
901 .devlink_sb_port_pool_get = felix_sb_port_pool_get,
902 .devlink_sb_port_pool_set = felix_sb_port_pool_set,
903 .devlink_sb_tc_pool_bind_get = felix_sb_tc_pool_bind_get,
904 .devlink_sb_tc_pool_bind_set = felix_sb_tc_pool_bind_set,
905 .devlink_sb_occ_snapshot = felix_sb_occ_snapshot,
906 .devlink_sb_occ_max_clear = felix_sb_occ_max_clear,
907 .devlink_sb_occ_port_pool_get = felix_sb_occ_port_pool_get,
908 .devlink_sb_occ_tc_port_bind_get= felix_sb_occ_tc_port_bind_get,
791};
792
793struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port)
794{
795 struct felix *felix = ocelot_to_felix(ocelot);
796 struct dsa_switch *ds = felix->ds;
797
798 if (!dsa_is_user_port(ds, port))

--- 15 unchanged lines hidden ---
909};
910
911struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port)
912{
913 struct felix *felix = ocelot_to_felix(ocelot);
914 struct dsa_switch *ds = felix->ds;
915
916 if (!dsa_is_user_port(ds, port))

--- 15 unchanged lines hidden ---