Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
a4bcc795
K
kernel_linux
项目概览
OpenHarmony
/
kernel_linux
上一次同步 3 年多
通知
13
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kernel_linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
a4bcc795
编写于
11月 22, 2013
作者:
B
Ben Hutchings
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
net_tstamp,doc: Add test program for SIOC{G,S}HWTSTAMP
Signed-off-by:
N
Ben Hutchings
<
bhutchings@solarflare.com
>
上级
81fc347a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
138 addition
and
2 deletion
+138
-2
Documentation/networking/timestamping/.gitignore
Documentation/networking/timestamping/.gitignore
+1
-0
Documentation/networking/timestamping/Makefile
Documentation/networking/timestamping/Makefile
+3
-2
Documentation/networking/timestamping/hwtstamp_config.c
Documentation/networking/timestamping/hwtstamp_config.c
+134
-0
未找到文件。
Documentation/networking/timestamping/.gitignore
浏览文件 @
a4bcc795
timestamping
hwtstamp_config
Documentation/networking/timestamping/Makefile
浏览文件 @
a4bcc795
...
...
@@ -2,12 +2,13 @@
obj-
:=
dummy.o
# List of programs to build
hostprogs-y
:=
timestamping
hostprogs-y
:=
timestamping
hwtstamp_config
# Tell kbuild to always build the programs
always
:=
$
(
hostprogs-y
)
HOSTCFLAGS_timestamping.o
+=
-I
$(objtree)
/usr/include
HOSTCFLAGS_hwtstamp_config.o
+=
-I
$(objtree)
/usr/include
clean
:
rm
-f
timestamping
rm
-f
timestamping
hwtstamp_config
Documentation/networking/timestamping/hwtstamp_config.c
0 → 100644
浏览文件 @
a4bcc795
/* Test program for SIOC{G,S}HWTSTAMP
* Copyright 2013 Solarflare Communications
* Author: Ben Hutchings
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <linux/if.h>
#include <linux/net_tstamp.h>
#include <linux/sockios.h>
static
int
lookup_value
(
const
char
**
names
,
int
size
,
const
char
*
name
)
{
int
value
;
for
(
value
=
0
;
value
<
size
;
value
++
)
if
(
names
[
value
]
&&
strcasecmp
(
names
[
value
],
name
)
==
0
)
return
value
;
return
-
1
;
}
static
const
char
*
lookup_name
(
const
char
**
names
,
int
size
,
int
value
)
{
return
(
value
>=
0
&&
value
<
size
)
?
names
[
value
]
:
NULL
;
}
static
void
list_names
(
FILE
*
f
,
const
char
**
names
,
int
size
)
{
int
value
;
for
(
value
=
0
;
value
<
size
;
value
++
)
if
(
names
[
value
])
fprintf
(
f
,
" %s
\n
"
,
names
[
value
]);
}
static
const
char
*
tx_types
[]
=
{
#define TX_TYPE(name) [HWTSTAMP_TX_ ## name] = #name
TX_TYPE
(
OFF
),
TX_TYPE
(
ON
),
TX_TYPE
(
ONESTEP_SYNC
)
#undef TX_TYPE
};
#define N_TX_TYPES ((int)(sizeof(tx_types) / sizeof(tx_types[0])))
static
const
char
*
rx_filters
[]
=
{
#define RX_FILTER(name) [HWTSTAMP_FILTER_ ## name] = #name
RX_FILTER
(
NONE
),
RX_FILTER
(
ALL
),
RX_FILTER
(
SOME
),
RX_FILTER
(
PTP_V1_L4_EVENT
),
RX_FILTER
(
PTP_V1_L4_SYNC
),
RX_FILTER
(
PTP_V1_L4_DELAY_REQ
),
RX_FILTER
(
PTP_V2_L4_EVENT
),
RX_FILTER
(
PTP_V2_L4_SYNC
),
RX_FILTER
(
PTP_V2_L4_DELAY_REQ
),
RX_FILTER
(
PTP_V2_L2_EVENT
),
RX_FILTER
(
PTP_V2_L2_SYNC
),
RX_FILTER
(
PTP_V2_L2_DELAY_REQ
),
RX_FILTER
(
PTP_V2_EVENT
),
RX_FILTER
(
PTP_V2_SYNC
),
RX_FILTER
(
PTP_V2_DELAY_REQ
),
#undef RX_FILTER
};
#define N_RX_FILTERS ((int)(sizeof(rx_filters) / sizeof(rx_filters[0])))
static
void
usage
(
void
)
{
fputs
(
"Usage: hwtstamp_config if_name [tx_type rx_filter]
\n
"
"tx_type is any of (case-insensitive):
\n
"
,
stderr
);
list_names
(
stderr
,
tx_types
,
N_TX_TYPES
);
fputs
(
"rx_filter is any of (case-insensitive):
\n
"
,
stderr
);
list_names
(
stderr
,
rx_filters
,
N_RX_FILTERS
);
}
int
main
(
int
argc
,
char
**
argv
)
{
struct
ifreq
ifr
;
struct
hwtstamp_config
config
;
const
char
*
name
;
int
sock
;
if
((
argc
!=
2
&&
argc
!=
4
)
||
(
strlen
(
argv
[
1
])
>=
IFNAMSIZ
))
{
usage
();
return
2
;
}
if
(
argc
==
4
)
{
config
.
flags
=
0
;
config
.
tx_type
=
lookup_value
(
tx_types
,
N_TX_TYPES
,
argv
[
2
]);
config
.
rx_filter
=
lookup_value
(
rx_filters
,
N_RX_FILTERS
,
argv
[
3
]);
if
(
config
.
tx_type
<
0
||
config
.
rx_filter
<
0
)
{
usage
();
return
2
;
}
}
sock
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
if
(
sock
<
0
)
{
perror
(
"socket"
);
return
1
;
}
strcpy
(
ifr
.
ifr_name
,
argv
[
1
]);
ifr
.
ifr_data
=
(
caddr_t
)
&
config
;
if
(
ioctl
(
sock
,
(
argc
==
2
)
?
SIOCGHWTSTAMP
:
SIOCSHWTSTAMP
,
&
ifr
))
{
perror
(
"ioctl"
);
return
1
;
}
printf
(
"flags = %#x
\n
"
,
config
.
flags
);
name
=
lookup_name
(
tx_types
,
N_TX_TYPES
,
config
.
tx_type
);
if
(
name
)
printf
(
"tx_type = %s
\n
"
,
name
);
else
printf
(
"tx_type = %d
\n
"
,
config
.
tx_type
);
name
=
lookup_name
(
rx_filters
,
N_RX_FILTERS
,
config
.
rx_filter
);
if
(
name
)
printf
(
"rx_filter = %s
\n
"
,
name
);
else
printf
(
"rx_filter = %d
\n
"
,
config
.
rx_filter
);
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录