From nobody Wed Oct 19 23:23:39 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 4Mt6HH2wxXz4g2SX; Wed, 19 Oct 2022 23:23:39 +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 4Mt6HH25YBz3VFt; Wed, 19 Oct 2022 23:23:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666221819; 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=bS5DoZo5mXVfq+5TLVizXPQSgzxv1sW4fha44N9epjQ=; b=mnRXuVpPbcUVub9OQNj0iYB+GiGo9doZp/QaZ24rQ78cfEri85oOYM4ofHoorbt0eM3o+r 6F+r9/7lo8yocbptl7W6h+EssSDZvgd3t1eXZR4R2dAcFJ5Lu29SQ/A2CzxjwejNLJNFNf +d4ODvGPUq+Cwgqcx/WxNRj0pj2/iLh5Db/ES6iVkOrrrkZYOxbCk7g/u6cp7Id3QiPAzR hN+q8Xk1W+iHaUPAZ0Wxi8vp14DxphX8PH7/61BJvlHeWCE+SD5cADCwFpuc8J6+p2FRgC 3nQH3sH60Q1i3i1l3LB6Bq78NBz2FuFAB8dp7urdEBhL5ChUie/LIhxCND0VTw== 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 4Mt6HH13Byzh3G; Wed, 19 Oct 2022 23:23:39 +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 29JNNdhi021420; Wed, 19 Oct 2022 23:23:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29JNNdAi021419; Wed, 19 Oct 2022 23:23:39 GMT (envelope-from git) Date: Wed, 19 Oct 2022 23:23:39 GMT Message-Id: <202210192323.29JNNdAi021419@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: 2db192a85461 - stable/12 - ixl(4): Remove iavf(4) source files 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: 2db192a8546158fd67284d1d08ce253698723677 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666221819; 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=bS5DoZo5mXVfq+5TLVizXPQSgzxv1sW4fha44N9epjQ=; b=XErDwo8X/GM/yCHgXGavIhnpNhEr723RwTPiAwBzYbJLFghWZqqDAp6FjxcJAoRidwcQah c+ZK7zNpyboxIxiSQVPmyIR9tEwv/NreihmPGQafItrjcC8mT7j+y+fELomg7pZn2PwBIB F0MaEDGk/QPcWH7a4zJ70rZKjA0cl++73vlV16JtVNA5ACMaNTzv3/vRhBfX06HzUZlj34 ZSodtpvtGGZaRow06+cb+vBeasr+mMSmIF/pB/7ZFJLfMrtE7Mm8cJL4cF30XULNZwsfd0 6OfG6rPPEUyiU2RfrTXoUr9/H96HOlvrKg/P0mAh0+MvWEsPsHqthi3/YpibWg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666221819; a=rsa-sha256; cv=none; b=wRMND+Nq5bBzDTwwg68slCd2agtj0KGfrynCj749O6XRsRNICKWg0En54qKnHVONYz+9Xb U2slytVAKJY1PWRtLxDuD4kJvmPclWmnN6Y7y6GQQVnKelTnEe4gxfgxbs5lNLJs1VO6r2 ZiT04+DmNo4TUeGR7kD/IlLz2tc5w7Dq/isoXFVBWhOhdVmLVAgDC5mCyi2ESdC8skgkAB W08LXZ7SDJSD4VzK26iqcMcJirdha+KlmBDeKh0lubJOIVcAprDbOV8HIuLJpvIdVz4QLf v/HTKM8vFYot8/eFevt3P+jiyDqM7BeyBjx+YS1IG0DgcjUECLA148GoSGEHQA== 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=2db192a8546158fd67284d1d08ce253698723677 commit 2db192a8546158fd67284d1d08ce253698723677 Author: Eric Joyner AuthorDate: 2021-02-13 00:04:54 +0000 Commit: Eric Joyner CommitDate: 2022-10-19 21:57:18 +0000 ixl(4): Remove iavf(4) source files Since iavf(4) no longer shares code with ixl(4) as of commit f2fbd56a8d07665bc0a5e8b7e40026b50a591e2a and now has its own directory, remove these now-unused iavf(4)-only files. Signed-off-by: Eric Joyner Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D28638 (cherry picked from commit 409b36ad911d0a12a45c1488369b458965691379) --- sys/dev/ixl/iavf.h | 225 ----- sys/dev/ixl/iavf_vc.c | 1010 -------------------- sys/dev/ixl/if_iavf.c | 2447 ------------------------------------------------- 3 files changed, 3682 deletions(-) diff --git a/sys/dev/ixl/iavf.h b/sys/dev/ixl/iavf.h deleted file mode 100644 index 9a7716c5e5a2..000000000000 --- a/sys/dev/ixl/iavf.h +++ /dev/null @@ -1,225 +0,0 @@ -/****************************************************************************** - - Copyright (c) 2013-2018, Intel Corporation - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -******************************************************************************/ -/*$FreeBSD$*/ - - -#ifndef _IAVF_H_ -#define _IAVF_H_ - -#include "ixl.h" - -#define IAVF_AQ_MAX_ERR 200 -#define IAVF_MAX_FILTERS 128 -#define IAVF_MAX_QUEUES 16 -#define IAVF_AQ_TIMEOUT (1 * hz) - -/* MacVlan Flags */ -#define IAVF_FILTER_USED (u16)(1 << 0) -#define IAVF_FILTER_VLAN (u16)(1 << 1) -#define IAVF_FILTER_ADD (u16)(1 << 2) -#define IAVF_FILTER_DEL (u16)(1 << 3) -#define IAVF_FILTER_MC (u16)(1 << 4) - -#define IAVF_FLAG_AQ_ENABLE_QUEUES (u32)(1 << 0) -#define IAVF_FLAG_AQ_DISABLE_QUEUES (u32)(1 << 1) -#define IAVF_FLAG_AQ_ADD_MAC_FILTER (u32)(1 << 2) -#define IAVF_FLAG_AQ_ADD_VLAN_FILTER (u32)(1 << 3) -#define IAVF_FLAG_AQ_DEL_MAC_FILTER (u32)(1 << 4) -#define IAVF_FLAG_AQ_DEL_VLAN_FILTER (u32)(1 << 5) -#define IAVF_FLAG_AQ_CONFIGURE_QUEUES (u32)(1 << 6) -#define IAVF_FLAG_AQ_MAP_VECTORS (u32)(1 << 7) -#define IAVF_FLAG_AQ_HANDLE_RESET (u32)(1 << 8) -#define IAVF_FLAG_AQ_CONFIGURE_PROMISC (u32)(1 << 9) -#define IAVF_FLAG_AQ_GET_STATS (u32)(1 << 10) -#define IAVF_FLAG_AQ_CONFIG_RSS_KEY (u32)(1 << 11) -#define IAVF_FLAG_AQ_SET_RSS_HENA (u32)(1 << 12) -#define IAVF_FLAG_AQ_GET_RSS_HENA_CAPS (u32)(1 << 13) -#define IAVF_FLAG_AQ_CONFIG_RSS_LUT (u32)(1 << 14) - -/* printf %b flag args */ -#define IAVF_FLAGS \ - "\20\1ENABLE_QUEUES\2DISABLE_QUEUES\3ADD_MAC_FILTER" \ - "\4ADD_VLAN_FILTER\5DEL_MAC_FILTER\6DEL_VLAN_FILTER" \ - "\7CONFIGURE_QUEUES\10MAP_VECTORS\11HANDLE_RESET" \ - "\12CONFIGURE_PROMISC\13GET_STATS\14CONFIG_RSS_KEY" \ - "\15SET_RSS_HENA\16GET_RSS_HENA_CAPS\17CONFIG_RSS_LUT" -#define IAVF_PRINTF_VF_OFFLOAD_FLAGS \ - "\20\1L2" \ - "\2IWARP" \ - "\3RSVD" \ - "\4RSS_AQ" \ - "\5RSS_REG" \ - "\6WB_ON_ITR" \ - "\7REQ_QUEUES" \ - "\21VLAN" \ - "\22RX_POLLING" \ - "\23RSS_PCTYPE_V2" \ - "\24RSS_PF" \ - "\25ENCAP" \ - "\26ENCAP_CSUM" \ - "\27RX_ENCAP_CSUM" - -MALLOC_DECLARE(M_IAVF); - -/* Driver state */ -enum iavf_state_t { - IAVF_RESET_REQUIRED, - IAVF_RESET_PENDING, - IAVF_INIT_READY, - IAVF_RUNNING, -}; - -/* Structs */ - -struct iavf_mac_filter { - SLIST_ENTRY(iavf_mac_filter) next; - u8 macaddr[ETHER_ADDR_LEN]; - u16 flags; -}; -SLIST_HEAD(mac_list, iavf_mac_filter); - -struct iavf_vlan_filter { - SLIST_ENTRY(iavf_vlan_filter) next; - u16 vlan; - u16 flags; -}; -SLIST_HEAD(vlan_list, iavf_vlan_filter); - -/* Software controller structure */ -struct iavf_sc { - struct ixl_vsi vsi; - - struct i40e_hw hw; - struct i40e_osdep osdep; - device_t dev; - - struct resource *pci_mem; - - enum iavf_state_t init_state; - - struct ifmedia media; - struct virtchnl_version_info version; - enum ixl_dbg_mask dbg_mask; - u16 promisc_flags; - - bool link_up; - enum virtchnl_link_speed link_speed; - - /* Tunable settings */ - int tx_itr; - int rx_itr; - int dynamic_tx_itr; - int dynamic_rx_itr; - - /* Filter lists */ - struct mac_list *mac_filters; - struct vlan_list *vlan_filters; - - /* Virtual comm channel */ - struct virtchnl_vf_resource *vf_res; - struct virtchnl_vsi_resource *vsi_res; - - /* Misc stats maintained by the driver */ - u64 admin_irq; - - /* Buffer used for reading AQ responses */ - u8 aq_buffer[IXL_AQ_BUF_SZ]; - - /* State flag used in init/stop */ - u32 queues_enabled; - u8 enable_queues_chan; - u8 disable_queues_chan; -}; - -/* -** This checks for a zero mac addr, something that will be likely -** unless the Admin on the Host has created one. -*/ -static inline bool -iavf_check_ether_addr(u8 *addr) -{ - bool status = TRUE; - - if ((addr[0] == 0 && addr[1]== 0 && addr[2] == 0 && - addr[3] == 0 && addr[4]== 0 && addr[5] == 0)) - status = FALSE; - return (status); -} - -/* Debug printing */ -#define iavf_dbg(sc, m, s, ...) ixl_debug_core(sc->dev, sc->dbg_mask, m, s, ##__VA_ARGS__) -#define iavf_dbg_init(sc, s, ...) ixl_debug_core(sc->dev, sc->dbg_mask, IAVF_DBG_INIT, s, ##__VA_ARGS__) -#define iavf_dbg_info(sc, s, ...) ixl_debug_core(sc->dev, sc->dbg_mask, IAVF_DBG_INFO, s, ##__VA_ARGS__) -#define iavf_dbg_vc(sc, s, ...) ixl_debug_core(sc->dev, sc->dbg_mask, IAVF_DBG_VC, s, ##__VA_ARGS__) -#define iavf_dbg_filter(sc, s, ...) ixl_debug_core(sc->dev, sc->dbg_mask, IAVF_DBG_FILTER, s, ##__VA_ARGS__) - -/* -** VF Common function prototypes -*/ -void iavf_if_init(if_ctx_t ctx); - -int iavf_send_api_ver(struct iavf_sc *); -int iavf_verify_api_ver(struct iavf_sc *); -int iavf_send_vf_config_msg(struct iavf_sc *); -int iavf_get_vf_config(struct iavf_sc *); -void iavf_init(void *); -int iavf_reinit_locked(struct iavf_sc *); -int iavf_configure_queues(struct iavf_sc *); -int iavf_enable_queues(struct iavf_sc *); -int iavf_disable_queues(struct iavf_sc *); -int iavf_map_queues(struct iavf_sc *); -void iavf_enable_intr(struct ixl_vsi *); -void iavf_disable_intr(struct ixl_vsi *); -int iavf_add_ether_filters(struct iavf_sc *); -int iavf_del_ether_filters(struct iavf_sc *); -int iavf_request_stats(struct iavf_sc *); -int iavf_request_reset(struct iavf_sc *); -void iavf_vc_completion(struct iavf_sc *, - enum virtchnl_ops, enum virtchnl_status_code, - u8 *, u16); -int iavf_add_ether_filter(struct iavf_sc *); -int iavf_add_vlans(struct iavf_sc *); -int iavf_del_vlans(struct iavf_sc *); -void iavf_update_stats_counters(struct iavf_sc *, - struct i40e_eth_stats *); -void iavf_update_link_status(struct iavf_sc *); -int iavf_get_default_rss_key(u32 *, bool); -int iavf_config_rss_key(struct iavf_sc *); -int iavf_set_rss_hena(struct iavf_sc *); -int iavf_config_rss_lut(struct iavf_sc *); -int iavf_config_promisc_mode(struct iavf_sc *); - -int ixl_vc_send_cmd(struct iavf_sc *sc, uint32_t request); -char *iavf_vc_speed_to_string(enum virtchnl_link_speed link_speed); -void *ixl_vc_get_op_chan(struct iavf_sc *sc, uint32_t request); -#endif /* _IAVF_H_ */ diff --git a/sys/dev/ixl/iavf_vc.c b/sys/dev/ixl/iavf_vc.c deleted file mode 100644 index ed9cc8432438..000000000000 --- a/sys/dev/ixl/iavf_vc.c +++ /dev/null @@ -1,1010 +0,0 @@ -/****************************************************************************** - - Copyright (c) 2013-2018, Intel Corporation - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -******************************************************************************/ -/*$FreeBSD$*/ - -/* -** Virtual Channel support -** These are support functions to communication -** between the VF and PF drivers. -*/ - -#include "ixl.h" -#include "iavf.h" - -/* busy wait delay in msec */ -#define IAVF_BUSY_WAIT_DELAY 10 -#define IAVF_BUSY_WAIT_COUNT 50 - -/* -** iavf_send_pf_msg -** -** Send message to PF and print status if failure. -*/ -static int -iavf_send_pf_msg(struct iavf_sc *sc, - enum virtchnl_ops op, u8 *msg, u16 len) -{ - struct i40e_hw *hw = &sc->hw; - device_t dev = sc->dev; - i40e_status status; - int val_err; - - /* Validating message before sending it to the PF */ - val_err = virtchnl_vc_validate_vf_msg(&sc->version, op, msg, len); - if (val_err) - device_printf(dev, "Error validating msg to PF for op %d," - " msglen %d: error %d\n", op, len, val_err); - - if (!i40e_check_asq_alive(hw)) { - if (op != VIRTCHNL_OP_GET_STATS) - device_printf(dev, "Unable to send opcode %s to PF, " - "ASQ is not alive\n", ixl_vc_opcode_str(op)); - return (0); - } - - if (op != VIRTCHNL_OP_GET_STATS) - iavf_dbg_vc(sc, - "Sending msg (op=%s[%d]) to PF\n", - ixl_vc_opcode_str(op), op); - - status = i40e_aq_send_msg_to_pf(hw, op, I40E_SUCCESS, msg, len, NULL); - if (status && op != VIRTCHNL_OP_GET_STATS) - device_printf(dev, "Unable to send opcode %s to PF, " - "status %s, aq error %s\n", - ixl_vc_opcode_str(op), - i40e_stat_str(hw, status), - i40e_aq_str(hw, hw->aq.asq_last_status)); - - return (status); -} - -/* -** iavf_send_api_ver -** -** Send API version admin queue message to the PF. The reply is not checked -** in this function. Returns 0 if the message was successfully -** sent, or one of the I40E_ADMIN_QUEUE_ERROR_ statuses if not. -*/ -int -iavf_send_api_ver(struct iavf_sc *sc) -{ - struct virtchnl_version_info vvi; - - vvi.major = VIRTCHNL_VERSION_MAJOR; - vvi.minor = VIRTCHNL_VERSION_MINOR; - - return iavf_send_pf_msg(sc, VIRTCHNL_OP_VERSION, - (u8 *)&vvi, sizeof(vvi)); -} - -/* -** iavf_verify_api_ver -** -** Compare API versions with the PF. Must be called after admin queue is -** initialized. Returns 0 if API versions match, EIO if -** they do not, or I40E_ERR_ADMIN_QUEUE_NO_WORK if the admin queue is empty. -*/ -int -iavf_verify_api_ver(struct iavf_sc *sc) -{ - struct virtchnl_version_info *pf_vvi; - struct i40e_hw *hw = &sc->hw; - struct i40e_arq_event_info event; - device_t dev = sc->dev; - i40e_status err; - int retries = 0; - - event.buf_len = IXL_AQ_BUF_SZ; - event.msg_buf = malloc(event.buf_len, M_IAVF, M_WAITOK); - - for (;;) { - if (++retries > IAVF_AQ_MAX_ERR) - goto out_alloc; - - /* Initial delay here is necessary */ - i40e_msec_pause(100); - err = i40e_clean_arq_element(hw, &event, NULL); - if (err == I40E_ERR_ADMIN_QUEUE_NO_WORK) - continue; - else if (err) { - err = EIO; - goto out_alloc; - } - - if ((enum virtchnl_ops)le32toh(event.desc.cookie_high) != - VIRTCHNL_OP_VERSION) { - DDPRINTF(dev, "Received unexpected op response: %d\n", - le32toh(event.desc.cookie_high)); - /* Don't stop looking for expected response */ - continue; - } - - err = (i40e_status)le32toh(event.desc.cookie_low); - if (err) { - err = EIO; - goto out_alloc; - } else - break; - } - - pf_vvi = (struct virtchnl_version_info *)event.msg_buf; - if ((pf_vvi->major > VIRTCHNL_VERSION_MAJOR) || - ((pf_vvi->major == VIRTCHNL_VERSION_MAJOR) && - (pf_vvi->minor > VIRTCHNL_VERSION_MINOR))) { - device_printf(dev, "Critical PF/VF API version mismatch!\n"); - err = EIO; - } else { - sc->version.major = pf_vvi->major; - sc->version.minor = pf_vvi->minor; - } - - /* Log PF/VF api versions */ - device_printf(dev, "PF API %d.%d / VF API %d.%d\n", - pf_vvi->major, pf_vvi->minor, - VIRTCHNL_VERSION_MAJOR, VIRTCHNL_VERSION_MINOR); - -out_alloc: - free(event.msg_buf, M_IAVF); - return (err); -} - -/* -** iavf_send_vf_config_msg -** -** Send VF configuration request admin queue message to the PF. The reply -** is not checked in this function. Returns 0 if the message was -** successfully sent, or one of the I40E_ADMIN_QUEUE_ERROR_ statuses if not. -*/ -int -iavf_send_vf_config_msg(struct iavf_sc *sc) -{ - u32 caps; - - caps = VIRTCHNL_VF_OFFLOAD_L2 | - VIRTCHNL_VF_OFFLOAD_RSS_PF | - VIRTCHNL_VF_OFFLOAD_VLAN; - - iavf_dbg_info(sc, "Sending offload flags: 0x%b\n", - caps, IAVF_PRINTF_VF_OFFLOAD_FLAGS); - - if (sc->version.minor == VIRTCHNL_VERSION_MINOR_NO_VF_CAPS) - return iavf_send_pf_msg(sc, VIRTCHNL_OP_GET_VF_RESOURCES, - NULL, 0); - else - return iavf_send_pf_msg(sc, VIRTCHNL_OP_GET_VF_RESOURCES, - (u8 *)&caps, sizeof(caps)); -} - -/* -** iavf_get_vf_config -** -** Get VF configuration from PF and populate hw structure. Must be called after -** admin queue is initialized. Busy waits until response is received from PF, -** with maximum timeout. Response from PF is returned in the buffer for further -** processing by the caller. -*/ -int -iavf_get_vf_config(struct iavf_sc *sc) -{ - struct i40e_hw *hw = &sc->hw; - device_t dev = sc->dev; - struct i40e_arq_event_info event; - u16 len; - i40e_status err = 0; - u32 retries = 0; - - /* Note this assumes a single VSI */ - len = sizeof(struct virtchnl_vf_resource) + - sizeof(struct virtchnl_vsi_resource); - event.buf_len = len; - event.msg_buf = malloc(event.buf_len, M_IAVF, M_WAITOK); - - for (;;) { - err = i40e_clean_arq_element(hw, &event, NULL); - if (err == I40E_ERR_ADMIN_QUEUE_NO_WORK) { - if (++retries <= IAVF_AQ_MAX_ERR) - i40e_msec_pause(10); - } else if ((enum virtchnl_ops)le32toh(event.desc.cookie_high) != - VIRTCHNL_OP_GET_VF_RESOURCES) { - DDPRINTF(dev, "Received a response from PF," - " opcode %d, error %d", - le32toh(event.desc.cookie_high), - le32toh(event.desc.cookie_low)); - retries++; - continue; - } else { - err = (i40e_status)le32toh(event.desc.cookie_low); - if (err) { - device_printf(dev, "%s: Error returned from PF," - " opcode %d, error %d\n", __func__, - le32toh(event.desc.cookie_high), - le32toh(event.desc.cookie_low)); - err = EIO; - goto out_alloc; - } - /* We retrieved the config message, with no errors */ - break; - } - - if (retries > IAVF_AQ_MAX_ERR) { - INIT_DBG_DEV(dev, "Did not receive response after %d tries.", - retries); - err = ETIMEDOUT; - goto out_alloc; - } - } - - memcpy(sc->vf_res, event.msg_buf, min(event.msg_len, len)); - i40e_vf_parse_hw_config(hw, sc->vf_res); - -out_alloc: - free(event.msg_buf, M_IAVF); - return err; -} - -/* -** iavf_configure_queues -** -** Request that the PF set up our queues. -*/ -int -iavf_configure_queues(struct iavf_sc *sc) -{ - device_t dev = sc->dev; - struct ixl_vsi *vsi = &sc->vsi; - if_softc_ctx_t scctx = iflib_get_softc_ctx(vsi->ctx); - struct ixl_tx_queue *tx_que = vsi->tx_queues; - struct ixl_rx_queue *rx_que = vsi->rx_queues; - struct tx_ring *txr; - struct rx_ring *rxr; - int len, pairs; - - struct virtchnl_vsi_queue_config_info *vqci; - struct virtchnl_queue_pair_info *vqpi; - - /* XXX: Linux PF driver wants matching ids in each tx/rx struct, so both TX/RX - * queues of a pair need to be configured */ - pairs = max(vsi->num_tx_queues, vsi->num_rx_queues); - len = sizeof(struct virtchnl_vsi_queue_config_info) + - (sizeof(struct virtchnl_queue_pair_info) * pairs); - vqci = malloc(len, M_IAVF, M_NOWAIT | M_ZERO); - if (!vqci) { - device_printf(dev, "%s: unable to allocate memory\n", __func__); - return (ENOMEM); - } - vqci->vsi_id = sc->vsi_res->vsi_id; - vqci->num_queue_pairs = pairs; - vqpi = vqci->qpair; - /* Size check is not needed here - HW max is 16 queue pairs, and we - * can fit info for 31 of them into the AQ buffer before it overflows. - */ - // TODO: the above is wrong now; X722 VFs can have 256 queues - for (int i = 0; i < pairs; i++, tx_que++, rx_que++, vqpi++) { - txr = &tx_que->txr; - rxr = &rx_que->rxr; - - vqpi->txq.vsi_id = vqci->vsi_id; - vqpi->txq.queue_id = i; - vqpi->txq.ring_len = scctx->isc_ntxd[0]; - vqpi->txq.dma_ring_addr = txr->tx_paddr; - /* Enable Head writeback */ - if (!vsi->enable_head_writeback) { - vqpi->txq.headwb_enabled = 0; - vqpi->txq.dma_headwb_addr = 0; - } else { - vqpi->txq.headwb_enabled = 1; - vqpi->txq.dma_headwb_addr = txr->tx_paddr + - sizeof(struct i40e_tx_desc) * scctx->isc_ntxd[0]; - } - - vqpi->rxq.vsi_id = vqci->vsi_id; - vqpi->rxq.queue_id = i; - vqpi->rxq.ring_len = scctx->isc_nrxd[0]; - vqpi->rxq.dma_ring_addr = rxr->rx_paddr; - vqpi->rxq.max_pkt_size = scctx->isc_max_frame_size; - vqpi->rxq.databuffer_size = rxr->mbuf_sz; - vqpi->rxq.splithdr_enabled = 0; - } - - iavf_send_pf_msg(sc, VIRTCHNL_OP_CONFIG_VSI_QUEUES, - (u8 *)vqci, len); - free(vqci, M_IAVF); - - return (0); -} - -/* -** iavf_enable_queues -** -** Request that the PF enable all of our queues. -*/ -int -iavf_enable_queues(struct iavf_sc *sc) -{ - struct virtchnl_queue_select vqs; - - vqs.vsi_id = sc->vsi_res->vsi_id; - /* XXX: In Linux PF, as long as neither of these is 0, - * every queue in VF VSI is enabled. */ - vqs.tx_queues = (1 << sc->vsi.num_tx_queues) - 1; - vqs.rx_queues = vqs.tx_queues; - iavf_send_pf_msg(sc, VIRTCHNL_OP_ENABLE_QUEUES, - (u8 *)&vqs, sizeof(vqs)); - return (0); -} - -/* -** iavf_disable_queues -** -** Request that the PF disable all of our queues. -*/ -int -iavf_disable_queues(struct iavf_sc *sc) -{ - struct virtchnl_queue_select vqs; - - vqs.vsi_id = sc->vsi_res->vsi_id; - /* XXX: In Linux PF, as long as neither of these is 0, - * every queue in VF VSI is disabled. */ - vqs.tx_queues = (1 << sc->vsi.num_tx_queues) - 1; - vqs.rx_queues = vqs.tx_queues; - iavf_send_pf_msg(sc, VIRTCHNL_OP_DISABLE_QUEUES, - (u8 *)&vqs, sizeof(vqs)); - return (0); -} - -/* -** iavf_map_queues -** -** Request that the PF map queues to interrupt vectors. Misc causes, including -** admin queue, are always mapped to vector 0. -*/ -int -iavf_map_queues(struct iavf_sc *sc) -{ - struct virtchnl_irq_map_info *vm; - int i, q, len; - struct ixl_vsi *vsi = &sc->vsi; - struct ixl_rx_queue *rx_que = vsi->rx_queues; - if_softc_ctx_t scctx = vsi->shared; - device_t dev = sc->dev; - - // XXX: What happens if we only get 1 MSI-X vector? - MPASS(scctx->isc_vectors > 1); - - /* How many queue vectors, adminq uses one */ - // XXX: How do we know how many interrupt vectors we have? - q = scctx->isc_vectors - 1; - - len = sizeof(struct virtchnl_irq_map_info) + - (scctx->isc_vectors * sizeof(struct virtchnl_vector_map)); - vm = malloc(len, M_IAVF, M_NOWAIT); - if (!vm) { - device_printf(dev, "%s: unable to allocate memory\n", __func__); - return (ENOMEM); - } - - vm->num_vectors = scctx->isc_vectors; - /* Queue vectors first */ - for (i = 0; i < q; i++, rx_que++) { - vm->vecmap[i].vsi_id = sc->vsi_res->vsi_id; - vm->vecmap[i].vector_id = i + 1; /* first is adminq */ - // TODO: Re-examine this - vm->vecmap[i].txq_map = (1 << rx_que->rxr.me); - vm->vecmap[i].rxq_map = (1 << rx_que->rxr.me); - vm->vecmap[i].rxitr_idx = 0; - vm->vecmap[i].txitr_idx = 1; - } - - /* Misc vector last - this is only for AdminQ messages */ - vm->vecmap[i].vsi_id = sc->vsi_res->vsi_id; - vm->vecmap[i].vector_id = 0; - vm->vecmap[i].txq_map = 0; - vm->vecmap[i].rxq_map = 0; - vm->vecmap[i].rxitr_idx = 0; - vm->vecmap[i].txitr_idx = 0; - - iavf_send_pf_msg(sc, VIRTCHNL_OP_CONFIG_IRQ_MAP, - (u8 *)vm, len); - free(vm, M_IAVF); - - return (0); -} - -/* -** Scan the Filter List looking for vlans that need -** to be added, then create the data to hand to the AQ -** for handling. -*/ -int -iavf_add_vlans(struct iavf_sc *sc) -{ - struct virtchnl_vlan_filter_list *v; - struct iavf_vlan_filter *f, *ftmp; - device_t dev = sc->dev; - int len, i = 0, cnt = 0; - - /* Get count of VLAN filters to add */ - SLIST_FOREACH(f, sc->vlan_filters, next) { - if (f->flags & IAVF_FILTER_ADD) - cnt++; - } - - if (!cnt) /* no work... */ - return (ENOENT); - - len = sizeof(struct virtchnl_vlan_filter_list) + - (cnt * sizeof(u16)); - - if (len > IXL_AQ_BUF_SZ) { - device_printf(dev, "%s: Exceeded Max AQ Buf size\n", - __func__); - return (EFBIG); - } - - v = malloc(len, M_IAVF, M_NOWAIT); - if (!v) { - device_printf(dev, "%s: unable to allocate memory\n", - __func__); - return (ENOMEM); - } - - v->vsi_id = sc->vsi_res->vsi_id; - v->num_elements = cnt; - - /* Scan the filter array */ - SLIST_FOREACH_SAFE(f, sc->vlan_filters, next, ftmp) { - if (f->flags & IAVF_FILTER_ADD) { - bcopy(&f->vlan, &v->vlan_id[i], sizeof(u16)); - f->flags = IAVF_FILTER_USED; - i++; - } - if (i == cnt) - break; - } - - iavf_send_pf_msg(sc, VIRTCHNL_OP_ADD_VLAN, (u8 *)v, len); - free(v, M_IAVF); - /* add stats? */ - return (0); -} - -/* -** Scan the Filter Table looking for vlans that need -** to be removed, then create the data to hand to the AQ -** for handling. -*/ -int -iavf_del_vlans(struct iavf_sc *sc) -{ - struct virtchnl_vlan_filter_list *v; - struct iavf_vlan_filter *f, *ftmp; - device_t dev = sc->dev; - int len, i = 0, cnt = 0; - - /* Get count of VLAN filters to delete */ - SLIST_FOREACH(f, sc->vlan_filters, next) { - if (f->flags & IAVF_FILTER_DEL) - cnt++; - } - - if (!cnt) /* no work... */ - return (ENOENT); - - len = sizeof(struct virtchnl_vlan_filter_list) + - (cnt * sizeof(u16)); - - if (len > IXL_AQ_BUF_SZ) { - device_printf(dev, "%s: Exceeded Max AQ Buf size\n", - __func__); - return (EFBIG); - } - - v = malloc(len, M_IAVF, M_NOWAIT | M_ZERO); - if (!v) { - device_printf(dev, "%s: unable to allocate memory\n", - __func__); - return (ENOMEM); - } - - v->vsi_id = sc->vsi_res->vsi_id; - v->num_elements = cnt; - - /* Scan the filter array */ - SLIST_FOREACH_SAFE(f, sc->vlan_filters, next, ftmp) { - if (f->flags & IAVF_FILTER_DEL) { - bcopy(&f->vlan, &v->vlan_id[i], sizeof(u16)); - i++; - SLIST_REMOVE(sc->vlan_filters, f, iavf_vlan_filter, next); - free(f, M_IAVF); - } - if (i == cnt) - break; - } - - iavf_send_pf_msg(sc, VIRTCHNL_OP_DEL_VLAN, (u8 *)v, len); - free(v, M_IAVF); - /* add stats? */ - return (0); -} - - -/* -** This routine takes additions to the vsi filter -** table and creates an Admin Queue call to create -** the filters in the hardware. -*/ -int -iavf_add_ether_filters(struct iavf_sc *sc) -{ - struct virtchnl_ether_addr_list *a; - struct iavf_mac_filter *f; - device_t dev = sc->dev; - int len, j = 0, cnt = 0; - enum i40e_status_code status; - - /* Get count of MAC addresses to add */ - SLIST_FOREACH(f, sc->mac_filters, next) { - if (f->flags & IAVF_FILTER_ADD) - cnt++; - } - if (cnt == 0) { /* Should not happen... */ - iavf_dbg_vc(sc, "%s: cnt == 0, exiting...\n", __func__); - return (ENOENT); - } - - len = sizeof(struct virtchnl_ether_addr_list) + - (cnt * sizeof(struct virtchnl_ether_addr)); - - a = malloc(len, M_IAVF, M_NOWAIT | M_ZERO); - if (a == NULL) { - device_printf(dev, "%s: Failed to get memory for " - "virtchnl_ether_addr_list\n", __func__); - return (ENOMEM); - } - a->vsi_id = sc->vsi.id; - a->num_elements = cnt; - - /* Scan the filter array */ - SLIST_FOREACH(f, sc->mac_filters, next) { - if (f->flags & IAVF_FILTER_ADD) { - bcopy(f->macaddr, a->list[j].addr, ETHER_ADDR_LEN); - f->flags &= ~IAVF_FILTER_ADD; - j++; - - iavf_dbg_vc(sc, "ADD: " MAC_FORMAT "\n", - MAC_FORMAT_ARGS(f->macaddr)); - } - if (j == cnt) - break; - } - DDPRINTF(dev, "len %d, j %d, cnt %d", - len, j, cnt); - - status = iavf_send_pf_msg(sc, - VIRTCHNL_OP_ADD_ETH_ADDR, (u8 *)a, len); - /* add stats? */ - free(a, M_IAVF); - return (status); -} - -/* -** This routine takes filters flagged for deletion in the -** sc MAC filter list and creates an Admin Queue call -** to delete those filters in the hardware. -*/ -int -iavf_del_ether_filters(struct iavf_sc *sc) -{ - struct virtchnl_ether_addr_list *d; - struct iavf_mac_filter *f, *f_temp; - device_t dev = sc->dev; - int len, j = 0, cnt = 0; - - /* Get count of MAC addresses to delete */ - SLIST_FOREACH(f, sc->mac_filters, next) { - if (f->flags & IAVF_FILTER_DEL) - cnt++; - } - if (cnt == 0) { - iavf_dbg_vc(sc, "%s: cnt == 0, exiting...\n", __func__); - return (ENOENT); - } - - len = sizeof(struct virtchnl_ether_addr_list) + - (cnt * sizeof(struct virtchnl_ether_addr)); - - d = malloc(len, M_IAVF, M_NOWAIT | M_ZERO); - if (d == NULL) { - device_printf(dev, "%s: Failed to get memory for " - "virtchnl_ether_addr_list\n", __func__); - return (ENOMEM); - } - d->vsi_id = sc->vsi.id; - d->num_elements = cnt; - - /* Scan the filter array */ - SLIST_FOREACH_SAFE(f, sc->mac_filters, next, f_temp) { - if (f->flags & IAVF_FILTER_DEL) { - bcopy(f->macaddr, d->list[j].addr, ETHER_ADDR_LEN); - iavf_dbg_vc(sc, "DEL: " MAC_FORMAT "\n", - MAC_FORMAT_ARGS(f->macaddr)); - j++; - SLIST_REMOVE(sc->mac_filters, f, iavf_mac_filter, next); - free(f, M_IAVF); - } - if (j == cnt) - break; - } - iavf_send_pf_msg(sc, - VIRTCHNL_OP_DEL_ETH_ADDR, (u8 *)d, len); - /* add stats? */ - free(d, M_IAVF); - return (0); -} - -/* -** iavf_request_reset -** Request that the PF reset this VF. No response is expected. -*/ -int -iavf_request_reset(struct iavf_sc *sc) -{ - /* - ** Set the reset status to "in progress" before - ** the request, this avoids any possibility of - ** a mistaken early detection of completion. - */ - wr32(&sc->hw, I40E_VFGEN_RSTAT, VIRTCHNL_VFR_INPROGRESS); - iavf_send_pf_msg(sc, VIRTCHNL_OP_RESET_VF, NULL, 0); - return (0); -} - -/* -** iavf_request_stats -** Request the statistics for this VF's VSI from PF. -*/ -int -iavf_request_stats(struct iavf_sc *sc) -{ - struct virtchnl_queue_select vqs; - int error = 0; - - vqs.vsi_id = sc->vsi_res->vsi_id; - /* Low priority, we don't need to error check */ - error = iavf_send_pf_msg(sc, VIRTCHNL_OP_GET_STATS, - (u8 *)&vqs, sizeof(vqs)); - if (error) - device_printf(sc->dev, "Error sending stats request to PF: %d\n", error); - - return (0); -} - -/* -** Updates driver's stats counters with VSI stats returned from PF. -*/ -void -iavf_update_stats_counters(struct iavf_sc *sc, struct i40e_eth_stats *es) -{ - struct ixl_vsi *vsi = &sc->vsi; - uint64_t tx_discards; - - tx_discards = es->tx_discards; *** 2741 LINES SKIPPED ***