From nobody Wed Nov 04 21:20:52 2026 X-Original-To: dev-commits-src-all@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 4jKddx3rxXz703pW for ; Wed, 04 Nov 2026 21:20:53 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jKddx1yKNz4Wlq for ; Wed, 04 Nov 2026 21:20:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793827253; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UOfeppIDxhL37XuGlGhNLPzKGHBwPmwjTqs7SUU8oTg=; b=xjGy6/C+5kj83tC6GhAxdA6KFuYAFgjhtbWa8lxc/2Kmd8CeISciOoXqEBrnowrmGRQLSM Vl02TlOgMLTS+fHv2iSVZlprUdIa66aK4hVB3nbC/plVO/z3uKb7jjCy0u8Owx3burzHDF ExuBQiu+gATOsTt69zQILo8palKZ/yB05RNut+gIuiz55sPhDfvGkxc+gzNoNhTOqIvtxq c/ErKAtpbUv3cSX3+DjOF0iUD29C0snAN1/1rmQxe2dV+91EY6j+ZiW81VThgB5y2nBlwE 9xHBh2Bknf49/wcV8dBUCYNmiQiP8qkHWhwh7skFYITxZS0jaUxR068r9duwUA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793827253; b=IB0tFNwDhTWDx4nYSDAbyYIk+qJUhyY8bwg81nuq6D/YG8gRPx8bZpRRT0I0LVg2+2giCJ ZlFU7ObOUnF2svDS9K1u9I4kgi3WAt2Zo6/jBsT5zEt5RAz9bd/ZILdvlRgqcBHIyVTzx1 gU1LH5luYD77bpU0TPEU7egxT/PY49JTtiTzpaQn71vZSg/FHrPBdEOaUQPq+uKkbym8Cy VwTu30CT0hx1NqOi693pWqo2kv4Vm5qeniVJKs43vI+GlcnODSIAXqfAdy1RV11j1v3nvK X5YTJnXcEBRwzzqayOCtXcrRGJkT+KHNPxvwWxxpFths1XQAIV1GFtf3FmWG3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793827253; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UOfeppIDxhL37XuGlGhNLPzKGHBwPmwjTqs7SUU8oTg=; b=suAh4vOhBdl0bdXYY1bEWawQGpa+7WlzmMZI2iNMII4nwMWP2FQk+kjGs8fWJB30hHHY1/ y/VJqclory2V4poRwMw7MWtVr2deIiPfSPxmMKP0sI3V/bwEpzmKJoR3QMSRFhBOr3dLB9 py18qbK0IFmW84DzCXqZzjKs+nT9YPcqo17xNigCRPyldGGuKEp49x6oAp4cvmC07jW4l8 Sv5wbkiKfcYAvHfTvSkTJwKF4ZYG1d43hmWBUXfIprJ5t8LeSRU4qF3rGkLd0vbXMY2Dvt 3v8HTPLGPDiyQVR166rXOBTNZ/0oV0nO2MZolh+Rkwgtiy+ytY4MPK9IJb9r3g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jKddw72ZHzKWD for ; Wed, 04 Nov 2026 21:20:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2132c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 04 Nov 2026 21:20:52 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Gilad Ben Yakov From: Arthur Kiyanovski Subject: git: fa816a033315 - stable/14 - ena: Retrieve RSS table size from device List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: akiyano X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: fa816a033315f52b075642f887a7be80836ac295 Auto-Submitted: auto-generated Date: Wed, 04 Nov 2026 21:20:52 +0000 Message-Id: <6aeba1b4.2132c.2b0778ec@gitrepo.freebsd.org> The branch stable/14 has been updated by akiyano: URL: https://cgit.FreeBSD.org/src/commit/?id=fa816a033315f52b075642f887a7be80836ac295 commit fa816a033315f52b075642f887a7be80836ac295 Author: Gilad Ben Yakov AuthorDate: 2026-03-30 12:12:50 +0000 Commit: Arthur Kiyanovski CommitDate: 2026-11-04 21:18:01 +0000 ena: Retrieve RSS table size from device The current driver assumes a default RSS table size of 128 entries, expecting the device's RSS table size to match this assumption. This patch allows the driver to create RSS indirection table with the size advertised by the device. Reviewed by: cperciva MFC after: 3 days Sponsored by: Amazon, Inc. (cherry picked from commit 3d1e732a43eda16f20dea3fe2671ce6fca8a03a6) --- share/man/man4/ena.4 | 1 - sys/dev/ena/ena.c | 5 ++++- sys/dev/ena/ena.h | 3 --- sys/dev/ena/ena_rss.c | 46 ++++++++++++++++++++++++++++++++++++++++------ sys/dev/ena/ena_rss.h | 35 +++++++++++++++++++++++++++++------ sys/dev/ena/ena_sysctl.c | 32 ++++++++++++++++++++++++-------- 6 files changed, 97 insertions(+), 25 deletions(-) diff --git a/share/man/man4/ena.4 b/share/man/man4/ena.4 index cb5b9367da43..453d30a5b64e 100644 --- a/share/man/man4/ena.4 +++ b/share/man/man4/ena.4 @@ -272,7 +272,6 @@ sysctl dev.ena.1.eni_metrics.sample_interval=10 .Ed .It Va dev.ena.X.rss.indir_table_size RSS indirection table size. -The default is 128. Returns the number of entries in the RSS indirection table. .Pp Example: diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index a8af69e94093..412a9d95e3be 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -4115,8 +4115,11 @@ ena_detach(device_t pdev) ena_free_pci_resources(adapter); - if (adapter->rss_indir != NULL) + if (adapter->rss_indir != NULL) { + free(adapter->rss_indir->table, M_DEVBUF); + free(adapter->rss_indir->sysctl_buf, M_DEVBUF); free(adapter->rss_indir, M_DEVBUF); + } if (likely(ENA_FLAG_ISSET(ENA_FLAG_RSS_ACTIVE, adapter))) ena_com_rss_destroy(ena_dev); diff --git a/sys/dev/ena/ena.h b/sys/dev/ena/ena.h index a62bfccba7ad..f54d7f115338 100644 --- a/sys/dev/ena/ena.h +++ b/sys/dev/ena/ena.h @@ -81,9 +81,6 @@ #define ENA_PKT_MAX_BUFS 19 -#define ENA_RX_RSS_TABLE_LOG_SIZE 7 -#define ENA_RX_RSS_TABLE_SIZE (1 << ENA_RX_RSS_TABLE_LOG_SIZE) - #define ENA_HASH_KEY_SIZE 40 #define ENA_MAX_FRAME_LEN 10000 diff --git a/sys/dev/ena/ena_rss.c b/sys/dev/ena/ena_rss.c index b7706e33065d..648767678d91 100644 --- a/sys/dev/ena/ena_rss.c +++ b/sys/dev/ena/ena_rss.c @@ -102,15 +102,22 @@ ena_rss_init_default(struct ena_adapter *adapter) { struct ena_com_dev *ena_dev = adapter->ena_dev; device_t dev = adapter->pdev; + u32 table_size; int qid, rc, i; - rc = ena_com_rss_init(ena_dev, ENA_RX_RSS_TABLE_LOG_SIZE); + rc = ena_com_rss_init(ena_dev); if (unlikely(rc != 0)) { ena_log(dev, ERR, "Cannot init indirect table\n"); return (rc); } - for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; i++) { + table_size = ena_get_rss_indirection_table_size(adapter); + if (table_size == 0) { + rc = EOPNOTSUPP; + goto err_rss_destroy; + } + + for (i = 0; i < table_size; i++) { #ifdef RSS qid = rss_get_indirection_to_bucket(i) % adapter->num_io_queues; #else @@ -229,6 +236,7 @@ SYSINIT(ena_rss_init, SI_SUB_KICK_SCHEDULER, SI_ORDER_SECOND, int ena_rss_indir_get(struct ena_adapter *adapter, uint32_t *table) { + u32 table_size; int rc, i; rc = ena_com_indirect_table_get(adapter->ena_dev, table); @@ -242,7 +250,11 @@ ena_rss_indir_get(struct ena_adapter *adapter, uint32_t *table) return (rc); } - for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; ++i) + table_size = ena_get_rss_indirection_table_size(adapter); + if (table_size == 0) + return (EOPNOTSUPP); + + for (i = 0; i < table_size; ++i) table[i] = ENA_IO_RXQ_IDX_TO_COMBINED_IDX(table[i]); return (0); @@ -251,9 +263,14 @@ ena_rss_indir_get(struct ena_adapter *adapter, uint32_t *table) int ena_rss_indir_set(struct ena_adapter *adapter, uint32_t *table) { + u32 table_size; int rc, i; - for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; ++i) { + table_size = ena_get_rss_indirection_table_size(adapter); + if (table_size == 0) + return (EOPNOTSUPP); + + for (i = 0; i < table_size; ++i) { rc = ena_com_indirect_table_fill_entry(adapter->ena_dev, i, ENA_IO_RXQ_IDX(table[i])); if (rc != 0) { @@ -277,21 +294,38 @@ int ena_rss_indir_init(struct ena_adapter *adapter) { struct ena_indir *indir = adapter->rss_indir; + u32 table_size; int rc; - if (indir == NULL) + if (indir == NULL) { + table_size = ena_get_rss_indirection_table_size(adapter); + if (table_size == 0) + return (EOPNOTSUPP); + adapter->rss_indir = indir = malloc(sizeof(struct ena_indir), M_DEVBUF, M_WAITOK | M_ZERO); + indir->table = malloc(sizeof(uint32_t) * table_size, + M_DEVBUF, M_WAITOK | M_ZERO); + indir->record_size = ENA_RSS_RECORD_SIZE(table_size, + adapter->max_num_io_queues); + indir->sysctl_buf = malloc(indir->record_size * table_size + 1, + M_DEVBUF, M_WAITOK | M_ZERO); + indir->table_size = table_size; + } + rc = ena_rss_indir_get(adapter, indir->table); if (rc != 0) { + free(indir->sysctl_buf, M_DEVBUF); + free(indir->table, M_DEVBUF); free(adapter->rss_indir, M_DEVBUF); adapter->rss_indir = NULL; return (rc); } - ena_rss_copy_indir_buf(indir->sysctl_buf, indir->table); + ena_rss_copy_indir_buf(indir->sysctl_buf, indir->table, + indir->table_size, indir->record_size); return (0); } diff --git a/sys/dev/ena/ena_rss.h b/sys/dev/ena/ena_rss.h index d2706deef8ca..465314918a4d 100644 --- a/sys/dev/ena/ena_rss.h +++ b/sys/dev/ena/ena_rss.h @@ -41,12 +41,21 @@ #include #endif -#define ENA_RX_RSS_MSG_RECORD_SZ 8 +/* Number of decimal digits needed to represent a value in range [0, n-1] */ +#define ENA_DECIMAL_DIGITS(n) (snprintf(NULL, 0, "%d", n)) +/* + * Per-record size in sysctl_buf: " :\0" + * +1 for space/separator, +1 for ':', +1 for null terminator + */ +#define ENA_RSS_RECORD_SIZE(table_size, num_queues) \ + (1 + ENA_DECIMAL_DIGITS(table_size) + 1 + ENA_DECIMAL_DIGITS(num_queues) + 1) struct ena_indir { - uint32_t table[ENA_RX_RSS_TABLE_SIZE]; + uint32_t *table; /* This is the buffer wired to `rss.indir_table` sysctl. */ - char sysctl_buf[ENA_RX_RSS_TABLE_SIZE * ENA_RX_RSS_MSG_RECORD_SZ]; + char *sysctl_buf; + u32 table_size; + u32 record_size; }; int ena_rss_set_hash(struct ena_com_dev *ena_dev, const u8 *key); @@ -57,14 +66,28 @@ int ena_rss_indir_set(struct ena_adapter *adapter, uint32_t *table); int ena_rss_indir_init(struct ena_adapter *adapter); static inline void -ena_rss_copy_indir_buf(char *buf, uint32_t *table) +ena_rss_copy_indir_buf(char *buf, uint32_t *table, u32 table_size, + u32 record_size) { int i; - for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; ++i) { - buf += snprintf(buf, ENA_RX_RSS_MSG_RECORD_SZ + 1, "%s%d:%d", + for (i = 0; i < table_size; ++i) { + buf += snprintf(buf, record_size, "%s%d:%d", i == 0 ? "" : " ", i, table[i]); } } +static inline u32 +ena_get_rss_indirection_table_size(struct ena_adapter *adapter) +{ + struct ena_com_dev *ena_dev = adapter->ena_dev; + + if (!ena_com_indirection_table_config_supported(ena_dev)) { + device_printf(adapter->pdev, + "RSS indirection table configuration not supported\n"); + return (0); + } + + return (1UL << ena_dev->rss.tbl_log_size); +} #endif /* !(ENA_RSS_H) */ diff --git a/sys/dev/ena/ena_sysctl.c b/sys/dev/ena/ena_sysctl.c index cac5c07ce7b7..65f7b0143104 100644 --- a/sys/dev/ena/ena_sysctl.c +++ b/sys/dev/ena/ena_sysctl.c @@ -54,6 +54,8 @@ static int ena_sysctl_metrics_interval(SYSCTL_HANDLER_ARGS); #ifndef RSS static int ena_sysctl_rss_key(SYSCTL_HANDLER_ARGS); static int ena_sysctl_rss_indir_table(SYSCTL_HANDLER_ARGS); +static int ena_sysctl_rss_indir_table_size(SYSCTL_HANDLER_ARGS); + #endif /* Limit max ENA sample rate to be an hour. */ @@ -160,8 +162,6 @@ SYSCTL_INT(_hw_ena, OID_AUTO, force_large_llq_header, CTLFLAG_RDTUN, &ena_force_large_llq_header, 0, "Change default LLQ entry size received from the device"); -int ena_rss_table_size = ENA_RX_RSS_TABLE_SIZE; - int ena_sysctl_allocate_customer_metrics_buffer(struct ena_adapter *adapter) { int rc = 0; @@ -632,9 +632,10 @@ ena_sysctl_add_rss(struct ena_adapter *adapter) ena_sysctl_rss_indir_table, "A", "RSS indirection table."); /* RSS indirection table size */ - SYSCTL_ADD_INT(ctx, child, OID_AUTO, "indir_table_size", - CTLFLAG_RD | CTLFLAG_MPSAFE, &ena_rss_table_size, 0, - "RSS indirection table size."); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "indir_table_size", + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, + adapter, 0, ena_sysctl_rss_indir_table_size, + "I", "RSS indirection table size."); } #endif /* RSS */ @@ -1166,7 +1167,8 @@ ena_sysctl_rss_indir_table(SYSCTL_HANDLER_ARGS) goto unlock; } - error = sysctl_handle_string(oidp, msg, sizeof(indir->sysctl_buf), req); + error = sysctl_handle_string(oidp, msg, indir->record_size + * indir->table_size, req); if (error != 0 || req->newptr == NULL) goto unlock; @@ -1186,7 +1188,7 @@ ena_sysctl_rss_indir_table(SYSCTL_HANDLER_ARGS) break; } - if (idx >= ENA_RX_RSS_TABLE_SIZE) { + if (idx >= indir->table_size) { device_printf(adapter->pdev, "Index %d out of range\n", idx); error = ERANGE; @@ -1224,7 +1226,8 @@ ena_sysctl_rss_indir_table(SYSCTL_HANDLER_ARGS) ena_rss_indir_get(adapter, indir->table); /* At this point msg has been clobbered by sysctl_handle_string. */ - ena_rss_copy_indir_buf(msg, indir->table); + ena_rss_copy_indir_buf(msg, indir->table, indir->table_size, + indir->record_size); if (error == 0) error = ena_rss_indir_set(adapter, indir->table); @@ -1234,4 +1237,17 @@ unlock: return (error); } + +static int +ena_sysctl_rss_indir_table_size(SYSCTL_HANDLER_ARGS) +{ + struct ena_adapter *adapter = arg1; + int actual_size; + + actual_size = ena_get_rss_indirection_table_size(adapter); + if (actual_size == 0) + return (EOPNOTSUPP); + + return sysctl_handle_int(oidp, &actual_size, 0, req); +} #endif /* RSS */