From nobody Tue Nov 08 18:18:17 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N6GYj4d92z4V63X; Tue, 8 Nov 2022 18:18:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N6GYj3WLVz4JKc; Tue, 8 Nov 2022 18:18:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667931497; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Bwe2KtjAAy6acft+E8ZTKsC9XTLjAZddJfPbswYL4ME=; b=h4RwlcG2vZ67hvZljnQPqILlO6hqThi9pcbWgOd0eZo/oP/GfGScMLpvTfSKuuHnG75tH8 Md0YqLJdypkGZkutx5d/UhcExly3R5+rBv1RrRc5DES/j7yZB/8Oi7Sv9rRRRFhjJAlq7T MIyFYnmTVUksq3fZ7+4/o9wcmodG5BjXNvNmYr9iDwEIrHrYjOcyJujM35KqIybznI6hHY peuDTZx7eNg/SVlMqujxmP3LmKb3gNZdhnfihJCycHTrSqsY9d33iVPdvS0MNAKvTUy6fw kakAUAwOD+sByU4rWFV2/t22Z25VGSaHGdKWh3Bt5TqCZwMg+Ep4iq/DTcasqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667931497; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Bwe2KtjAAy6acft+E8ZTKsC9XTLjAZddJfPbswYL4ME=; b=UNjXblYbXTKW0WA/093Q89Hjieq6lmezTxC/4dTNAmqm6pj8AkK4bxTbGNMzCEy7Vgg6jE UeYlDF4gcGQBdoeAGeyN+tpX/a0gUDraKCfZx3dRRCtmN0qTPDUFMmLM7IG5TA6ZdSdV/b D32XhNhpcr53AYNUAOBt+XH8aCtsSY1DHpAyeth+ywuA6ySHLI6MsXOKhC4v4mTfNoHHQ3 AfDa57ST5760qdNvkcYnP0462u+yuuK3xbORz8ytfbQLkrVS6xj3ymrI2a5e1LPC420X7g 6Je1L0QDFImijgcnoThzErCw4ggepev0mnwPFm0KWYVNWiVpevZrV/LEAIEGfg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667931497; a=rsa-sha256; cv=none; b=NngWC5gUQ+9l03Qu1134L7m5cAy2/c93QRrPUonBgw8AHF1T4rsffqRZTpW9t2B25ZMiYm 9OP37qhTP3sCo/1zA94NO/dyjdFPEgxG8Im6os2B4qvHTamNkeDBYoMHvqSJxUA5N8N9aZ EDIpXu8cJeXGOzmTvrVNNeJQZaCcf2moUA1Dj7DShGxta4g7QZyff3RDhqBo28huWTzOc7 MWAw+Rqd+xx/yPnG5oPYOAtr4EBn/GXVvfqptqr04FyTTfCYJpa5LDp+R/nMGNoVdL28q6 7FZSKXeYgwnNdnPSle7+mHd2rQz6SZjbHEBDH+JhaUHVhXZ4nfrCgvxgDrT55A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N6GYj27bCzrqv; Tue, 8 Nov 2022 18:18:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2A8IIH9R029253; Tue, 8 Nov 2022 18:18:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2A8IIHJv029252; Tue, 8 Nov 2022 18:18:17 GMT (envelope-from git) Date: Tue, 8 Nov 2022 18:18:17 GMT Message-Id: <202211081818.2A8IIHJv029252@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: f2978460c7fd - main - LinuxKPI: tasklet add (*callback) support List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f2978460c7fd5d90837843cbe8edf86a2df4a922 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=f2978460c7fd5d90837843cbe8edf86a2df4a922 commit f2978460c7fd5d90837843cbe8edf86a2df4a922 Author: Bjoern A. Zeeb AuthorDate: 2022-10-30 17:20:11 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-11-08 18:14:17 +0000 LinuxKPI: tasklet add (*callback) support In addition to (*func) tasklet also seems to have a (*callback) with a different argument. Add support for this and add tasklet_setup() as well for support in more drivers. The from_tasklet() definition is duplicated in the tree; hide it there under #ifndef to avoid a re-definition. People should generally add LinuxKPI bits to linuxkpi rather than private files if they also rely on other LinuxKPI bits. X-MFC: DO NOT MFC, space allocated by drivers not us. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D37216 --- sys/compat/linuxkpi/common/include/linux/interrupt.h | 9 +++++++++ sys/compat/linuxkpi/common/src/linux_tasklet.c | 20 +++++++++++++++++++- sys/dev/irdma/fbsd_kcompat.h | 2 ++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/linux/interrupt.h b/sys/compat/linuxkpi/common/include/linux/interrupt.h index d44b813ada8d..4c914a7b45a1 100644 --- a/sys/compat/linuxkpi/common/include/linux/interrupt.h +++ b/sys/compat/linuxkpi/common/include/linux/interrupt.h @@ -134,7 +134,9 @@ irq_set_affinity_hint(int vector, cpumask_t *mask) /* * LinuxKPI tasklet support */ +struct tasklet_struct; typedef void tasklet_func_t(unsigned long); +typedef void tasklet_callback_t(struct tasklet_struct *); struct tasklet_struct { TAILQ_ENTRY(tasklet_struct) entry; @@ -143,6 +145,8 @@ struct tasklet_struct { volatile u_int tasklet_state; atomic_t count; unsigned long data; + tasklet_callback_t *callback; + bool use_callback; }; #define DECLARE_TASKLET(_name, _func, _data) \ @@ -150,6 +154,11 @@ struct tasklet_struct _name = { .func = (_func), .data = (_data) } #define tasklet_hi_schedule(t) tasklet_schedule(t) +/* Some other compat code in the tree has this defined as well. */ +#define from_tasklet(_dev, _t, _field) \ + container_of(_t, typeof(*(_dev)), _field) + +void tasklet_setup(struct tasklet_struct *, tasklet_callback_t *); extern void tasklet_schedule(struct tasklet_struct *); extern void tasklet_kill(struct tasklet_struct *); extern void tasklet_init(struct tasklet_struct *, tasklet_func_t *, diff --git a/sys/compat/linuxkpi/common/src/linux_tasklet.c b/sys/compat/linuxkpi/common/src/linux_tasklet.c index 26e7bb75cf19..d6e20a63c579 100644 --- a/sys/compat/linuxkpi/common/src/linux_tasklet.c +++ b/sys/compat/linuxkpi/common/src/linux_tasklet.c @@ -85,7 +85,10 @@ tasklet_handler(void *arg) /* reset executing state */ TASKLET_ST_SET(ts, TASKLET_ST_EXEC); - ts->func(ts->data); + if (ts->use_callback) + ts->callback(ts); + else + ts->func(ts->data); } while (TASKLET_ST_CMPSET(ts, TASKLET_ST_EXEC, TASKLET_ST_IDLE) == 0); @@ -149,9 +152,24 @@ tasklet_init(struct tasklet_struct *ts, ts->entry.tqe_prev = NULL; ts->entry.tqe_next = NULL; ts->func = func; + ts->callback = NULL; ts->data = data; atomic_set_int(&ts->tasklet_state, TASKLET_ST_IDLE); atomic_set(&ts->count, 0); + ts->use_callback = false; +} + +void +tasklet_setup(struct tasklet_struct *ts, tasklet_callback_t *c) +{ + ts->entry.tqe_prev = NULL; + ts->entry.tqe_next = NULL; + ts->func = NULL; + ts->callback = c; + ts->data = 0; + atomic_set_int(&ts->tasklet_state, TASKLET_ST_IDLE); + atomic_set(&ts->count, 0); + ts->use_callback = true; } void diff --git a/sys/dev/irdma/fbsd_kcompat.h b/sys/dev/irdma/fbsd_kcompat.h index 179229d6be03..a6e3941440f8 100644 --- a/sys/dev/irdma/fbsd_kcompat.h +++ b/sys/dev/irdma/fbsd_kcompat.h @@ -44,8 +44,10 @@ tasklet_init((tasklet), (TASKLET_FUNC_TYPE)(callback), \ (TASKLET_DATA_TYPE)(tasklet)) +#ifndef from_tasklet #define from_tasklet(var, callback_tasklet, tasklet_fieldname) \ container_of(callback_tasklet, typeof(*var), tasklet_fieldname) +#endif #define IRDMA_SET_RDMA_OBJ_SIZE(ib_struct, drv_struct, member) \ (sizeof(struct drv_struct) + \