cxl: add type2 device basic support
Subsystems (4)
v9 cover cxl: add type2 device basic support
From: Alejandro Lucero <[email protected]>
v9 changes:
- adding forward definitions (Jonathan Cameron)
- using set_bit instead of bitmap_set (Jonathan Cameron)
- fix rebase problem (Jonathan Cameron)
- Improve error path (Jonathan Cameron)
- fix build problems with cxl region dependency (robot)
- fix error path (Simon Horman)
v8 changes:
- Change error path labeling inside sfc cxl code (Edward Cree)
- Properly handling checks and error in sfc cxl code (Simon Horman)
- Fix bug when checking resource_size (Simon Horman)
- Avoid bisect problems reordering patches (Edward Cree)
- Fix buffer allocation size in sfc (Simon Horman)
v7 changes:
- fixing kernel test robot complains
- fix type with Type3 mandatory capabilities (Zhi Wang)
- optimize code in cxl_request_resource (Kalesh Anakkur Purayil)
- add sanity check when dealing with resources arithmetics (Fan Ni)
- fix typos and blank lines (Fan Ni)
- keep previous log errors/warnings in sfc driver (Martin Habets)
- add WARN_ON_ONCE if region given is NULL
v6 changes:
- update sfc mcdi_pcol.h with full hardware changes most not related to this patchset. This is an automatic file created from hardware design changes and not touched by software. It is updated from time to time and it required update for the sfc driver CXL support.
- remove CXL capabilities definitions not used by the patchset or previous kernel code. (Dave Jiang, Jonathan Cameron)
- Use bitmap_subset instead of reinventing the wheel ... (Ben Cheatham)
- Use cxl_accel_memdev for new device_type created (Ben Cheatham)
- Fix construct_region use of rwsem (Zhi Wang)
- Obtain region range instead of region params (Allison Schofield, Dave Jiang)
v5 changes:
- Fix SFC configuration based on kernel CXL configuration
- Add subset check for capabilities.
- fix region creation when HDM decoders programmed by firmware/BIOS (Ben Cheatham)
- Add option for creating dax region based on driver decission (Ben Cheatham)
- Using sfc probe_data struct for keeping sfc cxl data
v4 changes:
- Use bitmap for capabilities new field (Jonathan Cameron)
- Use cxl_mem attributes for sysfs based on device type (Dave Jian)
- Add conditional cxl sfc compilation relying on kernel CXL config (kernel test robot)
- Add sfc changes in different patches for facilitating backport (Jonathan Cameron)
- Remove patch for dealing with cxl modules dependencies and using sfc kconfig plus MODULE_SOFTDEP instead.
v3 changes:
- cxl_dev_state not defined as opaque but only manipulated by accel drivers through accessors.
- accessors names not identified as only for accel drivers.
- move pci code from pci driver (drivers/cxl/pci.c) to generic pci code (drivers/cxl/core/pci.c).
- capabilities field from u8 to u32 and initialised by CXL regs discovering code.
- add capabilities check and removing current check by CXL regs discovering code.
- Not fail if CXL Device Registers not found. Not mandatory for Type2.
- add timeout in acquire_endpoint for solving a race with the endpoint port creation.
- handle EPROBE_DEFER by sfc driver.
- Limiting interleave ways to 1 for accel driver HPA/DPA requests.
- factoring out interleave ways and granularity helpers from type2 region creation patch.
- restricting region_creation for type2 to one endpoint decoder.
- add accessor for release_resource.
- handle errors and errors messages properly.
v2 changes:
I have removed the introduction about the concerns with BIOS/UEFI after the discussion leading to confirm the need of the functionality implemented, at least is some scenarios.
There are two main changes from the RFC:
1) Following concerns about drivers using CXL core without restrictions, the CXL struct to work with is opaque to those drivers, therefore functions are implemented for modifying or reading those structs indirectly.
2) The driver for using the added functionality is not a test driver but a real
one: the SFC ethernet network driver. It uses the CXL region mapped for PIO buffers instead of regions inside PCIe BARs.
RFC:
Current CXL kernel code is focused on supporting Type3 CXL devices, aka memory expanders. Type2 CXL devices, aka device accelerators, share some functionalities but require some special handling.
First of all, Type2 are by definition specific to drivers doing something and not just a memory expander, so it is expected to work with the CXL specifics. This implies the CXL setup needs to be done by such a driver instead of by a generic CXL PCI driver as for memory expanders. Most of such setup needs to use current CXL core code and therefore needs to be accessible to those vendor drivers. This is accomplished exporting opaque CXL structs and adding and exporting functions for working with those structs indirectly.
Some of the patches are based on a patchset sent by Dan Williams [1] which was just partially integrated, most related to making things ready for Type2 but none related to specific Type2 support. Those patches based on Dan´s work have Dan´s signing as co-developer, and a link to the original patch.
A final note about CXL.cache is needed. This patchset does not cover it at all, although the emulated Type2 device advertises it. From the kernel point of view supporting CXL.cache will imply to be sure the CXL path supports what the Type2 device needs. A device accelerator will likely be connected to a Root Switch, but other configurations can not be discarded. Therefore the kernel will need to check not just HPA, DPA, interleave and granularity, but also the available CXL.cache support and resources in each switch in the CXL path to the Type2 device. I expect to contribute to this support in the following months, and it would be good to discuss about it when possible.
[1] https://lore.kernel.org/linux-cxl/[email protected]/T/
Alejandro Lucero (27):
cxl: add type2 device basic support
sfc: add cxl support using new CXL API
cxl: add capabilities field to cxl_dev_state and cxl_port cxl/pci: add check for validating capabilities
cxl: move pci generic code
cxl: add function for type2 cxl regs setup
sfc: use cxl api for regs setup and checking
cxl: add functions for resource request/release by a driver
sfc: request cxl ram resource
resource: harden resource_contains
cxl: add function for setting media ready by a driver
sfc: set cxl media ready
cxl: prepare memdev creation for type2
sfc: create type2 cxl memdev
cxl: define a driver interface for HPA free space enumeration
sfc: obtain root decoder with enough HPA free space
cxl: define a driver interface for DPA allocation
sfc: get endpoint decoder
cxl: make region type based on endpoint type
cxl/region: factor out interleave ways setup
cxl/region: factor out interleave granularity setup
cxl: allow region creation by type2 drivers
cxl: add region flag for precluding a device memory to be used for dax
sfc: create cxl region
cxl: add function for obtaining region range
sfc: update MCDI protocol headers
sfc: support pio mapping based on cxl
drivers/cxl/core/cdat.c | 3 + drivers/cxl/core/hdm.c | 153 +- drivers/cxl/core/memdev.c | 110 +- drivers/cxl/core/pci.c | 141 + drivers/cxl/core/port.c | 11 +- drivers/cxl/core/region.c | 422 +- drivers/cxl/core/regs.c | 32 +- drivers/cxl/cxl.h | 16 +- drivers/cxl/cxlmem.h | 7 +- drivers/cxl/cxlpci.h | 19 +- drivers/cxl/mem.c | 25 +- drivers/cxl/pci.c | 112 +- drivers/cxl/port.c | 5 +- drivers/net/ethernet/sfc/Kconfig | 7 + drivers/net/ethernet/sfc/Makefile | 1 + drivers/net/ethernet/sfc/ef10.c | 50 +- drivers/net/ethernet/sfc/efx.c | 23 +- drivers/net/ethernet/sfc/efx_cxl.c | 183 + drivers/net/ethernet/sfc/efx_cxl.h | 34 + drivers/net/ethernet/sfc/mcdi_pcol.h | 13645 +++++++++--------------- drivers/net/ethernet/sfc/net_driver.h | 12 + drivers/net/ethernet/sfc/nic.h | 3 + include/cxl/cxl.h | 73 + include/cxl/pci.h | 23 + include/linux/ioport.h | 2 + 25 files changed, 6120 insertions(+), 8992 deletions(-) create mode 100644 drivers/net/ethernet/sfc/efx_cxl.c create mode 100644 drivers/net/ethernet/sfc/efx_cxl.h create mode 100644 include/cxl/cxl.h create mode 100644 include/cxl/pci.h
base-commit: fac04efc5c793dccbd07e2d59af9f90b7fc0dca4
prerequisite-patch-id: 91b580e38dc5d1ef2eb4175507d7d3d1fb438958
Signature · 1 line
2.17.1
PATCH v9 1/27 cxl: add type2 device basic support
From: Alejandro Lucero <[email protected]>
Differentiate CXL memory expanders (type 3) from CXL device accelerators (type 2) with a new function for initializing cxl_dev_state.
Create accessors to cxl_dev_state to be used by accel drivers.
Based on previous work by Dan Williams [1]
--- drivers/cxl/core/memdev.c | 51 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/pci.c | 1 + drivers/cxl/cxlpci.h | 16 ------------ drivers/cxl/pci.c | 13 +++++++--- include/cxl/cxl.h | 24 ++++++++++++++++++ include/cxl/pci.h | 23 ++++++++++++++++++ 6 files changed, 108 insertions(+), 20 deletions(-) create mode 100644 include/cxl/cxl.h create mode 100644 include/cxl/pci.h
drivers/cxl/core/memdev.c +51 -0
@@ -7,6 +7,7 @@#include <linux/slab.h> #include <linux/idr.h> #include <linux/pci.h> +#include <cxl/cxl.h> #include <cxlmem.h> #include "trace.h" #include "core.h"
@@ -616,6 +617,25 @@ static void detach_memdev(struct work_struct *work)static struct lock_class_key cxl_memdev_key; +struct cxl_dev_state *cxl_accel_state_create (struct device *dev) +{ +struct cxl_dev_state *cxlds; + + cxlds =kzalloc (sizeof (*cxlds),GFP_KERNEL ); +if (!cxlds) +return ERR_PTR (-ENOMEM ); + + cxlds->dev = dev; + cxlds->type =CXL_DEVTYPE_DEVMEM ; + + cxlds->dpa_res =DEFINE_RES_MEM_NAMED (0 ,0 ,"dpa" ); + cxlds->ram_res =DEFINE_RES_MEM_NAMED (0 ,0 ,"ram" ); + cxlds->pmem_res =DEFINE_RES_MEM_NAMED (0 ,0 ,"pmem" ); + +return cxlds; +} +EXPORT_SYMBOL_NS_GPL (cxl_accel_state_create,"CXL" ); +static struct cxl_memdev *cxl_memdev_alloc (struct cxl_dev_state *cxlds,const struct file_operations *fops) {
@@ -693,6 +713,37 @@ static int cxl_memdev_open(struct inode *inode, struct file *file)return 0 ; } +void cxl_set_dvsec (struct cxl_dev_state *cxlds,u16 dvsec) +{ + cxlds->cxl_dvsec = dvsec; +} +EXPORT_SYMBOL_NS_GPL (cxl_set_dvsec,"CXL" ); + +void cxl_set_serial (struct cxl_dev_state *cxlds,u64 serial) +{ + cxlds->serial = serial; +} +EXPORT_SYMBOL_NS_GPL (cxl_set_serial,"CXL" ); + +int cxl_set_resource (struct cxl_dev_state *cxlds,struct resource res, +enum cxl_resource type) +{ +switch (type) { +case CXL_RES_DPA : + cxlds->dpa_res = res; +return 0 ; +case CXL_RES_RAM : + cxlds->ram_res = res; +return 0 ; +case CXL_RES_PMEM : + cxlds->pmem_res = res; +return 0 ; + } + +return -EINVAL ; +} +EXPORT_SYMBOL_NS_GPL (cxl_set_resource,"CXL" ); +static int cxl_memdev_release_file (struct inode *inode,struct file *file) { struct cxl_memdev *cxlmd =
drivers/cxl/core/pci.c +1 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* Copyright(c) 2021 Intel Corporation. All rights reserved. */ +#include <cxl/pci.h> #include <linux/units.h> #include <linux/io-64-nonatomic-lo-hi.h> #include <linux/device.h>
drivers/cxl/cxlpci.h +0 -16
@@ -14,22 +14,6 @@*/ #define PCI_DVSEC_HEADER1_LENGTH_MASK GENMASK(31, 20) -/* CXL 2.0 8.1.3: PCIe DVSEC for CXL Device */ -#define CXL_DVSEC_PCIE_DEVICE 0 -#define CXL_DVSEC_CAP_OFFSET 0xA -#define CXL_DVSEC_MEM_CAPABLE BIT(2) -#define CXL_DVSEC_HDM_COUNT_MASK GENMASK(5, 4) -#define CXL_DVSEC_CTRL_OFFSET 0xC -#define CXL_DVSEC_MEM_ENABLE BIT(2) -#define CXL_DVSEC_RANGE_SIZE_HIGH (i) (0x18 + (i * 0x10)) -#define CXL_DVSEC_RANGE_SIZE_LOW (i) (0x1C + (i * 0x10)) -#define CXL_DVSEC_MEM_INFO_VALID BIT(0) -#define CXL_DVSEC_MEM_ACTIVE BIT(1) -#define CXL_DVSEC_MEM_SIZE_LOW_MASK GENMASK(31, 28) -#define CXL_DVSEC_RANGE_BASE_HIGH (i) (0x20 + (i * 0x10)) -#define CXL_DVSEC_RANGE_BASE_LOW (i) (0x24 + (i * 0x10)) -#define CXL_DVSEC_MEM_BASE_LOW_MASK GENMASK(31, 28) -#define CXL_DVSEC_RANGE_MAX 2/* CXL 2.0 8.1.4: Non-CXL Function Map DVSEC */
drivers/cxl/pci.c +9 -4
@@ -1,5 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* Copyright(c) 2020 Intel Corporation. All rights reserved. */ +#include <cxl/cxl.h> +#include <cxl/pci.h> #include <linux/unaligned.h> #include <linux/io-64-nonatomic-lo-hi.h> #include <linux/moduleparam.h>
@@ -906,6 +908,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)struct cxl_memdev *cxlmd;int i, rc, pmu_count;bool irq_avail; +u16 dvsec;/* * Double check the anonymous union trickery in struct cxl_regs
@@ -926,13 +929,15 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)pci_set_drvdata (pdev, cxlds); cxlds->rcd =is_cxl_restricted (pdev); - cxlds->serial =pci_get_dsn (pdev); - cxlds->cxl_dvsec =pci_find_dvsec_capability ( - pdev,PCI_VENDOR_ID_CXL ,CXL_DVSEC_PCIE_DEVICE ); -if (!cxlds->cxl_dvsec) +cxl_set_serial (cxlds,pci_get_dsn (pdev)); + dvsec =pci_find_dvsec_capability (pdev,PCI_VENDOR_ID_CXL , +CXL_DVSEC_PCIE_DEVICE ); +if (!dvsec)dev_warn (&pdev->dev,"Device DVSEC not present, skip CXL.mem init\n" ); +cxl_set_dvsec (cxlds, dvsec); + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_MEMDEV , &map);if (rc)return rc;
include/cxl/cxl.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright(c) 2024 Advanced Micro Devices, Inc. */ + +#ifndef __CXL_H +#define __CXL_H + +#include <linux/ioport.h> + +enum cxl_resource { +CXL_RES_DPA , +CXL_RES_RAM , +CXL_RES_PMEM , +}; + +struct cxl_dev_state ; +struct device ; + +struct cxl_dev_state *cxl_accel_state_create (struct device *dev); + +void cxl_set_dvsec (struct cxl_dev_state *cxlds,u16 dvsec); +void cxl_set_serial (struct cxl_dev_state *cxlds,u64 serial); +int cxl_set_resource (struct cxl_dev_state *cxlds,struct resource res, +enum cxl_resource ); +#endif
include/cxl/pci.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2020 Intel Corporation. All rights reserved. */ + +#ifndef __CXL_ACCEL_PCI_H +#define __CXL_ACCEL_PCI_H + +/* CXL 2.0 8.1.3: PCIe DVSEC for CXL Device */ +#define CXL_DVSEC_PCIE_DEVICE 0 +#define CXL_DVSEC_CAP_OFFSET 0xA +#define CXL_DVSEC_MEM_CAPABLE BIT(2) +#define CXL_DVSEC_HDM_COUNT_MASK GENMASK(5, 4) +#define CXL_DVSEC_CTRL_OFFSET 0xC +#define CXL_DVSEC_MEM_ENABLE BIT(2) +#define CXL_DVSEC_RANGE_SIZE_HIGH (i) (0x18 + ((i) * 0x10)) +#define CXL_DVSEC_RANGE_SIZE_LOW (i) (0x1C + ((i) * 0x10)) +#define CXL_DVSEC_MEM_INFO_VALID BIT(0) +#define CXL_DVSEC_MEM_ACTIVE BIT(1) +#define CXL_DVSEC_MEM_SIZE_LOW_MASK GENMASK(31, 28) +#define CXL_DVSEC_RANGE_BASE_HIGH (i) (0x20 + ((i) * 0x10)) +#define CXL_DVSEC_RANGE_BASE_LOW (i) (0x24 + ((i) * 0x10)) +#define CXL_DVSEC_MEM_BASE_LOW_MASK GENMASK(31, 28) + +#endif
Signature · 1 line
2.17.1
PATCH v9 2/27 sfc: add cxl support using new CXL API
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Add CXL initialization based on new CXL API for accel drivers and make it dependent on kernel CXL configuration.
--- drivers/net/ethernet/sfc/Kconfig | 7 +++ drivers/net/ethernet/sfc/Makefile | 1 + drivers/net/ethernet/sfc/efx.c | 23 ++++++- drivers/net/ethernet/sfc/efx_cxl.c | 86 +++++++++++++++++++++++++++ drivers/net/ethernet/sfc/efx_cxl.h | 34 +++++++++++ drivers/net/ethernet/sfc/net_driver.h | 10 ++++ 6 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/sfc/efx_cxl.c create mode 100644 drivers/net/ethernet/sfc/efx_cxl.h
drivers/net/ethernet/sfc/Kconfig +7 -0
@@ -65,6 +65,13 @@ config SFC_MCDI_LOGGING Driver-Interface) commands and responses, allowing debugging of driver/firmware interaction. The tracing is actually enabled by a sysfs file 'mcdi_logging' under the PCI device. +config SFC_CXL + bool "Solarflare SFC9100-family CXL support" + depends on SFC && CXL_BUS && !(SFC=y && CXL_BUS=m) + default y + help + This enables CXL support by the driver relying on kernel support + and hardware support. source "drivers/net/ethernet/sfc/falcon/Kconfig" source "drivers/net/ethernet/sfc/siena/Kconfig"
drivers/net/ethernet/sfc/Makefile +1 -0
@@ -13,6 +13,7 @@ sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o ef100_rep.o \ mae.o tc.o tc_bindings.o tc_counters.o \ tc_encap_actions.o tc_conntrack.o +sfc-$(CONFIG_SFC_CXL) += efx_cxl.o obj-$(CONFIG_SFC) += sfc.o obj-$(CONFIG_SFC_FALCON) += falcon/
drivers/net/ethernet/sfc/efx.c +22 -1
@@ -34,6 +34,9 @@#include "selftest.h" #include "sriov.h" #include "efx_devlink.h" +#ifdef CONFIG_SFC_CXL +#include "efx_cxl.h" +#endif #include "mcdi_port_common.h" #include "mcdi_pcol.h"
@@ -1004,12 +1007,17 @@ static void efx_pci_remove(struct pci_dev *pci_dev)efx_pci_remove_main (efx);efx_fini_io (efx); + + probe_data = container_of(efx, struct efx_probe_data, efx); +#ifdef CONFIG_SFC_CXL +efx_cxl_exit (probe_data); +#endif +pci_dbg (efx->pci_dev,"shutdown successful\n" );efx_fini_devlink_and_unlock (efx);efx_fini_struct (efx);free_netdev (efx->net_dev); - probe_data = container_of(efx, struct efx_probe_data, efx);kfree (probe_data); };
@@ -1214,6 +1222,16 @@ static int efx_pci_probe(struct pci_dev *pci_dev,if (rc) goto fail2; +#ifdef CONFIG_SFC_CXL +/* A successful cxl initialization implies a CXL region created to be +* used for PIO buffers. If there is no CXL support, or initialization +* fails, efx_cxl_pio_initialised wll be false and legacy PIO buffers +* defined at specific PCI BAR regions will be used. +*/ + rc =efx_cxl_init (probe_data); +if (rc) +pci_err (pci_dev,"CXL initialization failed with error %d\n" , rc); +#endif rc =efx_pci_probe_post_io (efx);if (rc) {/* On failure, retry once immediately.
@@ -1485,3 +1503,6 @@ MODULE_AUTHOR("Solarflare Communications and "MODULE_DESCRIPTION ("Solarflare network driver" );MODULE_LICENSE ("GPL" );MODULE_DEVICE_TABLE (pci, efx_pci_table); +#ifdef CONFIG_SFC_CXL +MODULE_SOFTDEP ("pre: cxl_core cxl_port cxl_acpi cxl-mem" ); +#endif
drivers/net/ethernet/sfc/efx_cxl.c new file +86 -0
86 lines not on this page · raw message
drivers/net/ethernet/sfc/efx_cxl.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/**************************************************************************** +* Driver for AMD network controllers and boards +* Copyright (C) 2024, Advanced Micro Devices, Inc. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation, incorporated herein by reference. +*/ + +#ifndef EFX_CXL_H +#define EFX_CXL_H + +struct cxl_dev_state ; +struct cxl_memdev ; +struct cxl_root_decoder ; +struct cxl_port ; +struct cxl_endpoint_decoder ; +struct cxl_region ; +struct efx_probe_data ; + +struct efx_cxl { +struct cxl_dev_state *cxlds; +struct cxl_memdev *cxlmd; +struct cxl_root_decoder *cxlrd; +struct cxl_port *endpoint; +struct cxl_endpoint_decoder *cxled; +struct cxl_region *efx_region; +void __iomem *ctpio_cxl; +}; + +int efx_cxl_init (struct efx_probe_data *probe_data); +void efx_cxl_exit (struct efx_probe_data *probe_data); +#endif
drivers/net/ethernet/sfc/net_driver.h +10 -0
@@ -1199,14 +1199,24 @@ struct efx_nic {atomic_t n_rx_noskb_drops; }; +#ifdef CONFIG_SFC_CXL +struct efx_cxl ; +#endif +/** * struct efx_probe_data - State after hardware probe * @pci_dev: The PCI device * @efx: Efx NIC details +* @cxl: details of related cxl objects +* @cxl_pio_initialised: cxl initialization outcome. */ struct efx_probe_data {struct pci_dev *pci_dev;struct efx_nic efx; +#ifdef CONFIG_SFC_CXL +struct efx_cxl *cxl; +bool cxl_pio_initialised; +#endif };static inline struct efx_nic *efx_netdev_priv (struct net_device *dev)
Signature · 1 line
2.17.1
Re: [PATCH v9 02/27] sfc: add cxl support using new CXL API
Quoted 8 lines · On Mon, 30 Dec 2024 21:44:20 +0000 [email protected] wrote:
From: Alejandro Lucero <[email protected]>
Add CXL initialization based on new CXL API for accel drivers and make it dependent on kernel CXL configuration.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>Acked-by Edward Cree <[email protected]>
Hi Alejandro,
Happy New Year!
I gave an RB for this on v8 (subject to the few small things you have tidied up), I guess you missed it.
Re: [PATCH v9 02/27] sfc: add cxl support using new CXL API
Quoted 11 lines · Jonathan Cameron
Quoted 8 lines · On Mon, 30 Dec 2024 21:44:20 +0000 [email protected] wrote:
From: Alejandro Lucero <[email protected]>
Add CXL initialization based on new CXL API for accel drivers and make it dependent on kernel CXL configuration.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>Acked-by Edward Cree <[email protected]>
Quoted 6 lines
Hi Alejandro,
Happy New Year!
I gave an RB for this on v8 (subject to the few small things you have tidied up), I guess you missed it.
Hi Jonathan,
Yes, sorry. I will add yours in v10.
Happy new year!
Quoted 1 line
Reviewed-by Jonathan Cameron <[email protected]>
Re: [PATCH v9 02/27] sfc: add cxl support using new CXL API
In reply to [email protected]Quoted 8 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Add CXL initialization based on new CXL API for accel drivers and make it dependent on kernel CXL configuration.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>Acked-by Edward Cree <[email protected]>
Quoted 10 lines
--- drivers/net/ethernet/sfc/Kconfig | 7 +++ drivers/net/ethernet/sfc/Makefile | 1 + drivers/net/ethernet/sfc/efx.c | 23 ++++++- drivers/net/ethernet/sfc/efx_cxl.c | 86 +++++++++++++++++++++++++++ drivers/net/ethernet/sfc/efx_cxl.h | 34 +++++++++++ drivers/net/ethernet/sfc/net_driver.h | 10 ++++ 6 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/sfc/efx_cxl.c create mode 100644 drivers/net/ethernet/sfc/efx_cxl.h
v9 did not pick up the comments I left on v8 of this patch:
Re: [PATCH v9 02/27] sfc: add cxl support using new CXL API
Quoted 19 lines · Dan Williams
Quoted 16 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Add CXL initialization based on new CXL API for accel drivers and make it dependent on kernel CXL configuration.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>Acked-by Edward Cree <[email protected]>--- drivers/net/ethernet/sfc/Kconfig | 7 +++ drivers/net/ethernet/sfc/Makefile | 1 + drivers/net/ethernet/sfc/efx.c | 23 ++++++- drivers/net/ethernet/sfc/efx_cxl.c | 86 +++++++++++++++++++++++++++ drivers/net/ethernet/sfc/efx_cxl.h | 34 +++++++++++ drivers/net/ethernet/sfc/net_driver.h | 10 ++++ 6 files changed, 160 insertions(+), 1 deletion(-)Quoted 2 lines
create mode 100644
drivers/net/ethernet/sfc/efx_cxl.ccreate mode 100644drivers/net/ethernet/sfc/efx_cxl.h
Quoted 1 line
v9 did not pick up the comments I left on v8 of this patch:
That is because v9 was out before you commented in v8.
Those patches did not change from v8 to v9, so your comments are still valid.
I did apply the changes and they will be in v10.
Quoted 1 line
PATCH v9 3/27 cxl: add capabilities field to cxl_dev_state and cxl_port
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Type2 devices have some Type3 functionalities as optional like an mbox or an hdm decoder, and CXL core needs a way to know what an CXL accelerator implements.
Add a new field to cxl_dev_state for keeping device capabilities as discovered during initialization. Add same field to cxl_port as registers discovery is also used during port initialization.
--- drivers/cxl/core/port.c | 11 +++++++---- drivers/cxl/core/regs.c | 23 ++++++++++++++++------- drivers/cxl/cxl.h | 9 ++++++--- drivers/cxl/cxlmem.h | 2 ++ drivers/cxl/pci.c | 10 ++++++---- include/cxl/cxl.h | 19 +++++++++++++++++++ 6 files changed, 56 insertions(+), 18 deletions(-)
drivers/cxl/core/port.c +7 -4
@@ -749,7 +749,7 @@ static struct cxl_port *cxl_port_alloc(struct device *uport_dev, }static int cxl_setup_comp_regs (struct device *host,struct cxl_register_map *map, -resource_size_t component_reg_phys) +resource_size_t component_reg_phys,unsigned long *caps) { *map = (struct cxl_register_map ) { .host = host,
@@ -763,7 +763,7 @@ static int cxl_setup_comp_regs(struct device *host, struct cxl_register_map *map map->reg_type =CXL_REGLOC_RBI_COMPONENT ; map->max_size =CXL_COMPONENT_REG_BLOCK_SIZE ; -return cxl_setup_regs (map); +return cxl_setup_regs (map, caps); } static int cxl_port_setup_regs(struct cxl_port *port,
@@ -772,7 +772,7 @@ static int cxl_port_setup_regs(struct cxl_port *port,if (dev_is_platform (port->uport_dev))return 0 ;return cxl_setup_comp_regs (&port->dev, &port->reg_map, - component_reg_phys); + component_reg_phys, port->capabilities); } static int cxl_dport_setup_regs(struct device *host, struct cxl_dport *dport,
@@ -789,7 +789,8 @@ static int cxl_dport_setup_regs(struct device *host, struct cxl_dport *dport,* NULL. */ rc =cxl_setup_comp_regs (dport->dport_dev, &dport->reg_map, - component_reg_phys); + component_reg_phys, + dport->port->capabilities); dport->reg_map.host = host;return rc; }
@@ -851,6 +852,8 @@ static int cxl_port_add(struct cxl_port *port, port->reg_map = cxlds->reg_map; port->reg_map.host = &port->dev; cxlmd->endpoint = port; +bitmap_copy (port->capabilities, cxlds->capabilities, +CXL_MAX_CAPS ); }else if (parent_dport) { rc =dev_set_name (dev,"port%d" , port->id);if (rc)
drivers/cxl/core/regs.c +16 -7
@@ -4,6 +4,7 @@#include <linux/device.h> #include <linux/slab.h> #include <linux/pci.h> +#include <cxl/cxl.h> #include <cxlmem.h> #include <cxlpci.h> #include <pmu.h>
@@ -29,6 +30,7 @@* @dev: Host device of the @base mapping * @base: Mapping containing the HDM Decoder Capability Header * @map: Map object describing the register block information found +* @caps: capabilities to be set when discovered * * See CXL 2.0 8.2.4 Component Register Layout and Definition * See CXL 2.0 8.2.5.5 CXL Device Register Interface
@@ -36,7 +38,8 @@* Probe for component register information and return it in map object. */ void cxl_probe_component_regs (struct device *dev,void __iomem *base, -struct cxl_component_reg_map *map) +struct cxl_component_reg_map *map, +unsigned long *caps) {int cap, cap_count;u32 cap_array;
@@ -84,6 +87,7 @@ void cxl_probe_component_regs(struct device *dev, void __iomem *base, decoder_cnt =cxl_hdm_decoder_count (hdr); length =0x20 * decoder_cnt +0x10 ; rmap = &map->hdm_decoder; +set_bit (CXL_DEV_CAP_HDM , caps);break ; }case CXL_CM_CAP_CAP_ID_RAS :
@@ -91,6 +95,7 @@ void cxl_probe_component_regs(struct device *dev, void __iomem *base, offset); length =CXL_RAS_CAPABILITY_LENGTH ; rmap = &map->ras; +set_bit (CXL_DEV_CAP_RAS , caps);break ;default : dev_dbg(dev, "Unknown CM cap ID: %d (0x%x)\n", cap_id,
@@ -113,11 +118,12 @@ EXPORT_SYMBOL_NS_GPL(cxl_probe_component_regs, "CXL");* @dev: Host device of the @base mapping * @base: Mapping of CXL 2.0 8.2.8 CXL Device Register Interface * @map: Map object describing the register block information found +* @caps: capabilities to be set when discovered * * Probe for device register information and return it in map object. */ void cxl_probe_device_regs (struct device *dev,void __iomem *base, -struct cxl_device_reg_map *map) +struct cxl_device_reg_map *map,unsigned long *caps) {int cap, cap_count;u64 cap_array;
@@ -146,10 +152,12 @@ void cxl_probe_device_regs(struct device *dev, void __iomem *base,case CXLDEV_CAP_CAP_ID_DEVICE_STATUS :dev_dbg (dev,"found Status capability (0x%x)\n" , offset); rmap = &map->status; +set_bit (CXL_DEV_CAP_DEV_STATUS , caps);break ;case CXLDEV_CAP_CAP_ID_PRIMARY_MAILBOX :dev_dbg (dev,"found Mailbox capability (0x%x)\n" , offset); rmap = &map->mbox; +set_bit (CXL_DEV_CAP_MAILBOX_PRIMARY , caps);break ;case CXLDEV_CAP_CAP_ID_SECONDARY_MAILBOX :dev_dbg (dev,"found Secondary Mailbox capability (0x%x)\n" , offset);
@@ -157,6 +165,7 @@ void cxl_probe_device_regs(struct device *dev, void __iomem *base,case CXLDEV_CAP_CAP_ID_MEMDEV :dev_dbg (dev,"found Memory Device capability (0x%x)\n" , offset); rmap = &map->memdev; +set_bit (CXL_DEV_CAP_MEMDEV , caps);break ;default :if (cap_id >=0x8000 )
@@ -421,7 +430,7 @@ static void cxl_unmap_regblock(struct cxl_register_map *map) map->base =NULL ; } -static int cxl_probe_regs (struct cxl_register_map *map) +static int cxl_probe_regs (struct cxl_register_map *map,unsigned long *caps) {struct cxl_component_reg_map *comp_map;struct cxl_device_reg_map *dev_map;
@@ -431,12 +440,12 @@ static int cxl_probe_regs(struct cxl_register_map *map)switch (map->reg_type) {case CXL_REGLOC_RBI_COMPONENT : comp_map = &map->component_map; -cxl_probe_component_regs (host, base, comp_map); +cxl_probe_component_regs (host, base, comp_map, caps);dev_dbg (host,"Set up component registers\n" );break ;case CXL_REGLOC_RBI_MEMDEV : dev_map = &map->device_map; -cxl_probe_device_regs (host, base, dev_map); +cxl_probe_device_regs (host, base, dev_map, caps);if (!dev_map->status.valid || !dev_map->mbox.valid || !dev_map->memdev.valid) { dev_err(host, "registers not found: %s%s%s\n",
@@ -455,7 +464,7 @@ static int cxl_probe_regs(struct cxl_register_map *map)return 0 ; } -int cxl_setup_regs (struct cxl_register_map *map) +int cxl_setup_regs (struct cxl_register_map *map,unsigned long *caps) {int rc;
@@ -463,7 +472,7 @@ int cxl_setup_regs(struct cxl_register_map *map)if (rc)return rc; - rc =cxl_probe_regs (map); + rc =cxl_probe_regs (map, caps);cxl_unmap_regblock (map);return rc;
drivers/cxl/cxl.h +6 -3
@@ -4,6 +4,7 @@#ifndef __CXL_H__#define __CXL_H__ +#include <cxl/cxl.h> #include <linux/libnvdimm.h> #include <linux/bitfield.h> #include <linux/notifier.h>
@@ -292,9 +293,9 @@ struct cxl_register_map { };void cxl_probe_component_regs (struct device *dev,void __iomem *base, -struct cxl_component_reg_map *map); +struct cxl_component_reg_map *map,unsigned long *caps);void cxl_probe_device_regs (struct device *dev,void __iomem *base, -struct cxl_device_reg_map *map); +struct cxl_device_reg_map *map,unsigned long *caps);int cxl_map_component_regs (const struct cxl_register_map *map,struct cxl_component_regs *regs,unsigned long map_mask);
@@ -308,7 +309,7 @@ int cxl_find_regblock_instance(struct pci_dev *pdev, enum cxl_regloc_type type, struct cxl_register_map *map, int index);int cxl_find_regblock (struct pci_dev *pdev,enum cxl_regloc_type type,struct cxl_register_map *map); -int cxl_setup_regs (struct cxl_register_map *map); +int cxl_setup_regs (struct cxl_register_map *map,unsigned long *caps);struct cxl_dport ;resource_size_t cxl_rcd_component_reg_phys (struct device *dev,struct cxl_dport *dport);
@@ -609,6 +610,7 @@ struct cxl_dax_region {* @cdat: Cached CDAT data * @cdat_available: Should a CDAT attribute be available in sysfs * @pci_latency: Upstream latency in picoseconds +* @capabilities: those capabilities as defined in device mapped registers */ struct cxl_port {struct device dev;
@@ -632,6 +634,7 @@ struct cxl_port { } cdat;bool cdat_available;long pci_latency; +DECLARE_BITMAP (capabilities,CXL_MAX_CAPS ); };/**
drivers/cxl/cxlmem.h +2 -0
@@ -428,6 +428,7 @@ struct cxl_dpa_perf {* @serial: PCIe Device Serial Number * @type: Generic Memory Class device or Vendor Specific Memory device * @cxl_mbox: CXL mailbox context +* @capabilities: those capabilities as defined in device mapped registers */ struct cxl_dev_state {struct device *dev;
@@ -443,6 +444,7 @@ struct cxl_dev_state {u64 serial;enum cxl_devtype type;struct cxl_mailbox cxl_mbox; +DECLARE_BITMAP (capabilities,CXL_MAX_CAPS ); };static inline struct cxl_dev_state *mbox_to_cxlds (struct cxl_mailbox *cxl_mbox)
drivers/cxl/pci.c +6 -4
@@ -504,7 +504,8 @@ static int cxl_rcrb_get_comp_regs(struct pci_dev *pdev, }static int cxl_pci_setup_regs (struct pci_dev *pdev,enum cxl_regloc_type type, -struct cxl_register_map *map) +struct cxl_register_map *map, +unsigned long *caps) {int rc;
@@ -534,7 +535,7 @@ static int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type,return rc; } -return cxl_setup_regs (map); +return cxl_setup_regs (map, caps); }static int cxl_pci_ras_unmask (struct pci_dev *pdev)
@@ -938,7 +939,8 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)cxl_set_dvsec (cxlds, dvsec); - rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_MEMDEV , &map); + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_MEMDEV , &map, + cxlds->capabilities);if (rc)return rc;
@@ -951,7 +953,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)* still be useful for management functions so don't return an error. */ rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_COMPONENT , - &cxlds->reg_map); + &cxlds->reg_map, cxlds->capabilities);if (rc)dev_warn (&pdev->dev,"No component registers (%d)\n" , rc);else if (!cxlds->reg_map.component_map.ras.valid)
include/cxl/cxl.h +19 -0
@@ -12,6 +12,25 @@ enum cxl_resource { CXL_RES_PMEM, }; +/* Capabilities as defined for: +* +* Component Registers (Table 8-22 CXL 3.1 specification) +* Device Registers (8.2.8.2.1 CXL 3.1 specification) +* +* and currently being used for kernel CXL support. +*/ + +enum cxl_dev_cap { +/* capabilities from Component Registers */ +CXL_DEV_CAP_RAS , +CXL_DEV_CAP_HDM , +/* capabilities from Device Registers */ +CXL_DEV_CAP_DEV_STATUS , +CXL_DEV_CAP_MAILBOX_PRIMARY , +CXL_DEV_CAP_MEMDEV , +CXL_MAX_CAPS =64 +}; +struct cxl_dev_state ;struct device ;
Signature · 1 line
2.17.1
Re: [PATCH v9 03/27] cxl: add capabilities field to cxl_dev_state and cxl_port
Quoted 6 lines · On Mon, 30 Dec 2024 21:44:21 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
Type2 devices have some Type3 functionalities as optional like an mbox or an hdm decoder, and CXL core needs a way to know what an CXL accelerator implements.
Quoted 7 lines
Add a new field to
cxl_dev_statefor keeping device capabilities as discovered during initialization. Add same field tocxl_portas registers discovery is also used during port initialization.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Ben Cheatham <[email protected]>Reviewed-by Fan Ni <[email protected]>
Comment in thread on v8. I don't see a reason to have any specific bitmap length - just use a final entry in the enum without a value set to let us know how long it actually is.
Using the bit / bitmap functions should work fine without constraining that to any particular value - also allowing for greater than 64 entries with no need to fix up call sites etc.
Quoted 5 lines
drivers/cxl/core/regs.c +0
-0
drivers/cxl/core/regs.c
Quoted 10 lines
drivers/cxl/core/regs.c +9
-0@@ -4,6 +4,7 @@ +enum cxl_dev_cap { +/* capabilities from Component Registers */ +CXL_DEV_CAP_RAS , +CXL_DEV_CAP_HDM , +/* capabilities from Device Registers */ +CXL_DEV_CAP_DEV_STATUS , +CXL_DEV_CAP_MAILBOX_PRIMARY , +CXL_DEV_CAP_MEMDEV , +CXL_MAX_CAPS =64
As in v8. I'm not seeing any reason for this. If you need a bitmap to be a particular number of unsigned longs, then that code should be fixed. (only exception being compile time constant bitmaps where this is tricky to do!)
Obviously I replied with that to v8 after you posted this so time machines aside no way you could have acted on it yet.
Jonathan
Quoted 5 lines
drivers/cxl/core/regs.c +2
-0+}; +struct cxl_dev_state ;struct device ;
Re: [PATCH v9 03/27] cxl: add capabilities field to cxl_dev_state and cxl_port
Quoted 13 lines · Jonathan Cameron
Quoted 10 lines · On Mon, 30 Dec 2024 21:44:21 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
Type2 devices have some Type3 functionalities as optional like an mbox or an hdm decoder, and CXL core needs a way to know what an CXL accelerator implements.
Add a new field to
cxl_dev_statefor keeping device capabilities as discovered during initialization. Add same field tocxl_portas registers discovery is also used during port initialization.
Quoted 6 lines
Quoted 3 lines
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Ben Cheatham <[email protected]>Reviewed-by Fan Ni <[email protected]>Comment in thread on v8. I don't see a reason to have any specific bitmap length - just use a final entry in the enum without a value set to let us know how long it actually is.
I could do this but it implies to clear/zeroing the bitmaps with the final entry value and to mask bitmaps with that when comparing them.
I tried to avoid the masking, and it led to that use of sizeof and then CXL_MAX_CAPS=64.
Quoted 35 lines
Using the bit / bitmap functions should work fine without constraining that to any particular value - also allowing for greater than 64 entries with no need to fix up call sites etc.
Quoted 5 lines
drivers/cxl/core/regs.c +0
-0drivers/cxl/core/regs.c
Quoted 9 lines
drivers/cxl/core/regs.c +9
-0@@ -4,6 +4,7 @@ +enum cxl_dev_cap { +/* capabilities from Component Registers */ +CXL_DEV_CAP_RAS , +CXL_DEV_CAP_HDM , +/* capabilities from Device Registers */ +CXL_DEV_CAP_DEV_STATUS , +CXL_DEV_CAP_MAILBOX_PRIMARY , +CXL_DEV_CAP_MEMDEV , +CXL_MAX_CAPS =64 As in v8. I'm not seeing any reason for this. If you need a bitmap to be a particular number of unsigned longs, then that code should be fixed. (only exception being compile time constant bitmaps where this is tricky to do!)
Obviously I replied with that to v8 after you posted this so time machines aside no way you could have acted on it yet.
Jonathan
Quoted 5 lines
drivers/cxl/core/regs.c +2
-0+}; +struct cxl_dev_state ;struct device ;
Re: [PATCH v9 03/27] cxl: add capabilities field to cxl_dev_state and cxl_port
Quoted 17 lines · On Fri, 3 Jan 2025 07:20:48 +0000 Alejandro Lucero Palau <[email protected]>…
Quoted 16 lines · Jonathan Cameron
Quoted 13 lines · On Mon, 30 Dec 2024 21:44:21 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
Type2 devices have some Type3 functionalities as optional like an mbox or an hdm decoder, and CXL core needs a way to know what an CXL accelerator implements.
Add a new field to
cxl_dev_statefor keeping device capabilities as discovered during initialization. Add same field tocxl_portas registers discovery is also used during port initialization.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Ben Cheatham <[email protected]>Reviewed-by Fan Ni <[email protected]>
Quoted 7 lines
Quoted 3 lines
Comment in thread on v8. I don't see a reason to have any specific bitmap length - just use a final entry in the enum without a value set to let us know how long it actually is.
I could do this but it implies to clear/zeroing the bitmaps with the final entry value and to mask bitmaps with that when comparing them.
Yes but that is automatic if you use the bitmap functions throughout.
Quoted 3 lines
I tried to avoid the masking, and it led to that use of sizeof and then CXL_MAX_CAPS=64.
Don't avoid it. You are creating maintenance pain for a bit of unnecessary micro optimization. Just make sure to treat this bitmap as a bitmap in all paths and there will be not reason for a reviewer to ever have to care what this value is and whether enough bits are zero etc.
Jonathan
Quoted 37 lines
Quoted 37 lines
Using the bit / bitmap functions should work fine without constraining that to any particular value - also allowing for greater than 64 entries with no need to fix up call sites etc.
Quoted 5 lines
drivers/cxl/core/regs.c +0
-0drivers/cxl/core/regs.c
Quoted 9 lines
drivers/cxl/core/regs.c +9
-0@@ -4,6 +4,7 @@ +enum cxl_dev_cap { +/* capabilities from Component Registers */ +CXL_DEV_CAP_RAS , +CXL_DEV_CAP_HDM , +/* capabilities from Device Registers */ +CXL_DEV_CAP_DEV_STATUS , +CXL_DEV_CAP_MAILBOX_PRIMARY , +CXL_DEV_CAP_MEMDEV , +CXL_MAX_CAPS =64 As in v8. I'm not seeing any reason for this. If you need a bitmap to be a particular number of unsigned longs, then that code should be fixed. (only exception being compile time constant bitmaps where this is tricky to do!)
Obviously I replied with that to v8 after you posted this so time machines aside no way you could have acted on it yet.
Jonathan
Quoted 5 lines
drivers/cxl/core/regs.c +2
-0+}; +struct cxl_dev_state ;struct device ;
Re: [PATCH v9 03/27] cxl: add capabilities field to cxl_dev_state and cxl_port
Quoted 20 lines · Jonathan Cameron
Quoted 17 lines · On Fri, 3 Jan 2025 07:20:48 +0000 Alejandro Lucero Palau <[email protected]>…
Quoted 16 lines · Jonathan Cameron
Quoted 13 lines · On Mon, 30 Dec 2024 21:44:21 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
Type2 devices have some Type3 functionalities as optional like an mbox or an hdm decoder, and CXL core needs a way to know what an CXL accelerator implements.
Add a new field to
cxl_dev_statefor keeping device capabilities as discovered during initialization. Add same field tocxl_portas registers discovery is also used during port initialization.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Ben Cheatham <[email protected]>Reviewed-by Fan Ni <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Comment in thread on v8. I don't see a reason to have any specific bitmap length - just use a final entry in the enum without a value set to let us know how long it actually is.
I could do this but it implies to clear/zeroing the bitmaps with the final entry value and to mask bitmaps with that when comparing them.
Yes but that is automatic if you use the bitmap functions throughout.
Oh, that is true.
Quoted 6 lines
Quoted 2 lines
I tried to avoid the masking, and it led to that use of sizeof and then CXL_MAX_CAPS=64.
Don't avoid it. You are creating maintenance pain for a bit of unnecessary micro optimization. Just make sure to treat this bitmap as a bitmap in all paths and there will be not reason for a reviewer to ever have to care what this value is and whether enough bits are zero etc.
I'm afraid I have been in the wrong path regarding the use of the bitmap API.
I even initially implemented my own bitmap_subset because I did not notice there was one already there, and I think that was the starting point of this chain of bad decisions. Because I did implement it poorly it led to keep with the wrong assumptions when I was told to use the existing one.
Happy to have you pointing this out. I'll fix it.
Thank you!
Quoted 41 lines
Jonathan
Quoted 36 lines
Quoted 36 lines
Using the bit / bitmap functions should work fine without constraining that to any particular value - also allowing for greater than 64 entries with no need to fix up call sites etc.
Quoted 5 lines
drivers/cxl/core/regs.c +0
-0drivers/cxl/core/regs.c
Quoted 9 lines
drivers/cxl/core/regs.c +9
-0@@ -4,6 +4,7 @@ +enum cxl_dev_cap { +/* capabilities from Component Registers */ +CXL_DEV_CAP_RAS , +CXL_DEV_CAP_HDM , +/* capabilities from Device Registers */ +CXL_DEV_CAP_DEV_STATUS , +CXL_DEV_CAP_MAILBOX_PRIMARY , +CXL_DEV_CAP_MEMDEV , +CXL_MAX_CAPS =64 As in v8. I'm not seeing any reason for this. If you need a bitmap to be a particular number of unsigned longs, then that code should be fixed. (only exception being compile time constant bitmaps where this is tricky to do!)
Obviously I replied with that to v8 after you posted this so time machines aside no way you could have acted on it yet.
Jonathan
Quoted 5 lines
drivers/cxl/core/regs.c +2
-0+}; +struct cxl_dev_state ;struct device ;
Re: [PATCH v9 03/27] cxl: add capabilities field to cxl_dev_state and cxl_port
In reply to [email protected]Quoted 22 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Type2 devices have some Type3 functionalities as optional like an mbox or an hdm decoder, and CXL core needs a way to know what an CXL accelerator implements.
Add a new field to
cxl_dev_statefor keeping device capabilities as discovered during initialization. Add same field tocxl_portas registers discovery is also used during port initialization.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Ben Cheatham <[email protected]>Reviewed-by Fan Ni <[email protected]>--- drivers/cxl/core/port.c | 11 +++++++---- drivers/cxl/core/regs.c | 23 ++++++++++++++++------- drivers/cxl/cxl.h | 9 ++++++--- drivers/cxl/cxlmem.h | 2 ++ drivers/cxl/pci.c | 10 ++++++---- include/cxl/cxl.h | 19 +++++++++++++++++++ 6 files changed, 56 insertions(+), 18 deletions(-)
[..]
Quoted 28 lines
drivers/cxl/core/regs.c +4
-1@@ -113,11 +118,12 @@ EXPORT_SYMBOL_NS_GPL(cxl_probe_component_regs, "CXL");* @dev: Host device of the @base mapping * @base: Mapping of CXL 2.0 8.2.8 CXL Device Register Interface * @map: Map object describing the register block information found +* @caps: capabilities to be set when discovered * * Probe for device register information and return it in map object. */ void cxl_probe_device_regs (struct device *dev,void __iomem *base, -struct cxl_device_reg_map *map) +struct cxl_device_reg_map *map,unsigned long *caps) {int cap, cap_count;u64 cap_array;@@ -146,10 +152,12 @@ void cxl_probe_device_regs(struct device *dev, void __iomem *base,case CXLDEV_CAP_CAP_ID_DEVICE_STATUS :dev_dbg (dev,"found Status capability (0x%x)\n" , offset); rmap = &map->status; +set_bit (CXL_DEV_CAP_DEV_STATUS , caps);break ;case CXLDEV_CAP_CAP_ID_PRIMARY_MAILBOX :dev_dbg (dev,"found Mailbox capability (0x%x)\n" , offset); rmap = &map->mbox; +set_bit (CXL_DEV_CAP_MAILBOX_PRIMARY , caps);break ;case CXLDEV_CAP_CAP_ID_SECONDARY_MAILBOX :dev_dbg (dev,"found Secondary Mailbox capability (0x%x)\n" , offset);
drivers/cxl/core/regs.c void cxl_probe_device_regs(struct device *dev, void __iomem *base, · line 168
Quoted 4 lines
drivers/cxl/core/regs.c +1
-0@@ -157,6 +165,7 @@ void cxl_probe_device_regs(struct device *dev, void __iomem *base,case CXLDEV_CAP_CAP_ID_MEMDEV :dev_dbg (dev,"found Memory Device capability (0x%x)\n" , offset); rmap = &map->memdev; +set_bit (CXL_DEV_CAP_MEMDEV , caps);
I do not understand the rationale for a capability bitmap. There is already a 'valid' flag in 'struct cxl_reg_map' for all register blocks. Any optional core functionality should key off those existing flags.
Re: [PATCH v9 03/27] cxl: add capabilities field to cxl_dev_state and cxl_port
Quoted 51 lines · Dan Williams
Quoted 22 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Type2 devices have some Type3 functionalities as optional like an mbox or an hdm decoder, and CXL core needs a way to know what an CXL accelerator implements.
Add a new field to
cxl_dev_statefor keeping device capabilities as discovered during initialization. Add same field tocxl_portas registers discovery is also used during port initialization.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Ben Cheatham <[email protected]>Reviewed-by Fan Ni <[email protected]>--- drivers/cxl/core/port.c | 11 +++++++---- drivers/cxl/core/regs.c | 23 ++++++++++++++++------- drivers/cxl/cxl.h | 9 ++++++--- drivers/cxl/cxlmem.h | 2 ++ drivers/cxl/pci.c | 10 ++++++---- include/cxl/cxl.h | 19 +++++++++++++++++++ 6 files changed, 56 insertions(+), 18 deletions(-)[..]
Quoted 27 lines
drivers/cxl/core/regs.c +4
-1@@ -113,11 +118,12 @@ EXPORT_SYMBOL_NS_GPL(cxl_probe_component_regs, "CXL");* @dev: Host device of the @base mapping * @base: Mapping of CXL 2.0 8.2.8 CXL Device Register Interface * @map: Map object describing the register block information found +* @caps: capabilities to be set when discovered * * Probe for device register information and return it in map object. */ void cxl_probe_device_regs (struct device *dev,void __iomem *base, -struct cxl_device_reg_map *map) +struct cxl_device_reg_map *map,unsigned long *caps) {int cap, cap_count;u64 cap_array;@@ -146,10 +152,12 @@ void cxl_probe_device_regs(struct device *dev, void __iomem *base,case CXLDEV_CAP_CAP_ID_DEVICE_STATUS :dev_dbg (dev,"found Status capability (0x%x)\n" , offset); rmap = &map->status; +set_bit (CXL_DEV_CAP_DEV_STATUS , caps);break ;case CXLDEV_CAP_CAP_ID_PRIMARY_MAILBOX :dev_dbg (dev,"found Mailbox capability (0x%x)\n" , offset); rmap = &map->mbox; +set_bit (CXL_DEV_CAP_MAILBOX_PRIMARY , caps);break ;case CXLDEV_CAP_CAP_ID_SECONDARY_MAILBOX :dev_dbg (dev,"found Secondary Mailbox capability (0x%x)\n" , offset);
Quoted 8 lines
drivers/cxl/core/regs.c void cxl_probe_device_regs(struct device *dev, void __iomem *base, · line 168
Quoted 5 lines
drivers/cxl/core/regs.c +1
-0@@ -157,6 +165,7 @@ void cxl_probe_device_regs(struct device *dev, void __iomem *base,case CXLDEV_CAP_CAP_ID_MEMDEV :dev_dbg (dev,"found Memory Device capability (0x%x)\n" , offset); rmap = &map->memdev; +set_bit (CXL_DEV_CAP_MEMDEV , caps);I do not understand the rationale for a capability bitmap. There is already a 'valid' flag in 'struct
cxl_reg_map' for all register blocks. Any optional core functionality should key off those existing flags.
The current code is based on Type3 and the registers and capabilities are defined as mandatory, I think except RAS.
With Type2 we have optional capabilities like mailbox and hdm, and the code probing the regs should not make any assumption about what should be there.
With this patchset the capabilities to expect are set by the accel driver and compared with those discovered when probing CXL regs. Although the capabilities check could use the cxl_reg_map, I consider it is convenient to have a capability bitmap for keeping those discovered and easily checking them against those expected by the accel driver, and reporting them (if necessary) as well without further processing.
Re: [PATCH v9 03/27] cxl: add capabilities field to cxl_dev_state and cxl_port
Alejandro Lucero Palau wrote:
[..]
Quoted 12 lines
Quoted 3 lines
I do not understand the rationale for a capability bitmap. There is already a 'valid' flag in 'struct
cxl_reg_map' for all register blocks. Any optional core functionality should key off those existing flags.The current code is based on Type3 and the registers and capabilities are defined as mandatory, I think except RAS.
With Type2 we have optional capabilities like mailbox and hdm, and the code probing the regs should not make any assumption about what should be there.
Quoted 6 lines
With this patchset the capabilities to expect are set by the accel driver and compared with those discovered when probing CXL regs. Although the capabilities check could use the
cxl_reg_map, I consider it is convenient to have a capability bitmap for keeping those discovered and easily checking them against those expected by the accel driver, and reporting them (if necessary) as well without further processing.
That is just on-loading redundancy to the core data structure for a workalike way of checking the available register blocks. The 'struct cxl_reg_map' already tracks this, the only needed change is to move the responsibility for validating those bits to the driver. That work is nearly identical to teaching the driver to inject a capability bitmask, but more flexible for the case where the driver wants to optionally enable functionality. In that latter case it will end up checking the valid-bits anyway.
PATCH v9 4/27 cxl/pci: add check for validating capabilities
In reply to [email protected]From: Alejandro Lucero <[email protected]>
During CXL device initialization supported capabilities by the device are discovered. Type3 and Type2 devices have different mandatory capabilities and a Type2 expects a specific set including optional capabilities.
Add a function for checking expected capabilities against those found during initialization and allow those mandatory/expected capabilities to be a subset of the capabilities found.
Rely on this function for validating capabilities instead of when CXL regs are probed.
--- drivers/cxl/core/pci.c | 16 ++++++++++++++++ drivers/cxl/core/regs.c | 9 --------- drivers/cxl/pci.c | 24 ++++++++++++++++++++++++ include/cxl/cxl.h | 3 +++ 4 files changed, 43 insertions(+), 9 deletions(-)
drivers/cxl/core/pci.c +16 -0
@@ -8,6 +8,7 @@#include <linux/pci.h> #include <linux/pci-doe.h> #include <linux/aer.h> +#include <cxl/cxl.h> #include <cxlpci.h> #include <cxlmem.h> #include <cxl.h>
@@ -1055,3 +1056,18 @@ int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c)return 0 ; } + +bool cxl_pci_check_caps (struct cxl_dev_state *cxlds,unsigned long *expected_caps, +unsigned long *current_caps) +{ + +if (current_caps) +bitmap_copy (current_caps, cxlds->capabilities,CXL_MAX_CAPS ); + +dev_dbg (cxlds->dev,"Checking cxlds caps 0x%pb vs expected caps 0x%pb\n" , + cxlds->capabilities, expected_caps); + +/* Checking a minimum of mandatory/expected capabilities */ +return bitmap_subset (expected_caps, cxlds->capabilities,CXL_MAX_CAPS ); +} +EXPORT_SYMBOL_NS_GPL (cxl_pci_check_caps,"CXL" );
drivers/cxl/core/regs.c +0 -9
@@ -446,15 +446,6 @@ static int cxl_probe_regs(struct cxl_register_map *map, unsigned long *caps)case CXL_REGLOC_RBI_MEMDEV : dev_map = &map->device_map;cxl_probe_device_regs (host, base, dev_map, caps); -if (!dev_map->status.valid || !dev_map->mbox.valid || - !dev_map->memdev.valid) { -dev_err (host,"registers not found: %s%s%s\n" , - !dev_map->status.valid ?"status " :"" , - !dev_map->mbox.valid ?"mbox " :"" , - !dev_map->memdev.valid ?"memdev " :"" ); -return -ENXIO ; - } -dev_dbg (host,"Probing device registers...\n" );break ;default :
drivers/cxl/pci.c +24 -0
@@ -903,6 +903,8 @@ __ATTRIBUTE_GROUPS(cxl_rcd);static int cxl_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct pci_host_bridge *host_bridge =pci_find_host_bridge (pdev->bus); +DECLARE_BITMAP (expected,CXL_MAX_CAPS ); +DECLARE_BITMAP (found,CXL_MAX_CAPS );struct cxl_memdev_state *mds;struct cxl_dev_state *cxlds;struct cxl_register_map map;
@@ -964,6 +966,28 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)dev_dbg (&pdev->dev,"Failed to map RAS capability.\n" ); +bitmap_clear (expected,0 ,CXL_MAX_CAPS ); + +/* +* These are the mandatory capabilities for a Type3 device. +* Only checking capabilities used by current Linux drivers. +*/ +set_bit (CXL_DEV_CAP_HDM , expected); +set_bit (CXL_DEV_CAP_DEV_STATUS , expected); +set_bit (CXL_DEV_CAP_MAILBOX_PRIMARY , expected); +set_bit (CXL_DEV_CAP_MEMDEV , expected); + +/* +* Checking mandatory caps are there as, at least, a subset of those +* found. +*/ +if (!cxl_pci_check_caps (cxlds, expected, found)) { +dev_err (&pdev->dev, +"Expected mandatory capabilities not found: (%pb - %pb)\n" , + expected, found); +return -ENXIO ; + } + rc =cxl_pci_type3_init_mailbox (cxlds);if (rc)return rc;
include/cxl/cxl.h +3 -0
@@ -40,4 +40,7 @@ void cxl_set_dvsec(struct cxl_dev_state *cxlds, u16 dvsec);void cxl_set_serial (struct cxl_dev_state *cxlds,u64 serial);int cxl_set_resource (struct cxl_dev_state *cxlds,struct resource res,enum cxl_resource ); +bool cxl_pci_check_caps (struct cxl_dev_state *cxlds, +unsigned long *expected_caps, +unsigned long *current_caps);#endif
Signature · 1 line
2.17.1
Re: [PATCH v9 04/27] cxl/pci: add check for validating capabilities
Quoted 11 lines · On Mon, 30 Dec 2024 21:44:22 +0000 [email protected] wrote:
From: Alejandro Lucero <[email protected]>
During CXL device initialization supported capabilities by the device are discovered. Type3 and Type2 devices have different mandatory capabilities and a Type2 expects a specific set including optional capabilities.
Add a function for checking expected capabilities against those found during initialization and allow those mandatory/expected capabilities to be a subset of the capabilities found.
Quoted 5 lines
Rely on this function for validating capabilities instead of when CXL regs are probed.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Zhi Wang <[email protected]>
Re: [PATCH v9 04/27] cxl/pci: add check for validating capabilities
In reply to [email protected]Quoted 44 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
During CXL device initialization supported capabilities by the device are discovered. Type3 and Type2 devices have different mandatory capabilities and a Type2 expects a specific set including optional capabilities.
Add a function for checking expected capabilities against those found during initialization and allow those mandatory/expected capabilities to be a subset of the capabilities found.
Rely on this function for validating capabilities instead of when CXL regs are probed.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Zhi Wang <[email protected]>--- drivers/cxl/core/pci.c | 16 ++++++++++++++++ drivers/cxl/core/regs.c | 9 --------- drivers/cxl/pci.c | 24 ++++++++++++++++++++++++ include/cxl/cxl.h | 3 +++ 4 files changed, 43 insertions(+), 9 deletions(-)drivers/cxl/core/pci.c +6
-0@@ -8,6 +8,7 @@#include <linux/pci.h> #include <linux/pci-doe.h> #include <linux/aer.h> +#include <cxl/cxl.h> #include <cxlpci.h> #include <cxlmem.h> #include <cxl.h> @@ -1055,3 +1056,18 @@ int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c)return 0 ; } + +bool cxl_pci_check_caps (struct cxl_dev_state *cxlds,unsigned long *expected_caps, +unsigned long *current_caps) +{ +
drivers/cxl/core/pci.c int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c) · line 1073
Quoted 10 lines
drivers/cxl/core/pci.c +10
-0+if (current_caps) +bitmap_copy (current_caps, cxlds->capabilities,CXL_MAX_CAPS ); + +dev_dbg (cxlds->dev,"Checking cxlds caps 0x%pb vs expected caps 0x%pb\n" , + cxlds->capabilities, expected_caps); + +/* Checking a minimum of mandatory/expected capabilities */ +return bitmap_subset (expected_caps, cxlds->capabilities,CXL_MAX_CAPS ); +} +EXPORT_SYMBOL_NS_GPL (cxl_pci_check_caps,"CXL" );
cxl_setup_regs() is already exported from the core. Just make the caller of cxl_setup_regs() responsible for checking the valid bits per its constraints rather a new mechanism.
Re: [PATCH v9 04/27] cxl/pci: add check for validating capabilities
Quoted 50 lines · Dan Williams
Quoted 49 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
During CXL device initialization supported capabilities by the device are discovered. Type3 and Type2 devices have different mandatory capabilities and a Type2 expects a specific set including optional capabilities.
Add a function for checking expected capabilities against those found during initialization and allow those mandatory/expected capabilities to be a subset of the capabilities found.
Rely on this function for validating capabilities instead of when CXL regs are probed.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Zhi Wang <[email protected]>--- drivers/cxl/core/pci.c | 16 ++++++++++++++++ drivers/cxl/core/regs.c | 9 --------- drivers/cxl/pci.c | 24 ++++++++++++++++++++++++ include/cxl/cxl.h | 3 +++ 4 files changed, 43 insertions(+), 9 deletions(-)drivers/cxl/core/pci.c +11
-0@@ -8,6 +8,7 @@#include <linux/pci.h> #include <linux/pci-doe.h> #include <linux/aer.h> +#include <cxl/cxl.h> #include <cxlpci.h> #include <cxlmem.h> #include <cxl.h> @@ -1055,3 +1056,18 @@ int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c)return 0 ; } + +bool cxl_pci_check_caps (struct cxl_dev_state *cxlds,unsigned long *expected_caps, +unsigned long *current_caps) +{ + +if (current_caps) +bitmap_copy (current_caps, cxlds->capabilities,CXL_MAX_CAPS ); + +dev_dbg (cxlds->dev,"Checking cxlds caps 0x%pb vs expected caps 0x%pb\n" , + cxlds->capabilities, expected_caps);
Quoted 8 lines
drivers/cxl/core/pci.c int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c) · line 1073
Quoted 5 lines
drivers/cxl/core/pci.c +5
-0+ +/* Checking a minimum of mandatory/expected capabilities */ +return bitmap_subset (expected_caps, cxlds->capabilities,CXL_MAX_CAPS ); +} +EXPORT_SYMBOL_NS_GPL (cxl_pci_check_caps,"CXL" );
cxl_setup_regs()is already exported from the core. Just make the caller ofcxl_setup_regs()responsible for checking the valid bits per its constraints rather a new mechanism.
I prefer to keep the regs setup separated from the checks, and I think your suggestion involves a higher impact on the current code.
Note this is the API for accel drivers and by design what the accel driver can do with cxl structs is restricted. The patchset adds a new function in patch 6 for regs setup by accel drivers.
Re: [PATCH v9 04/27] cxl/pci: add check for validating capabilities
Quoted 61 lines · Alejandro Lucero Palau
Quoted 50 lines · Dan Williams
Quoted 49 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
During CXL device initialization supported capabilities by the device are discovered. Type3 and Type2 devices have different mandatory capabilities and a Type2 expects a specific set including optional capabilities.
Add a function for checking expected capabilities against those found during initialization and allow those mandatory/expected capabilities to be a subset of the capabilities found.
Rely on this function for validating capabilities instead of when CXL regs are probed.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Zhi Wang <[email protected]>--- drivers/cxl/core/pci.c | 16 ++++++++++++++++ drivers/cxl/core/regs.c | 9 --------- drivers/cxl/pci.c | 24 ++++++++++++++++++++++++ include/cxl/cxl.h | 3 +++ 4 files changed, 43 insertions(+), 9 deletions(-)drivers/cxl/core/pci.c +11
-0@@ -8,6 +8,7 @@#include <linux/pci.h> #include <linux/pci-doe.h> #include <linux/aer.h> +#include <cxl/cxl.h> #include <cxlpci.h> #include <cxlmem.h> #include <cxl.h> @@ -1055,3 +1056,18 @@ int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c)return 0 ; } + +bool cxl_pci_check_caps (struct cxl_dev_state *cxlds,unsigned long *expected_caps, +unsigned long *current_caps) +{ + +if (current_caps) +bitmap_copy (current_caps, cxlds->capabilities,CXL_MAX_CAPS ); + +dev_dbg (cxlds->dev,"Checking cxlds caps 0x%pb vs expected caps 0x%pb\n" , + cxlds->capabilities, expected_caps);Quoted 8 lines
drivers/cxl/core/pci.c int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c) · line 1073
Quoted 5 lines
drivers/cxl/core/pci.c +5
-0+ +/* Checking a minimum of mandatory/expected capabilities */ +return bitmap_subset (expected_caps, cxlds->capabilities,CXL_MAX_CAPS ); +} +EXPORT_SYMBOL_NS_GPL (cxl_pci_check_caps,"CXL" );
cxl_setup_regs()is already exported from the core. Just make the caller ofcxl_setup_regs()responsible for checking the valid bits per its constraints rather a new mechanism.
Quoted 2 lines
I prefer to keep the regs setup separated from the checks, and I think your suggestion involves a higher impact on the current code.
Yes, it moves complexity to the leaf consumers where it belongs.
Quoted 3 lines
Note this is the API for accel drivers and by design what the accel driver can do with cxl structs is restricted. The patchset adds a new function in patch 6 for regs setup by accel drivers.
"restricted" as in "least privilege design"? There is nothing in 'struct cxl_reg_map' that needs least privilege restrictions.
PATCH v9 5/27 cxl: move pci generic code
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Inside cxl/core/pci.c there are helpers for CXL PCIe initialization meanwhile cxl/pci.c implements the functionality for a Type3 device initialization.
Move helper functions from cxl/pci.c to cxl/core/pci.c in order to be exported and shared with CXL Type2 device initialization.
--- drivers/cxl/core/pci.c | 73 ++++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlpci.h | 3 ++ drivers/cxl/pci.c | 71 ---------------------------------------- 3 files changed, 76 insertions(+), 71 deletions(-)
drivers/cxl/core/pci.c +73 -0
@@ -1034,6 +1034,79 @@ bool cxl_endpoint_decoder_reset_detected(struct cxl_port *port) }EXPORT_SYMBOL_NS_GPL (cxl_endpoint_decoder_reset_detected,"CXL" ); +/* +* Assume that any RCIEP that emits the CXL memory expander class code +* is an RCD +*/ +bool is_cxl_restricted (struct pci_dev *pdev) +{ +return pci_pcie_type (pdev) ==PCI_EXP_TYPE_RC_END ; +} +EXPORT_SYMBOL_NS_GPL (is_cxl_restricted,"CXL" ); + +static int cxl_rcrb_get_comp_regs (struct pci_dev *pdev, +struct cxl_register_map *map, +struct cxl_dport *dport) +{ +resource_size_t component_reg_phys; + + *map = (struct cxl_register_map ) { + .host = &pdev->dev, + .resource =CXL_RESOURCE_NONE , + }; + + struct cxl_port *port __free(put_cxl_port) = +cxl_pci_find_port (pdev, &dport); +if (!port) +return -EPROBE_DEFER ; + + component_reg_phys =cxl_rcd_component_reg_phys (&pdev->dev, dport); +if (component_reg_phys ==CXL_RESOURCE_NONE ) +return -ENXIO ; + + map->resource = component_reg_phys; + map->reg_type =CXL_REGLOC_RBI_COMPONENT ; + map->max_size =CXL_COMPONENT_REG_BLOCK_SIZE ; + +return 0 ; +} + +int cxl_pci_setup_regs (struct pci_dev *pdev,enum cxl_regloc_type type, +struct cxl_register_map *map, +unsigned long *caps) +{ +int rc; + + rc =cxl_find_regblock (pdev, type, map); + +/* +* If the Register Locator DVSEC does not exist, check if it +* is an RCH and try to extract the Component Registers from +* an RCRB. +*/ +if (rc && type ==CXL_REGLOC_RBI_COMPONENT &&is_cxl_restricted (pdev)) { +struct cxl_dport *dport; + struct cxl_port *port __free(put_cxl_port) = +cxl_pci_find_port (pdev, &dport); +if (!port) +return -EPROBE_DEFER ; + + rc =cxl_rcrb_get_comp_regs (pdev, map, dport); +if (rc) +return rc; + + rc =cxl_dport_map_rcd_linkcap (pdev, dport); +if (rc) +return rc; + + }else if (rc) { +return rc; + } + +return cxl_setup_regs (map, caps); +} +EXPORT_SYMBOL_NS_GPL (cxl_pci_setup_regs,"CXL" ); +int cxl_pci_get_bandwidth (struct pci_dev *pdev,struct access_coordinate *c) {int speed, bw;
drivers/cxl/cxlpci.h +3 -0
@@ -113,4 +113,7 @@ void read_cdat_data(struct cxl_port *port);void cxl_cor_error_detected (struct pci_dev *pdev);pci_ers_result_t cxl_error_detected (struct pci_dev *pdev,pci_channel_state_t state); +bool is_cxl_restricted (struct pci_dev *pdev); +int cxl_pci_setup_regs (struct pci_dev *pdev,enum cxl_regloc_type type, +struct cxl_register_map *map,unsigned long *caps);#endif /* __CXL_PCI_H__ */
drivers/cxl/pci.c +0 -71
77 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v9 05/27] cxl: move pci generic code
Quoted 6 lines · On Mon, 30 Dec 2024 21:44:23 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
Inside
cxl/core/pci.cthere are helpers for CXL PCIe initialization meanwhilecxl/pci.cimplements the functionality for a Type3 device initialization.
Quoted 7 lines
Move helper functions from
cxl/pci.ctocxl/core/pci.cin order to be exported and shared with CXL Type2 device initialization.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Ben Cheatham <[email protected]>Reviewed-by Fan Ni <[email protected]>
Re: [PATCH v9 05/27] cxl: move pci generic code
In reply to [email protected]Quoted 26 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Inside
cxl/core/pci.cthere are helpers for CXL PCIe initialization meanwhilecxl/pci.cimplements the functionality for a Type3 device initialization.Move helper functions from
cxl/pci.ctocxl/core/pci.cin order to be exported and shared with CXL Type2 device initialization.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Ben Cheatham <[email protected]>Reviewed-by Fan Ni <[email protected]>--- drivers/cxl/core/pci.c | 73 ++++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlpci.h | 3 ++ drivers/cxl/pci.c | 71 ---------------------------------------- 3 files changed, 76 insertions(+), 71 deletions(-)drivers/cxl/core/pci.c +0
-0@@ -1034,6 +1034,79 @@ bool cxl_endpoint_decoder_reset_detected(struct cxl_port *port) }EXPORT_SYMBOL_NS_GPL (cxl_endpoint_decoder_reset_detected,"CXL" );
drivers/cxl/core/pci.c bool cxl_endpoint_decoder_reset_detected(struct cxl_port *port) · line 1045
Quoted 10 lines
drivers/cxl/core/pci.c +9
-0+/* +* Assume that any RCIEP that emits the CXL memory expander class code +* is an RCD +*/ +bool is_cxl_restricted (struct pci_dev *pdev) +{ +return pci_pcie_type (pdev) ==PCI_EXP_TYPE_RC_END ; +} +EXPORT_SYMBOL_NS_GPL (is_cxl_restricted,"CXL" );
ok, so v9 is missing my v8 comments:
PATCH v9 6/27 cxl: add function for type2 cxl regs setup
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Create a new function for a type2 device initialising cxl_dev_state struct regarding cxl regs setup and mapping.
--- drivers/cxl/core/pci.c | 51 ++++++++++++++++++++++++++++++++++++++++++ include/cxl/cxl.h | 2 ++ 2 files changed, 53 insertions(+)
drivers/cxl/core/pci.c +51 -0
@@ -1107,6 +1107,57 @@ int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, }EXPORT_SYMBOL_NS_GPL (cxl_pci_setup_regs,"CXL" ); +static int cxl_pci_setup_memdev_regs (struct pci_dev *pdev, +struct cxl_dev_state *cxlds) +{ +struct cxl_register_map map; +int rc; + + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_MEMDEV , &map, + cxlds->capabilities); +/* +* This call can return -ENODEV if regs not found. This is not an error +* for Type2 since these regs are not mandatory. If they do exist then +* mapping them should not fail. If they should exist, it is with driver +* calling cxl_pci_check_caps where the problem should be found. +*/ +if (rc == -ENODEV ) +return 0 ; + +if (rc) +return rc; + +return cxl_map_device_regs (&map, &cxlds->regs.device_regs); +} + +int cxl_pci_accel_setup_regs (struct pci_dev *pdev,struct cxl_dev_state *cxlds) +{ +int rc; + + rc =cxl_pci_setup_memdev_regs (pdev, cxlds); +if (rc) +return rc; + + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_COMPONENT , + &cxlds->reg_map, cxlds->capabilities); +if (rc) { +dev_warn (&pdev->dev,"No component registers (%d)\n" , rc); +return rc; + } + +if (!test_bit (CXL_CM_CAP_CAP_ID_RAS , cxlds->capabilities)) +return rc; + + rc =cxl_map_component_regs (&cxlds->reg_map, + &cxlds->regs.component, +BIT (CXL_CM_CAP_CAP_ID_RAS )); +if (rc) +dev_dbg (&pdev->dev,"Failed to map RAS capability.\n" ); + +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_pci_accel_setup_regs,"CXL" ); +int cxl_pci_get_bandwidth (struct pci_dev *pdev,struct access_coordinate *c) {int speed, bw;
include/cxl/cxl.h +2 -0
@@ -43,4 +43,6 @@ int cxl_set_resource(struct cxl_dev_state *cxlds, struct resource res,bool cxl_pci_check_caps (struct cxl_dev_state *cxlds,unsigned long *expected_caps,unsigned long *current_caps); +struct pci_dev ; +int cxl_pci_accel_setup_regs (struct pci_dev *pdev,struct cxl_dev_state *cxlds);#endif
Signature · 1 line
2.17.1
Re: [PATCH v9 06/27] cxl: add function for type2 cxl regs setup
Quoted 8 lines · On Mon, 30 Dec 2024 21:44:24 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
Create a new function for a type2 device initialising
cxl_dev_statestruct regarding cxl regs setup and mapping.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Fan Ni <[email protected]>
Hi Alejandro
I think there was one additional change you were going to make based on v8 feedback.
See inline. With that add
Quoted 43 lines
--- drivers/cxl/core/pci.c | 51 ++++++++++++++++++++++++++++++++++++++++++ include/cxl/cxl.h | 2 ++ 2 files changed, 53 insertions(+)drivers/cxl/core/pci.c +30
-0@@ -1107,6 +1107,57 @@ int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, }EXPORT_SYMBOL_NS_GPL (cxl_pci_setup_regs,"CXL" ); +static int cxl_pci_setup_memdev_regs (struct pci_dev *pdev, +struct cxl_dev_state *cxlds) +{ +struct cxl_register_map map; +int rc; + + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_MEMDEV , &map, + cxlds->capabilities); +/* +* This call can return -ENODEV if regs not found. This is not an error +* for Type2 since these regs are not mandatory. If they do exist then +* mapping them should not fail. If they should exist, it is with driver +* calling cxl_pci_check_caps where the problem should be found. +*/ +if (rc == -ENODEV ) +return 0 ; + +if (rc) +return rc; + +return cxl_map_device_regs (&map, &cxlds->regs.device_regs); +} + +int cxl_pci_accel_setup_regs (struct pci_dev *pdev,struct cxl_dev_state *cxlds) +{ +int rc; + + rc =cxl_pci_setup_memdev_regs (pdev, cxlds); +if (rc) +return rc;
drivers/cxl/core/pci.c int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, · line 1149
Quoted 10 lines
drivers/cxl/core/pci.c +10
-0+ + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_COMPONENT , + &cxlds->reg_map, cxlds->capabilities); +if (rc) { +dev_warn (&pdev->dev,"No component registers (%d)\n" , rc); +return rc; + } + +if (!test_bit (CXL_CM_CAP_CAP_ID_RAS , cxlds->capabilities)) +return rc;
return 0;
will make it clear what intent is here.
Quoted 10 lines
drivers/cxl/core/pci.c +10
-0+ + rc =cxl_map_component_regs (&cxlds->reg_map, + &cxlds->regs.component, +BIT (CXL_CM_CAP_CAP_ID_RAS )); +if (rc) +dev_dbg (&pdev->dev,"Failed to map RAS capability.\n" ); + +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_pci_accel_setup_regs,"CXL" );
Re: [PATCH v9 06/27] cxl: add function for type2 cxl regs setup
Quoted 8 lines · Jonathan Cameron
Quoted 5 lines · On Mon, 30 Dec 2024 21:44:24 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
Create a new function for a type2 device initialising
cxl_dev_statestruct regarding cxl regs setup and mapping.
Quoted 7 lines
Quoted 3 lines
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Fan Ni <[email protected]>Hi Alejandro
I think there was one additional change you were going to make based on v8 feedback.
Oh, I just commented there agreeing with that (and the other one) but forgot this one.
I'll do it in v10.
Thanks
Quoted 71 lines
See inline. With that add
Reviewed-by Jonathan Cameron <[email protected]>Quoted 43 lines
--- drivers/cxl/core/pci.c | 51 ++++++++++++++++++++++++++++++++++++++++++ include/cxl/cxl.h | 2 ++ 2 files changed, 53 insertions(+)drivers/cxl/core/pci.c +30
-0@@ -1107,6 +1107,57 @@ int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, }EXPORT_SYMBOL_NS_GPL (cxl_pci_setup_regs,"CXL" ); +static int cxl_pci_setup_memdev_regs (struct pci_dev *pdev, +struct cxl_dev_state *cxlds) +{ +struct cxl_register_map map; +int rc; + + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_MEMDEV , &map, + cxlds->capabilities); +/* +* This call can return -ENODEV if regs not found. This is not an error +* for Type2 since these regs are not mandatory. If they do exist then +* mapping them should not fail. If they should exist, it is with driver +* calling cxl_pci_check_caps where the problem should be found. +*/ +if (rc == -ENODEV ) +return 0 ; + +if (rc) +return rc; + +return cxl_map_device_regs (&map, &cxlds->regs.device_regs); +} + +int cxl_pci_accel_setup_regs (struct pci_dev *pdev,struct cxl_dev_state *cxlds) +{ +int rc; + + rc =cxl_pci_setup_memdev_regs (pdev, cxlds); +if (rc) +return rc;drivers/cxl/core/pci.c int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, · line 1149
Quoted 10 lines
drivers/cxl/core/pci.c +10
-0+ + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_COMPONENT , + &cxlds->reg_map, cxlds->capabilities); +if (rc) { +dev_warn (&pdev->dev,"No component registers (%d)\n" , rc); +return rc; + } + +if (!test_bit (CXL_CM_CAP_CAP_ID_RAS , cxlds->capabilities)) +return rc;return 0;
will make it clear what intent is here.
Quoted 10 lines
drivers/cxl/core/pci.c +10
-0+ + rc =cxl_map_component_regs (&cxlds->reg_map, + &cxlds->regs.component, +BIT (CXL_CM_CAP_CAP_ID_RAS )); +if (rc) +dev_dbg (&pdev->dev,"Failed to map RAS capability.\n" ); + +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_pci_accel_setup_regs,"CXL" );
Re: [PATCH v9 06/27] cxl: add function for type2 cxl regs setup
In reply to [email protected]Quoted 25 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Create a new function for a type2 device initialising
cxl_dev_statestruct regarding cxl regs setup and mapping.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Fan Ni <[email protected]>--- drivers/cxl/core/pci.c | 51 ++++++++++++++++++++++++++++++++++++++++++ include/cxl/cxl.h | 2 ++ 2 files changed, 53 insertions(+)drivers/cxl/core/pci.c +4
-0@@ -1107,6 +1107,57 @@ int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, }EXPORT_SYMBOL_NS_GPL (cxl_pci_setup_regs,"CXL" ); +static int cxl_pci_setup_memdev_regs (struct pci_dev *pdev, +struct cxl_dev_state *cxlds) +{ +struct cxl_register_map map;
drivers/cxl/core/pci.c int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, · line 1123
Quoted 10 lines
drivers/cxl/core/pci.c +10
-0+int rc; + + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_MEMDEV , &map, + cxlds->capabilities); +/* +* This call can return -ENODEV if regs not found. This is not an error +* for Type2 since these regs are not mandatory. If they do exist then +* mapping them should not fail. If they should exist, it is with driver +* calling cxl_pci_check_caps where the problem should be found. +*/
There is no common definition of type-2 so the core should not try to assume it knows, or be told what is mandatory. Just export the raw helpers and leave it to the caller to make these decisions.
Quoted 26 lines
drivers/cxl/core/pci.c +26
-0+if (rc == -ENODEV ) +return 0 ; + +if (rc) +return rc; + +return cxl_map_device_regs (&map, &cxlds->regs.device_regs); +} + +int cxl_pci_accel_setup_regs (struct pci_dev *pdev,struct cxl_dev_state *cxlds) +{ +int rc; + + rc =cxl_pci_setup_memdev_regs (pdev, cxlds); +if (rc) +return rc; + + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_COMPONENT , + &cxlds->reg_map, cxlds->capabilities); +if (rc) { +dev_warn (&pdev->dev,"No component registers (%d)\n" , rc); +return rc; + } + +if (!test_bit (CXL_CM_CAP_CAP_ID_RAS , cxlds->capabilities)) +return rc;
drivers/cxl/core/pci.c int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, · line 1159
Quoted 10 lines
drivers/cxl/core/pci.c +10
-0+ + rc =cxl_map_component_regs (&cxlds->reg_map, + &cxlds->regs.component, +BIT (CXL_CM_CAP_CAP_ID_RAS )); +if (rc) +dev_dbg (&pdev->dev,"Failed to map RAS capability.\n" ); + +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_pci_accel_setup_regs,"CXL" );
Only after we have multiple instances of CXL accelerator drivers that start copying the same init code should a helper be created that wraps that duplication. Otherwise move this probing and error determination out to SFC for now.
Re: [PATCH v9 06/27] cxl: add function for type2 cxl regs setup
Quoted 31 lines · Dan Williams
Quoted 30 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Create a new function for a type2 device initialising
cxl_dev_statestruct regarding cxl regs setup and mapping.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Fan Ni <[email protected]>--- drivers/cxl/core/pci.c | 51 ++++++++++++++++++++++++++++++++++++++++++ include/cxl/cxl.h | 2 ++ 2 files changed, 53 insertions(+)drivers/cxl/core/pci.c +9
-0@@ -1107,6 +1107,57 @@ int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, }EXPORT_SYMBOL_NS_GPL (cxl_pci_setup_regs,"CXL" ); +static int cxl_pci_setup_memdev_regs (struct pci_dev *pdev, +struct cxl_dev_state *cxlds) +{ +struct cxl_register_map map; +int rc; + + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_MEMDEV , &map, + cxlds->capabilities); +/*
Quoted 8 lines
drivers/cxl/core/pci.c int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, · line 1123
Quoted 5 lines
drivers/cxl/core/pci.c +5
-0+* This call can return -ENODEV if regs not found. This is not an error +* for Type2 since these regs are not mandatory. If they do exist then +* mapping them should not fail. If they should exist, it is with driver +* calling cxl_pci_check_caps where the problem should be found. +*/ There is no common definition of type-2 so the core should not try to assume it knows, or be told what is mandatory. Just export the raw helpers and leave it to the caller to make these decisions.
The code does not know, but it knows it does not know, therefore handles this new situation not needed before Type2 support in the generic code for the pci driver and Type3.
This is added to the API for accel drivers following the design restrictions I have commented earlier in another patch. Your suggestion seems to go against that decision what was implicitly taken after the first versions and which had no complains until now.
More about this same issue below.
Quoted 32 lines
Quoted 32 lines
drivers/cxl/core/pci.c +32
-0+if (rc == -ENODEV ) +return 0 ; + +if (rc) +return rc; + +return cxl_map_device_regs (&map, &cxlds->regs.device_regs); +} + +int cxl_pci_accel_setup_regs (struct pci_dev *pdev,struct cxl_dev_state *cxlds) +{ +int rc; + + rc =cxl_pci_setup_memdev_regs (pdev, cxlds); +if (rc) +return rc; + + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_COMPONENT , + &cxlds->reg_map, cxlds->capabilities); +if (rc) { +dev_warn (&pdev->dev,"No component registers (%d)\n" , rc); +return rc; + } + +if (!test_bit (CXL_CM_CAP_CAP_ID_RAS , cxlds->capabilities)) +return rc; + + rc =cxl_map_component_regs (&cxlds->reg_map, + &cxlds->regs.component, +BIT (CXL_CM_CAP_CAP_ID_RAS )); +if (rc) +dev_dbg (&pdev->dev,"Failed to map RAS capability.\n" );
Quoted 8 lines
drivers/cxl/core/pci.c int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, · line 1159
Quoted 4 lines
drivers/cxl/core/pci.c +4
-0+ +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_pci_accel_setup_regs,"CXL" );Only after we have multiple instances of CXL accelerator drivers that start copying the same init code should a helper be created that wraps that duplication. Otherwise move this probing and error determination out to SFC for now.
I do not think moving this to the accel driver makes sense at this point, but I think it is worth to try to share this as much as possible with the current pci driver for Type3.
Re: [PATCH v9 06/27] cxl: add function for type2 cxl regs setup
Quoted 43 lines · Alejandro Lucero Palau
Quoted 31 lines · Dan Williams
Quoted 30 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Create a new function for a type2 device initialising
cxl_dev_statestruct regarding cxl regs setup and mapping.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Fan Ni <[email protected]>--- drivers/cxl/core/pci.c | 51 ++++++++++++++++++++++++++++++++++++++++++ include/cxl/cxl.h | 2 ++ 2 files changed, 53 insertions(+)drivers/cxl/core/pci.c +9
-0@@ -1107,6 +1107,57 @@ int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, }EXPORT_SYMBOL_NS_GPL (cxl_pci_setup_regs,"CXL" ); +static int cxl_pci_setup_memdev_regs (struct pci_dev *pdev, +struct cxl_dev_state *cxlds) +{ +struct cxl_register_map map; +int rc; + + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_MEMDEV , &map, + cxlds->capabilities); +/* Quoted 8 lines
drivers/cxl/core/pci.c int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, · line 1123
Quoted 5 lines
drivers/cxl/core/pci.c +5
-0+* This call can return -ENODEV if regs not found. This is not an error +* for Type2 since these regs are not mandatory. If they do exist then +* mapping them should not fail. If they should exist, it is with driver +* calling cxl_pci_check_caps where the problem should be found. +*/ There is no common definition of type-2 so the core should not try to assume it knows, or be told what is mandatory. Just export the raw helpers and leave it to the caller to make these decisions.
Quoted 8 lines
The code does not know, but it knows it does not know, therefore handles this new situation not needed before Type2 support in the generic code for the pci driver and Type3.
This is added to the API for accel drivers following the design restrictions I have commented earlier in another patch. Your suggestion seems to go against that decision what was implicitly taken after the first versions and which had no complains until now.
Apologies for that, I had not looked at the implications of that general decision until now, but the result is going in the wrong direction from what it is doing to the core.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
drivers/cxl/core/pci.c +17
-0+return 0 ; + +if (rc) +return rc; + +return cxl_map_device_regs (&map, &cxlds->regs.device_regs); +} + +int cxl_pci_accel_setup_regs (struct pci_dev *pdev,struct cxl_dev_state *cxlds) +{ +int rc; + + rc =cxl_pci_setup_memdev_regs (pdev, cxlds); +if (rc) +return rc; + + rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT,
Quoted 8 lines
Quoted 8 lines
drivers/cxl/core/pci.c int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, · line 1149
Quoted 8 lines
drivers/cxl/core/pci.c +8
-0+ &cxlds->reg_map, cxlds->capabilities); +if (rc) { +dev_warn (&pdev->dev,"No component registers (%d)\n" , rc); +return rc; + } + +if (!test_bit (CXL_CM_CAP_CAP_ID_RAS , cxlds->capabilities)) +return rc;
This is injecting logic in a bitmap and a new CXL core exported ABI just to avoid the driver optionally skipping RAS register enumeration.
The core should not care how and whether endpoint drivers (accel or cxl_pci) consume register blocks, just arrange for their enumeration and let the leaf driver logic take it from there.
Re: [PATCH v9 06/27] cxl: add function for type2 cxl regs setup
Quoted 46 lines · Dan Williams
Quoted 45 lines · Alejandro Lucero Palau
Quoted 31 lines · Dan Williams
Quoted 30 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Create a new function for a type2 device initialising
cxl_dev_statestruct regarding cxl regs setup and mapping.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Fan Ni <[email protected]>--- drivers/cxl/core/pci.c | 51 ++++++++++++++++++++++++++++++++++++++++++ include/cxl/cxl.h | 2 ++ 2 files changed, 53 insertions(+)drivers/cxl/core/pci.c +9
-0@@ -1107,6 +1107,57 @@ int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, }EXPORT_SYMBOL_NS_GPL (cxl_pci_setup_regs,"CXL" ); +static int cxl_pci_setup_memdev_regs (struct pci_dev *pdev, +struct cxl_dev_state *cxlds) +{ +struct cxl_register_map map; +int rc; + + rc =cxl_pci_setup_regs (pdev,CXL_REGLOC_RBI_MEMDEV , &map, + cxlds->capabilities); +/* Quoted 8 lines
drivers/cxl/core/pci.c int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, · line 1123
Quoted 5 lines
drivers/cxl/core/pci.c +5
-0+* This call can return -ENODEV if regs not found. This is not an error +* for Type2 since these regs are not mandatory. If they do exist then +* mapping them should not fail. If they should exist, it is with driver +* calling cxl_pci_check_caps where the problem should be found. +*/ There is no common definition of type-2 so the core should not try to assume it knows, or be told what is mandatory. Just export the raw helpers and leave it to the caller to make these decisions.
The code does not know, but it knows it does not know, therefore handles this new situation not needed before Type2 support in the generic code for the pci driver and Type3.
Quoted 7 lines
Quoted 4 lines
This is added to the API for accel drivers following the design restrictions I have commented earlier in another patch. Your suggestion seems to go against that decision what was implicitly taken after the first versions and which had no complains until now.
Apologies for that, I had not looked at the implications of that general decision until now, but the result is going in the wrong direction from what it is doing to the core.
After yesterday's meeting listening to Jonathan and you discussing last reviews, what I thought was mainly related to this patchset, I was not sure I had to address this concern, but it is clear now.
I'm a bit disappointed this requiring new design after so many cycles and about something I thought it was set and consensus existed.
Anyway, I'll work on that, not sure yet what I should change and what should stay, because the main reason for the current design of an accel driver API does not exist anymore.
I need time for figuring out the work to do, so DCD should take priority now for trying to merge it with 6.14.
Quoted 32 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/cxl/core/pci.c +17
-0+return 0 ; + +if (rc) +return rc; + +return cxl_map_device_regs (&map, &cxlds->regs.device_regs); +} + +int cxl_pci_accel_setup_regs (struct pci_dev *pdev,struct cxl_dev_state *cxlds) +{ +int rc; + + rc =cxl_pci_setup_memdev_regs (pdev, cxlds); +if (rc) +return rc; + + rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT,Quoted 8 lines
Quoted 8 lines
drivers/cxl/core/pci.c int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, · line 1149
Quoted 8 lines
drivers/cxl/core/pci.c +8
-0+ &cxlds->reg_map, cxlds->capabilities); +if (rc) { +dev_warn (&pdev->dev,"No component registers (%d)\n" , rc); +return rc; + } + +if (!test_bit (CXL_CM_CAP_CAP_ID_RAS , cxlds->capabilities)) +return rc;This is injecting logic in a bitmap and a new CXL core exported ABI just to avoid the driver optionally skipping RAS register enumeration.
The core should not care how and whether endpoint drivers (accel or
cxl_pci) consume register blocks, just arrange for their enumeration and let the leaf driver logic take it from there.
Re: [PATCH v9 06/27] cxl: add function for type2 cxl regs setup
Alejandro Lucero Palau wrote:
[..]
Quoted 10 lines
Quoted 3 lines
Apologies for that, I had not looked at the implications of that general decision until now, but the result is going in the wrong direction from what it is doing to the core.
After yesterday's meeting listening to Jonathan and you discussing last reviews, what I thought was mainly related to this patchset, I was not sure I had to address this concern, but it is clear now.
I'm a bit disappointed this requiring new design after so many cycles and about something I thought it was set and consensus existed.
That is valid frustration, and there was indeed long silence on this patchset from me until recently.
Quoted 3 lines
Anyway, I'll work on that, not sure yet what I should change and what should stay, because the main reason for the current design of an accel driver API does not exist anymore.
Yes, I think this was the main disconnect. The CXL core is a library, the expander use case is supported by a class code, the accelerator use case is an a la carte subset plus some disjoint bits. The library should be use case agnostic.
That means that accelerator specific exports should be avoided especially when they are just wrapping other existing library exports. Push the use case specific concerns to the leaf drivers.
Another way to put it is that new exports from drivers/cxl/ and core data structure touches will receive higher scrutiny, because that is new maintenance burden on the core.
Quoted 2 lines
I need time for figuring out the work to do, so DCD should take priority now for trying to merge it with 6.14.
This is all a bit too late unfortunately and I do not want to pressure Dave to explain to Linus why patches are still flowing into the CXL tree during the merge window.
Lets get this wrapped up and in cxl.next early in the v6.15 cycle.
PATCH v9 7/27 sfc: use cxl api for regs setup and checking
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Use cxl code for registers discovery and mapping.
Validate capabilities found based on those registers against expected capabilities.
--- drivers/net/ethernet/sfc/efx_cxl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/net/ethernet/sfc/efx_cxl.c +21 -0
@@ -22,6 +22,8 @@ int efx_cxl_init(struct efx_probe_data *probe_data) {struct efx_nic *efx = &probe_data->efx;struct pci_dev *pci_dev = efx->pci_dev; +DECLARE_BITMAP (expected,CXL_MAX_CAPS ); +DECLARE_BITMAP (found,CXL_MAX_CAPS );struct efx_cxl *cxl;struct resource res;u16 dvsec;
@@ -64,6 +66,25 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err_resource_set; } + rc =cxl_pci_accel_setup_regs (pci_dev, cxl->cxlds); +if (rc) { +pci_err (pci_dev,"CXL accel setup regs failed" ); + goto err_resource_set; + } + +bitmap_clear (expected,0 ,CXL_MAX_CAPS ); +set_bit (CXL_DEV_CAP_HDM , expected); +set_bit (CXL_DEV_CAP_HDM , expected); +set_bit (CXL_DEV_CAP_RAS , expected); + +if (!cxl_pci_check_caps (cxl->cxlds, expected, found)) { +pci_err (pci_dev, +"CXL device capabilities found(%pb) not as expected(%pb)" , + found, expected); + rc = -EIO ; + goto err_resource_set; + } + probe_data->cxl = cxl;return 0 ;
Signature · 1 line
2.17.1
Re: [PATCH v9 07/27] sfc: use cxl api for regs setup and checking
Quoted 11 lines · On Mon, 30 Dec 2024 21:44:25 +0000 [email protected] wrote:
From: Alejandro Lucero <[email protected]>
Use cxl code for registers discovery and mapping.
Validate capabilities found based on those registers against expected capabilities.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>Reviewed-by Zhi Wang <[email protected]>Acked-by Edward Cree <[email protected]>
Re: [PATCH v9 07/27] sfc: use cxl api for regs setup and checking
In reply to [email protected]Quoted 41 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Use cxl code for registers discovery and mapping.
Validate capabilities found based on those registers against expected capabilities.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>Reviewed-by Zhi Wang <[email protected]>Acked-by Edward Cree <[email protected]>--- drivers/net/ethernet/sfc/efx_cxl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)drivers/net/ethernet/sfc/efx_cxl.c +11
-0@@ -22,6 +22,8 @@ int efx_cxl_init(struct efx_probe_data *probe_data) {struct efx_nic *efx = &probe_data->efx;struct pci_dev *pci_dev = efx->pci_dev; +DECLARE_BITMAP (expected,CXL_MAX_CAPS ); +DECLARE_BITMAP (found,CXL_MAX_CAPS );struct efx_cxl *cxl;struct resource res;u16 dvsec;@@ -64,6 +66,25 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err_resource_set; } + rc =cxl_pci_accel_setup_regs (pci_dev, cxl->cxlds); +if (rc) { +pci_err (pci_dev,"CXL accel setup regs failed" ); + goto err_resource_set; + } + +bitmap_clear (expected,0 ,CXL_MAX_CAPS ); +set_bit (CXL_DEV_CAP_HDM , expected); +set_bit (CXL_DEV_CAP_HDM , expected);
drivers/net/ethernet/sfc/efx_cxl.c int efx_cxl_init(struct efx_probe_data *probe_data) · line 87
Quoted 10 lines
drivers/net/ethernet/sfc/efx_cxl.c +10
-0+set_bit (CXL_DEV_CAP_RAS , expected); + +if (!cxl_pci_check_caps (cxl->cxlds, expected, found)) { +pci_err (pci_dev, +"CXL device capabilities found(%pb) not as expected(%pb)" , + found, expected); + rc = -EIO ; + goto err_resource_set; + } +
Walk the existing valid bits in the reg maps. If you want to do this with bitmaps you can convert reg_map valid bits into a bitmap locally, but that redundant infrastructure can be left out of the core.
Re: [PATCH v9 07/27] sfc: use cxl api for regs setup and checking
Quoted 47 lines · Dan Williams
Quoted 46 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Use cxl code for registers discovery and mapping.
Validate capabilities found based on those registers against expected capabilities.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>Reviewed-by Zhi Wang <[email protected]>Acked-by Edward Cree <[email protected]>--- drivers/net/ethernet/sfc/efx_cxl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)drivers/net/ethernet/sfc/efx_cxl.c +16
-0@@ -22,6 +22,8 @@ int efx_cxl_init(struct efx_probe_data *probe_data) {struct efx_nic *efx = &probe_data->efx;struct pci_dev *pci_dev = efx->pci_dev; +DECLARE_BITMAP (expected,CXL_MAX_CAPS ); +DECLARE_BITMAP (found,CXL_MAX_CAPS );struct efx_cxl *cxl;struct resource res;u16 dvsec;@@ -64,6 +66,25 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err_resource_set; } + rc =cxl_pci_accel_setup_regs (pci_dev, cxl->cxlds); +if (rc) { +pci_err (pci_dev,"CXL accel setup regs failed" ); + goto err_resource_set; + } + +bitmap_clear (expected,0 ,CXL_MAX_CAPS ); +set_bit (CXL_DEV_CAP_HDM , expected); +set_bit (CXL_DEV_CAP_HDM , expected); +set_bit (CXL_DEV_CAP_RAS , expected); + +if (!cxl_pci_check_caps (cxl->cxlds, expected, found)) { + pci_err(pci_dev, + "CXL device capabilities found(%pb) not as expected(%pb)",
Quoted 8 lines
drivers/net/ethernet/sfc/efx_cxl.c int efx_cxl_init(struct efx_probe_data *probe_data) · line 87
Quoted 5 lines
drivers/net/ethernet/sfc/efx_cxl.c +5
-0+ found, expected); + rc = -EIO ; + goto err_resource_set; + } +Walk the existing valid bits in the reg maps. If you want to do this with bitmaps you can convert
reg_mapvalid bits into a bitmap locally, but that redundant infrastructure can be left out of the core.
This is the accel driver. Some way for doing this needs to be implemented, and although I'm not against solving the duplication between the reg_map valid bit and the new capability bitmap, an accel driver will need this piece of code or something equivalent.
PATCH v9 8/27 cxl: add functions for resource request/release by a driver
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Create accessors for an accel driver requesting and releasing a resource.
--- drivers/cxl/core/memdev.c | 39 +++++++++++++++++++++++++++++++++++++++ include/cxl/cxl.h | 2 ++ 2 files changed, 41 insertions(+)
drivers/cxl/core/memdev.c +39 -0
@@ -744,6 +744,45 @@ int cxl_set_resource(struct cxl_dev_state *cxlds, struct resource res, }EXPORT_SYMBOL_NS_GPL (cxl_set_resource,"CXL" ); +int cxl_request_resource (struct cxl_dev_state *cxlds,enum cxl_resource type) +{ +switch (type) { +case CXL_RES_RAM : +if (!resource_size (&cxlds->ram_res)) { +dev_err (cxlds->dev, +"resource request for ram with size 0\n" ); +return -EINVAL ; + } + +return request_resource (&cxlds->dpa_res, &cxlds->ram_res); +case CXL_RES_PMEM : +if (!resource_size (&cxlds->pmem_res)) { +dev_err (cxlds->dev, +"resource request for pmem with size 0\n" ); +return -EINVAL ; + } +return request_resource (&cxlds->dpa_res, &cxlds->pmem_res); +default : +dev_err (cxlds->dev,"unsupported resource type (%u)\n" , type); +return -EINVAL ; + } +} +EXPORT_SYMBOL_NS_GPL (cxl_request_resource,"CXL" ); + +int cxl_release_resource (struct cxl_dev_state *cxlds,enum cxl_resource type) +{ +switch (type) { +case CXL_RES_RAM : +return release_resource (&cxlds->ram_res); +case CXL_RES_PMEM : +return release_resource (&cxlds->pmem_res); +default : +dev_err (cxlds->dev,"unknown resource type (%u)\n" , type); +return -EINVAL ; + } +} +EXPORT_SYMBOL_NS_GPL (cxl_release_resource,"CXL" ); +static int cxl_memdev_release_file (struct inode *inode,struct file *file) { struct cxl_memdev *cxlmd =
include/cxl/cxl.h +2 -0
@@ -45,4 +45,6 @@ bool cxl_pci_check_caps(struct cxl_dev_state *cxlds, unsigned long *current_caps);struct pci_dev ;int cxl_pci_accel_setup_regs (struct pci_dev *pdev,struct cxl_dev_state *cxlds); +int cxl_request_resource (struct cxl_dev_state *cxlds,enum cxl_resource type); +int cxl_release_resource (struct cxl_dev_state *cxlds,enum cxl_resource type);#endif
Signature · 1 line
2.17.1
PATCH v9 9/27 sfc: request cxl ram resource
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Use cxl accessor for obtaining the ram resource the device advertises.
--- drivers/net/ethernet/sfc/efx_cxl.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/sfc/efx_cxl.c +7 -0
@@ -85,6 +85,12 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err_resource_set; } + rc =cxl_request_resource (cxl->cxlds,CXL_RES_RAM ); +if (rc) { +pci_err (pci_dev,"CXL request resource failed" ); + goto err_resource_set; + } + probe_data->cxl = cxl;return 0 ;
@@ -99,6 +105,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data)void efx_cxl_exit (struct efx_probe_data *probe_data) {if (probe_data->cxl) { +cxl_release_resource (probe_data->cxl->cxlds,CXL_RES_RAM );kfree (probe_data->cxl->cxlds);kfree (probe_data->cxl); }
Signature · 1 line
2.17.1
Re: [PATCH v9 09/27] sfc: request cxl ram resource
Quoted 31 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Use cxl accessor for obtaining the ram resource the device advertises.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>Reviewed-by Fan Ni <[email protected]>Acked-by Edward Cree <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>--- drivers/net/ethernet/sfc/efx_cxl.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/net/ethernet/sfc/efx_cxl.c +6
-0@@ -85,6 +85,12 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err_resource_set; } + rc =cxl_request_resource (cxl->cxlds,CXL_RES_RAM ); +if (rc) { +pci_err (pci_dev,"CXL request resource failed" ); + goto err_resource_set; + } + probe_data->cxl = cxl;return 0 ;
drivers/net/ethernet/sfc/efx_cxl.c int efx_cxl_init(struct efx_probe_data *probe_data) · line 108
Quoted 4 lines
drivers/net/ethernet/sfc/efx_cxl.c +1
-0@@ -99,6 +105,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data)void efx_cxl_exit (struct efx_probe_data *probe_data) {if (probe_data->cxl) { +cxl_release_resource (probe_data->cxl->cxlds,CXL_RES_RAM );
Given that the DPA layout is a static property of 'struct cxl_dev_state' once set there is no need to release it. Notice how there is no release in the memdev case either. The 'release' is freeing @cxlds.
Now, any DPA reservations from that partition need to be released, but those releases are with respect to cxl_dpa_{alloc,free}().
Re: [PATCH v9 09/27] sfc: request cxl ram resource
Quoted 40 lines · Dan Williams
Quoted 31 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Use cxl accessor for obtaining the ram resource the device advertises.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>Reviewed-by Fan Ni <[email protected]>Acked-by Edward Cree <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>--- drivers/net/ethernet/sfc/efx_cxl.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/net/ethernet/sfc/efx_cxl.c +6
-0@@ -85,6 +85,12 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err_resource_set; } + rc =cxl_request_resource (cxl->cxlds,CXL_RES_RAM ); +if (rc) { +pci_err (pci_dev,"CXL request resource failed" ); + goto err_resource_set; + } + probe_data->cxl = cxl;return 0 ;drivers/net/ethernet/sfc/efx_cxl.c int efx_cxl_init(struct efx_probe_data *probe_data) · line 108
Quoted 4 lines
drivers/net/ethernet/sfc/efx_cxl.c +1
-0@@ -99,6 +105,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data)void efx_cxl_exit (struct efx_probe_data *probe_data) {if (probe_data->cxl) { +cxl_release_resource (probe_data->cxl->cxlds,CXL_RES_RAM );Given that the DPA layout is a static property of 'struct
cxl_dev_state' once set there is no need to release it. Notice how there is no release in the memdev case either. The 'release' is freeing @cxlds.
Quoted 2 lines
Now, any DPA reservations from that partition need to be released, but those releases are with respect to cxl_dpa_{alloc,free}().
Yes, it is now all more clear after the "DPA layout mess" work-in-progress.
I'll drop the release_resource in patch 8.
Thanks
PATCH v9 10/27 resource: harden resource_contains
In reply to [email protected]From: Alejandro Lucero <[email protected]>
While resource_contains checks for IORESOURCE_UNSET flag for the resources given, if r1 was initialized with 0 size, the function returns a false positive. This is so because resource start and end fields are unsigned with end initialised to size - 1 by current resource macros.
Make the function to check for the resource size for both resources since r2 with size 0 should not be considered as valid for the function purpose.
--- include/linux/ioport.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/ioport.h +2 -0
@@ -296,6 +296,8 @@ static inline unsigned long resource_ext_type(const struct resource *res)/* True iff r1 completely contains r2 */ static inline bool resource_contains (const struct resource *r1,const struct resource *r2) { +if (!resource_size (r1) || !resource_size (r2)) +return false;if (resource_type (r1) !=resource_type (r2))return false;if (r1->flags &IORESOURCE_UNSET || r2->flags &IORESOURCE_UNSET )
Signature · 1 line
2.17.1
Re: [PATCH v9 10/27] resource: harden resource_contains
Quoted 26 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
While
resource_containschecks forIORESOURCE_UNSETflag for the resources given, if r1 was initialized with 0 size, the function returns a false positive. This is so because resource start and end fields are unsigned with end initialised to size - 1 by current resource macros.Make the function to check for the resource size for both resources since r2 with size 0 should not be considered as valid for the function purpose.
Signed-off-by Alejandro Lucero <[email protected]>Suggested-by Alison Schofield <[email protected]>Reviewed-by Alison Schofield <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>--- include/linux/ioport.h | 2 ++ 1 file changed, 2 insertions(+)include/linux/ioport.h +0
-0
include/linux/ioport.h static inline unsigned long resource_ext_type(const struct resource *res) · line 300
Quoted 5 lines
include/linux/ioport.h +2
-0@@ -296,6 +296,8 @@ static inline unsigned long resource_ext_type(const struct resource *res)/* True iff r1 completely contains r2 */ static inline bool resource_contains (const struct resource *r1,const struct resource *r2) { +if (!resource_size (r1) || !resource_size (r2)) +return false;
I just worry that some code paths expect the opposite, that it is ok to pass zero size resources and get a true result.
Did you audit existing callers?
Re: [PATCH v9 10/27] resource: harden resource_contains
Quoted 22 lines · Dan Williams
Quoted 21 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
While
resource_containschecks forIORESOURCE_UNSETflag for the resources given, if r1 was initialized with 0 size, the function returns a false positive. This is so because resource start and end fields are unsigned with end initialised to size - 1 by current resource macros.Make the function to check for the resource size for both resources since r2 with size 0 should not be considered as valid for the function purpose.
Signed-off-by Alejandro Lucero <[email protected]>Suggested-by Alison Schofield <[email protected]>Reviewed-by Alison Schofield <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>--- include/linux/ioport.h | 2 ++ 1 file changed, 2 insertions(+)
Quoted 12 lines
include/linux/ioport.h static inline unsigned long resource_ext_type(const struct resource *res) · line 300
Quoted 10 lines
include/linux/ioport.h +2
-0@@ -296,6 +296,8 @@ static inline unsigned long resource_ext_type(const struct resource *res)/* True iff r1 completely contains r2 */ static inline bool resource_contains (const struct resource *r1,const struct resource *r2) { +if (!resource_size (r1) || !resource_size (r2)) +return false;I just worry that some code paths expect the opposite, that it is ok to pass zero size resources and get a true result.
That is an interesting point, I would say close to philosophic arguments. I guess you mean the zero size resource being the one that is contained inside the non-zero one, because the other option is making my vision blurry. In fact, even that one makes me feel trapped in a window-less room, in summer, with a bunch of economists, I mean philosophers, and my phone without signal for emergency calls.
But maybe it is just my lack of understanding and there exists a good reason for this possibility.
Bjorn, I guess the ball is in your side ...
Quoted 1 line
Did you audit existing callers?
Re: [PATCH v9 10/27] resource: harden resource_contains
Adding Bjorn to the thread. Not sure if he just gets the email being in an Acked-by line.
Quoted 48 lines · Alejandro Lucero Palau
Quoted 22 lines · Dan Williams
Quoted 21 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
While
resource_containschecks forIORESOURCE_UNSETflag for the resources given, if r1 was initialized with 0 size, the function returns a false positive. This is so because resource start and end fields are unsigned with end initialised to size - 1 by current resource macros.Make the function to check for the resource size for both resources since r2 with size 0 should not be considered as valid for the function purpose.
Signed-off-by Alejandro Lucero <[email protected]>Suggested-by Alison Schofield <[email protected]>Reviewed-by Alison Schofield <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>---
include/linux/ioport.h| 2 ++1 file changed, 2 insertions(+)Quoted 13 lines
include/linux/ioport.h static inline unsigned long · line 301
Quoted 11 lines
include/linux/ioport.h +2
-0@@ -296,6 +296,8 @@ static inline unsigned long resource_ext_type(const struct resource *res) /* True iff r1 completely contains r2 */ static inline bool resource_contains(const struct resource *r1, const struct resource *r2) { + if (!resource_size(r1) || !resource_size(r2)) + return false;I just worry that some code paths expect the opposite, that it is ok to pass zero size resources and get a true result.
That is an interesting point, I would say close to philosophic arguments. I guess you mean the zero size resource being the one that is contained inside the non-zero one, because the other option is making my vision blurry. In fact, even that one makes me feel trapped in a window-less room, in summer, with a bunch of economists, I mean philosophers, and my phone without signal for emergency calls.
But maybe it is just my lack of understanding and there exists a good reason for this possibility.
Bjorn, I guess the ball is in your side ...
Quoted 1 line
Did you audit existing callers?
Re: [PATCH v9 10/27] resource: harden resource_contains
Quoted 45 lines · Alejandro Lucero Palau
Adding Bjorn to the thread. Not sure if he just gets the email being in an Acked-by line.
Quoted 41 lines · Alejandro Lucero Palau
Quoted 22 lines · Dan Williams
Quoted 21 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
While
resource_containschecks forIORESOURCE_UNSETflag for the resources given, if r1 was initialized with 0 size, the function returns a false positive. This is so because resource start and end fields are unsigned with end initialised to size - 1 by current resource macros.Make the function to check for the resource size for both resources since r2 with size 0 should not be considered as valid for the function purpose.
Signed-off-by Alejandro Lucero <[email protected]>Suggested-by Alison Schofield <[email protected]>Reviewed-by Alison Schofield <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>---
include/linux/ioport.h| 2 ++1 file changed, 2 insertions(+)Quoted 13 lines
include/linux/ioport.h static inline unsigned long · line 301
Quoted 11 lines
include/linux/ioport.h +2
-0@@ -296,6 +296,8 @@ static inline unsigned long resource_ext_type(const struct resource *res) /* True iff r1 completely contains r2 */ static inline bool resource_contains(const struct resource *r1, const struct resource *r2) { + if (!resource_size(r1) || !resource_size(r2)) + return false;I just worry that some code paths expect the opposite, that it is ok to pass zero size resources and get a true result.
That is an interesting point, I would say close to philosophic arguments. I guess you mean the zero size resource being the one that is contained inside the non-zero one, because the other option is making my vision blurry. In fact, even that one makes me feel trapped in a window-less room, in summer, with a bunch of economists, I mean philosophers, and my phone without signal for emergency calls.
I forgot to make my strongest point :-). If someone assumes it is or it should be true a zero-size resource is contained inside a non zero-size resource, we do not need to call a function since it is always true regardless of the non zero-size resource ... that headache is starting again ...
Quoted 7 lines
Quoted 7 lines
But maybe it is just my lack of understanding and there exists a good reason for this possibility.
Bjorn, I guess the ball is in your side ...
Quoted 1 line
Did you audit existing callers?
Alison Schofield
maintainerRe: [PATCH v9 10/27] resource: harden resource_contains
Quoted 57 lines · Alejandro Lucero Palau
Quoted 4 lines · Alejandro Lucero Palau
Adding Bjorn to the thread. Not sure if he just gets the email being in an Acked-by line.
Quoted 50 lines
Quoted 49 lines · Alejandro Lucero Palau
Quoted 23 lines · Dan Williams
Quoted 22 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
While
resource_containschecks forIORESOURCE_UNSETflag for the resources given, if r1 was initialized with 0 size, the function returns a false positive. This is so because resource start and end fields are unsigned with end initialised to size - 1 by current resource macros.Make the function to check for the resource size for both resources since r2 with size 0 should not be considered as valid for the function
purpose.Signed-off-by Alejandro Lucero <[email protected]>Suggested-by Alison Schofield <[email protected]>Reviewed-by Alison Schofield <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>---
include/linux/ioport.h| 2 ++1 file changed, 2 insertions(+)Quoted 14 lines
Quoted 7 lines
include/linux/ioport.h +0
-0@@ -296,6 +296,8 @@ static inline unsigned long resource_ext_type(const struct resource *res) /* True iff r1 completely contains r2 */Quoted 5 lines
static inline bool
resource_contains(const struct resource *r1, const struct resource *r2)
{
+ if (!resource_size(r1) || !resource_size(r2)) + return false;I just worry that some code paths expect the opposite, that it is ok to pass zero size resources and get a true result.
That is an interesting point, I would say close to philosophic arguments. I guess you mean the zero size resource being the one that is contained inside the non-zero one, because the other option is making my vision blurry. In fact, even that one makes me feel trapped in a window-less room, in summer, with a bunch of economists, I mean philosophers, and my phone without signal for emergency calls.
Quoted 7 lines
I forgot to make my strongest point :-). If someone assumes it is or it should be true a zero-size resource is contained inside a non zero-size resource, we do not need to call a function since it is always true regardless of the non zero-size resource ... that headache is starting again
...
Maybe start using IORESOURCE_UNSET flag -
Looking back on when we first discussed this -
https://lore.kernel.org/linux-cxl/[email protected]/
where the thought was that checking for zero was helpful to all.
If this path starts using the IORESOURCE_UNSET flag can it accomplish the same thing? No need to touch resource_contains().
Is that an option?
-- Alison
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
But maybe it is just my lack of understanding and there exists a good reason for this possibility.
Bjorn, I guess the ball is in your side ...
Quoted 1 line
Did you audit existing callers?
Re: [PATCH v9 10/27] resource: harden resource_contains
Quoted 63 lines · Alison Schofield
Quoted 53 lines · Alejandro Lucero Palau
Quoted 4 lines · Alejandro Lucero Palau
Adding Bjorn to the thread. Not sure if he just gets the email being in an Acked-by line.
Quoted 48 lines
Quoted 47 lines · Alejandro Lucero Palau
Quoted 23 lines · Dan Williams
Quoted 22 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
While
resource_containschecks forIORESOURCE_UNSETflag for the resources given, if r1 was initialized with 0 size, the function returns a false positive. This is so because resource start and end fields are unsigned with end initialised to size - 1 by current resource macros.Make the function to check for the resource size for both resources since r2 with size 0 should not be considered as valid for the function
purpose.Signed-off-by Alejandro Lucero <[email protected]>Suggested-by Alison Schofield <[email protected]>Reviewed-by Alison Schofield <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>--- include/linux/ioport.h | 2 ++ 1 file changed, 2 insertions(+)Quoted 14 lines
include/linux/ioport.h static inline unsigned long · line 302
Quoted 12 lines
include/linux/ioport.h +2
-0@@ -296,6 +296,8 @@ static inline unsigned long resource_ext_type(const struct resource *res) /* True iff r1 completely contains r2 */ static inline bool resource_contains(const struct resource *r1,const struct resource *r2) { + if (!resource_size(r1) || !resource_size(r2)) + return false;I just worry that some code paths expect the opposite, that it is ok to pass zero size resources and get a true result.
That is an interesting point, I would say close to philosophic arguments. I guess you mean the zero size resource being the one that is contained inside the non-zero one, because the other option is making my vision blurry. In fact, even that one makes me feel trapped in a window-less room, in summer, with a bunch of economists, I mean philosophers, and my phone without signal for emergency calls.
Quoted 7 lines
I forgot to make my strongest point :-). If someone assumes it is or it should be true a zero-size resource is contained inside a non zero-size resource, we do not need to call a function since it is always true regardless of the non zero-size resource ... that headache is starting again
...Maybe start using
IORESOURCE_UNSETflag -
Quoted 8 lines
Looking back on when we first discussed this -
https://lore.kernel.org/linux-cxl/[email protected]/
where the thought was that checking for zero was helpful to all.If this path starts using the
IORESOURCE_UNSETflag can it accomplish the same thing? No need to touchresource_contains().Is that an option?
I think those are not mutually exclusive. The main reason for this change is hardening, in this particular case a resource definition/initialization apparently right, leading to this function returning something it should not. Even if you suggest the solution is hardening the resource definition/initialization, what I agree it is another thing to look at, I would leave this extra check here for correctness. This is assuming there is no case for what Dan mentioned and therefore auditing the callers being necessary.
Quoted 11 lines
-- Alison
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
But maybe it is just my lack of understanding and there exists a good reason for this possibility.
Bjorn, I guess the ball is in your side ...
Quoted 1 line
Did you audit existing callers?
Re: [PATCH v9 10/27] resource: harden resource_contains
In reply to Alejandro Lucero PalauQuoted 38 lines · Alejandro Lucero Palau
Quoted 22 lines · Dan Williams
Quoted 21 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
While
resource_containschecks forIORESOURCE_UNSETflag for the resources given, if r1 was initialized with 0 size, the function returns a false positive. This is so because resource start and end fields are unsigned with end initialised to size - 1 by current resource macros.Make the function to check for the resource size for both resources since r2 with size 0 should not be considered as valid for the function purpose.
Signed-off-by Alejandro Lucero <[email protected]>Suggested-by Alison Schofield <[email protected]>Reviewed-by Alison Schofield <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>--- include/linux/ioport.h | 2 ++ 1 file changed, 2 insertions(+)Quoted 12 lines
include/linux/ioport.h static inline unsigned long resource_ext_type(const struct resource *res) · line 300
Quoted 10 lines
include/linux/ioport.h +2
-0@@ -296,6 +296,8 @@ static inline unsigned long resource_ext_type(const struct resource *res)/* True iff r1 completely contains r2 */ static inline bool resource_contains (const struct resource *r1,const struct resource *r2) { +if (!resource_size (r1) || !resource_size (r2)) +return false;I just worry that some code paths expect the opposite, that it is ok to pass zero size resources and get a true result.
Quoted 6 lines
That is an interesting point, I would say close to philosophic arguments. I guess you mean the zero size resource being the one that is contained inside the non-zero one, because the other option is making my vision blurry. In fact, even that one makes me feel trapped in a window-less room, in summer, with a bunch of economists, I mean philosophers, and my phone without signal for emergency calls.
The regression risk is not philosophic relative to how long this function has returned 'true' for the size == 0 case.
Quoted 2 lines
But maybe it is just my lack of understanding and there exists a good reason for this possibility.
Questions like the following are good to answer when changing long standing behavior:
Did you look at any other resource_contains() user to get a sense of that regression risk?
Is the benefit to changing this higher than that risk?
Would it be better to just document the expectation that the caller should only pass non-zero sized resources to this function?
Re: [PATCH v9 10/27] resource: harden resource_contains
Quoted 37 lines · Dan Williams
Quoted 36 lines · Alejandro Lucero Palau
Quoted 34 lines · Dan Williams
Quoted 26 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
While
resource_containschecks forIORESOURCE_UNSETflag for the resources given, if r1 was initialized with 0 size, the function returns a false positive. This is so because resource start and end fields are unsigned with end initialised to size - 1 by current resource macros.Make the function to check for the resource size for both resources since r2 with size 0 should not be considered as valid for the function purpose.
Signed-off-by Alejandro Lucero <[email protected]>Suggested-by Alison Schofield <[email protected]>Reviewed-by Alison Schofield <[email protected]>Acked-by Bjorn Helgaas <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>--- include/linux/ioport.h | 2 ++ 1 file changed, 2 insertions(+)include/linux/ioport.h +0
-0include/linux/ioport.h static inline unsigned long resource_ext_type(const struct resource *res) · line 300
Quoted 5 lines
include/linux/ioport.h +2
-0@@ -296,6 +296,8 @@ static inline unsigned long resource_ext_type(const struct resource *res)/* True iff r1 completely contains r2 */ static inline bool resource_contains (const struct resource *r1,const struct resource *r2) { +if (!resource_size (r1) || !resource_size (r2)) +return false;I just worry that some code paths expect the opposite, that it is ok to pass zero size resources and get a true result.
Quoted 8 lines
Quoted 6 lines
That is an interesting point, I would say close to philosophic arguments. I guess you mean the zero size resource being the one that is contained inside the non-zero one, because the other option is making my vision blurry. In fact, even that one makes me feel trapped in a window-less room, in summer, with a bunch of economists, I mean philosophers, and my phone without signal for emergency calls.
The regression risk is not philosophic relative to how long this function has returned 'true' for the size == 0 case.
Would not this regression be a good thing?
Because I argue that is not the right thing to do.
Quoted 12 lines
Quoted 2 lines
But maybe it is just my lack of understanding and there exists a good reason for this possibility.
Questions like the following are good to answer when changing long standing behavior:
Did you look at any other
resource_contains()user to get a sense of that regression risk?Is the benefit to changing this higher than that risk?
Would it be better to just document the expectation that the caller should only pass non-zero sized resources to this function?
PATCH v9 11/27 cxl: add function for setting media ready by a driver
In reply to [email protected]From: Alejandro Lucero <[email protected]>
A Type-2 driver may be required to set the memory availability explicitly, for example because there is not a mailbox for doing so through a specific command.
Add a function to the exported CXL API for accelerator drivers having this possibility.
--- drivers/cxl/core/memdev.c | 6 ++++++ include/cxl/cxl.h | 1 + 2 files changed, 7 insertions(+)
drivers/cxl/core/memdev.c +6 -0
@@ -783,6 +783,12 @@ int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type) }EXPORT_SYMBOL_NS_GPL (cxl_release_resource,"CXL" ); +void cxl_set_media_ready (struct cxl_dev_state *cxlds) +{ + cxlds->media_ready = true; +} +EXPORT_SYMBOL_NS_GPL (cxl_set_media_ready,"CXL" ); +static int cxl_memdev_release_file (struct inode *inode,struct file *file) { struct cxl_memdev *cxlmd =
include/cxl/cxl.h +1 -0
@@ -47,4 +47,5 @@ struct pci_dev;int cxl_pci_accel_setup_regs (struct pci_dev *pdev,struct cxl_dev_state *cxlds);int cxl_request_resource (struct cxl_dev_state *cxlds,enum cxl_resource type);int cxl_release_resource (struct cxl_dev_state *cxlds,enum cxl_resource type); +void cxl_set_media_ready (struct cxl_dev_state *cxlds);#endif
Signature · 1 line
2.17.1
PATCH v9 12/27 sfc: set cxl media ready
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Use cxl api accessor for explicitly set media ready as hardware design implies it is ready and there is no device register for stating so.
--- drivers/net/ethernet/sfc/efx_cxl.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/sfc/efx_cxl.c +5 -0
@@ -91,6 +91,11 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err_resource_set; } +/* We do not have the register about media status. Hardware design +* implies it is ready. +*/ +cxl_set_media_ready (cxl->cxlds); + probe_data->cxl = cxl;return 0 ;
Signature · 1 line
2.17.1
Re: [PATCH v9 12/27] sfc: set cxl media ready
Quoted 8 lines · On Mon, 30 Dec 2024 21:44:30 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
Use cxl api accessor for explicitly set media ready as hardware design implies it is ready and there is no device register for stating so.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>Acked-by Edward Cree <[email protected]>
FWIW
Quoted 20 lines
--- drivers/net/ethernet/sfc/efx_cxl.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/ethernet/sfc/efx_cxl.c +5
-0@@ -91,6 +91,11 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err_resource_set; } +/* We do not have the register about media status. Hardware design +* implies it is ready. +*/ +cxl_set_media_ready (cxl->cxlds); + probe_data->cxl = cxl;return 0 ;
PATCH v9 13/27 cxl: prepare memdev creation for type2
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Current cxl core is relying on a CXL_DEVTYPE_CLASSMEM type device when creating a memdev leading to problems when obtaining cxl_memdev_state references from a CXL_DEVTYPE_DEVMEM type. This last device type is managed by a specific vendor driver and does not need same sysfs files since not userspace intervention is expected.
Create a new cxl_mem device type with no attributes for Type2.
Avoid debugfs files relying on existence of cxl_memdev_state.
Make devm_cxl_add_memdev accesible from a accel driver.
--- drivers/cxl/core/cdat.c | 3 +++ drivers/cxl/core/memdev.c | 14 ++++++++++++-- drivers/cxl/core/region.c | 3 ++- drivers/cxl/cxlmem.h | 2 -- drivers/cxl/mem.c | 25 +++++++++++++++++++------ include/cxl/cxl.h | 2 ++ 6 files changed, 38 insertions(+), 11 deletions(-)
drivers/cxl/core/cdat.c +3 -0
@@ -577,6 +577,9 @@ static struct cxl_dpa_perf *cxled_get_dpa_perf(struct cxl_endpoint_decoder *cxlestruct cxl_memdev_state *mds =to_cxl_memdev_state (cxlmd->cxlds);struct cxl_dpa_perf *perf; +if (!mds) +return ERR_PTR (-EINVAL ); +switch (mode) {case CXL_DECODER_RAM : perf = &mds->ram_perf;
drivers/cxl/core/memdev.c +12 -2
@@ -547,9 +547,16 @@ static const struct device_type cxl_memdev_type = { .groups = cxl_memdev_attribute_groups, }; +static const struct device_type cxl_accel_memdev_type = { + .name ="cxl_accel_memdev" , + .release = cxl_memdev_release, + .devnode = cxl_memdev_devnode, +}; +bool is_cxl_memdev (const struct device *dev) { -return dev->type == &cxl_memdev_type; +return (dev->type == &cxl_memdev_type || + dev->type == &cxl_accel_memdev_type); }EXPORT_SYMBOL_NS_GPL (is_cxl_memdev,"CXL" );
@@ -660,7 +667,10 @@ static struct cxl_memdev *cxl_memdev_alloc(struct cxl_dev_state *cxlds, dev->parent = cxlds->dev; dev->bus = &cxl_bus_type; dev->devt =MKDEV (cxl_mem_major, cxlmd->id); - dev->type = &cxl_memdev_type; +if (cxlds->type ==CXL_DEVTYPE_DEVMEM ) + dev->type = &cxl_accel_memdev_type; +else + dev->type = &cxl_memdev_type;device_set_pm_not_required (dev);INIT_WORK (&cxlmd->detach_work, detach_memdev);
drivers/cxl/core/region.c +2 -1
@@ -1948,7 +1948,8 @@ static int cxl_region_attach(struct cxl_region *cxlr,return -EINVAL ; } -cxl_region_perf_data_calculate (cxlr, cxled); +if (cxlr->type ==CXL_DECODER_HOSTONLYMEM ) +cxl_region_perf_data_calculate (cxlr, cxled);if (test_bit (CXL_REGION_F_AUTO , &cxlr->flags)) {int i;
drivers/cxl/cxlmem.h +0 -2
@@ -87,8 +87,6 @@ static inline bool is_cxl_endpoint(struct cxl_port *port)return is_cxl_memdev (port->uport_dev); } -struct cxl_memdev *devm_cxl_add_memdev (struct device *host, -struct cxl_dev_state *cxlds);int devm_cxl_sanitize_setup_notifier (struct device *host,struct cxl_memdev *cxlmd);struct cxl_memdev_state ;
drivers/cxl/mem.c +19 -6
@@ -130,12 +130,18 @@ static int cxl_mem_probe(struct device *dev) dentry =cxl_debugfs_create_dir (dev_name (dev));debugfs_create_devm_seqfile (dev,"dpamem" , dentry, cxl_mem_dpa_show); -if (test_bit (CXL_POISON_ENABLED_INJECT , mds->poison.enabled_cmds)) -debugfs_create_file ("inject_poison" ,0200 , dentry, cxlmd, - &cxl_poison_inject_fops); -if (test_bit (CXL_POISON_ENABLED_CLEAR , mds->poison.enabled_cmds)) -debugfs_create_file ("clear_poison" ,0200 , dentry, cxlmd, - &cxl_poison_clear_fops); +/* +* Avoid poison debugfs files for Type2 devices as they rely on +* cxl_memdev_state. +*/ +if (mds) { +if (test_bit (CXL_POISON_ENABLED_INJECT , mds->poison.enabled_cmds)) +debugfs_create_file ("inject_poison" ,0200 , dentry, cxlmd, + &cxl_poison_inject_fops); +if (test_bit (CXL_POISON_ENABLED_CLEAR , mds->poison.enabled_cmds)) +debugfs_create_file ("clear_poison" ,0200 , dentry, cxlmd, + &cxl_poison_clear_fops); + } rc =devm_add_action_or_reset (dev, remove_debugfs, dentry);if (rc)
@@ -219,6 +225,13 @@ static umode_t cxl_mem_visible(struct kobject *kobj, struct attribute *a, int n)struct cxl_memdev *cxlmd =to_cxl_memdev (dev);struct cxl_memdev_state *mds =to_cxl_memdev_state (cxlmd->cxlds); +/* +* Avoid poison sysfs files for Type2 devices as they rely on +* cxl_memdev_state. +*/ +if (!mds) +return 0 ; +if (a == &dev_attr_trigger_poison_list.attr)if (!test_bit (CXL_POISON_ENABLED_LIST , mds->poison.enabled_cmds))
include/cxl/cxl.h +2 -0
@@ -48,4 +48,6 @@ int cxl_pci_accel_setup_regs(struct pci_dev *pdev, struct cxl_dev_state *cxlds);int cxl_request_resource (struct cxl_dev_state *cxlds,enum cxl_resource type);int cxl_release_resource (struct cxl_dev_state *cxlds,enum cxl_resource type);void cxl_set_media_ready (struct cxl_dev_state *cxlds); +struct cxl_memdev *devm_cxl_add_memdev (struct device *host, +struct cxl_dev_state *cxlds);#endif
Signature · 1 line
2.17.1
Re: [PATCH v9 13/27] cxl: prepare memdev creation for type2
Quoted 11 lines · On Mon, 30 Dec 2024 21:44:31 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
Current cxl core is relying on a
CXL_DEVTYPE_CLASSMEMtype device when creating a memdev leading to problems when obtainingcxl_memdev_statereferences from aCXL_DEVTYPE_DEVMEMtype. This last device type is managed by a specific vendor driver and does not need same sysfs files since not userspace intervention is expected.Create a new
cxl_memdevice type with no attributes for Type2.Avoid debugfs files relying on existence of
cxl_memdev_state.
"Avoid debugfs files that rely on existence of cxl_memdev_state."
Currently it means you keep the files but break their reliance on that state. So subtly different from what is implemented.
Quoted 4 lines
Make
devm_cxl_add_memdevaccesible from a accel driver.Signed-off-by Alejandro Lucero <[email protected]>
Re: [PATCH v9 13/27] cxl: prepare memdev creation for type2
Quoted 11 lines · Jonathan Cameron
Quoted 8 lines · On Mon, 30 Dec 2024 21:44:31 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
Current cxl core is relying on a
CXL_DEVTYPE_CLASSMEMtype device when creating a memdev leading to problems when obtainingcxl_memdev_statereferences from aCXL_DEVTYPE_DEVMEMtype. This last device type is managed by a specific vendor driver and does not need same sysfs files since not userspace intervention is expected.
Quoted 7 lines
Quoted 3 lines
Create a new
cxl_memdevice type with no attributes for Type2.Avoid debugfs files relying on existence of
cxl_memdev_state."Avoid debugfs files that rely on existence of
cxl_memdev_state."Currently it means you keep the files but break their reliance on that state. So subtly different from what is implemented.
It makes sense.
I'll fix it in v10.
Thanks!
Quoted 6 lines
Quoted 3 lines
Make
devm_cxl_add_memdevaccesible from a accel driver.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>
Re: [PATCH v9 13/27] cxl: prepare memdev creation for type2
In reply to [email protected]Quoted 29 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Current cxl core is relying on a
CXL_DEVTYPE_CLASSMEMtype device when creating a memdev leading to problems when obtainingcxl_memdev_statereferences from aCXL_DEVTYPE_DEVMEMtype. This last device type is managed by a specific vendor driver and does not need same sysfs files since not userspace intervention is expected.Create a new
cxl_memdevice type with no attributes for Type2.Avoid debugfs files relying on existence of
cxl_memdev_state.Make
devm_cxl_add_memdevaccesible from a accel driver.Signed-off-by Alejandro Lucero <[email protected]>--- drivers/cxl/core/cdat.c | 3 +++ drivers/cxl/core/memdev.c | 14 ++++++++++++-- drivers/cxl/core/region.c | 3 ++- drivers/cxl/cxlmem.h | 2 -- drivers/cxl/mem.c | 25 +++++++++++++++++++------ include/cxl/cxl.h | 2 ++ 6 files changed, 38 insertions(+), 11 deletions(-)drivers/cxl/core/cdat.c +0
-0
drivers/cxl/core/cdat.c static struct cxl_dpa_perf *cxled_get_dpa_perf(struct cxl_endpoint_decoder *cxle · line 582
Quoted 6 lines
drivers/cxl/core/cdat.c +3
-0@@ -577,6 +577,9 @@ static struct cxl_dpa_perf *cxled_get_dpa_perf(struct cxl_endpoint_decoder *cxlestruct cxl_memdev_state *mds =to_cxl_memdev_state (cxlmd->cxlds);struct cxl_dpa_perf *perf; +if (!mds) +return ERR_PTR (-EINVAL ); +
The references to @mds in cxled_get_dpa_perf() are gone after the DPA partition changes.
If an accelerator has a CDAT it will get qos_class information for free. If it does not have a CDAT then I wonder how it is telling the BIOS the memory type for its CXL.mem?
Quoted 12 lines
drivers/cxl/core/cdat.c +0
-0switch (mode) {case CXL_DECODER_RAM : perf = &mds->ram_perf;drivers/cxl/core/memdev.c +1
-0@@ -547,9 +547,16 @@ static const struct device_type cxl_memdev_type = { .groups = cxl_memdev_attribute_groups, }; +static const struct device_type cxl_accel_memdev_type = {
drivers/cxl/core/memdev.c static const struct device_type cxl_memdev_type = { · line 559
Quoted 10 lines
drivers/cxl/core/memdev.c +7
-1+ .name = "cxl_accel_memdev", + .release = cxl_memdev_release, + .devnode = cxl_memdev_devnode, +}; +bool is_cxl_memdev (const struct device *dev) { -return dev->type == &cxl_memdev_type; +return (dev->type == &cxl_memdev_type || + dev->type == &cxl_accel_memdev_type);
At this point the game is over in terms of future code that trips over the assumption that all "is_cxl_memdev() == true" devices are created equal.
Quoted 20 lines
drivers/cxl/core/memdev.c +4
-1}EXPORT_SYMBOL_NS_GPL (is_cxl_memdev,"CXL" );@@ -660,7 +667,10 @@ static struct cxl_memdev *cxl_memdev_alloc(struct cxl_dev_state *cxlds, dev->parent = cxlds->dev; dev->bus = &cxl_bus_type; dev->devt =MKDEV (cxl_mem_major, cxlmd->id); - dev->type = &cxl_memdev_type; +if (cxlds->type ==CXL_DEVTYPE_DEVMEM ) + dev->type = &cxl_accel_memdev_type; +else + dev->type = &cxl_memdev_type;device_set_pm_not_required (dev);INIT_WORK (&cxlmd->detach_work, detach_memdev);drivers/cxl/core/region.c +0
-0
drivers/cxl/core/region.c static int cxl_region_attach(struct cxl_region *cxlr, · line 1952
Quoted 6 lines
drivers/cxl/core/region.c +2
-1@@ -1948,7 +1948,8 @@ static int cxl_region_attach(struct cxl_region *cxlr,return -EINVAL ; } -cxl_region_perf_data_calculate (cxlr, cxled); +if (cxlr->type ==CXL_DECODER_HOSTONLYMEM ) +cxl_region_perf_data_calculate (cxlr, cxled);
Per-above no need to worry about @mds reference in this path.
Quoted 45 lines
drivers/cxl/core/region.c +0
-0if (test_bit (CXL_REGION_F_AUTO , &cxlr->flags)) {int i;drivers/cxl/cxlmem.h +0
-2@@ -87,8 +87,6 @@ static inline bool is_cxl_endpoint(struct cxl_port *port)return is_cxl_memdev (port->uport_dev); } -struct cxl_memdev *devm_cxl_add_memdev (struct device *host, -struct cxl_dev_state *cxlds);int devm_cxl_sanitize_setup_notifier (struct device *host,struct cxl_memdev *cxlmd);struct cxl_memdev_state ;drivers/cxl/mem.c +12
-6@@ -130,12 +130,18 @@ static int cxl_mem_probe(struct device *dev) dentry =cxl_debugfs_create_dir (dev_name (dev));debugfs_create_devm_seqfile (dev,"dpamem" , dentry, cxl_mem_dpa_show); -if (test_bit (CXL_POISON_ENABLED_INJECT , mds->poison.enabled_cmds)) -debugfs_create_file ("inject_poison" ,0200 , dentry, cxlmd, - &cxl_poison_inject_fops); -if (test_bit (CXL_POISON_ENABLED_CLEAR , mds->poison.enabled_cmds)) -debugfs_create_file ("clear_poison" ,0200 , dentry, cxlmd, - &cxl_poison_clear_fops); +/* +* Avoid poison debugfs files for Type2 devices as they rely on +* cxl_memdev_state. +*/ +if (mds) { +if (test_bit (CXL_POISON_ENABLED_INJECT , mds->poison.enabled_cmds)) +debugfs_create_file ("inject_poison" ,0200 , dentry, cxlmd, + &cxl_poison_inject_fops); +if (test_bit (CXL_POISON_ENABLED_CLEAR , mds->poison.enabled_cmds)) +debugfs_create_file ("clear_poison" ,0200 , dentry, cxlmd, + &cxl_poison_clear_fops); + } rc =devm_add_action_or_reset (dev, remove_debugfs, dentry);if (rc)
drivers/cxl/mem.c static umode_t cxl_mem_visible(struct kobject *kobj, struct attribute *a, int n) · line 233
Quoted 9 lines
drivers/cxl/mem.c +6
-0@@ -219,6 +225,13 @@ static umode_t cxl_mem_visible(struct kobject *kobj, struct attribute *a, int n)struct cxl_memdev *cxlmd =to_cxl_memdev (dev);struct cxl_memdev_state *mds =to_cxl_memdev_state (cxlmd->cxlds); +/* +* Avoid poison sysfs files for Type2 devices as they rely on +* cxl_memdev_state. +*/ +if (!mds) +return 0 ;
It turns out that nothing in the poison handling path requires 'struct cxl_memdev_state'. So rather than key this rejection off of @mds == NULL, I would prefer to find a way to make this optional relative to data read from 'struct cxl_mailbox', or 'struct cxl_dev_state'. Conceptually there is nothing stopping a CXL accelertor from supporting poison management commands on its mailbox, it's just unlikely.
Re: [PATCH v9 13/27] cxl: prepare memdev creation for type2
Quoted 33 lines · Dan Williams
Quoted 32 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Current cxl core is relying on a
CXL_DEVTYPE_CLASSMEMtype device when creating a memdev leading to problems when obtainingcxl_memdev_statereferences from aCXL_DEVTYPE_DEVMEMtype. This last device type is managed by a specific vendor driver and does not need same sysfs files since not userspace intervention is expected.Create a new
cxl_memdevice type with no attributes for Type2.Avoid debugfs files relying on existence of
cxl_memdev_state.Make
devm_cxl_add_memdevaccesible from a accel driver.Signed-off-by Alejandro Lucero <[email protected]>--- drivers/cxl/core/cdat.c | 3 +++ drivers/cxl/core/memdev.c | 14 ++++++++++++-- drivers/cxl/core/region.c | 3 ++- drivers/cxl/cxlmem.h | 2 -- drivers/cxl/mem.c | 25 +++++++++++++++++++------ include/cxl/cxl.h | 2 ++ 6 files changed, 38 insertions(+), 11 deletions(-)drivers/cxl/core/cdat.c +0
-0@@ -577,6 +577,9 @@ static struct cxl_dpa_perf *cxled_get_dpa_perf(struct cxl_endpoint_decoder *cxlestruct cxl_memdev_state *mds =to_cxl_memdev_state (cxlmd->cxlds);struct cxl_dpa_perf *perf;
Quoted 5 lines
drivers/cxl/core/cdat.c static struct cxl_dpa_perf *cxled_get_dpa_perf(struct cxl_endpoint_decoder *cxle · line 582
Quoted 3 lines
drivers/cxl/core/cdat.c +3
-0+if (!mds) +return ERR_PTR (-EINVAL ); +The references to @mds in
cxled_get_dpa_perf()are gone after the DPA partition changes.
OK
Quoted 4 lines
If an accelerator has a CDAT it will get
qos_classinformation for free. If it does not have a CDAT then I wonder how it is telling the BIOS the memory type for its CXL.mem?
AFAIK, this is not mandatory, and the BIOS will look at CXL DVSEC for finding out. So no perf data is mandatory.
FWIW, our device will export a CDAT via PCI option rom since we have to avoid the BIOS doing things we do not want to like testing the memory as some BIOS seem to do in some debug/test mode, and to advertise this flag we discussed in v1/RFC for the kernel doing nothing with that memory when found in the HMAT table.
Quoted 11 lines
Quoted 11 lines
drivers/cxl/core/cdat.c +0
-0switch (mode) {case CXL_DECODER_RAM : perf = &mds->ram_perf;drivers/cxl/core/memdev.c +0
-0@@ -547,9 +547,16 @@ static const struct device_type cxl_memdev_type = { .groups = cxl_memdev_attribute_groups, };
Quoted 14 lines
drivers/cxl/core/memdev.c static const struct device_type cxl_memdev_type = { · line 559
Quoted 11 lines
drivers/cxl/core/memdev.c +8
-1+static const struct device_type cxl_accel_memdev_type = { + .name ="cxl_accel_memdev" , + .release = cxl_memdev_release, + .devnode = cxl_memdev_devnode, +}; +bool is_cxl_memdev (const struct device *dev) { -return dev->type == &cxl_memdev_type; +return (dev->type == &cxl_memdev_type || + dev->type == &cxl_accel_memdev_type);At this point the game is over in terms of future code that trips over the assumption that all "
is_cxl_memdev()== true" devices are created equal.
Yep.
Quoted 23 lines
Quoted 23 lines
drivers/cxl/core/memdev.c +4
-1}EXPORT_SYMBOL_NS_GPL (is_cxl_memdev,"CXL" );@@ -660,7 +667,10 @@ static struct cxl_memdev *cxl_memdev_alloc(struct cxl_dev_state *cxlds, dev->parent = cxlds->dev; dev->bus = &cxl_bus_type; dev->devt =MKDEV (cxl_mem_major, cxlmd->id); - dev->type = &cxl_memdev_type; +if (cxlds->type ==CXL_DEVTYPE_DEVMEM ) + dev->type = &cxl_accel_memdev_type; +else + dev->type = &cxl_memdev_type;device_set_pm_not_required (dev);INIT_WORK (&cxlmd->detach_work, detach_memdev);drivers/cxl/core/region.c +0
-0@@ -1948,7 +1948,8 @@ static int cxl_region_attach(struct cxl_region *cxlr,return -EINVAL ; }
Quoted 4 lines
drivers/cxl/core/region.c static int cxl_region_attach(struct cxl_region *cxlr, · line 1952
Quoted 3 lines
drivers/cxl/core/region.c +2
-1-cxl_region_perf_data_calculate (cxlr, cxled); +if (cxlr->type ==CXL_DECODER_HOSTONLYMEM ) +cxl_region_perf_data_calculate (cxlr, cxled);Per-above no need to worry about @mds reference in this path.
I'll adapt it.
Quoted 49 lines
Quoted 49 lines
drivers/cxl/core/region.c +0
-0if (test_bit (CXL_REGION_F_AUTO , &cxlr->flags)) {int i;drivers/cxl/cxlmem.h +0
-2@@ -87,8 +87,6 @@ static inline bool is_cxl_endpoint(struct cxl_port *port)return is_cxl_memdev (port->uport_dev); } -struct cxl_memdev *devm_cxl_add_memdev (struct device *host, -struct cxl_dev_state *cxlds);int devm_cxl_sanitize_setup_notifier (struct device *host,struct cxl_memdev *cxlmd);struct cxl_memdev_state ;drivers/cxl/mem.c +12
-6@@ -130,12 +130,18 @@ static int cxl_mem_probe(struct device *dev) dentry =cxl_debugfs_create_dir (dev_name (dev));debugfs_create_devm_seqfile (dev,"dpamem" , dentry, cxl_mem_dpa_show); -if (test_bit (CXL_POISON_ENABLED_INJECT , mds->poison.enabled_cmds)) -debugfs_create_file ("inject_poison" ,0200 , dentry, cxlmd, - &cxl_poison_inject_fops); -if (test_bit (CXL_POISON_ENABLED_CLEAR , mds->poison.enabled_cmds)) -debugfs_create_file ("clear_poison" ,0200 , dentry, cxlmd, - &cxl_poison_clear_fops); +/* +* Avoid poison debugfs files for Type2 devices as they rely on +* cxl_memdev_state. +*/ +if (mds) { +if (test_bit (CXL_POISON_ENABLED_INJECT , mds->poison.enabled_cmds)) +debugfs_create_file ("inject_poison" ,0200 , dentry, cxlmd, + &cxl_poison_inject_fops); +if (test_bit (CXL_POISON_ENABLED_CLEAR , mds->poison.enabled_cmds)) +debugfs_create_file ("clear_poison" ,0200 , dentry, cxlmd, + &cxl_poison_clear_fops); + } rc =devm_add_action_or_reset (dev, remove_debugfs, dentry);if (rc)@@ -219,6 +225,13 @@ static umode_t cxl_mem_visible(struct kobject *kobj, struct attribute *a, int n)struct cxl_memdev *cxlmd =to_cxl_memdev (dev);struct cxl_memdev_state *mds =to_cxl_memdev_state (cxlmd->cxlds);
Quoted 12 lines
drivers/cxl/mem.c static umode_t cxl_mem_visible(struct kobject *kobj, struct attribute *a, int n) · line 233
Quoted 6 lines
drivers/cxl/mem.c +6
-0+/* +* Avoid poison sysfs files for Type2 devices as they rely on +* cxl_memdev_state. +*/ +if (!mds) +return 0 ;It turns out that nothing in the poison handling path requires 'struct
cxl_memdev_state'. So rather than key this rejection off of @mds == NULL, I would prefer to find a way to make this optional relative to data read from 'structcxl_mailbox', or 'structcxl_dev_state'. Conceptually there is nothing stopping a CXL accelertor from supporting poison management commands on its mailbox, it's just unlikely.
Right. This is the easiest path for the initial type2 support SFC requires, but I agree it should cover other options as well.
I'll work on it for v10 and if not a major work, I'll do it.
Thanks
Re: [PATCH v9 13/27] cxl: prepare memdev creation for type2
Alejandro Lucero Palau wrote:
[..]
Quoted 6 lines
Quoted 3 lines
If an accelerator has a CDAT it will get
qos_classinformation for free. If it does not have a CDAT then I wonder how it is telling the BIOS the memory type for its CXL.mem?AFAIK, this is not mandatory, and the BIOS will look at CXL DVSEC for finding out. So no perf data is mandatory.
Right.
Quoted 5 lines
FWIW, our device will export a CDAT via PCI option rom since we have to avoid the BIOS doing things we do not want to like testing the memory as some BIOS seem to do in some debug/test mode, and to advertise this flag we discussed in v1/RFC for the kernel doing nothing with that memory when found in the HMAT table.
As long as devices that put standard things in standard places get standard Linux enabling, I am satisfied.
As for the comment about HMAT, I am not sure what that is referring?
The kernel should not need any other consideration for CXL accelerators. Either accelerator memory is properly marked Reserved in the EFI map, or it is not. It is a BIOS bug if it maps accelerator memory as EFI Conventional Memory (with or without the EFI_MEMORY_SP) and per the EFI spec the kernel has no responsibility to fix that up.
PATCH v9 14/27 sfc: create type2 cxl memdev
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Use cxl API for creating a cxl memory device using the type2 cxl_dev_state struct.
--- drivers/net/ethernet/sfc/efx_cxl.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/ethernet/sfc/efx_cxl.c +9 -0
@@ -96,10 +96,19 @@ int efx_cxl_init(struct efx_probe_data *probe_data)*/ cxl_set_media_ready (cxl->cxlds); + cxl->cxlmd =devm_cxl_add_memdev (&pci_dev->dev, cxl->cxlds); +if (IS_ERR (cxl->cxlmd)) { +pci_err (pci_dev,"CXL accel memdev creation failed" ); + rc =PTR_ERR (cxl->cxlmd); + goto err_memdev; + } + probe_data->cxl = cxl;return 0 ; +err_memdev: +cxl_release_resource (cxl->cxlds,CXL_RES_RAM ); err_resource_set:kfree (cxl->cxlds); err_state:
Signature · 1 line
2.17.1
Re: [PATCH v9 14/27] sfc: create type2 cxl memdev
Quoted 19 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Use cxl API for creating a cxl memory device using the type2
cxl_dev_statestruct.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>Reviewed-by Fan Ni <[email protected]>Acked-by Edward Cree <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>--- drivers/net/ethernet/sfc/efx_cxl.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/net/ethernet/sfc/efx_cxl.c +0
-0
drivers/net/ethernet/sfc/efx_cxl.c int efx_cxl_init(struct efx_probe_data *probe_data) · line 97
Quoted 2 lines
drivers/net/ethernet/sfc/efx_cxl.c +0
-0@@ -96,10 +96,19 @@ int efx_cxl_init(struct efx_probe_data *probe_data)*/ cxl_set_media_ready (cxl->cxlds);
It is unfortunate the media_ready is just being used as an offline/online flag for memdevs. I would be open to just switching to typical device online/offline semantics and drop the "media_ready" flag.
Quoted 6 lines
drivers/net/ethernet/sfc/efx_cxl.c +5
-0+ cxl->cxlmd =devm_cxl_add_memdev (&pci_dev->dev, cxl->cxlds); +if (IS_ERR (cxl->cxlmd)) { +pci_err (pci_dev,"CXL accel memdev creation failed" ); + rc =PTR_ERR (cxl->cxlmd); + goto err_memdev;
drivers/net/ethernet/sfc/efx_cxl.c int efx_cxl_init(struct efx_probe_data *probe_data) · line 113
Quoted 10 lines
drivers/net/ethernet/sfc/efx_cxl.c +4
-0+ } + probe_data->cxl = cxl;return 0 ; +err_memdev: +cxl_release_resource (cxl->cxlds,CXL_RES_RAM ); err_resource_set:kfree (cxl->cxlds);
In general a function should not mix devm and goto as that is a recipe for bugs.
The bug I see here is that devm_cxl_add_memdev() runs the teardown flow *after* efx_pci_probe() returns an error code. That happens in device_unbind_cleanup(), but when it goes to cleanup endpoint decoders and anything else that might reference @cxlds it crashes because @cxlds is long gone.
So if you use devm_cxl_add_memdev() then cxlds must be devm allocated as well to make sure it gets freed in the proper reverse order.
Re: [PATCH v9 14/27] sfc: create type2 cxl memdev
Quoted 15 lines · Dan Williams
Quoted 14 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Use cxl API for creating a cxl memory device using the type2
cxl_dev_statestruct.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>Reviewed-by Fan Ni <[email protected]>Acked-by Edward Cree <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>--- drivers/net/ethernet/sfc/efx_cxl.c | 9 +++++++++ 1 file changed, 9 insertions(+)
Quoted 10 lines
drivers/net/ethernet/sfc/efx_cxl.c int efx_cxl_init(struct efx_probe_data *probe_data) · line 97
Quoted 7 lines
drivers/net/ethernet/sfc/efx_cxl.c +0
-0@@ -96,10 +96,19 @@ int efx_cxl_init(struct efx_probe_data *probe_data)*/ cxl_set_media_ready (cxl->cxlds);It is unfortunate the
media_readyis just being used as an offline/online flag for memdevs. I would be open to just switching to typical device online/offline semantics and drop the "media_ready" flag.
Not sure I understand the semantics here. Note our device, as the related register being optional, has no way for asking the HW about this (by CXL means), mainly because it is not necessary. I guess this hardware state is there because it can be needed, but again, not sure I understand media-ready vs memory online.
Quoted 20 lines
Quoted 7 lines
drivers/net/ethernet/sfc/efx_cxl.c +5
-0+ cxl->cxlmd =devm_cxl_add_memdev (&pci_dev->dev, cxl->cxlds); +if (IS_ERR (cxl->cxlmd)) { +pci_err (pci_dev,"CXL accel memdev creation failed" ); + rc =PTR_ERR (cxl->cxlmd); + goto err_memdev;drivers/net/ethernet/sfc/efx_cxl.c int efx_cxl_init(struct efx_probe_data *probe_data) · line 113
Quoted 10 lines
drivers/net/ethernet/sfc/efx_cxl.c +4
-0+ } + probe_data->cxl = cxl;return 0 ; +err_memdev: +cxl_release_resource (cxl->cxlds,CXL_RES_RAM ); err_resource_set:kfree (cxl->cxlds);In general a function should not mix devm and goto as that is a recipe for bugs.
Quoted 8 lines
The bug I see here is that
devm_cxl_add_memdev()runs the teardown flow *after*efx_pci_probe()returns an error code. That happens indevice_unbind_cleanup(), but when it goes to cleanup endpoint decoders and anything else that might reference @cxlds it crashes because @cxlds is long gone.So if you use
devm_cxl_add_memdev()then cxlds must be devm allocated as well to make sure it gets freed in the proper reverse order.
That is true and I think it is easy to fix, even with your changes for patch 1.
I'll show it in v10.
Thanks!
Re: [PATCH v9 14/27] sfc: create type2 cxl memdev
Quoted 29 lines · Alejandro Lucero Palau
Quoted 15 lines · Dan Williams
Quoted 14 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
Use cxl API for creating a cxl memory device using the type2
cxl_dev_statestruct.Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>Reviewed-by Fan Ni <[email protected]>Acked-by Edward Cree <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>--- drivers/net/ethernet/sfc/efx_cxl.c | 9 +++++++++ 1 file changed, 9 insertions(+)Quoted 10 lines
drivers/net/ethernet/sfc/efx_cxl.c int efx_cxl_init(struct efx_probe_data *probe_data) · line 97
Quoted 7 lines
drivers/net/ethernet/sfc/efx_cxl.c +0
-0@@ -96,10 +96,19 @@ int efx_cxl_init(struct efx_probe_data *probe_data)*/ cxl_set_media_ready (cxl->cxlds);It is unfortunate the
media_readyis just being used as an offline/online flag for memdevs. I would be open to just switching to typical device online/offline semantics and drop the "media_ready" flag.
Quoted 5 lines
Not sure I understand the semantics here. Note our device, as the related register being optional, has no way for asking the HW about this (by CXL means), mainly because it is not necessary. I guess this hardware state is there because it can be needed, but again, not sure I understand media-ready vs memory online.
The ->media_ready flag gates capacity discovery for memory expanders (no impact to accelerators) *and* it gates whether cxl_mem_probe() even attempts to talk to the device.
The concern is that it should be removed from 'struct cxl_dev_state' if it cannot have common meaning across all CXL.mem capable devices. One way to remove it from 'struct cxl_dev_state' while still preserving the memory expander use case is to notice that ->media_ready is effectively identical to the 'struct device' @offline flag.
For now, just have the accelerator driver set ->media_ready and we can work on cleaning up that direct 'struct cxl_dev_state' touch later.
Quoted 24 lines
Quoted 24 lines
Quoted 5 lines
drivers/net/ethernet/sfc/efx_cxl.c +5
-0+ cxl->cxlmd =devm_cxl_add_memdev (&pci_dev->dev, cxl->cxlds); +if (IS_ERR (cxl->cxlmd)) { +pci_err (pci_dev,"CXL accel memdev creation failed" ); + rc =PTR_ERR (cxl->cxlmd); + goto err_memdev;drivers/net/ethernet/sfc/efx_cxl.c int efx_cxl_init(struct efx_probe_data *probe_data) · line 113
Quoted 10 lines
drivers/net/ethernet/sfc/efx_cxl.c +4
-0+ } + probe_data->cxl = cxl;return 0 ; +err_memdev: +cxl_release_resource (cxl->cxlds,CXL_RES_RAM ); err_resource_set:kfree (cxl->cxlds);In general a function should not mix devm and goto as that is a recipe for bugs.
The bug I see here is that
devm_cxl_add_memdev()runs the teardown flow *after*efx_pci_probe()returns an error code. That happens indevice_unbind_cleanup(), but when it goes to cleanup endpoint decoders and anything else that might reference @cxlds it crashes because @cxlds is long gone.
Quoted 5 lines
Quoted 2 lines
So if you use
devm_cxl_add_memdev()then cxlds must be devm allocated as well to make sure it gets freed in the proper reverse order.That is true and I think it is easy to fix, even with your changes for patch 1.
Yes, just add a devm_cxl_del_memdev() export for now that can be used unwind CXL core objects without requiring the driver to switch to devm more broadly.
PATCH v9 15/27 cxl: define a driver interface for HPA free space enumeration
In reply to [email protected]From: Alejandro Lucero <[email protected]>
CXL region creation involves allocating capacity from device DPA (device-physical-address space) and assigning it to decode a given HPA (host-physical-address space). Before determining how much DPA to allocate the amount of available HPA must be determined. Also, not all HPA is created equal, some specifically targets RAM, some target PMEM, some is prepared for device-memory flows like HDM-D and HDM-DB, and some is host-only (HDM-H).
Wrap all of those concerns into an API that retrieves a root decoder (platform CXL window) that fits the specified constraints and the capacity available for a new region.
--- drivers/cxl/core/region.c | 155 ++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 3 + include/cxl/cxl.h | 8 ++ 3 files changed, 166 insertions(+)
drivers/cxl/core/region.c +155 -0
@@ -687,6 +687,161 @@ static int free_hpa(struct cxl_region *cxlr)return 0 ; } +struct cxlrd_max_context { +struct device *host_bridge; +unsigned long flags; +resource_size_t max_hpa; +struct cxl_root_decoder *cxlrd; +}; + +static int find_max_hpa (struct device *dev,void *data) +{ +struct cxlrd_max_context *ctx = data; +struct cxl_switch_decoder *cxlsd; +struct cxl_root_decoder *cxlrd; +struct resource *res, *prev; +struct cxl_decoder *cxld; +resource_size_t max; + +if (!is_root_decoder (dev)) +return 0 ; + + cxlrd =to_cxl_root_decoder (dev); + cxlsd = &cxlrd->cxlsd; + cxld = &cxlsd->cxld; +if ((cxld->flags & ctx->flags) != ctx->flags) { +dev_dbg (dev,"%s, flags not matching: %08lx vs %08lx\n" , + __func__, cxld->flags, ctx->flags); +return 0 ; + } + +/* +* The CXL specs do not forbid an accelerator being part of an +* interleaved HPA range, but it is unlikely and because it simplifies +* the code, don´t allow it. +*/ +if (cxld->interleave_ways !=1 ) { +dev_dbg (dev,"interleave_ways not matching\n" ); +return 0 ; + } + +guard (rwsem_read)(&cxl_region_rwsem); +if (ctx->host_bridge != cxlsd->target[0 ]->dport_dev) { +dev_dbg (dev,"host bridge does not match\n" ); +return 0 ; + } + +/* +* Walk the root decoder resource range relying on cxl_region_rwsem to +* preclude sibling arrival/departure and find the largest free space +* gap. +*/ +lockdep_assert_held_read (&cxl_region_rwsem); + max =0 ; + res = cxlrd->res->child; + +/* With no resource child the whole parent resource is available */ +if (!res) + max =resource_size (cxlrd->res); +else + max =0 ; + +for (prev =NULL ; res; prev = res, res = res->sibling) { +struct resource *next = res->sibling; +resource_size_t free =0 ; + +/* +* Sanity check for preventing arithmetic problems below as a +* resource with size 0 could imply using the end field below +* when set to unsigned zero - 1 or all f in hex. +*/ +if (prev && !resource_size (prev)) +continue ; + +if (!prev && res->start > cxlrd->res->start) { + free = res->start - cxlrd->res->start; + max =max (free, max); + } +if (prev && res->start > prev->end +1 ) { + free = res->start - prev->end +1 ; + max =max (free, max); + } +if (next && res->end +1 < next->start) { + free = next->start - res->end +1 ; + max =max (free, max); + } +if (!next && res->end +1 < cxlrd->res->end +1 ) { + free = cxlrd->res->end +1 - res->end +1 ; + max =max (free, max); + } + } + +dev_dbg (CXLRD_DEV (cxlrd),"found %pa bytes of free space\n" , &max); +if (max > ctx->max_hpa) { +if (ctx->cxlrd) +put_device (CXLRD_DEV (ctx->cxlrd)); +get_device (CXLRD_DEV (cxlrd)); + ctx->cxlrd = cxlrd; + ctx->max_hpa = max; +dev_dbg (CXLRD_DEV (cxlrd),"found %pa bytes of free space\n" , + &max); + } +return 0 ; +} + +/** +* cxl_get_hpa_freespace - find a root decoder with free capacity per constraints +* @cxlmd: the CXL memory device with an endpoint that is mapped by the returned +* decoder +* @flags: CXL_DECODER_F flags for selecting RAM vs PMEM, and HDM-H vs HDM-D[B] +* @max_avail_contig: output parameter of max contiguous bytes available in the +* returned decoder +* +* The return tuple of a 'struct cxl_root_decoder' and 'bytes available given +* in (@max_avail_contig))' is a point in time snapshot. If by the time the +* caller goes to use this root decoder's capacity the capacity is reduced then +* caller needs to loop and retry. +* +* The returned root decoder has an elevated reference count that needs to be +* put with put_device(cxlrd_dev(cxlrd)). Locking context is with +* cxl_{acquire,release}_endpoint(), that ensures removal of the root decoder +* does not race. +*/ +struct cxl_root_decoder *cxl_get_hpa_freespace (struct cxl_memdev *cxlmd, +unsigned long flags, +resource_size_t *max_avail_contig) +{ +struct cxl_port *endpoint = cxlmd->endpoint; +struct cxlrd_max_context ctx = { + .host_bridge = endpoint->host_bridge, + .flags = flags, + }; +struct cxl_port *root_port; + struct cxl_root *root __free(put_cxl_root) = find_cxl_root(endpoint); + +if (!is_cxl_endpoint (endpoint)) { +dev_dbg (&endpoint->dev,"hpa requestor is not an endpoint\n" ); +return ERR_PTR (-EINVAL ); + } + +if (!root) { +dev_dbg (&endpoint->dev,"endpoint can not be related to a root port\n" ); +return ERR_PTR (-ENXIO ); + } + + root_port = &root->port; +down_read (&cxl_region_rwsem); +device_for_each_child (&root_port->dev, &ctx, find_max_hpa); +up_read (&cxl_region_rwsem); + +if (!ctx.cxlrd) +return ERR_PTR (-ENOMEM ); + + *max_avail_contig = ctx.max_hpa; +return ctx.cxlrd; +} +EXPORT_SYMBOL_NS_GPL (cxl_get_hpa_freespace,"CXL" ); +static ssize_t size_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t len) {
drivers/cxl/cxl.h +3 -0
@@ -785,6 +785,9 @@ static inline void cxl_dport_init_ras_reporting(struct cxl_dport *dport,struct cxl_decoder *to_cxl_decoder (struct device *dev);struct cxl_root_decoder *to_cxl_root_decoder (struct device *dev);struct cxl_switch_decoder *to_cxl_switch_decoder (struct device *dev); + +#define CXLRD_DEV (cxlrd) (&(cxlrd)->cxlsd.cxld.dev) +struct cxl_endpoint_decoder *to_cxl_endpoint_decoder (struct device *dev);bool is_root_decoder (struct device *dev);bool is_switch_decoder (struct device *dev);
include/cxl/cxl.h +8 -0
@@ -6,6 +6,10 @@#include <linux/ioport.h> +#define CXL_DECODER_F_RAM BIT(0) +#define CXL_DECODER_F_PMEM BIT(1) +#define CXL_DECODER_F_TYPE2 BIT(2) +enum cxl_resource {CXL_RES_DPA ,CXL_RES_RAM ,
@@ -50,4 +54,8 @@ int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type);void cxl_set_media_ready (struct cxl_dev_state *cxlds);struct cxl_memdev *devm_cxl_add_memdev (struct device *host,struct cxl_dev_state *cxlds); +struct cxl_port ; +struct cxl_root_decoder *cxl_get_hpa_freespace (struct cxl_memdev *cxlmd, +unsigned long flags, +resource_size_t *max);#endif
Signature · 1 line
2.17.1
Re: [PATCH v9 15/27] cxl: define a driver interface for HPA free space enumeration
Quoted 10 lines · On Mon, 30 Dec 2024 21:44:33 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
CXL region creation involves allocating capacity from device DPA (device-physical-address space) and assigning it to decode a given HPA (host-physical-address space). Before determining how much DPA to allocate the amount of available HPA must be determined. Also, not all HPA is created equal, some specifically targets RAM, some target PMEM, some is prepared for device-memory flows like HDM-D and HDM-DB, and some is host-only (HDM-H).
Quoted 8 lines
Wrap all of those concerns into an API that retrieves a root decoder (platform CXL window) that fits the specified constraints and the capacity available for a new region.
Signed-off-by Alejandro Lucero <[email protected]>Co-developed-by Dan Williams <[email protected]>
A couple of trivial things inline.
With those tidied up.
Quoted 29 lines
--- drivers/cxl/core/region.c | 155 ++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 3 + include/cxl/cxl.h | 8 ++ 3 files changed, 166 insertions(+)drivers/cxl/core/region.c +15
-0@@ -687,6 +687,161 @@ static int free_hpa(struct cxl_region *cxlr)return 0 ; } +struct cxlrd_max_context { +struct device *host_bridge; +unsigned long flags; +resource_size_t max_hpa; +struct cxl_root_decoder *cxlrd; +}; + +static int find_max_hpa (struct device *dev,void *data) +{ +struct cxlrd_max_context *ctx = data; +struct cxl_switch_decoder *cxlsd; +struct cxl_root_decoder *cxlrd; +struct resource *res, *prev; +struct cxl_decoder *cxld; +resource_size_t max;
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 714
Quoted 10 lines
drivers/cxl/core/region.c +10
-0+ +if (!is_root_decoder (dev)) +return 0 ; + + cxlrd =to_cxl_root_decoder (dev); + cxlsd = &cxlrd->cxlsd; + cxld = &cxlsd->cxld; +if ((cxld->flags & ctx->flags) != ctx->flags) { +dev_dbg (dev,"%s, flags not matching: %08lx vs %08lx\n" , + __func__, cxld->flags, ctx->flags);
Another __func__ to drop.
Check for other cases where dynamic debug applies.
Quoted 6 lines
drivers/cxl/core/region.c +6
-0+ +/** +* cxl_get_hpa_freespace - find a root decoder with free capacity per constraints +* @cxlmd: the CXL memory device with an endpoint that is mapped by the returned +* decoder +* @flags: CXL_DECODER_F flags for selecting RAM vs PMEM, and HDM-H vs HDM-D[B]
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 806
Quoted 10 lines
drivers/cxl/core/region.c +10
-0+* @max_avail_contig: output parameter of max contiguous bytes available in the +* returned decoder +* +* The return tuple of a 'struct cxl_root_decoder' and 'bytes available given +* in (@max_avail_contig))' is a point in time snapshot. If by the time the +* caller goes to use this root decoder's capacity the capacity is reduced then +* caller needs to loop and retry. +* +* The returned root decoder has an elevated reference count that needs to be +* put with put_device(cxlrd_dev(cxlrd)). Locking context is with
put_device(CXLRD_DEV(cxlrd))
Quoted 38 lines
drivers/cxl/core/region.c +38
-0+* cxl_{acquire,release}_endpoint(), that ensures removal of the root decoder +* does not race. +*/ +struct cxl_root_decoder *cxl_get_hpa_freespace (struct cxl_memdev *cxlmd, +unsigned long flags, +resource_size_t *max_avail_contig) +{ +struct cxl_port *endpoint = cxlmd->endpoint; +struct cxlrd_max_context ctx = { + .host_bridge = endpoint->host_bridge, + .flags = flags, + }; +struct cxl_port *root_port; + struct cxl_root *root __free(put_cxl_root) = find_cxl_root(endpoint); + +if (!is_cxl_endpoint (endpoint)) { +dev_dbg (&endpoint->dev,"hpa requestor is not an endpoint\n" ); +return ERR_PTR (-EINVAL ); + } + +if (!root) { +dev_dbg (&endpoint->dev,"endpoint can not be related to a root port\n" ); +return ERR_PTR (-ENXIO ); + } + + root_port = &root->port; +down_read (&cxl_region_rwsem); +device_for_each_child (&root_port->dev, &ctx, find_max_hpa); +up_read (&cxl_region_rwsem); + +if (!ctx.cxlrd) +return ERR_PTR (-ENOMEM ); + + *max_avail_contig = ctx.max_hpa; +return ctx.cxlrd; +} +EXPORT_SYMBOL_NS_GPL (cxl_get_hpa_freespace,"CXL" ); +
Re: [PATCH v9 15/27] cxl: define a driver interface for HPA free space enumeration
Quoted 60 lines · Jonathan Cameron
Quoted 10 lines · On Mon, 30 Dec 2024 21:44:33 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
CXL region creation involves allocating capacity from device DPA (device-physical-address space) and assigning it to decode a given HPA (host-physical-address space). Before determining how much DPA to allocate the amount of available HPA must be determined. Also, not all HPA is created equal, some specifically targets RAM, some target PMEM, some is prepared for device-memory flows like HDM-D and HDM-DB, and some is host-only (HDM-H).
Quoted 8 lines
Wrap all of those concerns into an API that retrieves a root decoder (platform CXL window) that fits the specified constraints and the capacity available for a new region.
Signed-off-by Alejandro Lucero <[email protected]>Co-developed-by Dan Williams <[email protected]>A couple of trivial things inline.
With those tidied up.
Reviewed-by Jonathan Cameron <[email protected]>Quoted 33 lines
--- drivers/cxl/core/region.c | 155 ++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 3 + include/cxl/cxl.h | 8 ++ 3 files changed, 166 insertions(+)drivers/cxl/core/region.c +19
-0@@ -687,6 +687,161 @@ static int free_hpa(struct cxl_region *cxlr)return 0 ; } +struct cxlrd_max_context { +struct device *host_bridge; +unsigned long flags; +resource_size_t max_hpa; +struct cxl_root_decoder *cxlrd; +}; + +static int find_max_hpa (struct device *dev,void *data) +{ +struct cxlrd_max_context *ctx = data; +struct cxl_switch_decoder *cxlsd; +struct cxl_root_decoder *cxlrd; +struct resource *res, *prev; +struct cxl_decoder *cxld; +resource_size_t max; + +if (!is_root_decoder (dev)) +return 0 ; +
Quoted 9 lines
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 714
Quoted 6 lines
drivers/cxl/core/region.c +6
-0+ cxlrd =to_cxl_root_decoder (dev); + cxlsd = &cxlrd->cxlsd; + cxld = &cxlsd->cxld; +if ((cxld->flags & ctx->flags) != ctx->flags) { +dev_dbg (dev,"%s, flags not matching: %08lx vs %08lx\n" , + __func__, cxld->flags, ctx->flags);Another
__func__to drop.
Check for other cases where dynamic debug applies.
I'll do.
Quoted 10 lines
Quoted 10 lines
drivers/cxl/core/region.c +9
-0+ +/** +* cxl_get_hpa_freespace - find a root decoder with free capacity per constraints +* @cxlmd: the CXL memory device with an endpoint that is mapped by the returned +* decoder +* @flags: CXL_DECODER_F flags for selecting RAM vs PMEM, and HDM-H vs HDM-D[B] +* @max_avail_contig: output parameter of max contiguous bytes available in the +* returned decoder +*
Quoted 8 lines
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 806
Quoted 7 lines
drivers/cxl/core/region.c +7
-0+* The return tuple of a 'struct cxl_root_decoder' and 'bytes available given +* in (@max_avail_contig))' is a point in time snapshot. If by the time the +* caller goes to use this root decoder's capacity the capacity is reduced then +* caller needs to loop and retry. +* +* The returned root decoder has an elevated reference count that needs to be +* put with put_device(cxlrd_dev(cxlrd)). Locking context is with put_device(CXLRD_DEV(cxlrd))
Right.
This helps to see the reference to cxl_acquire/release_endpoint needs to be dropped.
Thanks!
Quoted 38 lines
Quoted 38 lines
drivers/cxl/core/region.c +38
-0+* cxl_{acquire,release}_endpoint(), that ensures removal of the root decoder +* does not race. +*/ +struct cxl_root_decoder *cxl_get_hpa_freespace (struct cxl_memdev *cxlmd, +unsigned long flags, +resource_size_t *max_avail_contig) +{ +struct cxl_port *endpoint = cxlmd->endpoint; +struct cxlrd_max_context ctx = { + .host_bridge = endpoint->host_bridge, + .flags = flags, + }; +struct cxl_port *root_port; + struct cxl_root *root __free(put_cxl_root) = find_cxl_root(endpoint); + +if (!is_cxl_endpoint (endpoint)) { +dev_dbg (&endpoint->dev,"hpa requestor is not an endpoint\n" ); +return ERR_PTR (-EINVAL ); + } + +if (!root) { +dev_dbg (&endpoint->dev,"endpoint can not be related to a root port\n" ); +return ERR_PTR (-ENXIO ); + } + + root_port = &root->port; +down_read (&cxl_region_rwsem); +device_for_each_child (&root_port->dev, &ctx, find_max_hpa); +up_read (&cxl_region_rwsem); + +if (!ctx.cxlrd) +return ERR_PTR (-ENOMEM ); + + *max_avail_contig = ctx.max_hpa; +return ctx.cxlrd; +} +EXPORT_SYMBOL_NS_GPL (cxl_get_hpa_freespace,"CXL" ); +
Re: [PATCH v9 15/27] cxl: define a driver interface for HPA free space enumeration
In reply to [email protected]Quoted 10 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
CXL region creation involves allocating capacity from device DPA (device-physical-address space) and assigning it to decode a given HPA (host-physical-address space). Before determining how much DPA to allocate the amount of available HPA must be determined. Also, not all HPA is created equal, some specifically targets RAM, some target PMEM, some is prepared for device-memory flows like HDM-D and HDM-DB, and some is host-only (HDM-H).
Quoted 5 lines
Wrap all of those concerns into an API that retrieves a root decoder (platform CXL window) that fits the specified constraints and the capacity available for a new region.
What needed changing such that you could not use the patch verbatim? Then I can focus on that, although I am also critical of code I wrote (like the DPA layout mess).
Quoted 2 lines
Signed-off-by Alejandro Lucero <[email protected]>Co-developed-by Dan Williams <[email protected]>
Include Signed-off-by: whenever including Co-developed-by
Quoted 41 lines
--- drivers/cxl/core/region.c | 155 ++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 3 + include/cxl/cxl.h | 8 ++ 3 files changed, 166 insertions(+)drivers/cxl/core/region.c +27
-0@@ -687,6 +687,161 @@ static int free_hpa(struct cxl_region *cxlr)return 0 ; } +struct cxlrd_max_context { +struct device *host_bridge; +unsigned long flags; +resource_size_t max_hpa; +struct cxl_root_decoder *cxlrd; +}; + +static int find_max_hpa (struct device *dev,void *data) +{ +struct cxlrd_max_context *ctx = data; +struct cxl_switch_decoder *cxlsd; +struct cxl_root_decoder *cxlrd; +struct resource *res, *prev; +struct cxl_decoder *cxld; +resource_size_t max; + +if (!is_root_decoder (dev)) +return 0 ; + + cxlrd =to_cxl_root_decoder (dev); + cxlsd = &cxlrd->cxlsd; + cxld = &cxlsd->cxld; +if ((cxld->flags & ctx->flags) != ctx->flags) { +dev_dbg (dev,"%s, flags not matching: %08lx vs %08lx\n" , + __func__, cxld->flags, ctx->flags); +return 0 ; + }
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 726
Quoted 10 lines
drivers/cxl/core/region.c +10
-0+ +/* +* The CXL specs do not forbid an accelerator being part of an +* interleaved HPA range, but it is unlikely and because it simplifies +* the code, don´t allow it. +*/ +if (cxld->interleave_ways !=1 ) { +dev_dbg (dev,"interleave_ways not matching\n" ); +return 0 ; + }
Why does the core need to carry this quirk? If an accelerator does not want to support interleaving then just don't ask for interleaved capacity?
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 728
Quoted 2 lines
drivers/cxl/core/region.c +2
-0+ +guard (rwsem_read)(&cxl_region_rwsem);
See below...
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 739
Quoted 11 lines
drivers/cxl/core/region.c +11
-0+if (ctx->host_bridge != cxlsd->target[0 ]->dport_dev) { +dev_dbg (dev,"host bridge does not match\n" ); +return 0 ; + } + +/* +* Walk the root decoder resource range relying on cxl_region_rwsem to +* preclude sibling arrival/departure and find the largest free space +* gap. +*/ +lockdep_assert_held_read (&cxl_region_rwsem);
The lock was just acquired a few lines up, no need for extra lockdep assertion paranoia. However, I think the lock belongs outside of this function otherwise the iterator of region is racing region creation. However2, cxl_get_hpa_freespace() is already holding the lock!
So, I am not sure this code path has ever been tested as lockdep should complain about the double acquisition.
Quoted 33 lines
drivers/cxl/core/region.c +33
-0+ max =0 ; + res = cxlrd->res->child; + +/* With no resource child the whole parent resource is available */ +if (!res) + max =resource_size (cxlrd->res); +else + max =0 ; + +for (prev =NULL ; res; prev = res, res = res->sibling) { +struct resource *next = res->sibling; +resource_size_t free =0 ; + +/* +* Sanity check for preventing arithmetic problems below as a +* resource with size 0 could imply using the end field below +* when set to unsigned zero - 1 or all f in hex. +*/ +if (prev && !resource_size (prev)) +continue ; + +if (!prev && res->start > cxlrd->res->start) { + free = res->start - cxlrd->res->start; + max =max (free, max); + } +if (prev && res->start > prev->end +1 ) { + free = res->start - prev->end +1 ; + max =max (free, max); + } +if (next && res->end +1 < next->start) { + free = next->start - res->end +1 ; + max =max (free, max); + }
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 782
Quoted 10 lines
drivers/cxl/core/region.c +10
-0+if (!next && res->end +1 < cxlrd->res->end +1 ) { + free = cxlrd->res->end +1 - res->end +1 ; + max =max (free, max); + } + } + +dev_dbg (CXLRD_DEV (cxlrd),"found %pa bytes of free space\n" , &max); +if (max > ctx->max_hpa) { +if (ctx->cxlrd) +put_device (CXLRD_DEV (ctx->cxlrd));
What drove capitalizing "cxlrd_dev"?
Quoted 20 lines
drivers/cxl/core/region.c +20
-0+get_device (CXLRD_DEV (cxlrd)); + ctx->cxlrd = cxlrd; + ctx->max_hpa = max; +dev_dbg (CXLRD_DEV (cxlrd),"found %pa bytes of free space\n" , + &max); + } +return 0 ; +} + +/** +* cxl_get_hpa_freespace - find a root decoder with free capacity per constraints +* @cxlmd: the CXL memory device with an endpoint that is mapped by the returned +* decoder +* @flags: CXL_DECODER_F flags for selecting RAM vs PMEM, and HDM-H vs HDM-D[B] +* @max_avail_contig: output parameter of max contiguous bytes available in the +* returned decoder +* +* The return tuple of a 'struct cxl_root_decoder' and 'bytes available given +* in (@max_avail_contig))' is a point in time snapshot. If by the time the +* caller goes to use this root decoder's capacity the capacity is reduced then
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 812
Quoted 10 lines
drivers/cxl/core/region.c +10
-0+* caller needs to loop and retry. +* +* The returned root decoder has an elevated reference count that needs to be +* put with put_device(cxlrd_dev(cxlrd)). Locking context is with +* cxl_{acquire,release}_endpoint(), that ensures removal of the root decoder +* does not race. +*/ +struct cxl_root_decoder *cxl_get_hpa_freespace (struct cxl_memdev *cxlmd, +unsigned long flags, +resource_size_t *max_avail_contig)
I don't understand the rationale throwing away the ability to search root decoders by additional constraints.
Quoted 21 lines
drivers/cxl/core/region.c +21
-0+{ +struct cxl_port *endpoint = cxlmd->endpoint; +struct cxlrd_max_context ctx = { + .host_bridge = endpoint->host_bridge, + .flags = flags, + }; +struct cxl_port *root_port; + struct cxl_root *root __free(put_cxl_root) = find_cxl_root(endpoint); + +if (!is_cxl_endpoint (endpoint)) { +dev_dbg (&endpoint->dev,"hpa requestor is not an endpoint\n" ); +return ERR_PTR (-EINVAL ); + } + +if (!root) { +dev_dbg (&endpoint->dev,"endpoint can not be related to a root port\n" ); +return ERR_PTR (-ENXIO ); + } + + root_port = &root->port; +down_read (&cxl_region_rwsem);
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 843
Quoted 10 lines
drivers/cxl/core/region.c +10
-0+device_for_each_child (&root_port->dev, &ctx, find_max_hpa); +up_read (&cxl_region_rwsem); + +if (!ctx.cxlrd) +return ERR_PTR (-ENOMEM ); + + *max_avail_contig = ctx.max_hpa; +return ctx.cxlrd; +} +EXPORT_SYMBOL_NS_GPL (cxl_get_hpa_freespace,"CXL" );
Lets just do EXPORT_SYMBOL_GPL() for any API that an accelerator would use. The symbol namespace was more for warning about potential semantic shortcuts and liberties taken by drivers/cxl/ modules talking to each other. Anything that is exported for outside of drivers/cxl/ usage should not take those liberties.
Quoted 9 lines
drivers/cxl/core/region.c +1
-0+static ssize_t size_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t len) {drivers/cxl/cxl.h +0
-0
drivers/cxl/cxl.h static inline void cxl_dport_init_ras_reporting(struct cxl_dport *dport, · line 789
Quoted 5 lines
drivers/cxl/cxl.h +2
-0@@ -785,6 +785,9 @@ static inline void cxl_dport_init_ras_reporting(struct cxl_dport *dport,struct cxl_decoder *to_cxl_decoder (struct device *dev);struct cxl_root_decoder *to_cxl_root_decoder (struct device *dev);struct cxl_switch_decoder *to_cxl_switch_decoder (struct device *dev); + +#define CXLRD_DEV (cxlrd) (&(cxlrd)->cxlsd.cxld.dev)
...oh, it's a macro now for some reason.
Quoted 20 lines
drivers/cxl/cxl.h +1
-0+struct cxl_endpoint_decoder *to_cxl_endpoint_decoder (struct device *dev);bool is_root_decoder (struct device *dev);bool is_switch_decoder (struct device *dev);include/cxl/cxl.h +4
-0@@ -6,6 +6,10 @@#include <linux/ioport.h> +#define CXL_DECODER_F_RAM BIT(0) +#define CXL_DECODER_F_PMEM BIT(1) +#define CXL_DECODER_F_TYPE2 BIT(2) +enum cxl_resource {CXL_RES_DPA ,CXL_RES_RAM ,
include/cxl/cxl.h int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type); · line 60
Quoted 7 lines
include/cxl/cxl.h +4
-0@@ -50,4 +54,8 @@ int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type);void cxl_set_media_ready (struct cxl_dev_state *cxlds);struct cxl_memdev *devm_cxl_add_memdev (struct device *host,struct cxl_dev_state *cxlds); +struct cxl_port ; +struct cxl_root_decoder *cxl_get_hpa_freespace (struct cxl_memdev *cxlmd, +unsigned long flags, +resource_size_t *max);
The name does not track for me, because nothing is acquired in this function. It just surveys for a root decoder that meets the constraints. It is possible that by the time the caller turns around to use that freespace something else already grabbed it.
Re: [PATCH v9 15/27] cxl: define a driver interface for HPA free space enumeration
Quoted 11 lines · Dan Williams
Quoted 10 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
CXL region creation involves allocating capacity from device DPA (device-physical-address space) and assigning it to decode a given HPA (host-physical-address space). Before determining how much DPA to allocate the amount of available HPA must be determined. Also, not all HPA is created equal, some specifically targets RAM, some target PMEM, some is prepared for device-memory flows like HDM-D and HDM-DB, and some is host-only (HDM-H).
Quoted 8 lines
Quoted 5 lines
Wrap all of those concerns into an API that retrieves a root decoder (platform CXL window) that fits the specified constraints and the capacity available for a new region.
What needed changing such that you could not use the patch verbatim? Then I can focus on that, although I am also critical of code I wrote (like the DPA layout mess).
One thing modified is related to that ugly double lock you found out below.
I do not remember what was the problem but the original code using sequential locks did not work for me.
More about this later.
Quoted 3 lines
Quoted 2 lines
Signed-off-by Alejandro Lucero <[email protected]>Co-developed-by Dan Williams <[email protected]>Include Signed-off-by: whenever including Co-developed-by
I'll do but it is weird. I think, at least in this case where the co-development means different times and not close cooperation, you should add it explicitly.
Quoted 47 lines
Quoted 47 lines
--- drivers/cxl/core/region.c | 155 ++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 3 + include/cxl/cxl.h | 8 ++ 3 files changed, 166 insertions(+)drivers/cxl/core/region.c +32
-0@@ -687,6 +687,161 @@ static int free_hpa(struct cxl_region *cxlr)return 0 ; } +struct cxlrd_max_context { +struct device *host_bridge; +unsigned long flags; +resource_size_t max_hpa; +struct cxl_root_decoder *cxlrd; +}; + +static int find_max_hpa (struct device *dev,void *data) +{ +struct cxlrd_max_context *ctx = data; +struct cxl_switch_decoder *cxlsd; +struct cxl_root_decoder *cxlrd; +struct resource *res, *prev; +struct cxl_decoder *cxld; +resource_size_t max; + +if (!is_root_decoder (dev)) +return 0 ; + + cxlrd =to_cxl_root_decoder (dev); + cxlsd = &cxlrd->cxlsd; + cxld = &cxlsd->cxld; +if ((cxld->flags & ctx->flags) != ctx->flags) { +dev_dbg (dev,"%s, flags not matching: %08lx vs %08lx\n" , + __func__, cxld->flags, ctx->flags); +return 0 ; + } + +/* +* The CXL specs do not forbid an accelerator being part of an +* interleaved HPA range, but it is unlikely and because it simplifies +* the code, don´t allow it.
Quoted 9 lines
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 726
Quoted 5 lines
drivers/cxl/core/region.c +5
-0+*/ +if (cxld->interleave_ways !=1 ) { +dev_dbg (dev,"interleave_ways not matching\n" ); +return 0 ; + }Why does the core need to carry this quirk? If an accelerator does not want to support interleaving then just don't ask for interleaved capacity?
I think it was suggested as a simplification for initial Type2 support.
Quoted 4 lines
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 728
Quoted 2 lines
drivers/cxl/core/region.c +2
-0+ +guard (rwsem_read)(&cxl_region_rwsem);See below...
Quoted 15 lines
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 739
Quoted 11 lines
drivers/cxl/core/region.c +11
-0+if (ctx->host_bridge != cxlsd->target[0 ]->dport_dev) { +dev_dbg (dev,"host bridge does not match\n" ); +return 0 ; + } + +/* +* Walk the root decoder resource range relying on cxl_region_rwsem to +* preclude sibling arrival/departure and find the largest free space +* gap. +*/ +lockdep_assert_held_read (&cxl_region_rwsem);The lock was just acquired a few lines up, no need for extra lockdep assertion paranoia. However, I think the lock belongs outside of this function otherwise the iterator of region is racing region creation. However2,
cxl_get_hpa_freespace()is already holding the lock!
You are right and this is so obviously wrong ...
I think the problem is the adaptation of that initial patch with the seqlocks, and I ended up mixing things here.
I'll try to figure out why I had to adapt it and if I mistook the lock to use.
Quoted 3 lines
So, I am not sure this code path has ever been tested as lockdep should complain about the double acquisition.
Oddly enough, it has been tested with two different drivers and with the kernel configuring lockdep.
It is worth to investigate ...
Quoted 70 lines
Quoted 34 lines
drivers/cxl/core/region.c +33
-0+ max =0 ; + res = cxlrd->res->child; + +/* With no resource child the whole parent resource is available */ +if (!res) + max =resource_size (cxlrd->res); +else + max =0 ; + +for (prev =NULL ; res; prev = res, res = res->sibling) { +struct resource *next = res->sibling; +resource_size_t free =0 ; + +/* +* Sanity check for preventing arithmetic problems below as a +* resource with size 0 could imply using the end field below +* when set to unsigned zero - 1 or all f in hex. +*/ +if (prev && !resource_size (prev)) +continue ; + +if (!prev && res->start > cxlrd->res->start) { + free = res->start - cxlrd->res->start; + max =max (free, max); + } +if (prev && res->start > prev->end +1 ) { + free = res->start - prev->end +1 ; + max =max (free, max); + } +if (next && res->end +1 < next->start) { + free = next->start - res->end +1 ; + max =max (free, max); + }drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 782
Quoted 10 lines
drivers/cxl/core/region.c +10
-0+if (!next && res->end +1 < cxlrd->res->end +1 ) { + free = cxlrd->res->end +1 - res->end +1 ; + max =max (free, max); + } + } + +dev_dbg (CXLRD_DEV (cxlrd),"found %pa bytes of free space\n" , &max); +if (max > ctx->max_hpa) { +if (ctx->cxlrd) +put_device (CXLRD_DEV (ctx->cxlrd));What drove capitalizing "
cxlrd_dev"?Quoted 24 lines
drivers/cxl/core/region.c +24
-0+get_device (CXLRD_DEV (cxlrd)); + ctx->cxlrd = cxlrd; + ctx->max_hpa = max; +dev_dbg (CXLRD_DEV (cxlrd),"found %pa bytes of free space\n" , + &max); + } +return 0 ; +} + +/** +* cxl_get_hpa_freespace - find a root decoder with free capacity per constraints +* @cxlmd: the CXL memory device with an endpoint that is mapped by the returned +* decoder +* @flags: CXL_DECODER_F flags for selecting RAM vs PMEM, and HDM-H vs HDM-D[B] +* @max_avail_contig: output parameter of max contiguous bytes available in the +* returned decoder +* +* The return tuple of a 'struct cxl_root_decoder' and 'bytes available given +* in (@max_avail_contig))' is a point in time snapshot. If by the time the +* caller goes to use this root decoder's capacity the capacity is reduced then +* caller needs to loop and retry. +* +* The returned root decoder has an elevated reference count that needs to be +* put with put_device(cxlrd_dev(cxlrd)). Locking context is with
Quoted 8 lines
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 812
Quoted 6 lines
drivers/cxl/core/region.c +6
-0+* cxl_{acquire,release}_endpoint(), that ensures removal of the root decoder +* does not race. +*/ +struct cxl_root_decoder *cxl_get_hpa_freespace (struct cxl_memdev *cxlmd, +unsigned long flags, +resource_size_t *max_avail_contig)I don't understand the rationale throwing away the ability to search root decoders by additional constraints.
Not sure I follow you here. I think the constraints, set by the caller, is something to check for sure.
Quoted 28 lines
Quoted 28 lines
drivers/cxl/core/region.c +28
-0+{ +struct cxl_port *endpoint = cxlmd->endpoint; +struct cxlrd_max_context ctx = { + .host_bridge = endpoint->host_bridge, + .flags = flags, + }; +struct cxl_port *root_port; + struct cxl_root *root __free(put_cxl_root) = find_cxl_root(endpoint); + +if (!is_cxl_endpoint (endpoint)) { +dev_dbg (&endpoint->dev,"hpa requestor is not an endpoint\n" ); +return ERR_PTR (-EINVAL ); + } + +if (!root) { +dev_dbg (&endpoint->dev,"endpoint can not be related to a root port\n" ); +return ERR_PTR (-ENXIO ); + } + + root_port = &root->port; +down_read (&cxl_region_rwsem); +device_for_each_child (&root_port->dev, &ctx, find_max_hpa); +up_read (&cxl_region_rwsem); + +if (!ctx.cxlrd) +return ERR_PTR (-ENOMEM ); + + *max_avail_contig = ctx.max_hpa;
Quoted 8 lines
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 843
Quoted 3 lines
drivers/cxl/core/region.c +3
-0+return ctx.cxlrd; +} +EXPORT_SYMBOL_NS_GPL (cxl_get_hpa_freespace,"CXL" );Lets just do
EXPORT_SYMBOL_GPL()for any API that an accelerator would use. The symbol namespace was more for warning about potential semantic shortcuts and liberties taken bydrivers/cxl/modules talking to each other. Anything that is exported for outside ofdrivers/cxl/usage should not take those liberties.
OK
Quoted 40 lines
Quoted 10 lines
drivers/cxl/core/region.c +1
-0+static ssize_t size_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t len) {drivers/cxl/cxl.h +0
-0drivers/cxl/cxl.h static inline void cxl_dport_init_ras_reporting(struct cxl_dport *dport, · line 789
Quoted 5 lines
drivers/cxl/cxl.h +2
-0@@ -785,6 +785,9 @@ static inline void cxl_dport_init_ras_reporting(struct cxl_dport *dport,struct cxl_decoder *to_cxl_decoder (struct device *dev);struct cxl_root_decoder *to_cxl_root_decoder (struct device *dev);struct cxl_switch_decoder *to_cxl_switch_decoder (struct device *dev); + +#define CXLRD_DEV (cxlrd) (&(cxlrd)->cxlsd.cxld.dev)...oh, it's a macro now for some reason.
Quoted 23 lines
drivers/cxl/cxl.h +1
-0+struct cxl_endpoint_decoder *to_cxl_endpoint_decoder (struct device *dev);bool is_root_decoder (struct device *dev);bool is_switch_decoder (struct device *dev);include/cxl/cxl.h +4
-0@@ -6,6 +6,10 @@#include <linux/ioport.h> +#define CXL_DECODER_F_RAM BIT(0) +#define CXL_DECODER_F_PMEM BIT(1) +#define CXL_DECODER_F_TYPE2 BIT(2) +enum cxl_resource {CXL_RES_DPA ,CXL_RES_RAM ,@@ -50,4 +54,8 @@ int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type);void cxl_set_media_ready (struct cxl_dev_state *cxlds);struct cxl_memdev *devm_cxl_add_memdev (struct device *host,struct cxl_dev_state *cxlds);
Quoted 8 lines
include/cxl/cxl.h int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type); · line 60
Quoted 4 lines
include/cxl/cxl.h +4
-0+struct cxl_port ; +struct cxl_root_decoder *cxl_get_hpa_freespace (struct cxl_memdev *cxlmd, +unsigned long flags, +resource_size_t *max);The name does not track for me, because nothing is acquired in this function. It just surveys for a root decoder that meets the constraints. It is possible that by the time the caller turns around to use that freespace something else already grabbed it.
I'll think in a better name.
Thanks!
Re: [PATCH v9 15/27] cxl: define a driver interface for HPA free space enumeration
Quoted 122 lines · Alejandro Lucero Palau
Quoted 11 lines · Dan Williams
Quoted 10 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
CXL region creation involves allocating capacity from device DPA (device-physical-address space) and assigning it to decode a given HPA (host-physical-address space). Before determining how much DPA to allocate the amount of available HPA must be determined. Also, not all HPA is created equal, some specifically targets RAM, some target PMEM, some is prepared for device-memory flows like HDM-D and HDM-DB, and some is host-only (HDM-H).
Quoted 8 lines
Quoted 5 lines
Wrap all of those concerns into an API that retrieves a root decoder (platform CXL window) that fits the specified constraints and the capacity available for a new region.
What needed changing such that you could not use the patch verbatim? Then I can focus on that, although I am also critical of code I wrote (like the DPA layout mess).
One thing modified is related to that ugly double lock you found out below.
I do not remember what was the problem but the original code using sequential locks did not work for me.
More about this later.
Quoted 3 lines
Quoted 2 lines
Signed-off-by Alejandro Lucero <[email protected]>Co-developed-by Dan Williams <[email protected]>Include Signed-off-by: whenever including Co-developed-by
I'll do but it is weird. I think, at least in this case where the co-development means different times and not close cooperation, you should add it explicitly.
Quoted 48 lines
Quoted 48 lines
---
drivers/cxl/core/region.c| 155
++++++++++++++++++++++++++++++++++++++
drivers/cxl/cxl.h | 3 +
include/cxl/cxl.h | 8 ++3 files changed, 166 insertions(+)drivers/cxl/core/region.c +30
-0@@ -687,6 +687,161 @@ static int free_hpa(struct cxl_region *cxlr) return 0; } +struct cxlrd_max_context { + struct device *host_bridge; + unsigned long flags; + resource_size_t max_hpa; + struct cxl_root_decoder *cxlrd; +}; + +static int find_max_hpa (struct device *dev,void *data) +{ + struct cxlrd_max_context *ctx = data; + struct cxl_switch_decoder *cxlsd; + struct cxl_root_decoder *cxlrd; + struct resource *res, *prev; + struct cxl_decoder *cxld; + resource_size_t max; + + if (!is_root_decoder(dev)) + return 0; + + cxlrd = to_cxl_root_decoder(dev); + cxlsd = &cxlrd->cxlsd; + cxld = &cxlsd->cxld; + if ((cxld->flags & ctx->flags) != ctx->flags) { + dev_dbg(dev, "%s, flags not matching: %08lx vs %08lx\n", + __func__, cxld->flags, ctx->flags); + return 0; + } + + /* +* The CXL specs do not forbid an accelerator being part of an +* interleaved HPA range, but it is unlikely and because it simplifies
+ * the code, don´t allow it.Quoted 9 lines
Quoted 5 lines
+ */
+ if (cxld->interleave_ways!= 1) {
+dev_dbg(dev, "interleave_ways not matching\n"); + return 0;
+ }Why does the core need to carry this quirk? If an accelerator does not want to support interleaving then just don't ask for interleaved capacity?
I think it was suggested as a simplification for initial Type2 support.
Quoted 17 lines
Quoted 2 lines
+
+ guard(rwsem_read)(&cxl_region_rwsem);See below...
Quoted 5 lines
+ if (
ctx->host_bridge!= cxlsd->target[0]->dport_dev) { +dev_dbg(dev, "host bridge does not match\n"); + return 0;
+ }
+Quoted 8 lines
+ /*
+ * Walk the root decoder resource range relying oncxl_region_rwsemto
+ * preclude sibling arrival/departure and find the largest free space
+ * gap.
+ */
+lockdep_assert_held_read(&cxl_region_rwsem);Quoted 4 lines
The lock was just acquired a few lines up, no need for extra lockdep assertion paranoia. However, I think the lock belongs outside of this function otherwise the iterator of region is racing region creation. However2,
cxl_get_hpa_freespace()is already holding the lock!
Quoted 7 lines
You are right and this is so obviously wrong ...
I think the problem is the adaptation of that initial patch with the seqlocks, and I ended up mixing things here.
I'll try to figure out why I had to adapt it and if I mistook the lock to use.
After looking at the original code, the problem was the locking you used had to change since the target_lock field inside cxl_switch_decoder was removed after your patch before the time I took it over.
I did look at where a cxl_switch_decoder could be modified and I realized (guessing because I have not studied this in detail now) it could be enough grabbing the cxl_region_rwsem lock instead.
So I ended up adding that line for the locking without realizing it was already taken by the caller function.
The code morphed, because it was suggested current Type2 support should not support interleaving, for simplicity and because the use case did not require it, but the lock remained as the access to the cxl_switch_decoder linked to the endpoint is still there, although more simpler, and as a sanity check.
If we keep the simpler approach by now about forgetting interleaving, that code can just be dropped. If interleaving is a must, what I think it is not at this point, I should work on this asap.
Quoted 9 lines
Quoted 3 lines
So, I am not sure this code path has ever been tested as lockdep should complain about the double acquisition.
Oddly enough, it has been tested with two different drivers and with the kernel configuring lockdep.
It is worth to investigate ...
Confirmed the double lock is not an issue. Maybe the code hidden in those macros is checking if the current caller is the same one that the current owner of the lock. I will check that or investigate further.
Thank you
Quoted 195 lines
Quoted 83 lines
Quoted 43 lines
+ max = 0;
+ res =cxlrd->res->child;
+
+ /* With no resource child the whole parent resource is available */
+ if (!res)
+ max =resource_size(cxlrd->res);
+ else
+ max = 0;drivers/cxl/core/region.c +32
-0+ + for (prev = NULL; res; prev = res, res = res->sibling) { + struct resource *next = res->sibling; + resource_size_t free = 0; + + /* + * Sanity check for preventing arithmetic problems below as a + * resource with size 0 could imply using the end field below + * when set to unsigned zero - 1 or all f in hex. + */ + if (prev && !resource_size(prev)) + continue; + + if (!prev && res->start > cxlrd->res->start) { + free = res->start - cxlrd->res->start; + max = max(free, max); + } + if (prev && res->start > prev->end + 1) { + free = res->start - prev->end + 1; + max = max(free, max); + } + if (next && res->end + 1 < next->start) { + free = next->start - res->end + 1; + max = max(free, max); + } + if (!next && res->end + 1 < cxlrd->res->end + 1) { + free = cxlrd->res->end + 1 - res->end + 1; + max = max(free, max); + } + } + + dev_dbg(CXLRD_DEV(cxlrd), "found %pa bytes of free space\n",Quoted 4 lines
&max);
+ if (max >ctx->max_hpa) {
+ if (ctx->cxlrd)
+ put_device(CXLRD_DEV(ctx->cxlrd));What drove capitalizing "
cxlrd_dev"?Quoted 34 lines
+ get_device(CXLRD_DEV(cxlrd));
+ctx->cxlrd= cxlrd;
+ctx->max_hpa= max;
+dev_dbg(CXLRD_DEV(cxlrd), "found %pa bytes of free space\n", + &max);
+ }
+ return 0;drivers/cxl/core/region.c +4
-0+} + +/** +* cxl_get_hpa_freespace - find a root decoder with free capacity per constraints
+ * @cxlmd: the CXL memory device with an endpoint that is mapped by the returned
+ * decoder
+ * @flags:CXL_DECODER_Fflags for selecting RAM vs PMEM, and HDM-H vs HDM-D[B]
+ * @max_avail_contig: output parameter of max contiguous bytes available in the
+ * returned decoder
+ *
+ * The return tuple of a 'structcxl_root_decoder' and 'bytes available given
+ * in (@max_avail_contig))' is a point in time snapshot. If by the time the
+ * caller goes to use this root decoder's capacity the capacity is reduced then
+ * caller needs to loop and retry.
+ *
+ * The returned root decoder has an elevated reference count that needs to be
+ * put with put_device(cxlrd_dev(cxlrd)). Locking context is with
+ * cxl_{acquire,release}_endpoint(), that ensures removal of the root decoderQuoted 8 lines
Quoted 6 lines
+ * does not race.
+ */
+structcxl_root_decoder*cxl_get_hpa_freespace(structcxl_memdev*cxlmd,
+ unsigned long flags,
+resource_size_t*max_avail_contig)I don't understand the rationale throwing away the ability to search root decoders by additional constraints.
Not sure I follow you here. I think the constraints, set by the caller, is something to check for sure.
Quoted 30 lines
Quoted 30 lines
+{
+ structcxl_port*endpoint =cxlmd->endpoint;
+ structcxlrd_max_contextctx = {
+ .host_bridge =endpoint->host_bridge,
+ .flags = flags,
+ };
+ structcxl_port*root_port;
+ structcxl_root*root__free(put_cxl_root)=find_cxl_root(endpoint);drivers/cxl/core/region.c +8
-0+ + if (!is_cxl_endpoint(endpoint)) { + dev_dbg(&endpoint->dev, "hpa requestor is not an endpoint\n"); + return ERR_PTR(-EINVAL); + } + + if (!root) { + dev_dbg(&endpoint->dev, "endpoint can not be related to aroot port\n");
+ returnERR_PTR(-ENXIO);
+ }drivers/cxl/core/region.c +10
-0+ + root_port = &root->port; + down_read(&cxl_region_rwsem); + device_for_each_child(&root_port->dev, &ctx, find_max_hpa); + up_read(&cxl_region_rwsem); + + if (!ctx.cxlrd) + return ERR_PTR(-ENOMEM); + + *max_avail_contig = ctx.max_hpa;Quoted 8 lines
drivers/cxl/core/region.c
Quoted 3 lines
+ return ctx.cxlrd;
drivers/cxl/core/region.c +2
-0+} +EXPORT_SYMBOL_NS_GPL (cxl_get_hpa_freespace,"CXL" );Lets just do
EXPORT_SYMBOL_GPL()for any API that an accelerator would use. The symbol namespace was more for warning about potential semantic shortcuts and liberties taken bydrivers/cxl/modules talking to each other. Anything that is exported for outside ofdrivers/cxl/usage should not take those liberties.OK
Quoted 41 lines
Quoted 10 lines
+
staticssize_tsize_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len)
{drivers/cxl/cxl.h +0
-0drivers/cxl/cxl.h static inline void · line 790
Quoted 6 lines
drivers/cxl/cxl.h +2
-0@@ -785,6 +785,9 @@ static inline void cxl_dport_init_ras_reporting(struct cxl_dport *dport, struct cxl_decoder *to_cxl_decoder(struct device *dev); struct cxl_root_decoder *to_cxl_root_decoder(struct device *dev); struct cxl_switch_decoder *to_cxl_switch_decoder(struct device *dev); + +#define CXLRD_DEV (cxlrd) (&(cxlrd)->cxlsd.cxld.dev)...oh, it's a macro now for some reason.
Quoted 23 lines
drivers/cxl/cxl.h +1
-0+ struct cxl_endpoint_decoder *to_cxl_endpoint_decoder(struct device *dev); bool is_root_decoder(struct device *dev);bool
is_switch_decoder(struct device *dev);include/cxl/cxl.h +4
-0@@ -6,6 +6,10 @@ #include <linux/ioport.h> +#define CXL_DECODER_F_RAM BIT(0) +#define CXL_DECODER_F_PMEM BIT(1) +#define CXL_DECODER_F_TYPE2 BIT(2) + enum cxl_resource { CXL_RES_DPA, CXL_RES_RAM,@@ -50,4 +54,8 @@ int cxl_release_resource(struct cxl_dev_state *cxlds, enum cxl_resource type); void cxl_set_media_ready(struct cxl_dev_state *cxlds); struct cxl_memdev *devm_cxl_add_memdev(struct device *host, struct cxl_dev_state *cxlds); +struct cxl_port ;Quoted 8 lines
Quoted 4 lines
include/cxl/cxl.h +1
-0+struct cxl_root_decoder *cxl_get_hpa_freespace(struct cxl_memdev*cxlmd,
+ unsigned long flags, +resource_size_t*max);The name does not track for me, because nothing is acquired in this function. It just surveys for a root decoder that meets the constraints. It is possible that by the time the caller turns around to use that freespace something else already grabbed it.
I'll think in a better name.
Thanks!
Re: [PATCH v9 15/27] cxl: define a driver interface for HPA free space enumeration
Alejandro Lucero Palau wrote:
[..]
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
So, I am not sure this code path has ever been tested as lockdep should complain about the double acquisition.
Oddly enough, it has been tested with two different drivers and with the kernel configuring lockdep.
Quoted 6 lines
Quoted 2 lines
It is worth to investigate ...
Confirmed the double lock is not an issue. Maybe the code hidden in those macros is checking if the current caller is the same one that the current owner of the lock. I will check that or investigate further.
Are you sure?
This splat:
============================================
WARNING: possible recursive locking detected
6.13.0-rc2+ #68 Tainted: G OE
--------------------------------------------
cat/1212 is trying to acquire lock:
ffffffffc0591cf0 (cxl_region_rwsem){++++}-{4:4}, at: decoders_committed_show+0x2a/0x90 [cxl_core]
but task is already holding lock:
ffffffffc0591cf0 (cxl_region_rwsem){++++}-{4:4}, at: decoders_committed_show+0x1e/0x90 [cxl_core]
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(cxl_region_rwsem);
lock(cxl_region_rwsem);
*** DEADLOCK ***
...results from this change:
drivers/cxl/core/port.c +2 -0
@@ -560,9 +560,11 @@ static ssize_t decoders_committed_show(struct device *dev,struct cxl_port *port =to_cxl_port (dev);int rc; +down_read (&cxl_region_rwsem);down_read (&cxl_region_rwsem); rc =sysfs_emit (buf,"%d\n" ,cxl_num_decoders_committed (port));up_read (&cxl_region_rwsem); +up_read (&cxl_region_rwsem);return rc; }
...and "cat /sys/bus/cxl/devices/port*/decoders_committed".
Re: [PATCH v9 15/27] cxl: define a driver interface for HPA free space enumeration
Quoted 8 lines · Dan Williams
Alejandro Lucero Palau wrote:
[..]Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
So, I am not sure this code path has ever been tested as lockdep should complain about the double acquisition.
Oddly enough, it has been tested with two different drivers and with the kernel configuring lockdep.
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
It is worth to investigate ...
Confirmed the double lock is not an issue. Maybe the code hidden in those macros is checking if the current caller is the same one that the current owner of the lock. I will check that or investigate further.
Are you sure?
I'm sure it does not seem a problem ... with only CONFIG_LOCKDEP_SUPPORT=y what was what I saw in a quick search in the kernel config file.
But it triggers as expected if the right configuration does exist at kernel hacking->Lock debugging ->*
Moreover, my comment yesterday about checking current vs owner does not make sense since it is one of the reasons to check ...
Happy you spotted it. As I said, I think no special lock is needed for the following code, but I'll double check before v10.
Thanks!
Quoted 43 lines
This splat:
============================================
WARNING: possible recursive locking detected
6.13.0-rc2+ #68 Tainted: G OE
--------------------------------------------
cat/1212 is trying to acquire lock:
ffffffffc0591cf0(cxl_region_rwsem){++++}-{4:4}, at:decoders_committed_show+0x2a/0x90[cxl_core]but task is already holding lock:
ffffffffc0591cf0(cxl_region_rwsem){++++}-{4:4}, at:decoders_committed_show+0x1e/0x90[cxl_core]other info that might help us debug this:
Possible unsafe locking scenario:CPU0 ---- lock(cxl_region_rwsem); lock(cxl_region_rwsem);*** DEADLOCK ***...results from this change:
drivers/cxl/core/port.c +2
-0@@ -560,9 +560,11 @@ static ssize_t decoders_committed_show(struct device *dev,struct cxl_port *port =to_cxl_port (dev);int rc; +down_read (&cxl_region_rwsem);down_read (&cxl_region_rwsem); rc =sysfs_emit (buf,"%d\n" ,cxl_num_decoders_committed (port));up_read (&cxl_region_rwsem); +up_read (&cxl_region_rwsem);return rc; }...and "cat
/sys/bus/cxl/devices/port*/decoders_committed".
Re: [PATCH v9 15/27] cxl: define a driver interface for HPA free space enumeration
In reply to Alejandro Lucero PalauQuoted 18 lines · Alejandro Lucero Palau
Quoted 16 lines · Dan Williams
Quoted 15 lines · alejandro.lucero-palau@ wrote:
From: Alejandro Lucero <[email protected]>
CXL region creation involves allocating capacity from device DPA (device-physical-address space) and assigning it to decode a given HPA (host-physical-address space). Before determining how much DPA to allocate the amount of available HPA must be determined. Also, not all HPA is created equal, some specifically targets RAM, some target PMEM, some is prepared for device-memory flows like HDM-D and HDM-DB, and some is host-only (HDM-H).
Wrap all of those concerns into an API that retrieves a root decoder (platform CXL window) that fits the specified constraints and the capacity available for a new region.
[..]
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
+/**
+ *cxl_get_hpa_freespace- find a root decoder with free capacity per constraints
+ * @cxlmd: the CXL memory device with an endpoint that is mapped by the returned
+ * decoder
+ * @flags:CXL_DECODER_Fflags for selecting RAM vs PMEM, and HDM-H vs HDM-D[B]
+ * @max_avail_contig: output parameter of max contiguous bytes available in the
+ * returned decoder
+ *
+ * The return tuple of a 'structcxl_root_decoder' and 'bytes available given
+ * in (@max_avail_contig))' is a point in time snapshot. If by the time the
+ * caller goes to use this root decoder's capacity the capacity is reduced then
+ * caller needs to loop and retry.
+ *
+ * The returned root decoder has an elevated reference count that needs to be
+ * put with put_device(cxlrd_dev(cxlrd)). Locking context is withQuoted 8 lines
drivers/cxl/core/region.c static int free_hpa(struct cxl_region *cxlr) · line 812
Quoted 6 lines
+ * cxl_{acquire,release}_endpoint(), that ensures removal of the root decoder
+ * does not race.
+ */drivers/cxl/core/region.c +3
-0+struct cxl_root_decoder *cxl_get_hpa_freespace (struct cxl_memdev *cxlmd, +unsigned long flags, +resource_size_t *max_avail_contig)I don't understand the rationale throwing away the ability to search root decoders by additional constraints.
Quoted 2 lines
Not sure I follow you here. I think the constraints, set by the caller, is something to check for sure.
This is the original proposal:
struct cxl_root_decoder *cxl_hpa_freespace(struct cxl_port *endpoint,
struct device *const *host_bridges, int interleave_ways, unsigned long flags, resource_size_t *max)
...it includes support for selecting a CXL window that might be interleaved. The support for checking interleaved vs non-interleaved windows is trivial. The support for PMEM region assembly requires interleaved capacity search even if accelerators do not, so it is worth including that small incremental support from day one.
PATCH v9 16/27 sfc: obtain root decoder with enough HPA free space
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Asking for available HPA space is the previous step to try to obtain an HPA range suitable to accel driver purposes.
Add this call to efx cxl initialization.
Make sfc cxl build dependent on CXL region.
--- drivers/net/ethernet/sfc/Kconfig | 2 +- drivers/net/ethernet/sfc/efx_cxl.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/net/ethernet/sfc/Kconfig +1 -1
@@ -67,7 +67,7 @@ config SFC_MCDI_LOGGING a sysfs file 'mcdi_logging' under the PCI device. config SFC_CXL bool "Solarflare SFC9100-family CXL support" - depends on SFC && CXL_BUS && !(SFC=y && CXL_BUS=m) + depends on SFC && CXL_BUS && !(SFC=y && CXL_BUS=m) && CXL_REGION default y help This enables CXL support by the driver relying on kernel support
drivers/net/ethernet/sfc/efx_cxl.c +18 -0
@@ -24,6 +24,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data)struct pci_dev *pci_dev = efx->pci_dev;DECLARE_BITMAP (expected,CXL_MAX_CAPS );DECLARE_BITMAP (found,CXL_MAX_CAPS ); +resource_size_t max_size;struct efx_cxl *cxl;struct resource res;u16 dvsec;
@@ -103,6 +104,23 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err_memdev; } + cxl->cxlrd =cxl_get_hpa_freespace (cxl->cxlmd, +CXL_DECODER_F_RAM |CXL_DECODER_F_TYPE2 , + &max_size); + +if (IS_ERR (cxl->cxlrd)) { +pci_err (pci_dev,"cxl_get_hpa_freespace failed\n" ); + rc =PTR_ERR (cxl->cxlrd); + goto err_memdev; + } + +if (max_size <EFX_CTPIO_BUFFER_SIZE ) { +pci_err (pci_dev,"%s: not enough free HPA space %pap < %u\n" , + __func__, &max_size,EFX_CTPIO_BUFFER_SIZE ); + rc = -ENOSPC ; + goto err_memdev; + } + probe_data->cxl = cxl;return 0 ;
Signature · 1 line
2.17.1
PATCH v9 17/27 cxl: define a driver interface for DPA allocation
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Region creation involves finding available DPA (device-physical-address) capacity to map into HPA (host-physical-address) space. Given the HPA capacity constraint, define an API, cxl_request_dpa(), that has the flexibility to map the minimum amount of memory the driver needs to operate vs the total possible that can be mapped given HPA availability.
Factor out the core of cxl_dpa_alloc, that does free space scanning, into a cxl_dpa_freespace() helper, and use that to balance the capacity available to map vs the @min and @max arguments to cxl_request_dpa.
--- drivers/cxl/core/hdm.c | 153 +++++++++++++++++++++++++++++++++++------ include/cxl/cxl.h | 5 ++ 2 files changed, 138 insertions(+), 20 deletions(-)
drivers/cxl/core/hdm.c +133 -20
@@ -3,6 +3,7 @@#include <linux/seq_file.h> #include <linux/device.h> #include <linux/delay.h> +#include <cxl/cxl.h> #include "cxlmem.h" #include "core.h"
@@ -417,6 +418,7 @@ int cxl_dpa_free(struct cxl_endpoint_decoder *cxled)up_write (&cxl_dpa_rwsem);return rc; } +EXPORT_SYMBOL_NS_GPL (cxl_dpa_free,"CXL" );int cxl_dpa_set_mode (struct cxl_endpoint_decoder *cxled,enum cxl_decoder_mode mode)
@@ -455,31 +457,17 @@ int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled,return 0 ; } -int cxl_dpa_alloc (struct cxl_endpoint_decoder *cxled,unsigned long long size) +static resource_size_t cxl_dpa_freespace (struct cxl_endpoint_decoder *cxled, +resource_size_t *start_out, +resource_size_t *skip_out) {struct cxl_memdev *cxlmd =cxled_to_memdev (cxled);resource_size_t free_ram_start, free_pmem_start; -struct cxl_port *port =cxled_to_port (cxled);struct cxl_dev_state *cxlds = cxlmd->cxlds; -struct device *dev = &cxled->cxld.dev;resource_size_t start, avail, skip;struct resource *p, *last; -int rc; - -down_write (&cxl_dpa_rwsem); -if (cxled->cxld.region) { -dev_dbg (dev,"decoder attached to %s\n" , -dev_name (&cxled->cxld.region->dev)); - rc = -EBUSY ; - goto out; - } - -if (cxled->cxld.flags &CXL_DECODER_F_ENABLE ) { -dev_dbg (dev,"decoder enabled\n" ); - rc = -EBUSY ; - goto out; - } +lockdep_assert_held (&cxl_dpa_rwsem);for (p = cxlds->ram_res.child, last =NULL ; p; p = p->sibling) last = p;if (last)
@@ -516,11 +504,41 @@ int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size) skip_end = start -1 ; skip = skip_end - skip_start +1 ; }else { -dev_dbg (dev,"mode not set\n" ); - rc = -EINVAL ; + avail =0 ; + } + +if (!avail) +return 0 ; +if (start_out) + *start_out = start; +if (skip_out) + *skip_out = skip; +return avail; +} + +int cxl_dpa_alloc (struct cxl_endpoint_decoder *cxled,unsigned long long size) +{ +struct cxl_port *port =cxled_to_port (cxled); +struct device *dev = &cxled->cxld.dev; +resource_size_t start, avail, skip; +int rc; + +down_write (&cxl_dpa_rwsem); +if (cxled->cxld.region) { +dev_dbg (dev,"EBUSY, decoder attached to %s\n" , +dev_name (&cxled->cxld.region->dev)); + rc = -EBUSY ; + goto out; + } + +if (cxled->cxld.flags &CXL_DECODER_F_ENABLE ) { +dev_dbg (dev,"EBUSY, decoder enabled\n" ); + rc = -EBUSY ; goto out; } + avail =cxl_dpa_freespace (cxled, &start, &skip); +if (size > avail) {dev_dbg (dev,"%pa exceeds available %s capacity: %pa\n" , &size,cxl_decoder_mode_name (cxled->mode), &avail);
@@ -538,6 +556,101 @@ int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size)return devm_add_action_or_reset (&port->dev, cxl_dpa_release, cxled); } +static int find_free_decoder (struct device *dev,void *data) +{ +struct cxl_endpoint_decoder *cxled; +struct cxl_port *port; + +if (!is_endpoint_decoder (dev)) +return 0 ; + + cxled =to_cxl_endpoint_decoder (dev); + port =cxled_to_port (cxled); + +if (cxled->cxld.id != port->hdm_end +1 ) +return 0 ; + +return 1 ; +} + +/** +* cxl_request_dpa - search and reserve DPA given input constraints +* @cxlmd: memdev with an endpoint port with available decoders +* @is_ram: DPA operation mode (ram vs pmem) +* @min: the minimum amount of capacity the call needs +* @max: HPA capacity available +* +* Given that a region needs to allocate from limited HPA capacity it +* may be the case that a device has more mappable DPA capacity than +* available HPA. So, the expectation is that @min is a driver known +* value for how much capacity is needed, and @max is based the limit of +* how much HPA space is available for a new region. +* +* Returns a pinned cxl_decoder with at least @min bytes of capacity +* reserved, or an error pointer. The caller is also expected to own the +* lifetime of the memdev registration associated with the endpoint to +* pin the decoder registered as well. +*/ +struct cxl_endpoint_decoder *cxl_request_dpa (struct cxl_memdev *cxlmd, +bool is_ram, +resource_size_t min, +resource_size_t max) +{ +struct cxl_port *endpoint = cxlmd->endpoint; +struct cxl_endpoint_decoder *cxled; +enum cxl_decoder_mode mode; +struct device *cxled_dev; +resource_size_t alloc; +int rc; + +if (!IS_ALIGNED (min | max,SZ_256M )) +return ERR_PTR (-EINVAL ); + +down_read (&cxl_dpa_rwsem); + cxled_dev =device_find_child (&endpoint->dev,NULL , find_free_decoder); +up_read (&cxl_dpa_rwsem); + +if (!cxled_dev) +return ERR_PTR (-ENXIO ); + + cxled =to_cxl_endpoint_decoder (cxled_dev); + +if (!cxled) { +put_device (cxled_dev); +return ERR_PTR (-ENODEV ); + } + +if (is_ram) + mode =CXL_DECODER_RAM ; +else + mode =CXL_DECODER_PMEM ; + + rc =cxl_dpa_set_mode (cxled, mode); +if (rc) + goto err; + +down_read (&cxl_dpa_rwsem); + alloc =cxl_dpa_freespace (cxled,NULL ,NULL ); +up_read (&cxl_dpa_rwsem); + +if (max) + alloc =min (max, alloc); +if (alloc < min) { + rc = -ENOMEM ; + goto err; + } + + rc =cxl_dpa_alloc (cxled, alloc); +if (rc) + goto err; + +return cxled; +err: +put_device (cxled_dev); +return ERR_PTR (rc); +} +EXPORT_SYMBOL_NS_GPL (cxl_request_dpa,"CXL" ); +static void cxld_set_interleave (struct cxl_decoder *cxld,u32 *ctrl) {u16 eig;
include/cxl/cxl.h +5 -0
@@ -58,4 +58,9 @@ struct cxl_port;struct cxl_root_decoder *cxl_get_hpa_freespace (struct cxl_memdev *cxlmd,unsigned long flags,resource_size_t *max); +struct cxl_endpoint_decoder *cxl_request_dpa (struct cxl_memdev *cxlmd, +bool is_ram, +resource_size_t min, +resource_size_t max); +int cxl_dpa_free (struct cxl_endpoint_decoder *cxled);#endif
Signature · 1 line
2.17.1
Re: [PATCH v9 17/27] cxl: define a driver interface for DPA allocation
Quoted 8 lines · On Mon, 30 Dec 2024 21:44:35 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
Region creation involves finding available DPA (device-physical-address) capacity to map into HPA (host-physical-address) space. Given the HPA capacity constraint, define an API,
cxl_request_dpa(), that has the flexibility to map the minimum amount of memory the driver needs to operate vs the total possible that can be mapped given HPA availability.
Quoted 8 lines
Factor out the core of
cxl_dpa_alloc, that does free space scanning, into acxl_dpa_freespace()helper, and use that to balance the capacity available to map vs the @min and @max arguments tocxl_request_dpa.Signed-off-by Alejandro Lucero <[email protected]>Co-developed-by Dan Williams <[email protected]>
A couple of really minor things inline. Either way
Quoted 11 lines
+/**
+ *cxl_request_dpa- search and reserve DPA given input constraints
+ * @cxlmd: memdev with an endpoint port with available decoders
+ * @is_ram: DPA operation mode (ram vs pmem)
+ * @min: the minimum amount of capacity the call needs
+ * @max: HPA capacity available
+ *
+ * Given that a region needs to allocate from limited HPA capacity it
+ * may be the case that a device has more mappable DPA capacity than
+ * available HPA. So, the expectation is that @min is a driver known
+ * value for how much capacity is needed, and @max is based the limit of
is the limit? Not sure what the "is based" means
Quoted 24 lines
+ * how much HPA space is available for a new region.
+ *
+ * Returns a pinnedcxl_decoderwith at least @min bytes of capacity
+ * reserved, or an error pointer. The caller is also expected to own the
+ * lifetime of the memdev registration associated with the endpoint to
+ * pin the decoder registered as well.
+ */drivers/cxl/core/hdm.c +17
-0+struct cxl_endpoint_decoder *cxl_request_dpa (struct cxl_memdev *cxlmd, +bool is_ram, +resource_size_t min, +resource_size_t max) +{ +struct cxl_port *endpoint = cxlmd->endpoint; +struct cxl_endpoint_decoder *cxled; +enum cxl_decoder_mode mode; +struct device *cxled_dev; +resource_size_t alloc; +int rc; + +if (!IS_ALIGNED (min | max,SZ_256M )) +return ERR_PTR (-EINVAL ); + +down_read (&cxl_dpa_rwsem); + cxled_dev =device_find_child (&endpoint->dev,NULL , find_free_decoder);
drivers/cxl/core/hdm.c int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size) · line 620
Quoted 10 lines
drivers/cxl/core/hdm.c +10
-0+up_read (&cxl_dpa_rwsem); + +if (!cxled_dev) +return ERR_PTR (-ENXIO ); + + cxled =to_cxl_endpoint_decoder (cxled_dev); + +if (!cxled) { +put_device (cxled_dev); +return ERR_PTR (-ENODEV );
Ah. My suggestion on v8 missed that there is an error block below. More consistent with rest of the code as
rc = -ENODEV; goto err;
Quoted 32 lines
drivers/cxl/core/hdm.c +32
-0+ } + +if (is_ram) + mode =CXL_DECODER_RAM ; +else + mode =CXL_DECODER_PMEM ; + + rc =cxl_dpa_set_mode (cxled, mode); +if (rc) + goto err; + +down_read (&cxl_dpa_rwsem); + alloc =cxl_dpa_freespace (cxled,NULL ,NULL ); +up_read (&cxl_dpa_rwsem); + +if (max) + alloc =min (max, alloc); +if (alloc < min) { + rc = -ENOMEM ; + goto err; + } + + rc =cxl_dpa_alloc (cxled, alloc); +if (rc) + goto err; + +return cxled; +err: +put_device (cxled_dev); +return ERR_PTR (rc); +} +EXPORT_SYMBOL_NS_GPL (cxl_request_dpa,"CXL" );
Re: [PATCH v9 17/27] cxl: define a driver interface for DPA allocation
Quoted 34 lines · Jonathan Cameron
Quoted 8 lines · On Mon, 30 Dec 2024 21:44:35 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
Region creation involves finding available DPA (device-physical-address) capacity to map into HPA (host-physical-address) space. Given the HPA capacity constraint, define an API,
cxl_request_dpa(), that has the flexibility to map the minimum amount of memory the driver needs to operate vs the total possible that can be mapped given HPA availability.Quoted 8 lines
Factor out the core of
cxl_dpa_alloc, that does free space scanning, into acxl_dpa_freespace()helper, and use that to balance the capacity available to map vs the @min and @max arguments tocxl_request_dpa.Signed-off-by Alejandro Lucero <[email protected]>Co-developed-by Dan Williams <[email protected]>A couple of really minor things inline. Either way
Reviewed-by Jonathan Cameron <[email protected]>Quoted 11 lines
+/**
+ *cxl_request_dpa- search and reserve DPA given input constraints
+ * @cxlmd: memdev with an endpoint port with available decoders
+ * @is_ram: DPA operation mode (ram vs pmem)
+ * @min: the minimum amount of capacity the call needs
+ * @max: HPA capacity available
+ *
+ * Given that a region needs to allocate from limited HPA capacity it
+ * may be the case that a device has more mappable DPA capacity than
+ * available HPA. So, the expectation is that @min is a driver known
+ * value for how much capacity is needed, and @max is based the limit of
Quoted 1 line
is the limit? Not sure what the "is based" means
Typo from original Dan's patches.
I'll fix it.
Quoted 38 lines
Quoted 25 lines
+ * how much HPA space is available for a new region.
+ *
+ * Returns a pinnedcxl_decoderwith at least @min bytes of capacity
+ * reserved, or an error pointer. The caller is also expected to own the
+ * lifetime of the memdev registration associated with the endpoint to
+ * pin the decoder registered as well.
+ */drivers/cxl/core/hdm.c +17
-0+struct cxl_endpoint_decoder *cxl_request_dpa (struct cxl_memdev *cxlmd, +bool is_ram, +resource_size_t min, +resource_size_t max) +{ +struct cxl_port *endpoint = cxlmd->endpoint; +struct cxl_endpoint_decoder *cxled; +enum cxl_decoder_mode mode; +struct device *cxled_dev; +resource_size_t alloc; +int rc; + +if (!IS_ALIGNED (min | max,SZ_256M )) +return ERR_PTR (-EINVAL ); + +down_read (&cxl_dpa_rwsem); + cxled_dev =device_find_child (&endpoint->dev,NULL , find_free_decoder);drivers/cxl/core/hdm.c int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size) · line 620
Quoted 10 lines
drivers/cxl/core/hdm.c +10
-0+up_read (&cxl_dpa_rwsem); + +if (!cxled_dev) +return ERR_PTR (-ENXIO ); + + cxled =to_cxl_endpoint_decoder (cxled_dev); + +if (!cxled) { +put_device (cxled_dev); +return ERR_PTR (-ENODEV );Ah. My suggestion on v8 missed that there is an error block below. More consistent with rest of the code as
Quoted 3 lines
rc = -ENODEV; goto err;
I'll do.
Thanks!
Quoted 33 lines
Quoted 32 lines
drivers/cxl/core/hdm.c +32
-0+ } + +if (is_ram) + mode =CXL_DECODER_RAM ; +else + mode =CXL_DECODER_PMEM ; + + rc =cxl_dpa_set_mode (cxled, mode); +if (rc) + goto err; + +down_read (&cxl_dpa_rwsem); + alloc =cxl_dpa_freespace (cxled,NULL ,NULL ); +up_read (&cxl_dpa_rwsem); + +if (max) + alloc =min (max, alloc); +if (alloc < min) { + rc = -ENOMEM ; + goto err; + } + + rc =cxl_dpa_alloc (cxled, alloc); +if (rc) + goto err; + +return cxled; +err: +put_device (cxled_dev); +return ERR_PTR (rc); +} +EXPORT_SYMBOL_NS_GPL (cxl_request_dpa,"CXL" );
PATCH v9 18/27 sfc: get endpoint decoder
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Use cxl api for getting DPA (Device Physical Address) to use through an endpoint decoder.
--- drivers/net/ethernet/sfc/efx_cxl.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/ethernet/sfc/efx_cxl.c +9 -0
@@ -121,6 +121,14 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err_memdev; } + cxl->cxled =cxl_request_dpa (cxl->cxlmd, true,EFX_CTPIO_BUFFER_SIZE , +EFX_CTPIO_BUFFER_SIZE ); +if (IS_ERR (cxl->cxled)) { +pci_err (pci_dev,"CXL accel request DPA failed" ); + rc =PTR_ERR (cxl->cxled); + goto err_memdev; + } + probe_data->cxl = cxl;return 0 ;
@@ -137,6 +145,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data)void efx_cxl_exit (struct efx_probe_data *probe_data) {if (probe_data->cxl) { +cxl_dpa_free (probe_data->cxl->cxled);cxl_release_resource (probe_data->cxl->cxlds,CXL_RES_RAM );kfree (probe_data->cxl->cxlds);kfree (probe_data->cxl);
Signature · 1 line
2.17.1
Re: [PATCH v9 18/27] sfc: get endpoint decoder
Quoted 7 lines · On Mon, 30 Dec 2024 21:44:36 +0000 <[email protected]> wrote:
From: Alejandro Lucero <[email protected]>
Use cxl api for getting DPA (Device Physical Address) to use through an endpoint decoder.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>
FWIW seems sensible
Re: [PATCH v9 18/27] sfc: get endpoint decoder
In reply to [email protected]Quoted 7 lines · On 30/12/2024 21:44, [email protected] wrote:
From: Alejandro Lucero <[email protected]>
Use cxl api for getting DPA (Device Physical Address) to use through an endpoint decoder.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Martin Habets <[email protected]>
PATCH v9 19/27 cxl: make region type based on endpoint type
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Current code is expecting Type3 or CXL_DECODER_HOSTONLYMEM devices only. Support for Type2 implies region type needs to be based on the endpoint type instead.
--- drivers/cxl/core/region.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/cxl/core/region.c +6 -4
@@ -2668,7 +2668,8 @@ static ssize_t create_ram_region_show(struct device *dev, }static struct cxl_region *__create_region (struct cxl_root_decoder *cxlrd, -enum cxl_decoder_mode mode,int id) +enum cxl_decoder_mode mode,int id, +enum cxl_decoder_type target_type) {int rc;
@@ -2690,7 +2691,7 @@ static struct cxl_region *__create_region(struct cxl_root_decoder *cxlrd,return ERR_PTR (-EBUSY ); } -return devm_cxl_add_region (cxlrd, id, mode,CXL_DECODER_HOSTONLYMEM ); +return devm_cxl_add_region (cxlrd, id, mode, target_type); } static ssize_t create_region_store(struct device *dev, const char *buf,
@@ -2704,7 +2705,7 @@ static ssize_t create_region_store(struct device *dev, const char *buf,if (rc !=1 )return -EINVAL ; - cxlr =__create_region (cxlrd, mode, id); + cxlr =__create_region (cxlrd, mode, id,CXL_DECODER_HOSTONLYMEM );if (IS_ERR (cxlr))return PTR_ERR (cxlr);
@@ -3380,7 +3381,8 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,do { cxlr =__create_region (cxlrd, cxled->mode, -atomic_read (&cxlrd->region_id)); +atomic_read (&cxlrd->region_id), + cxled->cxld.target_type); }while (IS_ERR (cxlr) &&PTR_ERR (cxlr) == -EBUSY );if (IS_ERR (cxlr)) {
Signature · 1 line
2.17.1
PATCH v9 20/27 cxl/region: factor out interleave ways setup
In reply to [email protected]From: Alejandro Lucero <[email protected]>
In preparation for kernel driven region creation, factor out a common helper from the user-sysfs region setup for interleave ways.
--- drivers/cxl/core/region.c | 46 +++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 19 deletions(-)
drivers/cxl/core/region.c +27 -19
@@ -464,22 +464,14 @@ static ssize_t interleave_ways_show(struct device *dev,static const struct attribute_group *get_cxl_region_target_group (void ); -static ssize_t interleave_ways_store (struct device *dev, -struct device_attribute *attr, -const char *buf,size_t len) +static int set_interleave_ways (struct cxl_region *cxlr,int val) { -struct cxl_root_decoder *cxlrd =to_cxl_root_decoder (dev->parent); +struct cxl_root_decoder *cxlrd =to_cxl_root_decoder (cxlr->dev.parent);struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld; -struct cxl_region *cxlr =to_cxl_region (dev);struct cxl_region_params *p = &cxlr->params; -unsigned int val, save; -int rc; +int save, rc;u8 iw; - rc =kstrtouint (buf,0 , &val); -if (rc) -return rc; - rc =ways_to_eiw (val, &iw);if (rc)return rc;
@@ -494,20 +486,36 @@ static ssize_t interleave_ways_store(struct device *dev,return -EINVAL ; } - rc =down_write_killable (&cxl_region_rwsem); -if (rc) -return rc; -if (p->state >=CXL_CONFIG_INTERLEAVE_ACTIVE ) { - rc = -EBUSY ; - goto out; - } +lockdep_assert_held_write (&cxl_region_rwsem); +if (p->state >=CXL_CONFIG_INTERLEAVE_ACTIVE ) +return -EBUSY ; save = p->interleave_ways; p->interleave_ways = val; rc =sysfs_update_group (&cxlr->dev.kobj,get_cxl_region_target_group ());if (rc) p->interleave_ways = save; -out: + +return rc; +} + +static ssize_t interleave_ways_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +struct cxl_region *cxlr =to_cxl_region (dev); +unsigned int val; +int rc; + + rc =kstrtouint (buf,0 , &val); +if (rc) +return rc; + + rc =down_write_killable (&cxl_region_rwsem); +if (rc) +return rc; + + rc =set_interleave_ways (cxlr, val);up_write (&cxl_region_rwsem);if (rc)return rc;
Signature · 1 line
2.17.1
PATCH v9 21/27 cxl/region: factor out interleave granularity setup
In reply to [email protected]From: Alejandro Lucero <[email protected]>
In preparation for kernel driven region creation, factor out a common helper from the user-sysfs region setup for interleave granularity.
--- drivers/cxl/core/region.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
drivers/cxl/core/region.c +23 -16
@@ -540,21 +540,14 @@ static ssize_t interleave_granularity_show(struct device *dev,return rc; } -static ssize_t interleave_granularity_store (struct device *dev, -struct device_attribute *attr, -const char *buf,size_t len) +static int set_interleave_granularity (struct cxl_region *cxlr,int val) { -struct cxl_root_decoder *cxlrd =to_cxl_root_decoder (dev->parent); +struct cxl_root_decoder *cxlrd =to_cxl_root_decoder (cxlr->dev.parent);struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld; -struct cxl_region *cxlr =to_cxl_region (dev);struct cxl_region_params *p = &cxlr->params; -int rc, val; +int rc;u16 ig; - rc =kstrtoint (buf,0 , &val); -if (rc) -return rc; - rc =granularity_to_eig (val, &ig);if (rc)return rc;
@@ -570,16 +563,30 @@ static ssize_t interleave_granularity_store(struct device *dev,if (cxld->interleave_ways >1 && val != cxld->interleave_granularity)return -EINVAL ; +lockdep_assert_held_write (&cxl_region_rwsem); +if (p->state >=CXL_CONFIG_INTERLEAVE_ACTIVE ) +return -EBUSY ; + + p->interleave_granularity = val; +return 0 ; +} + +static ssize_t interleave_granularity_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t len) +{ +struct cxl_region *cxlr =to_cxl_region (dev); +int rc, val; + + rc =kstrtoint (buf,0 , &val); +if (rc) +return rc; + rc =down_write_killable (&cxl_region_rwsem);if (rc)return rc; -if (p->state >=CXL_CONFIG_INTERLEAVE_ACTIVE ) { - rc = -EBUSY ; - goto out; - } - p->interleave_granularity = val; -out: + rc =set_interleave_granularity (cxlr, val);up_write (&cxl_region_rwsem);if (rc)return rc;
Signature · 1 line
2.17.1
PATCH v9 22/27 cxl: allow region creation by type2 drivers
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Creating a CXL region requires userspace intervention through the cxl sysfs files. Type2 support should allow accelerator drivers to create such cxl region from kernel code.
Adding that functionality and integrating it with current support for memory expanders.
--- drivers/cxl/core/region.c | 145 ++++++++++++++++++++++++++++++++++---- drivers/cxl/cxlmem.h | 2 + drivers/cxl/port.c | 5 +- include/cxl/cxl.h | 4 ++ 4 files changed, 141 insertions(+), 15 deletions(-)
drivers/cxl/core/region.c +131 -14
@@ -2270,6 +2270,18 @@ static int cxl_region_detach(struct cxl_endpoint_decoder *cxled)return rc; } +int cxl_accel_region_detach (struct cxl_endpoint_decoder *cxled) +{ +int rc; + +down_write (&cxl_region_rwsem); + cxled->mode =CXL_DECODER_DEAD ; + rc =cxl_region_detach (cxled); +up_write (&cxl_region_rwsem); +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_accel_region_detach,"CXL" ); +void cxl_decoder_kill_region (struct cxl_endpoint_decoder *cxled) {down_write (&cxl_region_rwsem);
@@ -2776,6 +2788,14 @@ cxl_find_region_by_name(struct cxl_root_decoder *cxlrd, const char *name)return to_cxl_region (region_dev); } +static void drop_region (struct cxl_region *cxlr) +{ +struct cxl_root_decoder *cxlrd =to_cxl_root_decoder (cxlr->dev.parent); +struct cxl_port *port =cxlrd_to_port (cxlrd); + +devm_release_action (port->uport_dev, unregister_region, cxlr); +} +static ssize_t delete_region_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t len)
@@ -3382,17 +3402,18 @@ static int match_region_by_range(struct device *dev, void *data)return rc; } -/* Establish an empty region covering the given HPA range */ -static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, - struct cxl_endpoint_decoder *cxled) +static void construct_region_end (void ) +{ +up_write (&cxl_region_rwsem); +} + +static struct cxl_region *construct_region_begin(struct cxl_root_decoder *cxlrd, + struct cxl_endpoint_decoder *cxled) { struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); - struct cxl_port *port = cxlrd_to_port(cxlrd); - struct range *hpa = &cxled->cxld.hpa_range; struct cxl_region_params *p; struct cxl_region *cxlr; - struct resource *res; - int rc; + int err; do { cxlr = __create_region(cxlrd, cxled->mode,
@@ -3412,13 +3433,33 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, p = &cxlr->params;if (p->state >=CXL_CONFIG_INTERLEAVE_ACTIVE ) {dev_err (cxlmd->dev.parent, -"%s:%s: %s autodiscovery interrupted\n" , +"%s:%s: %s region setup interrupted\n" ,dev_name (&cxlmd->dev),dev_name (&cxled->cxld.dev), __func__); - rc = -EBUSY ; - goto err; + err = -EBUSY ; +construct_region_end (); +drop_region (cxlr); +return ERR_PTR (err); } +return cxlr; +} + +/* Establish an empty region covering the given HPA range */ +static struct cxl_region *construct_region (struct cxl_root_decoder *cxlrd, +struct cxl_endpoint_decoder *cxled) +{ +struct cxl_memdev *cxlmd =cxled_to_memdev (cxled); +struct range *hpa = &cxled->cxld.hpa_range; +struct cxl_region_params *p; +struct cxl_region *cxlr; +struct resource *res; +int rc; + + cxlr =construct_region_begin (cxlrd, cxled); +if (IS_ERR (cxlr)) +return cxlr; +set_bit (CXL_REGION_F_AUTO , &cxlr->flags); res =kmalloc (sizeof (*res),GFP_KERNEL );
@@ -3441,6 +3482,7 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, __func__, dev_name(&cxlr->dev)); } + p = &cxlr->params; p->res = res; p->interleave_ways = cxled->cxld.interleave_ways; p->interleave_granularity = cxled->cxld.interleave_granularity;
@@ -3457,16 +3499,91 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,/* ...to match put_device() in cxl_add_to_region() */ get_device (&cxlr->dev); -up_write (&cxl_region_rwsem); - +construct_region_end ();return cxlr; err: -up_write (&cxl_region_rwsem); -devm_release_action (port->uport_dev, unregister_region, cxlr); +construct_region_end (); +drop_region (cxlr); +return ERR_PTR (rc); +} + +static struct cxl_region * +__construct_new_region (struct cxl_root_decoder *cxlrd, +struct cxl_endpoint_decoder *cxled) +{ +struct cxl_decoder *cxld = &cxlrd->cxlsd.cxld; +struct cxl_region_params *p; +struct cxl_region *cxlr; +int rc; + + cxlr =construct_region_begin (cxlrd, cxled); +if (IS_ERR (cxlr)) +return cxlr; + + rc =set_interleave_ways (cxlr,1 ); +if (rc) + goto err; + + rc =set_interleave_granularity (cxlr, cxld->interleave_granularity); +if (rc) + goto err; + + rc =alloc_hpa (cxlr,resource_size (cxled->dpa_res)); +if (rc) + goto err; + +down_read (&cxl_dpa_rwsem); + rc =cxl_region_attach (cxlr, cxled,0 ); +up_read (&cxl_dpa_rwsem); + +if (rc) + goto err; + + rc =cxl_region_decode_commit (cxlr); +if (rc) + goto err; + + p = &cxlr->params; + p->state =CXL_CONFIG_COMMIT ; + +construct_region_end (); +return cxlr; +err: +construct_region_end (); +drop_region (cxlr);return ERR_PTR (rc); } +/** +* cxl_create_region - Establish a region given an endpoint decoder +* @cxlrd: root decoder to allocate HPA +* @cxled: endpoint decoder with reserved DPA capacity +* +* Returns a fully formed region in the commit state and attached to the +* cxl_region driver. +*/ +struct cxl_region *cxl_create_region (struct cxl_root_decoder *cxlrd, +struct cxl_endpoint_decoder *cxled) +{ +struct cxl_region *cxlr; + +mutex_lock (&cxlrd->range_lock); + cxlr =__construct_new_region (cxlrd, cxled); +mutex_unlock (&cxlrd->range_lock); + +if (IS_ERR (cxlr)) +return cxlr; + +if (device_attach (&cxlr->dev) <=0 ) { +dev_err (&cxlr->dev,"failed to create region\n" ); +drop_region (cxlr); +return ERR_PTR (-ENODEV ); + } +return cxlr; +} +EXPORT_SYMBOL_NS_GPL (cxl_create_region,"CXL" ); +int cxl_add_to_region (struct cxl_port *root,struct cxl_endpoint_decoder *cxled) {struct cxl_memdev *cxlmd =cxled_to_memdev (cxled);
drivers/cxl/cxlmem.h +2 -0
@@ -872,4 +872,6 @@ struct cxl_hdm {struct seq_file ;struct dentry *cxl_debugfs_create_dir (const char *dir);void cxl_dpa_debug (struct seq_file *file,struct cxl_dev_state *cxlds); +struct cxl_region *cxl_create_region (struct cxl_root_decoder *cxlrd, +struct cxl_endpoint_decoder *cxled);#endif /* __CXL_MEM_H__ */
drivers/cxl/port.c +4 -1
@@ -33,6 +33,7 @@ static void schedule_detach(void *cxlmd)static int discover_region (struct device *dev,void *root) {struct cxl_endpoint_decoder *cxled; +struct cxl_memdev *cxlmd;int rc;if (!is_endpoint_decoder (dev))
@@ -42,7 +43,9 @@ static int discover_region(struct device *dev, void *root)if ((cxled->cxld.flags &CXL_DECODER_F_ENABLE ) ==0 )return 0 ; -if (cxled->state !=CXL_DECODER_STATE_AUTO ) + cxlmd =cxled_to_memdev (cxled); +if (cxled->state !=CXL_DECODER_STATE_AUTO || + cxlmd->cxlds->type ==CXL_DEVTYPE_DEVMEM )return 0 ;/*
include/cxl/cxl.h +4 -0
@@ -63,4 +63,8 @@ struct cxl_endpoint_decoder *cxl_request_dpa(struct cxl_memdev *cxlmd,resource_size_t min, resource_size_t max);int cxl_dpa_free (struct cxl_endpoint_decoder *cxled); +struct cxl_region *cxl_create_region (struct cxl_root_decoder *cxlrd, +struct cxl_endpoint_decoder *cxled); + +int cxl_accel_region_detach (struct cxl_endpoint_decoder *cxled);#endif
Signature · 1 line
2.17.1
Re: [PATCH v9 22/27] cxl: allow region creation by type2 drivers
Quoted 6 lines · On Mon, 30 Dec 2024 21:44:40 +0000 [email protected] wrote:
From: Alejandro Lucero <[email protected]>
Creating a CXL region requires userspace intervention through the cxl sysfs files. Type2 support should allow accelerator drivers to create such cxl region from kernel code.
Quoted 8 lines
Adding that functionality and integrating it with current support for memory expanders.
Signed-off-by Alejandro Lucero <[email protected]>Co-developed-by Dan Williams <[email protected]>Reviewed-by Zhi Wang <[email protected]>
Trivial comment inline. Either way
Quoted 12 lines
--- drivers/cxl/core/region.c | 145 ++++++++++++++++++++++++++++++++++---- drivers/cxl/cxlmem.h | 2 + drivers/cxl/port.c | 5 +- include/cxl/cxl.h | 4 ++ 4 files changed, 141 insertions(+), 15 deletions(-)drivers/cxl/core/region.c +0
-0
drivers/cxl/core/region.c static int cxl_region_detach(struct cxl_endpoint_decoder *cxled) · line 2277
Quoted 8 lines
drivers/cxl/core/region.c +5
-0@@ -2270,6 +2270,18 @@ static int cxl_region_detach(struct cxl_endpoint_decoder *cxled)return rc; } +int cxl_accel_region_detach (struct cxl_endpoint_decoder *cxled) +{ +int rc; + +down_write (&cxl_region_rwsem);
Could use a guard here so you can return directly.
Quoted 6 lines
drivers/cxl/core/region.c +6
-0+ cxled->mode =CXL_DECODER_DEAD ; + rc =cxl_region_detach (cxled); +up_write (&cxl_region_rwsem); +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_accel_region_detach,"CXL" );
Re: [PATCH v9 22/27] cxl: allow region creation by type2 drivers
Quoted 35 lines · Jonathan Cameron
Quoted 6 lines · On Mon, 30 Dec 2024 21:44:40 +0000 [email protected] wrote:
From: Alejandro Lucero <[email protected]>
Creating a CXL region requires userspace intervention through the cxl sysfs files. Type2 support should allow accelerator drivers to create such cxl region from kernel code.
Quoted 8 lines
Adding that functionality and integrating it with current support for memory expanders.
Signed-off-by Alejandro Lucero <[email protected]>Co-developed-by Dan Williams <[email protected]>Reviewed-by Zhi Wang <[email protected]>Trivial comment inline. Either way
Reviewed-by Jonathan Cameron <[email protected]>Quoted 15 lines
--- drivers/cxl/core/region.c | 145 ++++++++++++++++++++++++++++++++++---- drivers/cxl/cxlmem.h | 2 + drivers/cxl/port.c | 5 +- include/cxl/cxl.h | 4 ++ 4 files changed, 141 insertions(+), 15 deletions(-)drivers/cxl/core/region.c +0
-0@@ -2270,6 +2270,18 @@ static int cxl_region_detach(struct cxl_endpoint_decoder *cxled)return rc; }
Quoted 6 lines
drivers/cxl/core/region.c static int cxl_region_detach(struct cxl_endpoint_decoder *cxled) · line 2277
Quoted 5 lines
drivers/cxl/core/region.c +5
-0+int cxl_accel_region_detach (struct cxl_endpoint_decoder *cxled) +{ +int rc; + +down_write (&cxl_region_rwsem);Could use a guard here so you can return directly.
Interesting. Not familiar with this automatic cleanups, but I'll use as it is already being used inside kernel cxl core.
Thanks!
Quoted 7 lines
Quoted 6 lines
drivers/cxl/core/region.c +6
-0+ cxled->mode =CXL_DECODER_DEAD ; + rc =cxl_region_detach (cxled); +up_write (&cxl_region_rwsem); +return rc; +} +EXPORT_SYMBOL_NS_GPL (cxl_accel_region_detach,"CXL" );
PATCH v9 23/27 cxl: add region flag for precluding a device memory to be used for dax
In reply to [email protected]From: Alejandro Lucero <[email protected]>
By definition a type2 cxl device will use the host managed memory for specific functionality, therefore it should not be available to other uses. However, a dax interface could be just good enough in some cases.
Add a flag to a cxl region for specifically state to not create a dax device. Allow a Type2 driver to set that flag at region creation time.
--- drivers/cxl/core/region.c | 11 ++++++++++- drivers/cxl/cxl.h | 3 +++ drivers/cxl/cxlmem.h | 3 ++- include/cxl/cxl.h | 3 ++- 4 files changed, 17 insertions(+), 3 deletions(-)
drivers/cxl/core/region.c +10 -1
@@ -3559,12 +3559,14 @@ __construct_new_region(struct cxl_root_decoder *cxlrd,* cxl_create_region - Establish a region given an endpoint decoder * @cxlrd: root decoder to allocate HPA * @cxled: endpoint decoder with reserved DPA capacity +* @no_dax: if true no DAX device should be created * * Returns a fully formed region in the commit state and attached to the * cxl_region driver. */ struct cxl_region *cxl_create_region (struct cxl_root_decoder *cxlrd, -struct cxl_endpoint_decoder *cxled) +struct cxl_endpoint_decoder *cxled, +bool no_dax) {struct cxl_region *cxlr;
@@ -3580,6 +3582,10 @@ struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd,drop_region (cxlr);return ERR_PTR (-ENODEV ); } + +if (no_dax) +set_bit (CXL_REGION_F_NO_DAX , &cxlr->flags); +return cxlr; }EXPORT_SYMBOL_NS_GPL (cxl_create_region,"CXL" );
@@ -3715,6 +3721,9 @@ static int cxl_region_probe(struct device *dev)if (rc)return rc; +if (test_bit (CXL_REGION_F_NO_DAX , &cxlr->flags)) +return 0 ; +switch (cxlr->mode) {case CXL_DECODER_PMEM :return devm_cxl_add_pmem_region (cxlr);
drivers/cxl/cxl.h +3 -0
@@ -521,6 +521,9 @@ struct cxl_region_params {*/ #define CXL_REGION_F_NEEDS_RESET 1 +/* Allow Type2 drivers to specify if a dax region should not be created. */ +#define CXL_REGION_F_NO_DAX 2 +/** * struct cxl_region - CXL region * @dev: This region's device
drivers/cxl/cxlmem.h +2 -1
@@ -873,5 +873,6 @@ struct seq_file;struct dentry *cxl_debugfs_create_dir (const char *dir);void cxl_dpa_debug (struct seq_file *file,struct cxl_dev_state *cxlds);struct cxl_region *cxl_create_region (struct cxl_root_decoder *cxlrd, -struct cxl_endpoint_decoder *cxled); +struct cxl_endpoint_decoder *cxled, +bool no_dax);#endif /* __CXL_MEM_H__ */
include/cxl/cxl.h +2 -1
@@ -64,7 +64,8 @@ struct cxl_endpoint_decoder *cxl_request_dpa(struct cxl_memdev *cxlmd, resource_size_t max);int cxl_dpa_free (struct cxl_endpoint_decoder *cxled);struct cxl_region *cxl_create_region (struct cxl_root_decoder *cxlrd, -struct cxl_endpoint_decoder *cxled); +struct cxl_endpoint_decoder *cxled, +bool no_dax);int cxl_accel_region_detach (struct cxl_endpoint_decoder *cxled);#endif
Signature · 1 line
2.17.1
Re: [PATCH v9 23/27] cxl: add region flag for precluding a device memory to be used for dax
Quoted 11 lines · On Mon, 30 Dec 2024 21:44:41 +0000 [email protected] wrote:
From: Alejandro Lucero <[email protected]>
By definition a type2 cxl device will use the host managed memory for specific functionality, therefore it should not be available to other uses. However, a dax interface could be just good enough in some cases.
Add a flag to a cxl region for specifically state to not create a dax device. Allow a Type2 driver to set that flag at region creation time.
Signed-off-by Alejandro Lucero <[email protected]>Reviewed-by Zhi Wang <[email protected]>
To me this seems a little premature as it will always be set by known usecases, but meh, if someone else wants it it is indeed harmless.
PATCH v9 24/27 sfc: create cxl region
In reply to [email protected]From: Alejandro Lucero <[email protected]>
Use cxl api for creating a region using the endpoint decoder related to a DPA range specifying no DAX device should be created.
--- drivers/net/ethernet/sfc/efx_cxl.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/ethernet/sfc/efx_cxl.c +10 -0
@@ -129,10 +129,19 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err_memdev; } + cxl->efx_region =cxl_create_region (cxl->cxlrd, cxl->cxled, true); +if (IS_ERR (cxl->efx_region)) { +pci_err (pci_dev,"CXL accel create region failed" ); + rc =PTR_ERR (cxl->efx_region); + goto err_region; + } + probe_data->cxl = cxl;return 0 ; +err_region: +cxl_dpa_free (cxl->cxled); err_memdev:cxl_release_resource (cxl->cxlds,CXL_RES_RAM ); err_resource_set:
@@ -145,6 +154,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data)void efx_cxl_exit (struct efx_probe_data *probe_data) {if (probe_data->cxl) { +cxl_accel_region_detach (probe_data->cxl->cxled);cxl_dpa_free (probe_data->cxl->cxled);cxl_release_resource (probe_data->cxl->cxlds,CXL_RES_RAM );kfree (probe_data->cxl->cxlds);
Signature · 1 line
2.17.1
PATCH v9 25/27 cxl: add function for obtaining region range
In reply to [email protected]From: Alejandro Lucero <[email protected]>
A CXL region struct contains the physical address to work with.
Add a function for getting the cxl region range to be used for mapping such memory range.
--- drivers/cxl/core/region.c | 15 +++++++++++++++ drivers/cxl/cxl.h | 1 + include/cxl/cxl.h | 2 ++ 3 files changed, 18 insertions(+)
drivers/cxl/core/region.c +15 -0
@@ -2677,6 +2677,21 @@ static struct cxl_region *devm_cxl_add_region(struct cxl_root_decoder *cxlrd,return ERR_PTR (rc); } +int cxl_get_region_range (struct cxl_region *region,struct range *range) +{ +if (WARN_ON_ONCE (!region)) +return -ENODEV ; + +if (!region->params.res) +return -ENOSPC ; + + range->start = region->params.res->start; + range->end = region->params.res->end; + +return 0 ; +} +EXPORT_SYMBOL_NS_GPL (cxl_get_region_range,"CXL" ); +static ssize_t __create_region_show (struct cxl_root_decoder *cxlrd,char *buf) {return sysfs_emit (buf,"region%u\n" ,atomic_read (&cxlrd->region_id));
drivers/cxl/cxl.h +1 -0
@@ -921,6 +921,7 @@ void cxl_coordinates_combine(struct access_coordinate *out,bool cxl_endpoint_decoder_reset_detected (struct cxl_port *port); +int cxl_get_region_range (struct cxl_region *region,struct range *range);/* * Unit test builds overrides this to __weak, find the 'strong' version * of these symbols in tools/testing/cxl/.
include/cxl/cxl.h +2 -0
@@ -68,4 +68,6 @@ struct cxl_region *cxl_create_region(struct cxl_root_decoder *cxlrd, bool no_dax);int cxl_accel_region_detach (struct cxl_endpoint_decoder *cxled); +struct range ; +int cxl_get_region_range (struct cxl_region *region,struct range *range);#endif
Signature · 1 line
2.17.1
PATCH v9 26/27 sfc: update MCDI protocol headers
In reply to [email protected]From: Alejandro Lucero <[email protected]>
The script used to generate this now includes CXL definitions.
--- drivers/net/ethernet/sfc/mcdi_pcol.h | 13645 +++++++++---------------- 1 file changed, 4861 insertions(+), 8784 deletions(-)
drivers/net/ethernet/sfc/mcdi_pcol.h +4861 -8784
@@ -72,19 +72,19 @@* | \------- Error * \------------------------------ Resync (always set) * -* The client writes it's request into MC shared memory, and rings the -* doorbell. Each request is completed by either by the MC writing +* The client writes its request into MC shared memory, and rings the +* doorbell. Each request is completed either by the MC writing * back into shared memory, or by writing out an event. * * All MCDI commands support completion by shared memory response. Each * request may also contain additional data (accounted for by HEADER.LEN), -* and some response's may also contain additional data (again, accounted +* and some responses may also contain additional data (again, accounted * for by HEADER.LEN). * * Some MCDI commands support completion by event, in which any associated * response data is included in the event. * -* The protocol requires one response to be delivered for every request, a +* The protocol requires one response to be delivered for every request; a * request should not be sent unless the response for the previous request * has been received (either by polling shared memory, or by receiving * an event).
@@ -321,7 +321,7 @@/* enum: The requesting client is not a function */ #define MC_CMD_ERR_CLIENT_NOT_FN 0x100c/* enum: The requested operation might require the command to be passed between -* MCs, and thetransport doesn't support that. Should only ever been seen over +* MCs, and the transport doesn't support that. Should only ever been seen over * the UART. */ #define MC_CMD_ERR_TRANSPORT_NOPROXY 0x100d
@@ -358,7 +358,7 @@* sub-variant switching. */ #define MC_CMD_ERR_FILTERS_PRESENT 0x1014 -/* enum: The clock whose frequency you've attempted to set set doesn't exist on +/* enum: The clock whose frequency you've attempted to set doesn't exist on * this NIC */ #define MC_CMD_ERR_NO_CLOCK 0x1015
@@ -387,25 +387,6 @@*/ #define MC_CMD_ERR_PIOBUFS_PRESENT 0x101b -/* MC_CMD_RESOURCE_SPECIFIER enum */ -/* enum: Any */ -#define MC_CMD_RESOURCE_INSTANCE_ANY 0xffffffff -#define MC_CMD_RESOURCE_INSTANCE_NONE 0xfffffffe/* enum */ - -/* MC_CMD_FPGA_FLASH_INDEX enum */ -#define MC_CMD_FPGA_FLASH_PRIMARY 0x0/* enum */ -#define MC_CMD_FPGA_FLASH_SECONDARY 0x1/* enum */ - -/* MC_CMD_EXTERNAL_MAE_LINK_MODE enum */ -/* enum: Legacy mode as described in XN-200039-TC. */ -#define MC_CMD_EXTERNAL_MAE_LINK_MODE_LEGACY 0x0 -/* enum: Switchdev mode as described in XN-200039-TC. */ -#define MC_CMD_EXTERNAL_MAE_LINK_MODE_SWITCHDEV 0x1 -/* enum: Bootstrap mode as described in XN-200039-TC. */ -#define MC_CMD_EXTERNAL_MAE_LINK_MODE_BOOTSTRAP 0x2 -/* enum: Link-mode change is in-progress as described in XN-200039-TC. */ -#define MC_CMD_EXTERNAL_MAE_LINK_MODE_PENDING 0xf -/* PCIE_INTERFACE enum: From EF100 onwards, SFC products can have multiple PCIe * interfaces. There is a need to refer to interfaces explicitly from drivers * (for example, a management driver on one interface administering a function
@@ -424,6 +405,14 @@* an on-NIC ARM module is expected to be connected. */ #define PCIE_INTERFACE_NIC_EMBEDDED 0x1 +/* enum: The PCIe logical interface 0. It is an alias for HOST_PRIMARY. */ +#define PCIE_INTERFACE_PCIE_HOST_INTF_0 0x0 +/* enum: The PCIe logical interface 1. */ +#define PCIE_INTERFACE_PCIE_HOST_INTF_1 0x2 +/* enum: The PCIe logical interface 2. */ +#define PCIE_INTERFACE_PCIE_HOST_INTF_2 0x3 +/* enum: The PCIe logical interface 3. */ +#define PCIE_INTERFACE_PCIE_HOST_INTF_3 0x4/* enum: For MCDI commands issued over a PCIe interface, this value is * translated into the interface over which the command was issued. Not * meaningful for other MCDI transports.
@@ -640,7 +629,11 @@* be allocated by different counter blocks, so e.g. AR counter 42 is different * from CT counter 42. Generation counts are also type-specific. This value is * also present in the header of streaming counter packets, in the IDENTIFIER -* field (see packetiser packet format definitions). +* field (see packetiser packet format definitions). Also note that LACP +* counter IDs are not allocated individually, instead the counter IDs are +* directly tied to the LACP balance table indices. These in turn are allocated +* in large contiguous blocks as a LAG config. Calling MAE_COUNTER_ALLOC/FREE +* with an LACP counter type will return EPERM. */ /* enum: Action Rule counters - can be referenced in AR response. */ #define MAE_COUNTER_TYPE_AR 0x0
@@ -648,6 +641,14 @@#define MAE_COUNTER_TYPE_CT 0x1/* enum: Outer Rule counters - can be referenced in OR response. */ #define MAE_COUNTER_TYPE_OR 0x2 +/* enum: LACP counters - linked to LACP balance table entries. */ +#define MAE_COUNTER_TYPE_LACP 0x3 + +/* MAE_COUNTER_ID enum: ID of allocated counter or counter list. */ +/* enum: A counter ID that is guaranteed never to represent a real counter or +* counter list. +*/ +#define MAE_COUNTER_ID_NULL 0xffffffff/* TABLE_ID enum: Unique IDs for tables. The 32-bit ID values have been * structured with bits [31:24] reserved (0), [23:16] indicating which major
@@ -656,7 +657,9 @@* variations of the same table. (All of the tables currently defined within * the streaming engines are listed here, but this does not imply that they are * all supported - MC_CMD_TABLE_LIST returns the list of actually supported -* tables.) +* tables.) The DPU offload engines' enumerators follow a deliberate pattern: +* 0x01010000 + is_dpu_net * 0x10000 + is_wr_or_tx * 0x8000 + is_lite_pipe * +* 0x1000 + oe_engine_type * 0x100 + oe_instance_within_pipe * 0x10 */ /* enum: Outer_Rule_Table in the MAE - refer to SF-123102-TC. */ #define TABLE_ID_OUTER_RULE_TABLE 0x10000
@@ -694,45 +697,70 @@#define TABLE_ID_RSS_CONTEXT_TABLE 0x20200/* enum: Indirection_Table in VNIC Rx - refer to SF-123102-TC. */ #define TABLE_ID_INDIRECTION_TABLE 0x20300 - -/* TABLE_COMPRESSED_VLAN enum: Compressed VLAN TPID as used by some field -* types; can be calculated by (((ether_type_msb >> 2) & 0x4) ^ 0x4) | -* (ether_type_msb & 0x3); -*/ -#define TABLE_COMPRESSED_VLAN_TPID_8100 0x5/* enum */ -#define TABLE_COMPRESSED_VLAN_TPID_88A8 0x4/* enum */ -#define TABLE_COMPRESSED_VLAN_TPID_9100 0x1/* enum */ -#define TABLE_COMPRESSED_VLAN_TPID_9200 0x2/* enum */ -#define TABLE_COMPRESSED_VLAN_TPID_9300 0x3/* enum */ - -/* TABLE_NAT_DIR enum: NAT direction. */ -#define TABLE_NAT_DIR_SOURCE 0x0/* enum */ -#define TABLE_NAT_DIR_DEST 0x1/* enum */ - -/* TABLE_RSS_KEY_MODE enum: Defines how the value for Toeplitz hashing for RSS -* is constructed as a concatenation (indicated here by "++") of packet header -* fields. -*/ -/* enum: IP src addr ++ IP dst addr */ -#define TABLE_RSS_KEY_MODE_SA_DA 0x0 -/* enum: IP src addr ++ IP dst addr ++ TCP/UDP src port ++ TCP/UDP dst port */ -#define TABLE_RSS_KEY_MODE_SA_DA_SP_DP 0x1 -/* enum: IP src addr */ -#define TABLE_RSS_KEY_MODE_SA 0x2 -/* enum: IP dst addr */ -#define TABLE_RSS_KEY_MODE_DA 0x3 -/* enum: IP src addr ++ TCP/UDP src port */ -#define TABLE_RSS_KEY_MODE_SA_SP 0x4 -/* enum: IP dest addr ++ TCP dest port */ -#define TABLE_RSS_KEY_MODE_DA_DP 0x5 -/* enum: Nothing (produces input of 0, resulting in output hash of 0) */ -#define TABLE_RSS_KEY_MODE_NONE 0x7 - -/* TABLE_RSS_SPREAD_MODE enum: RSS spreading mode. */ -/* enum: RSS uses Indirection_Table lookup. */ -#define TABLE_RSS_SPREAD_MODE_INDIRECTION 0x0 -/* enum: RSS uses even spreading calculation. */ -#define TABLE_RSS_SPREAD_MODE_EVEN 0x1 +/* enum: DPU.host read pipe first CRC offload engine profiles - refer to +* XN-200147-AN. +*/ +#define TABLE_ID_DPU_HOST_RD_CRC0_OE_PROFILE 0x1010000 +/* enum: DPU.host read pipe second CRC offload engine profiles - refer to +* XN-200147-AN. +*/ +#define TABLE_ID_DPU_HOST_RD_CRC1_OE_PROFILE 0x1010010 +/* enum: DPU.host write pipe first CRC offload engine profiles - refer to +* XN-200147-AN. +*/ +#define TABLE_ID_DPU_HOST_WR_CRC0_OE_PROFILE 0x1018000 +/* enum: DPU.host write pipe second CRC offload engine profiles - refer to +* XN-200147-AN. +*/ +#define TABLE_ID_DPU_HOST_WR_CRC1_OE_PROFILE 0x1018010 +/* enum: DPU.net 'full' receive pipe CRC offload engine profiles - refer to +* XN-200147-AN. +*/ +#define TABLE_ID_DPU_NET_RX_CRC0_OE_PROFILE 0x1020000 +/* enum: DPU.net 'full' receive pipe first checksum offload engine profiles - +* refer to XN-200147-AN. +*/ +#define TABLE_ID_DPU_NET_RX_CSUM0_OE_PROFILE 0x1020100 +/* enum: DPU.net 'full' receive pipe second checksum offload engine profiles - +* refer to XN-200147-AN. +*/ +#define TABLE_ID_DPU_NET_RX_CSUM1_OE_PROFILE 0x1020110 +/* enum: DPU.net 'full' receive pipe AES-GCM offload engine profiles - refer to +* XN-200147-AN. +*/ +#define TABLE_ID_DPU_NET_RX_AES_GCM0_OE_PROFILE 0x1020200 +/* enum: DPU.net 'lite' receive pipe CRC offload engine profiles - refer to +* XN-200147-AN. +*/ +#define TABLE_ID_DPU_NET_RXLITE_CRC0_OE_PROFILE 0x1021000 +/* enum: DPU.net 'lite' receive pipe checksum offload engine profiles - refer +* to XN-200147-AN. +*/ +#define TABLE_ID_DPU_NET_RXLITE_CSUM0_OE_PROFILE 0x1021100 +/* enum: DPU.net 'full' transmit pipe CRC offload engine profiles - refer to +* XN-200147-AN. +*/ +#define TABLE_ID_DPU_NET_TX_CRC0_OE_PROFILE 0x1028000 +/* enum: DPU.net 'full' transmit pipe first checksum offload engine profiles - +* refer to XN-200147-AN. +*/ +#define TABLE_ID_DPU_NET_TX_CSUM0_OE_PROFILE 0x1028100 +/* enum: DPU.net 'full' transmit pipe second checksum offload engine profiles - +* refer to XN-200147-AN. +*/ +#define TABLE_ID_DPU_NET_TX_CSUM1_OE_PROFILE 0x1028110 +/* enum: DPU.net 'full' transmit pipe AES-GCM offload engine profiles - refer +* to XN-200147-AN. +*/ +#define TABLE_ID_DPU_NET_TX_AES_GCM0_OE_PROFILE 0x1028200 +/* enum: DPU.net 'lite' transmit pipe CRC offload engine profiles - refer to +* XN-200147-AN. +*/ +#define TABLE_ID_DPU_NET_TXLITE_CRC0_OE_PROFILE 0x1029000 +/* enum: DPU.net 'lite' transmit pipe checksum offload engine profiles - refer +* to XN-200147-AN. +*/ +#define TABLE_ID_DPU_NET_TXLITE_CSUM0_OE_PROFILE 0x1029100/* TABLE_FIELD_ID enum: Unique IDs for fields. Related concepts have been * loosely grouped together into blocks with gaps for expansion, but the values
@@ -1026,6 +1054,16 @@#define TABLE_FIELD_ID_BAL_TBL_BASE_DIV64 0xde/* enum: Length of balance table region: 0=>64, 1=>128, 2=>256. */ #define TABLE_FIELD_ID_BAL_TBL_LEN_ID 0xdf +/* enum: LACP LAG ID (i.e. the low 3 bits of LACP LAG mport ID), indexing +* LACP_LAG_Config_Table. Refer to SF-123102-TC. +*/ +#define TABLE_FIELD_ID_LACP_LAG_ID 0xe0 +/* enum: Address in LACP_Balance_Table. The balance table is partitioned +* between LAGs according to the settings in LACP_LAG_Config_Table and then +* indexed by the LACP hash, providing the mapping to destination mports. Refer +* to SF-123102-TC. +*/ +#define TABLE_FIELD_ID_BAL_TBL_ADDR 0xe1/* enum: UDP port to match for UDP-based encapsulations; required to be 0 for * other encapsulation types. */
@@ -1082,6 +1120,55 @@#define TABLE_FIELD_ID_INDIR_TBL_LEN_ID 0x105/* enum: An offset to be applied to the base destination queue ID. */ #define TABLE_FIELD_ID_INDIR_OFFSET 0x106 +/* enum: DPU offload engine profile ID to address. */ +#define TABLE_FIELD_ID_OE_PROFILE 0x3e8 +/* enum: Width of the CRC to calculate - see CRC_VARIANT enum. */ +#define TABLE_FIELD_ID_CRC_VARIANT 0x3f2 +/* enum: If set, reflect the bits of each input byte, bit 7 is LSB, bit 0 is +* MSB. If clear, bit 7 is MSB, bit 0 is LSB. +*/ +#define TABLE_FIELD_ID_CRC_REFIN 0x3f3 +/* enum: If set, reflect the bits of each output byte, bit 7 is LSB, bit 0 is +* MSB. If clear, bit 7 is MSB, bit 0 is LSB. +*/ +#define TABLE_FIELD_ID_CRC_REFOUT 0x3f4 +/* enum: If set, invert every bit of the output value. */ +#define TABLE_FIELD_ID_CRC_INVOUT 0x3f5 +/* enum: The CRC polynomial to use for checksumming, in normal form. */ +#define TABLE_FIELD_ID_CRC_POLY 0x3f6 +/* enum: Operation for the checksum engine to perform - see DPU_CSUM_OP enum. +*/ +#define TABLE_FIELD_ID_CSUM_OP 0x410 +/* enum: Byte offset of checksum relative to region_start (for VALIDATE_* +* operations only). +*/ +#define TABLE_FIELD_ID_CSUM_OFFSET 0x411 +/* enum: Indicates there is additional data on OPR bus that needs to be +* incorporated into the payload checksum. +*/ +#define TABLE_FIELD_ID_CSUM_OPR_ADDITIONAL_DATA 0x412 +/* enum: Log2 data size of additional data on OPR bus. */ +#define TABLE_FIELD_ID_CSUM_OPR_DATA_SIZE_LOG2 0x413 +/* enum: 4 byte offset of where to find the additional data on the OPR bus. */ +#define TABLE_FIELD_ID_CSUM_OPR_4B_OFF 0x414 +/* enum: Operation type for the AES-GCM core - see GCM_OP_CODE enum. */ +#define TABLE_FIELD_ID_GCM_OP_CODE 0x41a +/* enum: Key length - AES_KEY_LEN enum. */ +#define TABLE_FIELD_ID_GCM_KEY_LEN 0x41b +/* enum: OPR 4 byte offset for ICV or GHASH output (only in BULK_* mode) or +* IPSEC descrypt output. +*/ +#define TABLE_FIELD_ID_GCM_OPR_4B_OFFSET 0x41c +/* enum: If OP_CODE is BULK_*, indicates Emit GHASH (Fragment mode). Else, +* indicates IPSEC-ESN mode. +*/ +#define TABLE_FIELD_ID_GCM_EMIT_GHASH_ISESN 0x41d +/* enum: Replay Protection Enable. */ +#define TABLE_FIELD_ID_GCM_REPLAY_PROTECT_EN 0x41e +/* enum: IPSEC Encrypt ESP trailer NEXT_HEADER byte. */ +#define TABLE_FIELD_ID_GCM_NEXT_HDR 0x41f +/* enum: Replay Window Size. */ +#define TABLE_FIELD_ID_GCM_REPLAY_WIN_SIZE 0x420/* MCDI_EVENT structuredef: The structure of an MCDI_EVENT on Siena/EF10/EF100 * platforms
@@ -1138,6 +1225,24 @@#define MCDI_EVENT_LINKCHANGE_LINK_FLAGS_OFST 0#define MCDI_EVENT_LINKCHANGE_LINK_FLAGS_LBN 24#define MCDI_EVENT_LINKCHANGE_LINK_FLAGS_WIDTH 8 +#define MCDI_EVENT_PORT_LINKCHANGE_PORT_HANDLE_OFST 0 +#define MCDI_EVENT_PORT_LINKCHANGE_PORT_HANDLE_LBN 0 +#define MCDI_EVENT_PORT_LINKCHANGE_PORT_HANDLE_WIDTH 24 +#define MCDI_EVENT_PORT_LINKCHANGE_SEQ_NUM_OFST 0 +#define MCDI_EVENT_PORT_LINKCHANGE_SEQ_NUM_LBN 24 +#define MCDI_EVENT_PORT_LINKCHANGE_SEQ_NUM_WIDTH 7 +#define MCDI_EVENT_PORT_LINKCHANGE_LINK_UP_OFST 0 +#define MCDI_EVENT_PORT_LINKCHANGE_LINK_UP_LBN 31 +#define MCDI_EVENT_PORT_LINKCHANGE_LINK_UP_WIDTH 1 +#define MCDI_EVENT_PORT_MODULECHANGE_PORT_HANDLE_OFST 0 +#define MCDI_EVENT_PORT_MODULECHANGE_PORT_HANDLE_LBN 0 +#define MCDI_EVENT_PORT_MODULECHANGE_PORT_HANDLE_WIDTH 24 +#define MCDI_EVENT_PORT_MODULECHANGE_SEQ_NUM_OFST 0 +#define MCDI_EVENT_PORT_MODULECHANGE_SEQ_NUM_LBN 24 +#define MCDI_EVENT_PORT_MODULECHANGE_SEQ_NUM_WIDTH 7 +#define MCDI_EVENT_PORT_MODULECHANGE_MDI_CONNECTED_OFST 0 +#define MCDI_EVENT_PORT_MODULECHANGE_MDI_CONNECTED_LBN 31 +#define MCDI_EVENT_PORT_MODULECHANGE_MDI_CONNECTED_WIDTH 1#define MCDI_EVENT_SENSOREVT_MONITOR_OFST 0#define MCDI_EVENT_SENSOREVT_MONITOR_LBN 0#define MCDI_EVENT_SENSOREVT_MONITOR_WIDTH 8
@@ -1237,7 +1342,7 @@#define MCDI_EVENT_AOE_FPGA_LOAD_FAILED 0xe/* enum: Notify that invalid flash type detected */ #define MCDI_EVENT_AOE_INVALID_FPGA_FLASH_TYPE 0xf -/* enum: Notify that the attempt to run FPGA Controller firmware timedout */ +/* enum: Notify that the attempt to run FPGA Controller firmware timed out */ #define MCDI_EVENT_AOE_FC_RUN_TIMEDOUT 0x10/* enum: Failure to probe one or more FPGA boot flash chips */ #define MCDI_EVENT_AOE_FPGA_BOOT_FLASH_INVALID 0x11
@@ -1255,7 +1360,7 @@#define MCDI_EVENT_AOE_ERR_FC_ASSERT_INFO_WIDTH 8/* enum: FC Assert happened, but the register information is not available */ #define MCDI_EVENT_AOE_ERR_FC_ASSERT_SEEN 0x0 -/* enum: The register information for FC Assert is ready for readinng by driver +/* enum: The register information for FC Assert is ready for reading by driver */ #define MCDI_EVENT_AOE_ERR_FC_ASSERT_DATA_READY 0x1#define MCDI_EVENT_AOE_ERR_CODE_FPGA_HEADER_VERIFY_FAILED_OFST 0
@@ -1364,6 +1469,12 @@#define MCDI_EVENT_MODULECHANGE_SEQ_OFST 0#define MCDI_EVENT_MODULECHANGE_SEQ_LBN 30#define MCDI_EVENT_MODULECHANGE_SEQ_WIDTH 2 +#define MCDI_EVENT_DESC_PROXY_VIRTQ_VI_ID_OFST 0 +#define MCDI_EVENT_DESC_PROXY_VIRTQ_VI_ID_LBN 0 +#define MCDI_EVENT_DESC_PROXY_VIRTQ_VI_ID_WIDTH 16 +#define MCDI_EVENT_DESC_PROXY_VIRTQ_ID_OFST 0 +#define MCDI_EVENT_DESC_PROXY_VIRTQ_ID_LBN 16 +#define MCDI_EVENT_DESC_PROXY_VIRTQ_ID_WIDTH 16#define MCDI_EVENT_DATA_LBN 0#define MCDI_EVENT_DATA_WIDTH 32/* Alias for PTP_DATA. */
@@ -1500,6 +1611,31 @@* change to the journal. */ #define MCDI_EVENT_CODE_MPORT_JOURNAL_CHANGE 0x27 +/* enum: Notification that a source queue is enabled and attached to its proxy +* sink queue. SRC field contains the handle of the affected descriptor proxy +* function. DATA field contains the relative source queue number and absolute +* VI ID. +*/ +#define MCDI_EVENT_CODE_DESC_PROXY_FUNC_QUEUE_START 0x28 +/* enum: Notification of a change in link state and/or link speed of a network +* port link. This event applies to a network port identified by a handle, +* PORT_HANDLE, which is discovered by the driver using the MC_CMD_ENUM_PORTS +* command. +*/ +#define MCDI_EVENT_CODE_PORT_LINKCHANGE 0x29 +/* enum: Notification of a change in the state of an MDI (external connector) +* of a network port. This typically corresponds to module plug/unplug for +* modular interfaces (e.g., SFP/QSFP and similar) or cable connect/disconnect. +* This event applies to a network port identified by a handle, PORT_HANDLE, +* which is discovered by the driver using the MC_CMD_ENUM_PORTS command. +*/ +#define MCDI_EVENT_CODE_PORT_MODULECHANGE 0x2a +/* enum: Notification that the port enumeration journal has changed since it +* was last read and updates can be read using the MC_CMD_ENUM_PORTS command. +* The firmware may moderate the events so that an event is not sent for every +* change to the journal. +*/ +#define MCDI_EVENT_CODE_ENUM_PORTS_CHANGE 0x2b/* enum: Artificial event generated by host and posted via MC for test * purposes. */
@@ -1512,6 +1648,14 @@#define MCDI_EVENT_LINKCHANGE_DATA_LEN 4#define MCDI_EVENT_LINKCHANGE_DATA_LBN 0#define MCDI_EVENT_LINKCHANGE_DATA_WIDTH 32 +#define MCDI_EVENT_PORT_LINKCHANGE_DATA_OFST 0 +#define MCDI_EVENT_PORT_LINKCHANGE_DATA_LEN 4 +#define MCDI_EVENT_PORT_LINKCHANGE_DATA_LBN 0 +#define MCDI_EVENT_PORT_LINKCHANGE_DATA_WIDTH 32 +#define MCDI_EVENT_PORT_MODULECHANGE_DATA_OFST 0 +#define MCDI_EVENT_PORT_MODULECHANGE_DATA_LEN 4 +#define MCDI_EVENT_PORT_MODULECHANGE_DATA_LBN 0 +#define MCDI_EVENT_PORT_MODULECHANGE_DATA_WIDTH 32#define MCDI_EVENT_SENSOREVT_DATA_OFST 0#define MCDI_EVENT_SENSOREVT_DATA_LEN 4#define MCDI_EVENT_SENSOREVT_DATA_LBN 0
@@ -1668,247 +1812,6 @@#define MCDI_EVENT_DESC_PROXY_VIRTIO_FEATURES_LBN 0#define MCDI_EVENT_DESC_PROXY_VIRTIO_FEATURES_WIDTH 32 -/* FCDI_EVENT structuredef */ -#define FCDI_EVENT_LEN 8 -#define FCDI_EVENT_CONT_LBN 32 -#define FCDI_EVENT_CONT_WIDTH 1 -#define FCDI_EVENT_LEVEL_LBN 33 -#define FCDI_EVENT_LEVEL_WIDTH 3 -/* enum: Info. */ -#define FCDI_EVENT_LEVEL_INFO 0x0 -/* enum: Warning. */ -#define FCDI_EVENT_LEVEL_WARN 0x1 -/* enum: Error. */ -#define FCDI_EVENT_LEVEL_ERR 0x2 -/* enum: Fatal. */ -#define FCDI_EVENT_LEVEL_FATAL 0x3 -#define FCDI_EVENT_DATA_OFST 0 -#define FCDI_EVENT_DATA_LEN 4 -#define FCDI_EVENT_LINK_STATE_STATUS_OFST 0 -#define FCDI_EVENT_LINK_STATE_STATUS_LBN 0 -#define FCDI_EVENT_LINK_STATE_STATUS_WIDTH 1 -#define FCDI_EVENT_LINK_DOWN 0x0/* enum */ -#define FCDI_EVENT_LINK_UP 0x1/* enum */ -#define FCDI_EVENT_DATA_LBN 0 -#define FCDI_EVENT_DATA_WIDTH 32 -#define FCDI_EVENT_SRC_LBN 36 -#define FCDI_EVENT_SRC_WIDTH 8 -#define FCDI_EVENT_EV_CODE_LBN 60 -#define FCDI_EVENT_EV_CODE_WIDTH 4 -#define FCDI_EVENT_CODE_LBN 44 -#define FCDI_EVENT_CODE_WIDTH 8 -/* enum: The FC was rebooted. */ -#define FCDI_EVENT_CODE_REBOOT 0x1 -/* enum: Bad assert. */ -#define FCDI_EVENT_CODE_ASSERT 0x2 -/* enum: DDR3 test result. */ -#define FCDI_EVENT_CODE_DDR_TEST_RESULT 0x3 -/* enum: Link status. */ -#define FCDI_EVENT_CODE_LINK_STATE 0x4 -/* enum: A timed read is ready to be serviced. */ -#define FCDI_EVENT_CODE_TIMED_READ 0x5 -/* enum: One or more PPS IN events */ -#define FCDI_EVENT_CODE_PPS_IN 0x6 -/* enum: Tick event from PTP clock */ -#define FCDI_EVENT_CODE_PTP_TICK 0x7 -/* enum: ECC error counters */ -#define FCDI_EVENT_CODE_DDR_ECC_STATUS 0x8 -/* enum: Current status of PTP */ -#define FCDI_EVENT_CODE_PTP_STATUS 0x9 -/* enum: Port id config to map MC-FC port idx */ -#define FCDI_EVENT_CODE_PORT_CONFIG 0xa -/* enum: Boot result or error code */ -#define FCDI_EVENT_CODE_BOOT_RESULT 0xb -#define FCDI_EVENT_REBOOT_SRC_LBN 36 -#define FCDI_EVENT_REBOOT_SRC_WIDTH 8 -#define FCDI_EVENT_REBOOT_FC_FW 0x0/* enum */ -#define FCDI_EVENT_REBOOT_FC_BOOTLOADER 0x1/* enum */ -#define FCDI_EVENT_ASSERT_INSTR_ADDRESS_OFST 0 -#define FCDI_EVENT_ASSERT_INSTR_ADDRESS_LEN 4 -#define FCDI_EVENT_ASSERT_INSTR_ADDRESS_LBN 0 -#define FCDI_EVENT_ASSERT_INSTR_ADDRESS_WIDTH 32 -#define FCDI_EVENT_ASSERT_TYPE_LBN 36 -#define FCDI_EVENT_ASSERT_TYPE_WIDTH 8 -#define FCDI_EVENT_DDR_TEST_RESULT_STATUS_CODE_LBN 36 -#define FCDI_EVENT_DDR_TEST_RESULT_STATUS_CODE_WIDTH 8 -#define FCDI_EVENT_DDR_TEST_RESULT_RESULT_OFST 0 -#define FCDI_EVENT_DDR_TEST_RESULT_RESULT_LEN 4 -#define FCDI_EVENT_DDR_TEST_RESULT_RESULT_LBN 0 -#define FCDI_EVENT_DDR_TEST_RESULT_RESULT_WIDTH 32 -#define FCDI_EVENT_LINK_STATE_DATA_OFST 0 -#define FCDI_EVENT_LINK_STATE_DATA_LEN 4 -#define FCDI_EVENT_LINK_STATE_DATA_LBN 0 -#define FCDI_EVENT_LINK_STATE_DATA_WIDTH 32 -#define FCDI_EVENT_PTP_STATE_OFST 0 -#define FCDI_EVENT_PTP_STATE_LEN 4 -#define FCDI_EVENT_PTP_UNDEFINED 0x0/* enum */ -#define FCDI_EVENT_PTP_SETUP_FAILED 0x1/* enum */ -#define FCDI_EVENT_PTP_OPERATIONAL 0x2/* enum */ -#define FCDI_EVENT_PTP_STATE_LBN 0 -#define FCDI_EVENT_PTP_STATE_WIDTH 32 -#define FCDI_EVENT_DDR_ECC_STATUS_BANK_ID_LBN 36 -#define FCDI_EVENT_DDR_ECC_STATUS_BANK_ID_WIDTH 8 -#define FCDI_EVENT_DDR_ECC_STATUS_STATUS_OFST 0 -#define FCDI_EVENT_DDR_ECC_STATUS_STATUS_LEN 4 -#define FCDI_EVENT_DDR_ECC_STATUS_STATUS_LBN 0 -#define FCDI_EVENT_DDR_ECC_STATUS_STATUS_WIDTH 32 -/* Index of MC port being referred to */ -#define FCDI_EVENT_PORT_CONFIG_SRC_LBN 36 -#define FCDI_EVENT_PORT_CONFIG_SRC_WIDTH 8 -/* FC Port index that matches the MC port index in SRC */ -#define FCDI_EVENT_PORT_CONFIG_DATA_OFST 0 -#define FCDI_EVENT_PORT_CONFIG_DATA_LEN 4 -#define FCDI_EVENT_PORT_CONFIG_DATA_LBN 0 -#define FCDI_EVENT_PORT_CONFIG_DATA_WIDTH 32 -#define FCDI_EVENT_BOOT_RESULT_OFST 0 -#define FCDI_EVENT_BOOT_RESULT_LEN 4 -/* Enum values, see field(s): */ -/* MC_CMD_AOE/MC_CMD_AOE_OUT_INFO/FC_BOOT_RESULT */ -#define FCDI_EVENT_BOOT_RESULT_LBN 0 -#define FCDI_EVENT_BOOT_RESULT_WIDTH 32 - -/* FCDI_EXTENDED_EVENT_PPS structuredef: Extended FCDI event to send PPS events -* to the MC. Note that this structure | is overlayed over a normal FCDI event -* such that bits 32-63 containing | event code, level, source etc remain the -* same. In this case the data | field of the header is defined to be the -* number of timestamps -*/ -#define FCDI_EXTENDED_EVENT_PPS_LENMIN 16 -#define FCDI_EXTENDED_EVENT_PPS_LENMAX 248 -#define FCDI_EXTENDED_EVENT_PPS_LENMAX_MCDI2 1016 -#define FCDI_EXTENDED_EVENT_PPS_LEN (num) (8+8*(num)) -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_NUM (len) (((len)-8)/8) -/* Number of timestamps following */ -#define FCDI_EXTENDED_EVENT_PPS_COUNT_OFST 0 -#define FCDI_EXTENDED_EVENT_PPS_COUNT_LEN 4 -#define FCDI_EXTENDED_EVENT_PPS_COUNT_LBN 0 -#define FCDI_EXTENDED_EVENT_PPS_COUNT_WIDTH 32 -/* Seconds field of a timestamp record */ -#define FCDI_EXTENDED_EVENT_PPS_SECONDS_OFST 8 -#define FCDI_EXTENDED_EVENT_PPS_SECONDS_LEN 4 -#define FCDI_EXTENDED_EVENT_PPS_SECONDS_LBN 64 -#define FCDI_EXTENDED_EVENT_PPS_SECONDS_WIDTH 32 -/* Nanoseconds field of a timestamp record */ -#define FCDI_EXTENDED_EVENT_PPS_NANOSECONDS_OFST 12 -#define FCDI_EXTENDED_EVENT_PPS_NANOSECONDS_LEN 4 -#define FCDI_EXTENDED_EVENT_PPS_NANOSECONDS_LBN 96 -#define FCDI_EXTENDED_EVENT_PPS_NANOSECONDS_WIDTH 32 -/* Timestamp records comprising the event */ -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_OFST 8 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_LEN 8 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_LO_OFST 8 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_LO_LEN 4 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_LO_LBN 64 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_LO_WIDTH 32 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_HI_OFST 12 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_HI_LEN 4 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_HI_LBN 96 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_HI_WIDTH 32 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_MINNUM 1 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_MAXNUM 30 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_MAXNUM_MCDI2 126 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_LBN 64 -#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_WIDTH 64 - -/* MUM_EVENT structuredef */ -#define MUM_EVENT_LEN 8 -#define MUM_EVENT_CONT_LBN 32 -#define MUM_EVENT_CONT_WIDTH 1 -#define MUM_EVENT_LEVEL_LBN 33 -#define MUM_EVENT_LEVEL_WIDTH 3 -/* enum: Info. */ -#define MUM_EVENT_LEVEL_INFO 0x0 -/* enum: Warning. */ -#define MUM_EVENT_LEVEL_WARN 0x1 -/* enum: Error. */ -#define MUM_EVENT_LEVEL_ERR 0x2 -/* enum: Fatal. */ -#define MUM_EVENT_LEVEL_FATAL 0x3 -#define MUM_EVENT_DATA_OFST 0 -#define MUM_EVENT_DATA_LEN 4 -#define MUM_EVENT_SENSOR_ID_OFST 0 -#define MUM_EVENT_SENSOR_ID_LBN 0 -#define MUM_EVENT_SENSOR_ID_WIDTH 8 -/* Enum values, see field(s): */ -/* MC_CMD_SENSOR_INFO/MC_CMD_SENSOR_INFO_OUT/MASK */ -#define MUM_EVENT_SENSOR_STATE_OFST 0 -#define MUM_EVENT_SENSOR_STATE_LBN 8 -#define MUM_EVENT_SENSOR_STATE_WIDTH 8 -#define MUM_EVENT_PORT_PHY_READY_OFST 0 -#define MUM_EVENT_PORT_PHY_READY_LBN 0 -#define MUM_EVENT_PORT_PHY_READY_WIDTH 1 -#define MUM_EVENT_PORT_PHY_LINK_UP_OFST 0 -#define MUM_EVENT_PORT_PHY_LINK_UP_LBN 1 -#define MUM_EVENT_PORT_PHY_LINK_UP_WIDTH 1 -#define MUM_EVENT_PORT_PHY_TX_LOL_OFST 0 -#define MUM_EVENT_PORT_PHY_TX_LOL_LBN 2 -#define MUM_EVENT_PORT_PHY_TX_LOL_WIDTH 1 -#define MUM_EVENT_PORT_PHY_RX_LOL_OFST 0 -#define MUM_EVENT_PORT_PHY_RX_LOL_LBN 3 -#define MUM_EVENT_PORT_PHY_RX_LOL_WIDTH 1 -#define MUM_EVENT_PORT_PHY_TX_LOS_OFST 0 -#define MUM_EVENT_PORT_PHY_TX_LOS_LBN 4 -#define MUM_EVENT_PORT_PHY_TX_LOS_WIDTH 1 -#define MUM_EVENT_PORT_PHY_RX_LOS_OFST 0 -#define MUM_EVENT_PORT_PHY_RX_LOS_LBN 5 -#define MUM_EVENT_PORT_PHY_RX_LOS_WIDTH 1 -#define MUM_EVENT_PORT_PHY_TX_FAULT_OFST 0 -#define MUM_EVENT_PORT_PHY_TX_FAULT_LBN 6 -#define MUM_EVENT_PORT_PHY_TX_FAULT_WIDTH 1 -#define MUM_EVENT_DATA_LBN 0 -#define MUM_EVENT_DATA_WIDTH 32 -#define MUM_EVENT_SRC_LBN 36 -#define MUM_EVENT_SRC_WIDTH 8 -#define MUM_EVENT_EV_CODE_LBN 60 -#define MUM_EVENT_EV_CODE_WIDTH 4 -#define MUM_EVENT_CODE_LBN 44 -#define MUM_EVENT_CODE_WIDTH 8 -/* enum: The MUM was rebooted. */ -#define MUM_EVENT_CODE_REBOOT 0x1 -/* enum: Bad assert. */ -#define MUM_EVENT_CODE_ASSERT 0x2 -/* enum: Sensor failure. */ -#define MUM_EVENT_CODE_SENSOR 0x3 -/* enum: Link fault has been asserted, or has cleared. */ -#define MUM_EVENT_CODE_QSFP_LASI_INTERRUPT 0x4 -#define MUM_EVENT_SENSOR_DATA_OFST 0 -#define MUM_EVENT_SENSOR_DATA_LEN 4 -#define MUM_EVENT_SENSOR_DATA_LBN 0 -#define MUM_EVENT_SENSOR_DATA_WIDTH 32 -#define MUM_EVENT_PORT_PHY_FLAGS_OFST 0 -#define MUM_EVENT_PORT_PHY_FLAGS_LEN 4 -#define MUM_EVENT_PORT_PHY_FLAGS_LBN 0 -#define MUM_EVENT_PORT_PHY_FLAGS_WIDTH 32 -#define MUM_EVENT_PORT_PHY_COPPER_LEN_OFST 0 -#define MUM_EVENT_PORT_PHY_COPPER_LEN_LEN 4 -#define MUM_EVENT_PORT_PHY_COPPER_LEN_LBN 0 -#define MUM_EVENT_PORT_PHY_COPPER_LEN_WIDTH 32 -#define MUM_EVENT_PORT_PHY_CAPS_OFST 0 -#define MUM_EVENT_PORT_PHY_CAPS_LEN 4 -#define MUM_EVENT_PORT_PHY_CAPS_LBN 0 -#define MUM_EVENT_PORT_PHY_CAPS_WIDTH 32 -#define MUM_EVENT_PORT_PHY_TECH_OFST 0 -#define MUM_EVENT_PORT_PHY_TECH_LEN 4 -#define MUM_EVENT_PORT_PHY_STATE_QSFP_MODULE_TECH_UNKNOWN 0x0/* enum */ -#define MUM_EVENT_PORT_PHY_STATE_QSFP_MODULE_TECH_OPTICAL 0x1/* enum */ -#define MUM_EVENT_PORT_PHY_STATE_QSFP_MODULE_TECH_COPPER_PASSIVE 0x2/* enum */ -#define MUM_EVENT_PORT_PHY_STATE_QSFP_MODULE_TECH_COPPER_PASSIVE_EQUALIZED 0x3/* enum */ -#define MUM_EVENT_PORT_PHY_STATE_QSFP_MODULE_TECH_COPPER_ACTIVE_LIMITING 0x4/* enum */ -#define MUM_EVENT_PORT_PHY_STATE_QSFP_MODULE_TECH_COPPER_ACTIVE_LINEAR 0x5/* enum */ -#define MUM_EVENT_PORT_PHY_STATE_QSFP_MODULE_TECH_BASE_T 0x6/* enum */ -#define MUM_EVENT_PORT_PHY_STATE_QSFP_MODULE_TECH_LOOPBACK_PASSIVE 0x7/* enum */ -#define MUM_EVENT_PORT_PHY_TECH_LBN 0 -#define MUM_EVENT_PORT_PHY_TECH_WIDTH 32 -#define MUM_EVENT_PORT_PHY_SRC_DATA_ID_LBN 36 -#define MUM_EVENT_PORT_PHY_SRC_DATA_ID_WIDTH 4 -#define MUM_EVENT_PORT_PHY_SRC_DATA_ID_FLAGS 0x0/* enum */ -#define MUM_EVENT_PORT_PHY_SRC_DATA_ID_COPPER_LEN 0x1/* enum */ -#define MUM_EVENT_PORT_PHY_SRC_DATA_ID_CAPS 0x2/* enum */ -#define MUM_EVENT_PORT_PHY_SRC_DATA_ID_TECH 0x3/* enum */ -#define MUM_EVENT_PORT_PHY_SRC_DATA_ID_MAX 0x4/* enum */ -#define MUM_EVENT_PORT_PHY_SRC_PORT_NO_LBN 40 -#define MUM_EVENT_PORT_PHY_SRC_PORT_NO_WIDTH 4 -/***********************************/ /* MC_CMD_READ32
@@ -1968,90 +1871,6 @@#define MC_CMD_WRITE32_OUT_LEN 0 -/***********************************/ -/* MC_CMD_COPYCODE -* Copy MC code between two locations and jump. Note - this command really -* belongs to INSECURE category but is required by shmboot. The command handler -* has additional checks to reject insecure calls. -*/ -#define MC_CMD_COPYCODE 0x3 -#undef MC_CMD_0x3_PRIVILEGE_CTG - -#define MC_CMD_0x3_PRIVILEGE_CTG SRIOV_CTG_ADMIN - -/* MC_CMD_COPYCODE_IN msgrequest */ -#define MC_CMD_COPYCODE_IN_LEN 16 -/* Source address -* -* The main image should be entered via a copy of a single word from and to a -* magic address, which controls various aspects of the boot. The magic address -* is a bitfield, with each bit as documented below. -*/ -#define MC_CMD_COPYCODE_IN_SRC_ADDR_OFST 0 -#define MC_CMD_COPYCODE_IN_SRC_ADDR_LEN 4 -/* enum: Deprecated; equivalent to setting BOOT_MAGIC_PRESENT (see below) */ -#define MC_CMD_COPYCODE_HUNT_NO_MAGIC_ADDR 0x10000 -/* enum: Deprecated; equivalent to setting BOOT_MAGIC_PRESENT and -* BOOT_MAGIC_SATELLITE_CPUS_NOT_LOADED (see below) -*/ -#define MC_CMD_COPYCODE_HUNT_NO_DATAPATH_MAGIC_ADDR 0x1d0d0 -/* enum: Deprecated; equivalent to setting BOOT_MAGIC_PRESENT, -* BOOT_MAGIC_SATELLITE_CPUS_NOT_LOADED and BOOT_MAGIC_IGNORE_CONFIG (see -* below) -*/ -#define MC_CMD_COPYCODE_HUNT_IGNORE_CONFIG_MAGIC_ADDR 0x1badc -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_PRESENT_OFST 0 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_PRESENT_LBN 17 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_PRESENT_WIDTH 1 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_SATELLITE_CPUS_NOT_LOADED_OFST 0 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_SATELLITE_CPUS_NOT_LOADED_LBN 2 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_SATELLITE_CPUS_NOT_LOADED_WIDTH 1 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_IGNORE_CONFIG_OFST 0 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_IGNORE_CONFIG_LBN 3 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_IGNORE_CONFIG_WIDTH 1 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_SKIP_BOOT_ICORE_SYNC_OFST 0 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_SKIP_BOOT_ICORE_SYNC_LBN 4 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_SKIP_BOOT_ICORE_SYNC_WIDTH 1 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_FORCE_STANDALONE_OFST 0 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_FORCE_STANDALONE_LBN 5 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_FORCE_STANDALONE_WIDTH 1 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_DISABLE_XIP_OFST 0 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_DISABLE_XIP_LBN 6 -#define MC_CMD_COPYCODE_IN_BOOT_MAGIC_DISABLE_XIP_WIDTH 1 -/* Destination address */ -#define MC_CMD_COPYCODE_IN_DEST_ADDR_OFST 4 -#define MC_CMD_COPYCODE_IN_DEST_ADDR_LEN 4 -#define MC_CMD_COPYCODE_IN_NUMWORDS_OFST 8 -#define MC_CMD_COPYCODE_IN_NUMWORDS_LEN 4 -/* Address of where to jump after copy. */ -#define MC_CMD_COPYCODE_IN_JUMP_OFST 12 -#define MC_CMD_COPYCODE_IN_JUMP_LEN 4 -/* enum: Control should return to the caller rather than jumping */ -#define MC_CMD_COPYCODE_JUMP_NONE 0x1 - -/* MC_CMD_COPYCODE_OUT msgresponse */ -#define MC_CMD_COPYCODE_OUT_LEN 0 - - -/***********************************/ -/* MC_CMD_SET_FUNC -* Select function for function-specific commands. -*/ -#define MC_CMD_SET_FUNC 0x4 -#undef MC_CMD_0x4_PRIVILEGE_CTG - -#define MC_CMD_0x4_PRIVILEGE_CTG SRIOV_CTG_INSECURE - -/* MC_CMD_SET_FUNC_IN msgrequest */ -#define MC_CMD_SET_FUNC_IN_LEN 4 -/* Set function */ -#define MC_CMD_SET_FUNC_IN_FUNC_OFST 0 -#define MC_CMD_SET_FUNC_IN_FUNC_LEN 4 - -/* MC_CMD_SET_FUNC_OUT msgresponse */ -#define MC_CMD_SET_FUNC_OUT_LEN 0 - -/***********************************/ /* MC_CMD_GET_BOOT_STATUS * Get the instruction address from which the MC booted.
@@ -2259,6 +2078,7 @@/* Log destination */ #define MC_CMD_LOG_CTRL_IN_LOG_DEST_OFST 0#define MC_CMD_LOG_CTRL_IN_LOG_DEST_LEN 4 +/* enum property: bitmask */ /* enum: UART. */ #define MC_CMD_LOG_CTRL_IN_LOG_DEST_UART 0x1/* enum: Event queue. */
@@ -2304,6 +2124,9 @@/* MC_CMD_GET_VERSION_OUT msgresponse */ #define MC_CMD_GET_VERSION_OUT_LEN 32 +/* This is normally the UTC build time in seconds since epoch or one of the +* special values listed +*/ /* MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0 */ /* MC_CMD_GET_VERSION_OUT_FIRMWARE_LEN 4 */ /* Enum values, see field(s): */
@@ -2326,6 +2149,9 @@/* MC_CMD_GET_VERSION_EXT_OUT msgresponse */ #define MC_CMD_GET_VERSION_EXT_OUT_LEN 48 +/* This is normally the UTC build time in seconds since epoch or one of the +* special values listed +*/ /* MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0 */ /* MC_CMD_GET_VERSION_OUT_FIRMWARE_LEN 4 */ /* Enum values, see field(s): */
@@ -2356,6 +2182,9 @@* (depending on which components exist on a particular adapter) */ #define MC_CMD_GET_VERSION_V2_OUT_LEN 304 +/* This is normally the UTC build time in seconds since epoch or one of the +* special values listed +*/ /* MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0 */ /* MC_CMD_GET_VERSION_OUT_FIRMWARE_LEN 4 */ /* Enum values, see field(s): */
@@ -2495,6 +2324,9 @@* (depending on which components exist on a particular adapter) */ #define MC_CMD_GET_VERSION_V3_OUT_LEN 328 +/* This is normally the UTC build time in seconds since epoch or one of the +* special values listed +*/ /* MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0 */ /* MC_CMD_GET_VERSION_OUT_FIRMWARE_LEN 4 */ /* Enum values, see field(s): */
@@ -2641,6 +2473,9 @@* version information */ #define MC_CMD_GET_VERSION_V4_OUT_LEN 392 +/* This is normally the UTC build time in seconds since epoch or one of the +* special values listed +*/ /* MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0 */ /* MC_CMD_GET_VERSION_OUT_FIRMWARE_LEN 4 */ /* Enum values, see field(s): */
@@ -2803,6 +2638,9 @@* and board version information */ #define MC_CMD_GET_VERSION_V5_OUT_LEN 424 +/* This is normally the UTC build time in seconds since epoch or one of the +* special values listed +*/ /* MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0 */ /* MC_CMD_GET_VERSION_OUT_FIRMWARE_LEN 4 */ /* Enum values, see field(s): */
@@ -3065,8 +2903,11 @@* subscribers. */ #define MC_CMD_PTP_OP_SET_SYNC_STATUS 0x1b -/* enum: Above this for future use. */ -#define MC_CMD_PTP_OP_MAX 0x1c +/* enum: X4 and later adapters should use this instead of +* PTP_OP_TIME_EVENT_SUBSCRIBE. Subscribe to receive periodic time events +* indicating the current NIC time +*/ +#define MC_CMD_PTP_OP_TIME_EVENT_SUBSCRIBE_V2 0x1c/* MC_CMD_PTP_IN_ENABLE msgrequest */ #define MC_CMD_PTP_IN_ENABLE_LEN 16
@@ -3507,6 +3348,22 @@#define MC_CMD_PTP_IN_TIME_EVENT_UNSUBSCRIBE_QUEUE_OFST 12#define MC_CMD_PTP_IN_TIME_EVENT_UNSUBSCRIBE_QUEUE_LEN 4 +/* MC_CMD_PTP_IN_TIME_EVENT_SUBSCRIBE_V2 msgrequest */ +#define MC_CMD_PTP_IN_TIME_EVENT_SUBSCRIBE_V2_LEN 16 +/* MC_CMD_PTP_IN_CMD_OFST 0 */ +/* MC_CMD_PTP_IN_CMD_LEN 4 */ +/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */ +/* MC_CMD_PTP_IN_PERIPH_ID_LEN 4 */ +/* Event queue ID */ +#define MC_CMD_PTP_IN_TIME_EVENT_SUBSCRIBE_V2_QUEUE_ID_OFST 8 +#define MC_CMD_PTP_IN_TIME_EVENT_SUBSCRIBE_V2_QUEUE_ID_LEN 4 +/* Space for flags. */ +#define MC_CMD_PTP_IN_TIME_EVENT_SUBSCRIBE_V2_FLAGS_OFST 12 +#define MC_CMD_PTP_IN_TIME_EVENT_SUBSCRIBE_V2_FLAGS_LEN 4 +#define MC_CMD_PTP_IN_TIME_EVENT_SUBSCRIBE_V2_REPORT_SYNC_STATUS_OFST 12 +#define MC_CMD_PTP_IN_TIME_EVENT_SUBSCRIBE_V2_REPORT_SYNC_STATUS_LBN 31 +#define MC_CMD_PTP_IN_TIME_EVENT_SUBSCRIBE_V2_REPORT_SYNC_STATUS_WIDTH 1 +/* MC_CMD_PTP_IN_MANFTEST_PPS msgrequest */ #define MC_CMD_PTP_IN_MANFTEST_PPS_LEN 12/* MC_CMD_PTP_IN_CMD_OFST 0 */
@@ -3940,151 +3797,6 @@#define MC_CMD_PTP_OUT_SET_SYNC_STATUS_LEN 0 -/***********************************/ -/* MC_CMD_CSR_READ32 -* Read 32bit words from the indirect memory map. -*/ -#define MC_CMD_CSR_READ32 0xc -#undef MC_CMD_0xc_PRIVILEGE_CTG - -#define MC_CMD_0xc_PRIVILEGE_CTG SRIOV_CTG_INSECURE - -/* MC_CMD_CSR_READ32_IN msgrequest */ -#define MC_CMD_CSR_READ32_IN_LEN 12 -/* Address */ -#define MC_CMD_CSR_READ32_IN_ADDR_OFST 0 -#define MC_CMD_CSR_READ32_IN_ADDR_LEN 4 -#define MC_CMD_CSR_READ32_IN_STEP_OFST 4 -#define MC_CMD_CSR_READ32_IN_STEP_LEN 4 -#define MC_CMD_CSR_READ32_IN_NUMWORDS_OFST 8 -#define MC_CMD_CSR_READ32_IN_NUMWORDS_LEN 4 - -/* MC_CMD_CSR_READ32_OUT msgresponse */ -#define MC_CMD_CSR_READ32_OUT_LENMIN 4 -#define MC_CMD_CSR_READ32_OUT_LENMAX 252 -#define MC_CMD_CSR_READ32_OUT_LENMAX_MCDI2 1020 -#define MC_CMD_CSR_READ32_OUT_LEN (num) (0+4*(num)) -#define MC_CMD_CSR_READ32_OUT_BUFFER_NUM (len) (((len)-0)/4) -/* The last dword is the status, not a value read */ -#define MC_CMD_CSR_READ32_OUT_BUFFER_OFST 0 -#define MC_CMD_CSR_READ32_OUT_BUFFER_LEN 4 -#define MC_CMD_CSR_READ32_OUT_BUFFER_MINNUM 1 -#define MC_CMD_CSR_READ32_OUT_BUFFER_MAXNUM 63 -#define MC_CMD_CSR_READ32_OUT_BUFFER_MAXNUM_MCDI2 255 - - -/***********************************/ -/* MC_CMD_CSR_WRITE32 -* Write 32bit dwords to the indirect memory map. -*/ -#define MC_CMD_CSR_WRITE32 0xd -#undef MC_CMD_0xd_PRIVILEGE_CTG - -#define MC_CMD_0xd_PRIVILEGE_CTG SRIOV_CTG_INSECURE - -/* MC_CMD_CSR_WRITE32_IN msgrequest */ -#define MC_CMD_CSR_WRITE32_IN_LENMIN 12 -#define MC_CMD_CSR_WRITE32_IN_LENMAX 252 -#define MC_CMD_CSR_WRITE32_IN_LENMAX_MCDI2 1020 -#define MC_CMD_CSR_WRITE32_IN_LEN (num) (8+4*(num)) -#define MC_CMD_CSR_WRITE32_IN_BUFFER_NUM (len) (((len)-8)/4) -/* Address */ -#define MC_CMD_CSR_WRITE32_IN_ADDR_OFST 0 -#define MC_CMD_CSR_WRITE32_IN_ADDR_LEN 4 -#define MC_CMD_CSR_WRITE32_IN_STEP_OFST 4 -#define MC_CMD_CSR_WRITE32_IN_STEP_LEN 4 -#define MC_CMD_CSR_WRITE32_IN_BUFFER_OFST 8 -#define MC_CMD_CSR_WRITE32_IN_BUFFER_LEN 4 -#define MC_CMD_CSR_WRITE32_IN_BUFFER_MINNUM 1 -#define MC_CMD_CSR_WRITE32_IN_BUFFER_MAXNUM 61 -#define MC_CMD_CSR_WRITE32_IN_BUFFER_MAXNUM_MCDI2 253 - -/* MC_CMD_CSR_WRITE32_OUT msgresponse */ -#define MC_CMD_CSR_WRITE32_OUT_LEN 4 -#define MC_CMD_CSR_WRITE32_OUT_STATUS_OFST 0 -#define MC_CMD_CSR_WRITE32_OUT_STATUS_LEN 4 - - -/***********************************/ -/* MC_CMD_HP -* These commands are used for HP related features. They are grouped under one -* MCDI command to avoid creating too many MCDI commands. -*/ -#define MC_CMD_HP 0x54 -#undef MC_CMD_0x54_PRIVILEGE_CTG - -#define MC_CMD_0x54_PRIVILEGE_CTG SRIOV_CTG_ADMIN - -/* MC_CMD_HP_IN msgrequest */ -#define MC_CMD_HP_IN_LEN 16 -/* HP OCSD sub-command. When address is not NULL, request activation of OCSD at -* the specified address with the specified interval.When address is NULL, -* INTERVAL is interpreted as a command: 0: stop OCSD / 1: Report OCSD current -* state / 2: (debug) Show temperature reported by one of the supported -* sensors. -*/ -#define MC_CMD_HP_IN_SUBCMD_OFST 0 -#define MC_CMD_HP_IN_SUBCMD_LEN 4 -/* enum: OCSD (Option Card Sensor Data) sub-command. */ -#define MC_CMD_HP_IN_OCSD_SUBCMD 0x0 -/* enum: Last known valid HP sub-command. */ -#define MC_CMD_HP_IN_LAST_SUBCMD 0x0 -/* The address to the array of sensor fields. (Or NULL to use a sub-command.) -*/ -#define MC_CMD_HP_IN_OCSD_ADDR_OFST 4 -#define MC_CMD_HP_IN_OCSD_ADDR_LEN 8 -#define MC_CMD_HP_IN_OCSD_ADDR_LO_OFST 4 -#define MC_CMD_HP_IN_OCSD_ADDR_LO_LEN 4 -#define MC_CMD_HP_IN_OCSD_ADDR_LO_LBN 32 -#define MC_CMD_HP_IN_OCSD_ADDR_LO_WIDTH 32 -#define MC_CMD_HP_IN_OCSD_ADDR_HI_OFST 8 -#define MC_CMD_HP_IN_OCSD_ADDR_HI_LEN 4 -#define MC_CMD_HP_IN_OCSD_ADDR_HI_LBN 64 -#define MC_CMD_HP_IN_OCSD_ADDR_HI_WIDTH 32 -/* The requested update interval, in seconds. (Or the sub-command if ADDR is -* NULL.) -*/ -#define MC_CMD_HP_IN_OCSD_INTERVAL_OFST 12 -#define MC_CMD_HP_IN_OCSD_INTERVAL_LEN 4 - -/* MC_CMD_HP_OUT msgresponse */ -#define MC_CMD_HP_OUT_LEN 4 -#define MC_CMD_HP_OUT_OCSD_STATUS_OFST 0 -#define MC_CMD_HP_OUT_OCSD_STATUS_LEN 4 -/* enum: OCSD stopped for this card. */ -#define MC_CMD_HP_OUT_OCSD_STOPPED 0x1 -/* enum: OCSD was successfully started with the address provided. */ -#define MC_CMD_HP_OUT_OCSD_STARTED 0x2 -/* enum: OCSD was already started for this card. */ -#define MC_CMD_HP_OUT_OCSD_ALREADY_STARTED 0x3 - - -/***********************************/ -/* MC_CMD_STACKINFO -* Get stack information. -*/ -#define MC_CMD_STACKINFO 0xf -#undef MC_CMD_0xf_PRIVILEGE_CTG - -#define MC_CMD_0xf_PRIVILEGE_CTG SRIOV_CTG_ADMIN - -/* MC_CMD_STACKINFO_IN msgrequest */ -#define MC_CMD_STACKINFO_IN_LEN 0 - -/* MC_CMD_STACKINFO_OUT msgresponse */ -#define MC_CMD_STACKINFO_OUT_LENMIN 12 -#define MC_CMD_STACKINFO_OUT_LENMAX 252 -#define MC_CMD_STACKINFO_OUT_LENMAX_MCDI2 1020 -#define MC_CMD_STACKINFO_OUT_LEN (num) (0+12*(num)) -#define MC_CMD_STACKINFO_OUT_THREAD_INFO_NUM (len) (((len)-0)/12) -/* (thread ptr, stack size, free space) for each thread in system */ -#define MC_CMD_STACKINFO_OUT_THREAD_INFO_OFST 0 -#define MC_CMD_STACKINFO_OUT_THREAD_INFO_LEN 12 -#define MC_CMD_STACKINFO_OUT_THREAD_INFO_MINNUM 1 -#define MC_CMD_STACKINFO_OUT_THREAD_INFO_MAXNUM 21 -#define MC_CMD_STACKINFO_OUT_THREAD_INFO_MAXNUM_MCDI2 85 - -/***********************************/ /* MC_CMD_MDIO_READ * MDIO register read.
@@ -4181,176 +3893,6 @@/* MC_CMD_MDIO_STATUS_GOOD 0x8 */ -/***********************************/ -/* MC_CMD_DBI_WRITE -* Write DBI register(s). -*/ -#define MC_CMD_DBI_WRITE 0x12 -#undef MC_CMD_0x12_PRIVILEGE_CTG - -#define MC_CMD_0x12_PRIVILEGE_CTG SRIOV_CTG_INSECURE - -/* MC_CMD_DBI_WRITE_IN msgrequest */ -#define MC_CMD_DBI_WRITE_IN_LENMIN 12 -#define MC_CMD_DBI_WRITE_IN_LENMAX 252 -#define MC_CMD_DBI_WRITE_IN_LENMAX_MCDI2 1020 -#define MC_CMD_DBI_WRITE_IN_LEN (num) (0+12*(num)) -#define MC_CMD_DBI_WRITE_IN_DBIWROP_NUM (len) (((len)-0)/12) -/* Each write op consists of an address (offset 0), byte enable/VF/CS2 (offset -* 32) and value (offset 64). See MC_CMD_DBIWROP_TYPEDEF. -*/ -#define MC_CMD_DBI_WRITE_IN_DBIWROP_OFST 0 -#define MC_CMD_DBI_WRITE_IN_DBIWROP_LEN 12 -#define MC_CMD_DBI_WRITE_IN_DBIWROP_MINNUM 1 -#define MC_CMD_DBI_WRITE_IN_DBIWROP_MAXNUM 21 -#define MC_CMD_DBI_WRITE_IN_DBIWROP_MAXNUM_MCDI2 85 - -/* MC_CMD_DBI_WRITE_OUT msgresponse */ -#define MC_CMD_DBI_WRITE_OUT_LEN 0 - -/* MC_CMD_DBIWROP_TYPEDEF structuredef */ -#define MC_CMD_DBIWROP_TYPEDEF_LEN 12 -#define MC_CMD_DBIWROP_TYPEDEF_ADDRESS_OFST 0 -#define MC_CMD_DBIWROP_TYPEDEF_ADDRESS_LEN 4 -#define MC_CMD_DBIWROP_TYPEDEF_ADDRESS_LBN 0 -#define MC_CMD_DBIWROP_TYPEDEF_ADDRESS_WIDTH 32 -#define MC_CMD_DBIWROP_TYPEDEF_PARMS_OFST 4 -#define MC_CMD_DBIWROP_TYPEDEF_PARMS_LEN 4 -#define MC_CMD_DBIWROP_TYPEDEF_VF_NUM_OFST 4 -#define MC_CMD_DBIWROP_TYPEDEF_VF_NUM_LBN 16 -#define MC_CMD_DBIWROP_TYPEDEF_VF_NUM_WIDTH 16 -#define MC_CMD_DBIWROP_TYPEDEF_VF_ACTIVE_OFST 4 -#define MC_CMD_DBIWROP_TYPEDEF_VF_ACTIVE_LBN 15 -#define MC_CMD_DBIWROP_TYPEDEF_VF_ACTIVE_WIDTH 1 -#define MC_CMD_DBIWROP_TYPEDEF_CS2_OFST 4 -#define MC_CMD_DBIWROP_TYPEDEF_CS2_LBN 14 -#define MC_CMD_DBIWROP_TYPEDEF_CS2_WIDTH 1 -#define MC_CMD_DBIWROP_TYPEDEF_PARMS_LBN 32 -#define MC_CMD_DBIWROP_TYPEDEF_PARMS_WIDTH 32 -#define MC_CMD_DBIWROP_TYPEDEF_VALUE_OFST 8 -#define MC_CMD_DBIWROP_TYPEDEF_VALUE_LEN 4 -#define MC_CMD_DBIWROP_TYPEDEF_VALUE_LBN 64 -#define MC_CMD_DBIWROP_TYPEDEF_VALUE_WIDTH 32 - - -/***********************************/ -/* MC_CMD_PORT_READ32 -* Read a 32-bit register from the indirect port register map. The port to -* access is implied by the Shared memory channel used. -*/ -#define MC_CMD_PORT_READ32 0x14 - -/* MC_CMD_PORT_READ32_IN msgrequest */ -#define MC_CMD_PORT_READ32_IN_LEN 4 -/* Address */ -#define MC_CMD_PORT_READ32_IN_ADDR_OFST 0 -#define MC_CMD_PORT_READ32_IN_ADDR_LEN 4 - -/* MC_CMD_PORT_READ32_OUT msgresponse */ -#define MC_CMD_PORT_READ32_OUT_LEN 8 -/* Value */ -#define MC_CMD_PORT_READ32_OUT_VALUE_OFST 0 -#define MC_CMD_PORT_READ32_OUT_VALUE_LEN 4 -/* Status */ -#define MC_CMD_PORT_READ32_OUT_STATUS_OFST 4 -#define MC_CMD_PORT_READ32_OUT_STATUS_LEN 4 - - -/***********************************/ -/* MC_CMD_PORT_WRITE32 -* Write a 32-bit register to the indirect port register map. The port to -* access is implied by the Shared memory channel used. -*/ -#define MC_CMD_PORT_WRITE32 0x15 - -/* MC_CMD_PORT_WRITE32_IN msgrequest */ -#define MC_CMD_PORT_WRITE32_IN_LEN 8 -/* Address */ -#define MC_CMD_PORT_WRITE32_IN_ADDR_OFST 0 -#define MC_CMD_PORT_WRITE32_IN_ADDR_LEN 4 -/* Value */ -#define MC_CMD_PORT_WRITE32_IN_VALUE_OFST 4 -#define MC_CMD_PORT_WRITE32_IN_VALUE_LEN 4 - -/* MC_CMD_PORT_WRITE32_OUT msgresponse */ -#define MC_CMD_PORT_WRITE32_OUT_LEN 4 -/* Status */ -#define MC_CMD_PORT_WRITE32_OUT_STATUS_OFST 0 -#define MC_CMD_PORT_WRITE32_OUT_STATUS_LEN 4 - - -/***********************************/ -/* MC_CMD_PORT_READ128 -* Read a 128-bit register from the indirect port register map. The port to -* access is implied by the Shared memory channel used. -*/ -#define MC_CMD_PORT_READ128 0x16 - -/* MC_CMD_PORT_READ128_IN msgrequest */ -#define MC_CMD_PORT_READ128_IN_LEN 4 -/* Address */ -#define MC_CMD_PORT_READ128_IN_ADDR_OFST 0 -#define MC_CMD_PORT_READ128_IN_ADDR_LEN 4 - -/* MC_CMD_PORT_READ128_OUT msgresponse */ -#define MC_CMD_PORT_READ128_OUT_LEN 20 -/* Value */ -#define MC_CMD_PORT_READ128_OUT_VALUE_OFST 0 -#define MC_CMD_PORT_READ128_OUT_VALUE_LEN 16 -/* Status */ -#define MC_CMD_PORT_READ128_OUT_STATUS_OFST 16 -#define MC_CMD_PORT_READ128_OUT_STATUS_LEN 4 - - -/***********************************/ -/* MC_CMD_PORT_WRITE128 -* Write a 128-bit register to the indirect port register map. The port to -* access is implied by the Shared memory channel used. -*/ -#define MC_CMD_PORT_WRITE128 0x17 - -/* MC_CMD_PORT_WRITE128_IN msgrequest */ -#define MC_CMD_PORT_WRITE128_IN_LEN 20 -/* Address */ -#define MC_CMD_PORT_WRITE128_IN_ADDR_OFST 0 -#define MC_CMD_PORT_WRITE128_IN_ADDR_LEN 4 -/* Value */ -#define MC_CMD_PORT_WRITE128_IN_VALUE_OFST 4 -#define MC_CMD_PORT_WRITE128_IN_VALUE_LEN 16 - -/* MC_CMD_PORT_WRITE128_OUT msgresponse */ -#define MC_CMD_PORT_WRITE128_OUT_LEN 4 -/* Status */ -#define MC_CMD_PORT_WRITE128_OUT_STATUS_OFST 0 -#define MC_CMD_PORT_WRITE128_OUT_STATUS_LEN 4 - -/* MC_CMD_CAPABILITIES structuredef */ -#define MC_CMD_CAPABILITIES_LEN 4 -/* Small buf table. */ -#define MC_CMD_CAPABILITIES_SMALL_BUF_TBL_LBN 0 -#define MC_CMD_CAPABILITIES_SMALL_BUF_TBL_WIDTH 1 -/* Turbo mode (for Maranello). */ -#define MC_CMD_CAPABILITIES_TURBO_LBN 1 -#define MC_CMD_CAPABILITIES_TURBO_WIDTH 1 -/* Turbo mode active (for Maranello). */ -#define MC_CMD_CAPABILITIES_TURBO_ACTIVE_LBN 2 -#define MC_CMD_CAPABILITIES_TURBO_ACTIVE_WIDTH 1 -/* PTP offload. */ -#define MC_CMD_CAPABILITIES_PTP_LBN 3 -#define MC_CMD_CAPABILITIES_PTP_WIDTH 1 -/* AOE mode. */ -#define MC_CMD_CAPABILITIES_AOE_LBN 4 -#define MC_CMD_CAPABILITIES_AOE_WIDTH 1 -/* AOE mode active. */ -#define MC_CMD_CAPABILITIES_AOE_ACTIVE_LBN 5 -#define MC_CMD_CAPABILITIES_AOE_ACTIVE_WIDTH 1 -/* AOE mode active. */ -#define MC_CMD_CAPABILITIES_FC_ACTIVE_LBN 6 -#define MC_CMD_CAPABILITIES_FC_ACTIVE_WIDTH 1 -#define MC_CMD_CAPABILITIES_RESERVED_LBN 7 -#define MC_CMD_CAPABILITIES_RESERVED_WIDTH 25 - -/***********************************/ /* MC_CMD_GET_BOARD_CFG * Returns the MC firmware configuration structure.
@@ -4426,112 +3968,6 @@#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MAXNUM_MCDI2 32 -/***********************************/ -/* MC_CMD_DBI_READX -* Read DBI register(s) -- extended functionality -*/ -#define MC_CMD_DBI_READX 0x19 -#undef MC_CMD_0x19_PRIVILEGE_CTG - -#define MC_CMD_0x19_PRIVILEGE_CTG SRIOV_CTG_INSECURE - -/* MC_CMD_DBI_READX_IN msgrequest */ -#define MC_CMD_DBI_READX_IN_LENMIN 8 -#define MC_CMD_DBI_READX_IN_LENMAX 248 -#define MC_CMD_DBI_READX_IN_LENMAX_MCDI2 1016 -#define MC_CMD_DBI_READX_IN_LEN (num) (0+8*(num)) -#define MC_CMD_DBI_READX_IN_DBIRDOP_NUM (len) (((len)-0)/8) -/* Each Read op consists of an address (offset 0), VF/CS2) */ -#define MC_CMD_DBI_READX_IN_DBIRDOP_OFST 0 -#define MC_CMD_DBI_READX_IN_DBIRDOP_LEN 8 -#define MC_CMD_DBI_READX_IN_DBIRDOP_LO_OFST 0 -#define MC_CMD_DBI_READX_IN_DBIRDOP_LO_LEN 4 -#define MC_CMD_DBI_READX_IN_DBIRDOP_LO_LBN 0 -#define MC_CMD_DBI_READX_IN_DBIRDOP_LO_WIDTH 32 -#define MC_CMD_DBI_READX_IN_DBIRDOP_HI_OFST 4 -#define MC_CMD_DBI_READX_IN_DBIRDOP_HI_LEN 4 -#define MC_CMD_DBI_READX_IN_DBIRDOP_HI_LBN 32 -#define MC_CMD_DBI_READX_IN_DBIRDOP_HI_WIDTH 32 -#define MC_CMD_DBI_READX_IN_DBIRDOP_MINNUM 1 -#define MC_CMD_DBI_READX_IN_DBIRDOP_MAXNUM 31 -#define MC_CMD_DBI_READX_IN_DBIRDOP_MAXNUM_MCDI2 127 - -/* MC_CMD_DBI_READX_OUT msgresponse */ -#define MC_CMD_DBI_READX_OUT_LENMIN 4 -#define MC_CMD_DBI_READX_OUT_LENMAX 252 -#define MC_CMD_DBI_READX_OUT_LENMAX_MCDI2 1020 -#define MC_CMD_DBI_READX_OUT_LEN (num) (0+4*(num)) -#define MC_CMD_DBI_READX_OUT_VALUE_NUM (len) (((len)-0)/4) -/* Value */ -#define MC_CMD_DBI_READX_OUT_VALUE_OFST 0 -#define MC_CMD_DBI_READX_OUT_VALUE_LEN 4 -#define MC_CMD_DBI_READX_OUT_VALUE_MINNUM 1 -#define MC_CMD_DBI_READX_OUT_VALUE_MAXNUM 63 -#define MC_CMD_DBI_READX_OUT_VALUE_MAXNUM_MCDI2 255 - -/* MC_CMD_DBIRDOP_TYPEDEF structuredef */ -#define MC_CMD_DBIRDOP_TYPEDEF_LEN 8 -#define MC_CMD_DBIRDOP_TYPEDEF_ADDRESS_OFST 0 -#define MC_CMD_DBIRDOP_TYPEDEF_ADDRESS_LEN 4 -#define MC_CMD_DBIRDOP_TYPEDEF_ADDRESS_LBN 0 -#define MC_CMD_DBIRDOP_TYPEDEF_ADDRESS_WIDTH 32 -#define MC_CMD_DBIRDOP_TYPEDEF_PARMS_OFST 4 -#define MC_CMD_DBIRDOP_TYPEDEF_PARMS_LEN 4 -#define MC_CMD_DBIRDOP_TYPEDEF_VF_NUM_OFST 4 -#define MC_CMD_DBIRDOP_TYPEDEF_VF_NUM_LBN 16 -#define MC_CMD_DBIRDOP_TYPEDEF_VF_NUM_WIDTH 16 -#define MC_CMD_DBIRDOP_TYPEDEF_VF_ACTIVE_OFST 4 -#define MC_CMD_DBIRDOP_TYPEDEF_VF_ACTIVE_LBN 15 -#define MC_CMD_DBIRDOP_TYPEDEF_VF_ACTIVE_WIDTH 1 -#define MC_CMD_DBIRDOP_TYPEDEF_CS2_OFST 4 -#define MC_CMD_DBIRDOP_TYPEDEF_CS2_LBN 14 -#define MC_CMD_DBIRDOP_TYPEDEF_CS2_WIDTH 1 -#define MC_CMD_DBIRDOP_TYPEDEF_PARMS_LBN 32 -#define MC_CMD_DBIRDOP_TYPEDEF_PARMS_WIDTH 32 - - -/***********************************/ -/* MC_CMD_SET_RAND_SEED -* Set the 16byte seed for the MC pseudo-random generator. -*/ -#define MC_CMD_SET_RAND_SEED 0x1a -#undef MC_CMD_0x1a_PRIVILEGE_CTG - -#define MC_CMD_0x1a_PRIVILEGE_CTG SRIOV_CTG_INSECURE - -/* MC_CMD_SET_RAND_SEED_IN msgrequest */ -#define MC_CMD_SET_RAND_SEED_IN_LEN 16 -/* Seed value. */ -#define MC_CMD_SET_RAND_SEED_IN_SEED_OFST 0 -#define MC_CMD_SET_RAND_SEED_IN_SEED_LEN 16 - -/* MC_CMD_SET_RAND_SEED_OUT msgresponse */ -#define MC_CMD_SET_RAND_SEED_OUT_LEN 0 - - -/***********************************/ -/* MC_CMD_LTSSM_HIST -* Retrieve the history of the LTSSM, if the build supports it. -*/ -#define MC_CMD_LTSSM_HIST 0x1b - -/* MC_CMD_LTSSM_HIST_IN msgrequest */ -#define MC_CMD_LTSSM_HIST_IN_LEN 0 - -/* MC_CMD_LTSSM_HIST_OUT msgresponse */ -#define MC_CMD_LTSSM_HIST_OUT_LENMIN 0 -#define MC_CMD_LTSSM_HIST_OUT_LENMAX 252 -#define MC_CMD_LTSSM_HIST_OUT_LENMAX_MCDI2 1020 -#define MC_CMD_LTSSM_HIST_OUT_LEN (num) (0+4*(num)) -#define MC_CMD_LTSSM_HIST_OUT_DATA_NUM (len) (((len)-0)/4) -/* variable number of LTSSM values, as bytes. The history is read-to-clear. */ -#define MC_CMD_LTSSM_HIST_OUT_DATA_OFST 0 -#define MC_CMD_LTSSM_HIST_OUT_DATA_LEN 4 -#define MC_CMD_LTSSM_HIST_OUT_DATA_MINNUM 0 -#define MC_CMD_LTSSM_HIST_OUT_DATA_MAXNUM 63 -#define MC_CMD_LTSSM_HIST_OUT_DATA_MAXNUM_MCDI2 255 - -/***********************************/ /* MC_CMD_DRV_ATTACH * Inform MCPU that this port is managed on the host (i.e. driver active). For
@@ -4705,6 +4141,7 @@/* Flags associated with this function */ #define MC_CMD_DRV_ATTACH_EXT_OUT_FUNC_FLAGS_OFST 4#define MC_CMD_DRV_ATTACH_EXT_OUT_FUNC_FLAGS_LEN 4 +/* enum property: bitshift */ /* enum: Labels the lowest-numbered function visible to the OS */ #define MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_PRIMARY 0x0/* enum: The function can control the link state of the physical port it is
@@ -4731,22 +4168,6 @@#define MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_TX_ONLY_VI_SPREADING_ENABLED 0x5 -/***********************************/ -/* MC_CMD_SHMUART -* Route UART output to circular buffer in shared memory instead. -*/ -#define MC_CMD_SHMUART 0x1f - -/* MC_CMD_SHMUART_IN msgrequest */ -#define MC_CMD_SHMUART_IN_LEN 4 -/* ??? */ -#define MC_CMD_SHMUART_IN_FLAG_OFST 0 -#define MC_CMD_SHMUART_IN_FLAG_LEN 4 - -/* MC_CMD_SHMUART_OUT msgresponse */ -#define MC_CMD_SHMUART_OUT_LEN 0 - -/***********************************/ /* MC_CMD_PORT_RESET * Generic per-port reset. There is no equivalent for per-board reset. Locks
@@ -4789,100 +4210,6 @@#define MC_CMD_ENTITY_RESET_OUT_LEN 0 -/***********************************/ -/* MC_CMD_PCIE_CREDITS -* Read instantaneous and minimum flow control thresholds. -*/ -#define MC_CMD_PCIE_CREDITS 0x21 - -/* MC_CMD_PCIE_CREDITS_IN msgrequest */ -#define MC_CMD_PCIE_CREDITS_IN_LEN 8 -/* poll period. 0 is disabled */ -#define MC_CMD_PCIE_CREDITS_IN_POLL_PERIOD_OFST 0 -#define MC_CMD_PCIE_CREDITS_IN_POLL_PERIOD_LEN 4 -/* wipe statistics */ -#define MC_CMD_PCIE_CREDITS_IN_WIPE_OFST 4 -#define MC_CMD_PCIE_CREDITS_IN_WIPE_LEN 4 - -/* MC_CMD_PCIE_CREDITS_OUT msgresponse */ -#define MC_CMD_PCIE_CREDITS_OUT_LEN 16 -#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_P_HDR_OFST 0 -#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_P_HDR_LEN 2 -#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_P_DATA_OFST 2 -#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_P_DATA_LEN 2 -#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_NP_HDR_OFST 4 -#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_NP_HDR_LEN 2 -#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_NP_DATA_OFST 6 -#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_NP_DATA_LEN 2 -#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_P_HDR_OFST 8 -#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_P_HDR_LEN 2 -#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_P_DATA_OFST 10 -#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_P_DATA_LEN 2 -#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_NP_HDR_OFST 12 -#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_NP_HDR_LEN 2 -#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_NP_DATA_OFST 14 -#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_NP_DATA_LEN 2 - - -/***********************************/ -/* MC_CMD_RXD_MONITOR -* Get histogram of RX queue fill level. -*/ -#define MC_CMD_RXD_MONITOR 0x22 - -/* MC_CMD_RXD_MONITOR_IN msgrequest */ -#define MC_CMD_RXD_MONITOR_IN_LEN 12 -#define MC_CMD_RXD_MONITOR_IN_QID_OFST 0 -#define MC_CMD_RXD_MONITOR_IN_QID_LEN 4 -#define MC_CMD_RXD_MONITOR_IN_POLL_PERIOD_OFST 4 -#define MC_CMD_RXD_MONITOR_IN_POLL_PERIOD_LEN 4 -#define MC_CMD_RXD_MONITOR_IN_WIPE_OFST 8 -#define MC_CMD_RXD_MONITOR_IN_WIPE_LEN 4 - -/* MC_CMD_RXD_MONITOR_OUT msgresponse */ -#define MC_CMD_RXD_MONITOR_OUT_LEN 80 -#define MC_CMD_RXD_MONITOR_OUT_QID_OFST 0 -#define MC_CMD_RXD_MONITOR_OUT_QID_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_RING_FILL_OFST 4 -#define MC_CMD_RXD_MONITOR_OUT_RING_FILL_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_FILL_OFST 8 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_FILL_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_1_OFST 12 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_1_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_2_OFST 16 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_2_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_4_OFST 20 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_4_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_8_OFST 24 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_8_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_16_OFST 28 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_16_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_32_OFST 32 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_32_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_64_OFST 36 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_64_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_128_OFST 40 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_128_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_256_OFST 44 -#define MC_CMD_RXD_MONITOR_OUT_RING_LT_256_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_RING_GE_256_OFST 48 -#define MC_CMD_RXD_MONITOR_OUT_RING_GE_256_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_1_OFST 52 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_1_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_2_OFST 56 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_2_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_4_OFST 60 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_4_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_8_OFST 64 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_8_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_16_OFST 68 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_16_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_32_OFST 72 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_32_LEN 4 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_GE_32_OFST 76 -#define MC_CMD_RXD_MONITOR_OUT_CACHE_GE_32_LEN 4 - -/***********************************/ /* MC_CMD_PUTS * Copy the given ASCII string out onto UART and/or out of the network port.
@@ -4931,6 +4258,54 @@/* MC_CMD_GET_PHY_CFG_IN msgrequest */ #define MC_CMD_GET_PHY_CFG_IN_LEN 0 +/* MC_CMD_GET_PHY_CFG_IN_V2 msgrequest */ +#define MC_CMD_GET_PHY_CFG_IN_V2_LEN 8 +/* Target port to request PHY state for. Uses MAE_LINK_ENDPOINT_SELECTOR which +* identifies a real or virtual network port by MAE port and link end. See the +* structure definition for more details +*/ +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_OFST 0 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_LEN 8 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_LO_OFST 0 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_LO_LEN 4 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_LO_LBN 0 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_LO_WIDTH 32 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_HI_OFST 4 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_HI_LEN 4 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_HI_LBN 32 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_HI_WIDTH 32 +/* See structuredef: MAE_LINK_ENDPOINT_SELECTOR */ +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_OFST 0 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_LEN 4 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_FLAT_OFST 0 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_FLAT_LEN 4 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_TYPE_OFST 3 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_TYPE_LEN 1 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_MPORT_ID_OFST 0 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_MPORT_ID_LEN 3 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_PPORT_ID_LBN 0 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_PPORT_ID_WIDTH 4 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_FUNC_INTF_ID_LBN 20 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_FUNC_INTF_ID_WIDTH 4 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_FUNC_MH_PF_ID_LBN 16 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_FUNC_MH_PF_ID_WIDTH 4 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_FUNC_PF_ID_OFST 2 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_FUNC_PF_ID_LEN 1 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_FUNC_VF_ID_OFST 0 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_MPORT_SELECTOR_FUNC_VF_ID_LEN 2 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_LINK_END_OFST 4 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_LINK_END_LEN 4 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_FLAT_OFST 0 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_FLAT_LEN 8 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_FLAT_LO_OFST 0 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_FLAT_LO_LEN 4 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_FLAT_LO_LBN 0 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_FLAT_LO_WIDTH 32 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_FLAT_HI_OFST 4 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_FLAT_HI_LEN 4 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_FLAT_HI_LBN 32 +#define MC_CMD_GET_PHY_CFG_IN_V2_TARGET_FLAT_HI_WIDTH 32 +/* MC_CMD_GET_PHY_CFG_OUT msgresponse */ #define MC_CMD_GET_PHY_CFG_OUT_LEN 72/* flags */
@@ -5026,6 +4401,9 @@#define MC_CMD_PHY_CAP_25G_BASER_FEC_REQUESTED_OFST 8#define MC_CMD_PHY_CAP_25G_BASER_FEC_REQUESTED_LBN 21#define MC_CMD_PHY_CAP_25G_BASER_FEC_REQUESTED_WIDTH 1 +#define MC_CMD_PHY_CAP_200000FDX_OFST 8 +#define MC_CMD_PHY_CAP_200000FDX_LBN 22 +#define MC_CMD_PHY_CAP_200000FDX_WIDTH 1/* ?? */ #define MC_CMD_GET_PHY_CFG_OUT_CHANNEL_OFST 12#define MC_CMD_GET_PHY_CFG_OUT_CHANNEL_LEN 4
@@ -5059,6 +4437,7 @@#define MC_CMD_MEDIA_DSFP 0x8#define MC_CMD_GET_PHY_CFG_OUT_MMD_MASK_OFST 48#define MC_CMD_GET_PHY_CFG_OUT_MMD_MASK_LEN 4 +/* enum property: bitshift */ /* enum: Native clause 22 */ #define MC_CMD_MMD_CLAUSE22 0x0#define MC_CMD_MMD_CLAUSE45_PMAPMD 0x1/* enum */
@@ -5084,7 +4463,7 @@#define MC_CMD_START_BIST 0x25#undef MC_CMD_0x25_PRIVILEGE_CTG -#define MC_CMD_0x25_PRIVILEGE_CTG SRIOV_CTG_ADMIN +#define MC_CMD_0x25_PRIVILEGE_CTG SRIOV_CTG_ADMIN_TSA_UNBOUND/* MC_CMD_START_BIST_IN msgrequest */ #define MC_CMD_START_BIST_IN_LEN 4
@@ -5124,7 +4503,7 @@#define MC_CMD_POLL_BIST 0x26#undef MC_CMD_0x26_PRIVILEGE_CTG -#define MC_CMD_0x26_PRIVILEGE_CTG SRIOV_CTG_ADMIN +#define MC_CMD_0x26_PRIVILEGE_CTG SRIOV_CTG_ADMIN_TSA_UNBOUND/* MC_CMD_POLL_BIST_IN msgrequest */ #define MC_CMD_POLL_BIST_IN_LEN 0
@@ -5320,6 +4699,54 @@/* MC_CMD_GET_LOOPBACK_MODES_IN msgrequest */ #define MC_CMD_GET_LOOPBACK_MODES_IN_LEN 0 +/* MC_CMD_GET_LOOPBACK_MODES_IN_V2 msgrequest */ +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_LEN 8 +/* Target port to request loopback modes for. Uses MAE_LINK_ENDPOINT_SELECTOR +* which identifies a real or virtual network port by MAE port and link end. +* See the structure definition for more details +*/ +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_OFST 0 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_LO_OFST 0 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_LO_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_LO_LBN 0 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_LO_WIDTH 32 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_HI_OFST 4 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_HI_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_HI_LBN 32 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_HI_WIDTH 32 +/* See structuredef: MAE_LINK_ENDPOINT_SELECTOR */ +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_OFST 0 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_FLAT_OFST 0 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_FLAT_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_TYPE_OFST 3 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_TYPE_LEN 1 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_MPORT_ID_OFST 0 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_MPORT_ID_LEN 3 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_PPORT_ID_LBN 0 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_PPORT_ID_WIDTH 4 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_FUNC_INTF_ID_LBN 20 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_FUNC_INTF_ID_WIDTH 4 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_FUNC_MH_PF_ID_LBN 16 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_FUNC_MH_PF_ID_WIDTH 4 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_FUNC_PF_ID_OFST 2 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_FUNC_PF_ID_LEN 1 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_FUNC_VF_ID_OFST 0 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_MPORT_SELECTOR_FUNC_VF_ID_LEN 2 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_LINK_END_OFST 4 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_LINK_END_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_FLAT_OFST 0 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_FLAT_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_FLAT_LO_OFST 0 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_FLAT_LO_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_FLAT_LO_LBN 0 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_FLAT_LO_WIDTH 32 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_FLAT_HI_OFST 4 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_FLAT_HI_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_FLAT_HI_LBN 32 +#define MC_CMD_GET_LOOPBACK_MODES_IN_V2_TARGET_FLAT_HI_WIDTH 32 +/* MC_CMD_GET_LOOPBACK_MODES_OUT msgresponse */ #define MC_CMD_GET_LOOPBACK_MODES_OUT_LEN 40/* Supported loopbacks. */
@@ -5333,6 +4760,7 @@#define MC_CMD_GET_LOOPBACK_MODES_OUT_100M_HI_LEN 4#define MC_CMD_GET_LOOPBACK_MODES_OUT_100M_HI_LBN 32#define MC_CMD_GET_LOOPBACK_MODES_OUT_100M_HI_WIDTH 32 +/* enum property: bitshift */ /* enum: None. */ #define MC_CMD_LOOPBACK_NONE 0x0/* enum: Data. */
@@ -5422,6 +4850,7 @@#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_HI_LEN 4#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_HI_LBN 96#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_HI_WIDTH 32 +/* enum property: bitshift */ /* Enum values, see field(s): */ /* 100M */ /* Supported loopbacks. */
@@ -5435,6 +4864,7 @@#define MC_CMD_GET_LOOPBACK_MODES_OUT_10G_HI_LEN 4#define MC_CMD_GET_LOOPBACK_MODES_OUT_10G_HI_LBN 160#define MC_CMD_GET_LOOPBACK_MODES_OUT_10G_HI_WIDTH 32 +/* enum property: bitshift */ /* Enum values, see field(s): */ /* 100M */ /* Supported loopbacks. */
@@ -5448,6 +4878,7 @@#define MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_HI_LEN 4#define MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_HI_LBN 224#define MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_HI_WIDTH 32 +/* enum property: bitshift */ /* Enum values, see field(s): */ /* 100M */ /* Supported loopbacks. */
@@ -5461,6 +4892,7 @@#define MC_CMD_GET_LOOPBACK_MODES_OUT_40G_HI_LEN 4#define MC_CMD_GET_LOOPBACK_MODES_OUT_40G_HI_LBN 288#define MC_CMD_GET_LOOPBACK_MODES_OUT_40G_HI_WIDTH 32 +/* enum property: bitshift */ /* Enum values, see field(s): */ /* 100M */
@@ -5479,6 +4911,7 @@#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_100M_HI_LEN 4#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_100M_HI_LBN 32#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_100M_HI_WIDTH 32 +/* enum property: bitshift */ /* enum: None. */ /* MC_CMD_LOOPBACK_NONE 0x0 */ /* enum: Data. */
@@ -5568,6 +5001,7 @@#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_1G_HI_LEN 4#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_1G_HI_LBN 96#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_1G_HI_WIDTH 32 +/* enum property: bitshift */ /* Enum values, see field(s): */ /* 100M */ /* Supported loopbacks. */
@@ -5581,6 +5015,7 @@#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_10G_HI_LEN 4#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_10G_HI_LBN 160#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_10G_HI_WIDTH 32 +/* enum property: bitshift */ /* Enum values, see field(s): */ /* 100M */ /* Supported loopbacks. */
@@ -5594,6 +5029,7 @@#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_SUGGESTED_HI_LEN 4#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_SUGGESTED_HI_LBN 224#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_SUGGESTED_HI_WIDTH 32 +/* enum property: bitshift */ /* Enum values, see field(s): */ /* 100M */ /* Supported loopbacks. */
@@ -5607,6 +5043,7 @@#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_40G_HI_LEN 4#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_40G_HI_LBN 288#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_40G_HI_WIDTH 32 +/* enum property: bitshift */ /* Enum values, see field(s): */ /* 100M */ /* Supported 25G loopbacks. */
@@ -5620,6 +5057,7 @@#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_25G_HI_LEN 4#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_25G_HI_LBN 352#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_25G_HI_WIDTH 32 +/* enum property: bitshift */ /* Enum values, see field(s): */ /* 100M */ /* Supported 50 loopbacks. */
@@ -5633,6 +5071,7 @@#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_50G_HI_LEN 4#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_50G_HI_LBN 416#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_50G_HI_WIDTH 32 +/* enum property: bitshift */ /* Enum values, see field(s): */ /* 100M */ /* Supported 100G loopbacks. */
@@ -5646,40 +5085,1070 @@#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_100G_HI_LEN 4#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_100G_HI_LBN 480#define MC_CMD_GET_LOOPBACK_MODES_OUT_V2_100G_HI_WIDTH 32 +/* enum property: bitshift */ /* Enum values, see field(s): */ /* 100M */ -/* AN_TYPE structuredef: Auto-negotiation types defined in IEEE802.3 */ -#define AN_TYPE_LEN 4 -#define AN_TYPE_TYPE_OFST 0 -#define AN_TYPE_TYPE_LEN 4 -/* enum: None, AN disabled or not supported */ -#define MC_CMD_AN_NONE 0x0 -/* enum: Clause 28 - BASE-T */ -#define MC_CMD_AN_CLAUSE28 0x1 -/* enum: Clause 37 - BASE-X */ -#define MC_CMD_AN_CLAUSE37 0x2 -/* enum: Clause 73 - BASE-R startup protocol for backplane and copper cable -* assemblies. Includes Clause 72/Clause 92 link-training. +/* MC_CMD_GET_LOOPBACK_MODES_OUT_V3 msgresponse: Supported loopback modes for +* newer NICs with 200G support */ -#define MC_CMD_AN_CLAUSE73 0x3 -#define AN_TYPE_TYPE_LBN 0 -#define AN_TYPE_TYPE_WIDTH 32 - -/* FEC_TYPE structuredef: Forward error correction types defined in IEEE802.3 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_LEN 72 +/* Supported loopbacks. */ +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100M_OFST 0 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100M_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100M_LO_OFST 0 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100M_LO_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100M_LO_LBN 0 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100M_LO_WIDTH 32 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100M_HI_OFST 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100M_HI_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100M_HI_LBN 32 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100M_HI_WIDTH 32 +/* enum property: bitshift */ +/* enum: None. */ +/* MC_CMD_LOOPBACK_NONE 0x0 */ +/* enum: Data. */ +/* MC_CMD_LOOPBACK_DATA 0x1 */ +/* enum: GMAC. */ +/* MC_CMD_LOOPBACK_GMAC 0x2 */ +/* enum: XGMII. */ +/* MC_CMD_LOOPBACK_XGMII 0x3 */ +/* enum: XGXS. */ +/* MC_CMD_LOOPBACK_XGXS 0x4 */ +/* enum: XAUI. */ +/* MC_CMD_LOOPBACK_XAUI 0x5 */ +/* enum: GMII. */ +/* MC_CMD_LOOPBACK_GMII 0x6 */ +/* enum: SGMII. */ +/* MC_CMD_LOOPBACK_SGMII 0x7 */ +/* enum: XGBR. */ +/* MC_CMD_LOOPBACK_XGBR 0x8 */ +/* enum: XFI. */ +/* MC_CMD_LOOPBACK_XFI 0x9 */ +/* enum: XAUI Far. */ +/* MC_CMD_LOOPBACK_XAUI_FAR 0xa */ +/* enum: GMII Far. */ +/* MC_CMD_LOOPBACK_GMII_FAR 0xb */ +/* enum: SGMII Far. */ +/* MC_CMD_LOOPBACK_SGMII_FAR 0xc */ +/* enum: XFI Far. */ +/* MC_CMD_LOOPBACK_XFI_FAR 0xd */ +/* enum: GPhy. */ +/* MC_CMD_LOOPBACK_GPHY 0xe */ +/* enum: PhyXS. */ +/* MC_CMD_LOOPBACK_PHYXS 0xf */ +/* enum: PCS. */ +/* MC_CMD_LOOPBACK_PCS 0x10 */ +/* enum: PMA-PMD. */ +/* MC_CMD_LOOPBACK_PMAPMD 0x11 */ +/* enum: Cross-Port. */ +/* MC_CMD_LOOPBACK_XPORT 0x12 */ +/* enum: XGMII-Wireside. */ +/* MC_CMD_LOOPBACK_XGMII_WS 0x13 */ +/* enum: XAUI Wireside. */ +/* MC_CMD_LOOPBACK_XAUI_WS 0x14 */ +/* enum: XAUI Wireside Far. */ +/* MC_CMD_LOOPBACK_XAUI_WS_FAR 0x15 */ +/* enum: XAUI Wireside near. */ +/* MC_CMD_LOOPBACK_XAUI_WS_NEAR 0x16 */ +/* enum: GMII Wireside. */ +/* MC_CMD_LOOPBACK_GMII_WS 0x17 */ +/* enum: XFI Wireside. */ +/* MC_CMD_LOOPBACK_XFI_WS 0x18 */ +/* enum: XFI Wireside Far. */ +/* MC_CMD_LOOPBACK_XFI_WS_FAR 0x19 */ +/* enum: PhyXS Wireside. */ +/* MC_CMD_LOOPBACK_PHYXS_WS 0x1a */ +/* enum: PMA lanes MAC-Serdes. */ +/* MC_CMD_LOOPBACK_PMA_INT 0x1b */ +/* enum: KR Serdes Parallel (Encoder). */ +/* MC_CMD_LOOPBACK_SD_NEAR 0x1c */ +/* enum: KR Serdes Serial. */ +/* MC_CMD_LOOPBACK_SD_FAR 0x1d */ +/* enum: PMA lanes MAC-Serdes Wireside. */ +/* MC_CMD_LOOPBACK_PMA_INT_WS 0x1e */ +/* enum: KR Serdes Parallel Wireside (Full PCS). */ +/* MC_CMD_LOOPBACK_SD_FEP2_WS 0x1f */ +/* enum: KR Serdes Parallel Wireside (Sym Aligner to TX). */ +/* MC_CMD_LOOPBACK_SD_FEP1_5_WS 0x20 */ +/* enum: KR Serdes Parallel Wireside (Deserializer to Serializer). */ +/* MC_CMD_LOOPBACK_SD_FEP_WS 0x21 */ +/* enum: KR Serdes Serial Wireside. */ +/* MC_CMD_LOOPBACK_SD_FES_WS 0x22 */ +/* enum: Near side of AOE Siena side port */ +/* MC_CMD_LOOPBACK_AOE_INT_NEAR 0x23 */ +/* enum: Medford Wireside datapath loopback */ +/* MC_CMD_LOOPBACK_DATA_WS 0x24 */ +/* enum: Force link up without setting up any physical loopback (snapper use +* only) */ -#define FEC_TYPE_LEN 4 -#define FEC_TYPE_TYPE_OFST 0 -#define FEC_TYPE_TYPE_LEN 4 -/* enum: No FEC */ -#define MC_CMD_FEC_NONE 0x0 -/* enum: Clause 74 BASE-R FEC (a.k.a Firecode) */ -#define MC_CMD_FEC_BASER 0x1 -/* enum: Clause 91/Clause 108 Reed-Solomon FEC */ +/* MC_CMD_LOOPBACK_FORCE_EXT_LINK 0x25 */ +/* Supported loopbacks. */ +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_1G_OFST 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_1G_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_1G_LO_OFST 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_1G_LO_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_1G_LO_LBN 64 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_1G_LO_WIDTH 32 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_1G_HI_OFST 12 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_1G_HI_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_1G_HI_LBN 96 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_1G_HI_WIDTH 32 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* 100M */ +/* Supported loopbacks. */ +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_10G_OFST 16 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_10G_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_10G_LO_OFST 16 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_10G_LO_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_10G_LO_LBN 128 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_10G_LO_WIDTH 32 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_10G_HI_OFST 20 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_10G_HI_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_10G_HI_LBN 160 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_10G_HI_WIDTH 32 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* 100M */ +/* Supported loopbacks. */ +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_SUGGESTED_OFST 24 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_SUGGESTED_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_SUGGESTED_LO_OFST 24 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_SUGGESTED_LO_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_SUGGESTED_LO_LBN 192 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_SUGGESTED_LO_WIDTH 32 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_SUGGESTED_HI_OFST 28 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_SUGGESTED_HI_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_SUGGESTED_HI_LBN 224 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_SUGGESTED_HI_WIDTH 32 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* 100M */ +/* Supported loopbacks. */ +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_40G_OFST 32 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_40G_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_40G_LO_OFST 32 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_40G_LO_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_40G_LO_LBN 256 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_40G_LO_WIDTH 32 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_40G_HI_OFST 36 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_40G_HI_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_40G_HI_LBN 288 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_40G_HI_WIDTH 32 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* 100M */ +/* Supported 25G loopbacks. */ +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_25G_OFST 40 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_25G_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_25G_LO_OFST 40 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_25G_LO_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_25G_LO_LBN 320 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_25G_LO_WIDTH 32 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_25G_HI_OFST 44 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_25G_HI_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_25G_HI_LBN 352 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_25G_HI_WIDTH 32 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* 100M */ +/* Supported 50 loopbacks. */ +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_50G_OFST 48 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_50G_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_50G_LO_OFST 48 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_50G_LO_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_50G_LO_LBN 384 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_50G_LO_WIDTH 32 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_50G_HI_OFST 52 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_50G_HI_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_50G_HI_LBN 416 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_50G_HI_WIDTH 32 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* 100M */ +/* Supported 100G loopbacks. */ +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100G_OFST 56 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100G_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100G_LO_OFST 56 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100G_LO_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100G_LO_LBN 448 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100G_LO_WIDTH 32 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100G_HI_OFST 60 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100G_HI_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100G_HI_LBN 480 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_100G_HI_WIDTH 32 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* 100M */ +/* Supported 200G loopbacks. */ +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_200G_OFST 64 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_200G_LEN 8 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_200G_LO_OFST 64 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_200G_LO_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_200G_LO_LBN 512 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_200G_LO_WIDTH 32 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_200G_HI_OFST 68 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_200G_HI_LEN 4 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_200G_HI_LBN 544 +#define MC_CMD_GET_LOOPBACK_MODES_OUT_V3_200G_HI_WIDTH 32 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* 100M */ + +/* AN_TYPE structuredef: Auto-negotiation types defined in IEEE802.3 */ +#define AN_TYPE_LEN 4 +#define AN_TYPE_TYPE_OFST 0 +#define AN_TYPE_TYPE_LEN 4 +/* enum: None, AN disabled or not supported */ +#define MC_CMD_AN_NONE 0x0 +/* enum: Clause 28 - BASE-T */ +#define MC_CMD_AN_CLAUSE28 0x1 +/* enum: Clause 37 - BASE-X */ +#define MC_CMD_AN_CLAUSE37 0x2 +/* enum: Clause 73 - BASE-R startup protocol for backplane and copper cable +* assemblies. Includes Clause 72/Clause 92 link-training. +*/ +#define MC_CMD_AN_CLAUSE73 0x3 +#define AN_TYPE_TYPE_LBN 0 +#define AN_TYPE_TYPE_WIDTH 32 + +/* FEC_TYPE structuredef: Forward error correction types defined in IEEE802.3 +*/ +#define FEC_TYPE_LEN 4 +#define FEC_TYPE_TYPE_OFST 0 +#define FEC_TYPE_TYPE_LEN 4 +/* enum: No FEC */ +#define MC_CMD_FEC_NONE 0x0 +/* enum: IEEE 802.3, Clause 74 BASE-R FEC (a.k.a Firecode) */ +#define MC_CMD_FEC_BASER 0x1 +/* enum: IEEE 802.3, Clause 91/Clause 108 Reed-Solomon FEC */ #define MC_CMD_FEC_RS 0x2 +/* enum: IEEE 802.3, Clause 161, interleaved RS-FEC sublayer for 100GBASE-R +* PHYs +*/ +#define MC_CMD_FEC_IEEE_RS_INT 0x3 +/* enum: Ethernet Consortium, Low Latency RS-FEC. RS(272, 258). Replaces FEC +* specified in Clause 119 for 100/200G PHY. Replaces FEC specified in Clause +* 134 for 50G PHY. +*/ +#define MC_CMD_FEC_ETCS_RS_LL 0x4 +/* enum: FEC mode selected automatically */ +#define MC_CMD_FEC_AUTO 0x5#define FEC_TYPE_TYPE_LBN 0#define FEC_TYPE_TYPE_WIDTH 32 +/* MC_CMD_ETH_TECH structuredef: Ethernet technology as defined by IEEE802.3, +* Ethernet Technology Consortium, proprietary technologies. The driver must +* not use technologies labelled NONE and AUTO. +*/ +#define MC_CMD_ETH_TECH_LEN 16 +/* The enums in this field can be used either as bitwise indices into a tech +* mask (e.g. see MC_CMD_ETH_AN_FIELDS/TECH_MASK for example) or as regular +* enums (e.g. see MC_CMD_LINK_CTRL_IN/ADVERTISED_TECH_ABILITIES_MASK). This +* structure must be updated to add new technologies when projects that need +* them arise. An incomplete list of possible expansion in the future include: +* 100GBASE_KP4, 800GBASE_CR8, 800GBASE_KR8, 800GBASE_DR8, 800GBASE_SR8 +* 800GBASE_VR8 +*/ +#define MC_CMD_ETH_TECH_TECH_OFST 0 +#define MC_CMD_ETH_TECH_TECH_LEN 16 +/* enum: 1000BASE-KX - 1000BASE-X PCS/PMA over an electrical backplane PMD. See +* IEEE 802.3 Clause 70 +*/ +#define MC_CMD_ETH_TECH_1000BASEKX 0x0 +/* enum: 10GBASE-R - PCS/PMA over an electrical backplane PMD. Refer to IEEE +* 802.3 Clause 72 +*/ +#define MC_CMD_ETH_TECH_10GBASE_KR 0x1 +/* enum: 40GBASE-R PCS/PMA over an electrical backplane PMD. See IEEE 802.3 +* Clause 84. +*/ +#define MC_CMD_ETH_TECH_40GBASE_KR4 0x2 +/* enum: 40GBASE-R PCS/PMA over 4 lane shielded copper balanced cable PMD. See +* IEEE 802.3 Clause 85 +*/ +#define MC_CMD_ETH_TECH_40GBASE_CR4 0x3 +/* enum: 40GBASE-R PCS/PMA over 4 lane multimode fiber PMD as specified in +* Clause 86 +*/ +#define MC_CMD_ETH_TECH_40GBASE_SR4 0x4 +/* enum: 40GBASE-R PCS/PMA over 4 WDM lane single mode fiber PMD with long +* reach. See IEEE 802.3 Clause 87 +*/ +#define MC_CMD_ETH_TECH_40GBASE_LR4 0x5 +/* enum: 25GBASE-R PCS/PMA over shielded balanced copper cable PMD. See IEEE +* 802.3 Clause 110 +*/ +#define MC_CMD_ETH_TECH_25GBASE_CR 0x6 +/* enum: 25GBASE-R PCS/PMA over an electrical backplane PMD. See IEEE 802.3 +* Clause 111 +*/ +#define MC_CMD_ETH_TECH_25GBASE_KR 0x7 +/* enum: 25GBASE-R PCS/PMA over multimode fiber PMD. Refer to IEEE 802.3 Clause +* 112 +*/ +#define MC_CMD_ETH_TECH_25GBASE_SR 0x8 +/* enum: An Ethernet Physical layer operating at 50 Gb/s on twin-axial copper +* cable. Refer to Ethernet Technology Consortium 25/50G Ethernet Spec. +*/ +#define MC_CMD_ETH_TECH_50GBASE_CR2 0x9 +/* enum: An Ethernet Physical layer operating at 50 Gb/s on copper backplane. +* Refer to Ethernet Technology Consortium 25/50G Ethernet Spec. +*/ +#define MC_CMD_ETH_TECH_50GBASE_KR2 0xa +/* enum: 100GBASE-R PCS/PMA over an electrical backplane PMD. See IEEE 802.3 +* Clause 93 +*/ +#define MC_CMD_ETH_TECH_100GBASE_KR4 0xb +/* enum: 100GBASE-R PCS/PMA over 4 lane multimode fiber PMD. See IEEE 802.3 +* Clause 95 +*/ +#define MC_CMD_ETH_TECH_100GBASE_SR4 0xc +/* enum: 100GBASE-R PCS/PMA over 4 lane shielded copper balanced cable PMD. See +* IEEE 802.3 Clause 92 +*/ +#define MC_CMD_ETH_TECH_100GBASE_CR4 0xd +/* enum: 100GBASE-R PCS/PMA over 4 WDM lane single mode fiber PMD, with +* long/extended reach,. See IEEE 802.3 Clause 88 +*/ +#define MC_CMD_ETH_TECH_100GBASE_LR4_ER4 0xe +/* enum: An Ethernet Physical layer operating at 50 Gb/s on short reach fiber. +* Refer to Ethernet Technology Consortium 25/50G Ethernet Spec. +*/ +#define MC_CMD_ETH_TECH_50GBASE_SR2 0xf +/* enum: 1000BASEX PCS/PMA. See IEEE 802.3 Clause 36 over undefined PMD, duplex +* mode unknown +*/ +#define MC_CMD_ETH_TECH_1000BASEX 0x10 +/* enum: Non-standardised. 10G direct attach */ +#define MC_CMD_ETH_TECH_10GBASE_CR 0x11 +/* enum: 10GBASE-SR fiber over 850nm optics. See IEEE 802.3 Clause 52 */ +#define MC_CMD_ETH_TECH_10GBASE_SR 0x12 +/* enum: 10GBASE-LR fiber over 1310nm optics. See IEEE 802.3 Clause 52 */ +#define MC_CMD_ETH_TECH_10GBASE_LR 0x13 +/* enum: 10GBASE-LRM fiber over 1310 nm optics. See IEEE 802.3 Clause 68 */ +#define MC_CMD_ETH_TECH_10GBASE_LRM 0x14 +/* enum: 10GBASE-ER fiber over 1550nm optics. See IEEE 802.3 Clause 52 */ +#define MC_CMD_ETH_TECH_10GBASE_ER 0x15 +/* enum: 50GBASE-R PCS/PMA over an electrical backplane PMD. See IEEE 802.3 +* Clause 137 +*/ +#define MC_CMD_ETH_TECH_50GBASE_KR 0x16 +/* enum: 50GBASE-SR PCS/PMA over multimode fiber PMD as specified in Clause 138 +*/ +#define MC_CMD_ETH_TECH_50GBASE_SR 0x17 +/* enum: 50GBASE-CR PCS/PMA over shielded copper balanced cable PMD. See IEEE +* 802.3 Clause 136 +*/ +#define MC_CMD_ETH_TECH_50GBASE_CR 0x18 +/* enum: 50GBASE-R PCS/PMA over single mode fiber PMD as specified in Clause +* 139. +*/ +#define MC_CMD_ETH_TECH_50GBASE_LR_ER_FR 0x19 +/* enum: 100 Gb/s PHY using 100GBASE-R encoding over single-mode fiber with +* reach up to at least 500 m (see IEEE 802.3 Clause 140) +*/ +#define MC_CMD_ETH_TECH_50GBASE_DR 0x1a +/* enum: 100GBASE-R PCS/PMA over an electrical backplane PMD. See IEEE 802.3 +* Clause 137 +*/ +#define MC_CMD_ETH_TECH_100GBASE_KR2 0x1b +/* enum: 100GBASE-R PCS/PMA over 2 lane multimode fiber PMD. See IEEE 802.3 +* Clause 138 +*/ +#define MC_CMD_ETH_TECH_100GBASE_SR2 0x1c +/* enum: 100GBASE-R PCS/PMA over 2 lane shielded copper balanced cable PMD. See +* IEEE 802.3 Clause 136 +*/ +#define MC_CMD_ETH_TECH_100GBASE_CR2 0x1d +/* enum: Unknown source */ +#define MC_CMD_ETH_TECH_100GBASE_LR2_ER2_FR2 0x1e +/* enum: Unknown source */ +#define MC_CMD_ETH_TECH_100GBASE_DR2 0x1f +/* enum: 200GBASE-R PCS/PMA over an electrical backplane PMD. See IEEE 802.3 +* Clause 137 +*/ +#define MC_CMD_ETH_TECH_200GBASE_KR4 0x20 +/* enum: 200GBASE-R PCS/PMA over 4 lane multimode fiber PMD. See IEEE 802.3 +* Clause 138 +*/ +#define MC_CMD_ETH_TECH_200GBASE_SR4 0x21 +/* enum: 200GBASE-R PCS/PMA over 4 WDM lane single-mode fiber PMD as specified +* in Clause 122 +*/ +#define MC_CMD_ETH_TECH_200GBASE_LR4_ER4_FR4 0x22 +/* enum: 200GBASE-R PCS/PMA over 4-lane single-mode fiber PMD. See IEEE 802.3 +* Clause 121 +*/ +#define MC_CMD_ETH_TECH_200GBASE_DR4 0x23 +/* enum: 200GBASE-R PCS/PMA over 4 lane shielded copper balanced cable PMD as +* specified in Clause 136 +*/ +#define MC_CMD_ETH_TECH_200GBASE_CR4 0x24 +/* enum: Ethernet Technology Consortium 400G AN Spec. 400GBASE-KR8 PMD uses +* 802.3 Clause 137, but the number PMD lanes is 8. +*/ +#define MC_CMD_ETH_TECH_400GBASE_KR8 0x25 +/* enum: 400GBASE-R PCS/PMA over 8-lane multimode fiber PMD. See IEEE 802.3 +* Clause 138 +*/ +#define MC_CMD_ETH_TECH_400GBASE_SR8 0x26 +/* enum: 400GBASE-R PCS/PMA over 8 WDM lane single-mode fiber PMD. See IEEE +* 802.3 Clause 122 +*/ +#define MC_CMD_ETH_TECH_400GBASE_LR8_ER8_FR8 0x27 +/* enum: Unknown source */ +#define MC_CMD_ETH_TECH_400GBASE_DR8 0x28 +/* enum: Ethernet Technology Consortium 400G AN Spec. 400GBASE-CR8 PMD uses +* IEEE 802.3 Clause 136, but the number PMD lanes is 8. +*/ +#define MC_CMD_ETH_TECH_400GBASE_CR8 0x29 +/* enum: 100GBASE-R PCS/PMA over an electrical backplane PMD. See IEEE 802.3ck +* Clause 163. +*/ +#define MC_CMD_ETH_TECH_100GBASE_KR 0x2a +/* enum: IEEE 802.3ck. 100G PHY with PMD as specified in Clause 167 over short +* reach fiber +*/ +#define MC_CMD_ETH_TECH_100GBASE_SR 0x2b +/* enum: 100G PMD together with single-mode fiber medium. See IEEE 802.3 Clause +* 140 +*/ +#define MC_CMD_ETH_TECH_100GBASE_LR_ER_FR 0x2c +/* enum: 100GBASE-R PCS/PMA over shielded balanced copper cable PMD. See IEEE +* 802.3 in Clause 162 IEEE 802.3ck. +*/ +#define MC_CMD_ETH_TECH_100GBASE_CR 0x2d +/* enum: 100G PMD together with single-mode fiber medium. See IEEE 802.3 Clause +* 140 +*/ +#define MC_CMD_ETH_TECH_100GBASE_DR 0x2e +/* enum: 200GBASE-R PCS/PMA over an electrical backplane PMD as specified in +* Clause 163 IEEE 802.3ck +*/ +#define MC_CMD_ETH_TECH_200GBASE_KR2 0x2f +/* enum: 200G PHY with PMD as specified in Clause 167 over short reach fiber +* IEEE 802.3ck +*/ +#define MC_CMD_ETH_TECH_200GBASE_SR2 0x30 +/* enum: Unknown source */ +#define MC_CMD_ETH_TECH_200GBASE_LR2_ER2_FR2 0x31 +/* enum: Unknown source */ +#define MC_CMD_ETH_TECH_200GBASE_DR2 0x32 +/* enum: 200GBASE-R PCS/PMA over 2 lane shielded balanced copper cable PMD as +* specified in Clause 162 IEEE 802.3ck. +*/ +#define MC_CMD_ETH_TECH_200GBASE_CR2 0x33 +/* enum: 400GBASE-R PCS/PMA over an electrical backplane PMD. See IEEE 802.3 +* Clause 163 IEEE 802.3ck. +*/ +#define MC_CMD_ETH_TECH_400GBASE_KR4 0x34 +/* enum: 400G PHY with PMD over short reach fiber. See Clause 167 of IEEE +* 802.3ck. +*/ +#define MC_CMD_ETH_TECH_400GBASE_SR4 0x35 +/* enum: 400GBASE-R PCS/PMA over 4 WDM lane single-mode fiber PMD. See IEEE +* 802.3 Clause 151 +*/ +#define MC_CMD_ETH_TECH_400GBASE_LR4_ER4_FR4 0x36 +/* enum: 400GBASE-R PCS/PMA over 4-lane single-mode fiber PMD as specified in +* Clause 124 +*/ +#define MC_CMD_ETH_TECH_400GBASE_DR4 0x37 +/* enum: 400GBASE-R PCS/PMA over 4 lane shielded balanced copper cable PMD as +* specified in Clause 162 of IEEE 802.3ck. +*/ +#define MC_CMD_ETH_TECH_400GBASE_CR4 0x38 +/* enum: Automatic tech mode. The driver must not use this. */ +#define MC_CMD_ETH_TECH_AUTO 0x39 +/* enum: See IEEE 802.3cc-2017 Clause 114 */ +#define MC_CMD_ETH_TECH_25GBASE_LR_ER 0x3a +/* enum: Up to 7 m over twinaxial copper cable assembly (10 lanes, 10 Gbit/s +* each) See IEEE 802.3ba-2010 Clause 85 +*/ +#define MC_CMD_ETH_TECH_100GBASE_CR10 0x3b +/* enum: Invalid tech mode. The driver must not use this. */ +#define MC_CMD_ETH_TECH_NONE 0x7f +#define MC_CMD_ETH_TECH_TECH_LBN 0 +#define MC_CMD_ETH_TECH_TECH_WIDTH 128 + +/* MC_CMD_LINK_STATUS_FLAGS structuredef */ +#define MC_CMD_LINK_STATUS_FLAGS_LEN 8 +/* Flags used to report the current configuration/state of the link. */ +#define MC_CMD_LINK_STATUS_FLAGS_STATUS_FLAGS_OFST 0 +#define MC_CMD_LINK_STATUS_FLAGS_STATUS_FLAGS_LEN 8 +#define MC_CMD_LINK_STATUS_FLAGS_STATUS_FLAGS_LO_OFST 0 +#define MC_CMD_LINK_STATUS_FLAGS_STATUS_FLAGS_LO_LEN 4 +#define MC_CMD_LINK_STATUS_FLAGS_STATUS_FLAGS_LO_LBN 0 +#define MC_CMD_LINK_STATUS_FLAGS_STATUS_FLAGS_LO_WIDTH 32 +#define MC_CMD_LINK_STATUS_FLAGS_STATUS_FLAGS_HI_OFST 4 +#define MC_CMD_LINK_STATUS_FLAGS_STATUS_FLAGS_HI_LEN 4 +#define MC_CMD_LINK_STATUS_FLAGS_STATUS_FLAGS_HI_LBN 32 +#define MC_CMD_LINK_STATUS_FLAGS_STATUS_FLAGS_HI_WIDTH 32 +/* enum property: bitshift */ +/* enum: Whether we have overall link up */ +#define MC_CMD_LINK_STATUS_FLAGS_LINK_UP 0x0 +/* enum: If set, the PHY has no external RX link synchronisation */ +#define MC_CMD_LINK_STATUS_FLAGS_NO_PHY_LINK 0x1 +/* enum: If set, PMD/MDI is not connected (e.g. cable disconnected, module cage +* empty) +*/ +#define MC_CMD_LINK_STATUS_FLAGS_PMD_MDI_DISCONNECTED 0x2 +/* enum: Set on error while decoding module data (e.g. module EEPROM does not +* contain valid values, has checksum errors, etc.) +*/ +#define MC_CMD_LINK_STATUS_FLAGS_PMD_BAD 0x3 +/* enum: Set when module unsupported (e.g. unsupported link rate or link +* technology) +*/ +#define MC_CMD_LINK_STATUS_FLAGS_PMD_UNSUPPORTED 0x4 +/* enum: Set on error while communicating with the module (e.g. I2C errors +* while reading EEPROM) +*/ +#define MC_CMD_LINK_STATUS_FLAGS_PMD_COMMS_FAULT 0x5 +/* enum: Set on module overcurrent/overvoltage condition */ +#define MC_CMD_LINK_STATUS_FLAGS_PMD_POWER_FAULT 0x6 +/* enum: Set on module overtemperature condition */ +#define MC_CMD_LINK_STATUS_FLAGS_PMD_THERMAL_FAULT 0x7 +/* enum: If set, the module is indicating Loss of Signal */ +#define MC_CMD_LINK_STATUS_FLAGS_PMD_LOS 0x8 +/* enum: If set, PMA is indicating loss of CDR lock (clock sync) */ +#define MC_CMD_LINK_STATUS_FLAGS_PMA_NO_CDR_LOCK 0x9 +/* enum: If set, PMA is indicating loss of analog signal */ +#define MC_CMD_LINK_STATUS_FLAGS_PMA_LOS 0xa +/* enum: If set, PCS is indicating loss of block lock */ +#define MC_CMD_LINK_STATUS_FLAGS_PCS_NO_BLOCK_LOCK 0xb +/* enum: If set, PCS is indicating loss of alignment marker lock on one or more +* lanes +*/ +#define MC_CMD_LINK_STATUS_FLAGS_PCS_NO_AM_LOCK 0xc +/* enum: If set, PCS is indicating loss of overall alignment lock */ +#define MC_CMD_LINK_STATUS_FLAGS_PCS_NO_ALIGN_LOCK 0xd +/* enum: If set, PCS is indicating high bit error rate condition. */ +#define MC_CMD_LINK_STATUS_FLAGS_PCS_HI_BER 0xe +/* enum: If set, FEC is indicating loss of FEC lock */ +#define MC_CMD_LINK_STATUS_FLAGS_FEC_NO_LOCK 0xf +/* enum: If set, indicates that the number of symbol errors in a 8192-codeword +* window has exceeded the threshold K (417). +*/ +#define MC_CMD_LINK_STATUS_FLAGS_FEC_HI_SER 0x10 +/* enum: If set, the receiver has detected the local FEC has degraded. */ +#define MC_CMD_LINK_STATUS_FLAGS_FEC_LOCAL_DEGRADED 0x11 +/* enum: If set, the receiver has detected the remote FEC has degraded. */ +#define MC_CMD_LINK_STATUS_FLAGS_FEC_RM_DEGRADED 0x12 +/* enum: If set, the number of symbol errors is over an internal threshold. */ +#define MC_CMD_LINK_STATUS_FLAGS_FEC_DEGRADED_SER 0x13 +/* enum: If set, autonegotiation has detected an auto-negotiation capable link +* partner +*/ +#define MC_CMD_LINK_STATUS_FLAGS_AN_ABLE 0x14 +/* enum: If set, autonegotiation base page exchange has failed */ +#define MC_CMD_LINK_STATUS_FLAGS_AN_BP_FAILED 0x15 +/* enum: If set, autonegotiation next page exchange has failed */ +#define MC_CMD_LINK_STATUS_FLAGS_AN_NP_FAILED 0x16 +/* enum: If set, autonegotiation has failed to negotiate a common set of +* capabilities +*/ +#define MC_CMD_LINK_STATUS_FLAGS_AN_NO_HCD 0x17 +/* enum: If set, local end link training has failed to establish link training +* frame lock on one or more lanes +*/ +#define MC_CMD_LINK_STATUS_FLAGS_LT_NO_LOCAL_FRAME_LOCK 0x18 +/* enum: If set, remote end link training has failed to establish link training +* frame lock on one or more lanes +*/ +#define MC_CMD_LINK_STATUS_FLAGS_LT_NO_RM_FRAME_LOCK 0x19 +/* enum: If set, remote end has failed to assert Receiver Ready (link training +* success) within the designated timeout +*/ +#define MC_CMD_LINK_STATUS_FLAGS_LT_NO_RX_READY 0x1a +#define MC_CMD_LINK_STATUS_FLAGS_STATUS_FLAGS_LBN 0 +#define MC_CMD_LINK_STATUS_FLAGS_STATUS_FLAGS_WIDTH 64 + +/* MC_CMD_PAUSE_MODE structuredef */ +#define MC_CMD_PAUSE_MODE_LEN 1 +#define MC_CMD_PAUSE_MODE_TYPE_OFST 0 +#define MC_CMD_PAUSE_MODE_TYPE_LEN 1 +/* enum: See IEEE 802.3 Clause 73.6.6 */ +#define MC_CMD_PAUSE_MODE_AN_PAUSE 0x0 +/* enum: See IEEE 802.3 Clause 73.6.6 */ +#define MC_CMD_PAUSE_MODE_AN_ASYM_DIR 0x1 +#define MC_CMD_PAUSE_MODE_TYPE_LBN 0 +#define MC_CMD_PAUSE_MODE_TYPE_WIDTH 8 + +/* MC_CMD_ETH_AN_FIELDS structuredef: Fields used for IEEE 802.3 Clause 73 +* Auto-Negotiation. Warning - This is fixed size and cannot be extended. This +* structure is used to define autonegotiable abilities (advertised, link +* partner and supported abilities). +*/ +#define MC_CMD_ETH_AN_FIELDS_LEN 25 +/* Mask of Ethernet technologies. The bit indices in this mask are taken from +* the TECH field in the MC_CMD_ETH_TECH structure. +*/ +#define MC_CMD_ETH_AN_FIELDS_TECH_MASK_OFST 0 +#define MC_CMD_ETH_AN_FIELDS_TECH_MASK_LEN 16 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* MC_CMD_ETH_TECH/TECH */ +#define MC_CMD_ETH_AN_FIELDS_TECH_MASK_LBN 0 +#define MC_CMD_ETH_AN_FIELDS_TECH_MASK_WIDTH 128 +/* Mask of supported FEC modes */ +#define MC_CMD_ETH_AN_FIELDS_FEC_MASK_OFST 16 +#define MC_CMD_ETH_AN_FIELDS_FEC_MASK_LEN 4 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* FEC_TYPE/TYPE */ +#define MC_CMD_ETH_AN_FIELDS_FEC_MASK_LBN 128 +#define MC_CMD_ETH_AN_FIELDS_FEC_MASK_WIDTH 32 +/* Mask of requested FEC modes */ +#define MC_CMD_ETH_AN_FIELDS_FEC_REQ_OFST 20 +#define MC_CMD_ETH_AN_FIELDS_FEC_REQ_LEN 4 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* FEC_TYPE/TYPE */ +#define MC_CMD_ETH_AN_FIELDS_FEC_REQ_LBN 160 +#define MC_CMD_ETH_AN_FIELDS_FEC_REQ_WIDTH 32 +/* Bitmask of negotiated pause modes */ +#define MC_CMD_ETH_AN_FIELDS_PAUSE_MASK_OFST 24 +#define MC_CMD_ETH_AN_FIELDS_PAUSE_MASK_LEN 1 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* MC_CMD_PAUSE_MODE/TYPE */ +#define MC_CMD_ETH_AN_FIELDS_PAUSE_MASK_LBN 192 +#define MC_CMD_ETH_AN_FIELDS_PAUSE_MASK_WIDTH 8 + +/* MC_CMD_LOOPBACK_V2 structuredef: Loopback modes for use with the new +* MC_CMD_LINK_CTRL and MC_CMD_LINK_STATE. These loopback modes are not +* supported in other getlink/setlink commands. +*/ +#define MC_CMD_LOOPBACK_V2_LEN 4 +#define MC_CMD_LOOPBACK_V2_MODE_OFST 0 +#define MC_CMD_LOOPBACK_V2_MODE_LEN 4 +/* enum: No loopback */ +#define MC_CMD_LOOPBACK_V2_NONE 0x0 +/* enum: Let firmware choose a supported loopback mode */ +#define MC_CMD_LOOPBACK_V2_AUTO 0x1 +/* enum: Loopback after the MAC */ +#define MC_CMD_LOOPBACK_V2_POST_MAC 0x2 +/* enum: Loopback after the PCS */ +#define MC_CMD_LOOPBACK_V2_POST_PCS 0x3 +/* enum: Loopback after the PMA */ +#define MC_CMD_LOOPBACK_V2_POST_PMA 0x4 +/* enum: Loopback after the MDI Wireside */ +#define MC_CMD_LOOPBACK_V2_POST_MDI_WS 0x5 +/* enum: Loopback after the PMA Wireside */ +#define MC_CMD_LOOPBACK_V2_POST_PMA_WS 0x6 +/* enum: Loopback after the PCS Wireside */ +#define MC_CMD_LOOPBACK_V2_POST_PCS_WS 0x7 +/* enum: Loopback after the MAC Wireside */ +#define MC_CMD_LOOPBACK_V2_POST_MAC_WS 0x8 +/* enum: Loopback after the MAC FIFOs (before the MAC) */ +#define MC_CMD_LOOPBACK_V2_PRE_MAC 0x9 +#define MC_CMD_LOOPBACK_V2_MODE_LBN 0 +#define MC_CMD_LOOPBACK_V2_MODE_WIDTH 32 + +/* MC_CMD_FCNTL structuredef */ +#define MC_CMD_FCNTL_LEN 4 +#define MC_CMD_FCNTL_MASK_OFST 0 +#define MC_CMD_FCNTL_MASK_LEN 4 +/* enum: Flow control is off. */ +#define MC_CMD_FCNTL_OFF 0x0 +/* enum: Respond to flow control. */ +#define MC_CMD_FCNTL_RESPOND 0x1 +/* enum: Respond to and Issue flow control. */ +#define MC_CMD_FCNTL_BIDIR 0x2 +/* enum: Auto negotiate flow control. */ +#define MC_CMD_FCNTL_AUTO 0x3 +/* enum: Priority flow control. This is only supported on KSB. */ +#define MC_CMD_FCNTL_QBB 0x4 +/* enum: Issue flow control. */ +#define MC_CMD_FCNTL_GENERATE 0x5 +#define MC_CMD_FCNTL_MASK_LBN 0 +#define MC_CMD_FCNTL_MASK_WIDTH 32 + +/* MC_CMD_LINK_FLAGS structuredef */ +#define MC_CMD_LINK_FLAGS_LEN 4 +/* The enums defined in this field are used as indices into the +* MC_CMD_LINK_FLAGS bitmask. +*/ +#define MC_CMD_LINK_FLAGS_MASK_OFST 0 +#define MC_CMD_LINK_FLAGS_MASK_LEN 4 +/* enum property: bitshift */ +/* enum: Enable auto-negotiation. If AN is enabled, link technology and FEC +* mode are determined by advertised capabilities and requested FEC modes, +* combined with link partner capabilities. If AN is disabled, link technology +* is forced to LINK_TECHNOLOGY and FEC mode is forced to FEC_MODE. Not valid +* if loopback is enabled +*/ +#define MC_CMD_LINK_FLAGS_AUTONEG_EN 0x0 +/* enum: Enable parallel detect. In addition to AN, try to sense partner forced +* speed/FEC mode (when partner AN disabled). Only valid if AN is enabled. +*/ +#define MC_CMD_LINK_FLAGS_PARALLEL_DETECT_EN 0x1 +/* enum: Force link down, in electrical idle. */ +#define MC_CMD_LINK_FLAGS_LINK_DISABLE 0x2 +/* enum: Ignore the sequence number and always apply. */ +#define MC_CMD_LINK_FLAGS_IGNORE_MODULE_SEQ 0x3 +#define MC_CMD_LINK_FLAGS_MASK_LBN 0 +#define MC_CMD_LINK_FLAGS_MASK_WIDTH 32 + + +/***********************************/ +/* MC_CMD_LINK_CTRL +* Write the unified MAC/PHY link configuration. Locks required: None. Return +* code: 0, EINVAL, ETIME, EAGAIN +*/ +#define MC_CMD_LINK_CTRL 0x6b +#undef MC_CMD_0x6b_PRIVILEGE_CTG + +#define MC_CMD_0x6b_PRIVILEGE_CTG SRIOV_CTG_LINK + +/* MC_CMD_LINK_CTRL_IN msgrequest */ +#define MC_CMD_LINK_CTRL_IN_LEN 40 +/* Handle to the port to set link state for. */ +#define MC_CMD_LINK_CTRL_IN_PORT_HANDLE_OFST 0 +#define MC_CMD_LINK_CTRL_IN_PORT_HANDLE_LEN 4 +/* Control flags */ +#define MC_CMD_LINK_CTRL_IN_CONTROL_FLAGS_OFST 4 +#define MC_CMD_LINK_CTRL_IN_CONTROL_FLAGS_LEN 4 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* MC_CMD_LINK_FLAGS/MASK */ +/* Reserved for future expansion, and included to provide padding for alignment +* purposes. +*/ +#define MC_CMD_LINK_CTRL_IN_RESERVED_OFST 8 +#define MC_CMD_LINK_CTRL_IN_RESERVED_LEN 8 +#define MC_CMD_LINK_CTRL_IN_RESERVED_LO_OFST 8 +#define MC_CMD_LINK_CTRL_IN_RESERVED_LO_LEN 4 +#define MC_CMD_LINK_CTRL_IN_RESERVED_LO_LBN 64 +#define MC_CMD_LINK_CTRL_IN_RESERVED_LO_WIDTH 32 +#define MC_CMD_LINK_CTRL_IN_RESERVED_HI_OFST 12 +#define MC_CMD_LINK_CTRL_IN_RESERVED_HI_LEN 4 +#define MC_CMD_LINK_CTRL_IN_RESERVED_HI_LBN 96 +#define MC_CMD_LINK_CTRL_IN_RESERVED_HI_WIDTH 32 +/* Technology abilities to advertise during auto-negotiation */ +#define MC_CMD_LINK_CTRL_IN_ADVERTISED_TECH_ABILITIES_MASK_OFST 16 +#define MC_CMD_LINK_CTRL_IN_ADVERTISED_TECH_ABILITIES_MASK_LEN 16 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* MC_CMD_ETH_TECH/TECH */ +/* Pause abilities to advertise during auto-negotiation. Valid when auto- +* negotation is enabled and MC_CMD_SET_MAC_IN/FCTL is set to +* MC_CMD_FCNTL_AUTO. If auto-negotiation is disabled the driver must +* explicitly configure pause mode with MC_CMD_SET_MAC. +*/ +#define MC_CMD_LINK_CTRL_IN_ADVERTISED_PAUSE_ABILITIES_MASK_OFST 32 +#define MC_CMD_LINK_CTRL_IN_ADVERTISED_PAUSE_ABILITIES_MASK_LEN 1 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* MC_CMD_PAUSE_MODE/TYPE */ +/* When auto-negotiation is enabled, this is the FEC mode to request. Note that +* a weaker FEC mode may get negotiated, depending on what the link partner +* supports. The driver should subsequently use MC_CMD_GET_LINK to check the +* actual negotiated FEC mode. When auto-negotiation is disabled, this is the +* forced FEC mode. +*/ +#define MC_CMD_LINK_CTRL_IN_FEC_MODE_OFST 33 +#define MC_CMD_LINK_CTRL_IN_FEC_MODE_LEN 1 +/* enum property: value */ +/* Enum values, see field(s): */ +/* FEC_TYPE/TYPE */ +/* This is only to be used when auto-negotiation is disabled (forced speed or +* loopback mode). If the specified value does not align with the values +* defined in the enum MC_CMD_ETH_TECH/TECH, it is considered invalid. +*/ +#define MC_CMD_LINK_CTRL_IN_LINK_TECHNOLOGY_OFST 36 +#define MC_CMD_LINK_CTRL_IN_LINK_TECHNOLOGY_LEN 2 +/* enum property: value */ +/* Enum values, see field(s): */ +/* MC_CMD_ETH_TECH/TECH */ +/* The sequence number of the last MODULECHANGE event. If this doesn't match, +* fail with EAGAIN. +*/ +#define MC_CMD_LINK_CTRL_IN_MODULE_SEQ_OFST 38 +#define MC_CMD_LINK_CTRL_IN_MODULE_SEQ_LEN 1 +/* Loopback Mode. Only valid when auto-negotiation is disabled. */ +#define MC_CMD_LINK_CTRL_IN_LOOPBACK_OFST 39 +#define MC_CMD_LINK_CTRL_IN_LOOPBACK_LEN 1 +/* enum property: value */ +/* Enum values, see field(s): */ +/* MC_CMD_LOOPBACK_V2/MODE */ + +/* MC_CMD_LINK_CTRL_OUT msgresponse */ +#define MC_CMD_LINK_CTRL_OUT_LEN 0 + + +/***********************************/ +/* MC_CMD_LINK_STATE +*/ +#define MC_CMD_LINK_STATE 0x6c +#undef MC_CMD_0x6c_PRIVILEGE_CTG + +#define MC_CMD_0x6c_PRIVILEGE_CTG SRIOV_CTG_LINK + +/* MC_CMD_LINK_STATE_IN msgrequest */ +#define MC_CMD_LINK_STATE_IN_LEN 4 +/* Handle to the port to get link state for. */ +#define MC_CMD_LINK_STATE_IN_PORT_HANDLE_OFST 0 +#define MC_CMD_LINK_STATE_IN_PORT_HANDLE_LEN 4 + +/* MC_CMD_LINK_STATE_OUT msgresponse */ +#define MC_CMD_LINK_STATE_OUT_LEN 114 +/* Flags used to report the current configuration/state of the link. */ +#define MC_CMD_LINK_STATE_OUT_STATUS_FLAGS_OFST 0 +#define MC_CMD_LINK_STATE_OUT_STATUS_FLAGS_LEN 8 +#define MC_CMD_LINK_STATE_OUT_STATUS_FLAGS_LO_OFST 0 +#define MC_CMD_LINK_STATE_OUT_STATUS_FLAGS_LO_LEN 4 +#define MC_CMD_LINK_STATE_OUT_STATUS_FLAGS_LO_LBN 0 +#define MC_CMD_LINK_STATE_OUT_STATUS_FLAGS_LO_WIDTH 32 +#define MC_CMD_LINK_STATE_OUT_STATUS_FLAGS_HI_OFST 4 +#define MC_CMD_LINK_STATE_OUT_STATUS_FLAGS_HI_LEN 4 +#define MC_CMD_LINK_STATE_OUT_STATUS_FLAGS_HI_LBN 32 +#define MC_CMD_LINK_STATE_OUT_STATUS_FLAGS_HI_WIDTH 32 +/* enum property: value */ +/* Enum values, see field(s): */ +/* MC_CMD_LINK_STATUS_FLAGS/STATUS_FLAGS */ +/* Configured technology. If the specified value does not align with the values +* defined in the enum MC_CMD_ETH_TECH/TECH, it is considered invalid. +*/ +#define MC_CMD_LINK_STATE_OUT_LINK_TECHNOLOGY_OFST 8 +#define MC_CMD_LINK_STATE_OUT_LINK_TECHNOLOGY_LEN 2 +/* enum property: value */ +/* Enum values, see field(s): */ +/* MC_CMD_ETH_TECH/TECH */ +/* Configured FEC mode */ +#define MC_CMD_LINK_STATE_OUT_FEC_MODE_OFST 10 +#define MC_CMD_LINK_STATE_OUT_FEC_MODE_LEN 1 +/* enum property: value */ +/* Enum values, see field(s): */ +/* FEC_TYPE/TYPE */ +/* Bitmask of auto-negotiated pause modes */ +#define MC_CMD_LINK_STATE_OUT_PAUSE_MASK_OFST 11 +#define MC_CMD_LINK_STATE_OUT_PAUSE_MASK_LEN 1 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* MC_CMD_PAUSE_MODE/TYPE */ +/* Configured loopback mode */ +#define MC_CMD_LINK_STATE_OUT_LOOPBACK_OFST 12 +#define MC_CMD_LINK_STATE_OUT_LOOPBACK_LEN 1 +/* enum property: value */ +/* Enum values, see field(s): */ +/* MC_CMD_LOOPBACK_V2/MODE */ +/* Abilities requested by the driver to advertise during auto-negotiation */ +#define MC_CMD_LINK_STATE_OUT_ADVERTISED_ABILITIES_OFST 16 +#define MC_CMD_LINK_STATE_OUT_ADVERTISED_ABILITIES_LEN 32 +/* See structuredef: MC_CMD_ETH_AN_FIELDS */ +#define MC_CMD_LINK_STATE_OUT_ADVERTISED_ABILITIES_TECH_MASK_OFST 16 +#define MC_CMD_LINK_STATE_OUT_ADVERTISED_ABILITIES_TECH_MASK_LEN 16 +#define MC_CMD_LINK_STATE_OUT_ADVERTISED_ABILITIES_FEC_MASK_OFST 32 +#define MC_CMD_LINK_STATE_OUT_ADVERTISED_ABILITIES_FEC_MASK_LEN 4 +#define MC_CMD_LINK_STATE_OUT_ADVERTISED_ABILITIES_FEC_REQ_OFST 36 +#define MC_CMD_LINK_STATE_OUT_ADVERTISED_ABILITIES_FEC_REQ_LEN 4 +#define MC_CMD_LINK_STATE_OUT_ADVERTISED_ABILITIES_PAUSE_MASK_OFST 40 +#define MC_CMD_LINK_STATE_OUT_ADVERTISED_ABILITIES_PAUSE_MASK_LEN 1 +/* Abilities advertised by the link partner during auto-negotiation */ +#define MC_CMD_LINK_STATE_OUT_LINK_PARTNER_ABILITIES_OFST 48 +#define MC_CMD_LINK_STATE_OUT_LINK_PARTNER_ABILITIES_LEN 32 +/* See structuredef: MC_CMD_ETH_AN_FIELDS */ +#define MC_CMD_LINK_STATE_OUT_LINK_PARTNER_ABILITIES_TECH_MASK_OFST 48 +#define MC_CMD_LINK_STATE_OUT_LINK_PARTNER_ABILITIES_TECH_MASK_LEN 16 +#define MC_CMD_LINK_STATE_OUT_LINK_PARTNER_ABILITIES_FEC_MASK_OFST 64 +#define MC_CMD_LINK_STATE_OUT_LINK_PARTNER_ABILITIES_FEC_MASK_LEN 4 +#define MC_CMD_LINK_STATE_OUT_LINK_PARTNER_ABILITIES_FEC_REQ_OFST 68 +#define MC_CMD_LINK_STATE_OUT_LINK_PARTNER_ABILITIES_FEC_REQ_LEN 4 +#define MC_CMD_LINK_STATE_OUT_LINK_PARTNER_ABILITIES_PAUSE_MASK_OFST 72 +#define MC_CMD_LINK_STATE_OUT_LINK_PARTNER_ABILITIES_PAUSE_MASK_LEN 1 +/* Abilities supported by the local device (including cable abilities) For +* fixed local device capbilities see MC_CMD_GET_LOCAL_DEVICE_INFO +*/ +#define MC_CMD_LINK_STATE_OUT_SUPPORTED_ABILITIES_OFST 80 +#define MC_CMD_LINK_STATE_OUT_SUPPORTED_ABILITIES_LEN 28 +/* See structuredef: MC_CMD_ETH_AN_FIELDS */ +#define MC_CMD_LINK_STATE_OUT_SUPPORTED_ABILITIES_TECH_MASK_OFST 80 +#define MC_CMD_LINK_STATE_OUT_SUPPORTED_ABILITIES_TECH_MASK_LEN 16 +#define MC_CMD_LINK_STATE_OUT_SUPPORTED_ABILITIES_FEC_MASK_OFST 96 +#define MC_CMD_LINK_STATE_OUT_SUPPORTED_ABILITIES_FEC_MASK_LEN 4 +#define MC_CMD_LINK_STATE_OUT_SUPPORTED_ABILITIES_FEC_REQ_OFST 100 +#define MC_CMD_LINK_STATE_OUT_SUPPORTED_ABILITIES_FEC_REQ_LEN 4 +#define MC_CMD_LINK_STATE_OUT_SUPPORTED_ABILITIES_PAUSE_MASK_OFST 104 +#define MC_CMD_LINK_STATE_OUT_SUPPORTED_ABILITIES_PAUSE_MASK_LEN 1 +/* Control flags */ +#define MC_CMD_LINK_STATE_OUT_CONTROL_FLAGS_OFST 108 +#define MC_CMD_LINK_STATE_OUT_CONTROL_FLAGS_LEN 4 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* MC_CMD_LINK_FLAGS/MASK */ +/* Sequence number to synchronize link change events */ +#define MC_CMD_LINK_STATE_OUT_PORT_LINKCHANGE_SEQ_NUM_OFST 112 +#define MC_CMD_LINK_STATE_OUT_PORT_LINKCHANGE_SEQ_NUM_LEN 1 +/* Sequence number to synchronize module change events */ +#define MC_CMD_LINK_STATE_OUT_PORT_MODULECHANGE_SEQ_NUM_OFST 113 +#define MC_CMD_LINK_STATE_OUT_PORT_MODULECHANGE_SEQ_NUM_LEN 1 + +/* MC_CMD_LINK_STATE_OUT_V2 msgresponse: Updated LINK_STATE_OUT with +* LOCAL_AN_SUPPORT +*/ +#define MC_CMD_LINK_STATE_OUT_V2_LEN 120 +/* Flags used to report the current configuration/state of the link. */ +#define MC_CMD_LINK_STATE_OUT_V2_STATUS_FLAGS_OFST 0 +#define MC_CMD_LINK_STATE_OUT_V2_STATUS_FLAGS_LEN 8 +#define MC_CMD_LINK_STATE_OUT_V2_STATUS_FLAGS_LO_OFST 0 +#define MC_CMD_LINK_STATE_OUT_V2_STATUS_FLAGS_LO_LEN 4 +#define MC_CMD_LINK_STATE_OUT_V2_STATUS_FLAGS_LO_LBN 0 +#define MC_CMD_LINK_STATE_OUT_V2_STATUS_FLAGS_LO_WIDTH 32 +#define MC_CMD_LINK_STATE_OUT_V2_STATUS_FLAGS_HI_OFST 4 +#define MC_CMD_LINK_STATE_OUT_V2_STATUS_FLAGS_HI_LEN 4 +#define MC_CMD_LINK_STATE_OUT_V2_STATUS_FLAGS_HI_LBN 32 +#define MC_CMD_LINK_STATE_OUT_V2_STATUS_FLAGS_HI_WIDTH 32 +/* enum property: value */ +/* Enum values, see field(s): */ +/* MC_CMD_LINK_STATUS_FLAGS/STATUS_FLAGS */ +/* Configured technology. If the specified value does not align with the values +* defined in the enum MC_CMD_ETH_TECH/TECH, it is considered invalid. +*/ +#define MC_CMD_LINK_STATE_OUT_V2_LINK_TECHNOLOGY_OFST 8 +#define MC_CMD_LINK_STATE_OUT_V2_LINK_TECHNOLOGY_LEN 2 +/* enum property: value */ +/* Enum values, see field(s): */ +/* MC_CMD_ETH_TECH/TECH */ +/* Configured FEC mode */ +#define MC_CMD_LINK_STATE_OUT_V2_FEC_MODE_OFST 10 +#define MC_CMD_LINK_STATE_OUT_V2_FEC_MODE_LEN 1 +/* enum property: value */ +/* Enum values, see field(s): */ +/* FEC_TYPE/TYPE */ +/* Bitmask of auto-negotiated pause modes */ +#define MC_CMD_LINK_STATE_OUT_V2_PAUSE_MASK_OFST 11 +#define MC_CMD_LINK_STATE_OUT_V2_PAUSE_MASK_LEN 1 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* MC_CMD_PAUSE_MODE/TYPE */ +/* Configured loopback mode */ +#define MC_CMD_LINK_STATE_OUT_V2_LOOPBACK_OFST 12 +#define MC_CMD_LINK_STATE_OUT_V2_LOOPBACK_LEN 1 +/* enum property: value */ +/* Enum values, see field(s): */ +/* MC_CMD_LOOPBACK_V2/MODE */ +/* Abilities requested by the driver to advertise during auto-negotiation */ +#define MC_CMD_LINK_STATE_OUT_V2_ADVERTISED_ABILITIES_OFST 16 +#define MC_CMD_LINK_STATE_OUT_V2_ADVERTISED_ABILITIES_LEN 32 +/* Abilities advertised by the link partner during auto-negotiation */ +#define MC_CMD_LINK_STATE_OUT_V2_LINK_PARTNER_ABILITIES_OFST 48 +#define MC_CMD_LINK_STATE_OUT_V2_LINK_PARTNER_ABILITIES_LEN 32 +/* Abilities supported by the local device (including cable abilities) For +* fixed local device capbilities see MC_CMD_GET_LOCAL_DEVICE_INFO +*/ +#define MC_CMD_LINK_STATE_OUT_V2_SUPPORTED_ABILITIES_OFST 80 +#define MC_CMD_LINK_STATE_OUT_V2_SUPPORTED_ABILITIES_LEN 28 +/* Control flags */ +#define MC_CMD_LINK_STATE_OUT_V2_CONTROL_FLAGS_OFST 108 +#define MC_CMD_LINK_STATE_OUT_V2_CONTROL_FLAGS_LEN 4 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* MC_CMD_LINK_FLAGS/MASK */ +/* Sequence number to synchronize link change events */ +#define MC_CMD_LINK_STATE_OUT_V2_PORT_LINKCHANGE_SEQ_NUM_OFST 112 +#define MC_CMD_LINK_STATE_OUT_V2_PORT_LINKCHANGE_SEQ_NUM_LEN 1 +/* Sequence number to synchronize module change events */ +#define MC_CMD_LINK_STATE_OUT_V2_PORT_MODULECHANGE_SEQ_NUM_OFST 113 +#define MC_CMD_LINK_STATE_OUT_V2_PORT_MODULECHANGE_SEQ_NUM_LEN 1 +/* Reports the auto-negotiation supported by the local device. This depends on +* the port and module properties. +*/ +#define MC_CMD_LINK_STATE_OUT_V2_LOCAL_AN_SUPPORT_OFST 116 +#define MC_CMD_LINK_STATE_OUT_V2_LOCAL_AN_SUPPORT_LEN 4 +/* Enum values, see field(s): */ +/* AN_TYPE/TYPE */ + +/* MC_CMD_LINK_STATE_OUT_V3 msgresponse: Updated LINK_STATE_OUT_V2 for explicit +* reporting of the link speed and duplex mode. +*/ +#define MC_CMD_LINK_STATE_OUT_V3_LEN 128 +/* Flags used to report the current configuration/state of the link. */ +#define MC_CMD_LINK_STATE_OUT_V3_STATUS_FLAGS_OFST 0 +#define MC_CMD_LINK_STATE_OUT_V3_STATUS_FLAGS_LEN 8 +#define MC_CMD_LINK_STATE_OUT_V3_STATUS_FLAGS_LO_OFST 0 +#define MC_CMD_LINK_STATE_OUT_V3_STATUS_FLAGS_LO_LEN 4 +#define MC_CMD_LINK_STATE_OUT_V3_STATUS_FLAGS_LO_LBN 0 +#define MC_CMD_LINK_STATE_OUT_V3_STATUS_FLAGS_LO_WIDTH 32 +#define MC_CMD_LINK_STATE_OUT_V3_STATUS_FLAGS_HI_OFST 4 +#define MC_CMD_LINK_STATE_OUT_V3_STATUS_FLAGS_HI_LEN 4 +#define MC_CMD_LINK_STATE_OUT_V3_STATUS_FLAGS_HI_LBN 32 +#define MC_CMD_LINK_STATE_OUT_V3_STATUS_FLAGS_HI_WIDTH 32 +/* enum property: value */ +/* Enum values, see field(s): */ +/* MC_CMD_LINK_STATUS_FLAGS/STATUS_FLAGS */ +/* Configured technology. If the specified value does not align with the values +* defined in the enum MC_CMD_ETH_TECH/TECH, it is considered invalid. +*/ +#define MC_CMD_LINK_STATE_OUT_V3_LINK_TECHNOLOGY_OFST 8 +#define MC_CMD_LINK_STATE_OUT_V3_LINK_TECHNOLOGY_LEN 2 +/* enum property: value */ +/* Enum values, see field(s): */ +/* MC_CMD_ETH_TECH/TECH */ +/* Configured FEC mode */ +#define MC_CMD_LINK_STATE_OUT_V3_FEC_MODE_OFST 10 +#define MC_CMD_LINK_STATE_OUT_V3_FEC_MODE_LEN 1 +/* enum property: value */ +/* Enum values, see field(s): */ +/* FEC_TYPE/TYPE */ +/* Bitmask of auto-negotiated pause modes */ +#define MC_CMD_LINK_STATE_OUT_V3_PAUSE_MASK_OFST 11 +#define MC_CMD_LINK_STATE_OUT_V3_PAUSE_MASK_LEN 1 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* MC_CMD_PAUSE_MODE/TYPE */ +/* Configured loopback mode */ +#define MC_CMD_LINK_STATE_OUT_V3_LOOPBACK_OFST 12 +#define MC_CMD_LINK_STATE_OUT_V3_LOOPBACK_LEN 1 +/* enum property: value */ +/* Enum values, see field(s): */ +/* MC_CMD_LOOPBACK_V2/MODE */ +/* Abilities requested by the driver to advertise during auto-negotiation */ +#define MC_CMD_LINK_STATE_OUT_V3_ADVERTISED_ABILITIES_OFST 16 +#define MC_CMD_LINK_STATE_OUT_V3_ADVERTISED_ABILITIES_LEN 32 +/* Abilities advertised by the link partner during auto-negotiation */ +#define MC_CMD_LINK_STATE_OUT_V3_LINK_PARTNER_ABILITIES_OFST 48 +#define MC_CMD_LINK_STATE_OUT_V3_LINK_PARTNER_ABILITIES_LEN 32 +/* Abilities supported by the local device (including cable abilities) For +* fixed local device capbilities see MC_CMD_GET_LOCAL_DEVICE_INFO +*/ +#define MC_CMD_LINK_STATE_OUT_V3_SUPPORTED_ABILITIES_OFST 80 +#define MC_CMD_LINK_STATE_OUT_V3_SUPPORTED_ABILITIES_LEN 28 +/* Control flags */ +#define MC_CMD_LINK_STATE_OUT_V3_CONTROL_FLAGS_OFST 108 +#define MC_CMD_LINK_STATE_OUT_V3_CONTROL_FLAGS_LEN 4 +/* enum property: bitshift */ +/* Enum values, see field(s): */ +/* MC_CMD_LINK_FLAGS/MASK */ +/* Sequence number to synchronize link change events */ +#define MC_CMD_LINK_STATE_OUT_V3_PORT_LINKCHANGE_SEQ_NUM_OFST 112 +#define MC_CMD_LINK_STATE_OUT_V3_PORT_LINKCHANGE_SEQ_NUM_LEN 1 +/* Sequence number to synchronize module change events */ +#define MC_CMD_LINK_STATE_OUT_V3_PORT_MODULECHANGE_SEQ_NUM_OFST 113 +#define MC_CMD_LINK_STATE_OUT_V3_PORT_MODULECHANGE_SEQ_NUM_LEN 1 +/* Reports the auto-negotiation supported by the local device. This depends on +* the port and module properties. +*/ +#define MC_CMD_LINK_STATE_OUT_V3_LOCAL_AN_SUPPORT_OFST 116 +#define MC_CMD_LINK_STATE_OUT_V3_LOCAL_AN_SUPPORT_LEN 4 +/* Enum values, see field(s): */ +/* AN_TYPE/TYPE */ +/* Autonegotiated speed in mbit/s. The link may still be down even if this +* reads non-zero. LINK_SPEED field is intended to be used by drivers without +* the most up-to-date MCDI definitions, unable to deduce the link speed from +* the reported LINK_TECHNOLOGY field. +*/ +#define MC_CMD_LINK_STATE_OUT_V3_LINK_SPEED_OFST 120 +#define MC_CMD_LINK_STATE_OUT_V3_LINK_SPEED_LEN 4 +#define MC_CMD_LINK_STATE_OUT_V3_FLAGS_OFST 124 +#define MC_CMD_LINK_STATE_OUT_V3_FLAGS_LEN 4 +#define MC_CMD_LINK_STATE_OUT_V3_FULL_DUPLEX_OFST 124 +#define MC_CMD_LINK_STATE_OUT_V3_FULL_DUPLEX_LBN 0 +#define MC_CMD_LINK_STATE_OUT_V3_FULL_DUPLEX_WIDTH 1 +/***********************************/ /* MC_CMD_GET_LINK
@@ -5694,6 +6163,54 @@/* MC_CMD_GET_LINK_IN msgrequest */ #define MC_CMD_GET_LINK_IN_LEN 0 +/* MC_CMD_GET_LINK_IN_V2 msgrequest */ +#define MC_CMD_GET_LINK_IN_V2_LEN 8 +/* Target port to request link state for. Uses MAE_LINK_ENDPOINT_SELECTOR which +* identifies a real or virtual network port by MAE port and link end. See the +* structure definition for more details. +*/ +#define MC_CMD_GET_LINK_IN_V2_TARGET_OFST 0 +#define MC_CMD_GET_LINK_IN_V2_TARGET_LEN 8 +#define MC_CMD_GET_LINK_IN_V2_TARGET_LO_OFST 0 +#define MC_CMD_GET_LINK_IN_V2_TARGET_LO_LEN 4 +#define MC_CMD_GET_LINK_IN_V2_TARGET_LO_LBN 0 +#define MC_CMD_GET_LINK_IN_V2_TARGET_LO_WIDTH 32 +#define MC_CMD_GET_LINK_IN_V2_TARGET_HI_OFST 4 +#define MC_CMD_GET_LINK_IN_V2_TARGET_HI_LEN 4 +#define MC_CMD_GET_LINK_IN_V2_TARGET_HI_LBN 32 +#define MC_CMD_GET_LINK_IN_V2_TARGET_HI_WIDTH 32 +/* See structuredef: MAE_LINK_ENDPOINT_SELECTOR */ +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_OFST 0 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_LEN 4 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_FLAT_OFST 0 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_FLAT_LEN 4 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_TYPE_OFST 3 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_TYPE_LEN 1 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_MPORT_ID_OFST 0 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_MPORT_ID_LEN 3 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_PPORT_ID_LBN 0 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_PPORT_ID_WIDTH 4 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_FUNC_INTF_ID_LBN 20 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_FUNC_INTF_ID_WIDTH 4 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_FUNC_MH_PF_ID_LBN 16 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_FUNC_MH_PF_ID_WIDTH 4 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_FUNC_PF_ID_OFST 2 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_FUNC_PF_ID_LEN 1 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_FUNC_VF_ID_OFST 0 +#define MC_CMD_GET_LINK_IN_V2_TARGET_MPORT_SELECTOR_FUNC_VF_ID_LEN 2 +#define MC_CMD_GET_LINK_IN_V2_TARGET_LINK_END_OFST 4 +#define MC_CMD_GET_LINK_IN_V2_TARGET_LINK_END_LEN 4 +#define MC_CMD_GET_LINK_IN_V2_TARGET_FLAT_OFST 0 +#define MC_CMD_GET_LINK_IN_V2_TARGET_FLAT_LEN 8 +#define MC_CMD_GET_LINK_IN_V2_TARGET_FLAT_LO_OFST 0 +#define MC_CMD_GET_LINK_IN_V2_TARGET_FLAT_LO_LEN 4 +#define MC_CMD_GET_LINK_IN_V2_TARGET_FLAT_LO_LBN 0 +#define MC_CMD_GET_LINK_IN_V2_TARGET_FLAT_LO_WIDTH 32 +#define MC_CMD_GET_LINK_IN_V2_TARGET_FLAT_HI_OFST 4 +#define MC_CMD_GET_LINK_IN_V2_TARGET_FLAT_HI_LEN 4 +#define MC_CMD_GET_LINK_IN_V2_TARGET_FLAT_HI_LBN 32 +#define MC_CMD_GET_LINK_IN_V2_TARGET_FLAT_HI_WIDTH 32 +/* MC_CMD_GET_LINK_OUT msgresponse */ #define MC_CMD_GET_LINK_OUT_LEN 28/* Near-side advertised capabilities. Refer to
@@ -5745,6 +6262,7 @@/* This returns the negotiated flow control value. */ #define MC_CMD_GET_LINK_OUT_FCNTL_OFST 20#define MC_CMD_GET_LINK_OUT_FCNTL_LEN 4 +/* enum property: value */ /* Enum values, see field(s): */ /* MC_CMD_SET_MAC/MC_CMD_SET_MAC_IN/FCNTL */ #define MC_CMD_GET_LINK_OUT_MAC_FAULT_OFST 24
@@ -5813,6 +6331,7 @@/* This returns the negotiated flow control value. */ #define MC_CMD_GET_LINK_OUT_V2_FCNTL_OFST 20#define MC_CMD_GET_LINK_OUT_V2_FCNTL_LEN 4 +/* enum property: value */ /* Enum values, see field(s): */ /* MC_CMD_SET_MAC/MC_CMD_SET_MAC_IN/FCNTL */ #define MC_CMD_GET_LINK_OUT_V2_MAC_FAULT_OFST 24
@@ -5969,6 +6488,95 @@#define MC_CMD_SET_LINK_IN_V2_MODULE_SEQ_IGNORE_LBN 7#define MC_CMD_SET_LINK_IN_V2_MODULE_SEQ_IGNORE_WIDTH 1 +/* MC_CMD_SET_LINK_IN_V3 msgrequest */ +#define MC_CMD_SET_LINK_IN_V3_LEN 28 +/* Near-side advertised capabilities. Refer to +* MC_CMD_GET_PHY_CFG_OUT/SUPPORTED_CAP for bit definitions. +*/ +#define MC_CMD_SET_LINK_IN_V3_CAP_OFST 0 +#define MC_CMD_SET_LINK_IN_V3_CAP_LEN 4 +/* Flags */ +#define MC_CMD_SET_LINK_IN_V3_FLAGS_OFST 4 +#define MC_CMD_SET_LINK_IN_V3_FLAGS_LEN 4 +#define MC_CMD_SET_LINK_IN_V3_LOWPOWER_OFST 4 +#define MC_CMD_SET_LINK_IN_V3_LOWPOWER_LBN 0 +#define MC_CMD_SET_LINK_IN_V3_LOWPOWER_WIDTH 1 +#define MC_CMD_SET_LINK_IN_V3_POWEROFF_OFST 4 +#define MC_CMD_SET_LINK_IN_V3_POWEROFF_LBN 1 +#define MC_CMD_SET_LINK_IN_V3_POWEROFF_WIDTH 1 +#define MC_CMD_SET_LINK_IN_V3_TXDIS_OFST 4 +#define MC_CMD_SET_LINK_IN_V3_TXDIS_LBN 2 +#define MC_CMD_SET_LINK_IN_V3_TXDIS_WIDTH 1 +#define MC_CMD_SET_LINK_IN_V3_LINKDOWN_OFST 4 +#define MC_CMD_SET_LINK_IN_V3_LINKDOWN_LBN 3 +#define MC_CMD_SET_LINK_IN_V3_LINKDOWN_WIDTH 1 +/* Loopback mode. */ +#define MC_CMD_SET_LINK_IN_V3_LOOPBACK_MODE_OFST 8 +#define MC_CMD_SET_LINK_IN_V3_LOOPBACK_MODE_LEN 4 +/* Enum values, see field(s): */ +/* MC_CMD_GET_LOOPBACK_MODES/MC_CMD_GET_LOOPBACK_MODES_OUT/100M */ +/* A loopback speed of "0" is supported, and means (choose any available +* speed). +*/ +#define MC_CMD_SET_LINK_IN_V3_LOOPBACK_SPEED_OFST 12 +#define MC_CMD_SET_LINK_IN_V3_LOOPBACK_SPEED_LEN 4 +#define MC_CMD_SET_LINK_IN_V3_MODULE_SEQ_OFST 16 +#define MC_CMD_SET_LINK_IN_V3_MODULE_SEQ_LEN 1 +#define MC_CMD_SET_LINK_IN_V3_MODULE_SEQ_NUMBER_OFST 16 +#define MC_CMD_SET_LINK_IN_V3_MODULE_SEQ_NUMBER_LBN 0 +#define MC_CMD_SET_LINK_IN_V3_MODULE_SEQ_NUMBER_WIDTH 7 +#define MC_CMD_SET_LINK_IN_V3_MODULE_SEQ_IGNORE_OFST 16 +#define MC_CMD_SET_LINK_IN_V3_MODULE_SEQ_IGNORE_LBN 7 +#define MC_CMD_SET_LINK_IN_V3_MODULE_SEQ_IGNORE_WIDTH 1 +/* Padding */ +#define MC_CMD_SET_LINK_IN_V3_RESERVED_OFST 17 +#define MC_CMD_SET_LINK_IN_V3_RESERVED_LEN 3 +/* Target port to set link state for. Uses MAE_LINK_ENDPOINT_SELECTOR which +* identifies a real or virtual network port by MAE port and link end. See the +* structure definition for more details +*/ +#define MC_CMD_SET_LINK_IN_V3_TARGET_OFST 20 +#define MC_CMD_SET_LINK_IN_V3_TARGET_LEN 8 +#define MC_CMD_SET_LINK_IN_V3_TARGET_LO_OFST 20 +#define MC_CMD_SET_LINK_IN_V3_TARGET_LO_LEN 4 +#define MC_CMD_SET_LINK_IN_V3_TARGET_LO_LBN 160 +#define MC_CMD_SET_LINK_IN_V3_TARGET_LO_WIDTH 32 +#define MC_CMD_SET_LINK_IN_V3_TARGET_HI_OFST 24 +#define MC_CMD_SET_LINK_IN_V3_TARGET_HI_LEN 4 +#define MC_CMD_SET_LINK_IN_V3_TARGET_HI_LBN 192 +#define MC_CMD_SET_LINK_IN_V3_TARGET_HI_WIDTH 32 +/* See structuredef: MAE_LINK_ENDPOINT_SELECTOR */ +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_OFST 20 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_LEN 4 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_FLAT_OFST 20 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_FLAT_LEN 4 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_TYPE_OFST 23 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_TYPE_LEN 1 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_MPORT_ID_OFST 20 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_MPORT_ID_LEN 3 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_PPORT_ID_LBN 160 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_PPORT_ID_WIDTH 4 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_FUNC_INTF_ID_LBN 180 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_FUNC_INTF_ID_WIDTH 4 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_FUNC_MH_PF_ID_LBN 176 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_FUNC_MH_PF_ID_WIDTH 4 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_FUNC_PF_ID_OFST 22 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_FUNC_PF_ID_LEN 1 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_FUNC_VF_ID_OFST 20 +#define MC_CMD_SET_LINK_IN_V3_TARGET_MPORT_SELECTOR_FUNC_VF_ID_LEN 2 +#define MC_CMD_SET_LINK_IN_V3_TARGET_LINK_END_OFST 24 +#define MC_CMD_SET_LINK_IN_V3_TARGET_LINK_END_LEN 4 +#define MC_CMD_SET_LINK_IN_V3_TARGET_FLAT_OFST 20 +#define MC_CMD_SET_LINK_IN_V3_TARGET_FLAT_LEN 8 +#define MC_CMD_SET_LINK_IN_V3_TARGET_FLAT_LO_OFST 20 +#define MC_CMD_SET_LINK_IN_V3_TARGET_FLAT_LO_LEN 4 +#define MC_CMD_SET_LINK_IN_V3_TARGET_FLAT_LO_LBN 160 +#define MC_CMD_SET_LINK_IN_V3_TARGET_FLAT_LO_WIDTH 32 +#define MC_CMD_SET_LINK_IN_V3_TARGET_FLAT_HI_OFST 24 +#define MC_CMD_SET_LINK_IN_V3_TARGET_FLAT_HI_LEN 4 +#define MC_CMD_SET_LINK_IN_V3_TARGET_FLAT_HI_LBN 192 +#define MC_CMD_SET_LINK_IN_V3_TARGET_FLAT_HI_WIDTH 32 +/* MC_CMD_SET_LINK_OUT msgresponse */ #define MC_CMD_SET_LINK_OUT_LEN 0
@@ -6034,17 +6642,17 @@#define MC_CMD_SET_MAC_IN_FCNTL_OFST 20#define MC_CMD_SET_MAC_IN_FCNTL_LEN 4/* enum: Flow control is off. */ -#define MC_CMD_FCNTL_OFF 0x0 +/* MC_CMD_FCNTL_OFF 0x0 */ /* enum: Respond to flow control. */ -#define MC_CMD_FCNTL_RESPOND 0x1 +/* MC_CMD_FCNTL_RESPOND 0x1 */ /* enum: Respond to and Issue flow control. */ -#define MC_CMD_FCNTL_BIDIR 0x2 -/* enum: Auto neg flow control. */ -#define MC_CMD_FCNTL_AUTO 0x3 -/* enum: Priority flow control (eftest builds only). */ -#define MC_CMD_FCNTL_QBB 0x4 +/* MC_CMD_FCNTL_BIDIR 0x2 */ +/* enum: Auto negotiate flow control. */ +/* MC_CMD_FCNTL_AUTO 0x3 */ +/* enum: Priority flow control. This is only supported on KSB. */ +/* MC_CMD_FCNTL_QBB 0x4 */ /* enum: Issue flow control. */ -#define MC_CMD_FCNTL_GENERATE 0x5 +/* MC_CMD_FCNTL_GENERATE 0x5 */ #define MC_CMD_SET_MAC_IN_FLAGS_OFST 24#define MC_CMD_SET_MAC_IN_FLAGS_LEN 4#define MC_CMD_SET_MAC_IN_FLAG_INCLUDE_FCS_OFST 24
@@ -6086,9 +6694,9 @@/* MC_CMD_FCNTL_RESPOND 0x1 */ /* enum: Respond to and Issue flow control. */ /* MC_CMD_FCNTL_BIDIR 0x2 */ -/* enum: Auto neg flow control. */ +/* enum: Auto negotiate flow control. */ /* MC_CMD_FCNTL_AUTO 0x3 */ -/* enum: Priority flow control (eftest builds only). */ +/* enum: Priority flow control. This is only supported on KSB. */ /* MC_CMD_FCNTL_QBB 0x4 */ /* enum: Issue flow control. */ /* MC_CMD_FCNTL_GENERATE 0x5 */
@@ -6155,9 +6763,9 @@/* MC_CMD_FCNTL_RESPOND 0x1 */ /* enum: Respond to and Issue flow control. */ /* MC_CMD_FCNTL_BIDIR 0x2 */ -/* enum: Auto neg flow control. */ +/* enum: Auto negotiate flow control. */ /* MC_CMD_FCNTL_AUTO 0x3 */ -/* enum: Priority flow control (eftest builds only). */ +/* enum: Priority flow control. This is only supported on KSB. */ /* MC_CMD_FCNTL_QBB 0x4 */ /* enum: Issue flow control. */ /* MC_CMD_FCNTL_GENERATE 0x5 */
@@ -6188,19 +6796,9 @@#define MC_CMD_SET_MAC_V3_IN_CFG_FCS_OFST 28#define MC_CMD_SET_MAC_V3_IN_CFG_FCS_LBN 4#define MC_CMD_SET_MAC_V3_IN_CFG_FCS_WIDTH 1 -/* Identifies the MAC to update by the specifying the end of a logical MAE -* link. Setting TARGET to MAE_LINK_ENDPOINT_COMPAT is equivalent to using the -* previous version of the command (MC_CMD_SET_MAC_EXT). Not all possible -* combinations of MPORT_END and MPORT_SELECTOR in TARGET will work in all -* circumstances. 1. Some will always work (e.g. a VF can always address its -* logical MAC using MPORT_SELECTOR=ASSIGNED,LINK_END=VNIC), 2. Some are not -* meaningful and will always fail with EINVAL (e.g. attempting to address the -* VNIC end of a link to a physical port), 3. Some are meaningful but require -* the MCDI client to have the required permission and fail with EPERM -* otherwise (e.g. trying to set the MAC on a VF the caller cannot administer), -* and 4. Some could be implementation-specific and fail with ENOTSUP if not -* available (no examples exist right now). See SF-123581-TC section 4.3 for -* more details. +/* Target port to set mac state for. Uses MAE_LINK_ENDPOINT_SELECTOR which +* identifies a real or virtual network port by MAE port and link end. See the +* structure definition for more details */ #define MC_CMD_SET_MAC_V3_IN_TARGET_OFST 32#define MC_CMD_SET_MAC_V3_IN_TARGET_LEN 8
@@ -6212,6 +6810,7 @@#define MC_CMD_SET_MAC_V3_IN_TARGET_HI_LEN 4#define MC_CMD_SET_MAC_V3_IN_TARGET_HI_LBN 288#define MC_CMD_SET_MAC_V3_IN_TARGET_HI_WIDTH 32 +/* See structuredef: MAE_LINK_ENDPOINT_SELECTOR */ #define MC_CMD_SET_MAC_V3_IN_TARGET_MPORT_SELECTOR_OFST 32#define MC_CMD_SET_MAC_V3_IN_TARGET_MPORT_SELECTOR_LEN 4#define MC_CMD_SET_MAC_V3_IN_TARGET_MPORT_SELECTOR_FLAT_OFST 32
@@ -6405,6 +7004,98 @@#define MC_CMD_MAC_STATS_IN_PORT_ID_OFST 16#define MC_CMD_MAC_STATS_IN_PORT_ID_LEN 4 +/* MC_CMD_MAC_STATS_V2_IN msgrequest */ +#define MC_CMD_MAC_STATS_V2_IN_LEN 28 +/* ??? */ +#define MC_CMD_MAC_STATS_V2_IN_DMA_ADDR_OFST 0 +#define MC_CMD_MAC_STATS_V2_IN_DMA_ADDR_LEN 8 +#define MC_CMD_MAC_STATS_V2_IN_DMA_ADDR_LO_OFST 0 +#define MC_CMD_MAC_STATS_V2_IN_DMA_ADDR_LO_LEN 4 +#define MC_CMD_MAC_STATS_V2_IN_DMA_ADDR_LO_LBN 0 +#define MC_CMD_MAC_STATS_V2_IN_DMA_ADDR_LO_WIDTH 32 +#define MC_CMD_MAC_STATS_V2_IN_DMA_ADDR_HI_OFST 4 +#define MC_CMD_MAC_STATS_V2_IN_DMA_ADDR_HI_LEN 4 +#define MC_CMD_MAC_STATS_V2_IN_DMA_ADDR_HI_LBN 32 +#define MC_CMD_MAC_STATS_V2_IN_DMA_ADDR_HI_WIDTH 32 +#define MC_CMD_MAC_STATS_V2_IN_CMD_OFST 8 +#define MC_CMD_MAC_STATS_V2_IN_CMD_LEN 4 +#define MC_CMD_MAC_STATS_V2_IN_DMA_OFST 8 +#define MC_CMD_MAC_STATS_V2_IN_DMA_LBN 0 +#define MC_CMD_MAC_STATS_V2_IN_DMA_WIDTH 1 +#define MC_CMD_MAC_STATS_V2_IN_CLEAR_OFST 8 +#define MC_CMD_MAC_STATS_V2_IN_CLEAR_LBN 1 +#define MC_CMD_MAC_STATS_V2_IN_CLEAR_WIDTH 1 +#define MC_CMD_MAC_STATS_V2_IN_PERIODIC_CHANGE_OFST 8 +#define MC_CMD_MAC_STATS_V2_IN_PERIODIC_CHANGE_LBN 2 +#define MC_CMD_MAC_STATS_V2_IN_PERIODIC_CHANGE_WIDTH 1 +#define MC_CMD_MAC_STATS_V2_IN_PERIODIC_ENABLE_OFST 8 +#define MC_CMD_MAC_STATS_V2_IN_PERIODIC_ENABLE_LBN 3 +#define MC_CMD_MAC_STATS_V2_IN_PERIODIC_ENABLE_WIDTH 1 +#define MC_CMD_MAC_STATS_V2_IN_PERIODIC_CLEAR_OFST 8 +#define MC_CMD_MAC_STATS_V2_IN_PERIODIC_CLEAR_LBN 4 +#define MC_CMD_MAC_STATS_V2_IN_PERIODIC_CLEAR_WIDTH 1 +#define MC_CMD_MAC_STATS_V2_IN_PERIODIC_NOEVENT_OFST 8 +#define MC_CMD_MAC_STATS_V2_IN_PERIODIC_NOEVENT_LBN 5 +#define MC_CMD_MAC_STATS_V2_IN_PERIODIC_NOEVENT_WIDTH 1 +#define MC_CMD_MAC_STATS_V2_IN_PERIOD_MS_OFST 8 +#define MC_CMD_MAC_STATS_V2_IN_PERIOD_MS_LBN 16 +#define MC_CMD_MAC_STATS_V2_IN_PERIOD_MS_WIDTH 16 +/* DMA length. Should be set to MAC_STATS_NUM_STATS * sizeof(uint64_t), as +* returned by MC_CMD_GET_CAPABILITIES_V4_OUT. For legacy firmware not +* supporting MC_CMD_GET_CAPABILITIES_V4_OUT, DMA_LEN should be set to +* MC_CMD_MAC_NSTATS * sizeof(uint64_t) +*/ +#define MC_CMD_MAC_STATS_V2_IN_DMA_LEN_OFST 12 +#define MC_CMD_MAC_STATS_V2_IN_DMA_LEN_LEN 4 +/* port id so vadapter stats can be provided */ +#define MC_CMD_MAC_STATS_V2_IN_PORT_ID_OFST 16 +#define MC_CMD_MAC_STATS_V2_IN_PORT_ID_LEN 4 +/* Target port to request statistics for. Uses MAE_LINK_ENDPOINT_SELECTOR which
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.17.1
Part of the diff is not shown here. View the raw message.
PATCH v9 27/27 sfc: support pio mapping based on cxl
In reply to [email protected]From: Alejandro Lucero <[email protected]>
With a device supporting CXL and successfully initialised, use the cxl region to map the memory range and use this mapping for PIO buffers.
--- drivers/net/ethernet/sfc/ef10.c | 50 +++++++++++++++++++++++---- drivers/net/ethernet/sfc/efx_cxl.c | 18 ++++++++++ drivers/net/ethernet/sfc/net_driver.h | 2 ++ drivers/net/ethernet/sfc/nic.h | 3 ++ 4 files changed, 66 insertions(+), 7 deletions(-)
drivers/net/ethernet/sfc/ef10.c +43 -7
@@ -24,6 +24,7 @@#include <linux/wait.h> #include <linux/workqueue.h> #include <net/udp_tunnel.h> +#include "efx_cxl.h" /* Hardware control for EF10 architecture including 'Huntington'. */
@@ -106,7 +107,7 @@ static int efx_ef10_get_vf_index(struct efx_nic *efx)static int efx_ef10_init_datapath_caps (struct efx_nic *efx) { -MCDI_DECLARE_BUF (outbuf,MC_CMD_GET_CAPABILITIES_V4_OUT_LEN ); +MCDI_DECLARE_BUF (outbuf,MC_CMD_GET_CAPABILITIES_V7_OUT_LEN );struct efx_ef10_nic_data *nic_data = efx->nic_data;size_t outlen;int rc;
@@ -177,6 +178,12 @@ static int efx_ef10_init_datapath_caps(struct efx_nic *efx) efx->num_mac_stats); } +if (outlen <MC_CMD_GET_CAPABILITIES_V7_OUT_LEN ) + nic_data->datapath_caps3 =0 ; +else + nic_data->datapath_caps3 =MCDI_DWORD (outbuf, +GET_CAPABILITIES_V7_OUT_FLAGS3 ); +return 0 ; }
@@ -919,6 +926,9 @@ static void efx_ef10_forget_old_piobufs(struct efx_nic *efx)static void efx_ef10_remove (struct efx_nic *efx) {struct efx_ef10_nic_data *nic_data = efx->nic_data; +#ifdef CONFIG_SFC_CXL +struct efx_probe_data *probe_data; +#endif int rc;#ifdef CONFIG_SFC_SRIOV
@@ -949,7 +959,12 @@ static void efx_ef10_remove(struct efx_nic *efx)efx_mcdi_rx_free_indir_table (efx); +#ifdef CONFIG_SFC_CXL + probe_data = container_of(efx, struct efx_probe_data, efx); +if (nic_data->wc_membase && !probe_data->cxl_pio_in_use) +#else if (nic_data->wc_membase) +#endif iounmap (nic_data->wc_membase); rc =efx_mcdi_free_vis (efx);
@@ -1140,6 +1155,9 @@ static int efx_ef10_dimension_resources(struct efx_nic *efx)unsigned int channel_vis, pio_write_vi_base, max_vis;struct efx_ef10_nic_data *nic_data = efx->nic_data;unsigned int uc_mem_map_size, wc_mem_map_size; +#ifdef CONFIG_SFC_CXL +struct efx_probe_data *probe_data; +#endif void __iomem *membase;int rc;
@@ -1263,8 +1281,25 @@ static int efx_ef10_dimension_resources(struct efx_nic *efx)iounmap (efx->membase); efx->membase = membase; -/* Set up the WC mapping if needed */ -if (wc_mem_map_size) { +if (!wc_mem_map_size) + goto skip_pio; + +/* Set up the WC mapping */ + +#ifdef CONFIG_SFC_CXL + probe_data = container_of(efx, struct efx_probe_data, efx); +if ((nic_data->datapath_caps3 & + (1 <<MC_CMD_GET_CAPABILITIES_V7_OUT_CXL_CONFIG_ENABLE_LBN )) && + probe_data->cxl_pio_initialised) { +/* Using PIO through CXL mapping? */ + nic_data->pio_write_base = probe_data->cxl->ctpio_cxl + + (pio_write_vi_base * efx->vi_stride + +ER_DZ_TX_PIOBUF - uc_mem_map_size); + probe_data->cxl_pio_in_use = true; + } else +#endif + { +/* Using legacy PIO BAR mapping */ nic_data->wc_membase =ioremap_wc (efx->membase_phys + uc_mem_map_size, wc_mem_map_size);
@@ -1279,12 +1314,13 @@ static int efx_ef10_dimension_resources(struct efx_nic *efx) nic_data->wc_membase + (pio_write_vi_base * efx->vi_stride +ER_DZ_TX_PIOBUF - uc_mem_map_size); - - rc =efx_ef10_link_piobufs (efx); -if (rc) -efx_ef10_free_piobufs (efx); } + rc =efx_ef10_link_piobufs (efx); +if (rc) +efx_ef10_free_piobufs (efx); + +skip_pio: netif_dbg(efx, probe, efx->net_dev, "memory BAR at %pa (virtual %p+%x UC, %p+%x WC)\n", &efx->membase_phys, efx->membase, uc_mem_map_size,
drivers/net/ethernet/sfc/efx_cxl.c +18 -0
@@ -27,6 +27,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data)resource_size_t max_size;struct efx_cxl *cxl;struct resource res; +struct range range;u16 dvsec;int rc;
@@ -136,10 +137,26 @@ int efx_cxl_init(struct efx_probe_data *probe_data) goto err_region; } + rc =cxl_get_region_range (cxl->efx_region, &range); +if (rc) { +pci_err (pci_dev,"CXL getting regions params failed" ); + goto err_region_params; + } + + cxl->ctpio_cxl =ioremap (range.start, range.end - range.start +1 ); +if (!cxl->ctpio_cxl) { +pci_err (pci_dev,"CXL ioremap region (%pra) pfailed" , &range); + rc = -ENOMEM ; + goto err_region_params; + } + probe_data->cxl = cxl; + probe_data->cxl_pio_initialised = true;return 0 ; +err_region_params: +cxl_accel_region_detach (cxl->cxled); err_region:cxl_dpa_free (cxl->cxled); err_memdev:
@@ -154,6 +171,7 @@ int efx_cxl_init(struct efx_probe_data *probe_data)void efx_cxl_exit (struct efx_probe_data *probe_data) {if (probe_data->cxl) { +iounmap (probe_data->cxl->ctpio_cxl);cxl_accel_region_detach (probe_data->cxl->cxled);cxl_dpa_free (probe_data->cxl->cxled);cxl_release_resource (probe_data->cxl->cxlds,CXL_RES_RAM );
drivers/net/ethernet/sfc/net_driver.h +2 -0
@@ -1209,6 +1209,7 @@ struct efx_cxl;* @efx: Efx NIC details * @cxl: details of related cxl objects * @cxl_pio_initialised: cxl initialization outcome. +* @cxl_pio_in_use: PIO using CXL mapping */ struct efx_probe_data {struct pci_dev *pci_dev;
@@ -1216,6 +1217,7 @@ struct efx_probe_data {#ifdef CONFIG_SFC_CXL struct efx_cxl *cxl;bool cxl_pio_initialised; +bool cxl_pio_in_use;#endif };
drivers/net/ethernet/sfc/nic.h +3 -0
@@ -152,6 +152,8 @@ enum {* %MC_CMD_GET_CAPABILITIES response) * @datapath_caps2: Further Capabilities of datapath firmware (FLAGS2 field of * %MC_CMD_GET_CAPABILITIES response) +* @datapath_caps3: Further Capabilities of datapath firmware (FLAGS3 field of +* %MC_CMD_GET_CAPABILITIES response) * @rx_dpcpu_fw_id: Firmware ID of the RxDPCPU * @tx_dpcpu_fw_id: Firmware ID of the TxDPCPU * @must_probe_vswitching: Flag: vswitching has yet to be setup after MC reboot
@@ -186,6 +188,7 @@ struct efx_ef10_nic_data {bool must_check_datapath_caps;u32 datapath_caps;u32 datapath_caps2; +u32 datapath_caps3;unsigned int rx_dpcpu_fw_id;unsigned int tx_dpcpu_fw_id;bool must_probe_vswitching;
Signature · 1 line
2.17.1