Skip to content

Commit 65fbd20

Browse files
Jiri Pirkogregkh
authored andcommitted
dpll: add clock quality level attribute and op
[ Upstream commit a1afb95 ] In order to allow driver expose quality level of the clock it is running, introduce a new netlink attr with enum to carry it to the userspace. Also, introduce an op the dpll netlink code calls into the driver to obtain the value. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Link: https://patch.msgid.link/20241030081157.966604-2-jiri@resnulli.us Signed-off-by: Jakub Kicinski <kuba@kernel.org> Stable-dep-of: 11c057d ("net/mlx5: Fix MCIA register buffer overflow on 32 dword reads") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f488116 commit 65fbd20

4 files changed

Lines changed: 93 additions & 0 deletions

File tree

Documentation/netlink/specs/dpll.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,36 @@ definitions:
8585
This may happen for example if dpll device was previously
8686
locked on an input pin of type PIN_TYPE_SYNCE_ETH_PORT.
8787
render-max: true
88+
-
89+
type: enum
90+
name: clock-quality-level
91+
doc: |
92+
level of quality of a clock device. This mainly applies when
93+
the dpll lock-status is DPLL_LOCK_STATUS_HOLDOVER.
94+
The current list is defined according to the table 11-7 contained
95+
in ITU-T G.8264/Y.1364 document. One may extend this list freely
96+
by other ITU-T defined clock qualities, or different ones defined
97+
by another standardization body (for those, please use
98+
different prefix).
99+
entries:
100+
-
101+
name: itu-opt1-prc
102+
value: 1
103+
-
104+
name: itu-opt1-ssu-a
105+
-
106+
name: itu-opt1-ssu-b
107+
-
108+
name: itu-opt1-eec1
109+
-
110+
name: itu-opt1-prtc
111+
-
112+
name: itu-opt1-eprtc
113+
-
114+
name: itu-opt1-eeec
115+
-
116+
name: itu-opt1-eprc
117+
render-max: true
88118
-
89119
type: const
90120
name: temp-divider
@@ -252,6 +282,17 @@ attribute-sets:
252282
name: lock-status-error
253283
type: u32
254284
enum: lock-status-error
285+
-
286+
name: clock-quality-level
287+
type: u32
288+
enum: clock-quality-level
289+
multi-attr: true
290+
doc: |
291+
Level of quality of a clock device. This mainly applies when
292+
the dpll lock-status is DPLL_LOCK_STATUS_HOLDOVER. This could
293+
be put to message multiple times to indicate possible parallel
294+
quality levels (e.g. one specified by ITU option 1 and another
295+
one specified by option 2).
255296
-
256297
name: pin
257298
enum-name: dpll_a_pin

drivers/dpll/dpll_netlink.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,27 @@ dpll_msg_add_temp(struct sk_buff *msg, struct dpll_device *dpll,
187187
return 0;
188188
}
189189

190+
static int
191+
dpll_msg_add_clock_quality_level(struct sk_buff *msg, struct dpll_device *dpll,
192+
struct netlink_ext_ack *extack)
193+
{
194+
const struct dpll_device_ops *ops = dpll_device_ops(dpll);
195+
DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX) = { 0 };
196+
enum dpll_clock_quality_level ql;
197+
int ret;
198+
199+
if (!ops->clock_quality_level_get)
200+
return 0;
201+
ret = ops->clock_quality_level_get(dpll, dpll_priv(dpll), qls, extack);
202+
if (ret)
203+
return ret;
204+
for_each_set_bit(ql, qls, DPLL_CLOCK_QUALITY_LEVEL_MAX)
205+
if (nla_put_u32(msg, DPLL_A_CLOCK_QUALITY_LEVEL, ql))
206+
return -EMSGSIZE;
207+
208+
return 0;
209+
}
210+
190211
static int
191212
dpll_msg_add_pin_prio(struct sk_buff *msg, struct dpll_pin *pin,
192213
struct dpll_pin_ref *ref,
@@ -623,6 +644,9 @@ dpll_device_get_one(struct dpll_device *dpll, struct sk_buff *msg,
623644
if (ret)
624645
return ret;
625646
ret = dpll_msg_add_lock_status(msg, dpll, extack);
647+
if (ret)
648+
return ret;
649+
ret = dpll_msg_add_clock_quality_level(msg, dpll, extack);
626650
if (ret)
627651
return ret;
628652
ret = dpll_msg_add_mode(msg, dpll, extack);

include/linux/dpll.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ struct dpll_device_ops {
2828
struct netlink_ext_ack *extack);
2929
int (*temp_get)(const struct dpll_device *dpll, void *dpll_priv,
3030
s32 *temp, struct netlink_ext_ack *extack);
31+
int (*clock_quality_level_get)(const struct dpll_device *dpll,
32+
void *dpll_priv,
33+
unsigned long *qls,
34+
struct netlink_ext_ack *extack);
3135
};
3236

3337
struct dpll_pin_ops {

include/uapi/linux/dpll.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,29 @@ enum dpll_lock_status_error {
7979
DPLL_LOCK_STATUS_ERROR_MAX = (__DPLL_LOCK_STATUS_ERROR_MAX - 1)
8080
};
8181

82+
/**
83+
* enum dpll_clock_quality_level - level of quality of a clock device. This
84+
* mainly applies when the dpll lock-status is DPLL_LOCK_STATUS_HOLDOVER. The
85+
* current list is defined according to the table 11-7 contained in ITU-T
86+
* G.8264/Y.1364 document. One may extend this list freely by other ITU-T
87+
* defined clock qualities, or different ones defined by another
88+
* standardization body (for those, please use different prefix).
89+
*/
90+
enum dpll_clock_quality_level {
91+
DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_PRC = 1,
92+
DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_SSU_A,
93+
DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_SSU_B,
94+
DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EEC1,
95+
DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_PRTC,
96+
DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRTC,
97+
DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EEEC,
98+
DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRC,
99+
100+
/* private: */
101+
__DPLL_CLOCK_QUALITY_LEVEL_MAX,
102+
DPLL_CLOCK_QUALITY_LEVEL_MAX = (__DPLL_CLOCK_QUALITY_LEVEL_MAX - 1)
103+
};
104+
82105
#define DPLL_TEMP_DIVIDER 1000
83106

84107
/**
@@ -180,6 +203,7 @@ enum dpll_a {
180203
DPLL_A_TEMP,
181204
DPLL_A_TYPE,
182205
DPLL_A_LOCK_STATUS_ERROR,
206+
DPLL_A_CLOCK_QUALITY_LEVEL,
183207

184208
__DPLL_A_MAX,
185209
DPLL_A_MAX = (__DPLL_A_MAX - 1)

0 commit comments

Comments
 (0)