Commit 26285e68 authored by Xabier Marquiegui's avatar Xabier Marquiegui Committed by David S. Miller

ptp: add testptp mask test

Add option to test timestamp event queue mask manipulation in testptp.

Option -F allows the user to specify a single channel that will be
applied on the mask filter via IOCTL.

The test program will maintain the file open until user input is
received.

This allows checking the effect of the IOCTL in debugfs.

eg:

Console 1:
```
Channel 12 exclusively enabled. Check on debugfs.
Press any key to continue
```

Console 2:
```
0x00000000 0x00000001 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000
```
Signed-off-by: default avatarXabier Marquiegui <reibax@gmail.com>
Suggested-by: default avatarRichard Cochran <richardcochran@gmail.com>
Suggested-by: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 403376dd
...@@ -121,6 +121,7 @@ static void usage(char *progname) ...@@ -121,6 +121,7 @@ static void usage(char *progname)
" -d name device to open\n" " -d name device to open\n"
" -e val read 'val' external time stamp events\n" " -e val read 'val' external time stamp events\n"
" -f val adjust the ptp clock frequency by 'val' ppb\n" " -f val adjust the ptp clock frequency by 'val' ppb\n"
" -F chan Enable single channel mask and keep device open for debugfs verification.\n"
" -g get the ptp clock time\n" " -g get the ptp clock time\n"
" -h prints this message\n" " -h prints this message\n"
" -i val index for event/trigger\n" " -i val index for event/trigger\n"
...@@ -187,6 +188,7 @@ int main(int argc, char *argv[]) ...@@ -187,6 +188,7 @@ int main(int argc, char *argv[])
int pps = -1; int pps = -1;
int seconds = 0; int seconds = 0;
int settime = 0; int settime = 0;
int channel = -1;
int64_t t1, t2, tp; int64_t t1, t2, tp;
int64_t interval, offset; int64_t interval, offset;
...@@ -196,7 +198,7 @@ int main(int argc, char *argv[]) ...@@ -196,7 +198,7 @@ int main(int argc, char *argv[])
progname = strrchr(argv[0], '/'); progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0]; progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv, "cd:e:f:ghH:i:k:lL:n:o:p:P:sSt:T:w:x:Xz"))) { while (EOF != (c = getopt(argc, argv, "cd:e:f:F:ghH:i:k:lL:n:o:p:P:sSt:T:w:x:Xz"))) {
switch (c) { switch (c) {
case 'c': case 'c':
capabilities = 1; capabilities = 1;
...@@ -210,6 +212,9 @@ int main(int argc, char *argv[]) ...@@ -210,6 +212,9 @@ int main(int argc, char *argv[])
case 'f': case 'f':
adjfreq = atoi(optarg); adjfreq = atoi(optarg);
break; break;
case 'F':
channel = atoi(optarg);
break;
case 'g': case 'g':
gettime = 1; gettime = 1;
break; break;
...@@ -604,6 +609,18 @@ int main(int argc, char *argv[]) ...@@ -604,6 +609,18 @@ int main(int argc, char *argv[])
free(xts); free(xts);
} }
if (channel >= 0) {
if (ioctl(fd, PTP_MASK_CLEAR_ALL)) {
perror("PTP_MASK_CLEAR_ALL");
} else if (ioctl(fd, PTP_MASK_EN_SINGLE, (unsigned int *)&channel)) {
perror("PTP_MASK_EN_SINGLE");
} else {
printf("Channel %d exclusively enabled. Check on debugfs.\n", channel);
printf("Press any key to continue\n.");
getchar();
}
}
close(fd); close(fd);
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment