xref: /linux/drivers/net/ethernet/mscc/ocelot_police.h (revision d85ddd1318e66c0c2665dbfcbc21a8b66c9152aa)
1 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
2 /* Microsemi Ocelot Switch driver
3  *
4  * Copyright (c) 2019 Microsemi Corporation
5  */
6 
7 #ifndef _MSCC_OCELOT_POLICE_H_
8 #define _MSCC_OCELOT_POLICE_H_
9 
10 #include "ocelot.h"
11 
12 enum mscc_qos_rate_mode {
13 	MSCC_QOS_RATE_MODE_DISABLED, /* Policer/shaper disabled */
14 	MSCC_QOS_RATE_MODE_LINE, /* Measure line rate in kbps incl. IPG */
15 	MSCC_QOS_RATE_MODE_DATA, /* Measures data rate in kbps excl. IPG */
16 	MSCC_QOS_RATE_MODE_FRAME, /* Measures frame rate in fps */
17 	__MSCC_QOS_RATE_MODE_END,
18 	NUM_MSCC_QOS_RATE_MODE = __MSCC_QOS_RATE_MODE_END,
19 	MSCC_QOS_RATE_MODE_MAX = __MSCC_QOS_RATE_MODE_END - 1,
20 };
21 
22 struct qos_policer_conf {
23 	enum mscc_qos_rate_mode mode;
24 	bool dlb; /* Enable DLB (dual leaky bucket mode */
25 	bool cf;  /* Coupling flag (ignored in SLB mode) */
26 	u32  cir; /* CIR in kbps/fps (ignored in SLB mode) */
27 	u32  cbs; /* CBS in bytes/frames (ignored in SLB mode) */
28 	u32  pir; /* PIR in kbps/fps */
29 	u32  pbs; /* PBS in bytes/frames */
30 	u8   ipg; /* Size of IPG when MSCC_QOS_RATE_MODE_LINE is chosen */
31 };
32 
33 int qos_policer_conf_set(struct ocelot *ocelot, int port, u32 pol_ix,
34 			 struct qos_policer_conf *conf);
35 
36 #endif /* _MSCC_OCELOT_POLICE_H_ */
37