This patch enables support for ingress broadcast(BC)/multicast(MC) packets rate limiting in TI AM65x CPSW driver (the corresponding ALE support was added in previous patch) by implementing HW offload for simple tc-flower with policer action with matches on dst_mac/mask: - ff:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff has to be used for BC packets rate limiting (exact match) - 01:00:00:00:00:00/01:00:00:00:00:00 fixed value has to be used for MC packets rate limiting The CPSW supports MC/BC packets rate limiting in packets/sec and affects all ingress MC/BC packets and serves as BC/MC storm prevention feature. Examples: - BC rate limit to 1000pps: tc qdisc add dev eth0 clsact tc filter add dev eth0 ingress flower skip_sw dst_mac ff:ff:ff:ff:ff:ff \ action police pkts_rate 1000 pkts_burst 1 drop - MC rate limit to 20000pps: tc qdisc add dev eth0 clsact tc filter add dev eth0 ingress flower skip_sw dst_mac 01:00:00:00:00:00/01:00:00:00:00:00 \ action police rate pkts_rate 20000 pkts_burst 1 drop pkts_burst - not used. Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
38 lines
914 B
C
38 lines
914 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
|
|
*/
|
|
|
|
#ifndef AM65_CPSW_QOS_H_
|
|
#define AM65_CPSW_QOS_H_
|
|
|
|
#include <linux/netdevice.h>
|
|
#include <net/pkt_sched.h>
|
|
|
|
struct am65_cpsw_est {
|
|
int buf;
|
|
/* has to be the last one */
|
|
struct tc_taprio_qopt_offload taprio;
|
|
};
|
|
|
|
struct am65_cpsw_ale_ratelimit {
|
|
unsigned long cookie;
|
|
u64 rate_packet_ps;
|
|
};
|
|
|
|
struct am65_cpsw_qos {
|
|
struct am65_cpsw_est *est_admin;
|
|
struct am65_cpsw_est *est_oper;
|
|
ktime_t link_down_time;
|
|
int link_speed;
|
|
|
|
struct am65_cpsw_ale_ratelimit ale_bc_ratelimit;
|
|
struct am65_cpsw_ale_ratelimit ale_mc_ratelimit;
|
|
};
|
|
|
|
int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type,
|
|
void *type_data);
|
|
void am65_cpsw_qos_link_up(struct net_device *ndev, int link_speed);
|
|
void am65_cpsw_qos_link_down(struct net_device *ndev);
|
|
|
|
#endif /* AM65_CPSW_QOS_H_ */
|