From nobody Thu Oct 29 20:30:26 2026 X-Original-To: dev-commits-src-branches@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 4jFwpW0fVZz6xcBV for ; Thu, 29 Oct 2026 20:30:27 +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 4jFwpV4lXWz4Q2h for ; Thu, 29 Oct 2026 20:30:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793305826; 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=UqVQNMrMg+fQRW0aT6IJUeasN658ShB2VuR0fsLdOp4=; b=N6YdJnWKNTYuWYjftM3738Ytd/Opo0ZsZEcJ16j0gRaFdEBuYt74AQNmixU85gspOC2PW5 ZRz3PTdXYSl6QAcFvWV1K2OXuqXWiotv1uOY1LpjQS/VcQDutkyx2rj/Op3uAnK8x5p00E YKcRakpY4AQdMSc8AZb+TmSjDftuahsyfkq38z4Kt4LrfzuSFm1kQ8wmKfXp4ASz29KH2h 0SE7frrhMRGcQykh2NPJkrMl0aSrZU+/LaLLNKKzqYB8Vm6kdqKK3+WAgeapmUcQ7tnpRd gV+5mVk9XVU0YFFmL2FLx2y20gSsCm0It2kjepgtP4Qt6dlB3cwIU/S2eWzijA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793305826; b=sEY6kjNkJ/6u/Q07MgY6iQbkOVm0ntDwD4jWUreX+NlTbVXnall5hEfff6BCkdp38hZ9HV Q7LqovVrbjQ58ySObvf6yhn26DwucCLUDWkRg0Fh0q+XAPtyy+9GhbhfGBBhGU9Mg/A14G aFijy6NVY7EDCU7RsNW79c4LyQIgAs30rNSVdTQyikEsu6RAHDjvSg3eYVlnwKkVWmP/+I fvMmiaQ8nPlY0D6k/IAJUd+2RNJOuFfbW95bc5n1d0eQLqCZHRm9FgyeiXj7i4HLUvhwSR 34xjKwBPC5z1noE76h9SoyRpJ5gAyG86+bgNtwdkKLfEnTTaVjfhVlH9SL7xlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793305826; 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=UqVQNMrMg+fQRW0aT6IJUeasN658ShB2VuR0fsLdOp4=; b=NN3oktD5816rsNIYxsK5YChGnRkJivc5x56I6dJK5RfwTTgjaCDeY2+ffkZPwvvVXdM47F fEUbEwylPOQzlGKPNHQBoJK3Na/gDPIGvQ1uDd3dxsZ1fz1FWNAQKCU9lB27J52NxpP6n1 X+X+CQug4DyDXAOC3zueqWhhYm79JmWKLSpinOq/CFM3XVmPDv9BkXFeXs8ld50KpUejt0 eLg346WYCBOilbOn74nUvaZDtNo19YsieDfZpmQMc7W5iN/jNX72uyjq2DkOYfdawGEOSw hC8vPfGTUOpL6zgyVwGUR6Z8wO4xwPyNc7wHPzutfawuL3rXcr9ZeLRZLm3vYQ== 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 4jFwpV2f1nzw30 for ; Thu, 29 Oct 2026 20:30:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 211b3 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 29 Oct 2026 20:30:26 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Andrew Gallatin From: Kevin Bowling Subject: git: d649c1d52508 - stable/15 - ifconfig: Improve CMIS parsing of breakout configs List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: Commits to the stable branches of the FreeBSD 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: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: d649c1d525087cb0702b218bb0eefb9968b32dc9 Auto-Submitted: auto-generated Date: Thu, 29 Oct 2026 20:30:26 +0000 Message-Id: <6ae3ace2.211b3.1bb10b8b@gitrepo.freebsd.org> The branch stable/15 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=d649c1d525087cb0702b218bb0eefb9968b32dc9 commit d649c1d525087cb0702b218bb0eefb9968b32dc9 Author: Andrew Gallatin AuthorDate: 2026-07-15 17:44:06 +0000 Commit: Kevin Bowling CommitDate: 2026-10-29 20:25:20 +0000 ifconfig: Improve CMIS parsing of breakout configs This fixes a bug where we do not report all lanes when a NIC configures a breakout. Eg, we reported all 4 lanes when a NIC configured the optics as 1x400g, but only printed the first lane's strength when configured as 4x100g. Fix this by actually parsing the active lane count, rather than pulling it from the default descriptor. While here, optionally print page 10h when -vvvv is specified. This aids in determining how a breakout is configured. I put it under an extra level of verbosity, as I don't want to let things get out of hand printing CMIS pages. Sponsored by: Netflix Reviewed by: kib, sumit.saxena_broadcom.com Differential Revision: https://reviews.freebsd.org/D58263 (cherry picked from commit 3a6bf8a72d4922b53d75924c4645774ef37e27ff) --- lib/libifconfig/libifconfig_sfp.c | 46 +++++++++++++++++++++++++++++++-------- lib/libifconfig/libifconfig_sfp.h | 3 ++- sbin/ifconfig/sfp.c | 5 +++++ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/lib/libifconfig/libifconfig_sfp.c b/lib/libifconfig/libifconfig_sfp.c index a2cddf89a13a..dcd5ef2e8e57 100644 --- a/lib/libifconfig/libifconfig_sfp.c +++ b/lib/libifconfig/libifconfig_sfp.c @@ -238,6 +238,27 @@ get_qsfp_info(struct i2c_info *ii, struct ifconfig_sfp_info *sfp) return (ii->error); } +/* Count active host lanes (nonzero AppSelCode) in the Active Control Set. */ +static uint8_t +get_cmis_active_lanes(struct i2c_info *ii) +{ + uint8_t dpconfig[CMIS_MAX_LANES]; + uint8_t lanes; + int i; + + lanes = 0; + read_i2c_page(ii, CMIS_BASE, 0x11, 0, CMIS_P11_ACS_DPCONFIG1, + sizeof(dpconfig), dpconfig); + if (ii->error != 0) + return (0); + + for (i = 0; i < CMIS_MAX_LANES; i++) { + if ((dpconfig[i] & CMIS_ACS_APPSEL_MASK) != 0) + lanes++; + } + return (lanes); +} + static int get_cmis_info(struct i2c_info *ii, struct ifconfig_sfp_info *sfp) { @@ -287,8 +308,10 @@ get_cmis_info(struct i2c_info *ii, struct ifconfig_sfp_info *sfp) break; } - /* Extract media lane count from app descriptor byte 2, bits 3:0 */ - sfp->sfp_cmis_lanes = app_desc[CMIS_APP_LANE_COUNT] & 0x0F; + /* Count active lanes; fall back to the descriptor's media lane count. */ + sfp->sfp_cmis_lanes = get_cmis_active_lanes(ii); + if (sfp->sfp_cmis_lanes == 0) + sfp->sfp_cmis_lanes = app_desc[CMIS_APP_LANE_COUNT] & 0x0F; return (ii->error); } @@ -657,15 +680,18 @@ ifconfig_sfp_get_sfp_status(ifconfig_handle_t *h, const char *name, if (ifconfig_sfp_id_is_cmis(ii.id)) { /* - * For CMIS, we need the lane count from the module info. - * Read the first Application Descriptor to get it. + * Match the active-lane count reported by get_cmis_info(); + * fall back to the first descriptor's media lane count. */ uint8_t app_desc[CMIS_APP_DESC_SIZE]; size_t channels; - read_i2c(&ii, CMIS_BASE, CMIS_APP_DESC_START, - CMIS_APP_DESC_SIZE, app_desc); - channels = app_desc[CMIS_APP_LANE_COUNT] & 0x0F; + channels = get_cmis_active_lanes(&ii); + if (channels == 0) { + read_i2c(&ii, CMIS_BASE, CMIS_APP_DESC_START, + CMIS_APP_DESC_SIZE, app_desc); + channels = app_desc[CMIS_APP_LANE_COUNT] & 0x0F; + } return (get_cmis_status(&ii, ss, channels)); } @@ -779,12 +805,14 @@ ifconfig_sfp_get_sfp_dump(ifconfig_handle_t *h, const char *name, return (-1); if (ifconfig_sfp_id_is_cmis(ii.id)) { - /* Lower memory (0-127), Page 00h (128-255), Page 11h */ + /* Lower memory (0-127), Page 00h, Page 11h, Page 10h */ read_i2c(&ii, CMIS_BASE, 0, 128, buf); read_i2c_page(&ii, CMIS_BASE, 0x00, 0, 128, 128, buf + 128); read_i2c_page(&ii, CMIS_BASE, 0x11, 0, 128, 128, buf + CMIS_DUMP_P11); + read_i2c_page(&ii, CMIS_BASE, 0x10, 0, 128, 128, + buf + CMIS_DUMP_P10); } else if (ifconfig_sfp_id_is_qsfp(ii.id)) { read_i2c(&ii, SFF_8436_BASE, QSFP_DUMP0_START, QSFP_DUMP0_SIZE, buf + QSFP_DUMP0_START); @@ -804,7 +832,7 @@ ifconfig_sfp_dump_region_count(const struct ifconfig_sfp_dump *dp) uint8_t id_byte = dp->data[0]; if (ifconfig_sfp_id_is_cmis((enum sfp_id)id_byte)) - return (3); + return (4); switch ((enum sfp_id)id_byte) { case SFP_ID_UNKNOWN: diff --git a/lib/libifconfig/libifconfig_sfp.h b/lib/libifconfig/libifconfig_sfp.h index 9ed4f684e5c4..725f96208066 100644 --- a/lib/libifconfig/libifconfig_sfp.h +++ b/lib/libifconfig/libifconfig_sfp.h @@ -85,10 +85,11 @@ struct ifconfig_sfp_status { #define CMIS_DUMP_SIZE 512 /**< CMIS dump buffer size */ #define CMIS_DUMP_P11 256 /**< offset of Page 11h in dump buffer */ +#define CMIS_DUMP_P10 384 /**< offset of Page 10h in dump buffer */ /** SFP module I2C memory dump * SFP modules have one region, QSFP modules have two. - * CMIS modules have three: lower memory, Page 00h, and Page 11h. + * CMIS modules have four: lower memory, Page 00h, Page 11h, and Page 10h. */ struct ifconfig_sfp_dump { uint8_t data[CMIS_DUMP_SIZE]; /**< memory dump data */ diff --git a/sbin/ifconfig/sfp.c b/sbin/ifconfig/sfp.c index f6400684ba7a..878a02a4a0da 100644 --- a/sbin/ifconfig/sfp.c +++ b/sbin/ifconfig/sfp.c @@ -122,6 +122,11 @@ sfp_status(if_ctx *ctx) printf("\n\tCMIS DUMP (Page 00h 128..255):\n"); hexdump(dump.data + 128, 128, "\t", HD_OMIT_COUNT | HD_OMIT_CHARS); + if (verbose > 3) { + printf("\n\tCMIS DUMP (Page 10h 128..255):\n"); + hexdump(dump.data + CMIS_DUMP_P10, 128, + "\t", HD_OMIT_COUNT | HD_OMIT_CHARS); + } printf("\n\tCMIS DUMP (Page 11h 128..255):\n"); hexdump(dump.data + CMIS_DUMP_P11, 128, "\t", HD_OMIT_COUNT | HD_OMIT_CHARS);