Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Xabier Marquiegui <reibax@gmail.com>
Suggested-by: Richard Cochran <richardcochran@gmail.com>
Suggested-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Xabier Marquiegui and committed by
David S. Miller
26285e68 403376dd

+18 -1
+18 -1
tools/testing/selftests/ptp/testptp.c
··· 121 121 " -d name device to open\n" 122 122 " -e val read 'val' external time stamp events\n" 123 123 " -f val adjust the ptp clock frequency by 'val' ppb\n" 124 + " -F chan Enable single channel mask and keep device open for debugfs verification.\n" 124 125 " -g get the ptp clock time\n" 125 126 " -h prints this message\n" 126 127 " -i val index for event/trigger\n" ··· 188 187 int pps = -1; 189 188 int seconds = 0; 190 189 int settime = 0; 190 + int channel = -1; 191 191 192 192 int64_t t1, t2, tp; 193 193 int64_t interval, offset; ··· 198 196 199 197 progname = strrchr(argv[0], '/'); 200 198 progname = progname ? 1+progname : argv[0]; 201 - while (EOF != (c = getopt(argc, argv, "cd:e:f:ghH:i:k:lL:n:o:p:P:sSt:T:w:x:Xz"))) { 199 + while (EOF != (c = getopt(argc, argv, "cd:e:f:F:ghH:i:k:lL:n:o:p:P:sSt:T:w:x:Xz"))) { 202 200 switch (c) { 203 201 case 'c': 204 202 capabilities = 1; ··· 211 209 break; 212 210 case 'f': 213 211 adjfreq = atoi(optarg); 212 + break; 213 + case 'F': 214 + channel = atoi(optarg); 214 215 break; 215 216 case 'g': 216 217 gettime = 1; ··· 607 602 } 608 603 609 604 free(xts); 605 + } 606 + 607 + if (channel >= 0) { 608 + if (ioctl(fd, PTP_MASK_CLEAR_ALL)) { 609 + perror("PTP_MASK_CLEAR_ALL"); 610 + } else if (ioctl(fd, PTP_MASK_EN_SINGLE, (unsigned int *)&channel)) { 611 + perror("PTP_MASK_EN_SINGLE"); 612 + } else { 613 + printf("Channel %d exclusively enabled. Check on debugfs.\n", channel); 614 + printf("Press any key to continue\n."); 615 + getchar(); 616 + } 610 617 } 611 618 612 619 close(fd);