From nobody Wed Oct 19 23:23:45 2022 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 4Mt6HQ22gWz4g2Vq; Wed, 19 Oct 2022 23:23:46 +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 4Mt6HQ17gsz3VjW; Wed, 19 Oct 2022 23:23:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666221826; 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=Wc6qSx8wzcyoBAIbcyRxNnUYEu6w9T2G4Sb45DfVN80=; b=VxRoKodmISmjVqX7vQ4j3vUhQEcJ2YXNgsoPiCp+S1kr/2RfA+gtBFyC3Rpk+rE+Mo4BBo pe6E2tbPc4JGw1D2OIGFZfLDPzrum06sRkS+LUbFM0rNqoGzDiMkhALS+wFaed9+ny2iF6 As2idn0oAHRc2Z9dU4/u5biFhtkzRt1IeMIsxdIZeRfIaSNdWlmOUalmznRRKhf0EWTP/7 ru5bFQyZY5lsibgNguCu+UfspGKRR5oRpMcuNe0ApcLdUn1M9+seFsnm8Td6ZL3vsVeQkN wPM6C5EIl6FYF+kFaooe+8wbE9MJhqf2RiNtDi6/LZi4v/DI42fFm28RSf8dQQ== 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 4Mt6HP6vzczh82; Wed, 19 Oct 2022 23:23:45 +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 29JNNjcO021572; Wed, 19 Oct 2022 23:23:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29JNNjMK021571; Wed, 19 Oct 2022 23:23:45 GMT (envelope-from git) Date: Wed, 19 Oct 2022 23:23:45 GMT Message-Id: <202210192323.29JNNjMK021571@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Eric Joyner Subject: git: b3aaf7ac3b17 - stable/12 - ixv(4): Allow PF to control the VF link state List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: erj X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: b3aaf7ac3b17ede6b542c10e776e7dc14b0da2bd Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666221826; 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=Wc6qSx8wzcyoBAIbcyRxNnUYEu6w9T2G4Sb45DfVN80=; b=UtEbGaIm9D3aW5CJbs4mipJghuHzHao6E/q5c2xc4i/iATLbmCUiTBTBOa8J3h2C1eouGJ YrAaPHC2NvXznqSo0HZM+Hs+NgdOaEzc4W19d3fWrZH7bbbNCTJsY4HFo8l5BkGNWTbOHj 6Dw2w1ry3pkb6gOOWlyMKUndPgR6R03if9cb9pUlCMDc+fzyb1CFDdZIQtLAbZVRCs2WXz raetuYWghCL/GV4nUuwf8temNoVzVs93aZ8ZxeaSH2bmbL2GPDQ0JGYlioOEQuPfwLwzzJ Gc5Wxd13M7dUXXPQZOgZowVrJJ7l0FMq0eZXzb1nUVMZDvfYXO0Hb1MSleSLeQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666221826; a=rsa-sha256; cv=none; b=Gs5XQ69JX0XcOK65LRyqfkZECYjMFeIvioOONkYobi9vjDNV7ZIU7TO0o23h9Sa+CE7aTl 0s0nCpULVAYgJlt2qlxCA9/6jf3MSkS1iZm18SLWdDYs7MOgwoyi0O3C2RTFZ2FEtq8x8j zfRV+P/hXkDruPg8cPf2AKx95Yc0jS7DglZVUDWsM7IMxN2O5V6SLUeriz5GjBJUt9ExVd 53VnrQcT3IlKHYH7FiymReY0IN2DObYyuiwo1r4ah4bFUXOqoIPjQ1MvgiwB0lpLzaVEtP g8Rbst/ZvydS6fWoWdTZvgXnHgTG36EpoPrSb8ol/l2Qu1yahmh3BRt7X+LFrA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by erj: URL: https://cgit.FreeBSD.org/src/commit/?id=b3aaf7ac3b17ede6b542c10e776e7dc14b0da2bd commit b3aaf7ac3b17ede6b542c10e776e7dc14b0da2bd Author: Piotr Pietruszewski AuthorDate: 2022-03-04 18:33:02 +0000 Commit: Eric Joyner CommitDate: 2022-10-19 23:17:03 +0000 ixv(4): Allow PF to control the VF link state This patch adds checks of a VF link state provided by PF via mailbox API. Such change enables the PF to disable a VF administratively. Since command needed by the PF to control the VF is introduced in mailbox api version 1.2, this patch also bumps supported mailbox api version to 1.2. Co-authored-by: Krzysztof Galazka Reviewed By: kbowling@ Tested by: lukasz.szczepaniak@intel.com MFC after: 3 days Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D32004 (cherry picked from commit a3e719bbc21a56230a5b8adeb4c531a6dfb77940) --- sys/dev/ixgbe/if_ixv.c | 19 +++++++++++++++++-- sys/dev/ixgbe/ixgbe.h | 1 + sys/dev/ixgbe/ixgbe_mbx.h | 1 + sys/dev/ixgbe/ixgbe_type.h | 1 + sys/dev/ixgbe/ixgbe_vf.c | 29 +++++++++++++++++++++++++++++ sys/dev/ixgbe/ixgbe_vf.h | 1 + 6 files changed, 50 insertions(+), 2 deletions(-) diff --git a/sys/dev/ixgbe/if_ixv.c b/sys/dev/ixgbe/if_ixv.c index 805701073e0a..569c12bc0d5e 100644 --- a/sys/dev/ixgbe/if_ixv.c +++ b/sys/dev/ixgbe/if_ixv.c @@ -463,6 +463,13 @@ ixv_if_attach_pre(if_ctx_t ctx) goto err_out; } + /* Check if VF was disabled by PF */ + error = hw->mac.ops.get_link_state(hw, &sc->link_enabled); + if (error) { + /* PF is not capable of controlling VF state. Enable the link. */ + sc->link_enabled = true; + } + /* If no mac address was assigned, make a random one */ if (!ixv_check_ether_addr(hw->mac.addr)) { ether_gen_addr(iflib_get_ifp(ctx), @@ -648,6 +655,13 @@ ixv_if_init(if_ctx_t ctx) ixv_init_stats(sc); /* Config/Enable Link */ + error = hw->mac.ops.get_link_state(hw, &sc->link_enabled); + if (error) { + /* PF is not capable of controlling VF state. Enable the link. */ + sc->link_enabled = true; + } else if (sc->link_enabled == false) + device_printf(dev, "VF is disabled by PF\n"); + hw->mac.ops.check_link(hw, &sc->link_speed, &sc->link_up, false); @@ -805,7 +819,8 @@ static int ixv_negotiate_api(struct ixgbe_softc *sc) { struct ixgbe_hw *hw = &sc->hw; - int mbx_api[] = { ixgbe_mbox_api_11, + int mbx_api[] = { ixgbe_mbox_api_12, + ixgbe_mbox_api_11, ixgbe_mbox_api_10, ixgbe_mbox_api_unknown }; int i = 0; @@ -914,7 +929,7 @@ ixv_if_update_admin_status(if_ctx_t ctx) iflib_get_ifp(ctx)->if_init(ctx); } - if (sc->link_up) { + if (sc->link_up && sc->link_enabled) { if (sc->link_active == false) { if (bootverbose) device_printf(dev, "Link is up %d Gbps %s \n", diff --git a/sys/dev/ixgbe/ixgbe.h b/sys/dev/ixgbe/ixgbe.h index 19e7e615ab8b..f2003993b171 100644 --- a/sys/dev/ixgbe/ixgbe.h +++ b/sys/dev/ixgbe/ixgbe.h @@ -393,6 +393,7 @@ struct ixgbe_softc { u16 num_segs; u32 link_speed; bool link_up; + bool link_enabled; u32 vector; u16 dmac; u32 phy_layer; diff --git a/sys/dev/ixgbe/ixgbe_mbx.h b/sys/dev/ixgbe/ixgbe_mbx.h index 88387ea3f7c2..c5940b0823b0 100644 --- a/sys/dev/ixgbe/ixgbe_mbx.h +++ b/sys/dev/ixgbe/ixgbe_mbx.h @@ -115,6 +115,7 @@ enum ixgbe_pfvf_api_rev { #define IXGBE_VF_GET_RETA 0x0a /* VF request for RETA */ #define IXGBE_VF_GET_RSS_KEY 0x0b /* get RSS key */ #define IXGBE_VF_UPDATE_XCAST_MODE 0x0c +#define IXGBE_VF_GET_LINK_STATE 0x10 /* mode choices for IXGBE_VF_UPDATE_XCAST_MODE */ enum ixgbevf_xcast_modes { diff --git a/sys/dev/ixgbe/ixgbe_type.h b/sys/dev/ixgbe/ixgbe_type.h index 769c47a143d8..9fb800560e43 100644 --- a/sys/dev/ixgbe/ixgbe_type.h +++ b/sys/dev/ixgbe/ixgbe_type.h @@ -4012,6 +4012,7 @@ struct ixgbe_mac_operations { ixgbe_mc_addr_itr); s32 (*update_mc_addr_list)(struct ixgbe_hw *, u8 *, u32, ixgbe_mc_addr_itr, bool clear); + s32 (*get_link_state)(struct ixgbe_hw *hw, bool *link_state); s32 (*enable_mc)(struct ixgbe_hw *); s32 (*disable_mc)(struct ixgbe_hw *); s32 (*clear_vfta)(struct ixgbe_hw *); diff --git a/sys/dev/ixgbe/ixgbe_vf.c b/sys/dev/ixgbe/ixgbe_vf.c index f70f4d667aee..75612a7f83ca 100644 --- a/sys/dev/ixgbe/ixgbe_vf.c +++ b/sys/dev/ixgbe/ixgbe_vf.c @@ -73,6 +73,7 @@ s32 ixgbe_init_ops_vf(struct ixgbe_hw *hw) hw->mac.ops.init_rx_addrs = NULL; hw->mac.ops.update_mc_addr_list = ixgbe_update_mc_addr_list_vf; hw->mac.ops.update_xcast_mode = ixgbevf_update_xcast_mode; + hw->mac.ops.get_link_state = ixgbe_get_link_state_vf; hw->mac.ops.enable_mc = NULL; hw->mac.ops.disable_mc = NULL; hw->mac.ops.clear_vfta = NULL; @@ -452,6 +453,34 @@ s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode) return IXGBE_SUCCESS; } +/** + * ixgbe_get_link_state_vf - Get VF link state from PF + * @hw: pointer to the HW structure + * @link_state: link state storage + * + * Returns state of the operation error or success. + **/ +s32 ixgbe_get_link_state_vf(struct ixgbe_hw *hw, bool *link_state) +{ + u32 msgbuf[2]; + s32 err; + s32 ret_val; + + msgbuf[0] = IXGBE_VF_GET_LINK_STATE; + msgbuf[1] = 0x0; + + err = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2); + + if (err || (msgbuf[0] & IXGBE_VT_MSGTYPE_NACK)) { + ret_val = IXGBE_ERR_MBX; + } else { + ret_val = IXGBE_SUCCESS; + *link_state = msgbuf[1]; + } + + return ret_val; +} + /** * ixgbe_set_vfta_vf - Set/Unset vlan filter table address * @hw: pointer to the HW structure diff --git a/sys/dev/ixgbe/ixgbe_vf.h b/sys/dev/ixgbe/ixgbe_vf.h index 5cdb241ec2aa..49f3a173d561 100644 --- a/sys/dev/ixgbe/ixgbe_vf.h +++ b/sys/dev/ixgbe/ixgbe_vf.h @@ -135,6 +135,7 @@ s32 ixgbe_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 *mc_addr_list, u32 mc_addr_count, ixgbe_mc_addr_itr, bool clear); s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode); +s32 ixgbe_get_link_state_vf(struct ixgbe_hw *hw, bool *link_state); s32 ixgbe_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on, bool vlvf_bypass); s32 ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size);