Thank you very much for your fast reply and the notes. Please find below a
modified patch according to your annotations:
---
diff -rwbBu a/config.c b/config.c
--- a/config.c 2015-09-19 16:25:11.000000000 +0200
+++ b/config.c 2016-07-06 17:07:38.176449373 +0200
@@ -226,6 +226,8 @@
PORT_ITEM_INT("syncReceiptTimeout", 0, 0, UINT8_MAX),
GLOB_ITEM_INT("timeSource", INTERNAL_OSCILLATOR, 0x10, 0xfe),
GLOB_ITEM_ENU("time_stamping", TS_HARDWARE, timestamping_enu),
+ GLOB_ITEM_INT("tos_event", 0, 0, 0x3F),
+ GLOB_ITEM_INT("tos_general", 0, 0, 0x3F),
PORT_ITEM_INT("transportSpecific", 0, 0, 0x0F),
PORT_ITEM_ENU("tsproc_mode", TSPROC_FILTER, tsproc_enu),
GLOB_ITEM_INT("twoStepFlag", 1, 0, 1),
@@ -235,7 +237,7 @@
GLOB_ITEM_STR("uds_address", "/var/run/ptp4l"),
GLOB_ITEM_INT("use_syslog", 1, 0, 1),
GLOB_ITEM_STR("userDescription", ""),
- GLOB_ITEM_INT("verbose", 0, 0, 1),
+ GLOB_ITEM_INT("verbose", 0, 0, 1)
};
static enum parser_result
diff -rwbBu a/default.cfg b/default.cfg
--- a/default.cfg 2015-09-19 16:25:11.000000000 +0200
+++ b/default.cfg 2016-07-06 16:49:36.853140183 +0200
@@ -12,6 +12,8 @@
offsetScaledLogVariance 0xFFFF
free_running 0
freq_est_interval 1
+tos_event 0
+tos_general 0
#
# Port Data Set
#
diff -rwbBu a/ptp4l.8 b/ptp4l.8
--- a/ptp4l.8 2015-09-19 16:25:11.000000000 +0200
+++ b/ptp4l.8 2016-07-06 16:58:23.722698053 +0200
@@ -446,6 +446,14 @@
Specifies the address of the UNIX domain socket for receiving local
management messages. The default is /var/run/ptp4l.
.TP
+.B tos_event
+Defines the Differentiated Services Codepoint (DSCP) to be used for PTP
+event messages. Must be a value between 0 and 63. The default is 0.
+.TP
+.B tos_general
+Defines the Differentiated Services Codepoint (DSCP) to be used for PTP
+general messages. Must be a value between 0 and 63. The default is 0.
+.TP
.B logging_level
The maximum logging level of messages which should be printed.
The default is 6 (LOG_INFO).
diff -rwbBu a/sk.c b/sk.c
--- a/sk.c 2015-09-19 16:25:11.000000000 +0200
+++ b/sk.c 2016-07-06 16:40:27.000000000 +0200
@@ -35,6 +35,7 @@
#include "missing.h"
#include "print.h"
#include "sk.h"
+#include "config.h"
/* globals */
@@ -78,6 +79,28 @@
return 0;
}
+static int set_priority(int fd, uint8_t dscp) {
+ int tos;
+ socklen_t tos_len;
+
+ tos_len = sizeof(tos);
+ if (getsockopt(fd, SOL_IP, IP_TOS, &tos, &tos_len) < 0) {
+ tos = 0;
+ }
+
+ /* clear old DSCP value */
+ tos &= ~0xFC;
+
+ /* set new DSCP value */
+ tos |= dscp<<2;
+ tos_len = sizeof(tos);
+ if (setsockopt(fd, SOL_IP, IP_TOS, &tos, tos_len) < 0) {
+ return -1;
+ }
+
+ return 0;
+}
+
/* public methods */
int sk_interface_index(int fd, const char *name)
@@ -105,6 +128,24 @@
return 0;
}
+int sk_set_priority(struct config *c, int event_fd, int general_fd) {
+ uint8_t event_dscp = config_get_int(c, NULL, "tos_event");
+ uint8_t general_dscp = config_get_int(c, NULL, "tos_general");
+
+ int err = 0;
+
+ if(event_dscp != 0) {
+ err = set_priority(event_fd, event_dscp);
+ }
+
+ if(!err && general_dscp) {
+ err = set_priority(general_fd, general_dscp);
+ }
+
+ return err;
+}
+
+
int sk_get_ts_info(const char *name, struct sk_ts_info *sk_info)
{
#ifdef ETHTOOL_GET_TS_INFO
diff -rwbBu a/sk.h b/sk.h
--- a/sk.h 2015-09-19 16:25:11.000000000 +0200
+++ b/sk.h 2016-07-06 16:38:36.000000000 +0200
@@ -55,6 +55,16 @@
int sk_general_init(int fd);
/**
+ * Set DSCP value for socket.
+ * @param c Current linuxptp configuration.
+ * @param event_fd Open socket for ptp event messages.
+ * @param general_fd Open socket for ptp general messages.
+ * @return Zero in success, negative on failure
+ *
+ */
+int sk_set_priority(struct config *c, int event_fd, int general_fd);
+
+/**
* Obtain supported timestamping information
* @param name The name of the interface
* @param info Struct containing obtained timestamping information.
diff -rwbBu a/udp6.c b/udp6.c
--- a/udp6.c 2015-09-19 16:25:11.000000000 +0200
+++ b/udp6.c 2016-07-06 16:39:48.000000000 +0200
@@ -196,6 +196,10 @@
if (sk_general_init(gfd))
goto no_timestamping;
+ if(sk_set_priority(t->cfg, efd, gfd) < 0) {
+ pr_warning("Failure on setting DSCP priority.");
+ }
+
fda->fd[FD_EVENT] = efd;
fda->fd[FD_GENERAL] = gfd;
return 0;
diff -rwbBu a/udp.c b/udp.c
--- a/udp.c 2015-09-19 16:25:11.000000000 +0200
+++ b/udp.c 2016-07-06 16:39:27.000000000 +0200
@@ -186,6 +186,10 @@
if (sk_general_init(gfd))
goto no_timestamping;
+ if(sk_set_priority(t->cfg, efd, gfd) < 0) {
+ pr_warning("Failure on setting DSCP priority.");
+ }
+
fda->fd[FD_EVENT] = efd;
fda->fd[FD_GENERAL] = gfd;
return 0;
---
Best regards
Henry Jesuiter
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel