Documentation/driver-api/hte/hte.rst GitHub 원문 ↗

Linux 6.18.37 · Driver API

The Linux Hardware Timestamping Engine (HTE)

HTE provider·consumer API, nanosecond timestamp lifecycle과 debugfs 통계를 설명합니다.

Source pathDocumentation/driver-api/hte/hte.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

hte.rst:1-79

HTE는 signal 변화 순간을 hardware에서 capture해 software timestamp보다 높은 정확도를 제공합니다. Provider는 nanosecond timestamp를 push하고 core는 sequence를 관리하며 consumer callback과 optional threaded callback을 호출합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0+
2
3 ============================================
4 The Linux Hardware Timestamping Engine (HTE)
5 ============================================
6
7 :Author: Dipen Patel
8
9 Introduction
10 ------------
11
12 Certain devices have built in hardware timestamping engines which can
13 monitor sets of system signals, lines, buses etc... in realtime for state
14 change; upon detecting the change they can automatically store the timestamp at
15 the moment of occurrence. Such functionality may help achieve better accuracy
16 in obtaining timestamps than using software counterparts i.e. ktime and
17 friends.
18
19 This document describes the API that can be used by hardware timestamping
20 engine provider and consumer drivers that want to use the hardware timestamping
21 engine (HTE) framework. Both consumers and providers must include
22 ``#include <linux/hte.h>``.
23
24 The HTE framework APIs for the providers
25 ----------------------------------------
26
27 .. kernel-doc:: drivers/hte/hte.c
28 :functions: devm_hte_register_chip hte_push_ts_ns
29
30 The HTE framework APIs for the consumers
31 ----------------------------------------
32
33 .. kernel-doc:: drivers/hte/hte.c
34 :functions: hte_init_line_attr hte_ts_get hte_ts_put devm_hte_request_ts_ns hte_request_ts_ns hte_enable_ts hte_disable_ts of_hte_req_count hte_get_clk_src_info
35
36 The HTE framework public structures
37 -----------------------------------
38 .. kernel-doc:: include/linux/hte.h
39
40 More on the HTE timestamp data
41 ------------------------------
42 The ``struct hte_ts_data`` is used to pass timestamp details between the
43 consumers and the providers. It expresses timestamp data in nanoseconds in
44 u64. An example of the typical timestamp data life cycle, for the GPIO line is
45 as follows::
46
47 - Monitors GPIO line change.
48 - Detects the state change on GPIO line.
49 - Converts timestamps in nanoseconds.
50 - Stores GPIO raw level in raw_level variable if the provider has that
51 hardware capability.
52 - Pushes this hte_ts_data object to HTE subsystem.
53 - HTE subsystem increments seq counter and invokes consumer provided callback.
54 Based on callback return value, the HTE core invokes secondary callback in
55 the thread context.
56
57 HTE subsystem debugfs attributes
58 --------------------------------
59 HTE subsystem creates debugfs attributes at ``/sys/kernel/debug/hte/``.
60 It also creates line/signal-related debugfs attributes at
61 ``/sys/kernel/debug/hte/<provider>/<label or line id>/``. Note that these
62 attributes are read-only.
63
64 `ts_requested`
65 The total number of entities requested from the given provider,
66 where entity is specified by the provider and could represent
67 lines, GPIO, chip signals, buses etc...
68 The attribute will be available at
69 ``/sys/kernel/debug/hte/<provider>/``.
70
71 `total_ts`
72 The total number of entities supported by the provider.
73 The attribute will be available at
74 ``/sys/kernel/debug/hte/<provider>/``.
75
76 `dropped_timestamps`
77 The dropped timestamps for a given line.
78 The attribute will be available at
79 ``/sys/kernel/debug/hte/<provider>/<label or line id>/``.
80

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Hardware Timestamping Engine 소개

1-23

문서 제목은 `The Linux Hardware Timestamping Engine (HTE)`이며 저자는 Dipen Patel입니다.

일부 device에는 system signal, line, bus 등의 state change를 real time으로 감시하고 변화가 감지된 바로 그 순간의 timestamp를 자동 저장하는 hardware timestamping engine이 내장되어 있습니다.

이 기능은 `ktime` 계열 같은 software 방식보다 정확한 timestamp를 얻는 데 도움이 됩니다.

문서는 HTE framework를 사용하는 hardware timestamp engine provider·consumer driver용 API를 설명합니다. Consumer와 provider 모두 `#include <linux/hte.h>`를 include해야 합니다.

Hardware timestamp 포착
Hardware가 signal·line·bus 감시State change 발생Engine이 즉시 counter captureProvider가 timestamp 변환HTE core가 consumer에 전달

Signal 변화에서 nanosecond timestamp 전달까지의 큰 흐름입니다.

Provider·consumer API와 public structure

24-39

Provider framework API는 `drivers/hte/hte.c`의 `devm_hte_register_chip`, `hte_push_ts_ns`입니다.

.. kernel-doc:: drivers/hte/hte.c
   :functions: devm_hte_register_chip hte_push_ts_ns

Consumer API는 같은 source의 `hte_init_line_attr`, `hte_ts_get`, `hte_ts_put`, managed·unmanaged request, enable·disable, Device Tree request count와 clock-source 정보 function입니다.

.. kernel-doc:: drivers/hte/hte.c
   :functions: hte_init_line_attr hte_ts_get hte_ts_put devm_hte_request_ts_ns hte_request_ts_ns hte_enable_ts hte_disable_ts of_hte_req_count hte_get_clk_src_info

Public structure의 kernel-doc source는 `include/linux/hte.h`입니다.

.. kernel-doc:: include/linux/hte.h
HTE API 역할
역할대표 API목적
Providerdevm_hte_register_chipHTE chip 등록
Providerhte_push_ts_nsNanosecond timestamp push
Consumerhte_request_ts_ns·devm_hte_request_ts_nsTimestamp channel 요청
Consumerhte_enable_ts·hte_disable_tsCapture enable·disable
Consumerhte_ts_get·hte_ts_putTimestamp resource lifecycle

Provider와 consumer가 호출하는 핵심 API를 구분합니다.

struct hte_ts_data lifecycle

40-56

`struct hte_ts_data`는 consumer와 provider 사이에서 timestamp detail을 전달하며 nanosecond timestamp를 `u64`로 표현합니다.

GPIO line의 전형적인 lifecycle은 line change 감시, state change 감지, timestamp를 nanosecond로 변환, provider hardware가 지원하면 `raw_level`에 GPIO raw level 저장, `hte_ts_data`를 HTE subsystem으로 push하는 순서입니다.

HTE subsystem은 sequence counter를 증가시키고 consumer가 제공한 callback을 호출합니다. Callback return value에 따라 HTE core가 thread context의 secondary callback을 호출합니다.

HTE timestamp data lifecycle
GPIO line change 감시State change 감지Timestamp를 nanosecond로 변환Optional raw_level 저장hte_ts_data를 HTE core에 pushseq 증가·consumer callback필요하면 threaded secondary callback

원문의 GPIO timestamp 처리 단계를 구조화했습니다.

HTE debugfs attribute

57-79

HTE subsystem은 `/sys/kernel/debug/hte/`에 debugfs attribute를 만듭니다. Line·signal별 read-only attribute는 `/sys/kernel/debug/hte/<provider>/<label or line id>/`에 생성됩니다.

`ts_requested`는 provider에서 요청된 entity의 총수입니다. Entity의 의미는 provider가 정하며 line, GPIO, chip signal, bus 등이 될 수 있습니다. 위치는 `/sys/kernel/debug/hte/<provider>/`입니다.

`total_ts`는 provider가 지원하는 entity 총수이며 같은 provider directory에 있습니다.

`dropped_timestamps`는 특정 line에서 누락된 timestamp 수이며 line·label directory에 있습니다.

HTE debugfs
Attribute의미경로
ts_requested요청된 entity 수/sys/kernel/debug/hte/<provider>/
total_ts지원 entity 총수/sys/kernel/debug/hte/<provider>/
dropped_timestamps특정 line의 누락 timestamp/sys/kernel/debug/hte/<provider>/<label or line id>/

Read-only statistic의 의미와 위치입니다.