ocelot.h (f81483aaeb59da530b286fe5d081e1705eb5c886) ocelot.h (5cad43a52ee3caf451cd645baa4beb53a1733dae)
1/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
2/* Copyright (c) 2017 Microsemi Corporation
3 */
4
5#ifndef _SOC_MSCC_OCELOT_H
6#define _SOC_MSCC_OCELOT_H
7
8#include <linux/ptp_clock_kernel.h>

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

113 QSYS,
114 REW,
115 SYS,
116 S0,
117 S1,
118 S2,
119 HSIO,
120 PTP,
1/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
2/* Copyright (c) 2017 Microsemi Corporation
3 */
4
5#ifndef _SOC_MSCC_OCELOT_H
6#define _SOC_MSCC_OCELOT_H
7
8#include <linux/ptp_clock_kernel.h>

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

113 QSYS,
114 REW,
115 SYS,
116 S0,
117 S1,
118 S2,
119 HSIO,
120 PTP,
121 FDMA,
121 GCB,
122 DEV_GMII,
123 TARGET_MAX,
124};
125
126enum ocelot_reg {
127 ANA_ADVLEARN = ANA << TARGET_OFFSET,
128 ANA_VLANMASK,

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

550
551struct ocelot_ops {
552 struct net_device *(*port_to_netdev)(struct ocelot *ocelot, int port);
553 int (*netdev_to_port)(struct net_device *dev);
554 int (*reset)(struct ocelot *ocelot);
555 u16 (*wm_enc)(u16 value);
556 u16 (*wm_dec)(u16 value);
557 void (*wm_stat)(u32 val, u32 *inuse, u32 *maxuse);
122 GCB,
123 DEV_GMII,
124 TARGET_MAX,
125};
126
127enum ocelot_reg {
128 ANA_ADVLEARN = ANA << TARGET_OFFSET,
129 ANA_VLANMASK,

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

551
552struct ocelot_ops {
553 struct net_device *(*port_to_netdev)(struct ocelot *ocelot, int port);
554 int (*netdev_to_port)(struct net_device *dev);
555 int (*reset)(struct ocelot *ocelot);
556 u16 (*wm_enc)(u16 value);
557 u16 (*wm_dec)(u16 value);
558 void (*wm_stat)(u32 val, u32 *inuse, u32 *maxuse);
559 void (*psfp_init)(struct ocelot *ocelot);
560 int (*psfp_filter_add)(struct ocelot *ocelot, int port,
561 struct flow_cls_offload *f);
562 int (*psfp_filter_del)(struct ocelot *ocelot, struct flow_cls_offload *f);
563 int (*psfp_stats_get)(struct ocelot *ocelot, struct flow_cls_offload *f,
564 struct flow_stats *stats);
565 void (*cut_through_fwd)(struct ocelot *ocelot);
558};
559
566};
567
568struct ocelot_vcap_policer {
569 struct list_head pol_list;
570 u16 base;
571 u16 max;
572 u16 base2;
573 u16 max2;
574};
575
560struct ocelot_vcap_block {
561 struct list_head rules;
562 int count;
576struct ocelot_vcap_block {
577 struct list_head rules;
578 int count;
563 int pol_lpr;
564};
565
566struct ocelot_bridge_vlan {
567 u16 vid;
568 unsigned long portmask;
569 unsigned long untagged;
570 struct list_head list;
571};

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

576 /* all VLANs except the native VLAN and VID 0 are egress-tagged */
577 OCELOT_PORT_TAG_NATIVE = 1,
578 /* all VLANs except VID 0 are egress-tagged */
579 OCELOT_PORT_TAG_TRUNK_NO_VID0 = 2,
580 /* all VLANs are egress-tagged */
581 OCELOT_PORT_TAG_TRUNK = 3,
582};
583
579};
580
581struct ocelot_bridge_vlan {
582 u16 vid;
583 unsigned long portmask;
584 unsigned long untagged;
585 struct list_head list;
586};

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

591 /* all VLANs except the native VLAN and VID 0 are egress-tagged */
592 OCELOT_PORT_TAG_NATIVE = 1,
593 /* all VLANs except VID 0 are egress-tagged */
594 OCELOT_PORT_TAG_TRUNK_NO_VID0 = 2,
595 /* all VLANs are egress-tagged */
596 OCELOT_PORT_TAG_TRUNK = 3,
597};
598
599struct ocelot_psfp_list {
600 struct list_head stream_list;
601 struct list_head sfi_list;
602 struct list_head sgi_list;
603};
604
584enum ocelot_sb {
585 OCELOT_SB_BUF,
586 OCELOT_SB_REF,
587 OCELOT_SB_NUM,
588};
589
590enum ocelot_sb_pool {
591 OCELOT_SB_POOL_ING,
592 OCELOT_SB_POOL_EGR,
593 OCELOT_SB_POOL_NUM,
594};
595
605enum ocelot_sb {
606 OCELOT_SB_BUF,
607 OCELOT_SB_REF,
608 OCELOT_SB_NUM,
609};
610
611enum ocelot_sb_pool {
612 OCELOT_SB_POOL_ING,
613 OCELOT_SB_POOL_EGR,
614 OCELOT_SB_POOL_NUM,
615};
616
617/* MAC table entry types.
618 * ENTRYTYPE_NORMAL is subject to aging.
619 * ENTRYTYPE_LOCKED is not subject to aging.
620 * ENTRYTYPE_MACv4 is not subject to aging. For IPv4 multicast.
621 * ENTRYTYPE_MACv6 is not subject to aging. For IPv6 multicast.
622 */
623enum macaccess_entry_type {
624 ENTRYTYPE_NORMAL = 0,
625 ENTRYTYPE_LOCKED,
626 ENTRYTYPE_MACv4,
627 ENTRYTYPE_MACv6,
628};
629
596#define OCELOT_QUIRK_PCS_PERFORMS_RATE_ADAPTATION BIT(0)
597#define OCELOT_QUIRK_QSGMII_PORTS_MUST_BE_UP BIT(1)
598
599struct ocelot_port {
600 struct ocelot *ocelot;
601
602 struct regmap *target;
603

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

618
619 struct net_device *bond;
620 bool lag_tx_active;
621
622 u16 mrp_ring_id;
623
624 struct net_device *bridge;
625 u8 stp_state;
630#define OCELOT_QUIRK_PCS_PERFORMS_RATE_ADAPTATION BIT(0)
631#define OCELOT_QUIRK_QSGMII_PORTS_MUST_BE_UP BIT(1)
632
633struct ocelot_port {
634 struct ocelot *ocelot;
635
636 struct regmap *target;
637

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

652
653 struct net_device *bond;
654 bool lag_tx_active;
655
656 u16 mrp_ring_id;
657
658 struct net_device *bridge;
659 u8 stp_state;
660
661 int speed;
626};
627
628struct ocelot {
629 struct device *dev;
630 struct devlink *devlink;
631 struct devlink_port *devlink_ports;
632
633 const struct ocelot_ops *ops;

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

662 enum ocelot_tag_prefix npi_inj_prefix;
663 enum ocelot_tag_prefix npi_xtr_prefix;
664
665 struct list_head multicast;
666 struct list_head pgids;
667
668 struct list_head dummy_rules;
669 struct ocelot_vcap_block block[3];
662};
663
664struct ocelot {
665 struct device *dev;
666 struct devlink *devlink;
667 struct devlink_port *devlink_ports;
668
669 const struct ocelot_ops *ops;

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

698 enum ocelot_tag_prefix npi_inj_prefix;
699 enum ocelot_tag_prefix npi_xtr_prefix;
700
701 struct list_head multicast;
702 struct list_head pgids;
703
704 struct list_head dummy_rules;
705 struct ocelot_vcap_block block[3];
706 struct ocelot_vcap_policer vcap_pol;
670 struct vcap_props *vcap;
671
707 struct vcap_props *vcap;
708
709 struct ocelot_psfp_list psfp;
710
672 /* Workqueue to check statistics for overflow with its lock */
673 struct mutex stats_lock;
674 u64 *stats;
675 struct delayed_work stats_work;
676 struct workqueue_struct *stats_queue;
677
678 /* Lock for serializing access to the MAC table */
679 struct mutex mact_lock;
711 /* Workqueue to check statistics for overflow with its lock */
712 struct mutex stats_lock;
713 u64 *stats;
714 struct delayed_work stats_work;
715 struct workqueue_struct *stats_queue;
716
717 /* Lock for serializing access to the MAC table */
718 struct mutex mact_lock;
719 /* Lock for serializing forwarding domain changes */
720 struct mutex fwd_domain_lock;
680
681 struct workqueue_struct *owq;
682
683 u8 ptp:1;
684 struct ptp_clock *ptp_clock;
685 struct ptp_clock_info ptp_info;
686 struct hwtstamp_config hwtstamp_config;
687 unsigned int ptp_skbs_in_flight;
688 /* Protects the 2-step TX timestamp ID logic */
689 spinlock_t ts_id_lock;
690 /* Protects the PTP interface state */
691 struct mutex ptp_lock;
692 /* Protects the PTP clock */
693 spinlock_t ptp_clock_lock;
694 struct ptp_pin_desc ptp_pins[OCELOT_PTP_PINS_NUM];
721
722 struct workqueue_struct *owq;
723
724 u8 ptp:1;
725 struct ptp_clock *ptp_clock;
726 struct ptp_clock_info ptp_info;
727 struct hwtstamp_config hwtstamp_config;
728 unsigned int ptp_skbs_in_flight;
729 /* Protects the 2-step TX timestamp ID logic */
730 spinlock_t ts_id_lock;
731 /* Protects the PTP interface state */
732 struct mutex ptp_lock;
733 /* Protects the PTP clock */
734 spinlock_t ptp_clock_lock;
735 struct ptp_pin_desc ptp_pins[OCELOT_PTP_PINS_NUM];
736
737 struct ocelot_fdma *fdma;
695};
696
697struct ocelot_policer {
698 u32 rate; /* kilobit per second */
699 u32 burst; /* bytes */
700};
701
702#define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))

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

749 u32 reg, u32 offset);
750void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target,
751 u32 val, u32 reg, u32 offset);
752
753/* Packet I/O */
754bool ocelot_can_inject(struct ocelot *ocelot, int grp);
755void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp,
756 u32 rew_op, struct sk_buff *skb);
738};
739
740struct ocelot_policer {
741 u32 rate; /* kilobit per second */
742 u32 burst; /* bytes */
743};
744
745#define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))

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

792 u32 reg, u32 offset);
793void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target,
794 u32 val, u32 reg, u32 offset);
795
796/* Packet I/O */
797bool ocelot_can_inject(struct ocelot *ocelot, int grp);
798void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp,
799 u32 rew_op, struct sk_buff *skb);
800void ocelot_ifh_port_set(void *ifh, int port, u32 rew_op, u32 vlan_tag);
757int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct sk_buff **skb);
758void ocelot_drain_cpu_queue(struct ocelot *ocelot, int grp);
801int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct sk_buff **skb);
802void ocelot_drain_cpu_queue(struct ocelot *ocelot, int grp);
803void ocelot_ptp_rx_timestamp(struct ocelot *ocelot, struct sk_buff *skb,
804 u64 timestamp);
759
760/* Hardware initialization */
761int ocelot_regfields_init(struct ocelot *ocelot,
762 const struct reg_field *const regfields);
763struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res);
764int ocelot_init(struct ocelot *ocelot);
765void ocelot_deinit(struct ocelot *ocelot);
766void ocelot_init_port(struct ocelot *ocelot, int port);

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

771void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data);
772int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset);
773int ocelot_get_ts_info(struct ocelot *ocelot, int port,
774 struct ethtool_ts_info *info);
775void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs);
776int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool enabled,
777 struct netlink_ext_ack *extack);
778void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state);
805
806/* Hardware initialization */
807int ocelot_regfields_init(struct ocelot *ocelot,
808 const struct reg_field *const regfields);
809struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res);
810int ocelot_init(struct ocelot *ocelot);
811void ocelot_deinit(struct ocelot *ocelot);
812void ocelot_init_port(struct ocelot *ocelot, int port);

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

817void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data);
818int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset);
819int ocelot_get_ts_info(struct ocelot *ocelot, int port,
820 struct ethtool_ts_info *info);
821void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs);
822int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool enabled,
823 struct netlink_ext_ack *extack);
824void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state);
779void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot);
825u32 ocelot_get_dsa_8021q_cpu_mask(struct ocelot *ocelot);
826u32 ocelot_get_bridge_fwd_mask(struct ocelot *ocelot, int src_port);
827void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot, bool joining);
780int ocelot_port_pre_bridge_flags(struct ocelot *ocelot, int port,
781 struct switchdev_brport_flags val);
782void ocelot_port_bridge_flags(struct ocelot *ocelot, int port,
783 struct switchdev_brport_flags val);
784void ocelot_port_bridge_join(struct ocelot *ocelot, int port,
785 struct net_device *bridge);
786void ocelot_port_bridge_leave(struct ocelot *ocelot, int port,
787 struct net_device *bridge);
828int ocelot_port_pre_bridge_flags(struct ocelot *ocelot, int port,
829 struct switchdev_brport_flags val);
830void ocelot_port_bridge_flags(struct ocelot *ocelot, int port,
831 struct switchdev_brport_flags val);
832void ocelot_port_bridge_join(struct ocelot *ocelot, int port,
833 struct net_device *bridge);
834void ocelot_port_bridge_leave(struct ocelot *ocelot, int port,
835 struct net_device *bridge);
836int ocelot_mact_flush(struct ocelot *ocelot, int port);
788int ocelot_fdb_dump(struct ocelot *ocelot, int port,
789 dsa_fdb_dump_cb_t *cb, void *data);
790int ocelot_fdb_add(struct ocelot *ocelot, int port,
791 const unsigned char *addr, u16 vid);
792int ocelot_fdb_del(struct ocelot *ocelot, int port,
793 const unsigned char *addr, u16 vid);
794int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid,
795 bool untagged, struct netlink_ext_ack *extack);

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

865void ocelot_phylink_mac_link_up(struct ocelot *ocelot, int port,
866 struct phy_device *phydev,
867 unsigned int link_an_mode,
868 phy_interface_t interface,
869 int speed, int duplex,
870 bool tx_pause, bool rx_pause,
871 unsigned long quirks);
872
837int ocelot_fdb_dump(struct ocelot *ocelot, int port,
838 dsa_fdb_dump_cb_t *cb, void *data);
839int ocelot_fdb_add(struct ocelot *ocelot, int port,
840 const unsigned char *addr, u16 vid);
841int ocelot_fdb_del(struct ocelot *ocelot, int port,
842 const unsigned char *addr, u16 vid);
843int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid,
844 bool untagged, struct netlink_ext_ack *extack);

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

914void ocelot_phylink_mac_link_up(struct ocelot *ocelot, int port,
915 struct phy_device *phydev,
916 unsigned int link_an_mode,
917 phy_interface_t interface,
918 int speed, int duplex,
919 bool tx_pause, bool rx_pause,
920 unsigned long quirks);
921
922int ocelot_mact_lookup(struct ocelot *ocelot, int *dst_idx,
923 const unsigned char mac[ETH_ALEN],
924 unsigned int vid, enum macaccess_entry_type *type);
925int ocelot_mact_learn_streamdata(struct ocelot *ocelot, int dst_idx,
926 const unsigned char mac[ETH_ALEN],
927 unsigned int vid,
928 enum macaccess_entry_type type,
929 int sfid, int ssid);
930
931int ocelot_vcap_policer_add(struct ocelot *ocelot, u32 pol_ix,
932 struct ocelot_policer *pol);
933int ocelot_vcap_policer_del(struct ocelot *ocelot, u32 pol_ix);
934
873#if IS_ENABLED(CONFIG_BRIDGE_MRP)
874int ocelot_mrp_add(struct ocelot *ocelot, int port,
875 const struct switchdev_obj_mrp *mrp);
876int ocelot_mrp_del(struct ocelot *ocelot, int port,
877 const struct switchdev_obj_mrp *mrp);
878int ocelot_mrp_add_ring_role(struct ocelot *ocelot, int port,
879 const struct switchdev_obj_ring_role_mrp *mrp);
880int ocelot_mrp_del_ring_role(struct ocelot *ocelot, int port,

--- 30 unchanged lines hidden ---
935#if IS_ENABLED(CONFIG_BRIDGE_MRP)
936int ocelot_mrp_add(struct ocelot *ocelot, int port,
937 const struct switchdev_obj_mrp *mrp);
938int ocelot_mrp_del(struct ocelot *ocelot, int port,
939 const struct switchdev_obj_mrp *mrp);
940int ocelot_mrp_add_ring_role(struct ocelot *ocelot, int port,
941 const struct switchdev_obj_ring_role_mrp *mrp);
942int ocelot_mrp_del_ring_role(struct ocelot *ocelot, int port,

--- 30 unchanged lines hidden ---