xref: /linux/drivers/net/ethernet/mscc/ocelot_police.h (revision 9c90eea310f80460b81a7afe27064c7f0200d1d1)
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"
112c1d029aSJoergen Andreasen 
12*9c90eea3SVladimir Oltean enum mscc_qos_rate_mode {
13*9c90eea3SVladimir Oltean 	MSCC_QOS_RATE_MODE_DISABLED, /* Policer/shaper disabled */
14*9c90eea3SVladimir Oltean 	MSCC_QOS_RATE_MODE_LINE, /* Measure line rate in kbps incl. IPG */
15*9c90eea3SVladimir Oltean 	MSCC_QOS_RATE_MODE_DATA, /* Measures data rate in kbps excl. IPG */
16*9c90eea3SVladimir Oltean 	MSCC_QOS_RATE_MODE_FRAME, /* Measures frame rate in fps */
17*9c90eea3SVladimir Oltean 	__MSCC_QOS_RATE_MODE_END,
18*9c90eea3SVladimir Oltean 	NUM_MSCC_QOS_RATE_MODE = __MSCC_QOS_RATE_MODE_END,
19*9c90eea3SVladimir Oltean 	MSCC_QOS_RATE_MODE_MAX = __MSCC_QOS_RATE_MODE_END - 1,
20*9c90eea3SVladimir Oltean };
21*9c90eea3SVladimir Oltean 
22*9c90eea3SVladimir Oltean struct qos_policer_conf {
23*9c90eea3SVladimir Oltean 	enum mscc_qos_rate_mode mode;
24*9c90eea3SVladimir Oltean 	bool dlb; /* Enable DLB (dual leaky bucket mode */
25*9c90eea3SVladimir Oltean 	bool cf;  /* Coupling flag (ignored in SLB mode) */
26*9c90eea3SVladimir Oltean 	u32  cir; /* CIR in kbps/fps (ignored in SLB mode) */
27*9c90eea3SVladimir Oltean 	u32  cbs; /* CBS in bytes/frames (ignored in SLB mode) */
28*9c90eea3SVladimir Oltean 	u32  pir; /* PIR in kbps/fps */
29*9c90eea3SVladimir Oltean 	u32  pbs; /* PBS in bytes/frames */
30*9c90eea3SVladimir Oltean 	u8   ipg; /* Size of IPG when MSCC_QOS_RATE_MODE_LINE is chosen */
31*9c90eea3SVladimir Oltean };
32*9c90eea3SVladimir Oltean 
33*9c90eea3SVladimir Oltean int qos_policer_conf_set(struct ocelot *ocelot, int port, u32 pol_ix,
34*9c90eea3SVladimir Oltean 			 struct qos_policer_conf *conf);
35*9c90eea3SVladimir Oltean 
36c9a7fe12SXiaoliang Yang int ocelot_ace_policer_add(struct ocelot *ocelot, u32 pol_ix,
37c9a7fe12SXiaoliang Yang 			   struct ocelot_policer *pol);
38c9a7fe12SXiaoliang Yang 
39c9a7fe12SXiaoliang Yang int ocelot_ace_policer_del(struct ocelot *ocelot, u32 pol_ix);
40c9a7fe12SXiaoliang Yang 
412c1d029aSJoergen Andreasen #endif /* _MSCC_OCELOT_POLICE_H_ */
42