ptp4l: Add configuration option for socket priority
Users may need to use different socket priorities for ptp4l traffic for the purpose of traffic shaping. An example is to route ptp4l traffic through a specific Linux egress queue using the mqprio qdisc. - Update raw.c open_socket() to accept a socket_priority parameter - Add the socket_priority option to config.c and the default.cfg config file. The option defaults to 0. CC: "Ong, Boon Leong" <boon.leong.ong@intel.com> CC: "Wong, Vincent Por Yin" <vincent.por.yin.wong@intel.com> Signed-off-by: Khor, Isaac Shi Yan <isaac.shi.yan.khor@intel.com>master
parent
f2aac1b30e
commit
c15e8c7600
1
config.c
1
config.c
|
@ -285,6 +285,7 @@ struct config_item config_tab[] = {
|
|||
GLOB_ITEM_INT("servo_num_offset_values", 10, 0, INT_MAX),
|
||||
GLOB_ITEM_INT("servo_offset_threshold", 0, 0, INT_MAX),
|
||||
GLOB_ITEM_INT("slaveOnly", 0, 0, 1),
|
||||
GLOB_ITEM_INT("socket_priority", 0, 0, 15),
|
||||
GLOB_ITEM_DBL("step_threshold", 0.0, 0.0, DBL_MAX),
|
||||
GLOB_ITEM_INT("summary_interval", 0, INT_MIN, INT_MAX),
|
||||
PORT_ITEM_INT("syncReceiptTimeout", 0, 0, UINT8_MAX),
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#
|
||||
twoStepFlag 1
|
||||
slaveOnly 0
|
||||
socket_priority 0
|
||||
priority1 128
|
||||
priority2 128
|
||||
domainNumber 0
|
||||
|
|
7
ptp4l.8
7
ptp4l.8
|
@ -384,6 +384,13 @@ The default is 1 (enabled).
|
|||
.B slaveOnly
|
||||
The local clock is a slave-only clock if enabled. The default is 0 (disabled).
|
||||
.TP
|
||||
.B socket_priority
|
||||
Configure the SO_PRIORITY of sockets. This is to support cases where a user
|
||||
wants to route ptp4l traffic using Linux qdiscs for the purpose of traffic
|
||||
shaping. This option is only available with the IEEE 802.3 transport (the
|
||||
\fB-2\fP option) and is silently ignored when using the UDP IPv4/6 network
|
||||
transports. Must be in the range of 0 to 15, inclusive. The default is 0.
|
||||
.TP
|
||||
.B gmCapable
|
||||
If this option is enabled, then the local clock is able to become grand master.
|
||||
This is only for use with 802.1AS clocks and has no effect on 1588 clocks.
|
||||
|
|
17
raw.c
17
raw.c
|
@ -150,7 +150,7 @@ static int raw_close(struct transport *t, struct fdarray *fda)
|
|||
}
|
||||
|
||||
static int open_socket(const char *name, int event, unsigned char *ptp_dst_mac,
|
||||
unsigned char *p2p_dst_mac)
|
||||
unsigned char *p2p_dst_mac, int socket_priority)
|
||||
{
|
||||
struct sockaddr_ll addr;
|
||||
int fd, index;
|
||||
|
@ -176,6 +176,13 @@ static int open_socket(const char *name, int event, unsigned char *ptp_dst_mac,
|
|||
pr_err("setsockopt SO_BINDTODEVICE failed: %m");
|
||||
goto no_option;
|
||||
}
|
||||
|
||||
if (socket_priority > 0 &&
|
||||
setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &socket_priority,
|
||||
sizeof(socket_priority))) {
|
||||
pr_err("setsockopt SO_PRIORITY failed: %m");
|
||||
goto no_option;
|
||||
}
|
||||
if (raw_configure(fd, event, index, ptp_dst_mac, p2p_dst_mac, 1))
|
||||
goto no_option;
|
||||
|
||||
|
@ -205,7 +212,7 @@ static int raw_open(struct transport *t, struct interface *iface,
|
|||
struct raw *raw = container_of(t, struct raw, t);
|
||||
unsigned char ptp_dst_mac[MAC_LEN];
|
||||
unsigned char p2p_dst_mac[MAC_LEN];
|
||||
int efd, gfd;
|
||||
int efd, gfd, socket_priority;
|
||||
char *str, *name;
|
||||
|
||||
name = iface->ts_label;
|
||||
|
@ -225,11 +232,13 @@ static int raw_open(struct transport *t, struct interface *iface,
|
|||
if (sk_interface_macaddr(name, &raw->src_addr))
|
||||
goto no_mac;
|
||||
|
||||
efd = open_socket(name, 1, ptp_dst_mac, p2p_dst_mac);
|
||||
socket_priority = config_get_int(t->cfg, "global", "socket_priority");
|
||||
|
||||
efd = open_socket(name, 1, ptp_dst_mac, p2p_dst_mac, socket_priority);
|
||||
if (efd < 0)
|
||||
goto no_event;
|
||||
|
||||
gfd = open_socket(name, 0, ptp_dst_mac, p2p_dst_mac);
|
||||
gfd = open_socket(name, 0, ptp_dst_mac, p2p_dst_mac, socket_priority);
|
||||
if (gfd < 0)
|
||||
goto no_general;
|
||||
|
||||
|
|
Loading…
Reference in New Issue