[PATCH v9 02/14] net/sxe: add ethdev probe and remove
Stephen Hemminger
stephen at networkplumber.org
Thu Jul 17 18:50:18 CEST 2025
On Wed, 16 Jul 2025 04:29:18 -0400
Jie Liu <liujie5 at linkdatatechnology.com> wrote:
> +static s32 sxe_hdc_cmd_process(struct sxe_hw *hw, u64 trace_id,
> + struct sxe_hdc_trans_info *trans_info)
> +{
> + s32 ret;
> + u8 retry_idx;
> + struct sxe_adapter *adapter = hw->adapter;
> + sigset_t old_mask, new_mask;
> + sigemptyset(&new_mask);
> + sigaddset(&new_mask, SIGINT);
> + sigaddset(&new_mask, SIGTERM);
> + ret = pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask);
> + if (ret) {
> + LOG_ERROR_BDF("hdc set signal mask failed, ret=%d", ret);
> + goto l_ret;
> + }
> +
> + LOG_DEBUG_BDF("hw[%p] cmd trace=0x%" SXE_PRIX64 "", hw, trace_id);
> +
> + ret = sem_wait(sxe_hdc_sema_get());
> + if (ret) {
> + LOG_WARN_BDF("hw[%p] hdc concurrency full", hw);
> + goto l_ret;
> + }
> +
> + for (retry_idx = 0; retry_idx < 250; retry_idx++) {
> + ret = sxe_hdc_packet_trans(hw, trace_id, trans_info);
> + if (ret == SXE_SUCCESS) {
> + goto l_up;
> + } else if (ret == -SXE_HDC_RETRY_ERR) {
> + rte_delay_ms(10);
> + continue;
> + } else {
> + LOG_ERROR_BDF("sxe hdc packet trace_id=0x%" SXE_PRIX64
> + " trans error, ret=%d", trace_id, ret);
> + ret = -EFAULT;
> + goto l_up;
> + }
> + }
> +
> +l_up:
> + LOG_DEBUG_BDF("hw[%p] cmd trace=0x%" SXE_PRIX64 "", hw, trace_id);
> + sem_post(sxe_hdc_sema_get());
> +l_ret:
> + ret = pthread_sigmask(SIG_SETMASK, &old_mask, NULL);
> + if (ret)
> + LOG_ERROR_BDF("hdc restore old signal mask failed, ret=%d", ret);
> +
> + if (ret == -SXE_HDC_RETRY_ERR)
> + ret = -EFAULT;
> +
> + return ret;
> +}
> +
This whole method using Unix semaphores and signals is non-portable and likely
to break some 3rd party application. The driver should not be doing this.
Not accepting driver with this logic.
If you must have another thread to do setup, the use DPDK EAL control
thread and block on an eventfd or pipe.
More information about the dev
mailing list