xref: /linux/drivers/net/ethernet/mscc/ocelot_police.h (revision 8e90c499bd6816f6dc4127f071179e7bd190e5aa)
12c1d029aSJoergen Andreasen /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
22c1d029aSJoergen Andreasen /* Microsemi Ocelot Switch driver
32c1d029aSJoergen Andreasen  *
42c1d029aSJoergen Andreasen  * Copyright (c) 2019 Microsemi Corporation
52c1d029aSJoergen Andreasen  */
62c1d029aSJoergen Andreasen 
72c1d029aSJoergen Andreasen #ifndef _MSCC_OCELOT_POLICE_H_
82c1d029aSJoergen Andreasen #define _MSCC_OCELOT_POLICE_H_
92c1d029aSJoergen Andreasen 
102c1d029aSJoergen Andreasen #include "ocelot.h"
11d97b4b10SJianbo Liu #include <net/flow_offload.h>
122c1d029aSJoergen Andreasen 
139c90eea3SVladimir Oltean enum mscc_qos_rate_mode {
149c90eea3SVladimir Oltean 	MSCC_QOS_RATE_MODE_DISABLED, /* Policer/shaper disabled */
159c90eea3SVladimir Oltean 	MSCC_QOS_RATE_MODE_LINE, /* Measure line rate in kbps incl. IPG */
169c90eea3SVladimir Oltean 	MSCC_QOS_RATE_MODE_DATA, /* Measures data rate in kbps excl. IPG */
179c90eea3SVladimir Oltean 	MSCC_QOS_RATE_MODE_FRAME, /* Measures frame rate in fps */
189c90eea3SVladimir Oltean 	__MSCC_QOS_RATE_MODE_END,
199c90eea3SVladimir Oltean 	NUM_MSCC_QOS_RATE_MODE = __MSCC_QOS_RATE_MODE_END,
209c90eea3SVladimir Oltean 	MSCC_QOS_RATE_MODE_MAX = __MSCC_QOS_RATE_MODE_END - 1,
219c90eea3SVladimir Oltean };
229c90eea3SVladimir Oltean 
239c90eea3SVladimir Oltean struct qos_policer_conf {
249c90eea3SVladimir Oltean 	enum mscc_qos_rate_mode mode;
259c90eea3SVladimir Oltean 	bool dlb; /* Enable DLB (dual leaky bucket mode */
269c90eea3SVladimir Oltean 	bool cf;  /* Coupling flag (ignored in SLB mode) */
279c90eea3SVladimir Oltean 	u32  cir; /* CIR in kbps/fps (ignored in SLB mode) */
289c90eea3SVladimir Oltean 	u32  cbs; /* CBS in bytes/frames (ignored in SLB mode) */
299c90eea3SVladimir Oltean 	u32  pir; /* PIR in kbps/fps */
309c90eea3SVladimir Oltean 	u32  pbs; /* PBS in bytes/frames */
319c90eea3SVladimir Oltean 	u8   ipg; /* Size of IPG when MSCC_QOS_RATE_MODE_LINE is chosen */
329c90eea3SVladimir Oltean };
339c90eea3SVladimir Oltean 
34*8e90c499SVladimir Oltean int qos_policer_conf_set(struct ocelot *ocelot, u32 pol_ix,
359c90eea3SVladimir Oltean 			 struct qos_policer_conf *conf);
369c90eea3SVladimir Oltean 
37d97b4b10SJianbo Liu int ocelot_policer_validate(const struct flow_action *action,
38d97b4b10SJianbo Liu 			    const struct flow_action_entry *a,
39d97b4b10SJianbo Liu 			    struct netlink_ext_ack *extack);
40d97b4b10SJianbo Liu 
412c1d029aSJoergen Andreasen #endif /* _MSCC_OCELOT_POLICE_H_ */
42