2022-06-22 14:34:23 +05:30
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* Microchip KSZ9477 series Header file
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017-2022 Microchip Technology Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __KSZ9477_H
|
|
|
|
#define __KSZ9477_H
|
|
|
|
|
|
|
|
#include <net/dsa.h>
|
|
|
|
#include "ksz_common.h"
|
|
|
|
|
|
|
|
int ksz9477_setup(struct dsa_switch *ds);
|
|
|
|
u32 ksz9477_get_port_addr(int port, int offset);
|
|
|
|
void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member);
|
|
|
|
void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port);
|
|
|
|
void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port);
|
2022-09-07 12:50:39 +05:30
|
|
|
int ksz9477_set_ageing_time(struct ksz_device *dev, unsigned int msecs);
|
2022-08-26 12:56:21 +02:00
|
|
|
int ksz9477_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data);
|
|
|
|
int ksz9477_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val);
|
2022-06-22 14:34:23 +05:30
|
|
|
void ksz9477_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u64 *cnt);
|
|
|
|
void ksz9477_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,
|
|
|
|
u64 *dropped, u64 *cnt);
|
|
|
|
void ksz9477_freeze_mib(struct ksz_device *dev, int port, bool freeze);
|
|
|
|
void ksz9477_port_init_cnt(struct ksz_device *dev, int port);
|
|
|
|
int ksz9477_port_vlan_filtering(struct ksz_device *dev, int port,
|
|
|
|
bool flag, struct netlink_ext_ack *extack);
|
|
|
|
int ksz9477_port_vlan_add(struct ksz_device *dev, int port,
|
|
|
|
const struct switchdev_obj_port_vlan *vlan,
|
|
|
|
struct netlink_ext_ack *extack);
|
|
|
|
int ksz9477_port_vlan_del(struct ksz_device *dev, int port,
|
|
|
|
const struct switchdev_obj_port_vlan *vlan);
|
|
|
|
int ksz9477_port_mirror_add(struct ksz_device *dev, int port,
|
|
|
|
struct dsa_mall_mirror_tc_entry *mirror,
|
|
|
|
bool ingress, struct netlink_ext_ack *extack);
|
|
|
|
void ksz9477_port_mirror_del(struct ksz_device *dev, int port,
|
|
|
|
struct dsa_mall_mirror_tc_entry *mirror);
|
|
|
|
void ksz9477_get_caps(struct ksz_device *dev, int port,
|
|
|
|
struct phylink_config *config);
|
|
|
|
int ksz9477_fdb_dump(struct ksz_device *dev, int port,
|
|
|
|
dsa_fdb_dump_cb_t *cb, void *data);
|
|
|
|
int ksz9477_fdb_add(struct ksz_device *dev, int port,
|
|
|
|
const unsigned char *addr, u16 vid, struct dsa_db db);
|
|
|
|
int ksz9477_fdb_del(struct ksz_device *dev, int port,
|
|
|
|
const unsigned char *addr, u16 vid, struct dsa_db db);
|
|
|
|
int ksz9477_mdb_add(struct ksz_device *dev, int port,
|
|
|
|
const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
|
|
|
|
int ksz9477_mdb_del(struct ksz_device *dev, int port,
|
|
|
|
const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
|
|
|
|
int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu);
|
|
|
|
void ksz9477_config_cpu_port(struct dsa_switch *ds);
|
2023-01-20 10:51:35 +05:30
|
|
|
int ksz9477_tc_cbs_set_cinc(struct ksz_device *dev, int port, u32 val);
|
2022-06-22 14:34:23 +05:30
|
|
|
int ksz9477_enable_stp_addr(struct ksz_device *dev);
|
|
|
|
int ksz9477_reset_switch(struct ksz_device *dev);
|
|
|
|
int ksz9477_switch_init(struct ksz_device *dev);
|
|
|
|
void ksz9477_switch_exit(struct ksz_device *dev);
|
2023-01-20 10:51:34 +05:30
|
|
|
void ksz9477_port_queue_split(struct ksz_device *dev, int port);
|
2023-09-22 15:31:08 +02:00
|
|
|
void ksz9477_hsr_join(struct dsa_switch *ds, int port, struct net_device *hsr);
|
|
|
|
void ksz9477_hsr_leave(struct dsa_switch *ds, int port, struct net_device *hsr);
|
2023-10-23 11:33:38 +02:00
|
|
|
void ksz9477_get_wol(struct ksz_device *dev, int port,
|
|
|
|
struct ethtool_wolinfo *wol);
|
|
|
|
int ksz9477_set_wol(struct ksz_device *dev, int port,
|
|
|
|
struct ethtool_wolinfo *wol);
|
2023-10-26 07:10:51 +02:00
|
|
|
void ksz9477_wol_pre_shutdown(struct ksz_device *dev, bool *wol_enabled);
|
2022-06-22 14:34:23 +05:30
|
|
|
|
net: dsa: microchip: Add partial ACL support for ksz9477 switches
This patch adds partial Access Control List (ACL) support for the
ksz9477 family of switches. ACLs enable filtering of incoming layer 2
MAC, layer 3 IP, and layer 4 TCP/UDP packets on each port. They provide
additional capabilities for filtering routed network protocols and can
take precedence over other forwarding functions.
ACLs can filter ingress traffic based on header fields such as
source/destination MAC address, EtherType, IPv4 address, IPv4 protocol,
UDP/TCP ports, and TCP flags. The ACL is an ordered list of up to 16
access control rules programmed into the ACL Table. Each entry specifies
a set of matching conditions and action rules for controlling packet
forwarding and priority.
The ACL also implements a count function, generating an interrupt
instead of a forwarding action. It can be used as a watchdog timer or an
event counter. The ACL consists of three parts: matching rules, action
rules, and processing entries. Multiple match conditions can be either
AND'ed or OR'ed together.
This patch introduces support for a subset of the available ACL
functionality, specifically layer 2 matching and prioritization of
matched packets. For example:
tc qdisc add dev lan2 clsact
tc filter add dev lan2 ingress protocol 0x88f7 flower action skbedit prio 7
tc qdisc add dev lan1 clsact
tc filter add dev lan1 ingress protocol 0x88f7 flower action skbedit prio 7
The hardware offloading implementation was benchmarked against a
configuration without hardware offloading. This latter setup relied on a
software-based Linux bridge. No noticeable differences were observed
between the two configurations. Here is an example of software-based
test:
ip l s dev enu1u1 up
ip l s dev enu1u2 up
ip l s dev enu1u4 up
ethtool -A enu1u1 autoneg off rx off tx off
ethtool -A enu1u2 autoneg off rx off tx off
ethtool -A enu1u4 autoneg off rx off tx off
ip l a name br0 type bridge
ip l s dev br0 up
ip l s enu1u1 master br0
ip l s enu1u2 master br0
ip l s enu1u4 master br0
tc qdisc add dev enu1u1 root handle 1: ets strict 4 priomap 3 3 2 2 1 1 0 0
tc qdisc add dev enu1u4 root handle 1: ets strict 4 priomap 3 3 2 2 1 1 0 0
tc qdisc add dev enu1u2 root handle 1: ets strict 4 priomap 3 3 2 2 1 1 0 0
tc qdisc add dev enu1u1 clsact
tc filter add dev enu1u1 ingress protocol ipv4 flower action skbedit prio 7
tc qdisc add dev enu1u4 clsact
tc filter add dev enu1u4 ingress protocol ipv4 flower action skbedit prio 0
On a system attached to the port enu1u2 I run two iperf3 server
instances:
iperf3 -s -p 5210 &
iperf3 -s -p 5211 &
On systems attached to enu1u4 and enu1u1 I run:
iperf3 -u -c 172.17.0.1 -p 5210 -b100M -l1472 -t100
and
iperf3 -u -c 172.17.0.1 -p 5211 -b100M -l1472 -t100
As a result, IP traffic on port enu1u1 will be prioritized and take
precedence over IP traffic on port enu1u4
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2023-09-14 15:11:45 +02:00
|
|
|
int ksz9477_port_acl_init(struct ksz_device *dev, int port);
|
|
|
|
void ksz9477_port_acl_free(struct ksz_device *dev, int port);
|
|
|
|
int ksz9477_cls_flower_add(struct dsa_switch *ds, int port,
|
|
|
|
struct flow_cls_offload *cls, bool ingress);
|
|
|
|
int ksz9477_cls_flower_del(struct dsa_switch *ds, int port,
|
|
|
|
struct flow_cls_offload *cls, bool ingress);
|
|
|
|
|
|
|
|
#define KSZ9477_ACL_ENTRY_SIZE 18
|
|
|
|
#define KSZ9477_ACL_MAX_ENTRIES 16
|
|
|
|
|
|
|
|
struct ksz9477_acl_entry {
|
|
|
|
u8 entry[KSZ9477_ACL_ENTRY_SIZE];
|
|
|
|
unsigned long cookie;
|
|
|
|
u32 prio;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ksz9477_acl_entries {
|
|
|
|
struct ksz9477_acl_entry entries[KSZ9477_ACL_MAX_ENTRIES];
|
|
|
|
int entries_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ksz9477_acl_priv {
|
|
|
|
struct ksz9477_acl_entries acles;
|
|
|
|
};
|
|
|
|
|
|
|
|
void ksz9477_acl_remove_entries(struct ksz_device *dev, int port,
|
|
|
|
struct ksz9477_acl_entries *acles,
|
|
|
|
unsigned long cookie);
|
|
|
|
int ksz9477_acl_write_list(struct ksz_device *dev, int port);
|
|
|
|
int ksz9477_sort_acl_entries(struct ksz_device *dev, int port);
|
|
|
|
void ksz9477_acl_action_rule_cfg(u8 *entry, bool force_prio, u8 prio_val);
|
|
|
|
void ksz9477_acl_processing_rule_set_action(u8 *entry, u8 action_idx);
|
|
|
|
void ksz9477_acl_match_process_l2(struct ksz_device *dev, int port,
|
|
|
|
u16 ethtype, u8 *src_mac, u8 *dst_mac,
|
|
|
|
unsigned long cookie, u32 prio);
|
|
|
|
|
2022-06-22 14:34:23 +05:30
|
|
|
#endif
|