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_ */