From patchwork Mon May 13 08:37:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 1934602 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=gd0ox5mB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (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 4VdCRx3Qwcz20d6 for ; Mon, 13 May 2024 18:33:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 101D5837C9; Mon, 13 May 2024 08:33:14 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id jk097zOdezFy; Mon, 13 May 2024 08:33:11 +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 smtp1.osuosl.org 9A6E783563 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1715589191; bh=zZy/hlY5AsyRG1o7YUxJ29p+vOhUbWh6HLcxurNbHR8=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=gd0ox5mBmO9SRkXLQMDeRvNdv0k1PmgEuGd0HlH5FiEWWF+Gy4B+kRivxS0B4Uj6A ZkWjB+Un59467xVn1MTjbaZyDUJR+LsTcAL0l2twEKjNnS5zmi82WCKPGrnXwPAO19 /xBusagmqiQfkjk6RwVK7kwth/5aRtsZfdedqUQ63tSibF6mn7X4HLssBrmfd0PEBm x1u6XliEKg9TqMsMu9pBkhsPP727duIOwXJcmOoNkPx1m5G/PbkXzV7q1itU+7Oy+C nbNZjMUlv3+YylKEZr0SgU301OsmnjbJGNwxFUV62+QLwbUePIusU3+VJQKKHoUhyC vbW6UrHt6NVbQ== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 9A6E783563; Mon, 13 May 2024 08:33:11 +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 B907A1BF86C for ; Mon, 13 May 2024 08:33:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id B15D9410B9 for ; Mon, 13 May 2024 08:33:04 +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 DdH-nYBicuyM for ; Mon, 13 May 2024 08:33:03 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=198.175.65.12; helo=mgamail.intel.com; envelope-from=michal.swiatkowski@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 548FC4109D DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 548FC4109D Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by smtp4.osuosl.org (Postfix) with ESMTPS id 548FC4109D for ; Mon, 13 May 2024 08:33:03 +0000 (UTC) X-CSE-ConnectionGUID: 4MyWFIn4QaC9HQv+X/0k1g== X-CSE-MsgGUID: L6gbnPO6QNu9xakDLHvkww== X-IronPort-AV: E=McAfee;i="6600,9927,11071"; a="22914849" X-IronPort-AV: E=Sophos;i="6.08,157,1712646000"; d="scan'208";a="22914849" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2024 01:33:04 -0700 X-CSE-ConnectionGUID: wGZ2Zb/ZRkCXjpxl0CXpCQ== X-CSE-MsgGUID: YYCz6JKcS/S94a2Tpogb5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,157,1712646000"; d="scan'208";a="30303565" Received: from wasp.igk.intel.com (HELO GK3153-DR2-R750-36946.localdomain.com) ([10.102.20.192]) by fmviesa006.fm.intel.com with ESMTP; 13 May 2024 01:33:00 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Date: Mon, 13 May 2024 10:37:29 +0200 Message-ID: <20240513083735.54791-10-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240513083735.54791-1-michal.swiatkowski@linux.intel.com> References: <20240513083735.54791-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=1715589184; x=1747125184; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=igDFjTBTKKEsP9nwMXUX3FIU9EjOl5sgqkaGJyHtrDs=; b=ATLNNhLbeyaKVIjriAKWayR6Ujnl3bk+dFOQO8tGZpVSIUdvM4mjtjhb eYUPQWMVSJj+Z/8L8mlyTI4t5ge6yWxRWQGWiqQUjV/xeYVCyk6AEssYo Q3jlnsbBgtzwiyrrof+Y9OsWlMXlGEKDsiY4HAdjIB4veAaDqRS9DPdPJ A9w//TkqWI8y7BSJyQ2wtyE6D7wiHn8d95sSfh/UAp+ysfDKV/UgG+V/k vmVF+CkjT0J5cTL2K+kGv2mLauEL1fuemVNq6iq/wH/TT57k8FiTjk918 44/m4qJ7pEXN1tJL8h6yciql8xDq1lJMrYSi1ShFaxPAamOKxaGdl/W1C w==; 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=ATLNNhLb Subject: [Intel-wired-lan] [iwl-next v2 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, 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 --- .../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 1355ea042f1d..78b5ec6941b4 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); @@ -727,9 +727,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);