Skip to content

Commit

Permalink
Merge branch 'v3_8'
Browse files Browse the repository at this point in the history
  • Loading branch information
abower-amd committed Nov 18, 2024
2 parents 26193fe + 8d64147 commit 4aa91ff
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 25 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Added

- Add `avoid_efx_ioctl` option to avoid sfc proprietary ioctl(). (SWPTP-1535)
- This prevents setting of the sync flags optionally used by Onload.

### Fixed

- Issue SWPTP-1506
Expand Down Expand Up @@ -36,7 +41,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- To enable, see [example](config/ptp_slave_lacp.cfg).
- Show unicast/multicast delay response flags in state file. (SWPTP-807)
- Get transmit timestamps via epoll to avoid blocking PTP thread. (SWPTP-831)
- Add interpolated config of patterns for clock names and ids. (SWPTP-997)
- Ethtool queries conducted over netlink on supported kernels. (SWPTP-1304)
- IP address of parent clock added to topology files (SWPTP-1312)
- Add option to configure state file and stats log update rates. (SWPTP-1326)
Expand Down
5 changes: 2 additions & 3 deletions src/sfptpd_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ static int renew_clock(struct sfptpd_clock *clock)
/* Set the primary interface for the clock and get the PHC
* supported flag and device index. */
clock->u.nic.primary_if = primary;
clock->u.nic.supports_sync_status_reporting = true;
clock->u.nic.supports_sync_status_reporting = !clock->cfg_avoid_efx;
clock->u.nic.device_idx = phc_idx;
clock->u.nic.supports_efx = supports_efx;

Expand Down Expand Up @@ -2219,8 +2219,7 @@ int sfptpd_clock_set_sync_status(struct sfptpd_clock *clock, bool in_sync,
goto finish;
}

/* Update the sync status via a private IOCTL.
Ignore clock->cfg_avoid_efx because there is no alternative mechanism. */
/* Update the sync status via a private IOCTL unless inhibited. */
memset(&sfc_req, 0, sizeof(sfc_req));
sfc_req.cmd = EFX_TS_SET_SYNC_STATUS;
sfc_req.u.ts_set_sync_status.in_sync = in_sync? 1: 0;
Expand Down
6 changes: 3 additions & 3 deletions src/sfptpd_general_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ static const sfptpd_config_option_t config_general_options[] =
parse_assume_one_phc_per_nic,
.dfl = SFPTPD_CONFIG_DFL_BOOL(SFPTPD_DEFAULT_ASSUME_ONE_PHC_PER_NIC)},
{"avoid_efx_ioctl", "<off | on>",
"Specify whether to avoid private SIOCEFX ioctl for Solarflare "
"adapters where possible",
"Specify whether to avoid private SIOCEFX ioctl for Solarflare adapters. "
"This prevents use of the sync flag via Onload",
1, SFPTPD_CONFIG_SCOPE_GLOBAL,
parse_avoid_efx_ioctl,
.dfl = SFPTPD_CONFIG_DFL_BOOL(false),
.hidden = true},
},
{"phc_diff_methods", "<sys-offset-precise | efx | pps | sys-offset-ext | sys-offset | read-time>*",
"Define the list of PHC diff methods used",
~1, SFPTPD_CONFIG_SCOPE_GLOBAL,
Expand Down
8 changes: 4 additions & 4 deletions src/sfptpd_priv.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ static int sfptpd_priv_rpc(struct sfptpd_priv_state *state,
return num_fds;
}

static bool priv_sync(struct sfptpd_priv_state *state)
static int priv_sync(struct sfptpd_priv_state *state)
{
struct sfptpd_priv_req_msg req = { .req = SFPTPD_PRIV_REQ_SYNC };
struct sfptpd_priv_resp_msg resp = { 0 };

return sfptpd_priv_rpc(state, &req, &resp, NULL) == 0;
return sfptpd_priv_rpc(state, &req, &resp, NULL);
}


Expand Down Expand Up @@ -307,10 +307,10 @@ int sfptpd_priv_start_helper(struct sfptpd_config *config, int *pid)
return -rc;
}

if (!priv_sync(state)) {
if ((rc = priv_sync(state)) < 0) {
sfptpd_priv_stop_helper();
CRITICAL("could not start privileged helper\n");
return -ESHUTDOWN;
return rc;
} else {
TRACE_L3("priv: started helper\n");
}
Expand Down
41 changes: 27 additions & 14 deletions src/sfptpd_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ struct sfptpd_thread_lib
/* Key used for storing per-thread context */
pthread_key_t key;

/* Key is valid */
bool key_valid;

/* Used to restore signal mask when signal library exits */
sigset_t original_signal_set;

Expand Down Expand Up @@ -1232,8 +1235,19 @@ int sfptpd_msg_reply(sfptpd_msg_hdr_t *msg)

struct sfptpd_thread *thread_self(void)
{
struct sfptpd_thread *self
= (struct sfptpd_thread *)pthread_getspecific(sfptpd_thread_lib.key);
struct sfptpd_thread *self;

/* If the key has not been created, pthread_getspecific() returns
* an undefined value. */
if (!sfptpd_thread_lib.key_valid)
return NULL;

self = (struct sfptpd_thread *)pthread_getspecific(sfptpd_thread_lib.key);

if (self != NULL && self->magic != SFPTPD_THREAD_MAGIC) {
CRITICAL("thread: thread state check failed\n");
sfptpd_debug_backtrace();
}

assert(self == NULL || self->magic == SFPTPD_THREAD_MAGIC);
return self;
Expand All @@ -1242,20 +1256,17 @@ struct sfptpd_thread *thread_self(void)

static const char *thread_get_name(void)
{
struct sfptpd_thread *self
= (struct sfptpd_thread *)pthread_getspecific(sfptpd_thread_lib.key);
struct sfptpd_thread *self = NULL;

/* If the key has not been created, pthread_getspecific() returns
* an undefined value. */
if (sfptpd_thread_lib.key_valid)
self = (struct sfptpd_thread *)pthread_getspecific(sfptpd_thread_lib.key);

/* This function is used to get the thread name when logging trace
* messages. Normally if self is not null then the magic value
* should be correct but there is one scenario there this is not the
* case. During the library initialisation, the global message pool
* is created from outside of an sfptpd thread context and may use
* this function to output trace messages. The value of
* pthread_getspecific() will be undefined in this case. */
if ((self != NULL) && (self->magic == SFPTPD_THREAD_MAGIC))
return self->name;

return "(global)";
else
return "(global)";
}


Expand Down Expand Up @@ -1846,14 +1857,15 @@ int sfptpd_threading_initialise(unsigned int num_global_msgs,
sfptpd_thread_lib.zombie_list = NULL;
sfptpd_thread_lib.zombie_policy = zombie_policy;

/* Create a pthread key to allow each thread to store it's message
/* Create a pthread key to allow each thread to store its message
* threading context */
rc = pthread_key_create(&sfptpd_thread_lib.key, NULL);
if (rc != 0) {
CRITICAL("threading: failed to create pthread key, %s\n",
strerror(rc));
return rc;
}
sfptpd_thread_lib.key_valid = true;

/* Create the global message pool */
rc = sfptpd_thread_alloc_msg_pool(SFPTPD_MSG_POOL_GLOBAL,
Expand Down Expand Up @@ -1907,6 +1919,7 @@ void sfptpd_threading_shutdown(void)
/* Destroy key before pool so that thread_get_name doesn't
* reference freed memory */
(void)pthread_key_delete(sfptpd_thread_lib.key);
sfptpd_thread_lib.key_valid = false;
pool_destroy(&sfptpd_thread_lib.global_msg_pool);
pool_destroy(&sfptpd_thread_lib.rt_stats_msg_pool);
(void)pthread_sigmask(SIG_SETMASK, &sfptpd_thread_lib.original_signal_set, NULL);
Expand Down

0 comments on commit 4aa91ff

Please sign in to comment.