From patchwork Tue May 7 11:45:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932429 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=Z91Tv6Ma; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbtb54wZz20fX for ; Tue, 7 May 2024 21:40:23 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 182F540210; Tue, 7 May 2024 11:40:20 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id rBTd1MZkU9uy; Tue, 7 May 2024 11:40:18 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org A3411404D5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082018; bh=WRedc3BC34dG0lrXrQeGVxV5cnSkM9K9yss032z+BRo=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Z91Tv6Mar9mWQ0JKAr9Cd4wn6C50k1+HdD7KvCrjHD5+FCpRdvXznBVMPa6J3LcNe 4MdvYASo74HKMUe8C3O6I+wFj2SiDqF7psHpRCfmpct+ST2mmXwlD0vJZPmzRgn0mE PsMQnSTC7Fa5XuOAQOZnQbnnjc91/Q6EhXlaVHaF/TWXQ8zHZXtCGoYWW16EW6dQZj brB7ECs412lryb2f8mr6Fg6xwu76tICks9mUbfxDWJD1xNpKjhOsvHiSlJA+SZfLO4 xDv3NfkzMJ401w8j4pQQ+t5+Cm6A8UDIY/33b3uowQrmKFjPUPIGUlPP/b/WGzx3sP wPba4cYBKJaPQ== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id A3411404D5; Tue, 7 May 2024 11:40:18 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 7ACCC1BF5A0 for ; Tue, 7 May 2024 11:40:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 676D240223 for ; Tue, 7 May 2024 11:40:16 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ldf9qXF0Z1Gk for ; Tue, 7 May 2024 11:40:15 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 4B2CD40154 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4B2CD40154 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id 4B2CD40154 for ; Tue, 7 May 2024 11:40:15 +0000 (UTC) X-CSE-ConnectionGUID: lrDD+yRoQH+dY8FLhxJzFw== X-CSE-MsgGUID: sGiWW6xKQMGfLGJ/ZXqznQ== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029103" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029103" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:15 -0700 X-CSE-ConnectionGUID: i3I392MySaGe50TT/txT9Q== X-CSE-MsgGUID: PvBBrNWoRcydYZ4UWf1ibw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576673" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:12 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:02 +0200 Message-ID: <20240507114516.9765-2-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082016; x=1746618016; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kVcpVddClaDdE3QMZ8Muaf9cVSX6xqkYnc7AwjJdwME=; b=OjCKb0qo51RWWee4XkuRrPfj5H9IfBnjtLOvpDMLC6HDbLJuT9DQct4N 4ap8GEZNKvg0c7ImZT06AzOcjYQvk3g/CZutaDSts0VTtMIqTZm4mKz9X euniSJ6fRsCBp5FJdjgY0bR22X1ycO31m2vgl7wph0BzBL83eRXzyhem1 QHVOzoKKbZbE3Fb/InbAKd89nZjuRP3VmjpBeZjK2IycnSCzfiSdDQvBH OCiKmAYff0kcGfQ868VQm7Wl/SZtqE1IsoaDJGHKshA6UwofQN5FDuz01 UrpX9/+rU2+dhUH67+0zEOvq9bx3J0NdPcBU3s3AhR5+Hz6tvxeeMf0kZ w==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=OjCKb0qo Subject: [Intel-wired-lan] [iwl-next v1 01/14] ice: add new VSI type for subfunctions X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Piotr Raczynski Add required plumbing for new VSI type dedicated to devlink subfunctions. Make sure that the vsi is properly configured and destroyed. Also allow loading XDP and AF_XDP sockets. The first implementation of devlink subfunctions supports only one Tx/Rx queue pair per given subfunction. Reviewed-by: Przemek Kitszel Reviewed-by: Wojciech Drewek Signed-off-by: Piotr Raczynski Signed-off-by: Michal Swiatkowski --- drivers/net/ethernet/intel/ice/ice_base.c | 5 +++- drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 1 + drivers/net/ethernet/intel/ice/ice_lib.c | 25 ++++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_main.c | 7 ++++-- drivers/net/ethernet/intel/ice/ice_type.h | 1 + drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c index 687f6cb2b917..bf1a085c7087 100644 --- a/drivers/net/ethernet/intel/ice/ice_base.c +++ b/drivers/net/ethernet/intel/ice/ice_base.c @@ -330,6 +330,9 @@ ice_setup_tx_ctx(struct ice_tx_ring *ring, struct ice_tlan_ctx *tlan_ctx, u16 pf tlan_ctx->vmvf_num = hw->func_caps.vf_base_id + vsi->vf->vf_id; tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VF; break; + case ICE_VSI_SF: + tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VMQ; + break; default: return; } @@ -526,7 +529,7 @@ static int ice_vsi_cfg_rxq(struct ice_rx_ring *ring) ring->rx_buf_len = ring->vsi->rx_buf_len; - if (ring->vsi->type == ICE_VSI_PF) { + if (ring->vsi->type == ICE_VSI_PF || ring->vsi->type == ICE_VSI_SF) { if (!xdp_rxq_info_is_reg(&ring->xdp_rxq)) { err = __xdp_rxq_info_reg(&ring->xdp_rxq, ring->netdev, ring->q_index, diff --git a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c index a94e7072b570..a7c510832824 100644 --- a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c @@ -187,6 +187,7 @@ void ice_vsi_set_dcb_tc_cfg(struct ice_vsi *vsi) vsi->tc_cfg.numtc = ice_dcb_get_num_tc(cfg); break; case ICE_VSI_CHNL: + case ICE_VSI_SF: vsi->tc_cfg.ena_tc = BIT(ice_get_first_droptc(vsi)); vsi->tc_cfg.numtc = 1; break; diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index 5371e91f6bbb..ccbd7bac3a9a 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -20,6 +20,8 @@ const char *ice_vsi_type_str(enum ice_vsi_type vsi_type) return "ICE_VSI_PF"; case ICE_VSI_VF: return "ICE_VSI_VF"; + case ICE_VSI_SF: + return "ICE_VSI_SF"; case ICE_VSI_CTRL: return "ICE_VSI_CTRL"; case ICE_VSI_CHNL: @@ -141,6 +143,7 @@ static void ice_vsi_set_num_desc(struct ice_vsi *vsi) { switch (vsi->type) { case ICE_VSI_PF: + case ICE_VSI_SF: case ICE_VSI_CTRL: case ICE_VSI_LB: /* a user could change the values of num_[tr]x_desc using @@ -207,6 +210,12 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi) max_t(int, vsi->alloc_rxq, vsi->alloc_txq)); break; + case ICE_VSI_SF: + vsi->alloc_txq = 1; + vsi->alloc_rxq = 1; + vsi->num_q_vectors = 1; + vsi->irq_dyn_alloc = true; + break; case ICE_VSI_VF: if (vf->num_req_qs) vf->num_vf_qs = vf->num_req_qs; @@ -566,6 +575,7 @@ ice_vsi_alloc_def(struct ice_vsi *vsi, struct ice_channel *ch) switch (vsi->type) { case ICE_VSI_PF: + case ICE_VSI_SF: /* Setup default MSIX irq handler for VSI */ vsi->irq_handler = ice_msix_clean_rings; break; @@ -894,6 +904,11 @@ static void ice_vsi_set_rss_params(struct ice_vsi *vsi) max_rss_size); vsi->rss_lut_type = ICE_LUT_PF; break; + case ICE_VSI_SF: + vsi->rss_table_size = ICE_LUT_VSI_SIZE; + vsi->rss_size = min_t(u16, num_online_cpus(), max_rss_size); + vsi->rss_lut_type = ICE_LUT_VSI; + break; case ICE_VSI_VF: /* VF VSI will get a small RSS table. * For VSI_LUT, LUT size should be set to 64 bytes. @@ -1141,6 +1156,7 @@ static void ice_set_rss_vsi_ctx(struct ice_vsi_ctx *ctxt, struct ice_vsi *vsi) lut_type = ICE_AQ_VSI_Q_OPT_RSS_LUT_PF; break; case ICE_VSI_VF: + case ICE_VSI_SF: /* VF VSI will gets a small RSS table which is a VSI LUT type */ lut_type = ICE_AQ_VSI_Q_OPT_RSS_LUT_VSI; break; @@ -1219,6 +1235,7 @@ static int ice_vsi_init(struct ice_vsi *vsi, u32 vsi_flags) case ICE_VSI_PF: ctxt->flags = ICE_AQ_VSI_TYPE_PF; break; + case ICE_VSI_SF: case ICE_VSI_CHNL: ctxt->flags = ICE_AQ_VSI_TYPE_VMDQ2; break; @@ -2100,6 +2117,7 @@ static void ice_set_agg_vsi(struct ice_vsi *vsi) case ICE_VSI_CHNL: case ICE_VSI_LB: case ICE_VSI_PF: + case ICE_VSI_SF: max_agg_nodes = ICE_MAX_PF_AGG_NODES; agg_node_id_start = ICE_PF_AGG_NODE_ID_START; agg_node_iter = &pf->pf_agg_node[0]; @@ -2269,6 +2287,7 @@ static int ice_vsi_cfg_def(struct ice_vsi *vsi) switch (vsi->type) { case ICE_VSI_CTRL: + case ICE_VSI_SF: case ICE_VSI_PF: ret = ice_vsi_alloc_q_vectors(vsi); if (ret) @@ -2654,7 +2673,8 @@ int ice_ena_vsi(struct ice_vsi *vsi, bool locked) clear_bit(ICE_VSI_NEEDS_RESTART, vsi->state); - if (vsi->netdev && vsi->type == ICE_VSI_PF) { + if (vsi->netdev && (vsi->type == ICE_VSI_PF || + vsi->type == ICE_VSI_SF)) { if (netif_running(vsi->netdev)) { if (!locked) rtnl_lock(); @@ -2683,7 +2703,8 @@ void ice_dis_vsi(struct ice_vsi *vsi, bool locked) set_bit(ICE_VSI_NEEDS_RESTART, vsi->state); - if (vsi->type == ICE_VSI_PF && vsi->netdev) { + if (vsi->netdev && (vsi->type == ICE_VSI_PF || + vsi->type == ICE_VSI_SF)) { if (netif_running(vsi->netdev)) { if (!locked) rtnl_lock(); diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 01c32a785ea4..9c85be556e6b 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -2947,6 +2947,9 @@ int ice_vsi_determine_xdp_res(struct ice_vsi *vsi) if (avail < cpus / 2) return -ENOMEM; + if (vsi->type == ICE_VSI_SF) + avail = vsi->alloc_txq; + vsi->num_xdp_txq = min_t(u16, avail, cpus); if (vsi->num_xdp_txq < cpus) @@ -3062,8 +3065,8 @@ static int ice_xdp(struct net_device *dev, struct netdev_bpf *xdp) struct ice_netdev_priv *np = netdev_priv(dev); struct ice_vsi *vsi = np->vsi; - if (vsi->type != ICE_VSI_PF) { - NL_SET_ERR_MSG_MOD(xdp->extack, "XDP can be loaded only on PF VSI"); + if (vsi->type != ICE_VSI_PF && vsi->type != ICE_VSI_SF) { + NL_SET_ERR_MSG_MOD(xdp->extack, "XDP can be loaded only on PF or SF VSI"); return -EINVAL; } diff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h index 5f0da6850b03..50c3ed76933d 100644 --- a/drivers/net/ethernet/intel/ice/ice_type.h +++ b/drivers/net/ethernet/intel/ice/ice_type.h @@ -150,6 +150,7 @@ enum ice_vsi_type { ICE_VSI_CTRL = 3, /* equates to ICE_VSI_PF with 1 queue pair */ ICE_VSI_CHNL = 4, ICE_VSI_LB = 6, + ICE_VSI_SF = 9, }; struct ice_link_status { diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c index aa81d1162b81..64f4927efa29 100644 --- a/drivers/net/ethernet/intel/ice/ice_xsk.c +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c @@ -288,7 +288,7 @@ ice_xsk_pool_enable(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid) { int err; - if (vsi->type != ICE_VSI_PF) + if (vsi->type != ICE_VSI_PF && vsi->type != ICE_VSI_SF) return -EINVAL; if (qid >= vsi->netdev->real_num_rx_queues || From patchwork Tue May 7 11:45:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932430 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=TUfq6K84; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbtf5QtCz1xnS for ; Tue, 7 May 2024 21:40:26 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 3A7F04022B; Tue, 7 May 2024 11:40:23 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id miV2l5j3Gto8; Tue, 7 May 2024 11:40:22 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org F173F404DB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082022; bh=oVRps8sSH65z18Z1Vo397PICrfFdn06uhaaq6N8BCG8=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=TUfq6K84Dk2CQ1PPFzL0RP7D5KwCJTRfEJrqmIPU1VO+2CW/JHB4joevlQimcZhFg XJzL4iiPKxm08zr/WbSXWzg76SF3Kf7Bpq9pYRO1534HClkvmgwbUpfUYFFpKYqyhy cpXNasko+NDpjLuDd7Lt4bBzxUudJZRpvrDSH93xAvz2eJEYaAONCtQkl/AMAROZXL +/fzDGGk1jrFKNPaxUhRGlMEn9loO6x/i7tkO0GNbPwjGN/KEZuYa8mVvWKPcj+Esv 0rTaEM4gT61L2HDprrsuA3aYCB3ejy1ReyYGNTi6ZeqryvcA/b8q9n6FIiUp5KqbKy ex+iGT0A4ojbw== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id F173F404DB; Tue, 7 May 2024 11:40:21 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 5A2A71BF5A0 for ; Tue, 7 May 2024 11:40:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 54C3040223 for ; Tue, 7 May 2024 11:40:19 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ztL2KqzqBGAL for ; Tue, 7 May 2024 11:40:18 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 5270440154 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5270440154 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5270440154 for ; Tue, 7 May 2024 11:40:18 +0000 (UTC) X-CSE-ConnectionGUID: E2Xs1+v4RqGeOqOmEAPIrw== X-CSE-MsgGUID: ggcESvPxRPKsRhRgfoNX9Q== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029122" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029122" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:18 -0700 X-CSE-ConnectionGUID: UbJ3625bREOLa4l1TUsu8Q== X-CSE-MsgGUID: 9HH8LUN6RbS4MwPNNFfTXw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576677" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:15 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:03 +0200 Message-ID: <20240507114516.9765-3-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082019; x=1746618019; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X+qScVtswezWq+EmUhUTmxIb6SH+LL7eFiCECmnEoD8=; b=DbDWiys18g7rB82xILQtS8xgDrXUZYIpHjYjbP6g68Tx8j82n3Mw+cfM 76S/6QpgmaGOpYY0yVfrU1s1XNV388M/M29G2Wy8DBXnc3ORcfYk0KGz8 GQGE2Og3H+KOvk2RVlyl2o/1BYEXVC3xCGRvl1x16/LOmWJEQIwRvYNdv ESbpmQ81SS5ylLzo3WlB9Apu3H2iUIRVqMF14eNGtmzzHeMtXpjTm70eA rgxYK+d3Mz9VdY6+GS+ChGDaVF/86qERcSYh/oAWp1rxFRjsJZsirvd5n 6ttgl9MlvGR1D6agjjbGlVr8CLK18QYm/Rpo+WC8fBBOJjCZ3HGWEDU0B w==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=DbDWiys1 Subject: [Intel-wired-lan] [iwl-next v1 02/14] ice: export ice ndo_ops functions X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Piotr Raczynski Make some of the netdevice_ops functions visible from outside for another VSI type created netdev. Reviewed-by: Przemek Kitszel Reviewed-by: Wojciech Drewek Signed-off-by: Piotr Raczynski Signed-off-by: Michal Swiatkowski --- drivers/net/ethernet/intel/ice/ice.h | 8 +++++ drivers/net/ethernet/intel/ice/ice_lib.c | 22 ++++++++++++++ drivers/net/ethernet/intel/ice/ice_lib.h | 1 + drivers/net/ethernet/intel/ice/ice_main.c | 37 ++++------------------- 4 files changed, 37 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 6ad8002b22e1..7bdf3fd30f7a 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -984,6 +984,14 @@ void ice_unload(struct ice_pf *pf); void ice_adv_lnk_speed_maps_init(void); int ice_init_dev(struct ice_pf *pf); void ice_deinit_dev(struct ice_pf *pf); +int ice_change_mtu(struct net_device *netdev, int new_mtu); +void ice_tx_timeout(struct net_device *netdev, unsigned int txqueue); +int ice_xdp(struct net_device *dev, struct netdev_bpf *xdp); +void ice_set_netdev_features(struct net_device *netdev); +int ice_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid); +int ice_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid); +void ice_get_stats64(struct net_device *netdev, + struct rtnl_link_stats64 *stats); /** * ice_set_rdma_cap - enable RDMA support diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index ccbd7bac3a9a..e2ce7395e2f2 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -2838,6 +2838,28 @@ void ice_vsi_set_napi_queues(struct ice_vsi *vsi) ice_q_vector_set_napi_queues(vsi->q_vectors[i]); } +/** + * ice_napi_add - register NAPI handler for the VSI + * @vsi: VSI for which NAPI handler is to be registered + * + * This function is only called in the driver's load path. Registering the NAPI + * handler is done in ice_vsi_alloc_q_vector() for all other cases (i.e. resume, + * reset/rebuild, etc.) + */ +void ice_napi_add(struct ice_vsi *vsi) +{ + int v_idx; + + if (!vsi->netdev) + return; + + ice_for_each_q_vector(vsi, v_idx) { + netif_napi_add(vsi->netdev, &vsi->q_vectors[v_idx]->napi, + ice_napi_poll); + __ice_q_vector_set_napi_queues(vsi->q_vectors[v_idx], false); + } +} + /** * ice_vsi_release - Delete a VSI and free its resources * @vsi: the VSI being removed diff --git a/drivers/net/ethernet/intel/ice/ice_lib.h b/drivers/net/ethernet/intel/ice/ice_lib.h index 94ce8964dda6..f9ee461c5c06 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.h +++ b/drivers/net/ethernet/intel/ice/ice_lib.h @@ -53,6 +53,7 @@ void __ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector, bool locked); void ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector); void ice_vsi_set_napi_queues(struct ice_vsi *vsi); +void ice_napi_add(struct ice_vsi *vsi); int ice_vsi_release(struct ice_vsi *vsi); diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 9c85be556e6b..ce1cf1b03321 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -3060,7 +3060,7 @@ static int ice_xdp_safe_mode(struct net_device __always_unused *dev, * @dev: netdevice * @xdp: XDP command */ -static int ice_xdp(struct net_device *dev, struct netdev_bpf *xdp) +int ice_xdp(struct net_device *dev, struct netdev_bpf *xdp) { struct ice_netdev_priv *np = netdev_priv(dev); struct ice_vsi *vsi = np->vsi; @@ -3519,28 +3519,6 @@ static int ice_req_irq_msix_misc(struct ice_pf *pf) return 0; } -/** - * ice_napi_add - register NAPI handler for the VSI - * @vsi: VSI for which NAPI handler is to be registered - * - * This function is only called in the driver's load path. Registering the NAPI - * handler is done in ice_vsi_alloc_q_vector() for all other cases (i.e. resume, - * reset/rebuild, etc.) - */ -static void ice_napi_add(struct ice_vsi *vsi) -{ - int v_idx; - - if (!vsi->netdev) - return; - - ice_for_each_q_vector(vsi, v_idx) { - netif_napi_add(vsi->netdev, &vsi->q_vectors[v_idx]->napi, - ice_napi_poll); - __ice_q_vector_set_napi_queues(vsi->q_vectors[v_idx], false); - } -} - /** * ice_set_ops - set netdev and ethtools ops for the given netdev * @vsi: the VSI associated with the new netdev @@ -3574,7 +3552,7 @@ static void ice_set_ops(struct ice_vsi *vsi) * ice_set_netdev_features - set features for the given netdev * @netdev: netdev instance */ -static void ice_set_netdev_features(struct net_device *netdev) +void ice_set_netdev_features(struct net_device *netdev) { struct ice_pf *pf = ice_netdev_to_pf(netdev); bool is_dvm_ena = ice_is_dvm_ena(&pf->hw); @@ -3756,8 +3734,7 @@ ice_lb_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi) * * net_device_ops implementation for adding VLAN IDs */ -static int -ice_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid) +int ice_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid) { struct ice_netdev_priv *np = netdev_priv(netdev); struct ice_vsi_vlan_ops *vlan_ops; @@ -3819,8 +3796,7 @@ ice_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid) * * net_device_ops implementation for removing VLAN IDs */ -static int -ice_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid) +int ice_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid) { struct ice_netdev_priv *np = netdev_priv(netdev); struct ice_vsi_vlan_ops *vlan_ops; @@ -7059,7 +7035,6 @@ void ice_update_pf_stats(struct ice_pf *pf) * @netdev: network interface device structure * @stats: main device statistics structure */ -static void ice_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) { struct ice_netdev_priv *np = netdev_priv(netdev); @@ -7732,7 +7707,7 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) * * Returns 0 on success, negative on failure */ -static int ice_change_mtu(struct net_device *netdev, int new_mtu) +int ice_change_mtu(struct net_device *netdev, int new_mtu) { struct ice_netdev_priv *np = netdev_priv(netdev); struct ice_vsi *vsi = np->vsi; @@ -8156,7 +8131,7 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh, * @netdev: network interface device structure * @txqueue: Tx queue */ -static void ice_tx_timeout(struct net_device *netdev, unsigned int txqueue) +void ice_tx_timeout(struct net_device *netdev, unsigned int txqueue) { struct ice_netdev_priv *np = netdev_priv(netdev); struct ice_tx_ring *tx_ring = NULL; From patchwork Tue May 7 11:45:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932431 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=81+2Dh5Y; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbtj4Gzrz1xnS for ; Tue, 7 May 2024 21:40:29 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id D5D2640701; Tue, 7 May 2024 11:40:26 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id XTcbdFW6fRcB; Tue, 7 May 2024 11:40:25 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org E782C40664 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082025; bh=jdnFsR+WbvBN6hdxHvXnN90w4+gPbIjJaQshj1GqGjI=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=81+2Dh5YRCEvLV3rH2ItfYOg2BFag0d/rj/A+gSq0QYjeDmusynKPwdt/9K50iALI jjHI40GVm2ftajPZaVWvVf+zLemGX1e9i++k/UPPWhr6mgrQWRmO+jjHtjolzHoq68 p+/k/cb65yt/L5a6QReUaJ1ehjA/qB2/J4mAv8J93zBPp5Z7i1pLfvt61ZzGNfz94f YWT4nDDdGPLwkUgfEMhPR6NA6KgTRNgsenrOyiviBy+W2QAofrAx21XCQngQNC7VFA O9vFvG6nfTBwNxBKqM5Xn1zd6mep81yaMKGD+8BxhHDQeCvePA0TK+8qdEzwfkpXj8 Sgqk1mRdoachA== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id E782C40664; Tue, 7 May 2024 11:40:24 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 3E5061BF5A0 for ; Tue, 7 May 2024 11:40:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 2B8C240223 for ; Tue, 7 May 2024 11:40:23 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id STHsIBhbfId2 for ; Tue, 7 May 2024 11:40:21 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 9E4AD40154 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9E4AD40154 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id 9E4AD40154 for ; Tue, 7 May 2024 11:40:21 +0000 (UTC) X-CSE-ConnectionGUID: V9Z1RnyTRcOqkE15gnOTyw== X-CSE-MsgGUID: OykoOmqkQjufmOyXz+lKqw== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029132" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029132" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:22 -0700 X-CSE-ConnectionGUID: ILAmH+U4SyGAyw2iahiTCg== X-CSE-MsgGUID: B1kLXF9CSEqYm03pZN7Izw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576681" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:18 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:04 +0200 Message-ID: <20240507114516.9765-4-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082022; x=1746618022; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5V2uhOj71ZXGSbxWTZ/Pt6JCmlQJfOFsRPyOZBGOytk=; b=A2gJHQYa0FQ5AYVyGlsY7U8axSUpYNMyiIAFGjYPQqeG1rmsFVOWFj1e jFmvENfWf6+viLTdUkgY7JD2bubbtn4QJx3KETWu604NSO6l5WjthOkse lOZRNjDPBlSdFPMrdm4YYG3kH2JP2I4P7qYwhlpCJTKGYbtKX1zeltBsU zRD7qOnOM/BC3uZEool++95hA2PfDkuXmpVnCwn0BBpRBUTpdK9kGLuBg j3Yw+qUEU+dRJWycd1aWBCsG2mrMjcKCRmOtlFgo1coh2kfIa2uXDRjT5 jQf25qO5g1oJZBPsC57KMPaDO7D87mJnqdr/rt5ij/H3ZxDItsJg10av2 w==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=A2gJHQYa Subject: [Intel-wired-lan] [iwl-next v1 03/14] ice: add basic devlink subfunctions support X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Piotr Raczynski Implement devlink port handlers responsible for ethernet type devlink subfunctions. Create subfunction devlink port and setup all resources needed for a subfunction netdev to operate. Configure new VSI for each new subfunction, initialize and configure interrupts and Tx/Rx resources. Set correct MAC filters and create new netdev. For now, subfunction is limited to only one Tx/Rx queue pair. Only allocate new subfunction VSI with devlink port new command. This makes sure that real resources are configured only when a new subfunction gets activated. Allocate and free subfunction MSIX interrupt vectors using new API calls with pci_msix_alloc_irq_at and pci_msix_free_irq. Support both automatic and manual subfunction numbers. If no subfunction number is provided, use xa_alloc to pick a number automatically. This will find the first free index and use that as the number. This reduces burden on users in the simple case where a specific number is not required. It may also be slightly faster to check that a number exists since xarray lookup should be faster than a linear scan of the dyn_ports xarray. Reviewed-by: Wojciech Drewek Co-developed-by: Jacob Keller Signed-off-by: Jacob Keller Signed-off-by: Piotr Raczynski Signed-off-by: Michal Swiatkowski --- .../net/ethernet/intel/ice/devlink/devlink.c | 3 + .../ethernet/intel/ice/devlink/devlink_port.c | 357 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 33 ++ drivers/net/ethernet/intel/ice/ice.h | 4 + drivers/net/ethernet/intel/ice/ice_lib.c | 5 +- drivers/net/ethernet/intel/ice/ice_lib.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 9 +- 7 files changed, 410 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c index 10073342e4f0..3fb3a7e828a4 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c @@ -6,6 +6,7 @@ #include "ice.h" #include "ice_lib.h" #include "devlink.h" +#include "devlink_port.h" #include "ice_eswitch.h" #include "ice_fw_update.h" #include "ice_dcb_lib.h" @@ -1277,6 +1278,8 @@ static const struct devlink_ops ice_devlink_ops = { .rate_leaf_parent_set = ice_devlink_set_parent, .rate_node_parent_set = ice_devlink_set_parent, + + .port_new = ice_devlink_port_new, }; static int diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c index c9fbeebf7fb9..995c11f71b3f 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c @@ -5,6 +5,9 @@ #include "ice.h" #include "devlink.h" +#include "devlink_port.h" +#include "ice_lib.h" +#include "ice_fltr.h" static int ice_active_port_option = -1; @@ -428,3 +431,357 @@ void ice_devlink_destroy_vf_port(struct ice_vf *vf) devl_rate_leaf_destroy(&vf->devlink_port); devl_port_unregister(&vf->devlink_port); } + +/** + * ice_dealloc_dynamic_port - Deallocate and remove a dynamic port + * @dyn_port: dynamic port instance to deallocate + * + * Free resources associated with a dynamically added devlink port. Will + * deactivate the port if its currently active. + */ +static void ice_dealloc_dynamic_port(struct ice_dynamic_port *dyn_port) +{ + struct devlink_port *devlink_port = &dyn_port->devlink_port; + struct ice_pf *pf = dyn_port->pf; + + xa_erase(&pf->sf_nums, devlink_port->attrs.pci_sf.sf); + devl_port_unregister(devlink_port); + ice_vsi_free(dyn_port->vsi); + xa_erase(&pf->dyn_ports, dyn_port->vsi->idx); + kfree(dyn_port); +} + +/** + * ice_dealloc_all_dynamic_ports - Deallocate all dynamic devlink ports + * @pf: pointer to the pf structure + */ +void ice_dealloc_all_dynamic_ports(struct ice_pf *pf) +{ + struct ice_dynamic_port *dyn_port; + unsigned long index; + + xa_for_each(&pf->dyn_ports, index, dyn_port) + ice_dealloc_dynamic_port(dyn_port); +} + +/** + * ice_devlink_port_new_check_attr - Check that new port attributes are valid + * @pf: pointer to the PF structure + * @new_attr: the attributes for the new port + * @extack: extack for reporting error messages + * + * Check that the attributes for the new port are valid before continuing to + * allocate the devlink port. + * + * Return: zero on success or an error code on failure. + */ +static int +ice_devlink_port_new_check_attr(struct ice_pf *pf, + const struct devlink_port_new_attrs *new_attr, + struct netlink_ext_ack *extack) +{ + if (new_attr->flavour != DEVLINK_PORT_FLAVOUR_PCI_SF) { + NL_SET_ERR_MSG_MOD(extack, "Flavour other than pcisf is not supported"); + return -EOPNOTSUPP; + } + + if (new_attr->controller_valid) { + NL_SET_ERR_MSG_MOD(extack, "Setting controller is not supported"); + return -EOPNOTSUPP; + } + + if (new_attr->port_index_valid) { + NL_SET_ERR_MSG_MOD(extack, "Port index is invalid"); + return -EOPNOTSUPP; + } + + if (new_attr->pfnum != pf->hw.bus.func) { + NL_SET_ERR_MSG_MOD(extack, "Incorrect pfnum supplied"); + return -EINVAL; + } + + if (!pci_msix_can_alloc_dyn(pf->pdev)) { + NL_SET_ERR_MSG_MOD(extack, "Dynamic MSIX-X interrupt allocation is not supported"); + return -EOPNOTSUPP; + } + + return 0; +} + +/** + * ice_devlink_port_del - devlink handler for port delete + * @devlink: pointer to devlink + * @port: devlink port to be deleted + * @extack: pointer to extack + * + * Deletes devlink port and deallocates all resources associated with + * created subfunction. + * + * Return: zero on success or an error code on failure. + */ +static int +ice_devlink_port_del(struct devlink *devlink, struct devlink_port *port, + struct netlink_ext_ack *extack) +{ + struct ice_dynamic_port *dyn_port; + + dyn_port = ice_devlink_port_to_dyn(port); + ice_dealloc_dynamic_port(dyn_port); + + return 0; +} + +/** + * ice_devlink_port_fn_hw_addr_set - devlink handler for mac address set + * @port: pointer to devlink port + * @hw_addr: hw address to set + * @hw_addr_len: hw address length + * @extack: extack for reporting error messages + * + * Sets mac address for the port, verifies arguments and copies address + * to the subfunction structure. + * + * Return: zero on success or an error code on failure. + */ +static int +ice_devlink_port_fn_hw_addr_set(struct devlink_port *port, const u8 *hw_addr, + int hw_addr_len, + struct netlink_ext_ack *extack) +{ + struct ice_dynamic_port *dyn_port; + + dyn_port = ice_devlink_port_to_dyn(port); + + if (hw_addr_len != ETH_ALEN || !is_valid_ether_addr(hw_addr)) { + NL_SET_ERR_MSG_MOD(extack, "Invalid ethernet address"); + return -EADDRNOTAVAIL; + } + + ether_addr_copy(dyn_port->hw_addr, hw_addr); + + return 0; +} + +/** + * ice_devlink_port_fn_hw_addr_get - devlink handler for mac address get + * @port: pointer to devlink port + * @hw_addr: hw address to set + * @hw_addr_len: hw address length + * @extack: extack for reporting error messages + * + * Returns mac address for the port. + * + * Return: zero on success or an error code on failure. + */ +static int +ice_devlink_port_fn_hw_addr_get(struct devlink_port *port, u8 *hw_addr, + int *hw_addr_len, + struct netlink_ext_ack *extack) +{ + struct ice_dynamic_port *dyn_port; + + dyn_port = ice_devlink_port_to_dyn(port); + + ether_addr_copy(hw_addr, dyn_port->hw_addr); + *hw_addr_len = ETH_ALEN; + + return 0; +} + +static const struct devlink_port_ops ice_devlink_port_sf_ops = { + .port_del = ice_devlink_port_del, + .port_fn_hw_addr_get = ice_devlink_port_fn_hw_addr_get, + .port_fn_hw_addr_set = ice_devlink_port_fn_hw_addr_set, +}; + +/** + * ice_reserve_sf_num - Reserve a subfunction number for this port + * @pf: pointer to the pf structure + * @new_attr: devlink port attributes requested + * @extack: extack for reporting error messages + * @sfnum: on success, the sf number reserved + * + * Reserve a subfunction number for this port. Only called for + * DEVLINK_PORT_FLAVOUR_PCI_SF ports. + * + * Return: zero on success or an error code on failure. + */ +static int +ice_reserve_sf_num(struct ice_pf *pf, + const struct devlink_port_new_attrs *new_attr, + struct netlink_ext_ack *extack, u32 *sfnum) +{ + int err; + + /* If user didn't request an explicit number, pick one */ + if (!new_attr->sfnum_valid) + return xa_alloc(&pf->sf_nums, sfnum, NULL, xa_limit_32b, + GFP_KERNEL); + + /* Otherwise, check and use the number provided */ + err = xa_insert(&pf->sf_nums, new_attr->sfnum, NULL, GFP_KERNEL); + if (err) { + if (err == -EBUSY) + NL_SET_ERR_MSG_MOD(extack, "Subfunction with given sfnum already exists"); + return err; + } + + *sfnum = new_attr->sfnum; + + return 0; +} + +/** + * ice_devlink_create_sf_port - Register PCI subfunction devlink port + * @dyn_port: the dynamic port instance structure for this subfunction + * + * Register PCI subfunction flavour devlink port for a dynamically added + * subfunction port. + * + * Return: zero on success or an error code on failure. + */ +int ice_devlink_create_sf_port(struct ice_dynamic_port *dyn_port) +{ + struct devlink_port_attrs attrs = {}; + struct devlink_port *devlink_port; + struct devlink *devlink; + struct ice_vsi *vsi; + struct device *dev; + struct ice_pf *pf; + int err; + + vsi = dyn_port->vsi; + pf = dyn_port->pf; + dev = ice_pf_to_dev(pf); + + devlink_port = &dyn_port->devlink_port; + + attrs.flavour = DEVLINK_PORT_FLAVOUR_PCI_SF; + attrs.pci_sf.pf = pf->hw.bus.func; + attrs.pci_sf.sf = dyn_port->sfnum; + + devlink_port_attrs_set(devlink_port, &attrs); + devlink = priv_to_devlink(pf); + + err = devl_port_register_with_ops(devlink, devlink_port, vsi->idx, + &ice_devlink_port_sf_ops); + if (err) { + dev_err(dev, "Failed to create devlink port for Subfunction %d", + vsi->idx); + return err; + } + + return 0; +} + +/** + * ice_devlink_destroy_sf_port - Destroy the devlink_port for this SF + * @dyn_port: the dynamic port instance structure for this subfunction + * + * Unregisters the devlink_port structure associated with this SF. + */ +void ice_devlink_destroy_sf_port(struct ice_dynamic_port *dyn_port) +{ + devl_port_unregister(&dyn_port->devlink_port); +} + +/** + * ice_alloc_dynamic_port - Allocate new dynamic port + * @pf: pointer to the pf structure + * @new_attr: devlink port attributes requested + * @extack: extack for reporting error messages + * @devlink_port: index of newly created devlink port + * + * Allocate a new dynamic port instance and prepare it for configuration + * with devlink. + * + * Return: zero on success or an error code on failure. + */ +static int +ice_alloc_dynamic_port(struct ice_pf *pf, + const struct devlink_port_new_attrs *new_attr, + struct netlink_ext_ack *extack, + struct devlink_port **devlink_port) +{ + struct ice_dynamic_port *dyn_port; + struct ice_vsi *vsi; + u32 sfnum; + int err; + + err = ice_reserve_sf_num(pf, new_attr, extack, &sfnum); + if (err) + return err; + + dyn_port = kzalloc(sizeof(*dyn_port), GFP_KERNEL); + if (!dyn_port) { + err = -ENOMEM; + goto unroll_reserve_sf_num; + } + + vsi = ice_vsi_alloc(pf); + if (!vsi) { + NL_SET_ERR_MSG_MOD(extack, "Unable to allocate VSI"); + err = -ENOMEM; + goto unroll_dyn_port_alloc; + } + + dyn_port->vsi = vsi; + dyn_port->pf = pf; + dyn_port->sfnum = sfnum; + eth_random_addr(dyn_port->hw_addr); + + err = xa_insert(&pf->dyn_ports, vsi->idx, dyn_port, GFP_KERNEL); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Port index reservation failed"); + goto unroll_vsi_alloc; + } + + err = ice_devlink_create_sf_port(dyn_port); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Port registration failed"); + goto unroll_xa_insert; + } + + *devlink_port = &dyn_port->devlink_port; + + return 0; + +unroll_xa_insert: + xa_erase(&pf->dyn_ports, vsi->idx); +unroll_vsi_alloc: + ice_vsi_free(vsi); +unroll_dyn_port_alloc: + kfree(dyn_port); +unroll_reserve_sf_num: + xa_erase(&pf->sf_nums, sfnum); + + return err; +} + +/** + * ice_devlink_port_new - devlink handler for the new port + * @devlink: pointer to devlink + * @new_attr: pointer to the port new attributes + * @extack: extack for reporting error messages + * @devlink_port: pointer to a new port + * + * Creates new devlink port, checks new port attributes and reject + * any unsupported parameters, allocates new subfunction for that port. + * + * Return: zero on success or an error code on failure. + */ +int +ice_devlink_port_new(struct devlink *devlink, + const struct devlink_port_new_attrs *new_attr, + struct netlink_ext_ack *extack, + struct devlink_port **devlink_port) +{ + struct ice_pf *pf = devlink_priv(devlink); + int err; + + err = ice_devlink_port_new_check_attr(pf, new_attr, extack); + if (err) + return err; + + return ice_alloc_dynamic_port(pf, new_attr, extack, devlink_port); +} diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h index 9223bcdb6444..f20d7cc522a6 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h +++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h @@ -4,9 +4,42 @@ #ifndef _DEVLINK_PORT_H_ #define _DEVLINK_PORT_H_ +#include "../ice.h" + +/** + * struct ice_dynamic_port - Track dynamically added devlink port instance + * @hw_addr: the HW address for this port + * @active: true if the port has been activated + * @devlink_port: the associated devlink port structure + * @pf: pointer to the PF private structure + * @vsi: the VSI associated with this port + * + * An instance of a dynamically added devlink port. Each port flavour + */ +struct ice_dynamic_port { + u8 hw_addr[ETH_ALEN]; + u8 active: 1; + struct devlink_port devlink_port; + struct ice_pf *pf; + struct ice_vsi *vsi; + u32 sfnum; +}; + +void ice_dealloc_all_dynamic_ports(struct ice_pf *pf); + int ice_devlink_create_pf_port(struct ice_pf *pf); void ice_devlink_destroy_pf_port(struct ice_pf *pf); int ice_devlink_create_vf_port(struct ice_vf *vf); void ice_devlink_destroy_vf_port(struct ice_vf *vf); +int ice_devlink_create_sf_port(struct ice_dynamic_port *dyn_port); +void ice_devlink_destroy_sf_port(struct ice_dynamic_port *dyn_port); + +#define ice_devlink_port_to_dyn(p) \ + container_of(port, struct ice_dynamic_port, devlink_port) +int +ice_devlink_port_new(struct devlink *devlink, + const struct devlink_port_new_attrs *new_attr, + struct netlink_ext_ack *extack, + struct devlink_port **devlink_port); #endif /* _DEVLINK_PORT_H_ */ diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 7bdf3fd30f7a..8a30b786b334 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -651,6 +651,9 @@ struct ice_pf { struct ice_eswitch eswitch; struct ice_esw_br_port *br_port; + struct xarray dyn_ports; + struct xarray sf_nums; + #define ICE_INVALID_AGG_NODE_ID 0 #define ICE_PF_AGG_NODE_ID_START 1 #define ICE_MAX_PF_AGG_NODES 32 @@ -907,6 +910,7 @@ int ice_vsi_open(struct ice_vsi *vsi); void ice_set_ethtool_ops(struct net_device *netdev); void ice_set_ethtool_repr_ops(struct net_device *netdev); void ice_set_ethtool_safe_mode_ops(struct net_device *netdev); +void ice_set_ethtool_sf_ops(struct net_device *netdev); u16 ice_get_avail_txq_count(struct ice_pf *pf); u16 ice_get_avail_rxq_count(struct ice_pf *pf); int ice_vsi_recfg_qs(struct ice_vsi *vsi, int new_rx, int new_tx, bool locked); diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index e2ce7395e2f2..bab2edaafb99 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -7,6 +7,7 @@ #include "ice_lib.h" #include "ice_fltr.h" #include "ice_dcb_lib.h" +#include "ice_type.h" #include "ice_vsi_vlan_ops.h" /** @@ -440,7 +441,7 @@ static int ice_vsi_alloc_ring_stats(struct ice_vsi *vsi) * This deallocates the VSI's queue resources, removes it from the PF's * VSI array if necessary, and deallocates the VSI */ -static void ice_vsi_free(struct ice_vsi *vsi) +void ice_vsi_free(struct ice_vsi *vsi) { struct ice_pf *pf = NULL; struct device *dev; @@ -612,7 +613,7 @@ ice_vsi_alloc_def(struct ice_vsi *vsi, struct ice_channel *ch) * * returns a pointer to a VSI on success, NULL on failure. */ -static struct ice_vsi *ice_vsi_alloc(struct ice_pf *pf) +struct ice_vsi *ice_vsi_alloc(struct ice_pf *pf) { struct device *dev = ice_pf_to_dev(pf); struct ice_vsi *vsi = NULL; diff --git a/drivers/net/ethernet/intel/ice/ice_lib.h b/drivers/net/ethernet/intel/ice/ice_lib.h index f9ee461c5c06..5de0cc50552c 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.h +++ b/drivers/net/ethernet/intel/ice/ice_lib.h @@ -66,6 +66,8 @@ void ice_dis_vsi(struct ice_vsi *vsi, bool locked); int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags); int ice_vsi_cfg(struct ice_vsi *vsi); +struct ice_vsi *ice_vsi_alloc(struct ice_pf *pf); +void ice_vsi_free(struct ice_vsi *vsi); bool ice_is_reset_in_progress(unsigned long *state); int ice_wait_for_reset(struct ice_pf *pf, unsigned long timeout); diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index ce1cf1b03321..7033981666a7 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -3965,6 +3965,9 @@ static void ice_deinit_pf(struct ice_pf *pf) if (pf->ptp.clock) ptp_clock_unregister(pf->ptp.clock); + + xa_destroy(&pf->dyn_ports); + xa_destroy(&pf->sf_nums); } /** @@ -4058,6 +4061,9 @@ static int ice_init_pf(struct ice_pf *pf) hash_init(pf->vfs.table); ice_mbx_init_snapshot(&pf->hw); + xa_init(&pf->dyn_ports); + xa_init(&pf->sf_nums); + return 0; } @@ -5383,6 +5389,7 @@ static void ice_remove(struct pci_dev *pdev) ice_remove_arfs(pf); devl_lock(priv_to_devlink(pf)); + ice_dealloc_all_dynamic_ports(pf); ice_deinit_devlink(pf); ice_unload(pf); @@ -6677,7 +6684,7 @@ static int ice_up_complete(struct ice_vsi *vsi) if (vsi->port_info && (vsi->port_info->phy.link_info.link_info & ICE_AQ_LINK_UP) && - vsi->netdev && vsi->type == ICE_VSI_PF) { + ((vsi->netdev && vsi->type == ICE_VSI_PF))) { ice_print_link_msg(vsi, true); netif_tx_start_all_queues(vsi->netdev); netif_carrier_on(vsi->netdev); From patchwork Tue May 7 11:45:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932432 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=RUWcUXBq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbtm5LnXz1xnS for ; Tue, 7 May 2024 21:40:32 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 806164071F; Tue, 7 May 2024 11:40:28 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id HnTw9YT0cLea; Tue, 7 May 2024 11:40:27 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C2EF740210 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082027; bh=9bnGNBSeTULXiTZfL1lyDBQr/rW0ys6eF4Iu94L9gKU=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=RUWcUXBqA7UNgo8bdzmwXHCip4t3F0IjvVtdollIayjrqRruOzfVYop6ECFWeu1B7 14x0/1TUoTW7VSioJ8rIHIb3w5AjuT0bVCW29SJDfscPWYdrd1Y6W3PctMKnDu/WJ9 dBiUskP5oXXhCMYEW+YRg2lmkjxyXWBGujxDMpdDfQCxClv3oZhJDdpr605JdlqARL 4HXTELwU2uHIIbXMA2ByKkXkLgsclbN3kLYFJrKdHOso1O8zeTPEquIdOgxUm4i82N WQfyqSfPhuZGIMsNf1BztKRLx78Ew5YnAWUQe9muQMog/0o2CuEs76DjVLNiou9BAQ HdvzoCCkQfl9w== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id C2EF740210; Tue, 7 May 2024 11:40:27 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 1335D1BF5A0 for ; Tue, 7 May 2024 11:40:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0078740223 for ; Tue, 7 May 2024 11:40:25 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ye56MDa35x-c for ; Tue, 7 May 2024 11:40:24 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 3EDA540154 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 3EDA540154 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id 3EDA540154 for ; Tue, 7 May 2024 11:40:24 +0000 (UTC) X-CSE-ConnectionGUID: vEMe9yB/TIyL5VcOqYxrxA== X-CSE-MsgGUID: Glq9ozMmRmiyVWAMqcHvNA== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029145" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029145" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:24 -0700 X-CSE-ConnectionGUID: XFUWXmy/RjaUWtbupfauJw== X-CSE-MsgGUID: au/JKmC8TJSJxtJAlWYLlQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576691" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:21 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:05 +0200 Message-ID: <20240507114516.9765-5-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082025; x=1746618025; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lO8+5IO5HfxSAncX4rBIRh4yy3is0kHO0is7we3eVuo=; b=NQt5VFU8Nwl/ynddIaT1Gr2k4IjpOtKnR1ww0Z3P+SkftVU9tlh+WRhC nL3wLjjXFw5JbVSeYNi/H3gYwGD4/Pmx7oexDAoca4EuxzNWlI6ch9UKv 4kVLlh0S1n7+8SqTd6FGhW1zBBzILOU+0JFu1F9yXLSxrdcmJZbP9BgH0 m6TZD70wW9e5zb68aKQIuzA5Hqq1bhjIo9azrayH08vmnd5NUWdGxVLpC KVPsb3nxrEapYgwR/THFLn6ZJUcjcDJNlidXQlJrUMPj07U8uUrChCjQo VOQGkTMWJ5bIevu3oML76GaE+6mMSvCp/P/zRO1wgpJWajFhhXvcEmFxW Q==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=NQt5VFU8 Subject: [Intel-wired-lan] [iwl-next v1 04/14] ice: treat subfunction VSI the same as PF VSI X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" When subfunction VSI is open the same code as for PF VSI should be executed. Also when up is complete. Reflect that in code by adding subfunction VSI to consideration. In case of stopping, PF doesn't have additional tasks, so the same is with subfunction VSI. Signed-off-by: Michal Swiatkowski --- drivers/net/ethernet/intel/ice/ice_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 7033981666a7..fdfdb27476e5 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -6684,7 +6684,8 @@ static int ice_up_complete(struct ice_vsi *vsi) if (vsi->port_info && (vsi->port_info->phy.link_info.link_info & ICE_AQ_LINK_UP) && - ((vsi->netdev && vsi->type == ICE_VSI_PF))) { + ((vsi->netdev && vsi->type == ICE_VSI_PF) || + (vsi->netdev && vsi->type == ICE_VSI_SF))) { ice_print_link_msg(vsi, true); netif_tx_start_all_queues(vsi->netdev); netif_carrier_on(vsi->netdev); @@ -7382,7 +7383,7 @@ int ice_vsi_open(struct ice_vsi *vsi) ice_vsi_cfg_netdev_tc(vsi, vsi->tc_cfg.ena_tc); - if (vsi->type == ICE_VSI_PF) { + if (vsi->type == ICE_VSI_PF || vsi->type == ICE_VSI_SF) { /* Notify the stack of the actual queue counts. */ err = netif_set_real_num_tx_queues(vsi->netdev, vsi->num_txq); if (err) From patchwork Tue May 7 11:45:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932433 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=p79XdOjh; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbtq381jz1xnS for ; Tue, 7 May 2024 21:40:35 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 64F46406F8; Tue, 7 May 2024 11:40:32 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id b1VtpYXwvyTz; Tue, 7 May 2024 11:40:30 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D9B07406C4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082029; bh=XPahqnAvoVpIF1shkRsskzeQ068vjdPy9nTTGVrD74o=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=p79XdOjhlSKYUbPd3yxhPKayM1tkcYdQlE15ZOS8yOprMty3LCvxQok1PRKSuRqnw AJKZ3EnWAjCudy8CZdAQPWK1gqgqT0K9VYNrZAAl6cj/PwBJ+XYDrUw7efOPpFdPqF a6U8ii8vqRmyoAwtmMTBydvPWFfmnkv5ow+WE5uzYugaYByotikV25TU46lwz6231O jzakHhzMmtsuOoxB2VbLoTX37answlwFxx0OHhv5wHI0BXvhCuWcVdRV5AijCU0YxG BQKMHxnKsGD3njeCCD4N+iWLMoRr4WiH4U5GXD4HZYqS0GoJPoG2F9ERC3kRetrihn 6cFaZ+3yATL9w== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id D9B07406C4; Tue, 7 May 2024 11:40:29 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 7C50E1BF5A0 for ; Tue, 7 May 2024 11:40:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 7659C40223 for ; Tue, 7 May 2024 11:40:28 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ViscEfI8ijKr for ; Tue, 7 May 2024 11:40:27 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 8F2E040154 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8F2E040154 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id 8F2E040154 for ; Tue, 7 May 2024 11:40:27 +0000 (UTC) X-CSE-ConnectionGUID: zOZEJNd6Qca6rZ2/IfvtPw== X-CSE-MsgGUID: euY0QrBXT7iJaQVdYAA7uw== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029155" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029155" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:28 -0700 X-CSE-ConnectionGUID: ETT2H8uaTvqPZNg9hVvhfQ== X-CSE-MsgGUID: zwFXQ/yQTPaA62t06IS+ZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576694" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:24 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:06 +0200 Message-ID: <20240507114516.9765-6-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082028; x=1746618028; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p7xbLuZCBblQGioAUsDrmvN/DI/qJSnEqL7wppc/oq4=; b=YCYuXPVkPiZbWW6JdaGdsTXmlC+9H5dhlqQ3ibq724Di8YKH4nYr2PQz nLacFt0CVbQY2cWGDp7FWirthsM2woAWSeCunoyy7q1DdsAloY9Np/sFf rjMX831FzHPRVnZ0NRvsQcSo2kuzIv8U2o5BmQninR+EmFA8wXQnioRWI ZeTA9xI6N4dC2vKxhd0DVRDj8by8cGrE2BrE0vXLGk8Sv0rWaT9Uz0bhk DWZJhWZ+qFG4Q88KiBWPY7dYS6e7VMumhraIjfIfonqWo99P8eGTpePI5 f/GupYJXJRXSqqMj/XSK+VGlgUMYx2sSW3Y3RUMI8M3CfQz3ZCsYnX/hd g==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YCYuXPVk Subject: [Intel-wired-lan] [iwl-next v1 05/14] ice: allocate devlink for subfunction X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Piotr Raczynski Make devlink allocation function generic to use it for PF and for SF. Add function for SF devlink port creation. It will be used in next patch. Create header file for subfunction device. Define subfunction device structure there as it is needed for devlink allocation and port creation. Signed-off-by: Piotr Raczynski Signed-off-by: Michal Swiatkowski --- .../net/ethernet/intel/ice/devlink/devlink.c | 33 ++++++++++++ .../net/ethernet/intel/ice/devlink/devlink.h | 1 + .../ethernet/intel/ice/devlink/devlink_port.c | 50 +++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 3 ++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 21 ++++++++ 5 files changed, 108 insertions(+) create mode 100644 drivers/net/ethernet/intel/ice/ice_sf_eth.h diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c index 3fb3a7e828a4..c1fe3726f6c0 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c @@ -10,6 +10,7 @@ #include "ice_eswitch.h" #include "ice_fw_update.h" #include "ice_dcb_lib.h" +#include "ice_sf_eth.h" /* context for devlink info version reporting */ struct ice_info_ctx { @@ -1282,6 +1283,8 @@ static const struct devlink_ops ice_devlink_ops = { .port_new = ice_devlink_port_new, }; +static const struct devlink_ops ice_sf_devlink_ops; + static int ice_devlink_enable_roce_get(struct devlink *devlink, u32 id, struct devlink_param_gset_ctx *ctx) @@ -1419,6 +1422,7 @@ static void ice_devlink_free(void *devlink_ptr) * Allocate a devlink instance for this device and return the private area as * the PF structure. The devlink memory is kept track of through devres by * adding an action to remove it when unwinding. + * */ struct ice_pf *ice_allocate_pf(struct device *dev) { @@ -1435,6 +1439,35 @@ struct ice_pf *ice_allocate_pf(struct device *dev) return devlink_priv(devlink); } +/** + * ice_allocate_sf - Allocate devlink and return SF structure pointer + * @dev: the device to allocate for + * @pf: pointer to the PF structure + * + * Allocate a devlink instance for SF. + * + * Return: void pointer to allocated memory + */ +struct ice_sf_priv *ice_allocate_sf(struct device *dev, struct ice_pf *pf) +{ + struct devlink *devlink; + int err; + + devlink = devlink_alloc_ns(&ice_sf_devlink_ops, + sizeof(struct ice_sf_priv), + devlink_net(priv_to_devlink(pf)), dev); + if (!devlink) + return NULL; + + err = devl_nested_devlink_set(priv_to_devlink(pf), devlink); + if (err) { + devlink_free(devlink); + return ERR_PTR(err); + } + + return devlink_priv(devlink); +} + /** * ice_devlink_register - Register devlink interface for this PF * @pf: the PF to register the devlink for. diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.h b/drivers/net/ethernet/intel/ice/devlink/devlink.h index d291c0e2e17b..1af3b0763fbb 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink.h +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.h @@ -5,6 +5,7 @@ #define _ICE_DEVLINK_H_ struct ice_pf *ice_allocate_pf(struct device *dev); +struct ice_sf_priv *ice_allocate_sf(struct device *dev, struct ice_pf *pf); void ice_devlink_register(struct ice_pf *pf); void ice_devlink_unregister(struct ice_pf *pf); diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c index 995c11f71b3f..eb552c1b1216 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c @@ -432,6 +432,56 @@ void ice_devlink_destroy_vf_port(struct ice_vf *vf) devl_port_unregister(&vf->devlink_port); } +/** + * ice_devlink_create_sf_dev_port - Register virtual port for a subfunction + * @sf_dev: the subfunction device to create a devlink port for + * + * Register virtual flavour devlink port for the subfunction auxiliary device + * created after activating a dynamically added devlink port. + * + * Return: zero on success or an error code on failure. + */ +int ice_devlink_create_sf_dev_port(struct ice_sf_dev *sf_dev) +{ + struct devlink_port_attrs attrs = {}; + struct devlink_port *devlink_port; + struct ice_dynamic_port *dyn_port; + struct devlink *devlink; + struct ice_vsi *vsi; + struct device *dev; + struct ice_pf *pf; + int err; + + dyn_port = sf_dev->dyn_port; + vsi = dyn_port->vsi; + pf = dyn_port->pf; + dev = ice_pf_to_dev(pf); + + devlink_port = &sf_dev->priv->devlink_port; + + attrs.flavour = DEVLINK_PORT_FLAVOUR_VIRTUAL; + + devlink_port_attrs_set(devlink_port, &attrs); + devlink = priv_to_devlink(sf_dev->priv); + + err = devl_port_register(devlink, devlink_port, vsi->idx); + if (err) + dev_err(dev, "Failed to create virtual devlink port for auxiliary subfunction device"); + + return err; +} + +/** + * ice_devlink_destroy_sf_dev_port - Destroy virtual port for a subfunction + * @sf_dev: the subfunction device to create a devlink port for + * + * Unregisters the virtual port associated with this subfunction. + */ +void ice_devlink_destroy_sf_dev_port(struct ice_sf_dev *sf_dev) +{ + devl_port_unregister(&sf_dev->priv->devlink_port); +} + /** * ice_dealloc_dynamic_port - Deallocate and remove a dynamic port * @dyn_port: dynamic port instance to deallocate diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h index f20d7cc522a6..e4acd855d9f9 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h +++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h @@ -5,6 +5,7 @@ #define _DEVLINK_PORT_H_ #include "../ice.h" +#include "../ice_sf_eth.h" /** * struct ice_dynamic_port - Track dynamically added devlink port instance @@ -33,6 +34,8 @@ int ice_devlink_create_vf_port(struct ice_vf *vf); void ice_devlink_destroy_vf_port(struct ice_vf *vf); int ice_devlink_create_sf_port(struct ice_dynamic_port *dyn_port); void ice_devlink_destroy_sf_port(struct ice_dynamic_port *dyn_port); +int ice_devlink_create_sf_dev_port(struct ice_sf_dev *sf_dev); +void ice_devlink_destroy_sf_dev_port(struct ice_sf_dev *sf_dev); #define ice_devlink_port_to_dyn(p) \ container_of(port, struct ice_dynamic_port, devlink_port) diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.h b/drivers/net/ethernet/intel/ice/ice_sf_eth.h new file mode 100644 index 000000000000..a08f8b2bceef --- /dev/null +++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2024, Intel Corporation. */ + +#ifndef _ICE_SF_ETH_H_ +#define _ICE_SF_ETH_H_ + +#include +#include "ice.h" + +struct ice_sf_dev { + struct auxiliary_device adev; + struct ice_dynamic_port *dyn_port; + struct ice_sf_priv *priv; +}; + +struct ice_sf_priv { + struct ice_sf_dev *dev; + struct devlink_port devlink_port; +}; + +#endif /* _ICE_SF_ETH_H_ */ From patchwork Tue May 7 11:45:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932434 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=BR8JSH5R; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbts41RMz1xnS for ; Tue, 7 May 2024 21:40:37 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 920174022B; Tue, 7 May 2024 11:40:34 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ZsBbqOlG4mGg; Tue, 7 May 2024 11:40:33 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 239D3406C4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082033; bh=oFR2LwMgfMD4jH3nUCwweb7yIaFDQ0lNc5QWQSuEuw4=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=BR8JSH5RFFyH5gyD6yBwVpY25hxB1IZM7zBAoy2HO262R5O6ShN2JHFV3/5wjedxL pWa/n1ezyR7iel9W7NXH9X8HrAdqagl80PMkbxPnd/i7IuPSBmhDw3LXcu7Q5nlrlJ lzpU5B4uoZJbNwIxJnkB+NR5unwfWOTs2/FpWZXO39/L+T+CEf2gQKtmQNAt4Kxa/n 84ZrXgT8VUuSeHBrKgkfNp49Lz6NmGMpo4bpBeo+9h2XN6XvlGKNDKc3wrg70dh/za OBpA39EKDHZZhiJJJEOMCBxtxPq1ZjGOjfdfWXXORrQX9MgW9FJ6yWGH7aGmhyyxl3 g/cNPxincltbg== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 239D3406C4; Tue, 7 May 2024 11:40:33 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id A97AD1BF5A0 for ; Tue, 7 May 2024 11:40:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 9637540223 for ; Tue, 7 May 2024 11:40:31 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id GMWQjjeVabAL for ; Tue, 7 May 2024 11:40:30 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 8EE1140154 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8EE1140154 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id 8EE1140154 for ; Tue, 7 May 2024 11:40:30 +0000 (UTC) X-CSE-ConnectionGUID: KeZ2XrgVT96AHya6Tdqe8Q== X-CSE-MsgGUID: RNWYkcY3STKINsm8Np1l3w== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029173" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029173" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:31 -0700 X-CSE-ConnectionGUID: 2o3MXOh/To2vEzI6IMFJiw== X-CSE-MsgGUID: 7+4rX4umRdq83EVbLP5drA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576697" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:27 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:07 +0200 Message-ID: <20240507114516.9765-7-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082031; x=1746618031; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9xe+epoimLSLuWVtaTh8fbFDCxUriWHe8tE+qVhX7K4=; b=MnwPbLVz6waTS/LRB58sdQm7FleJbqf/XV6sDtUSeZb0DGg6EGwyUu7D b9jUNQyagBbZCuhyciNyrpHuz9m2EY6Eq2JjLuy5yXIqOdGme28WiDJRI /Ezg9Pmxm4gbn1K3uJdxDfwqL30bg8jZHWTocI4v8ZVrnp5mz34WWIiCL wOfIPUnT/5MHccsa9jSrIIRhJ9F1zYreNgjaRmZCcqsh6rsluP7hBfqQy 7DqUdD0QiiMgGcRMZTcYQsB1TT2aPX2UsOS6/khTYSvjcTR5gsLKg2a2K rQK1J5jwF1wxNQyzkdABah+132kdeqBXgNRbVsbX53of7xLdjddHbxlHL Q==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=MnwPbLVz Subject: [Intel-wired-lan] [iwl-next v1 06/14] ice: base subfunction aux driver X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Piotr Raczynski Implement subfunction driver. It is probe when subfunction port is activated. VSI is already created. During the probe VSI is being configured. MAC unicast and broadcast filter is added to allow traffic to pass. Store subfunction pointer in VSI struct. The same is done for VF pointer. Make union of subfunction and VF pointer as only one of them can be set with one VSI. Reviewed-by: Jiri Pirko Signed-off-by: Piotr Raczynski Signed-off-by: Michal Swiatkowski --- drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice.h | 7 +- drivers/net/ethernet/intel/ice/ice_main.c | 10 ++ drivers/net/ethernet/intel/ice/ice_sf_eth.c | 139 ++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 9 ++ 5 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_sf_eth.c diff --git a/drivers/net/ethernet/intel/ice/Makefile b/drivers/net/ethernet/intel/ice/Makefile index 03500e28ac99..4d987f5dcdc1 100644 --- a/drivers/net/ethernet/intel/ice/Makefile +++ b/drivers/net/ethernet/intel/ice/Makefile @@ -31,6 +31,7 @@ ice-y := ice_main.o \ ice_idc.o \ devlink/devlink.o \ devlink/devlink_port.o \ + ice_sf_eth.o \ ice_ddp.o \ ice_fw_update.o \ ice_lag.o \ diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 8a30b786b334..e3c1313fe4ad 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -450,7 +450,12 @@ struct ice_vsi { struct_group_tagged(ice_vsi_cfg_params, params, struct ice_port_info *port_info; /* back pointer to port_info */ struct ice_channel *ch; /* VSI's channel structure, may be NULL */ - struct ice_vf *vf; /* VF associated with this VSI, may be NULL */ + union { + /* VF associated with this VSI, may be NULL */ + struct ice_vf *vf; + /* SF associated with this VSI, may be NULL */ + struct ice_dynamic_port *sf; + }; u32 flags; /* VSI flags used for rebuild and configuration */ enum ice_vsi_type type; /* the type of the VSI */ ); diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index fdfdb27476e5..60196aac7e75 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -15,6 +15,7 @@ #include "ice_dcb_nl.h" #include "devlink/devlink.h" #include "devlink/devlink_port.h" +#include "ice_sf_eth.h" #include "ice_hwmon.h" /* Including ice_trace.h with CREATE_TRACE_POINTS defined will generate the * ice tracepoint functions. This must be done exactly once across the @@ -5864,8 +5865,16 @@ static int __init ice_module_init(void) goto err_dest_lag_wq; } + status = ice_sf_driver_register(); + if (status) { + pr_err("Failed to register SF driver, err %d\n", status); + goto err_sf_driver; + } + return 0; +err_sf_driver: + pci_unregister_driver(&ice_driver); err_dest_lag_wq: destroy_workqueue(ice_lag_wq); ice_debugfs_exit(); @@ -5883,6 +5892,7 @@ module_init(ice_module_init); */ static void __exit ice_module_exit(void) { + ice_sf_driver_unregister(); pci_unregister_driver(&ice_driver); ice_debugfs_exit(); destroy_workqueue(ice_wq); diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.c b/drivers/net/ethernet/intel/ice/ice_sf_eth.c new file mode 100644 index 000000000000..abe495c2d033 --- /dev/null +++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.c @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2024, Intel Corporation. */ +#include "ice.h" +#include "ice_lib.h" +#include "ice_fltr.h" +#include "ice_sf_eth.h" +#include "devlink/devlink_port.h" +#include "devlink/devlink.h" + +/** + * ice_sf_dev_probe - subfunction driver probe function + * @adev: pointer to the auxiliary device + * @id: pointer to the auxiliary_device id + * + * Configure VSI and netdev resources for the subfunction device. + * + * Return: zero on success or an error code on failure. + */ +static int ice_sf_dev_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) +{ + struct ice_sf_dev *sf_dev = ice_adev_to_sf_dev(adev); + struct ice_dynamic_port *dyn_port = sf_dev->dyn_port; + struct ice_vsi *vsi = dyn_port->vsi; + struct ice_pf *pf = dyn_port->pf; + struct device *dev = &adev->dev; + struct ice_sf_priv *priv; + struct devlink *devlink; + int err; + + vsi->type = ICE_VSI_SF; + vsi->port_info = pf->hw.port_info; + vsi->flags = ICE_VSI_FLAG_INIT; + + priv = ice_allocate_sf(&adev->dev, pf); + if (!priv) { + dev_err(dev, "Subfunction devlink alloc failed"); + return -ENOMEM; + } + + priv->dev = sf_dev; + sf_dev->priv = priv; + devlink = priv_to_devlink(priv); + + devl_lock(devlink); + + err = ice_vsi_cfg(vsi); + if (err) { + dev_err(dev, "Subfunction vsi config failed"); + goto err_free_devlink; + } + vsi->sf = dyn_port; + + err = ice_devlink_create_sf_dev_port(sf_dev); + if (err) { + dev_err(dev, "Cannot add ice virtual devlink port for subfunction"); + goto err_vsi_decfg; + } + + err = devl_port_fn_devlink_set(&dyn_port->devlink_port, devlink); + if (err) { + dev_err(dev, "Can't link devlink instance to SF devlink port"); + goto err_devlink_destroy; + } + + ice_napi_add(vsi); + devl_unlock(devlink); + + devlink_register(devlink); + + return 0; + +err_devlink_destroy: + ice_devlink_destroy_sf_dev_port(sf_dev); +err_vsi_decfg: + ice_vsi_decfg(vsi); +err_free_devlink: + devl_unlock(devlink); + devlink_free(devlink); + return err; +} + +/** + * ice_sf_dev_remove - subfunction driver remove function + * @adev: pointer to the auxiliary device + * + * Deinitalize VSI and netdev resources for the subfunction device. + */ +static void ice_sf_dev_remove(struct auxiliary_device *adev) +{ + struct ice_sf_dev *sf_dev = ice_adev_to_sf_dev(adev); + struct ice_dynamic_port *dyn_port = sf_dev->dyn_port; + struct ice_vsi *vsi = dyn_port->vsi; + struct devlink *devlink; + + devlink = priv_to_devlink(sf_dev->priv); + devl_lock(devlink); + + ice_vsi_close(vsi); + + ice_devlink_destroy_sf_dev_port(sf_dev); + devl_unregister(devlink); + devl_unlock(devlink); + devlink_free(devlink); + ice_vsi_decfg(vsi); +} + +static const struct auxiliary_device_id ice_sf_dev_id_table[] = { + { .name = "ice.sf", }, + { }, +}; + +MODULE_DEVICE_TABLE(auxiliary, ice_sf_dev_id_table); + +static struct auxiliary_driver ice_sf_driver = { + .name = "sf", + .probe = ice_sf_dev_probe, + .remove = ice_sf_dev_remove, + .id_table = ice_sf_dev_id_table +}; + +/** + * ice_sf_driver_register - Register new auxiliary subfunction driver + * + * Return: zero on success or an error code on failure. + */ +int ice_sf_driver_register(void) +{ + return auxiliary_driver_register(&ice_sf_driver); +} + +/** + * ice_sf_driver_unregister - Unregister new auxiliary subfunction driver + * + */ +void ice_sf_driver_unregister(void) +{ + auxiliary_driver_unregister(&ice_sf_driver); +} diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.h b/drivers/net/ethernet/intel/ice/ice_sf_eth.h index a08f8b2bceef..e972c50f96c9 100644 --- a/drivers/net/ethernet/intel/ice/ice_sf_eth.h +++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.h @@ -18,4 +18,13 @@ struct ice_sf_priv { struct devlink_port devlink_port; }; +static inline struct +ice_sf_dev *ice_adev_to_sf_dev(struct auxiliary_device *adev) +{ + return container_of(adev, struct ice_sf_dev, adev); +} + +int ice_sf_driver_register(void); +void ice_sf_driver_unregister(void); + #endif /* _ICE_SF_ETH_H_ */ From patchwork Tue May 7 11:45:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932435 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=Uhg0hWwo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbty0rlJz1xnS for ; Tue, 7 May 2024 21:40:42 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 8FEB940666; Tue, 7 May 2024 11:40:40 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id hw9LMxl-dmeu; Tue, 7 May 2024 11:40:37 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org DA05F4065A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082036; bh=q/34pFmgUrGVRB5gFysO5jlu2DLko03PZ36/MB8HqXs=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Uhg0hWwoazO8XYzBKhnYnMGeje0Kc7CZhfro2nOlRwv3OaZFOwZ24hofpJKtHoSbr nkDFqXTc23FDGD7Bv6hVAEMFE75bn9tLP1HIXE9ljbwULD1KdlXmTASosd3tLgCgRQ IYQjQYjZpnpCGIZK27/7NGzYxoZuvYFYLJllUu2Lwu6BRyphCGB2HfO9E5fdm/CMz3 djt5mf8gI0khVdKvhDqzBJhDn8Rw57bnMDvXLZASnSik99kbNV3dDQ4nxkRxrkkGXZ t+upF4ameK2l5cvz6QujEegakiJ8bY7dKRiW2cNZOM7Xv0ZL+HQPmJgT8eGteKYs1K d3TdarsR4B7vQ== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id DA05F4065A; Tue, 7 May 2024 11:40:36 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 882461BF5A0 for ; Tue, 7 May 2024 11:40:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 757ED40223 for ; Tue, 7 May 2024 11:40:34 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id pTbkRN21jJf9 for ; Tue, 7 May 2024 11:40:33 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 8BB1940154 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8BB1940154 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id 8BB1940154 for ; Tue, 7 May 2024 11:40:33 +0000 (UTC) X-CSE-ConnectionGUID: +eBhhvciTWK9NneqML6++w== X-CSE-MsgGUID: pVDao3rwSOCSE/ApY12hQA== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029205" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029205" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:34 -0700 X-CSE-ConnectionGUID: rpIlg5HnSA+6EWqZ4NRuVQ== X-CSE-MsgGUID: 1m7Smn6USXm8BFLOneG5HA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576701" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:30 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:08 +0200 Message-ID: <20240507114516.9765-8-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082034; x=1746618034; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wTiie1WC0v0OwejiEl33D0ZP6bZoFdlvg+u6AavqK7A=; b=TQYZh5rdnIcI3KmWFsjhj9B3+V/ANLjCmxd5BjSd5znMQjmifd+zyq70 gAwsvfFY7fFT9UiFw7NGcqtnsGPzQBFbBP/RwPdw9PH0YycWDYeFD04z2 FF57N/qWRYnAU63pWKL4Pysjk32ysN5UTiQKs5BWzcdizje1IJJJ5YdgP 48olI+a8kz5za6Xbx9BJZ2EsuvJnmkNFOgM3TfsN4lXWPeFMHv7E4jZKe PhFKkHE83MHNdmzeXJdyQp3rKqGftjF7IEK22WCqHyR6hvrhcANyxN+qT CVJGxINMvMAXY0XqJs9XQnuYKDGURNFN5h/0nSr1jZcFI+IXZThgyo5bl A==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=TQYZh5rd Subject: [Intel-wired-lan] [iwl-next v1 07/14] ice: implement netdev for subfunction X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Piotr Raczynski Configure netdevice for subfunction usecase. Mostly it is reusing ops from the PF netdevice. SF netdev is linked to devlink port registered after SF activation. Reviewed-by: Jiri Pirko Signed-off-by: Piotr Raczynski Signed-off-by: Michal Swiatkowski --- drivers/net/ethernet/intel/ice/ice_sf_eth.c | 85 ++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.c b/drivers/net/ethernet/intel/ice/ice_sf_eth.c index abe495c2d033..3a540a2638d1 100644 --- a/drivers/net/ethernet/intel/ice/ice_sf_eth.c +++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.c @@ -2,11 +2,85 @@ /* Copyright (c) 2024, Intel Corporation. */ #include "ice.h" #include "ice_lib.h" +#include "ice_txrx.h" #include "ice_fltr.h" #include "ice_sf_eth.h" #include "devlink/devlink_port.h" #include "devlink/devlink.h" +static const struct net_device_ops ice_sf_netdev_ops = { + .ndo_open = ice_open, + .ndo_stop = ice_stop, + .ndo_start_xmit = ice_start_xmit, + .ndo_vlan_rx_add_vid = ice_vlan_rx_add_vid, + .ndo_vlan_rx_kill_vid = ice_vlan_rx_kill_vid, + .ndo_change_mtu = ice_change_mtu, + .ndo_get_stats64 = ice_get_stats64, + .ndo_tx_timeout = ice_tx_timeout, + .ndo_bpf = ice_xdp, + .ndo_xdp_xmit = ice_xdp_xmit, + .ndo_xsk_wakeup = ice_xsk_wakeup, +}; + +/** + * ice_sf_cfg_netdev - Allocate, configure and register a netdev + * @dyn_port: subfunction associated with configured netdev + * @devlink_port: subfunction devlink port to be linked with netdev + * + * Return: 0 on success, negative value on failure + */ +static int ice_sf_cfg_netdev(struct ice_dynamic_port *dyn_port, + struct devlink_port *devlink_port) +{ + struct ice_vsi *vsi = dyn_port->vsi; + struct ice_netdev_priv *np; + struct net_device *netdev; + int err; + + netdev = alloc_etherdev_mqs(sizeof(*np), vsi->alloc_txq, + vsi->alloc_rxq); + if (!netdev) + return -ENOMEM; + + SET_NETDEV_DEV(netdev, &vsi->back->pdev->dev); + set_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state); + vsi->netdev = netdev; + np = netdev_priv(netdev); + np->vsi = vsi; + + ice_set_netdev_features(netdev); + + netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | + NETDEV_XDP_ACT_XSK_ZEROCOPY | + NETDEV_XDP_ACT_RX_SG; + + eth_hw_addr_set(netdev, dyn_port->hw_addr); + ether_addr_copy(netdev->perm_addr, dyn_port->hw_addr); + netdev->netdev_ops = &ice_sf_netdev_ops; + SET_NETDEV_DEVLINK_PORT(netdev, devlink_port); + + err = register_netdev(netdev); + if (err) { + free_netdev(netdev); + vsi->netdev = NULL; + return -ENOMEM; + } + set_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state); + netif_carrier_off(netdev); + netif_tx_stop_all_queues(netdev); + + return 0; +} + +static void ice_sf_decfg_netdev(struct ice_vsi *vsi) +{ + unregister_netdev(vsi->netdev); + clear_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state); + free_netdev(vsi->netdev); + vsi->netdev = NULL; + clear_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state); +} + /** * ice_sf_dev_probe - subfunction driver probe function * @adev: pointer to the auxiliary device @@ -57,10 +131,16 @@ static int ice_sf_dev_probe(struct auxiliary_device *adev, goto err_vsi_decfg; } + err = ice_sf_cfg_netdev(dyn_port, &sf_dev->priv->devlink_port); + if (err) { + dev_err(dev, "Subfunction netdev config failed"); + goto err_devlink_destroy; + } + err = devl_port_fn_devlink_set(&dyn_port->devlink_port, devlink); if (err) { dev_err(dev, "Can't link devlink instance to SF devlink port"); - goto err_devlink_destroy; + goto err_netdev_decfg; } ice_napi_add(vsi); @@ -70,6 +150,8 @@ static int ice_sf_dev_probe(struct auxiliary_device *adev, return 0; +err_netdev_decfg: + ice_sf_decfg_netdev(vsi); err_devlink_destroy: ice_devlink_destroy_sf_dev_port(sf_dev); err_vsi_decfg: @@ -98,6 +180,7 @@ static void ice_sf_dev_remove(struct auxiliary_device *adev) ice_vsi_close(vsi); + ice_sf_decfg_netdev(vsi); ice_devlink_destroy_sf_dev_port(sf_dev); devl_unregister(devlink); devl_unlock(devlink); From patchwork Tue May 7 11:45:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932436 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=61lDzXKW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbv04B0Nz1xnS for ; Tue, 7 May 2024 21:40:44 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 0F95640780; Tue, 7 May 2024 11:40:42 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Sg7PPmXehboN; Tue, 7 May 2024 11:40:39 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 7F19340776 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082039; bh=pusthctWogBUtpBGAVfseXK9O2qlldqChZqGeyuSf7Y=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=61lDzXKWXqNwA8xEJPg74BZ+uIyrWrGra/uKPm+W82pVfzTdlEZj6psR0IbuRmZ6D V7gclyLwHXKkmOLxbiWtcgTD1N4cFnHwzYYSs0X2VmQ9AT3jB9nwakJYYcvKQjAJtA XG6+BKEGJh13ULEapiaDLZsvfq1XPssR6GCzo6SatlHF9btsXlXk0Y4E+TLbvjbyuB PVn9u+iUDf66UxkLkkqyuPwhB93yMhiuybKRBn39y2m6Vqne0QTkIIUje+o5jJVBnA 9bGHJuRDcYV9i9XxpmKfFcK5LkNfSaBRJ8aaGz1bb3+qX194LlMnzKXjPduaf1+uPI 4tCaDGN9td0Sg== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 7F19340776; Tue, 7 May 2024 11:40:39 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 01A9C1BF5A0 for ; Tue, 7 May 2024 11:40:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id EF4BE40223 for ; Tue, 7 May 2024 11:40:37 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 0NjpIShfs-ZE for ; Tue, 7 May 2024 11:40:36 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 9BC9340154 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9BC9340154 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id 9BC9340154 for ; Tue, 7 May 2024 11:40:36 +0000 (UTC) X-CSE-ConnectionGUID: x3vHj/MMSAeNPdDiiYmjQQ== X-CSE-MsgGUID: vZNm5Xr6S+WzCE4yjwa3Gg== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029230" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029230" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:37 -0700 X-CSE-ConnectionGUID: oKPLtcyaR4K86HTrvb6hdw== X-CSE-MsgGUID: 1UGKtIGrRVSGp+W9AaBmMw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576704" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:33 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:09 +0200 Message-ID: <20240507114516.9765-9-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082037; x=1746618037; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l7W5eFQF9t2T9BSrPimHeU00OtSeC7QwPLpWgvvnSgM=; b=n5surj3/lAzTLk/BwHJxmkG7rV2G1EzsWspwO9ZilncTC37+sQaYITG7 hGTxtd1z4wrW215rH1Ta5hxmX6TffKD0MwnYWK0/ioqoZnzrC1FCGsZBE fI0XxTKOm/i6hfIQmXwWarIbYtmprHmezcaEm9TAf4osNTZ+NKM3hamud geAdVqRcvewP2NvPlAA5u61wwt00yXVMDBqseaQgZm+pu/qkwYptpeFdL 9pRa0e0mSzAQoNo+a2C34Gmg2y3FMK8odvWW7E8I+y1vvvxTv5jPCI9E0 Lf5pfJXvjV6K++n/7RmrZ8smtlInL3D8amcbj1QMMStvKYJsvh2XeHIpS A==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=n5surj3/ Subject: [Intel-wired-lan] [iwl-next v1 08/14] ice: create port representor for SF X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Store subfunction and VF pointer in port representor structure as an union. Add port representor type to distinguish between each of them. Keep the same flow of port representor creation, but instead of general attach function create helpers for VF and subfunction attach function. Type of port representor can be also known based on VSI type, but it is more clean to have it directly saved in port representor structure. Create port representor when subfunction port is created. Add devlink lock for whole VF port representor creation and destruction. It is done to be symmetric with what happens in case of SF port representor. SF port representor is always added or removed with devlink lock taken. Doing the same with VF port representor simplify logic. Reviewed-by: Wojciech Drewek Signed-off-by: Michal Swiatkowski --- .../ethernet/intel/ice/devlink/devlink_port.c | 6 +- .../ethernet/intel/ice/devlink/devlink_port.h | 1 + drivers/net/ethernet/intel/ice/ice_eswitch.c | 85 +++++++++--- drivers/net/ethernet/intel/ice/ice_eswitch.h | 22 +++- drivers/net/ethernet/intel/ice/ice_repr.c | 124 +++++++++++------- drivers/net/ethernet/intel/ice/ice_repr.h | 21 ++- drivers/net/ethernet/intel/ice/ice_sriov.c | 4 +- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 +- 8 files changed, 187 insertions(+), 80 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c index eb552c1b1216..3d887e7ee78c 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c @@ -495,7 +495,7 @@ static void ice_dealloc_dynamic_port(struct ice_dynamic_port *dyn_port) struct ice_pf *pf = dyn_port->pf; xa_erase(&pf->sf_nums, devlink_port->attrs.pci_sf.sf); - devl_port_unregister(devlink_port); + ice_eswitch_detach_sf(pf, dyn_port); ice_vsi_free(dyn_port->vsi); xa_erase(&pf->dyn_ports, dyn_port->vsi->idx); kfree(dyn_port); @@ -786,9 +786,9 @@ ice_alloc_dynamic_port(struct ice_pf *pf, goto unroll_vsi_alloc; } - err = ice_devlink_create_sf_port(dyn_port); + err = ice_eswitch_attach_sf(pf, dyn_port); if (err) { - NL_SET_ERR_MSG_MOD(extack, "Port registration failed"); + NL_SET_ERR_MSG_MOD(extack, "Failed to attach SF to eswitch"); goto unroll_xa_insert; } diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h index e4acd855d9f9..6e14b9e4d621 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h +++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h @@ -23,6 +23,7 @@ struct ice_dynamic_port { struct devlink_port devlink_port; struct ice_pf *pf; struct ice_vsi *vsi; + unsigned long repr_id; u32 sfnum; }; diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c index 4f539b1c7781..4aca6620746b 100644 --- a/drivers/net/ethernet/intel/ice/ice_eswitch.c +++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c @@ -452,11 +452,9 @@ static void ice_eswitch_start_reprs(struct ice_pf *pf) ice_eswitch_start_all_tx_queues(pf); } -int -ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf) +static int +ice_eswitch_attach(struct ice_pf *pf, struct ice_repr *repr, unsigned long *id) { - struct devlink *devlink = priv_to_devlink(pf); - struct ice_repr *repr; int err; if (pf->eswitch_mode == DEVLINK_ESWITCH_MODE_LEGACY) @@ -470,13 +468,9 @@ ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf) ice_eswitch_stop_reprs(pf); - devl_lock(devlink); - repr = ice_repr_add_vf(vf); - devl_unlock(devlink); - if (IS_ERR(repr)) { - err = PTR_ERR(repr); + err = repr->ops.add(repr); + if (err) goto err_create_repr; - } err = ice_eswitch_setup_repr(pf, repr); if (err) @@ -486,7 +480,7 @@ ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf) if (err) goto err_xa_alloc; - vf->repr_id = repr->id; + *id = repr->id; ice_eswitch_start_reprs(pf); @@ -495,9 +489,7 @@ ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf) err_xa_alloc: ice_eswitch_release_repr(pf, repr); err_setup_repr: - devl_lock(devlink); - ice_repr_rem_vf(repr); - devl_unlock(devlink); + repr->ops.rem(repr); err_create_repr: if (xa_empty(&pf->eswitch.reprs)) ice_eswitch_disable_switchdev(pf); @@ -506,14 +498,41 @@ ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf) return err; } -void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf) +int ice_eswitch_attach_vf(struct ice_pf *pf, struct ice_vf *vf) { - struct ice_repr *repr = xa_load(&pf->eswitch.reprs, vf->repr_id); + struct ice_repr *repr = ice_repr_create_vf(vf); struct devlink *devlink = priv_to_devlink(pf); + int err; - if (!repr) - return; + if (IS_ERR(repr)) + return PTR_ERR(repr); + devl_lock(devlink); + err = ice_eswitch_attach(pf, repr, &vf->repr_id); + if (err) + ice_repr_destroy(repr); + devl_unlock(devlink); + + return err; +} + +int ice_eswitch_attach_sf(struct ice_pf *pf, struct ice_dynamic_port *sf) +{ + struct ice_repr *repr = ice_repr_create_sf(sf); + int err; + + if (IS_ERR(repr)) + return PTR_ERR(repr); + + err = ice_eswitch_attach(pf, repr, &sf->repr_id); + if (err) + ice_repr_destroy(repr); + + return err; +} + +static void ice_eswitch_detach(struct ice_pf *pf, struct ice_repr *repr) +{ ice_eswitch_stop_reprs(pf); xa_erase(&pf->eswitch.reprs, repr->id); @@ -521,10 +540,12 @@ void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf) ice_eswitch_disable_switchdev(pf); ice_eswitch_release_repr(pf, repr); - devl_lock(devlink); - ice_repr_rem_vf(repr); + repr->ops.rem(repr); + ice_repr_destroy(repr); if (xa_empty(&pf->eswitch.reprs)) { + struct devlink *devlink = priv_to_devlink(pf); + /* since all port representors are destroyed, there is * no point in keeping the nodes */ @@ -533,9 +554,31 @@ void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf) } else { ice_eswitch_start_reprs(pf); } +} + +void ice_eswitch_detach_vf(struct ice_pf *pf, struct ice_vf *vf) +{ + struct ice_repr *repr = xa_load(&pf->eswitch.reprs, vf->repr_id); + struct devlink *devlink = priv_to_devlink(pf); + + if (!repr) + return; + + devl_lock(devlink); + ice_eswitch_detach(pf, repr); devl_unlock(devlink); } +void ice_eswitch_detach_sf(struct ice_pf *pf, struct ice_dynamic_port *sf) +{ + struct ice_repr *repr = xa_load(&pf->eswitch.reprs, sf->repr_id); + + if (!repr) + return; + + ice_eswitch_detach(pf, repr); +} + /** * ice_eswitch_rebuild - rebuild eswitch * @pf: pointer to PF structure @@ -549,7 +592,7 @@ void ice_eswitch_rebuild(struct ice_pf *pf) return; xa_for_each(&pf->eswitch.reprs, id, repr) - ice_eswitch_detach(pf, repr->vf); + ice_eswitch_detach(pf, repr); } /** diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.h b/drivers/net/ethernet/intel/ice/ice_eswitch.h index 09194d514f9b..20f301093b36 100644 --- a/drivers/net/ethernet/intel/ice/ice_eswitch.h +++ b/drivers/net/ethernet/intel/ice/ice_eswitch.h @@ -5,11 +5,13 @@ #define _ICE_ESWITCH_H_ #include +#include "devlink/devlink_port.h" #ifdef CONFIG_ICE_SWITCHDEV -void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf); -int -ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf); +void ice_eswitch_detach_vf(struct ice_pf *pf, struct ice_vf *vf); +void ice_eswitch_detach_sf(struct ice_pf *pf, struct ice_dynamic_port *sf); +int ice_eswitch_attach_vf(struct ice_pf *pf, struct ice_vf *vf); +int ice_eswitch_attach_sf(struct ice_pf *pf, struct ice_dynamic_port *sf); void ice_eswitch_rebuild(struct ice_pf *pf); int ice_eswitch_mode_get(struct devlink *devlink, u16 *mode); @@ -32,10 +34,20 @@ struct net_device *ice_eswitch_get_target(struct ice_rx_ring *rx_ring, int ice_eswitch_cfg_vsi(struct ice_vsi *vsi, const u8 *mac); void ice_eswitch_decfg_vsi(struct ice_vsi *vsi, const u8 *mac); #else /* CONFIG_ICE_SWITCHDEV */ -static inline void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf) { } +static inline void +ice_eswitch_detach_vf(struct ice_pf *pf, struct ice_vf *vf) { } + +static inline void +ice_eswitch_detach_sf(struct ice_pf *pf, struct ice_dynamic_port *sf) { } + +static inline int +ice_eswitch_attach_vf(struct ice_pf *pf, struct ice_vf *vf) +{ + return -EOPNOTSUPP; +} static inline int -ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf) +ice_eswitch_attach_sf(struct ice_pf *pf, struct ice_dynamic_port *sf) { return -EOPNOTSUPP; } diff --git a/drivers/net/ethernet/intel/ice/ice_repr.c b/drivers/net/ethernet/intel/ice/ice_repr.c index bdda3401e343..03e6ca3eeedf 100644 --- a/drivers/net/ethernet/intel/ice/ice_repr.c +++ b/drivers/net/ethernet/intel/ice/ice_repr.c @@ -283,34 +283,29 @@ ice_repr_reg_netdev(struct net_device *netdev) return register_netdev(netdev); } -static void ice_repr_remove_node(struct devlink_port *devlink_port) -{ - devl_rate_leaf_destroy(devlink_port); -} - /** - * ice_repr_rem - remove representor from VF + * ice_repr_destroy - remove representor from VF * @repr: pointer to representor structure */ -static void ice_repr_rem(struct ice_repr *repr) +void ice_repr_destroy(struct ice_repr *repr) { free_percpu(repr->stats); free_netdev(repr->netdev); kfree(repr); } -/** - * ice_repr_rem_vf - remove representor from VF - * @repr: pointer to representor structure - */ -void ice_repr_rem_vf(struct ice_repr *repr) +static void ice_repr_rem_vf(struct ice_repr *repr) { - ice_repr_remove_node(&repr->vf->devlink_port); ice_eswitch_decfg_vsi(repr->src_vsi, repr->parent_mac); unregister_netdev(repr->netdev); ice_devlink_destroy_vf_port(repr->vf); ice_virtchnl_set_dflt_ops(repr->vf); - ice_repr_rem(repr); +} + +static void ice_repr_rem_sf(struct ice_repr *repr) +{ + unregister_netdev(repr->netdev); + ice_devlink_destroy_sf_port(repr->sf); } static void ice_repr_set_tx_topology(struct ice_pf *pf) @@ -327,13 +322,10 @@ static void ice_repr_set_tx_topology(struct ice_pf *pf) } /** - * ice_repr_add - add representor for generic VSI - * @pf: pointer to PF structure + * ice_repr_create - add representor for generic VSI * @src_vsi: pointer to VSI structure of device to represent - * @parent_mac: device MAC address */ -static struct ice_repr * -ice_repr_add(struct ice_pf *pf, struct ice_vsi *src_vsi, const u8 *parent_mac) +static struct ice_repr *ice_repr_create(struct ice_vsi *src_vsi) { struct ice_netdev_priv *np; struct ice_repr *repr; @@ -360,7 +352,10 @@ ice_repr_add(struct ice_pf *pf, struct ice_vsi *src_vsi, const u8 *parent_mac) np = netdev_priv(repr->netdev); np->repr = repr; - ether_addr_copy(repr->parent_mac, parent_mac); + repr->netdev->min_mtu = ETH_MIN_MTU; + repr->netdev->max_mtu = ICE_MAX_MTU; + + SET_NETDEV_DEV(repr->netdev, ice_pf_to_dev(src_vsi->back)); return repr; @@ -371,32 +366,15 @@ ice_repr_add(struct ice_pf *pf, struct ice_vsi *src_vsi, const u8 *parent_mac) return ERR_PTR(err); } -struct ice_repr *ice_repr_add_vf(struct ice_vf *vf) +static int ice_repr_add_vf(struct ice_repr *repr) { - struct ice_repr *repr; - struct ice_vsi *vsi; + struct ice_vf *vf = repr->vf; int err; - vsi = ice_get_vf_vsi(vf); - if (!vsi) - return ERR_PTR(-ENOENT); - err = ice_devlink_create_vf_port(vf); if (err) - return ERR_PTR(err); + return err; - repr = ice_repr_add(vf->pf, vsi, vf->hw_lan_addr); - if (IS_ERR(repr)) { - err = PTR_ERR(repr); - goto err_repr_add; - } - - repr->vf = vf; - - repr->netdev->min_mtu = ETH_MIN_MTU; - repr->netdev->max_mtu = ICE_MAX_MTU; - - SET_NETDEV_DEV(repr->netdev, ice_pf_to_dev(vf->pf)); SET_NETDEV_DEVLINK_PORT(repr->netdev, &vf->devlink_port); err = ice_repr_reg_netdev(repr->netdev); if (err) @@ -409,15 +387,73 @@ struct ice_repr *ice_repr_add_vf(struct ice_vf *vf) ice_virtchnl_set_repr_ops(vf); ice_repr_set_tx_topology(vf->pf); - return repr; + return 0; err_cfg_vsi: unregister_netdev(repr->netdev); err_netdev: - ice_repr_rem(repr); -err_repr_add: ice_devlink_destroy_vf_port(vf); - return ERR_PTR(err); + return err; +} + +struct ice_repr *ice_repr_create_vf(struct ice_vf *vf) +{ + struct ice_vsi *vsi = ice_get_vf_vsi(vf); + struct ice_repr *repr; + + if (!vsi) + return ERR_PTR(-EINVAL); + + repr = ice_repr_create(vsi); + if (!repr) + return ERR_PTR(-ENOMEM); + + repr->type = ICE_REPR_TYPE_VF; + repr->vf = vf; + repr->ops.add = ice_repr_add_vf; + repr->ops.rem = ice_repr_rem_vf; + + ether_addr_copy(repr->parent_mac, vf->hw_lan_addr); + + return repr; +} + +static int ice_repr_add_sf(struct ice_repr *repr) +{ + struct ice_dynamic_port *sf = repr->sf; + int err; + + err = ice_devlink_create_sf_port(sf); + if (err) + return err; + + SET_NETDEV_DEVLINK_PORT(repr->netdev, &sf->devlink_port); + err = ice_repr_reg_netdev(repr->netdev); + if (err) + goto err_netdev; + + return 0; + +err_netdev: + ice_devlink_destroy_sf_port(sf); + return err; +} + +struct ice_repr *ice_repr_create_sf(struct ice_dynamic_port *sf) +{ + struct ice_repr *repr = ice_repr_create(sf->vsi); + + if (!repr) + return ERR_PTR(-ENOMEM); + + repr->type = ICE_REPR_TYPE_SF; + repr->sf = sf; + repr->ops.add = ice_repr_add_sf; + repr->ops.rem = ice_repr_rem_sf; + + ether_addr_copy(repr->parent_mac, sf->hw_addr); + + return repr; } struct ice_repr *ice_repr_get(struct ice_pf *pf, u32 id) diff --git a/drivers/net/ethernet/intel/ice/ice_repr.h b/drivers/net/ethernet/intel/ice/ice_repr.h index 07842620d7a2..dcba07899877 100644 --- a/drivers/net/ethernet/intel/ice/ice_repr.h +++ b/drivers/net/ethernet/intel/ice/ice_repr.h @@ -15,19 +15,34 @@ struct ice_repr_pcpu_stats { u64 tx_drops; }; +enum ice_repr_type { + ICE_REPR_TYPE_VF, + ICE_REPR_TYPE_SF, +}; + struct ice_repr { struct ice_vsi *src_vsi; - struct ice_vf *vf; struct net_device *netdev; struct metadata_dst *dst; struct ice_esw_br_port *br_port; struct ice_repr_pcpu_stats __percpu *stats; u32 id; u8 parent_mac[ETH_ALEN]; + enum ice_repr_type type; + union { + struct ice_vf *vf; + struct ice_dynamic_port *sf; + }; + struct { + int (*add)(struct ice_repr *repr); + void (*rem)(struct ice_repr *repr); + } ops; }; -struct ice_repr *ice_repr_add_vf(struct ice_vf *vf); -void ice_repr_rem_vf(struct ice_repr *repr); +struct ice_repr *ice_repr_create_vf(struct ice_vf *vf); +struct ice_repr *ice_repr_create_sf(struct ice_dynamic_port *sf); + +void ice_repr_destroy(struct ice_repr *repr); void ice_repr_start_tx_queues(struct ice_repr *repr); void ice_repr_stop_tx_queues(struct ice_repr *repr); diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c index 067712f4923f..f0e4c955be34 100644 --- a/drivers/net/ethernet/intel/ice/ice_sriov.c +++ b/drivers/net/ethernet/intel/ice/ice_sriov.c @@ -175,7 +175,7 @@ void ice_free_vfs(struct ice_pf *pf) ice_for_each_vf(pf, bkt, vf) { mutex_lock(&vf->cfg_lock); - ice_eswitch_detach(pf, vf); + ice_eswitch_detach_vf(pf, vf); ice_dis_vf_qs(vf); if (test_bit(ICE_VF_STATE_INIT, vf->vf_states)) { @@ -598,7 +598,7 @@ static int ice_start_vfs(struct ice_pf *pf) goto teardown; } - retval = ice_eswitch_attach(pf, vf); + retval = ice_eswitch_attach_vf(pf, vf); if (retval) { dev_err(ice_pf_to_dev(pf), "Failed to attach VF %d to eswitch, error %d", vf->vf_id, retval); diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c index 5635e9da2212..a69e91f88d81 100644 --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c @@ -766,7 +766,7 @@ void ice_reset_all_vfs(struct ice_pf *pf) ice_for_each_vf(pf, bkt, vf) { mutex_lock(&vf->cfg_lock); - ice_eswitch_detach(pf, vf); + ice_eswitch_detach_vf(pf, vf); vf->driver_caps = 0; ice_vc_set_default_allowlist(vf); @@ -782,7 +782,7 @@ void ice_reset_all_vfs(struct ice_pf *pf) ice_vf_rebuild_vsi(vf); ice_vf_post_vsi_rebuild(vf); - ice_eswitch_attach(pf, vf); + ice_eswitch_attach_vf(pf, vf); mutex_unlock(&vf->cfg_lock); } From patchwork Tue May 7 11:45:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932437 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=4lw3NFYp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbv34Bbhz1xnS for ; Tue, 7 May 2024 21:40:47 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id CACA7404D5; Tue, 7 May 2024 11:40:42 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 4CFNdrTsvOwC; Tue, 7 May 2024 11:40:41 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 73B0E4075A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082041; bh=DOVz5G+TnCjOJtQYEzd3pzQ88bNxzPikkZ02OclgpWo=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=4lw3NFYpZD1b9U2NbYw21sX7t1HnPlhf3UoQYz70FkE16UaqPyVepMKrMkQxTfyBd clNekB14gGvGeyt1ya/AjRf/D+RBT0YA5YCcpbX14miJ0xPgVex7Cd1wG3+dzrPIGI NCk5bHUjZBhOAtbe8eEZILeFrG9S7M/FCRIY8CKsrIkNcefvDw0cJZXFoxFcu26DSJ kERFBOiXJS+E9g0bSS4xpWvxPr4BnW+R1RPtKlbrL/mAcg1s3APlPwOsM9tY+SfJI0 ypWCpD5q66+tQr3w4wdZ4wzk2h05ILzPiwpTv0/N9Pqh52NO24qG1uNAGlRfL1D5H0 s/y5NXsUzCy4w== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 73B0E4075A; Tue, 7 May 2024 11:40:41 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 3E1E51BF5A0 for ; Tue, 7 May 2024 11:40:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3860E40223 for ; Tue, 7 May 2024 11:40:40 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id H-CcZMkN5MQI for ; Tue, 7 May 2024 11:40:39 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 5880F40154 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5880F40154 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5880F40154 for ; Tue, 7 May 2024 11:40:39 +0000 (UTC) X-CSE-ConnectionGUID: IqrRHXBsSzyAFaZ7Dvg4jg== X-CSE-MsgGUID: X2//1VRmSL2b/NUbQkSWnQ== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029258" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029258" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:40 -0700 X-CSE-ConnectionGUID: JlShoNYRQECW6H+9ptThQQ== X-CSE-MsgGUID: C1c1cCk5SmWbinrikK7lIg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576708" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:36 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:10 +0200 Message-ID: <20240507114516.9765-10-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082040; x=1746618040; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eMS+oxn1tYp+rxus1jdEnm2eqSOO3ayeaJRU5iz4V2o=; b=HP6WC+/tQ1+iV6SvDzfW0QlMYQ/S09fxV42WnVj90dpqidPDBR7I4H7W hMMpPGbXQbPRZKG/YMut+y9IMEEUvsh8J67MMNDJRqhLZPexya6iHDiy3 wqig3s6ZEdK0I+KlZz8TzBt3K3VTdy2a6Mb3H4U7SkO/JlzLswCjS0C0v 5u0AeCRMe8asu1H8yLnsWkUbswHVJjZsC5tNImXbNXY6e2+DM627RUbdh E1BT8+JaWGD0K2JriOFlnoXG/uBufUyaXaY0E74f61z/jSTDc6xldy3Kt 8pNhIGJyF6L1eCz9gVAzkbR9XL9zQLiPudxyNnsKJibKqcf/pdVK5pm+z g==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=HP6WC+/t Subject: [Intel-wired-lan] [iwl-next v1 09/14] ice: don't set target VSI for subfunction X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Add check for subfunction before setting target VSI. It is needed for PF in switchdev mode but not for subfunction (even in switchdev mode). Signed-off-by: Michal Swiatkowski --- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c index 8bb743f78fcb..fe96af89509b 100644 --- a/drivers/net/ethernet/intel/ice/ice_txrx.c +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c @@ -2405,7 +2405,7 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_tx_ring *tx_ring) ICE_TXD_CTX_QW1_CMD_S); ice_tstamp(tx_ring, skb, first, &offload); - if (ice_is_switchdev_running(vsi->back)) + if (ice_is_switchdev_running(vsi->back) && vsi->type != ICE_VSI_SF) ice_eswitch_set_target_vsi(skb, &offload); if (offload.cd_qw1 & ICE_TX_DESC_DTYPE_CTX) { From patchwork Tue May 7 11:45:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932438 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=nao1rypm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbv63WsWz1xnS for ; Tue, 7 May 2024 21:40:50 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 98EB34075F; Tue, 7 May 2024 11:40:45 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ruJkjOco3sLK; Tue, 7 May 2024 11:40:44 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B15DF40703 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082044; bh=9wKIgxmMIyPhHkrQcCzyJafcwma7SRCIjzLJuriyOD8=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=nao1rypmkkBDyh7FMR/99uXWmjqzYHDrDM1nihvkMqnE7gOYr4iBe+TbyO8mxi+ja k67yNkQLGg8cTcJ2FLhhn0ux4cIaNLJDvuzFSY4T1dXG6B7glII8tQljZ2SCwTAF0w 65QYI9CBkQcYYzLp6cfiZI7A3iXQzhPorG6d2+DIuzi8GgiPWtWHp9RzOvewCmFHxP H/FEJYdtUq0wOvpziD1aXZDZeQOn/tpQXkVAVxbeoHzS5wVozO5kHkAMKn+TbJ29MI /e9JJWnE0WAMuFyg3wbB/8zYNZ4fcwLS08Cem22RP2deWQ/Juz2syeoLa8/epQuYoN vUoUTvXaC/mLw== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id B15DF40703; Tue, 7 May 2024 11:40:44 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 4C6141BF5A0 for ; Tue, 7 May 2024 11:40:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 39CE040223 for ; Tue, 7 May 2024 11:40:43 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id wZmFGxwalUtE for ; Tue, 7 May 2024 11:40:42 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 5539140154 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5539140154 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5539140154 for ; Tue, 7 May 2024 11:40:42 +0000 (UTC) X-CSE-ConnectionGUID: McHNZEUJSaKq30uY0d+Whw== X-CSE-MsgGUID: OaHdfO/XTyyOwuYDgYeI2w== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029279" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029279" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:43 -0700 X-CSE-ConnectionGUID: ANS5EiDWRqaWZqXU7NvETg== X-CSE-MsgGUID: /vUvE/zGQnOUTmGAorgMxQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576719" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:39 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:11 +0200 Message-ID: <20240507114516.9765-11-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082043; x=1746618043; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R3lA8nJjhfaQH1NLLvPiAwgs9WV9Hpp5oEBC8CjoWE0=; b=UfRTOfDi57jRw0ELo7s25hCarF6iFx3mpEvGrZFRqX7BpEK5reqRBEUt BrvgmlHw3fkw5017cDPyIyUPZKFbb+g4ooa3R4Iy/3fR3bq/iBm5y/fuM BbooEVvwDLb6R62akz+ubrcTsKYJKZIMF1ArtB8dknEVxfsg7/pY0HS9Q KmvTYCpMWC0mnCGmi3C2OrioCy4uK6qlM9z6uuKh8g6YrpGVspTYRZqlj rseHTXG5Y75d8TLtiuFAob02b/v7sqHSDrLFGxcZeakSEa+tBMdMr+p8R AJfFPLIbD0Ip5+neZkATd2593RcyFznzUF+bI0iDFa9DToOkhCTKu3l0J A==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=UfRTOfDi Subject: [Intel-wired-lan] [iwl-next v1 10/14] ice: check if SF is ready in ethtool ops X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Now there is another type of port representor. Correct checking if parent device is ready to reflect also new PR type. Reviewed-by: Wojciech Drewek Signed-off-by: Michal Swiatkowski --- drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 +++---- drivers/net/ethernet/intel/ice/ice_repr.c | 12 ++++++++++++ drivers/net/ethernet/intel/ice/ice_repr.h | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c index d91f41f61bce..3f0bf07ea126 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -4070,7 +4070,7 @@ ice_repr_get_drvinfo(struct net_device *netdev, { struct ice_repr *repr = ice_netdev_to_repr(netdev); - if (ice_check_vf_ready_for_cfg(repr->vf)) + if (repr->ops.ready(repr)) return; __ice_get_drvinfo(netdev, drvinfo, repr->src_vsi); @@ -4082,8 +4082,7 @@ ice_repr_get_strings(struct net_device *netdev, u32 stringset, u8 *data) struct ice_repr *repr = ice_netdev_to_repr(netdev); /* for port representors only ETH_SS_STATS is supported */ - if (ice_check_vf_ready_for_cfg(repr->vf) || - stringset != ETH_SS_STATS) + if (repr->ops.ready(repr) || stringset != ETH_SS_STATS) return; __ice_get_strings(netdev, stringset, data, repr->src_vsi); @@ -4096,7 +4095,7 @@ ice_repr_get_ethtool_stats(struct net_device *netdev, { struct ice_repr *repr = ice_netdev_to_repr(netdev); - if (ice_check_vf_ready_for_cfg(repr->vf)) + if (repr->ops.ready(repr)) return; __ice_get_ethtool_stats(netdev, stats, data, repr->src_vsi); diff --git a/drivers/net/ethernet/intel/ice/ice_repr.c b/drivers/net/ethernet/intel/ice/ice_repr.c index 03e6ca3eeedf..3cb3fc5f52ea 100644 --- a/drivers/net/ethernet/intel/ice/ice_repr.c +++ b/drivers/net/ethernet/intel/ice/ice_repr.c @@ -283,6 +283,16 @@ ice_repr_reg_netdev(struct net_device *netdev) return register_netdev(netdev); } +static int ice_repr_ready_vf(struct ice_repr *repr) +{ + return !ice_check_vf_ready_for_cfg(repr->vf); +} + +static int ice_repr_ready_sf(struct ice_repr *repr) +{ + return !repr->sf->active; +} + /** * ice_repr_destroy - remove representor from VF * @repr: pointer to representor structure @@ -412,6 +422,7 @@ struct ice_repr *ice_repr_create_vf(struct ice_vf *vf) repr->vf = vf; repr->ops.add = ice_repr_add_vf; repr->ops.rem = ice_repr_rem_vf; + repr->ops.ready = ice_repr_ready_vf; ether_addr_copy(repr->parent_mac, vf->hw_lan_addr); @@ -450,6 +461,7 @@ struct ice_repr *ice_repr_create_sf(struct ice_dynamic_port *sf) repr->sf = sf; repr->ops.add = ice_repr_add_sf; repr->ops.rem = ice_repr_rem_sf; + repr->ops.ready = ice_repr_ready_sf; ether_addr_copy(repr->parent_mac, sf->hw_addr); diff --git a/drivers/net/ethernet/intel/ice/ice_repr.h b/drivers/net/ethernet/intel/ice/ice_repr.h index dcba07899877..27def65614f3 100644 --- a/drivers/net/ethernet/intel/ice/ice_repr.h +++ b/drivers/net/ethernet/intel/ice/ice_repr.h @@ -36,6 +36,7 @@ struct ice_repr { struct { int (*add)(struct ice_repr *repr); void (*rem)(struct ice_repr *repr); + int (*ready)(struct ice_repr *repr); } ops; }; From patchwork Tue May 7 11:45:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932439 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=IEaK8mgE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbv83xBvz1xnS for ; Tue, 7 May 2024 21:40:52 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 7D58440701; Tue, 7 May 2024 11:40:48 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id UBDHZ20KRtTM; Tue, 7 May 2024 11:40:47 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 9B30640776 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082047; bh=pD50Jp07jC0H7nnNJNHlfHz0BeJp4fm46+A7arW3GJY=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=IEaK8mgEfct4OeV2oiP0bi2PyrcisHkeTbPxxAPggaD/i1oA40T945Q2ClbNs/N/E wES18xIczxvVpSj61ewJcnxqinbFXYB50XZ5qVNT3uyff1TBuGImEeJIx+z+783mEO FWikQNe+wv5qx4JfHoEHJ4AkcIlKdB9TDZyYg5NJAE9Z4+abz7oiu61V0HuDk9fdzI TE+34xIkpET65U/LAnfNps+xKgEntXscq7Pc9TwEOaSEopW1WTKkR+ZKGg/sqiRQeN ivDwmMKCp+I1n4Ju5CL8OmFR3m0qmvqMgq/CTXr4I0P5RKNn40CJ6VPZUeS/VjTc/b Jz/gtdwMwkztg== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 9B30640776; Tue, 7 May 2024 11:40:47 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 5A2F71BF95F for ; Tue, 7 May 2024 11:40:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 542E740223 for ; Tue, 7 May 2024 11:40:46 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id PBcWhHLAFZBm for ; Tue, 7 May 2024 11:40:45 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 6537540154 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 6537540154 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id 6537540154 for ; Tue, 7 May 2024 11:40:45 +0000 (UTC) X-CSE-ConnectionGUID: DKfEHZMDTYWTMih/UAcFwA== X-CSE-MsgGUID: QGMbbNX0T0K80M2NpU63Yg== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029302" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029302" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:46 -0700 X-CSE-ConnectionGUID: tvzRTxB2TQCgpwEJ+K635g== X-CSE-MsgGUID: vKok/OojStO0C0SdMUlfjw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576724" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:42 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:12 +0200 Message-ID: <20240507114516.9765-12-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082046; x=1746618046; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=U98RJNhpk0w1ibKjr+Y/Ppbe3WUrFIbLhoWnj4akRpY=; b=Nac8qefdUn9lG0m6EPGuotlce8yai+wkDmv38CK/aQAkMfJkNixgEM5l 6Oi2th+aV0nBrW+ObEv+1+zmXW69z1IXdbNeDtbYF0npZkxi5wn55U8qK bVa57E/fuw5FI0m5ckUJfWIH0NtPsgFy+TKwo6Y9i6Qm1yGXx8lDWJKI3 Nah9yqPgVRIiWC2EiI2w6f/FhSrElbLiH3pHlAY0RTZaH6J5Q9jlplHyw QvhZs4bnvCdBI6gtvcwEZA8HwXKC969iSPgRGtqS4QGDa1ALe+piEvIie 60Lqd6S1uxnQ1jkqKzPJYvjuCUnLhxr70EwYhbMV1yw5pmr59Tk/9PHpv w==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Nac8qefd Subject: [Intel-wired-lan] [iwl-next v1 11/14] ice: netdevice ops for SF representor X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Subfunction port representor needs the basic netdevice ops to work correctly. Create them. Reviewed-by: Wojciech Drewek Signed-off-by: Michal Swiatkowski Reviewed-by: Jiri Pirko --- drivers/net/ethernet/intel/ice/ice_repr.c | 57 +++++++++++++++++------ 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_repr.c b/drivers/net/ethernet/intel/ice/ice_repr.c index 3cb3fc5f52ea..ec4f5b8b46e6 100644 --- a/drivers/net/ethernet/intel/ice/ice_repr.c +++ b/drivers/net/ethernet/intel/ice/ice_repr.c @@ -59,12 +59,13 @@ static void ice_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) { struct ice_netdev_priv *np = netdev_priv(netdev); + struct ice_repr *repr = np->repr; struct ice_eth_stats *eth_stats; struct ice_vsi *vsi; - if (ice_is_vf_disabled(np->repr->vf)) + if (repr->ops.ready(repr)) return; - vsi = np->repr->src_vsi; + vsi = repr->src_vsi; ice_update_vsi_stats(vsi); eth_stats = &vsi->eth_stats; @@ -93,7 +94,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev) } /** - * ice_repr_open - Enable port representor's network interface + * ice_repr_vf_open - Enable port representor's network interface * @netdev: network interface device structure * * The open entry point is called when a port representor's network @@ -102,7 +103,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev) * * Returns 0 on success */ -static int ice_repr_open(struct net_device *netdev) +static int ice_repr_vf_open(struct net_device *netdev) { struct ice_repr *repr = ice_netdev_to_repr(netdev); struct ice_vf *vf; @@ -118,8 +119,16 @@ static int ice_repr_open(struct net_device *netdev) return 0; } +static int ice_repr_sf_open(struct net_device *netdev) +{ + netif_carrier_on(netdev); + netif_tx_start_all_queues(netdev); + + return 0; +} + /** - * ice_repr_stop - Disable port representor's network interface + * ice_repr_vf_stop - Disable port representor's network interface * @netdev: network interface device structure * * The stop entry point is called when a port representor's network @@ -128,7 +137,7 @@ static int ice_repr_open(struct net_device *netdev) * * Returns 0 on success */ -static int ice_repr_stop(struct net_device *netdev) +static int ice_repr_vf_stop(struct net_device *netdev) { struct ice_repr *repr = ice_netdev_to_repr(netdev); struct ice_vf *vf; @@ -144,6 +153,14 @@ static int ice_repr_stop(struct net_device *netdev) return 0; } +static int ice_repr_sf_stop(struct net_device *netdev) +{ + netif_carrier_off(netdev); + netif_tx_stop_all_queues(netdev); + + return 0; +} + /** * ice_repr_sp_stats64 - get slow path stats for port representor * @dev: network interface device structure @@ -245,10 +262,20 @@ ice_repr_setup_tc(struct net_device *netdev, enum tc_setup_type type, } } -static const struct net_device_ops ice_repr_netdev_ops = { +static const struct net_device_ops ice_repr_vf_netdev_ops = { + .ndo_get_stats64 = ice_repr_get_stats64, + .ndo_open = ice_repr_vf_open, + .ndo_stop = ice_repr_vf_stop, + .ndo_start_xmit = ice_eswitch_port_start_xmit, + .ndo_setup_tc = ice_repr_setup_tc, + .ndo_has_offload_stats = ice_repr_ndo_has_offload_stats, + .ndo_get_offload_stats = ice_repr_ndo_get_offload_stats, +}; + +static const struct net_device_ops ice_repr_sf_netdev_ops = { .ndo_get_stats64 = ice_repr_get_stats64, - .ndo_open = ice_repr_open, - .ndo_stop = ice_repr_stop, + .ndo_open = ice_repr_sf_open, + .ndo_stop = ice_repr_sf_stop, .ndo_start_xmit = ice_eswitch_port_start_xmit, .ndo_setup_tc = ice_repr_setup_tc, .ndo_has_offload_stats = ice_repr_ndo_has_offload_stats, @@ -261,18 +288,20 @@ static const struct net_device_ops ice_repr_netdev_ops = { */ bool ice_is_port_repr_netdev(const struct net_device *netdev) { - return netdev && (netdev->netdev_ops == &ice_repr_netdev_ops); + return netdev && (netdev->netdev_ops == &ice_repr_vf_netdev_ops || + netdev->netdev_ops == &ice_repr_sf_netdev_ops); } /** * ice_repr_reg_netdev - register port representor netdev * @netdev: pointer to port representor netdev + * @ops: new ops for netdev */ static int -ice_repr_reg_netdev(struct net_device *netdev) +ice_repr_reg_netdev(struct net_device *netdev, const struct net_device_ops *ops) { eth_hw_addr_random(netdev); - netdev->netdev_ops = &ice_repr_netdev_ops; + netdev->netdev_ops = ops; ice_set_ethtool_repr_ops(netdev); netdev->hw_features |= NETIF_F_HW_TC; @@ -386,7 +415,7 @@ static int ice_repr_add_vf(struct ice_repr *repr) return err; SET_NETDEV_DEVLINK_PORT(repr->netdev, &vf->devlink_port); - err = ice_repr_reg_netdev(repr->netdev); + err = ice_repr_reg_netdev(repr->netdev, &ice_repr_vf_netdev_ops); if (err) goto err_netdev; @@ -439,7 +468,7 @@ static int ice_repr_add_sf(struct ice_repr *repr) return err; SET_NETDEV_DEVLINK_PORT(repr->netdev, &sf->devlink_port); - err = ice_repr_reg_netdev(repr->netdev); + err = ice_repr_reg_netdev(repr->netdev, &ice_repr_sf_netdev_ops); if (err) goto err_netdev; From patchwork Tue May 7 11:45:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932440 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=yENLzC4d; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbvC3vCbz1xnS for ; Tue, 7 May 2024 21:40:55 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id DBBEB40210; Tue, 7 May 2024 11:40:52 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 2GEDaMu3aTUX; Tue, 7 May 2024 11:40:50 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org AC11840703 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082050; bh=byRgUaItHvg5/YjQ6ovLYFbPjbRgTZAmLy52RZmDUNA=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=yENLzC4ddf2SlS+qLPT98cdSM7G+jDslUuMx3pyAWzoVUuRog1ozNNJP8ieL4R4Q1 0oYVB5Y+de0f2bQXJra0gyVSnQ6KpEjOLNDQtAXKG7SYD52+22TdnJjcKcMV8ck9Ky hgLJThs0ZV6/UBG+NpnGSXikXxR+yJGbZCLWTzMW7mEZ7PHRI0wHIigYaTWiVJtt87 vXHsrRm0qosdjZKvcREn7+XVw3E+E8eph8lGQ7PHIJHIdZm2anKvDCXL4Ax2oykeI6 cp6WQwmidwMnHg8172ZJ4JfXJFKQ/B1atiHQkss4bjEMUqncvFkpVKJFRcP2U/Pdl4 YyUIMr+CPUSxg== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id AC11840703; Tue, 7 May 2024 11:40:50 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 5CD571BF5A0 for ; Tue, 7 May 2024 11:40:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 489A640223 for ; Tue, 7 May 2024 11:40:49 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id D5Kwwjj69fIj for ; Tue, 7 May 2024 11:40:48 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 645EA40154 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 645EA40154 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id 645EA40154 for ; Tue, 7 May 2024 11:40:48 +0000 (UTC) X-CSE-ConnectionGUID: Xsb1qd8TQlCeqQ/6NilnyA== X-CSE-MsgGUID: l8K4Lux5Teeas8QKdzzCTA== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029320" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029320" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:49 -0700 X-CSE-ConnectionGUID: HTz5vSOcQTGxzYiWUNCPVQ== X-CSE-MsgGUID: dwhDXAsnS/aHYs5xQu74HQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576731" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:45 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:13 +0200 Message-ID: <20240507114516.9765-13-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082049; x=1746618049; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=31Jejpe3OCSHK0a4fqPAn9kRSu7BW8zo2Jx5VlDmJB0=; b=IVp31S0eKykCCbhS7qreAcQJ/H8IAps/Md+t/bqjPYES/cswOPWfM/fR b2BAuz9jZSno2vn7plxssthXgqTnM/tpG1l0xc0KQdI/l6Q/lZAWeDApp D5rpEJflA5V61rEspQez40rlWYue1Ri0p9ETwGV8emEKT9jZ4t6RGKf2g CRfVdnDy8OLiSr7Py+X0W7qKVCcyR+UBRo9Lu5270obkOfW5UHuuGPzUJ L7J1sLRic//8ytNUuv5L1PUzqgtZ0g7oINiTrgmj0bMF32N/N+qXA74W/ mMFlnH3i49XyS9847QndpUGCr8iiFoqZ7z1R4o+fq2nS21LkxQsE/iqzm A==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=IVp31S0e Subject: [Intel-wired-lan] [iwl-next v1 12/14] ice: support subfunction devlink Tx topology X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Flow for creating Tx topology is the same as for VF port representors, but the devlink port is stored in different place (sf->devlink_port). When creating VF devlink lock isn't taken, when creating subfunction it is. Setting Tx topology function needs to take this lock, check if it was taken before to not do it twice. Reviewed-by: Przemek Kitszel Reviewed-by: Wojciech Drewek Signed-off-by: Michal Swiatkowski --- drivers/net/ethernet/intel/ice/devlink/devlink.c | 12 ++++++++++++ .../net/ethernet/intel/ice/devlink/devlink_port.c | 3 ++- drivers/net/ethernet/intel/ice/ice_repr.c | 12 +++++++----- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c index c1fe3726f6c0..22aa19c3c784 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c @@ -746,6 +746,7 @@ static void ice_traverse_tx_tree(struct devlink *devlink, struct ice_sched_node struct ice_sched_node *tc_node, struct ice_pf *pf) { struct devlink_rate *rate_node = NULL; + struct ice_dynamic_port *sf; struct ice_vf *vf; int i; @@ -757,6 +758,7 @@ static void ice_traverse_tx_tree(struct devlink *devlink, struct ice_sched_node /* create root node */ rate_node = devl_rate_node_create(devlink, node, node->name, NULL); } else if (node->vsi_handle && + pf->vsi[node->vsi_handle]->type == ICE_VSI_VF && pf->vsi[node->vsi_handle]->vf) { vf = pf->vsi[node->vsi_handle]->vf; if (!vf->devlink_port.devlink_rate) @@ -765,6 +767,16 @@ static void ice_traverse_tx_tree(struct devlink *devlink, struct ice_sched_node */ devl_rate_leaf_create(&vf->devlink_port, node, node->parent->rate_node); + } else if (node->vsi_handle && + pf->vsi[node->vsi_handle]->type == ICE_VSI_SF && + pf->vsi[node->vsi_handle]->sf) { + sf = pf->vsi[node->vsi_handle]->sf; + if (!sf->devlink_port.devlink_rate) + /* leaf nodes doesn't have children + * so we don't set rate_node + */ + devl_rate_leaf_create(&sf->devlink_port, node, + node->parent->rate_node); } else if (node->info.data.elem_type != ICE_AQC_ELEM_TYPE_LEAF && node->parent->rate_node) { rate_node = devl_rate_node_create(devlink, node, node->name, diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c index 3d887e7ee78c..e8929e91aff2 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c @@ -732,7 +732,8 @@ int ice_devlink_create_sf_port(struct ice_dynamic_port *dyn_port) */ void ice_devlink_destroy_sf_port(struct ice_dynamic_port *dyn_port) { - devl_port_unregister(&dyn_port->devlink_port); + devl_rate_leaf_destroy(&dyn_port->devlink_port); + devl_port_unregister(&dyn_port->devlink_port); } /** diff --git a/drivers/net/ethernet/intel/ice/ice_repr.c b/drivers/net/ethernet/intel/ice/ice_repr.c index ec4f5b8b46e6..da7489f8d9a7 100644 --- a/drivers/net/ethernet/intel/ice/ice_repr.c +++ b/drivers/net/ethernet/intel/ice/ice_repr.c @@ -347,16 +347,13 @@ static void ice_repr_rem_sf(struct ice_repr *repr) ice_devlink_destroy_sf_port(repr->sf); } -static void ice_repr_set_tx_topology(struct ice_pf *pf) +static void ice_repr_set_tx_topology(struct ice_pf *pf, struct devlink *devlink) { - struct devlink *devlink; - /* only export if ADQ and DCB disabled and eswitch enabled*/ if (ice_is_adq_active(pf) || ice_is_dcb_active(pf) || !ice_is_switchdev_running(pf)) return; - devlink = priv_to_devlink(pf); ice_devlink_rate_init_tx_topology(devlink, ice_get_main_vsi(pf)); } @@ -408,6 +405,7 @@ static struct ice_repr *ice_repr_create(struct ice_vsi *src_vsi) static int ice_repr_add_vf(struct ice_repr *repr) { struct ice_vf *vf = repr->vf; + struct devlink *devlink; int err; err = ice_devlink_create_vf_port(vf); @@ -424,7 +422,9 @@ static int ice_repr_add_vf(struct ice_repr *repr) goto err_cfg_vsi; ice_virtchnl_set_repr_ops(vf); - ice_repr_set_tx_topology(vf->pf); + + devlink = priv_to_devlink(vf->pf); + ice_repr_set_tx_topology(vf->pf, devlink); return 0; @@ -472,6 +472,8 @@ static int ice_repr_add_sf(struct ice_repr *repr) if (err) goto err_netdev; + ice_repr_set_tx_topology(sf->vsi->back, priv_to_devlink(sf->vsi->back)); + return 0; err_netdev: From patchwork Tue May 7 11:45:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932441 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=fRsiSIw/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbvG3Lpnz1xnS for ; Tue, 7 May 2024 21:40:58 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id EC83840657; Tue, 7 May 2024 11:40:54 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5z0dHU2AVVOn; Tue, 7 May 2024 11:40:54 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org E65EA40664 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082054; bh=fvhTNgzepA70VKx+g3dMxTCle0imbaDFtOpjr7AvHfE=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=fRsiSIw/T8eOaCWhj/caIM7hK2du8mPyMfC6Cf4RosBLdZiyK6dkrKMA2WY/IMm6a TdwATunuujOBLwBn0XLYk+lg6cBbEBaC+rPW3DdiMVrPb2YeIWCbq+3Nu3HiPeDvxe R9K4h9643DXkn0niyE2ZPbV3o8hNDtsegn5SWF5eqAgm8PcS5Ooyf1+xxEd1U53ck7 EfYqc9XFvI+HU+bhEEvkpngCBv3suv0jLUkv8epukFu0lBmLRovndNvBPF46e7Jgei jtHwOzyjurOc9OYXL2PZTlI8H6ZJFXCWveoGSVUf5rMHnHWcYZHHThpa+92bWNFvql JDrxs780Le8kA== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id E65EA40664; Tue, 7 May 2024 11:40:53 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 4669F1BF5A0 for ; Tue, 7 May 2024 11:40:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 339A740223 for ; Tue, 7 May 2024 11:40:52 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id KSScp25pQdnC for ; Tue, 7 May 2024 11:40:51 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 6027940154 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 6027940154 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id 6027940154 for ; Tue, 7 May 2024 11:40:51 +0000 (UTC) X-CSE-ConnectionGUID: 4xN1287PRYumTehUPHV1Tw== X-CSE-MsgGUID: ZAom1O7nQlC3izxs8v2tmQ== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029336" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029336" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:52 -0700 X-CSE-ConnectionGUID: N0r8h/CQRaKolxz0YzLXtg== X-CSE-MsgGUID: +b9YfGd6Spe/6VjEsr/miw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576737" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:48 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:14 +0200 Message-ID: <20240507114516.9765-14-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082052; x=1746618052; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eltzYPXEe6DjzwURvU/HaK1+yLcnmQPP8HVFJtBJ5LI=; b=ZfEr/zntW/bmj74p7tcHikWWpOIeui8hHq0MJfMCoz2n0zTraOZI5nY/ gOBaF6yIY9tqFQsaNCyk3wH9Xa95rczb4lTVutZNZmaWgS+RR0EMKz+5N hbPHczEoW+gG4deSR7m7wYjLnt2zRhDlsuFB0JZNNp9k8XeMFETM2500e bMUrQ0Jql642HtoLm/ONvYOHEDUKDnYDJZpoQiYX/mffJwxG5+fl46MX4 XUDJgBY3as5K0dGCou/qRTNypVua8INcsKyB2tpFVCYv37jDmMPpWa9dh gxX4vQI/vn+XtbWeVCwAO5/iVkQYg4So8q0vbqiKIkGMM0XpgBWT3IbfT A==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ZfEr/znt Subject: [Intel-wired-lan] [iwl-next v1 13/14] ice: basic support for VLAN in subfunctions X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Implement add / delete vlan for subfunction type VSI. Reviewed-by: Wojciech Drewek Signed-off-by: Michal Swiatkowski --- drivers/net/ethernet/intel/ice/Makefile | 1 + .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.c | 21 +++++++++++++++++++ .../ethernet/intel/ice/ice_sf_vsi_vlan_ops.h | 13 ++++++++++++ .../net/ethernet/intel/ice/ice_vsi_vlan_ops.c | 4 ++++ 4 files changed, 39 insertions(+) create mode 100644 drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.c create mode 100644 drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.h diff --git a/drivers/net/ethernet/intel/ice/Makefile b/drivers/net/ethernet/intel/ice/Makefile index 4d987f5dcdc1..f5ff5fba0c3a 100644 --- a/drivers/net/ethernet/intel/ice/Makefile +++ b/drivers/net/ethernet/intel/ice/Makefile @@ -32,6 +32,7 @@ ice-y := ice_main.o \ devlink/devlink.o \ devlink/devlink_port.o \ ice_sf_eth.o \ + ice_sf_vsi_vlan_ops.o \ ice_ddp.o \ ice_fw_update.o \ ice_lag.o \ diff --git a/drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.c b/drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.c new file mode 100644 index 000000000000..3d7e96721cf9 --- /dev/null +++ b/drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2023, Intel Corporation. */ + +#include "ice_vsi_vlan_ops.h" +#include "ice_vsi_vlan_lib.h" +#include "ice_vlan_mode.h" +#include "ice.h" +#include "ice_sf_vsi_vlan_ops.h" + +void ice_sf_vsi_init_vlan_ops(struct ice_vsi *vsi) +{ + struct ice_vsi_vlan_ops *vlan_ops; + + if (ice_is_dvm_ena(&vsi->back->hw)) + vlan_ops = &vsi->outer_vlan_ops; + else + vlan_ops = &vsi->inner_vlan_ops; + + vlan_ops->add_vlan = ice_vsi_add_vlan; + vlan_ops->del_vlan = ice_vsi_del_vlan; +} diff --git a/drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.h b/drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.h new file mode 100644 index 000000000000..8c44eafceea0 --- /dev/null +++ b/drivers/net/ethernet/intel/ice/ice_sf_vsi_vlan_ops.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2023, Intel Corporation. */ + +#ifndef _ICE_SF_VSI_VLAN_OPS_H_ +#define _ICE_SF_VSI_VLAN_OPS_H_ + +#include "ice_vsi_vlan_ops.h" + +struct ice_vsi; + +void ice_sf_vsi_init_vlan_ops(struct ice_vsi *vsi); + +#endif /* _ICE_SF_VSI_VLAN_OPS_H_ */ diff --git a/drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.c b/drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.c index 7aae7fdcfcdb..8c7a9b41fb63 100644 --- a/drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.c +++ b/drivers/net/ethernet/intel/ice/ice_vsi_vlan_ops.c @@ -3,6 +3,7 @@ #include "ice_pf_vsi_vlan_ops.h" #include "ice_vf_vsi_vlan_ops.h" +#include "ice_sf_vsi_vlan_ops.h" #include "ice_lib.h" #include "ice.h" @@ -77,6 +78,9 @@ void ice_vsi_init_vlan_ops(struct ice_vsi *vsi) case ICE_VSI_VF: ice_vf_vsi_init_vlan_ops(vsi); break; + case ICE_VSI_SF: + ice_sf_vsi_init_vlan_ops(vsi); + break; default: dev_dbg(ice_pf_to_dev(vsi->back), "%s does not support VLAN operations\n", ice_vsi_type_str(vsi->type)); From patchwork Tue May 7 11:45:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1932442 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=9ARa5Bjg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VYbvL2C1Pz1xnS for ; Tue, 7 May 2024 21:41:02 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id BE511407B1; Tue, 7 May 2024 11:41:00 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id OwH7bG1T9heB; Tue, 7 May 2024 11:40:59 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 64A9640675 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715082059; bh=xcbV/g9CDWwRfkGzc1woqvP5Mmss/nL9KFhFbw9uuqI=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=9ARa5BjgFiSmBlPeBDC//HIKes1DCjLZoquBiEV9kLB3P22DCe/CyM0OXyUyYMRcC S700yUgOo+DVQEOPAuZqybQjqKZcQzCOZvgLlcKrwJwAJVbXyOUMRoz/hQZJSVtdF5 iqTmYjHCwSOuWGDz45irpPCXXQLlQzbBeTDz8CYqB1d3N5msCKgFRnfJz2CRs17wnG tSGmllc83XWmtq5sO5+y4Fp8FPguWaqqq0QCrfidor7lDXzUaLbj2pkRkAw8sTTlhT bQ1NeM+bqNa93T5fw6X8zmkHa5RWHDC2dB2MnuBkWxMyX07WlX+plKyO0fLKL0njqR IzBs5ofMnIL0Q== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 64A9640675; Tue, 7 May 2024 11:40:59 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id BB8C61BF5A0 for ; Tue, 7 May 2024 11:40:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1ACD440279 for ; Tue, 7 May 2024 11:40:56 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id xMNBDUXj6Tz1 for ; Tue, 7 May 2024 11:40:55 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.13; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org E683740223 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E683740223 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by smtp2.osuosl.org (Postfix) with ESMTPS id E683740223 for ; Tue, 7 May 2024 11:40:54 +0000 (UTC) X-CSE-ConnectionGUID: H2U0za8nTyqXea+kgyA8Cg== X-CSE-MsgGUID: Lr/Xy++wT4GIaDMJ2fpJcg== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="22029351" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="22029351" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2024 04:40:55 -0700 X-CSE-ConnectionGUID: CfyQsZuUT2yiMuzL3nM/lQ== X-CSE-MsgGUID: 9bIEpOgxRzOGvAk2km5r0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="28576741" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by orviesa009.jf.intel.com with ESMTP; 07 May 2024 04:40:51 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 7 May 2024 13:45:15 +0200 Message-ID: <20240507114516.9765-15-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> References: <20240507114516.9765-1-michal.swiatkowski@linux.intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715082055; x=1746618055; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MeZ6eeUxWUz4oYk1ko9ELFZcngR3jjBxth6KTV+q3pk=; b=TtOw8tjmI3xjtfoGQ54Yp8i1d/Qzf0Q9QIguICHmCXHKil9kAqTdZDj6 LsiC2cooLGJUkfqDhMhstEJsFXEEdfqdssd3nxIBG29SrDeYYARwJCuMK I605WOL6ClnWVQZfgsSt97Aq6Y0nHXXszOO2+6JzTD5qZ68GqpN9HE8Dr Mc8Wzi4Eap7Yx4zxaag604czsCddbpZ1PlFRgBYXzzgHhQ4fFtS3n4Po9 +UdB4nua/euJB8AcybNPrp8V2trj/Z6ASn0o9k7D6Rg6s+INGbXHie5Sm 5mum7hBoL0xeGWrJmS8yAKOpYtwcrP1CW9UHHlvGNa3t+SDIM9JxosFq2 A==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=TtOw8tjm Subject: [Intel-wired-lan] [iwl-next v1 14/14] ice: allow to activate and deactivate subfunction X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shayd@nvidia.com, maciej.fijalkowski@intel.com, sridhar.samudrala@intel.com, mateusz.polchlopek@intel.com, netdev@vger.kernel.org, jiri@nvidia.com, michal.kubiak@intel.com, pio.raczynski@gmail.com, przemyslaw.kitszel@intel.com, jacob.e.keller@intel.com, wojciech.drewek@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Piotr Raczynski Use previously implemented SF aux driver. It is probe during SF activation and remove after deactivation. Signed-off-by: Piotr Raczynski Signed-off-by: Michal Swiatkowski --- .../ethernet/intel/ice/devlink/devlink_port.c | 108 ++++++++++++++++++ .../ethernet/intel/ice/devlink/devlink_port.h | 6 + drivers/net/ethernet/intel/ice/ice_sf_eth.c | 107 +++++++++++++++++ drivers/net/ethernet/intel/ice/ice_sf_eth.h | 3 + 4 files changed, 224 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c index e8929e91aff2..43ed05e5c883 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c @@ -482,6 +482,42 @@ void ice_devlink_destroy_sf_dev_port(struct ice_sf_dev *sf_dev) devl_port_unregister(&sf_dev->priv->devlink_port); } +/** + * ice_activate_dynamic_port - Activate a dynamic port + * @dyn_port: dynamic port instance to activate + * @extack: extack for reporting error messages + * + * Activate the dynamic port based on its flavour. + * + * Return: zero on success or an error code on failure. + */ +static int +ice_activate_dynamic_port(struct ice_dynamic_port *dyn_port, + struct netlink_ext_ack *extack) +{ + int err; + + err = ice_sf_eth_activate(dyn_port, extack); + if (err) + return err; + + dyn_port->active = true; + + return 0; +} + +/** + * ice_deactivate_dynamic_port - Deactivate a dynamic port + * @dyn_port: dynamic port instance to deactivate + * + * Undo activation of a dynamic port. + */ +static void ice_deactivate_dynamic_port(struct ice_dynamic_port *dyn_port) +{ + ice_sf_eth_deactivate(dyn_port); + dyn_port->active = false; +} + /** * ice_dealloc_dynamic_port - Deallocate and remove a dynamic port * @dyn_port: dynamic port instance to deallocate @@ -494,6 +530,9 @@ static void ice_dealloc_dynamic_port(struct ice_dynamic_port *dyn_port) struct devlink_port *devlink_port = &dyn_port->devlink_port; struct ice_pf *pf = dyn_port->pf; + if (dyn_port->active) + ice_deactivate_dynamic_port(dyn_port); + xa_erase(&pf->sf_nums, devlink_port->attrs.pci_sf.sf); ice_eswitch_detach_sf(pf, dyn_port); ice_vsi_free(dyn_port->vsi); @@ -638,10 +677,79 @@ ice_devlink_port_fn_hw_addr_get(struct devlink_port *port, u8 *hw_addr, return 0; } +/** + * ice_devlink_port_fn_state_set - devlink handler for port state set + * @port: pointer to devlink port + * @state: state to set + * @extack: extack for reporting error messages + * + * Activates or deactivates the port. + * + * Return: zero on success or an error code on failure. + */ +static int +ice_devlink_port_fn_state_set(struct devlink_port *port, + enum devlink_port_fn_state state, + struct netlink_ext_ack *extack) +{ + struct ice_dynamic_port *dyn_port; + + dyn_port = ice_devlink_port_to_dyn(port); + + switch (state) { + case DEVLINK_PORT_FN_STATE_ACTIVE: + if (!dyn_port->active) + return ice_activate_dynamic_port(dyn_port, extack); + break; + case DEVLINK_PORT_FN_STATE_INACTIVE: + if (dyn_port->active) + ice_deactivate_dynamic_port(dyn_port); + break; + } + + return 0; +} + +/** + * ice_devlink_port_fn_state_get - devlink handler for port state get + * @port: pointer to devlink port + * @state: admin configured state of the port + * @opstate: current port operational state + * @extack: extack for reporting error messages + * + * Gets port state. + * + * Return: zero on success or an error code on failure. + */ +static int +ice_devlink_port_fn_state_get(struct devlink_port *port, + enum devlink_port_fn_state *state, + enum devlink_port_fn_opstate *opstate, + struct netlink_ext_ack *extack) +{ + struct ice_dynamic_port *dyn_port; + + dyn_port = ice_devlink_port_to_dyn(port); + + if (dyn_port->active) + *state = DEVLINK_PORT_FN_STATE_ACTIVE; + else + *state = DEVLINK_PORT_FN_STATE_INACTIVE; + + if (dyn_port->attached) + *opstate = DEVLINK_PORT_FN_OPSTATE_ATTACHED; + else + *opstate = DEVLINK_PORT_FN_OPSTATE_DETACHED; + + return 0; +} + static const struct devlink_port_ops ice_devlink_port_sf_ops = { .port_del = ice_devlink_port_del, .port_fn_hw_addr_get = ice_devlink_port_fn_hw_addr_get, .port_fn_hw_addr_set = ice_devlink_port_fn_hw_addr_set, + .port_fn_state_get = ice_devlink_port_fn_state_get, + .port_fn_state_set = ice_devlink_port_fn_state_set, }; /** diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h index 6e14b9e4d621..28574e585341 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.h +++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.h @@ -14,17 +14,23 @@ * @devlink_port: the associated devlink port structure * @pf: pointer to the PF private structure * @vsi: the VSI associated with this port + * @sf_dev: pointer to the subfunction device * * An instance of a dynamically added devlink port. Each port flavour */ struct ice_dynamic_port { u8 hw_addr[ETH_ALEN]; u8 active: 1; + u8 attached: 1; struct devlink_port devlink_port; struct ice_pf *pf; struct ice_vsi *vsi; unsigned long repr_id; u32 sfnum; + /* Flavour-specific implementation data */ + union { + struct ice_sf_dev *sf_dev; + }; }; void ice_dealloc_all_dynamic_ports(struct ice_pf *pf); diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.c b/drivers/net/ethernet/intel/ice/ice_sf_eth.c index 3a540a2638d1..c01190c9403f 100644 --- a/drivers/net/ethernet/intel/ice/ice_sf_eth.c +++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.c @@ -147,6 +147,7 @@ static int ice_sf_dev_probe(struct auxiliary_device *adev, devl_unlock(devlink); devlink_register(devlink); + dyn_port->attached = true; return 0; @@ -186,6 +187,8 @@ static void ice_sf_dev_remove(struct auxiliary_device *adev) devl_unlock(devlink); devlink_free(devlink); ice_vsi_decfg(vsi); + + dyn_port->attached = false; } static const struct auxiliary_device_id ice_sf_dev_id_table[] = { @@ -202,6 +205,8 @@ static struct auxiliary_driver ice_sf_driver = { .id_table = ice_sf_dev_id_table }; +static DEFINE_XARRAY_ALLOC1(ice_sf_aux_id); + /** * ice_sf_driver_register - Register new auxiliary subfunction driver * @@ -220,3 +225,105 @@ void ice_sf_driver_unregister(void) { auxiliary_driver_unregister(&ice_sf_driver); } + +/** + * ice_sf_dev_release - Release device associated with auxiliary device + * @device: pointer to the device + * + * Since most of the code for subfunction deactivation is handled in + * the remove handler, here just free tracking resources. + */ +static void ice_sf_dev_release(struct device *device) +{ + struct auxiliary_device *adev = to_auxiliary_dev(device); + struct ice_sf_dev *sf_dev = ice_adev_to_sf_dev(adev); + + xa_erase(&ice_sf_aux_id, adev->id); + kfree(sf_dev); +} + +/** + * ice_sf_eth_activate - Activate Ethernet subfunction port + * @dyn_port: the dynamic port instance for this subfunction + * @extack: extack for reporting error messages + * + * Activate the dynamic port as an Ethernet subfunction. Setup the netdev + * resources associated and initialize the auxiliary device. + * + * Return: zero on success or an error code on failure. + */ +int +ice_sf_eth_activate(struct ice_dynamic_port *dyn_port, + struct netlink_ext_ack *extack) +{ + struct ice_pf *pf = dyn_port->pf; + struct ice_sf_dev *sf_dev; + struct pci_dev *pdev; + int err; + u32 id; + + err = xa_alloc(&ice_sf_aux_id, &id, NULL, xa_limit_32b, + GFP_KERNEL); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Could not allocate subfunction ID"); + return err; + } + + sf_dev = kzalloc(sizeof(*sf_dev), GFP_KERNEL); + if (!sf_dev) { + err = -ENOMEM; + NL_SET_ERR_MSG_MOD(extack, "Could not allocate sf_dev memory"); + goto xa_erase; + } + pdev = pf->pdev; + + sf_dev->dyn_port = dyn_port; + sf_dev->adev.id = id; + sf_dev->adev.name = "sf"; + sf_dev->adev.dev.release = ice_sf_dev_release; + sf_dev->adev.dev.parent = &pdev->dev; + + err = auxiliary_device_init(&sf_dev->adev); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Failed to initialize auxiliary device"); + goto sf_dev_free; + } + + err = auxiliary_device_add(&sf_dev->adev); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Auxiliary device failed to probe"); + goto aux_dev_uninit; + } + + dyn_port->sf_dev = sf_dev; + + return 0; + +aux_dev_uninit: + auxiliary_device_uninit(&sf_dev->adev); +sf_dev_free: + kfree(sf_dev); +xa_erase: + xa_erase(&ice_sf_aux_id, id); + + return err; +} + +/** + * ice_sf_eth_deactivate - Deactivate Ethernet subfunction port + * @dyn_port: the dynamic port instance for this subfunction + * + * Deactivate the Ethernet subfunction, removing its auxiliary device and the + * associated resources. + */ +void ice_sf_eth_deactivate(struct ice_dynamic_port *dyn_port) +{ + struct ice_sf_dev *sf_dev = dyn_port->sf_dev; + + if (sf_dev) { + auxiliary_device_delete(&sf_dev->adev); + auxiliary_device_uninit(&sf_dev->adev); + } + + dyn_port->sf_dev = NULL; +} diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.h b/drivers/net/ethernet/intel/ice/ice_sf_eth.h index e972c50f96c9..c558cad0a183 100644 --- a/drivers/net/ethernet/intel/ice/ice_sf_eth.h +++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.h @@ -27,4 +27,7 @@ ice_sf_dev *ice_adev_to_sf_dev(struct auxiliary_device *adev) int ice_sf_driver_register(void); void ice_sf_driver_unregister(void); +int ice_sf_eth_activate(struct ice_dynamic_port *dyn_port, + struct netlink_ext_ack *extack); +void ice_sf_eth_deactivate(struct ice_dynamic_port *dyn_port); #endif /* _ICE_SF_ETH_H_ */