Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Microchip KSZ9477 series Header file
4 *
5 * Copyright (C) 2017-2022 Microchip Technology Inc.
6 */
7
8#ifndef __KSZ9477_H
9#define __KSZ9477_H
10
11#include <net/dsa.h>
12#include "ksz_common.h"
13
14int ksz9477_setup(struct dsa_switch *ds);
15u32 ksz9477_get_port_addr(int port, int offset);
16void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member);
17void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port);
18void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port);
19int ksz9477_set_ageing_time(struct ksz_device *dev, unsigned int msecs);
20int ksz9477_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data);
21int ksz9477_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val);
22void ksz9477_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u64 *cnt);
23void ksz9477_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,
24 u64 *dropped, u64 *cnt);
25void ksz9477_freeze_mib(struct ksz_device *dev, int port, bool freeze);
26void ksz9477_port_init_cnt(struct ksz_device *dev, int port);
27int ksz9477_port_vlan_filtering(struct ksz_device *dev, int port,
28 bool flag, struct netlink_ext_ack *extack);
29int ksz9477_port_vlan_add(struct ksz_device *dev, int port,
30 const struct switchdev_obj_port_vlan *vlan,
31 struct netlink_ext_ack *extack);
32int ksz9477_port_vlan_del(struct ksz_device *dev, int port,
33 const struct switchdev_obj_port_vlan *vlan);
34int ksz9477_port_mirror_add(struct ksz_device *dev, int port,
35 struct dsa_mall_mirror_tc_entry *mirror,
36 bool ingress, struct netlink_ext_ack *extack);
37void ksz9477_port_mirror_del(struct ksz_device *dev, int port,
38 struct dsa_mall_mirror_tc_entry *mirror);
39int ksz9477_errata_monitor(struct ksz_device *dev, int port,
40 u64 tx_late_col);
41void ksz9477_get_caps(struct ksz_device *dev, int port,
42 struct phylink_config *config);
43int ksz9477_fdb_dump(struct ksz_device *dev, int port,
44 dsa_fdb_dump_cb_t *cb, void *data);
45int ksz9477_fdb_add(struct ksz_device *dev, int port,
46 const unsigned char *addr, u16 vid, struct dsa_db db);
47int ksz9477_fdb_del(struct ksz_device *dev, int port,
48 const unsigned char *addr, u16 vid, struct dsa_db db);
49int ksz9477_mdb_add(struct ksz_device *dev, int port,
50 const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
51int ksz9477_mdb_del(struct ksz_device *dev, int port,
52 const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
53int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu);
54void ksz9477_config_cpu_port(struct dsa_switch *ds);
55int ksz9477_tc_cbs_set_cinc(struct ksz_device *dev, int port, u32 val);
56int ksz9477_enable_stp_addr(struct ksz_device *dev);
57int ksz9477_reset_switch(struct ksz_device *dev);
58int ksz9477_switch_init(struct ksz_device *dev);
59void ksz9477_switch_exit(struct ksz_device *dev);
60void ksz9477_port_queue_split(struct ksz_device *dev, int port);
61void ksz9477_hsr_join(struct dsa_switch *ds, int port, struct net_device *hsr);
62void ksz9477_hsr_leave(struct dsa_switch *ds, int port, struct net_device *hsr);
63
64int ksz9477_port_acl_init(struct ksz_device *dev, int port);
65void ksz9477_port_acl_free(struct ksz_device *dev, int port);
66int ksz9477_cls_flower_add(struct dsa_switch *ds, int port,
67 struct flow_cls_offload *cls, bool ingress);
68int ksz9477_cls_flower_del(struct dsa_switch *ds, int port,
69 struct flow_cls_offload *cls, bool ingress);
70
71#define KSZ9477_ACL_ENTRY_SIZE 18
72#define KSZ9477_ACL_MAX_ENTRIES 16
73
74struct ksz9477_acl_entry {
75 u8 entry[KSZ9477_ACL_ENTRY_SIZE];
76 unsigned long cookie;
77 u32 prio;
78};
79
80struct ksz9477_acl_entries {
81 struct ksz9477_acl_entry entries[KSZ9477_ACL_MAX_ENTRIES];
82 int entries_count;
83};
84
85struct ksz9477_acl_priv {
86 struct ksz9477_acl_entries acles;
87};
88
89void ksz9477_acl_remove_entries(struct ksz_device *dev, int port,
90 struct ksz9477_acl_entries *acles,
91 unsigned long cookie);
92int ksz9477_acl_write_list(struct ksz_device *dev, int port);
93int ksz9477_sort_acl_entries(struct ksz_device *dev, int port);
94void ksz9477_acl_action_rule_cfg(u8 *entry, bool force_prio, u8 prio_val);
95void ksz9477_acl_processing_rule_set_action(u8 *entry, u8 action_idx);
96void ksz9477_acl_match_process_l2(struct ksz_device *dev, int port,
97 u16 ethtype, u8 *src_mac, u8 *dst_mac,
98 unsigned long cookie, u32 prio);
99
100#endif
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Microchip KSZ9477 series Header file
4 *
5 * Copyright (C) 2017-2022 Microchip Technology Inc.
6 */
7
8#ifndef __KSZ9477_H
9#define __KSZ9477_H
10
11#include <net/dsa.h>
12#include "ksz_common.h"
13
14int ksz9477_setup(struct dsa_switch *ds);
15u32 ksz9477_get_port_addr(int port, int offset);
16void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member);
17void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port);
18void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port);
19int ksz9477_set_ageing_time(struct ksz_device *dev, unsigned int msecs);
20int ksz9477_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data);
21int ksz9477_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val);
22void ksz9477_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u64 *cnt);
23void ksz9477_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,
24 u64 *dropped, u64 *cnt);
25void ksz9477_freeze_mib(struct ksz_device *dev, int port, bool freeze);
26void ksz9477_port_init_cnt(struct ksz_device *dev, int port);
27int ksz9477_port_vlan_filtering(struct ksz_device *dev, int port,
28 bool flag, struct netlink_ext_ack *extack);
29int ksz9477_port_vlan_add(struct ksz_device *dev, int port,
30 const struct switchdev_obj_port_vlan *vlan,
31 struct netlink_ext_ack *extack);
32int ksz9477_port_vlan_del(struct ksz_device *dev, int port,
33 const struct switchdev_obj_port_vlan *vlan);
34int ksz9477_port_mirror_add(struct ksz_device *dev, int port,
35 struct dsa_mall_mirror_tc_entry *mirror,
36 bool ingress, struct netlink_ext_ack *extack);
37void ksz9477_port_mirror_del(struct ksz_device *dev, int port,
38 struct dsa_mall_mirror_tc_entry *mirror);
39int ksz9477_get_stp_reg(void);
40void ksz9477_get_caps(struct ksz_device *dev, int port,
41 struct phylink_config *config);
42int ksz9477_fdb_dump(struct ksz_device *dev, int port,
43 dsa_fdb_dump_cb_t *cb, void *data);
44int ksz9477_fdb_add(struct ksz_device *dev, int port,
45 const unsigned char *addr, u16 vid, struct dsa_db db);
46int ksz9477_fdb_del(struct ksz_device *dev, int port,
47 const unsigned char *addr, u16 vid, struct dsa_db db);
48int ksz9477_mdb_add(struct ksz_device *dev, int port,
49 const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
50int ksz9477_mdb_del(struct ksz_device *dev, int port,
51 const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
52int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu);
53void ksz9477_config_cpu_port(struct dsa_switch *ds);
54int ksz9477_enable_stp_addr(struct ksz_device *dev);
55int ksz9477_reset_switch(struct ksz_device *dev);
56int ksz9477_dsa_init(struct ksz_device *dev);
57int ksz9477_switch_init(struct ksz_device *dev);
58void ksz9477_switch_exit(struct ksz_device *dev);
59
60#endif