From nobody Fri Oct 30 22:38:59 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 4jGbcT1Qr9z6xS3N for ; Fri, 30 Oct 2026 22:39:05 +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 4jGbcS6Ndtz4h4J for ; Fri, 30 Oct 2026 22:39:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793399944; 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=CHMoYl4pbH1nhxW/4DgRKd+50oBMzYCQsrLOunZjEOs=; b=MPFx+Um1SSGksV5DpZ4RcCCaU7qp2wyqF3nEi9gGhDD58TOYDpbCGwbPXIRIG+qCL0yyEW rWSayHDPNjDW1hDoZ76+lelY5PzmVTlk/bWJdOBHUf1LM6B03rsyNRrwKYeb9svrviaXTc 9oP2N5wWUXl6Kx1jUg2g5iKT5wvcvC/+cI0buoguybzWPUm/WEhPmXwGNLXHZXVqQ0b81W owmakWMBl5Yx3SNjF0YLiB+obEZrFYYfpDa2RXupDInxKjxQprv5qKMkPzyoUprkv9gdn5 Nks8//aK9PYeAnJeY+qCFXNUsLJUEJYwmo7pBT8aJ/kJSc/KLsOTwZLPVnn7Zw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793399944; b=EcGbnvygtsKQtCaSnuqlYYtSoI6dUiXFcr+eoNMTCzbBHWgciEC7G6YqxIynbV89NegIPb BplA/ZPsOlQGvIkeW3ytwI8W3y4+cyDJ0WyaJ8FUUwS5l5BBNR9BsqOIzCvFiNcJvtlcId 4tp3ZyUlYcvTVYWzz7Te1S+TRwke7vzKlbO5jre4vuD9l8u6F3UkunfeIsHkN4QuyCEXu8 kEPIAnOoqQ19KFrGh9EPkG5rpQPwv9RshViAgaRMFAJ5MBJP0UtDxFm0eJHyCdgNiWzwYJ /27TWR7m4IEDJTENd3Os1+/nI862aEpHGU8x3Q37xMrbCQZbb9J2IkrcGqjuUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793399944; 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=CHMoYl4pbH1nhxW/4DgRKd+50oBMzYCQsrLOunZjEOs=; b=cL5N2gKUsMbZ67IhpIxmIky3MB+RRlD5qIfqcwxrMr6p1Eceg1BS6F6pj5HXuF+lC611Nt QlJmyw1kl8n72wUZbNnXy8wOGmt8Z5c3LgPf/AVHOUkr5qRl4+RQbNgvy2fSU929Odt3OF ViEPwZF5NcqmS+hlxpzdVQMrMzOAP5Fcu5nG9ZHFo0y+k0YBR+zQdow1Jd7zvknzOpjuHE 0UxMLfVF37LuiivDMrt1d7XAEPKKtnp6GpMrI881xFGeMAnbDWsAu2H4ZmRLGMYQa4iMet yY+1M2KJdp25lhcknuu3NcADJappwSPIiCg1J/4zmzylQatXrSWM87cH46/geg== 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 4jGbcS5WNQznrk for ; Fri, 30 Oct 2026 22:39:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 38542 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 30 Oct 2026 22:38:59 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 0c08d85c99b7 - main - mlx5en: Report SR-IOV VF status 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: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0c08d85c99b7b57e45816d011685d349b240a3e3 Auto-Submitted: auto-generated Date: Fri, 30 Oct 2026 22:38:59 +0000 Message-Id: <6ae51c83.38542.5e6e6785@gitrepo.freebsd.org> The branch main has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=0c08d85c99b7b57e45816d011685d349b240a3e3 commit 0c08d85c99b7b57e45816d011685d349b240a3e3 Author: Kevin Bowling AuthorDate: 2026-08-08 17:50:12 +0000 Commit: Kevin Bowling CommitDate: 2026-10-30 22:37:54 +0000 mlx5en: Report SR-IOV VF status Query each enabled eswitch vport to report its effective MAC and VLAN configuration and administrative link-state policy. Serialize the query with vport enable and disable, and hold the interface state lock so teardown joins an in-progress report. Propagate firmware errors from MAC, administrative link-state, and supported VLAN queries instead of returning a partially initialized configuration. When the hardware lacks CVLAN enforcement, report the remaining status with no imposed access VLAN. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D58740 --- sys/dev/mlx5/mlx5_core/eswitch.h | 1 + sys/dev/mlx5/mlx5_core/mlx5_eswitch.c | 28 +++++--- sys/dev/mlx5/mlx5_core/mlx5_vport.c | 20 +++++- sys/dev/mlx5/mlx5_en/mlx5_en_main.c | 127 ++++++++++++++++++++++++++++++++++ sys/dev/mlx5/vport.h | 2 + 5 files changed, 166 insertions(+), 12 deletions(-) diff --git a/sys/dev/mlx5/mlx5_core/eswitch.h b/sys/dev/mlx5/mlx5_core/eswitch.h index 50d06951bf07..848decda8a5b 100644 --- a/sys/dev/mlx5/mlx5_core/eswitch.h +++ b/sys/dev/mlx5/mlx5_core/eswitch.h @@ -149,6 +149,7 @@ struct mlx5_esw_vport_info { __u32 linkstate; __u32 min_tx_rate; __u32 max_tx_rate; + bool cvlan_enabled; }; /* E-Switch API */ diff --git a/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c b/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c index 30f04144502b..ac6e95006509 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c @@ -130,7 +130,7 @@ static int query_esw_vport_context_cmd(struct mlx5_core_dev *mdev, u32 vport, } static int query_esw_vport_cvlan(struct mlx5_core_dev *dev, u32 vport, - u16 *vlan, u8 *qos) + u16 *vlan, u8 *qos, bool *enabled) { u32 out[MLX5_ST_SZ_DW(query_esw_vport_context_out)] = {0}; int err; @@ -139,6 +139,7 @@ static int query_esw_vport_cvlan(struct mlx5_core_dev *dev, u32 vport, *vlan = 0; *qos = 0; + *enabled = false; if (!MLX5_CAP_ESW(dev, vport_cvlan_strip) || !MLX5_CAP_ESW(dev, vport_cvlan_insert_if_not_exist)) @@ -154,7 +155,8 @@ static int query_esw_vport_cvlan(struct mlx5_core_dev *dev, u32 vport, cvlan_insert = MLX5_GET(query_esw_vport_context_out, out, esw_vport_context.vport_cvlan_insert); - if (cvlan_strip || cvlan_insert) { + *enabled = cvlan_strip || cvlan_insert; + if (*enabled) { *vlan = MLX5_GET(query_esw_vport_context_out, out, esw_vport_context.cvlan_id); *qos = MLX5_GET(query_esw_vport_context_out, out, @@ -1220,7 +1222,8 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw, int vport, struct mlx5_esw_vport_info *ivi) { u16 vlan; - u8 qos; + u8 linkstate, qos; + int err; if (!ESW_ALLOWED(esw)) return -EPERM; @@ -1230,11 +1233,19 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw, memset(ivi, 0, sizeof(*ivi)); ivi->vf = vport - 1; - mlx5_query_nic_vport_mac_address(esw->dev, vport, ivi->mac); - ivi->linkstate = mlx5_query_vport_admin_state(esw->dev, - MLX5_QUERY_VPORT_STATE_IN_OP_MOD_ESW_VPORT, - vport); - query_esw_vport_cvlan(esw->dev, vport, &vlan, &qos); + err = mlx5_query_nic_vport_mac_address(esw->dev, vport, ivi->mac); + if (err != 0) + return err; + err = mlx5_query_vport_admin_state_checked(esw->dev, + MLX5_QUERY_VPORT_STATE_IN_OP_MOD_ESW_VPORT, vport, + &linkstate); + if (err != 0) + return err; + ivi->linkstate = linkstate; + err = query_esw_vport_cvlan(esw->dev, vport, &vlan, &qos, + &ivi->cvlan_enabled); + if (err != 0 && err != -ENOTSUPP) + return err; ivi->vlan = vlan; ivi->qos = qos; ivi->spoofchk = 0; @@ -1273,4 +1284,3 @@ int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw, mutex_unlock(&evport->state_lock); return err; } - diff --git a/sys/dev/mlx5/mlx5_core/mlx5_vport.c b/sys/dev/mlx5/mlx5_core/mlx5_vport.c index 67893360044e..9d3e3c752111 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_vport.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_vport.c @@ -64,13 +64,27 @@ u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport) } EXPORT_SYMBOL_GPL(mlx5_query_vport_state); -u8 mlx5_query_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport) +int +mlx5_query_vport_admin_state_checked(struct mlx5_core_dev *mdev, u8 opmod, + u16 vport, u8 *state) { u32 out[MLX5_ST_SZ_DW(query_vport_state_out)] = {0}; + int err; - _mlx5_query_vport_state(mdev, opmod, vport, out, sizeof(out)); + err = _mlx5_query_vport_state(mdev, opmod, vport, out, sizeof(out)); + if (err != 0) + return err; + *state = MLX5_GET(query_vport_state_out, out, admin_state); + return 0; +} + +u8 mlx5_query_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport) +{ + u8 state; - return MLX5_GET(query_vport_state_out, out, admin_state); + state = 0; + (void)mlx5_query_vport_admin_state_checked(mdev, opmod, vport, &state); + return (state); } EXPORT_SYMBOL(mlx5_query_vport_admin_state); diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c index 8983762b9af4..f912e69819dd 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c @@ -37,14 +37,19 @@ #include #include +#include #include #include #include +#include + static int mlx5e_get_wqe_sz(struct mlx5e_priv *priv, u32 *wqe_sz, u32 *nsegs); static if_snd_tag_query_t mlx5e_ul_snd_tag_query; static if_snd_tag_free_t mlx5e_ul_snd_tag_free; +static int mlx5e_vf_status(if_t, struct if_vf_status **); + struct mlx5e_channel_param { struct mlx5e_rq_param rq; struct mlx5e_sq_param sq; @@ -3521,6 +3526,127 @@ mlx5e_is_tlsrx_capable(struct mlx5_core_dev *mdev) return (false); } +static int +mlx5e_vf_status(if_t ifp, struct if_vf_status **statusp) +{ + struct mlx5e_vf_status { + u8 mac[ETH_ALEN]; + u16 vlan; + u8 qos; + bool cvlan_enabled; + u32 vf; + u32 linkstate; + } *snapshot; + struct mlx5_esw_vport_info info; + struct mlx5_eswitch *esw; + struct mlx5_vport *vport; + struct if_vf_info *vf; + struct if_vf_status *status; + struct mlx5e_priv *priv; + int error, i, num_vfs; + + priv = if_getsoftc(ifp); + PRIV_LOCK(priv); + if (priv->gone != 0) { + PRIV_UNLOCK(priv); + return (EOPNOTSUPP); + } + esw = priv->mdev->priv.eswitch; + if (!priv->mdev->iov_pf || esw == NULL || esw->total_vports <= 1) { + PRIV_UNLOCK(priv); + return (EOPNOTSUPP); + } + snapshot = mallocarray(esw->total_vports - 1, sizeof(*snapshot), + M_DEVBUF, M_WAITOK | M_ZERO); + num_vfs = 0; + for (i = 1; i < esw->total_vports; i++) { + vport = &esw->vports[i]; + mutex_lock(&vport->state_lock); + if (!vport->enabled) { + mutex_unlock(&vport->state_lock); + continue; + } + /* + * The eswitch does not cache all effective vport policy. Query + * firmware while the vport is stable and return errors rather than + * publishing a partial snapshot. + */ + error = mlx5_eswitch_get_vport_config(esw, i, &info); + mutex_unlock(&vport->state_lock); + if (error != 0) { + PRIV_UNLOCK(priv); + free(snapshot, M_DEVBUF); + return (-error); + } + snapshot[num_vfs].vf = info.vf; + snapshot[num_vfs].vlan = info.vlan; + snapshot[num_vfs].qos = info.qos; + snapshot[num_vfs].cvlan_enabled = info.cvlan_enabled; + snapshot[num_vfs].linkstate = info.linkstate; + memcpy(snapshot[num_vfs].mac, info.mac, ETH_ALEN); + num_vfs++; + } + PRIV_UNLOCK(priv); + if (num_vfs == 0) { + free(snapshot, M_DEVBUF); + status = if_vf_status_alloc(0); + if (status == NULL) + return (ENOMEM); + *statusp = status; + return (0); + } + + status = if_vf_status_alloc(num_vfs); + if (status == NULL) { + free(snapshot, M_DEVBUF); + return (ENOMEM); + } + for (i = 0; i < num_vfs; i++) { + vf = &status->vfs[i]; + vf->fields = IFVF_F_CONFIGURED | IFVF_F_VLAN_MODE; + vf->index = snapshot[i].vf; + vf->configured = true; + /* An active priority policy may have both VID and PCP zero. */ + if (snapshot[i].cvlan_enabled) { + vf->vlan_pcp = snapshot[i].qos; + vf->fields |= IFVF_F_VLAN_PCP; + } + if (!ETHER_IS_ZERO(snapshot[i].mac)) { + memcpy(vf->mac, snapshot[i].mac, sizeof(vf->mac)); + vf->fields |= IFVF_F_MAC; + } + /* A priority-only tag does not impose an access VLAN. */ + if (snapshot[i].vlan == 0) + vf->vlan_mode = IFVF_VLAN_TRUNK; + else { + vf->vlan_mode = IFVF_VLAN_ACCESS; + vf->vlan = snapshot[i].vlan; + vf->vlan_proto = ETHERTYPE_VLAN; + vf->vlan_count = 1; + vf->fields |= IFVF_F_VLAN | IFVF_F_VLAN_PROTO | + IFVF_F_VLAN_COUNT; + } + switch (snapshot[i].linkstate) { + case MLX5_ESW_VPORT_ADMIN_STATE_DOWN: + vf->link_state_policy = IFVF_LINK_DOWN; + break; + case MLX5_ESW_VPORT_ADMIN_STATE_UP: + vf->link_state_policy = IFVF_LINK_UP; + break; + case MLX5_ESW_VPORT_ADMIN_STATE_AUTO: + vf->link_state_policy = IFVF_LINK_AUTO; + break; + default: + vf->link_state_policy = IFVF_LINK_UNKNOWN; + break; + } + vf->fields |= IFVF_F_LINK_STATE_POLICY; + } + free(snapshot, M_DEVBUF); + *statusp = status; + return (0); +} + static int mlx5e_ioctl(if_t ifp, u_long command, caddr_t data) { @@ -4661,6 +4787,7 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev) if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST | IFF_ALLMULTI); if_setioctlfn(ifp, mlx5e_ioctl); + if_setvfstatusfn(ifp, mlx5e_vf_status); if_settransmitfn(ifp, mlx5e_xmit); if_setqflushfn(ifp, if_qflush); if_setgetcounterfn(ifp, mlx5e_get_counter); diff --git a/sys/dev/mlx5/vport.h b/sys/dev/mlx5/vport.h index fbb24773c128..335374cd4b49 100644 --- a/sys/dev/mlx5/vport.h +++ b/sys/dev/mlx5/vport.h @@ -61,6 +61,8 @@ int mlx5_nic_vport_modify_local_lb(struct mlx5_core_dev *mdev, u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport); u8 mlx5_query_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport); +int mlx5_query_vport_admin_state_checked(struct mlx5_core_dev *mdev, + u8 opmod, u16 vport, u8 *state); int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport, u8 state);