From patchwork Tue May 28 04:38: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: 1940219 X-Patchwork-Delegate: anthony.l.nguyen@intel.com 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=9b50QmLz; 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 4VpKQh35rWz20Pq for ; Tue, 28 May 2024 14:33:48 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id E8665405CE; Tue, 28 May 2024 04:33:39 +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 4q-l4LGdApli; Tue, 28 May 2024 04:33: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 E302D405DD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1716870819; bh=1TA9dH55i0BPM5Tm27fB8TEkpAPNZb6Q3MaSkc5J2gQ=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=9b50QmLzuFFDIW93DG4+VfIEj6cIJ1iqsoWxA5tY2k2pEmeutBbMLadycs4nuBMpg bfT0EDl9LuDk2TCLi5jk8vhCm2Ei6rvcAKTA3BsD3wf2myGYoCywhSPKXJdBi2/Efh w/Dkxt2moFN6MJBs2o3xp+EJJaQ0NIMnQsA7arOLNYHXhHP6Qo42hkB4YtWeL9NwXZ v+x8/3ebG/xtPcMkkyQWwksi6XvYRVNaHbBCLUFraU6aTWUe6cH6k7cnEwm6IaKp2m 4uj4Rsz7ScWMOqyCeW0eJXHm10AqbcWko4LVzyhy3Mshc9iQI8VrjGKaWCGyozMrDP 65QWf9fgTQmDg== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id E302D405DD; Tue, 28 May 2024 04:33:38 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 8FCE41D23BA for ; Tue, 28 May 2024 04:33:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 6B11840590 for ; Tue, 28 May 2024 04:33:37 +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 iwXodQgQkH41 for ; Tue, 28 May 2024 04:33:36 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=192.198.163.19; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 31FEB405D2 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 31FEB405D2 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by smtp4.osuosl.org (Postfix) with ESMTPS id 31FEB405D2 for ; Tue, 28 May 2024 04:33:36 +0000 (UTC) X-CSE-ConnectionGUID: mJ3a523KR02ZT5cYFDBXmw== X-CSE-MsgGUID: 0vs6ibdWQfyDwX92NttiPw== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13020128" X-IronPort-AV: E=Sophos;i="6.08,194,1712646000"; d="scan'208";a="13020128" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2024 21:33:36 -0700 X-CSE-ConnectionGUID: PdxGu+NXT76nKuYBsAW37g== X-CSE-MsgGUID: aQfjq104Rm+ytIjRWvN2Vw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,194,1712646000"; d="scan'208";a="66152426" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by fmviesa001.fm.intel.com with ESMTP; 27 May 2024 21:33:33 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Tue, 28 May 2024 06:38:07 +0200 Message-ID: <20240528043813.1342483-10-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240528043813.1342483-1-michal.swiatkowski@linux.intel.com> References: <20240528043813.1342483-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=1716870816; x=1748406816; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VrCqo8+rc8JtjrClJ47v3EuHh+XFhPgKsFMWF5BUoSc=; b=bEWbsoRsKNZn3BRLHgg/+VLbj6ghMFmnCydZyW7Xarah4f+O49Yy1Gga PwD3P4J+YHeD64josO6mzZ62D9iw944r1Oby0f9VacefUUt1CZMfaUJ3p ZQPadlmf4ENXVGlSY3GrvnnAbGcVCyafdmvhBGBu5+k8PF+knEomuryNe 6ICOpXwLIvUqBe3SlQN3vSJ/UQlnc5pJIIQb7YNt+wxXwLMUPXuZykiOI IbfI9to95slqlRGrMAVSv5Tg+YdpkvJ3bf7vvBcRLrppnKTuwZklWohM4 oIoIgDTvotuhtdiBY9AQn54LvG8stiZfWt519GWODwB82JbY8axuEXGDC A==; X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=bEWbsoRs Subject: [Intel-wired-lan] [iwl-next v3 09/15] 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, kalesh-anakkur.purayil@broadcom.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 attaching and detaching SF port representor. It is done in the same way as the VF port representor. SF port representor is always added or removed with devlink lock taken. Signed-off-by: Michal Swiatkowski Reviewed-by: Simon Horman --- .../ethernet/intel/ice/devlink/devlink_port.c | 6 +-- drivers/net/ethernet/intel/ice/ice_eswitch.c | 39 ++++++++++++++ drivers/net/ethernet/intel/ice/ice_eswitch.h | 11 ++++ drivers/net/ethernet/intel/ice/ice_repr.c | 52 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_repr.h | 7 ++- 5 files changed, 111 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c index f06baabd0112..fb3ff68e0666 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink_port.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink_port.c @@ -543,7 +543,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); @@ -765,9 +765,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/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c index a4e7ed9fbaf5..d8c06147d4d4 100644 --- a/drivers/net/ethernet/intel/ice/ice_eswitch.c +++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c @@ -525,6 +525,30 @@ int ice_eswitch_attach_vf(struct ice_pf *pf, struct ice_vf *vf) return err; } +/** + * ice_eswitch_attach_sf - attach SF to a eswitch + * @pf: pointer to PF structure + * @sf: pointer to SF structure to be attached + * + * During attaching port representor for SF is created. + * + * Return: zero on success or an error code on failure. + */ +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); @@ -568,6 +592,21 @@ void ice_eswitch_detach_vf(struct ice_pf *pf, struct ice_vf *vf) devl_unlock(devlink); } +/** + * ice_eswitch_detach_sf - detach SF from a eswitch + * @pf: pointer to PF structure + * @sf: pointer to SF structure to be detached + */ +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 diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.h b/drivers/net/ethernet/intel/ice/ice_eswitch.h index 265b2af055b0..20f301093b36 100644 --- a/drivers/net/ethernet/intel/ice/ice_eswitch.h +++ b/drivers/net/ethernet/intel/ice/ice_eswitch.h @@ -9,7 +9,9 @@ #ifdef CONFIG_ICE_SWITCHDEV 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); @@ -35,12 +37,21 @@ void ice_eswitch_decfg_vsi(struct ice_vsi *vsi, const u8 *mac); 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_sf(struct ice_pf *pf, struct ice_dynamic_port *sf) +{ + return -EOPNOTSUPP; +} + static inline void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf) { } static inline void diff --git a/drivers/net/ethernet/intel/ice/ice_repr.c b/drivers/net/ethernet/intel/ice/ice_repr.c index 5d71f623b1e0..5ea8b512c421 100644 --- a/drivers/net/ethernet/intel/ice/ice_repr.c +++ b/drivers/net/ethernet/intel/ice/ice_repr.c @@ -302,6 +302,12 @@ static void ice_repr_rem_vf(struct ice_repr *repr) ice_virtchnl_set_dflt_ops(repr->vf); } +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) { struct devlink *devlink; @@ -420,6 +426,52 @@ struct ice_repr *ice_repr_create_vf(struct ice_vf *vf) 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; +} + +/** + * ice_repr_create_sf - add representor for SF VSI + * @sf: SF to create port representor on + * + * Set correct representor type for SF and functions pointer. + * + * Return: created port representor on success, error otherwise + */ +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) { return xa_load(&pf->eswitch.reprs, id); diff --git a/drivers/net/ethernet/intel/ice/ice_repr.h b/drivers/net/ethernet/intel/ice/ice_repr.h index d3454b6f5d41..dcba07899877 100644 --- a/drivers/net/ethernet/intel/ice/ice_repr.h +++ b/drivers/net/ethernet/intel/ice/ice_repr.h @@ -17,6 +17,7 @@ struct ice_repr_pcpu_stats { enum ice_repr_type { ICE_REPR_TYPE_VF, + ICE_REPR_TYPE_SF, }; struct ice_repr { @@ -28,7 +29,10 @@ struct ice_repr { u32 id; u8 parent_mac[ETH_ALEN]; enum ice_repr_type type; - struct ice_vf *vf; + union { + struct ice_vf *vf; + struct ice_dynamic_port *sf; + }; struct { int (*add)(struct ice_repr *repr); void (*rem)(struct ice_repr *repr); @@ -36,6 +40,7 @@ struct ice_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);