2013-07-07 14:25:49 +00:00
|
|
|
/*
|
2015-04-02 14:07:29 +00:00
|
|
|
* Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
|
2013-07-07 14:25:49 +00:00
|
|
|
*
|
|
|
|
* This software is available to you under a choice of one of two
|
|
|
|
* licenses. You may choose to be licensed under the terms of the GNU
|
|
|
|
* General Public License (GPL) Version 2, available from the file
|
|
|
|
* COPYING in the main directory of this source tree, or the
|
|
|
|
* OpenIB.org BSD license below:
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or
|
|
|
|
* without modification, are permitted provided that the following
|
|
|
|
* conditions are met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer.
|
|
|
|
*
|
|
|
|
* - Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials
|
|
|
|
* provided with the distribution.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MLX5_DRIVER_H
|
|
|
|
#define MLX5_DRIVER_H
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/completion.h>
|
|
|
|
#include <linux/pci.h>
|
2018-01-04 02:35:51 +00:00
|
|
|
#include <linux/irq.h>
|
2013-07-07 14:25:49 +00:00
|
|
|
#include <linux/spinlock_types.h>
|
|
|
|
#include <linux/semaphore.h>
|
2014-02-14 04:45:17 +00:00
|
|
|
#include <linux/slab.h>
|
2013-07-07 14:25:49 +00:00
|
|
|
#include <linux/vmalloc.h>
|
2019-06-20 07:03:47 +00:00
|
|
|
#include <linux/xarray.h>
|
2016-05-13 12:55:41 +00:00
|
|
|
#include <linux/workqueue.h>
|
2017-01-02 09:37:46 +00:00
|
|
|
#include <linux/mempool.h>
|
net/mlx5_core: Use tasklet for user-space CQ completion events
Previously, we've fired all our completion callbacks straight from
our ISR.
Some of those callbacks were lightweight (for example, mlx5 Ethernet
napi callbacks), but some of them did more work (for example,
the user-space RDMA stack uverbs' completion handler). Besides that,
doing more than the minimal work in ISR is generally considered wrong,
it could even lead to a hard lockup of the system. Since when a lot
of completion events are generated by the hardware, the loop over
those events could be so long, that we'll get into a hard lockup by
the system watchdog.
In order to avoid that, add a new way of invoking completion events
callbacks. In the interrupt itself, we add the CQs which receive
completion event to a per-EQ list and schedule a tasklet. In the
tasklet context we loop over all the CQs in the list and invoke the
user callback.
Signed-off-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2016-04-17 14:08:40 +00:00
|
|
|
#include <linux/interrupt.h>
|
2018-11-26 22:38:56 +00:00
|
|
|
#include <linux/notifier.h>
|
2019-08-06 01:59:50 +00:00
|
|
|
#include <linux/refcount.h>
|
2020-10-08 13:06:37 +00:00
|
|
|
#include <linux/auxiliary_bus.h>
|
2022-11-01 14:27:43 +00:00
|
|
|
#include <linux/mutex.h>
|
2014-02-14 04:45:17 +00:00
|
|
|
|
2013-07-07 14:25:49 +00:00
|
|
|
#include <linux/mlx5/device.h>
|
|
|
|
#include <linux/mlx5/doorbell.h>
|
2018-11-20 22:12:21 +00:00
|
|
|
#include <linux/mlx5/eq.h>
|
2017-08-15 10:46:04 +00:00
|
|
|
#include <linux/timecounter.h>
|
2018-12-11 14:09:53 +00:00
|
|
|
#include <net/devlink.h>
|
2013-07-07 14:25:49 +00:00
|
|
|
|
2020-10-04 11:30:58 +00:00
|
|
|
#define MLX5_ADEV_NAME "mlx5_core"
|
|
|
|
|
2021-08-19 13:18:57 +00:00
|
|
|
#define MLX5_IRQ_EQ_CTRL (U8_MAX)
|
|
|
|
|
2013-07-07 14:25:49 +00:00
|
|
|
enum {
|
|
|
|
MLX5_BOARD_ID_LEN = 64,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
MLX5_CMD_WQ_MAX_NAME = 32,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CMD_OWNER_SW = 0x0,
|
|
|
|
CMD_OWNER_HW = 0x1,
|
|
|
|
CMD_STATUS_SUCCESS = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum mlx5_sqp_t {
|
|
|
|
MLX5_SQP_SMI = 0,
|
|
|
|
MLX5_SQP_GSI = 1,
|
|
|
|
MLX5_SQP_IEEE_1588 = 2,
|
|
|
|
MLX5_SQP_SNIFFER = 3,
|
|
|
|
MLX5_SQP_SYNC_UMR = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
net/mlx5: Enable 8 ports LAG
This patch adds to mlx5 drivers support for 8 ports HCAs.
Starting with ConnectX-8 HCAs with 8 ports are possible.
As most driver parts aren't affected by such configuration most driver
code is unchanged.
Specially the only affected areas are:
- Lag
- Multiport E-Switch
- Single FDB E-Switch
All of the above are already factored in generic way, and LAG and VF LAG
are tested, so all that left is to change a #define and remove checks
which are no longer needed.
However, Multiport E-Switch is not tested yet, so it is left untouched.
This patch will allow to create hardware LAG/VF LAG when all 8 ports are
added to the same bond device.
for example, In order to activate the hardware lag a user can execute
the following:
ip link add bond0 type bond
ip link set bond0 type bond miimon 100 mode 2
ip link set eth2 master bond0
ip link set eth3 master bond0
ip link set eth4 master bond0
ip link set eth5 master bond0
ip link set eth6 master bond0
ip link set eth7 master bond0
ip link set eth8 master bond0
ip link set eth9 master bond0
Where eth2, eth3, eth4, eth5, eth6, eth7, eth8 and eth9 are the PFs of
the same HCA.
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240512124306.740898-2-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-05-12 12:43:03 +00:00
|
|
|
MLX5_MAX_PORTS = 8,
|
2013-07-07 14:25:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2018-10-10 06:25:16 +00:00
|
|
|
MLX5_ATOMIC_MODE_OFFSET = 16,
|
|
|
|
MLX5_ATOMIC_MODE_IB_COMP = 1,
|
|
|
|
MLX5_ATOMIC_MODE_CX = 2,
|
|
|
|
MLX5_ATOMIC_MODE_8B = 3,
|
|
|
|
MLX5_ATOMIC_MODE_16B = 4,
|
|
|
|
MLX5_ATOMIC_MODE_32B = 5,
|
|
|
|
MLX5_ATOMIC_MODE_64B = 6,
|
|
|
|
MLX5_ATOMIC_MODE_128B = 7,
|
|
|
|
MLX5_ATOMIC_MODE_256B = 8,
|
2013-07-07 14:25:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2022-11-28 16:00:17 +00:00
|
|
|
MLX5_REG_SBPR = 0xb001,
|
|
|
|
MLX5_REG_SBCM = 0xb002,
|
2017-07-18 21:08:46 +00:00
|
|
|
MLX5_REG_QPTS = 0x4002,
|
2016-02-22 16:17:25 +00:00
|
|
|
MLX5_REG_QETCR = 0x4005,
|
|
|
|
MLX5_REG_QTCT = 0x400a,
|
2017-07-18 21:08:46 +00:00
|
|
|
MLX5_REG_QPDPM = 0x4013,
|
2017-07-18 21:03:17 +00:00
|
|
|
MLX5_REG_QCAM = 0x4019,
|
2016-11-27 15:02:06 +00:00
|
|
|
MLX5_REG_DCBX_PARAM = 0x4020,
|
|
|
|
MLX5_REG_DCBX_APP = 0x4021,
|
2017-03-13 18:05:45 +00:00
|
|
|
MLX5_REG_FPGA_CAP = 0x4022,
|
|
|
|
MLX5_REG_FPGA_CTRL = 0x4023,
|
2017-04-18 10:10:41 +00:00
|
|
|
MLX5_REG_FPGA_ACCESS_REG = 0x4024,
|
2019-05-29 22:50:24 +00:00
|
|
|
MLX5_REG_CORE_DUMP = 0x402e,
|
2013-07-07 14:25:49 +00:00
|
|
|
MLX5_REG_PCAP = 0x5001,
|
|
|
|
MLX5_REG_PMTU = 0x5003,
|
|
|
|
MLX5_REG_PTYS = 0x5004,
|
|
|
|
MLX5_REG_PAOS = 0x5006,
|
2015-08-16 13:04:51 +00:00
|
|
|
MLX5_REG_PFCC = 0x5007,
|
2015-08-04 11:05:47 +00:00
|
|
|
MLX5_REG_PPCNT = 0x5008,
|
2018-03-02 21:47:01 +00:00
|
|
|
MLX5_REG_PPTB = 0x500b,
|
|
|
|
MLX5_REG_PBMC = 0x500c,
|
2013-07-07 14:25:49 +00:00
|
|
|
MLX5_REG_PMAOS = 0x5012,
|
|
|
|
MLX5_REG_PUDE = 0x5009,
|
|
|
|
MLX5_REG_PMPE = 0x5010,
|
|
|
|
MLX5_REG_PELC = 0x500e,
|
2015-06-04 16:30:45 +00:00
|
|
|
MLX5_REG_PVLC = 0x500f,
|
2016-04-24 19:51:52 +00:00
|
|
|
MLX5_REG_PCMR = 0x5041,
|
2021-02-15 14:13:02 +00:00
|
|
|
MLX5_REG_PDDR = 0x5031,
|
2016-04-24 19:51:54 +00:00
|
|
|
MLX5_REG_PMLP = 0x5002,
|
2018-10-09 11:16:43 +00:00
|
|
|
MLX5_REG_PPLM = 0x5023,
|
2016-12-08 13:52:00 +00:00
|
|
|
MLX5_REG_PCAM = 0x507f,
|
2013-07-07 14:25:49 +00:00
|
|
|
MLX5_REG_NODE_DESC = 0x6001,
|
|
|
|
MLX5_REG_HOST_ENDIANNESS = 0x7004,
|
net/mlx5: Expose NIC temperature via hardware monitoring kernel API
Expose NIC temperature by implementing hwmon kernel API, which turns
current thermal zone kernel API to redundant.
For each one of the supported and exposed thermal diode sensors, expose
the following attributes:
1) Input temperature.
2) Highest temperature.
3) Temperature label:
Depends on the firmware capability, if firmware doesn't support
sensors naming, the fallback naming convention would be: "sensorX",
where X is the HW spec (MTMP register) sensor index.
4) Temperature critical max value:
refers to the high threshold of Warning Event. Will be exposed as
`tempY_crit` hwmon attribute (RO attribute). For example for
ConnectX5 HCA's this temperature value will be 105 Celsius, 10
degrees lower than the HW shutdown temperature).
5) Temperature reset history: resets highest temperature.
For example, for dualport ConnectX5 NIC with a single IC thermal diode
sensor will have 2 hwmon directories (one for each PCI function)
under "/sys/class/hwmon/hwmon[X,Y]".
Listing one of the directories above (hwmonX/Y) generates the
corresponding output below:
$ grep -H -d skip . /sys/class/hwmon/hwmon0/*
Output
=======================================================================
/sys/class/hwmon/hwmon0/name:mlx5
/sys/class/hwmon/hwmon0/temp1_crit:105000
/sys/class/hwmon/hwmon0/temp1_highest:48000
/sys/class/hwmon/hwmon0/temp1_input:46000
/sys/class/hwmon/hwmon0/temp1_label:asic
grep: /sys/class/hwmon/hwmon0/temp1_reset_history: Permission denied
In addition, displaying the sensors data via lm_sensors generates the
corresponding output below:
$ sensors
Output
=======================================================================
mlx5-pci-0800
Adapter: PCI adapter
asic: +46.0°C (crit = +105.0°C, highest = +48.0°C)
mlx5-pci-0801
Adapter: PCI adapter
asic: +46.0°C (crit = +105.0°C, highest = +48.0°C)
CC: Jean Delvare <jdelvare@suse.com>
Signed-off-by: Adham Faris <afaris@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20230807180507.22984-3-saeed@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-08-07 18:05:07 +00:00
|
|
|
MLX5_REG_MTCAP = 0x9009,
|
2023-03-14 05:42:23 +00:00
|
|
|
MLX5_REG_MTMP = 0x900A,
|
2016-04-24 19:51:54 +00:00
|
|
|
MLX5_REG_MCIA = 0x9014,
|
2020-04-24 19:45:06 +00:00
|
|
|
MLX5_REG_MFRL = 0x9028,
|
2016-04-24 19:51:53 +00:00
|
|
|
MLX5_REG_MLCR = 0x902b,
|
2021-10-13 06:45:22 +00:00
|
|
|
MLX5_REG_MRTC = 0x902d,
|
2018-07-17 01:35:30 +00:00
|
|
|
MLX5_REG_MTRC_CAP = 0x9040,
|
|
|
|
MLX5_REG_MTRC_CONF = 0x9041,
|
|
|
|
MLX5_REG_MTRC_STDB = 0x9042,
|
|
|
|
MLX5_REG_MTRC_CTRL = 0x9043,
|
2019-03-29 22:38:03 +00:00
|
|
|
MLX5_REG_MPEIN = 0x9050,
|
2016-11-17 11:46:01 +00:00
|
|
|
MLX5_REG_MPCNT = 0x9051,
|
2016-10-10 13:05:53 +00:00
|
|
|
MLX5_REG_MTPPS = 0x9053,
|
|
|
|
MLX5_REG_MTPPSE = 0x9054,
|
2021-02-12 22:30:38 +00:00
|
|
|
MLX5_REG_MTUTC = 0x9055,
|
2018-07-17 01:35:31 +00:00
|
|
|
MLX5_REG_MPEGC = 0x9056,
|
2023-08-07 06:05:34 +00:00
|
|
|
MLX5_REG_MPIR = 0x9059,
|
2019-06-28 22:35:50 +00:00
|
|
|
MLX5_REG_MCQS = 0x9060,
|
2017-04-18 10:35:39 +00:00
|
|
|
MLX5_REG_MCQI = 0x9061,
|
|
|
|
MLX5_REG_MCC = 0x9062,
|
|
|
|
MLX5_REG_MCDA = 0x9063,
|
2016-12-08 13:52:00 +00:00
|
|
|
MLX5_REG_MCAM = 0x907f,
|
2023-09-13 20:49:43 +00:00
|
|
|
MLX5_REG_MSECQ = 0x9155,
|
|
|
|
MLX5_REG_MSEES = 0x9156,
|
2019-10-07 07:30:32 +00:00
|
|
|
MLX5_REG_MIRC = 0x9162,
|
2024-07-30 13:40:52 +00:00
|
|
|
MLX5_REG_MTPTM = 0x9180,
|
|
|
|
MLX5_REG_MTCTR = 0x9181,
|
2025-01-09 20:42:29 +00:00
|
|
|
MLX5_REG_MRTCQ = 0x9182,
|
2020-06-22 06:03:31 +00:00
|
|
|
MLX5_REG_SBCAM = 0xB01F,
|
2019-11-04 12:51:55 +00:00
|
|
|
MLX5_REG_RESOURCE_DUMP = 0xC000,
|
2025-01-09 20:42:31 +00:00
|
|
|
MLX5_REG_NIC_CAP = 0xC00D,
|
2021-07-21 13:14:12 +00:00
|
|
|
MLX5_REG_DTOR = 0xC00E,
|
2025-01-09 20:42:31 +00:00
|
|
|
MLX5_REG_VHCA_ICM_CTRL = 0xC010,
|
2013-07-07 14:25:49 +00:00
|
|
|
};
|
|
|
|
|
2017-07-18 21:08:46 +00:00
|
|
|
enum mlx5_qpts_trust_state {
|
|
|
|
MLX5_QPTS_TRUST_PCP = 1,
|
|
|
|
MLX5_QPTS_TRUST_DSCP = 2,
|
|
|
|
};
|
|
|
|
|
2016-11-27 15:02:06 +00:00
|
|
|
enum mlx5_dcbx_oper_mode {
|
|
|
|
MLX5E_DCBX_PARAM_VER_OPER_HOST = 0x0,
|
|
|
|
MLX5E_DCBX_PARAM_VER_OPER_AUTO = 0x3,
|
|
|
|
};
|
|
|
|
|
2015-12-14 14:34:10 +00:00
|
|
|
enum {
|
|
|
|
MLX5_ATOMIC_OPS_CMP_SWAP = 1 << 0,
|
|
|
|
MLX5_ATOMIC_OPS_FETCH_ADD = 1 << 1,
|
2018-10-10 06:25:16 +00:00
|
|
|
MLX5_ATOMIC_OPS_EXTENDED_CMP_SWAP = 1 << 2,
|
|
|
|
MLX5_ATOMIC_OPS_EXTENDED_FETCH_ADD = 1 << 3,
|
2015-12-14 14:34:10 +00:00
|
|
|
};
|
|
|
|
|
2014-12-11 15:04:19 +00:00
|
|
|
enum mlx5_page_fault_resume_flags {
|
|
|
|
MLX5_PAGE_FAULT_RESUME_REQUESTOR = 1 << 0,
|
|
|
|
MLX5_PAGE_FAULT_RESUME_WRITE = 1 << 1,
|
|
|
|
MLX5_PAGE_FAULT_RESUME_RDMA = 1 << 2,
|
|
|
|
MLX5_PAGE_FAULT_RESUME_ERROR = 1 << 7,
|
|
|
|
};
|
|
|
|
|
2013-07-07 14:25:49 +00:00
|
|
|
enum dbg_rsc_type {
|
|
|
|
MLX5_DBG_RSC_QP,
|
|
|
|
MLX5_DBG_RSC_EQ,
|
|
|
|
MLX5_DBG_RSC_CQ,
|
|
|
|
};
|
|
|
|
|
2017-05-30 07:18:24 +00:00
|
|
|
enum port_state_policy {
|
|
|
|
MLX5_POLICY_DOWN = 0,
|
|
|
|
MLX5_POLICY_UP = 1,
|
|
|
|
MLX5_POLICY_FOLLOW = 2,
|
|
|
|
MLX5_POLICY_INVALID = 0xffffffff
|
|
|
|
};
|
|
|
|
|
2019-06-28 22:35:58 +00:00
|
|
|
enum mlx5_coredev_type {
|
|
|
|
MLX5_COREDEV_PF,
|
2020-12-12 06:12:18 +00:00
|
|
|
MLX5_COREDEV_VF,
|
|
|
|
MLX5_COREDEV_SF,
|
2019-06-28 22:35:58 +00:00
|
|
|
};
|
|
|
|
|
2013-07-07 14:25:49 +00:00
|
|
|
struct mlx5_field_desc {
|
|
|
|
int i;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_rsc_debug {
|
|
|
|
struct mlx5_core_dev *dev;
|
|
|
|
void *object;
|
|
|
|
enum dbg_rsc_type type;
|
|
|
|
struct dentry *root;
|
2020-05-07 18:59:35 +00:00
|
|
|
struct mlx5_field_desc fields[];
|
2013-07-07 14:25:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum mlx5_dev_event {
|
2018-11-26 22:38:59 +00:00
|
|
|
MLX5_DEV_EVENT_SYS_ERROR = 128, /* 0 - 127 are FW events */
|
2019-02-21 14:29:27 +00:00
|
|
|
MLX5_DEV_EVENT_PORT_AFFINITY = 129,
|
2022-11-30 13:12:50 +00:00
|
|
|
MLX5_DEV_EVENT_MULTIPORT_ESW = 130,
|
2013-07-07 14:25:49 +00:00
|
|
|
};
|
|
|
|
|
2015-05-28 19:28:43 +00:00
|
|
|
enum mlx5_port_status {
|
2015-08-16 13:04:50 +00:00
|
|
|
MLX5_PORT_UP = 1,
|
|
|
|
MLX5_PORT_DOWN = 2,
|
2015-05-28 19:28:43 +00:00
|
|
|
};
|
|
|
|
|
2020-03-19 19:43:13 +00:00
|
|
|
enum mlx5_cmdif_state {
|
|
|
|
MLX5_CMDIF_STATE_UNINITIALIZED,
|
|
|
|
MLX5_CMDIF_STATE_UP,
|
|
|
|
MLX5_CMDIF_STATE_DOWN,
|
|
|
|
};
|
|
|
|
|
2013-07-07 14:25:49 +00:00
|
|
|
struct mlx5_cmd_first {
|
|
|
|
__be32 data[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_cmd_msg {
|
|
|
|
struct list_head list;
|
2016-11-17 11:45:55 +00:00
|
|
|
struct cmd_msg_cache *parent;
|
2013-07-07 14:25:49 +00:00
|
|
|
u32 len;
|
|
|
|
struct mlx5_cmd_first first;
|
|
|
|
struct mlx5_cmd_mailbox *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_cmd_debug {
|
|
|
|
struct dentry *dbg_root;
|
|
|
|
void *in_msg;
|
|
|
|
void *out_msg;
|
|
|
|
u8 status;
|
|
|
|
u16 inlen;
|
|
|
|
u16 outlen;
|
|
|
|
};
|
|
|
|
|
2016-11-17 11:45:55 +00:00
|
|
|
struct cmd_msg_cache {
|
2013-07-07 14:25:49 +00:00
|
|
|
/* protect block chain allocations
|
|
|
|
*/
|
|
|
|
spinlock_t lock;
|
|
|
|
struct list_head head;
|
2016-11-17 11:45:55 +00:00
|
|
|
unsigned int max_inbox_size;
|
|
|
|
unsigned int num_ent;
|
2013-07-07 14:25:49 +00:00
|
|
|
};
|
|
|
|
|
2016-11-17 11:45:55 +00:00
|
|
|
enum {
|
|
|
|
MLX5_NUM_COMMAND_CACHES = 5,
|
2013-07-07 14:25:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_cmd_stats {
|
|
|
|
u64 sum;
|
|
|
|
u64 n;
|
2022-01-27 13:22:21 +00:00
|
|
|
/* number of times command failed */
|
|
|
|
u64 failed;
|
|
|
|
/* number of times command failed on bad status returned by FW */
|
|
|
|
u64 failed_mbox_status;
|
|
|
|
/* last command failed returned errno */
|
|
|
|
u32 last_failed_errno;
|
|
|
|
/* last bad status returned by FW */
|
|
|
|
u8 last_failed_mbox_status;
|
2022-05-13 03:19:31 +00:00
|
|
|
/* last command failed syndrome returned by FW */
|
|
|
|
u32 last_failed_syndrome;
|
2013-07-07 14:25:49 +00:00
|
|
|
struct dentry *root;
|
|
|
|
/* protect command average calculations */
|
|
|
|
spinlock_t lock;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_cmd {
|
2018-11-20 22:12:24 +00:00
|
|
|
struct mlx5_nb nb;
|
|
|
|
|
2023-01-18 14:52:17 +00:00
|
|
|
/* members which needs to be queried or reinitialized each reload */
|
|
|
|
struct {
|
|
|
|
u16 cmdif_rev;
|
|
|
|
u8 log_sz;
|
|
|
|
u8 log_stride;
|
|
|
|
int max_reg_cmds;
|
|
|
|
unsigned long bitmask;
|
|
|
|
struct semaphore sem;
|
|
|
|
struct semaphore pages_sem;
|
|
|
|
struct semaphore throttle_sem;
|
2025-02-26 13:01:07 +00:00
|
|
|
struct semaphore unprivileged_sem;
|
|
|
|
struct xarray privileged_uids;
|
2023-01-18 14:52:17 +00:00
|
|
|
} vars;
|
2020-03-19 19:43:13 +00:00
|
|
|
enum mlx5_cmdif_state state;
|
2015-04-02 14:07:25 +00:00
|
|
|
void *cmd_alloc_buf;
|
|
|
|
dma_addr_t alloc_dma;
|
|
|
|
int alloc_size;
|
2013-07-07 14:25:49 +00:00
|
|
|
void *cmd_buf;
|
|
|
|
dma_addr_t dma;
|
|
|
|
|
|
|
|
/* protect command queue allocations
|
|
|
|
*/
|
|
|
|
spinlock_t alloc_lock;
|
|
|
|
|
|
|
|
/* protect token allocations
|
|
|
|
*/
|
|
|
|
spinlock_t token_lock;
|
|
|
|
u8 token;
|
|
|
|
char wq_name[MLX5_CMD_WQ_MAX_NAME];
|
|
|
|
struct workqueue_struct *wq;
|
|
|
|
int mode;
|
2020-03-18 19:44:32 +00:00
|
|
|
u16 allowed_opcode;
|
2013-07-07 14:25:49 +00:00
|
|
|
struct mlx5_cmd_work_ent *ent_arr[MLX5_MAX_COMMANDS];
|
2017-08-22 11:46:59 +00:00
|
|
|
struct dma_pool *pool;
|
2013-07-07 14:25:49 +00:00
|
|
|
struct mlx5_cmd_debug dbg;
|
2016-11-17 11:45:55 +00:00
|
|
|
struct cmd_msg_cache cache[MLX5_NUM_COMMAND_CACHES];
|
2013-07-07 14:25:49 +00:00
|
|
|
int checksum_disabled;
|
2023-01-19 07:10:50 +00:00
|
|
|
struct xarray stats;
|
2013-07-07 14:25:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_cmd_mailbox {
|
|
|
|
void *buf;
|
|
|
|
dma_addr_t dma;
|
|
|
|
struct mlx5_cmd_mailbox *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_buf_list {
|
|
|
|
void *buf;
|
|
|
|
dma_addr_t map;
|
|
|
|
};
|
|
|
|
|
2016-11-30 15:59:37 +00:00
|
|
|
struct mlx5_frag_buf {
|
|
|
|
struct mlx5_buf_list *frags;
|
|
|
|
int npages;
|
|
|
|
int size;
|
|
|
|
u8 page_shift;
|
|
|
|
};
|
|
|
|
|
2018-01-02 14:08:06 +00:00
|
|
|
struct mlx5_frag_buf_ctrl {
|
2018-09-12 12:36:41 +00:00
|
|
|
struct mlx5_buf_list *frags;
|
2018-01-02 14:08:06 +00:00
|
|
|
u32 sz_m1;
|
2018-08-21 13:04:41 +00:00
|
|
|
u16 frag_sz_m1;
|
2018-08-21 13:07:58 +00:00
|
|
|
u16 strides_offset;
|
2018-01-02 14:08:06 +00:00
|
|
|
u8 log_sz;
|
|
|
|
u8 log_stride;
|
|
|
|
u8 log_frag_strides;
|
|
|
|
};
|
|
|
|
|
2014-02-23 12:19:06 +00:00
|
|
|
struct mlx5_core_psv {
|
|
|
|
u32 psv_idx;
|
|
|
|
struct psv_layout {
|
|
|
|
u32 pd;
|
|
|
|
u16 syndrome;
|
|
|
|
u16 reserved;
|
|
|
|
u16 bg;
|
|
|
|
u16 app_tag;
|
|
|
|
u32 ref_tag;
|
|
|
|
} psv;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_core_sig_ctx {
|
|
|
|
struct mlx5_core_psv psv_memory;
|
|
|
|
struct mlx5_core_psv psv_wire;
|
2014-02-23 12:19:12 +00:00
|
|
|
struct ib_sig_err err_item;
|
|
|
|
bool sig_status_checked;
|
|
|
|
bool sig_err_exists;
|
|
|
|
u32 sigerr_count;
|
2014-02-23 12:19:06 +00:00
|
|
|
};
|
2013-07-07 14:25:49 +00:00
|
|
|
|
2017-01-02 09:37:46 +00:00
|
|
|
#define MLX5_24BIT_MASK ((1 << 24) - 1)
|
|
|
|
|
2014-10-02 09:19:45 +00:00
|
|
|
enum mlx5_res_type {
|
2016-01-14 17:13:00 +00:00
|
|
|
MLX5_RES_QP = MLX5_EVENT_QUEUE_TYPE_QP,
|
|
|
|
MLX5_RES_RQ = MLX5_EVENT_QUEUE_TYPE_RQ,
|
|
|
|
MLX5_RES_SQ = MLX5_EVENT_QUEUE_TYPE_SQ,
|
|
|
|
MLX5_RES_SRQ = 3,
|
|
|
|
MLX5_RES_XSRQ = 4,
|
2017-08-17 12:52:10 +00:00
|
|
|
MLX5_RES_XRQ = 5,
|
2014-10-02 09:19:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_core_rsc_common {
|
|
|
|
enum mlx5_res_type res;
|
2019-08-06 01:59:50 +00:00
|
|
|
refcount_t refcount;
|
2014-10-02 09:19:45 +00:00
|
|
|
struct completion free;
|
2025-04-28 11:34:07 +00:00
|
|
|
bool invalid;
|
2014-10-02 09:19:45 +00:00
|
|
|
};
|
|
|
|
|
2017-01-03 21:55:23 +00:00
|
|
|
struct mlx5_uars_page {
|
2013-07-07 14:25:49 +00:00
|
|
|
void __iomem *map;
|
2017-01-03 21:55:23 +00:00
|
|
|
bool wc;
|
|
|
|
u32 index;
|
|
|
|
struct list_head list;
|
|
|
|
unsigned int bfregs;
|
|
|
|
unsigned long *reg_bitmap; /* for non fast path bf regs */
|
|
|
|
unsigned long *fp_bitmap;
|
|
|
|
unsigned int reg_avail;
|
|
|
|
unsigned int fp_avail;
|
|
|
|
struct kref ref_count;
|
|
|
|
struct mlx5_core_dev *mdev;
|
2013-07-07 14:25:49 +00:00
|
|
|
};
|
|
|
|
|
2017-01-03 21:55:23 +00:00
|
|
|
struct mlx5_bfreg_head {
|
|
|
|
/* protect blue flame registers allocations */
|
|
|
|
struct mutex lock;
|
|
|
|
struct list_head list;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_bfreg_data {
|
|
|
|
struct mlx5_bfreg_head reg_head;
|
|
|
|
struct mlx5_bfreg_head wc_head;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_sq_bfreg {
|
|
|
|
void __iomem *map;
|
|
|
|
struct mlx5_uars_page *up;
|
|
|
|
bool wc;
|
|
|
|
u32 index;
|
|
|
|
unsigned int offset;
|
|
|
|
};
|
2013-07-07 14:25:49 +00:00
|
|
|
|
|
|
|
struct mlx5_core_health {
|
|
|
|
struct health_buffer __iomem *health;
|
|
|
|
__be32 __iomem *health_counter;
|
|
|
|
struct timer_list timer;
|
|
|
|
u32 prev;
|
|
|
|
int miss_counter;
|
2018-12-11 14:09:56 +00:00
|
|
|
u8 synd;
|
2018-11-12 13:23:02 +00:00
|
|
|
u32 fatal_error;
|
2018-07-17 08:18:26 +00:00
|
|
|
u32 crdump_size;
|
2015-10-08 14:14:00 +00:00
|
|
|
struct workqueue_struct *wq;
|
2016-10-25 15:36:33 +00:00
|
|
|
unsigned long flags;
|
2019-01-27 16:38:39 +00:00
|
|
|
struct work_struct fatal_report_work;
|
2018-12-11 14:09:56 +00:00
|
|
|
struct work_struct report_work;
|
2018-12-11 14:09:53 +00:00
|
|
|
struct devlink_health_reporter *fw_reporter;
|
2018-12-11 14:09:57 +00:00
|
|
|
struct devlink_health_reporter *fw_fatal_reporter;
|
2023-03-20 22:10:16 +00:00
|
|
|
struct devlink_health_reporter *vnic_reporter;
|
2021-10-13 06:45:22 +00:00
|
|
|
struct delayed_work update_fw_log_ts_work;
|
2013-07-07 14:25:49 +00:00
|
|
|
};
|
|
|
|
|
2022-05-10 09:02:03 +00:00
|
|
|
enum {
|
|
|
|
MLX5_PF_NOTIFY_DISABLE_VF,
|
|
|
|
MLX5_PF_NOTIFY_ENABLE_VF,
|
|
|
|
};
|
|
|
|
|
2015-12-01 16:03:09 +00:00
|
|
|
struct mlx5_vf_context {
|
|
|
|
int enabled;
|
2017-05-30 07:18:24 +00:00
|
|
|
u64 port_guid;
|
|
|
|
u64 node_guid;
|
IB/mlx5: Return the administrative GUID if exists
A user can change the operational GUID (a.k.a affective GUID) through
link/infiniband. Therefore it is preferred to return the currently set
GUID if it exists instead of the operational.
This way the PF can query which VF GUID will be set in the next bind. In
order to align with MAC address, zero is returned if administrative GUID
is not set.
For example, before setting administrative GUID:
$ ip link show
ib0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 4092 qdisc mq state UP mode DEFAULT group default qlen 256
link/infiniband 00:00:00:08:fe:80:00:00:00:00:00:00:52:54:00:c0:fe:12:34:55 brd 00:ff:ff:ff:ff:12:40:1b:ff:ff:00:00:00:00:00:00:ff:ff:ff:ff
vf 0 link/infiniband 00:00:00:08:fe:80:00:00:00:00:00:00:52:54:00:c0:fe:12:34:55 brd 00:ff:ff:ff:ff:12:40:1b:ff:ff:00:00:00:00:00:00:ff:ff:ff:ff,
spoof checking off, NODE_GUID 00:00:00:00:00:00:00:00, PORT_GUID 00:00:00:00:00:00:00:00, link-state auto, trust off, query_rss off
Then:
$ ip link set ib0 vf 0 node_guid 11:00:af:21:cb:05:11:00
$ ip link set ib0 vf 0 port_guid 22:11:af:21:cb:05:11:00
After setting administrative GUID:
$ ip link show
ib0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 4092 qdisc mq state UP mode DEFAULT group default qlen 256
link/infiniband 00:00:00:08:fe:80:00:00:00:00:00:00:52:54:00:c0:fe:12:34:55 brd 00:ff:ff:ff:ff:12:40:1b:ff:ff:00:00:00:00:00:00:ff:ff:ff:ff
vf 0 link/infiniband 00:00:00:08:fe:80:00:00:00:00:00:00:52:54:00:c0:fe:12:34:55 brd 00:ff:ff:ff:ff:12:40:1b:ff:ff:00:00:00:00:00:00:ff:ff:ff:ff,
spoof checking off, NODE_GUID 11:00:af:21:cb:05:11:00, PORT_GUID 22:11:af:21:cb:05:11:00, link-state auto, trust off, query_rss off
Fixes: 9c0015ef0928 ("IB/mlx5: Implement callbacks for getting VFs GUID attributes")
Link: https://lore.kernel.org/r/20200116120048.12744-1-leon@kernel.org
Signed-off-by: Danit Goldberg <danitg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
2020-01-16 12:00:48 +00:00
|
|
|
/* Valid bits are used to validate administrative guid only.
|
|
|
|
* Enabled after ndo_set_vf_guid
|
|
|
|
*/
|
|
|
|
u8 port_guid_valid:1;
|
|
|
|
u8 node_guid_valid:1;
|
2017-05-30 07:18:24 +00:00
|
|
|
enum port_state_policy policy;
|
2022-05-10 09:02:03 +00:00
|
|
|
struct blocking_notifier_head notifier;
|
2015-12-01 16:03:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_core_sriov {
|
|
|
|
struct mlx5_vf_context *vfs_ctx;
|
|
|
|
int num_vfs;
|
2019-06-10 23:38:19 +00:00
|
|
|
u16 max_vfs;
|
2023-03-07 17:36:14 +00:00
|
|
|
u16 max_ec_vfs;
|
2015-12-01 16:03:09 +00:00
|
|
|
};
|
|
|
|
|
2018-11-20 22:12:27 +00:00
|
|
|
struct mlx5_events;
|
2017-06-04 20:11:55 +00:00
|
|
|
struct mlx5_mpfs;
|
2015-12-01 16:03:18 +00:00
|
|
|
struct mlx5_eswitch;
|
net/mlx5: Implement RoCE LAG feature
Available on dual port cards only, this feature keeps
track, using netdev LAG events, of the bonding
and link status of each port's PF netdev.
When both of the card's PF netdevs are enslaved to the
same bond/team master, and only them, LAG state
is active.
During LAG, only one IB device is present for both ports.
In addition to the above, this commit includes FW commands
used for managing the LAG, new facilities for adding and removing
a single device by interface, and port remap functionality according to
bond events.
Please note that this feature is currently used only for mimicking
Ethernet bonding for RoCE - netdevs functionality is not altered,
and their bonding continues to be managed solely by bond/team driver.
Signed-off-by: Aviv Heller <avivh@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2016-04-17 13:57:32 +00:00
|
|
|
struct mlx5_lag;
|
2023-05-04 09:14:00 +00:00
|
|
|
struct mlx5_devcom_dev;
|
2020-10-07 06:00:49 +00:00
|
|
|
struct mlx5_fw_reset;
|
2018-11-19 18:52:38 +00:00
|
|
|
struct mlx5_eq_table;
|
2019-06-10 23:38:27 +00:00
|
|
|
struct mlx5_irq_table;
|
2020-12-12 06:12:16 +00:00
|
|
|
struct mlx5_vhca_state_notifier;
|
2020-12-12 06:12:17 +00:00
|
|
|
struct mlx5_sf_dev_table;
|
net/mlx5: SF, Add port add delete functionality
To handle SF port management outside of the eswitch as independent
software layer, introduce eswitch notifier APIs so that mlx5 upper
layer who wish to support sf port management in switchdev mode can
perform its task whenever eswitch mode is set to switchdev or before
eswitch is disabled.
Initialize sf port table on such eswitch event.
Add SF port add and delete functionality in switchdev mode.
Destroy all SF ports when eswitch is disabled.
Expose SF port add and delete to user via devlink commands.
$ devlink dev eswitch set pci/0000:06:00.0 mode switchdev
$ devlink port show
pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false
$ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
pci/0000:06:00.0/32768: type eth netdev eth6 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
function:
hw_addr 00:00:00:00:00:00 state inactive opstate detached
$ devlink port show ens2f0npf0sf88
pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
function:
hw_addr 00:00:00:00:00:00 state inactive opstate detached
or by its unique port index:
$ devlink port show pci/0000:06:00.0/32768
pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
function:
hw_addr 00:00:00:00:00:00 state inactive opstate detached
$ devlink port show ens2f0npf0sf88 -jp
{
"port": {
"pci/0000:06:00.0/32768": {
"type": "eth",
"netdev": "ens2f0npf0sf88",
"flavour": "pcisf",
"controller": 0,
"pfnum": 0,
"sfnum": 88,
"external": false,
"splittable": false,
"function": {
"hw_addr": "00:00:00:00:00:00",
"state": "inactive",
"opstate": "detached"
}
}
}
}
Signed-off-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Vu Pham <vuhuong@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
2020-12-12 06:12:21 +00:00
|
|
|
struct mlx5_sf_hw_table;
|
|
|
|
struct mlx5_sf_table;
|
2022-05-23 04:10:02 +00:00
|
|
|
struct mlx5_crypto_dek_priv;
|
2015-12-01 16:03:18 +00:00
|
|
|
|
2018-03-19 13:10:29 +00:00
|
|
|
struct mlx5_rate_limit {
|
|
|
|
u32 rate;
|
|
|
|
u32 max_burst_sz;
|
|
|
|
u16 typical_pkt_sz;
|
|
|
|
};
|
|
|
|
|
2016-06-23 14:02:37 +00:00
|
|
|
struct mlx5_rl_entry {
|
2020-02-19 19:05:17 +00:00
|
|
|
u8 rl_raw[MLX5_ST_SZ_BYTES(set_pp_rate_limit_context)];
|
|
|
|
u64 refcount;
|
2021-02-19 06:18:12 +00:00
|
|
|
u16 index;
|
2020-02-19 19:05:17 +00:00
|
|
|
u16 uid;
|
|
|
|
u8 dedicated : 1;
|
2016-06-23 14:02:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_rl_table {
|
|
|
|
/* protect rate limit table */
|
|
|
|
struct mutex rl_lock;
|
|
|
|
u16 max_size;
|
|
|
|
u32 max_rate;
|
|
|
|
u32 min_rate;
|
|
|
|
struct mlx5_rl_entry *rl_entry;
|
2021-02-19 10:06:54 +00:00
|
|
|
u64 refcount;
|
2016-06-23 14:02:37 +00:00
|
|
|
};
|
|
|
|
|
2019-04-29 18:14:16 +00:00
|
|
|
struct mlx5_core_roce {
|
|
|
|
struct mlx5_flow_table *ft;
|
|
|
|
struct mlx5_flow_group *fg;
|
|
|
|
struct mlx5_flow_handle *allow_rule;
|
|
|
|
};
|
|
|
|
|
2020-10-08 13:06:37 +00:00
|
|
|
enum {
|
|
|
|
MLX5_PRIV_FLAGS_DISABLE_IB_ADEV = 1 << 0,
|
|
|
|
MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV = 1 << 1,
|
2021-05-14 08:14:19 +00:00
|
|
|
/* Set during device detach to block any further devices
|
|
|
|
* creation/deletion on drivers rescan. Unset during device attach.
|
|
|
|
*/
|
|
|
|
MLX5_PRIV_FLAGS_DETACH = 1 << 2,
|
net/mlx5e: Keep netdev when leave switchdev for devlink set legacy only
In the cited commit, when changing from switchdev to legacy mode,
uplink representor's netdev is kept, and its profile is replaced with
nic profile, so netdev is detached from old profile, then attach to
new profile.
During profile change, the hardware resources allocated by the old
profile will be cleaned up. However, the cleanup is relying on the
related kernel modules. And they may need to flush themselves first,
which is triggered by netdev events, for example, NETDEV_UNREGISTER.
However, netdev is kept, or netdev_register is called after the
cleanup, which may cause troubles because the resources are still
referred by kernel modules.
The same process applies to all the caes when uplink is leaving
switchdev mode, including devlink eswitch mode set legacy, driver
unload and devlink reload. For the first one, it can be blocked and
returns failure to users, whenever possible. But it's hard for the
others. Besides, the attachment to nic profile is unnecessary as the
netdev will be unregistered anyway for such cases.
So in this patch, the original behavior is kept only for devlink
eswitch set mode legacy. For the others, moves netdev unregistration
before the profile change.
Fixes: 7a9fb35e8c3a ("net/mlx5e: Do not reload ethernet ports when changing eswitch mode")
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20241220081505.1286093-5-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-12-20 08:15:05 +00:00
|
|
|
MLX5_PRIV_FLAGS_SWITCH_LEGACY = 1 << 3,
|
2020-10-08 13:06:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_adev {
|
|
|
|
struct auxiliary_device adev;
|
|
|
|
struct mlx5_core_dev *mdev;
|
|
|
|
int idx;
|
|
|
|
};
|
|
|
|
|
2022-02-18 07:36:20 +00:00
|
|
|
struct mlx5_debugfs_entries {
|
|
|
|
struct dentry *dbg_root;
|
|
|
|
struct dentry *qp_debugfs;
|
|
|
|
struct dentry *eq_debugfs;
|
|
|
|
struct dentry *cq_debugfs;
|
|
|
|
struct dentry *cmdif_debugfs;
|
2022-01-27 05:03:33 +00:00
|
|
|
struct dentry *pages_debugfs;
|
2022-03-15 16:56:50 +00:00
|
|
|
struct dentry *lag_debugfs;
|
2022-02-18 07:36:20 +00:00
|
|
|
};
|
|
|
|
|
2023-01-22 19:09:40 +00:00
|
|
|
enum mlx5_func_type {
|
|
|
|
MLX5_PF,
|
|
|
|
MLX5_VF,
|
2023-01-22 21:24:56 +00:00
|
|
|
MLX5_SF,
|
2023-01-22 19:09:40 +00:00
|
|
|
MLX5_HOST_PF,
|
2023-03-06 22:53:21 +00:00
|
|
|
MLX5_EC_VF,
|
2023-01-22 19:09:40 +00:00
|
|
|
MLX5_FUNC_TYPE_NUM,
|
|
|
|
};
|
|
|
|
|
2021-03-08 12:16:02 +00:00
|
|
|
struct mlx5_ft_pool;
|
2013-07-07 14:25:49 +00:00
|
|
|
struct mlx5_priv {
|
2019-06-10 23:38:27 +00:00
|
|
|
/* IRQ table valid only for real pci devices PF or VF */
|
|
|
|
struct mlx5_irq_table *irq_table;
|
2018-11-19 18:52:38 +00:00
|
|
|
struct mlx5_eq_table *eq_table;
|
2013-07-07 14:25:49 +00:00
|
|
|
|
|
|
|
/* pages stuff */
|
2018-11-20 22:12:23 +00:00
|
|
|
struct mlx5_nb pg_nb;
|
2013-07-07 14:25:49 +00:00
|
|
|
struct workqueue_struct *pg_wq;
|
2020-05-18 08:13:52 +00:00
|
|
|
struct xarray page_root_xa;
|
2014-12-11 15:04:23 +00:00
|
|
|
atomic_t reg_pages;
|
2013-10-23 06:53:19 +00:00
|
|
|
struct list_head free_list;
|
2023-01-22 19:09:40 +00:00
|
|
|
u32 fw_pages;
|
|
|
|
u32 page_counters[MLX5_FUNC_TYPE_NUM];
|
2022-01-27 05:51:14 +00:00
|
|
|
u32 fw_pages_alloc_failed;
|
|
|
|
u32 give_pages_dropped;
|
|
|
|
u32 reclaim_pages_discard;
|
2013-07-07 14:25:49 +00:00
|
|
|
|
|
|
|
struct mlx5_core_health health;
|
2021-01-26 23:24:07 +00:00
|
|
|
struct list_head traps;
|
2013-07-07 14:25:49 +00:00
|
|
|
|
2022-02-18 07:36:20 +00:00
|
|
|
struct mlx5_debugfs_entries dbg;
|
2013-07-07 14:25:49 +00:00
|
|
|
|
|
|
|
/* start: alloc staff */
|
2021-07-30 03:03:00 +00:00
|
|
|
/* protect buffer allocation according to numa node */
|
2015-07-23 20:35:57 +00:00
|
|
|
struct mutex alloc_mutex;
|
|
|
|
int numa_node;
|
|
|
|
|
2013-07-07 14:25:49 +00:00
|
|
|
struct mutex pgdir_mutex;
|
|
|
|
struct list_head pgdir_list;
|
|
|
|
/* end: alloc staff */
|
|
|
|
|
2020-10-08 13:06:37 +00:00
|
|
|
struct mlx5_adev **adev;
|
|
|
|
int adev_idx;
|
2022-06-02 09:47:34 +00:00
|
|
|
int sw_vhca_id;
|
2018-11-26 22:39:01 +00:00
|
|
|
struct mlx5_events *events;
|
2023-10-12 19:27:36 +00:00
|
|
|
struct mlx5_vhca_events *vhca_events;
|
2017-06-07 09:14:24 +00:00
|
|
|
|
2016-07-04 14:23:06 +00:00
|
|
|
struct mlx5_flow_steering *steering;
|
2017-06-04 20:11:55 +00:00
|
|
|
struct mlx5_mpfs *mpfs;
|
2015-12-01 16:03:18 +00:00
|
|
|
struct mlx5_eswitch *eswitch;
|
2015-12-01 16:03:09 +00:00
|
|
|
struct mlx5_core_sriov sriov;
|
net/mlx5: Implement RoCE LAG feature
Available on dual port cards only, this feature keeps
track, using netdev LAG events, of the bonding
and link status of each port's PF netdev.
When both of the card's PF netdevs are enslaved to the
same bond/team master, and only them, LAG state
is active.
During LAG, only one IB device is present for both ports.
In addition to the above, this commit includes FW commands
used for managing the LAG, new facilities for adding and removing
a single device by interface, and port remap functionality according to
bond events.
Please note that this feature is currently used only for mimicking
Ethernet bonding for RoCE - netdevs functionality is not altered,
and their bonding continues to be managed solely by bond/team driver.
Signed-off-by: Aviv Heller <avivh@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2016-04-17 13:57:32 +00:00
|
|
|
struct mlx5_lag *lag;
|
2020-10-08 13:06:37 +00:00
|
|
|
u32 flags;
|
2023-05-04 09:14:00 +00:00
|
|
|
struct mlx5_devcom_dev *devc;
|
2023-10-12 19:27:39 +00:00
|
|
|
struct mlx5_devcom_comp_dev *hca_devcom_comp;
|
2020-10-07 06:00:49 +00:00
|
|
|
struct mlx5_fw_reset *fw_reset;
|
2019-04-29 18:14:16 +00:00
|
|
|
struct mlx5_core_roce roce;
|
2024-10-01 10:37:04 +00:00
|
|
|
struct mlx5_fc_stats *fc_stats;
|
2016-06-23 14:02:37 +00:00
|
|
|
struct mlx5_rl_table rl_table;
|
2021-03-08 12:16:02 +00:00
|
|
|
struct mlx5_ft_pool *ft_pool;
|
2016-11-17 11:45:57 +00:00
|
|
|
|
2017-01-03 21:55:23 +00:00
|
|
|
struct mlx5_bfreg_data bfregs;
|
2017-01-03 21:55:24 +00:00
|
|
|
struct mlx5_uars_page *uar;
|
2020-12-12 06:12:16 +00:00
|
|
|
#ifdef CONFIG_MLX5_SF
|
|
|
|
struct mlx5_vhca_state_notifier *vhca_state_notifier;
|
2020-12-12 06:12:17 +00:00
|
|
|
struct mlx5_sf_dev_table *sf_dev_table;
|
2020-12-12 06:12:18 +00:00
|
|
|
struct mlx5_core_dev *parent_mdev;
|
2020-12-12 06:12:16 +00:00
|
|
|
#endif
|
net/mlx5: SF, Add port add delete functionality
To handle SF port management outside of the eswitch as independent
software layer, introduce eswitch notifier APIs so that mlx5 upper
layer who wish to support sf port management in switchdev mode can
perform its task whenever eswitch mode is set to switchdev or before
eswitch is disabled.
Initialize sf port table on such eswitch event.
Add SF port add and delete functionality in switchdev mode.
Destroy all SF ports when eswitch is disabled.
Expose SF port add and delete to user via devlink commands.
$ devlink dev eswitch set pci/0000:06:00.0 mode switchdev
$ devlink port show
pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false
$ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
pci/0000:06:00.0/32768: type eth netdev eth6 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
function:
hw_addr 00:00:00:00:00:00 state inactive opstate detached
$ devlink port show ens2f0npf0sf88
pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
function:
hw_addr 00:00:00:00:00:00 state inactive opstate detached
or by its unique port index:
$ devlink port show pci/0000:06:00.0/32768
pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
function:
hw_addr 00:00:00:00:00:00 state inactive opstate detached
$ devlink port show ens2f0npf0sf88 -jp
{
"port": {
"pci/0000:06:00.0/32768": {
"type": "eth",
"netdev": "ens2f0npf0sf88",
"flavour": "pcisf",
"controller": 0,
"pfnum": 0,
"sfnum": 88,
"external": false,
"splittable": false,
"function": {
"hw_addr": "00:00:00:00:00:00",
"state": "inactive",
"opstate": "detached"
}
}
}
}
Signed-off-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Vu Pham <vuhuong@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
2020-12-12 06:12:21 +00:00
|
|
|
#ifdef CONFIG_MLX5_SF_MANAGER
|
|
|
|
struct mlx5_sf_hw_table *sf_hw_table;
|
|
|
|
struct mlx5_sf_table *sf_table;
|
|
|
|
#endif
|
2024-09-09 17:30:23 +00:00
|
|
|
struct blocking_notifier_head lag_nh;
|
2013-07-07 14:25:49 +00:00
|
|
|
};
|
|
|
|
|
2015-10-14 14:43:46 +00:00
|
|
|
enum mlx5_device_state {
|
2021-08-01 08:37:57 +00:00
|
|
|
MLX5_DEVICE_STATE_UP = 1,
|
2015-10-14 14:43:46 +00:00
|
|
|
MLX5_DEVICE_STATE_INTERNAL_ERROR,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum mlx5_interface_state {
|
2017-08-08 18:17:00 +00:00
|
|
|
MLX5_INTERFACE_STATE_UP = BIT(0),
|
2022-03-27 14:45:32 +00:00
|
|
|
MLX5_BREAK_FW_WAIT = BIT(1),
|
2015-10-14 14:43:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum mlx5_pci_status {
|
|
|
|
MLX5_PCI_STATUS_DISABLED,
|
|
|
|
MLX5_PCI_STATUS_ENABLED,
|
|
|
|
};
|
|
|
|
|
2017-01-02 09:37:46 +00:00
|
|
|
enum mlx5_pagefault_type_flags {
|
|
|
|
MLX5_PFAULT_REQUESTOR = 1 << 0,
|
|
|
|
MLX5_PFAULT_WRITE = 1 << 1,
|
|
|
|
MLX5_PFAULT_RDMA = 1 << 2,
|
|
|
|
};
|
|
|
|
|
2016-07-01 11:51:04 +00:00
|
|
|
struct mlx5_td {
|
2019-03-11 04:18:24 +00:00
|
|
|
/* protects tirs list changes while tirs refresh */
|
|
|
|
struct mutex list_lock;
|
2016-07-01 11:51:04 +00:00
|
|
|
struct list_head tirs_list;
|
|
|
|
u32 tdn;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5e_resources {
|
2021-01-26 09:51:04 +00:00
|
|
|
struct mlx5e_hw_objs {
|
|
|
|
u32 pdn;
|
|
|
|
struct mlx5_td td;
|
2021-10-12 10:26:33 +00:00
|
|
|
u32 mkey;
|
2021-01-26 09:51:04 +00:00
|
|
|
struct mlx5_sq_bfreg bfreg;
|
2023-08-06 11:01:10 +00:00
|
|
|
#define MLX5_MAX_NUM_TC 8
|
|
|
|
u32 tisn[MLX5_MAX_PORTS][MLX5_MAX_NUM_TC];
|
2023-12-16 03:31:14 +00:00
|
|
|
bool tisn_valid;
|
2021-01-26 09:51:04 +00:00
|
|
|
} hw_objs;
|
2020-09-16 07:11:33 +00:00
|
|
|
struct net_device *uplink_netdev;
|
2022-11-01 14:27:43 +00:00
|
|
|
struct mutex uplink_netdev_lock;
|
2022-05-23 04:10:02 +00:00
|
|
|
struct mlx5_crypto_dek_priv *dek_priv;
|
2016-07-01 11:51:04 +00:00
|
|
|
};
|
|
|
|
|
2019-08-29 23:42:30 +00:00
|
|
|
enum mlx5_sw_icm_type {
|
|
|
|
MLX5_SW_ICM_TYPE_STEERING,
|
|
|
|
MLX5_SW_ICM_TYPE_HEADER_MODIFY,
|
2022-06-07 12:47:44 +00:00
|
|
|
MLX5_SW_ICM_TYPE_HEADER_MODIFY_PATTERN,
|
2023-12-06 14:01:35 +00:00
|
|
|
MLX5_SW_ICM_TYPE_SW_ENCAP,
|
2019-08-29 23:42:30 +00:00
|
|
|
};
|
|
|
|
|
2017-03-26 14:01:57 +00:00
|
|
|
#define MLX5_MAX_RESERVED_GIDS 8
|
|
|
|
|
|
|
|
struct mlx5_rsvd_gids {
|
|
|
|
unsigned int start;
|
|
|
|
unsigned int count;
|
|
|
|
struct ida ida;
|
|
|
|
};
|
|
|
|
|
2025-02-03 21:35:06 +00:00
|
|
|
struct mlx5_clock;
|
2025-02-03 21:35:07 +00:00
|
|
|
struct mlx5_clock_dev_state;
|
2019-08-29 23:42:30 +00:00
|
|
|
struct mlx5_dm;
|
2018-07-16 22:22:01 +00:00
|
|
|
struct mlx5_fw_tracer;
|
2018-05-09 20:28:00 +00:00
|
|
|
struct mlx5_vxlan;
|
2019-01-30 15:21:55 +00:00
|
|
|
struct mlx5_geneve;
|
2019-08-22 05:05:51 +00:00
|
|
|
struct mlx5_hv_vhca;
|
2018-07-16 22:22:01 +00:00
|
|
|
|
2019-08-29 23:42:30 +00:00
|
|
|
#define MLX5_LOG_SW_ICM_BLOCK_SIZE(dev) (MLX5_CAP_DEV_MEM(dev, log_sw_icm_alloc_granularity))
|
|
|
|
#define MLX5_SW_ICM_BLOCK_SIZE(dev) (1 << MLX5_LOG_SW_ICM_BLOCK_SIZE(dev))
|
|
|
|
|
2021-05-12 10:52:27 +00:00
|
|
|
enum {
|
|
|
|
MLX5_PROF_MASK_QP_SIZE = (u64)1 << 0,
|
|
|
|
MLX5_PROF_MASK_MR_CACHE = (u64)1 << 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2022-07-26 07:19:11 +00:00
|
|
|
MKEY_CACHE_LAST_STD_ENTRY = 20,
|
2021-05-12 10:52:27 +00:00
|
|
|
MLX5_IMR_KSM_CACHE_ENTRY,
|
2022-07-26 07:19:11 +00:00
|
|
|
MAX_MKEY_CACHE_ENTRIES
|
2021-05-12 10:52:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_profile {
|
|
|
|
u64 mask;
|
|
|
|
u8 log_max_qp;
|
2020-04-23 13:27:59 +00:00
|
|
|
u8 num_cmd_caches;
|
2021-05-12 10:52:27 +00:00
|
|
|
struct {
|
|
|
|
int size;
|
|
|
|
int limit;
|
2022-07-26 07:19:11 +00:00
|
|
|
} mr_cache[MAX_MKEY_CACHE_ENTRIES];
|
2021-05-12 10:52:27 +00:00
|
|
|
};
|
|
|
|
|
2021-07-13 09:36:05 +00:00
|
|
|
struct mlx5_hca_cap {
|
|
|
|
u32 cur[MLX5_UN_SZ_DW(hca_cap_union)];
|
|
|
|
u32 max[MLX5_UN_SZ_DW(hca_cap_union)];
|
|
|
|
};
|
|
|
|
|
net/mlx5: Reimplement write combining test
The test of write combining was added before in mlx5_ib driver. It
opens UD QP and posts NOP WQEs, and uses BlueFlame doorbell. When
BlueFlame is used, WQEs get written directly to a PCI BAR of the
device (in addition to memory) so that the device handles them without
having to access memory.
In this test, the WQEs written in memory are different from the ones
written to the BlueFlame which request CQE update. By checking the
completion reports posted on CQ, we can know if BlueFlame succeeds or
not. The write combining must be supported if BlueFlame succeeds as
its register is written using write combining.
This patch reimplements the test in the same way, but using a pair of
SQ and CQ only. It is moved to mlx5_core as a general feature used by
both mlx5_core and mlx5_ib.
Besides, save write combine test result of the PCI function, so that
its thousands of child functions such as SF can query without paying
the time and resource penalty by itself. The test function is called
only after failing to get the cached result. With this enhancement,
all thousands of SFs of the PF attached to same driver no longer need
to perform WC check explicitly, which is already done in the system.
This saves several commands per SF, thereby speeds up SF creation and
also saves completion EQ creation.
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/4ff5a8cc4c5b5b0d98397baa45a5019bcdbf096e.1717409369.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2024-06-03 10:26:37 +00:00
|
|
|
enum mlx5_wc_state {
|
|
|
|
MLX5_WC_STATE_UNINITIALIZED,
|
|
|
|
MLX5_WC_STATE_UNSUPPORTED,
|
|
|
|
MLX5_WC_STATE_SUPPORTED,
|
|
|
|
};
|
|
|
|
|
2013-07-07 14:25:49 +00:00
|
|
|
struct mlx5_core_dev {
|
2019-04-29 18:14:02 +00:00
|
|
|
struct device *device;
|
2019-06-28 22:35:58 +00:00
|
|
|
enum mlx5_coredev_type coredev_type;
|
2013-07-07 14:25:49 +00:00
|
|
|
struct pci_dev *pdev;
|
2015-10-14 14:43:46 +00:00
|
|
|
/* sync pci state */
|
|
|
|
struct mutex pci_status_mutex;
|
|
|
|
enum mlx5_pci_status pci_status;
|
2013-07-07 14:25:49 +00:00
|
|
|
u8 rev_id;
|
|
|
|
char board_id[MLX5_BOARD_ID_LEN];
|
|
|
|
struct mlx5_cmd cmd;
|
2016-12-08 14:03:31 +00:00
|
|
|
struct {
|
2021-07-13 11:17:03 +00:00
|
|
|
struct mlx5_hca_cap *hca[MLX5_CAP_NUM];
|
2016-12-08 14:03:31 +00:00
|
|
|
u32 pcam[MLX5_ST_SZ_DW(pcam_reg)];
|
2019-10-07 07:31:42 +00:00
|
|
|
u32 mcam[MLX5_MCAM_REGS_NUM][MLX5_ST_SZ_DW(mcam_reg)];
|
2017-08-24 14:21:44 +00:00
|
|
|
u32 fpga[MLX5_ST_SZ_DW(fpga_cap)];
|
2017-07-18 21:03:17 +00:00
|
|
|
u32 qcam[MLX5_ST_SZ_DW(qcam_reg)];
|
2019-02-13 06:55:35 +00:00
|
|
|
u8 embedded_cpu;
|
2016-12-08 14:03:31 +00:00
|
|
|
} caps;
|
2021-10-07 15:00:27 +00:00
|
|
|
struct mlx5_timeouts *timeouts;
|
2018-09-05 14:06:37 +00:00
|
|
|
u64 sys_image_guid;
|
2013-07-07 14:25:49 +00:00
|
|
|
phys_addr_t iseg_base;
|
|
|
|
struct mlx5_init_seg __iomem *iseg;
|
2019-03-29 22:38:01 +00:00
|
|
|
phys_addr_t bar_addr;
|
2015-10-14 14:43:46 +00:00
|
|
|
enum mlx5_device_state state;
|
|
|
|
/* sync interface state */
|
|
|
|
struct mutex intf_state_mutex;
|
net/mlx5: Avoid false positive lockdep warning by adding lock_class_key
Add a lock_class_key per mlx5 device to avoid a false positive
"possible circular locking dependency" warning by lockdep, on flows
which lock more than one mlx5 device, such as adding SF.
kernel log:
======================================================
WARNING: possible circular locking dependency detected
5.19.0-rc8+ #2 Not tainted
------------------------------------------------------
kworker/u20:0/8 is trying to acquire lock:
ffff88812dfe0d98 (&dev->intf_state_mutex){+.+.}-{3:3}, at: mlx5_init_one+0x2e/0x490 [mlx5_core]
but task is already holding lock:
ffff888101aa7898 (&(¬ifier->n_head)->rwsem){++++}-{3:3}, at: blocking_notifier_call_chain+0x5a/0x130
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (&(¬ifier->n_head)->rwsem){++++}-{3:3}:
down_write+0x90/0x150
blocking_notifier_chain_register+0x53/0xa0
mlx5_sf_table_init+0x369/0x4a0 [mlx5_core]
mlx5_init_one+0x261/0x490 [mlx5_core]
probe_one+0x430/0x680 [mlx5_core]
local_pci_probe+0xd6/0x170
work_for_cpu_fn+0x4e/0xa0
process_one_work+0x7c2/0x1340
worker_thread+0x6f6/0xec0
kthread+0x28f/0x330
ret_from_fork+0x1f/0x30
-> #0 (&dev->intf_state_mutex){+.+.}-{3:3}:
__lock_acquire+0x2fc7/0x6720
lock_acquire+0x1c1/0x550
__mutex_lock+0x12c/0x14b0
mlx5_init_one+0x2e/0x490 [mlx5_core]
mlx5_sf_dev_probe+0x29c/0x370 [mlx5_core]
auxiliary_bus_probe+0x9d/0xe0
really_probe+0x1e0/0xaa0
__driver_probe_device+0x219/0x480
driver_probe_device+0x49/0x130
__device_attach_driver+0x1b8/0x280
bus_for_each_drv+0x123/0x1a0
__device_attach+0x1a3/0x460
bus_probe_device+0x1a2/0x260
device_add+0x9b1/0x1b40
__auxiliary_device_add+0x88/0xc0
mlx5_sf_dev_state_change_handler+0x67e/0x9d0 [mlx5_core]
blocking_notifier_call_chain+0xd5/0x130
mlx5_vhca_state_work_handler+0x2b0/0x3f0 [mlx5_core]
process_one_work+0x7c2/0x1340
worker_thread+0x59d/0xec0
kthread+0x28f/0x330
ret_from_fork+0x1f/0x30
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&(¬ifier->n_head)->rwsem);
lock(&dev->intf_state_mutex);
lock(&(¬ifier->n_head)->rwsem);
lock(&dev->intf_state_mutex);
*** DEADLOCK ***
4 locks held by kworker/u20:0/8:
#0: ffff888150612938 ((wq_completion)mlx5_events){+.+.}-{0:0}, at: process_one_work+0x6e2/0x1340
#1: ffff888100cafdb8 ((work_completion)(&work->work)#3){+.+.}-{0:0}, at: process_one_work+0x70f/0x1340
#2: ffff888101aa7898 (&(¬ifier->n_head)->rwsem){++++}-{3:3}, at: blocking_notifier_call_chain+0x5a/0x130
#3: ffff88813682d0e8 (&dev->mutex){....}-{3:3}, at:__device_attach+0x76/0x460
stack backtrace:
CPU: 6 PID: 8 Comm: kworker/u20:0 Not tainted 5.19.0-rc8+
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
Workqueue: mlx5_events mlx5_vhca_state_work_handler [mlx5_core]
Call Trace:
<TASK>
dump_stack_lvl+0x57/0x7d
check_noncircular+0x278/0x300
? print_circular_bug+0x460/0x460
? lock_chain_count+0x20/0x20
? register_lock_class+0x1880/0x1880
__lock_acquire+0x2fc7/0x6720
? register_lock_class+0x1880/0x1880
? register_lock_class+0x1880/0x1880
lock_acquire+0x1c1/0x550
? mlx5_init_one+0x2e/0x490 [mlx5_core]
? lockdep_hardirqs_on_prepare+0x400/0x400
__mutex_lock+0x12c/0x14b0
? mlx5_init_one+0x2e/0x490 [mlx5_core]
? mlx5_init_one+0x2e/0x490 [mlx5_core]
? _raw_read_unlock+0x1f/0x30
? mutex_lock_io_nested+0x1320/0x1320
? __ioremap_caller.constprop.0+0x306/0x490
? mlx5_sf_dev_probe+0x269/0x370 [mlx5_core]
? iounmap+0x160/0x160
mlx5_init_one+0x2e/0x490 [mlx5_core]
mlx5_sf_dev_probe+0x29c/0x370 [mlx5_core]
? mlx5_sf_dev_remove+0x130/0x130 [mlx5_core]
auxiliary_bus_probe+0x9d/0xe0
really_probe+0x1e0/0xaa0
__driver_probe_device+0x219/0x480
? auxiliary_match_id+0xe9/0x140
driver_probe_device+0x49/0x130
__device_attach_driver+0x1b8/0x280
? driver_allows_async_probing+0x140/0x140
bus_for_each_drv+0x123/0x1a0
? bus_for_each_dev+0x1a0/0x1a0
? lockdep_hardirqs_on_prepare+0x286/0x400
? trace_hardirqs_on+0x2d/0x100
__device_attach+0x1a3/0x460
? device_driver_attach+0x1e0/0x1e0
? kobject_uevent_env+0x22d/0xf10
bus_probe_device+0x1a2/0x260
device_add+0x9b1/0x1b40
? dev_set_name+0xab/0xe0
? __fw_devlink_link_to_suppliers+0x260/0x260
? memset+0x20/0x40
? lockdep_init_map_type+0x21a/0x7d0
__auxiliary_device_add+0x88/0xc0
? auxiliary_device_init+0x86/0xa0
mlx5_sf_dev_state_change_handler+0x67e/0x9d0 [mlx5_core]
blocking_notifier_call_chain+0xd5/0x130
mlx5_vhca_state_work_handler+0x2b0/0x3f0 [mlx5_core]
? mlx5_vhca_event_arm+0x100/0x100 [mlx5_core]
? lock_downgrade+0x6e0/0x6e0
? lockdep_hardirqs_on_prepare+0x286/0x400
process_one_work+0x7c2/0x1340
? lockdep_hardirqs_on_prepare+0x400/0x400
? pwq_dec_nr_in_flight+0x230/0x230
? rwlock_bug.part.0+0x90/0x90
worker_thread+0x59d/0xec0
? process_one_work+0x1340/0x1340
kthread+0x28f/0x330
? kthread_complete_and_exit+0x20/0x20
ret_from_fork+0x1f/0x30
</TASK>
Fixes: 6a3273217469 ("net/mlx5: SF, Port function state change support")
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Shay Drory <shayd@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
2022-08-03 07:49:23 +00:00
|
|
|
struct lock_class_key lock_key;
|
2016-04-21 21:33:07 +00:00
|
|
|
unsigned long intf_state;
|
2013-07-07 14:25:49 +00:00
|
|
|
struct mlx5_priv priv;
|
2021-05-12 10:52:27 +00:00
|
|
|
struct mlx5_profile profile;
|
2015-05-28 19:28:48 +00:00
|
|
|
u32 issi;
|
2016-07-01 11:51:04 +00:00
|
|
|
struct mlx5e_resources mlx5e_res;
|
2019-08-29 23:42:30 +00:00
|
|
|
struct mlx5_dm *dm;
|
2018-05-09 20:28:00 +00:00
|
|
|
struct mlx5_vxlan *vxlan;
|
2019-01-30 15:21:55 +00:00
|
|
|
struct mlx5_geneve *geneve;
|
2017-03-26 14:01:57 +00:00
|
|
|
struct {
|
|
|
|
struct mlx5_rsvd_gids reserved_gids;
|
2018-01-04 15:25:31 +00:00
|
|
|
u32 roce_en;
|
2017-03-26 14:01:57 +00:00
|
|
|
} roce;
|
2017-03-13 18:05:45 +00:00
|
|
|
#ifdef CONFIG_MLX5_FPGA
|
|
|
|
struct mlx5_fpga_device *fpga;
|
2016-04-28 22:36:39 +00:00
|
|
|
#endif
|
2025-02-03 21:35:06 +00:00
|
|
|
struct mlx5_clock *clock;
|
2025-02-03 21:35:07 +00:00
|
|
|
struct mlx5_clock_dev_state *clock_state;
|
2018-01-16 18:08:40 +00:00
|
|
|
struct mlx5_ib_clock_info *clock_info;
|
2018-07-16 22:22:01 +00:00
|
|
|
struct mlx5_fw_tracer *tracer;
|
2020-02-11 22:32:43 +00:00
|
|
|
struct mlx5_rsc_dump *rsc_dump;
|
2018-06-28 12:05:58 +00:00
|
|
|
u32 vsc_addr;
|
2019-08-22 05:05:51 +00:00
|
|
|
struct mlx5_hv_vhca *hv_vhca;
|
net/mlx5: Expose NIC temperature via hardware monitoring kernel API
Expose NIC temperature by implementing hwmon kernel API, which turns
current thermal zone kernel API to redundant.
For each one of the supported and exposed thermal diode sensors, expose
the following attributes:
1) Input temperature.
2) Highest temperature.
3) Temperature label:
Depends on the firmware capability, if firmware doesn't support
sensors naming, the fallback naming convention would be: "sensorX",
where X is the HW spec (MTMP register) sensor index.
4) Temperature critical max value:
refers to the high threshold of Warning Event. Will be exposed as
`tempY_crit` hwmon attribute (RO attribute). For example for
ConnectX5 HCA's this temperature value will be 105 Celsius, 10
degrees lower than the HW shutdown temperature).
5) Temperature reset history: resets highest temperature.
For example, for dualport ConnectX5 NIC with a single IC thermal diode
sensor will have 2 hwmon directories (one for each PCI function)
under "/sys/class/hwmon/hwmon[X,Y]".
Listing one of the directories above (hwmonX/Y) generates the
corresponding output below:
$ grep -H -d skip . /sys/class/hwmon/hwmon0/*
Output
=======================================================================
/sys/class/hwmon/hwmon0/name:mlx5
/sys/class/hwmon/hwmon0/temp1_crit:105000
/sys/class/hwmon/hwmon0/temp1_highest:48000
/sys/class/hwmon/hwmon0/temp1_input:46000
/sys/class/hwmon/hwmon0/temp1_label:asic
grep: /sys/class/hwmon/hwmon0/temp1_reset_history: Permission denied
In addition, displaying the sensors data via lm_sensors generates the
corresponding output below:
$ sensors
Output
=======================================================================
mlx5-pci-0800
Adapter: PCI adapter
asic: +46.0°C (crit = +105.0°C, highest = +48.0°C)
mlx5-pci-0801
Adapter: PCI adapter
asic: +46.0°C (crit = +105.0°C, highest = +48.0°C)
CC: Jean Delvare <jdelvare@suse.com>
Signed-off-by: Adham Faris <afaris@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20230807180507.22984-3-saeed@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-08-07 18:05:07 +00:00
|
|
|
struct mlx5_hwmon *hwmon;
|
2023-07-31 11:28:24 +00:00
|
|
|
u64 num_block_tc;
|
|
|
|
u64 num_block_ipsec;
|
2022-12-06 12:33:49 +00:00
|
|
|
#ifdef CONFIG_MLX5_MACSEC
|
|
|
|
struct mlx5_macsec_fs *macsec_fs;
|
2023-04-13 09:04:42 +00:00
|
|
|
/* MACsec notifier chain to sync MACsec core and IB database */
|
|
|
|
struct blocking_notifier_head macsec_nh;
|
2022-12-06 12:33:49 +00:00
|
|
|
#endif
|
2023-08-25 06:28:34 +00:00
|
|
|
u64 num_ipsec_offloads;
|
2024-02-15 03:08:13 +00:00
|
|
|
struct mlx5_sd *sd;
|
net/mlx5: Reimplement write combining test
The test of write combining was added before in mlx5_ib driver. It
opens UD QP and posts NOP WQEs, and uses BlueFlame doorbell. When
BlueFlame is used, WQEs get written directly to a PCI BAR of the
device (in addition to memory) so that the device handles them without
having to access memory.
In this test, the WQEs written in memory are different from the ones
written to the BlueFlame which request CQE update. By checking the
completion reports posted on CQ, we can know if BlueFlame succeeds or
not. The write combining must be supported if BlueFlame succeeds as
its register is written using write combining.
This patch reimplements the test in the same way, but using a pair of
SQ and CQ only. It is moved to mlx5_core as a general feature used by
both mlx5_core and mlx5_ib.
Besides, save write combine test result of the PCI function, so that
its thousands of child functions such as SF can query without paying
the time and resource penalty by itself. The test function is called
only after failing to get the cached result. With this enhancement,
all thousands of SFs of the PF attached to same driver no longer need
to perform WC check explicitly, which is already done in the system.
This saves several commands per SF, thereby speeds up SF creation and
also saves completion EQ creation.
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/4ff5a8cc4c5b5b0d98397baa45a5019bcdbf096e.1717409369.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2024-06-03 10:26:37 +00:00
|
|
|
enum mlx5_wc_state wc_state;
|
|
|
|
/* sync write combining state */
|
|
|
|
struct mutex wc_state_lock;
|
2013-07-07 14:25:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_db {
|
|
|
|
__be32 *db;
|
|
|
|
union {
|
|
|
|
struct mlx5_db_pgdir *pgdir;
|
|
|
|
struct mlx5_ib_user_db_page *user_page;
|
|
|
|
} u;
|
|
|
|
dma_addr_t dma;
|
|
|
|
int index;
|
|
|
|
};
|
|
|
|
|
2021-10-26 15:29:39 +00:00
|
|
|
enum {
|
|
|
|
MLX5_COMP_EQ_SIZE = 1024,
|
|
|
|
};
|
|
|
|
|
2015-05-28 19:28:42 +00:00
|
|
|
enum {
|
|
|
|
MLX5_PTYS_IB = 1 << 0,
|
|
|
|
MLX5_PTYS_EN = 1 << 2,
|
|
|
|
};
|
|
|
|
|
2013-07-07 14:25:49 +00:00
|
|
|
typedef void (*mlx5_cmd_cbk_t)(int status, void *context);
|
|
|
|
|
2017-02-23 09:19:36 +00:00
|
|
|
enum {
|
|
|
|
MLX5_CMD_ENT_STATE_PENDING_COMP,
|
|
|
|
};
|
|
|
|
|
2013-07-07 14:25:49 +00:00
|
|
|
struct mlx5_cmd_work_ent {
|
2017-02-23 09:19:36 +00:00
|
|
|
unsigned long state;
|
2013-07-07 14:25:49 +00:00
|
|
|
struct mlx5_cmd_msg *in;
|
|
|
|
struct mlx5_cmd_msg *out;
|
2013-10-23 06:53:14 +00:00
|
|
|
void *uout;
|
|
|
|
int uout_size;
|
2013-07-07 14:25:49 +00:00
|
|
|
mlx5_cmd_cbk_t callback;
|
2016-06-30 14:34:43 +00:00
|
|
|
struct delayed_work cb_timeout_work;
|
2013-07-07 14:25:49 +00:00
|
|
|
void *context;
|
2013-10-23 06:53:14 +00:00
|
|
|
int idx;
|
2019-12-27 05:01:53 +00:00
|
|
|
struct completion handling;
|
2024-05-09 11:29:50 +00:00
|
|
|
struct completion slotted;
|
2013-07-07 14:25:49 +00:00
|
|
|
struct completion done;
|
|
|
|
struct mlx5_cmd *cmd;
|
|
|
|
struct work_struct work;
|
|
|
|
struct mlx5_cmd_layout *lay;
|
|
|
|
int ret;
|
|
|
|
int page_queue;
|
|
|
|
u8 status;
|
|
|
|
u8 token;
|
2014-07-16 21:04:44 +00:00
|
|
|
u64 ts1;
|
|
|
|
u64 ts2;
|
2013-10-23 06:53:14 +00:00
|
|
|
u16 op;
|
2017-02-09 11:20:46 +00:00
|
|
|
bool polling;
|
net/mlx5: Avoid possible free of command entry while timeout comp handler
Upon command completion timeout, driver simulates a forced command
completion. In a rare case where real interrupt for that command arrives
simultaneously, it might release the command entry while the forced
handler might still access it.
Fix that by adding an entry refcount, to track current amount of allowed
handlers. Command entry to be released only when this refcount is
decremented to zero.
Command refcount is always initialized to one. For callback commands,
command completion handler is the symmetric flow to decrement it. For
non-callback commands, it is wait_func().
Before ringing the doorbell, increment the refcount for the real completion
handler. Once the real completion handler is called, it will decrement it.
For callback commands, once the delayed work is scheduled, increment the
refcount. Upon callback command completion handler, we will try to cancel
the timeout callback. In case of success, we need to decrement the callback
refcount as it will never run.
In addition, gather the entry index free and the entry free into a one
flow for all command types release.
Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Reviewed-by: Moshe Shemesh <moshe@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
2020-08-04 07:40:21 +00:00
|
|
|
/* Track the max comp handlers */
|
|
|
|
refcount_t refcnt;
|
2013-07-07 14:25:49 +00:00
|
|
|
};
|
|
|
|
|
2015-06-04 16:30:41 +00:00
|
|
|
enum phy_port_state {
|
|
|
|
MLX5_AAA_111
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_hca_vport_context {
|
|
|
|
u32 field_select;
|
|
|
|
bool sm_virt_aware;
|
|
|
|
bool has_smi;
|
|
|
|
bool has_raw;
|
|
|
|
enum port_state_policy policy;
|
|
|
|
enum phy_port_state phys_state;
|
|
|
|
enum ib_port_state vport_state;
|
|
|
|
u8 port_physical_state;
|
|
|
|
u64 sys_image_guid;
|
|
|
|
u64 port_guid;
|
|
|
|
u64 node_guid;
|
|
|
|
u32 cap_mask1;
|
|
|
|
u32 cap_mask1_perm;
|
2018-12-09 09:49:51 +00:00
|
|
|
u16 cap_mask2;
|
|
|
|
u16 cap_mask2_perm;
|
2015-06-04 16:30:41 +00:00
|
|
|
u16 lid;
|
|
|
|
u8 init_type_reply; /* bitmask: see ib spec 14.2.5.6 InitTypeReply */
|
|
|
|
u8 lmc;
|
|
|
|
u8 subnet_timeout;
|
|
|
|
u16 sm_lid;
|
|
|
|
u8 sm_sl;
|
|
|
|
u16 qkey_violation_counter;
|
|
|
|
u16 pkey_violation_counter;
|
|
|
|
bool grh_required;
|
2024-06-16 16:08:35 +00:00
|
|
|
u8 num_plane;
|
2015-06-04 16:30:41 +00:00
|
|
|
};
|
|
|
|
|
2013-07-07 14:25:49 +00:00
|
|
|
#define STRUCT_FIELD(header, field) \
|
|
|
|
.struct_offset_bytes = offsetof(struct ib_unpacked_ ## header, field), \
|
|
|
|
.struct_size_bytes = sizeof((struct ib_unpacked_ ## header *)0)->field
|
|
|
|
|
|
|
|
extern struct dentry *mlx5_debugfs_root;
|
|
|
|
|
|
|
|
static inline u16 fw_rev_maj(struct mlx5_core_dev *dev)
|
|
|
|
{
|
|
|
|
return ioread32be(&dev->iseg->fw_rev) & 0xffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u16 fw_rev_min(struct mlx5_core_dev *dev)
|
|
|
|
{
|
|
|
|
return ioread32be(&dev->iseg->fw_rev) >> 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u16 fw_rev_sub(struct mlx5_core_dev *dev)
|
|
|
|
{
|
|
|
|
return ioread32be(&dev->iseg->cmdif_rev_fw_sub) & 0xffff;
|
|
|
|
}
|
|
|
|
|
2014-02-23 12:19:10 +00:00
|
|
|
static inline u32 mlx5_base_mkey(const u32 key)
|
|
|
|
{
|
|
|
|
return key & 0xffffff00u;
|
|
|
|
}
|
|
|
|
|
2021-03-11 07:09:15 +00:00
|
|
|
static inline u32 wq_get_byte_sz(u8 log_sz, u8 log_stride)
|
|
|
|
{
|
|
|
|
return ((u32)1 << log_sz) << log_stride;
|
|
|
|
}
|
|
|
|
|
2018-09-12 12:36:41 +00:00
|
|
|
static inline void mlx5_init_fbc_offset(struct mlx5_buf_list *frags,
|
|
|
|
u8 log_stride, u8 log_sz,
|
2018-08-21 13:07:58 +00:00
|
|
|
u16 strides_offset,
|
2018-07-08 09:14:59 +00:00
|
|
|
struct mlx5_frag_buf_ctrl *fbc)
|
2018-01-02 14:08:06 +00:00
|
|
|
{
|
2018-09-12 12:36:41 +00:00
|
|
|
fbc->frags = frags;
|
2018-04-04 09:54:23 +00:00
|
|
|
fbc->log_stride = log_stride;
|
|
|
|
fbc->log_sz = log_sz;
|
2018-01-02 14:08:06 +00:00
|
|
|
fbc->sz_m1 = (1 << fbc->log_sz) - 1;
|
|
|
|
fbc->log_frag_strides = PAGE_SHIFT - fbc->log_stride;
|
|
|
|
fbc->frag_sz_m1 = (1 << fbc->log_frag_strides) - 1;
|
2018-07-08 09:14:59 +00:00
|
|
|
fbc->strides_offset = strides_offset;
|
|
|
|
}
|
|
|
|
|
2018-09-12 12:36:41 +00:00
|
|
|
static inline void mlx5_init_fbc(struct mlx5_buf_list *frags,
|
|
|
|
u8 log_stride, u8 log_sz,
|
2018-07-08 09:14:59 +00:00
|
|
|
struct mlx5_frag_buf_ctrl *fbc)
|
|
|
|
{
|
2018-09-12 12:36:41 +00:00
|
|
|
mlx5_init_fbc_offset(frags, log_stride, log_sz, 0, fbc);
|
2018-04-04 09:54:23 +00:00
|
|
|
}
|
|
|
|
|
2018-01-02 14:08:06 +00:00
|
|
|
static inline void *mlx5_frag_buf_get_wqe(struct mlx5_frag_buf_ctrl *fbc,
|
|
|
|
u32 ix)
|
|
|
|
{
|
2018-07-08 09:14:59 +00:00
|
|
|
unsigned int frag;
|
|
|
|
|
|
|
|
ix += fbc->strides_offset;
|
|
|
|
frag = ix >> fbc->log_frag_strides;
|
2018-01-02 14:08:06 +00:00
|
|
|
|
2018-09-12 12:36:41 +00:00
|
|
|
return fbc->frags[frag].buf + ((fbc->frag_sz_m1 & ix) << fbc->log_stride);
|
2018-01-02 14:08:06 +00:00
|
|
|
}
|
|
|
|
|
net/mlx5: WQ, fixes for fragmented WQ buffers API
mlx5e netdevice used to calculate fragment edges by a call to
mlx5_wq_cyc_get_frag_size(). This calculation did not give the correct
indication for queues smaller than a PAGE_SIZE, (broken by default on
PowerPC, where PAGE_SIZE == 64KB). Here it is replaced by the correct new
calls/API.
Since (TX/RX) Work Queues buffers are fragmented, here we introduce
changes to the API in core driver, so that it gets a stride index and
returns the index of last stride on same fragment, and an additional
wrapping function that returns the number of physically contiguous
strides that can be written contiguously to the work queue.
This obsoletes the following API functions, and their buggy
usage in EN driver:
* mlx5_wq_cyc_get_frag_size()
* mlx5_wq_cyc_ctr2fragix()
The new API improves modularity and hides the details of such
calculation for mlx5e netdevice and mlx5_ib rdma drivers.
New calculation is also more efficient, and improves performance
as follows:
Packet rate test: pktgen, UDP / IPv4, 64byte, single ring, 8K ring size.
Before: 16,477,619 pps
After: 17,085,793 pps
3.7% improvement
Fixes: 3a2f70331226 ("net/mlx5: Use order-0 allocations for all WQ types")
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Reviewed-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-08-21 11:41:41 +00:00
|
|
|
static inline u32
|
|
|
|
mlx5_frag_buf_get_idx_last_contig_stride(struct mlx5_frag_buf_ctrl *fbc, u32 ix)
|
|
|
|
{
|
|
|
|
u32 last_frag_stride_idx = (ix + fbc->strides_offset) | fbc->frag_sz_m1;
|
|
|
|
|
|
|
|
return min_t(u32, last_frag_stride_idx - fbc->strides_offset, fbc->sz_m1);
|
|
|
|
}
|
|
|
|
|
2020-03-18 19:44:32 +00:00
|
|
|
enum {
|
|
|
|
CMD_ALLOWED_OPCODE_ALL,
|
|
|
|
};
|
|
|
|
|
2013-07-07 14:25:49 +00:00
|
|
|
void mlx5_cmd_use_events(struct mlx5_core_dev *dev);
|
|
|
|
void mlx5_cmd_use_polling(struct mlx5_core_dev *dev);
|
2020-03-18 19:44:32 +00:00
|
|
|
void mlx5_cmd_allowed_opcode(struct mlx5_core_dev *dev, u16 opcode);
|
2016-07-19 17:17:12 +00:00
|
|
|
|
2019-01-19 00:33:10 +00:00
|
|
|
struct mlx5_async_ctx {
|
|
|
|
struct mlx5_core_dev *dev;
|
|
|
|
atomic_t num_inflight;
|
2022-10-26 13:51:45 +00:00
|
|
|
struct completion inflight_done;
|
2019-01-19 00:33:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_async_work;
|
|
|
|
|
|
|
|
typedef void (*mlx5_async_cbk_t)(int status, struct mlx5_async_work *context);
|
|
|
|
|
|
|
|
struct mlx5_async_work {
|
|
|
|
struct mlx5_async_ctx *ctx;
|
|
|
|
mlx5_async_cbk_t user_callback;
|
2022-01-27 13:22:21 +00:00
|
|
|
u16 opcode; /* cmd opcode */
|
2022-05-31 06:14:03 +00:00
|
|
|
u16 op_mod; /* cmd op_mod */
|
2025-02-26 13:01:06 +00:00
|
|
|
u8 throttle_locked:1;
|
2025-02-26 13:01:07 +00:00
|
|
|
u8 unpriv_locked:1;
|
2020-04-01 05:03:00 +00:00
|
|
|
void *out; /* pointer to the cmd output buffer */
|
2019-01-19 00:33:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void mlx5_cmd_init_async_ctx(struct mlx5_core_dev *dev,
|
|
|
|
struct mlx5_async_ctx *ctx);
|
|
|
|
void mlx5_cmd_cleanup_async_ctx(struct mlx5_async_ctx *ctx);
|
|
|
|
int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size,
|
|
|
|
void *out, int out_size, mlx5_async_cbk_t callback,
|
|
|
|
struct mlx5_async_work *work);
|
2020-04-01 05:03:00 +00:00
|
|
|
void mlx5_cmd_out_err(struct mlx5_core_dev *dev, u16 opcode, u16 op_mod, void *out);
|
2019-08-17 10:05:10 +00:00
|
|
|
int mlx5_cmd_do(struct mlx5_core_dev *dev, void *in, int in_size, void *out, int out_size);
|
|
|
|
int mlx5_cmd_check(struct mlx5_core_dev *dev, int err, void *in, void *out);
|
2013-07-07 14:25:49 +00:00
|
|
|
int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
|
|
|
|
int out_size);
|
2020-04-05 17:57:00 +00:00
|
|
|
|
|
|
|
#define mlx5_cmd_exec_inout(dev, ifc_cmd, in, out) \
|
|
|
|
({ \
|
|
|
|
mlx5_cmd_exec(dev, in, MLX5_ST_SZ_BYTES(ifc_cmd##_in), out, \
|
|
|
|
MLX5_ST_SZ_BYTES(ifc_cmd##_out)); \
|
|
|
|
})
|
|
|
|
|
|
|
|
#define mlx5_cmd_exec_in(dev, ifc_cmd, in) \
|
|
|
|
({ \
|
|
|
|
u32 _out[MLX5_ST_SZ_DW(ifc_cmd##_out)] = {}; \
|
|
|
|
mlx5_cmd_exec_inout(dev, ifc_cmd, in, _out); \
|
|
|
|
})
|
|
|
|
|
2017-02-09 11:20:46 +00:00
|
|
|
int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size,
|
|
|
|
void *out, int out_size);
|
2020-09-11 18:48:55 +00:00
|
|
|
bool mlx5_cmd_is_down(struct mlx5_core_dev *dev);
|
2025-02-26 13:01:07 +00:00
|
|
|
int mlx5_cmd_add_privileged_uid(struct mlx5_core_dev *dev, u16 uid);
|
|
|
|
void mlx5_cmd_remove_privileged_uid(struct mlx5_core_dev *dev, u16 uid);
|
2016-07-19 17:17:12 +00:00
|
|
|
|
2022-11-01 14:27:43 +00:00
|
|
|
void mlx5_core_uplink_netdev_set(struct mlx5_core_dev *mdev, struct net_device *netdev);
|
|
|
|
void mlx5_core_uplink_netdev_event_replay(struct mlx5_core_dev *mdev);
|
|
|
|
|
2023-09-21 12:10:27 +00:00
|
|
|
void mlx5_core_mp_event_replay(struct mlx5_core_dev *dev, u32 event, void *data);
|
|
|
|
|
2015-10-08 14:14:00 +00:00
|
|
|
void mlx5_health_cleanup(struct mlx5_core_dev *dev);
|
|
|
|
int mlx5_health_init(struct mlx5_core_dev *dev);
|
2013-07-07 14:25:49 +00:00
|
|
|
void mlx5_start_health_poll(struct mlx5_core_dev *dev);
|
2018-08-05 06:19:33 +00:00
|
|
|
void mlx5_stop_health_poll(struct mlx5_core_dev *dev, bool disable_health);
|
2022-10-02 04:56:28 +00:00
|
|
|
void mlx5_start_health_fw_log_up(struct mlx5_core_dev *dev);
|
2016-10-25 15:36:33 +00:00
|
|
|
void mlx5_drain_health_wq(struct mlx5_core_dev *dev);
|
2017-05-07 10:48:31 +00:00
|
|
|
void mlx5_trigger_health_work(struct mlx5_core_dev *dev);
|
2016-11-30 15:59:37 +00:00
|
|
|
int mlx5_frag_buf_alloc_node(struct mlx5_core_dev *dev, int size,
|
|
|
|
struct mlx5_frag_buf *buf, int node);
|
|
|
|
void mlx5_frag_buf_free(struct mlx5_core_dev *dev, struct mlx5_frag_buf *buf);
|
2021-10-12 10:26:33 +00:00
|
|
|
int mlx5_core_create_mkey(struct mlx5_core_dev *dev, u32 *mkey, u32 *in,
|
|
|
|
int inlen);
|
|
|
|
int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, u32 mkey);
|
|
|
|
int mlx5_core_query_mkey(struct mlx5_core_dev *dev, u32 mkey, u32 *out,
|
|
|
|
int outlen);
|
2013-07-07 14:25:49 +00:00
|
|
|
int mlx5_core_alloc_pd(struct mlx5_core_dev *dev, u32 *pdn);
|
|
|
|
int mlx5_core_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn);
|
2018-11-20 22:12:23 +00:00
|
|
|
int mlx5_pagealloc_init(struct mlx5_core_dev *dev);
|
2013-07-07 14:25:49 +00:00
|
|
|
void mlx5_pagealloc_cleanup(struct mlx5_core_dev *dev);
|
2018-11-20 22:12:23 +00:00
|
|
|
void mlx5_pagealloc_start(struct mlx5_core_dev *dev);
|
2013-07-07 14:25:49 +00:00
|
|
|
void mlx5_pagealloc_stop(struct mlx5_core_dev *dev);
|
2022-01-27 05:03:33 +00:00
|
|
|
void mlx5_pages_debugfs_init(struct mlx5_core_dev *dev);
|
|
|
|
void mlx5_pages_debugfs_cleanup(struct mlx5_core_dev *dev);
|
2013-07-18 12:31:08 +00:00
|
|
|
int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot);
|
2013-07-07 14:25:49 +00:00
|
|
|
int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev);
|
|
|
|
void mlx5_register_debugfs(void);
|
|
|
|
void mlx5_unregister_debugfs(void);
|
2018-01-02 14:08:06 +00:00
|
|
|
|
2020-07-15 04:28:32 +00:00
|
|
|
void mlx5_fill_page_frag_array_perm(struct mlx5_frag_buf *buf, __be64 *pas, u8 perm);
|
2016-11-30 15:59:37 +00:00
|
|
|
void mlx5_fill_page_frag_array(struct mlx5_frag_buf *frag_buf, __be64 *pas);
|
2023-06-12 07:13:50 +00:00
|
|
|
int mlx5_comp_eqn_get(struct mlx5_core_dev *dev, u16 vecidx, int *eqn);
|
2013-07-07 14:25:49 +00:00
|
|
|
int mlx5_core_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
|
|
|
|
int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
|
|
|
|
|
2022-02-18 07:36:20 +00:00
|
|
|
struct dentry *mlx5_debugfs_get_dev_root(struct mlx5_core_dev *dev);
|
2019-08-10 10:17:18 +00:00
|
|
|
void mlx5_qp_debugfs_init(struct mlx5_core_dev *dev);
|
2013-07-07 14:25:49 +00:00
|
|
|
void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev);
|
2021-09-06 08:02:44 +00:00
|
|
|
int mlx5_access_reg(struct mlx5_core_dev *dev, void *data_in, int size_in,
|
|
|
|
void *data_out, int size_out, u16 reg_id, int arg,
|
|
|
|
int write, bool verbose);
|
2013-07-07 14:25:49 +00:00
|
|
|
int mlx5_core_access_reg(struct mlx5_core_dev *dev, void *data_in,
|
|
|
|
int size_in, void *data_out, int size_out,
|
|
|
|
u16 reg_num, int arg, int write);
|
2015-05-28 19:28:42 +00:00
|
|
|
|
2015-07-23 20:35:57 +00:00
|
|
|
int mlx5_db_alloc_node(struct mlx5_core_dev *dev, struct mlx5_db *db,
|
|
|
|
int node);
|
2022-01-25 12:47:36 +00:00
|
|
|
|
|
|
|
static inline int mlx5_db_alloc(struct mlx5_core_dev *dev, struct mlx5_db *db)
|
|
|
|
{
|
|
|
|
return mlx5_db_alloc_node(dev, db, dev->priv.numa_node);
|
|
|
|
}
|
|
|
|
|
2013-07-07 14:25:49 +00:00
|
|
|
void mlx5_db_free(struct mlx5_core_dev *dev, struct mlx5_db *db);
|
|
|
|
|
|
|
|
const char *mlx5_command_str(int command);
|
2019-08-10 10:17:18 +00:00
|
|
|
void mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev);
|
2013-07-07 14:25:49 +00:00
|
|
|
void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev);
|
2014-02-23 12:19:06 +00:00
|
|
|
int mlx5_core_create_psv(struct mlx5_core_dev *dev, u32 pdn,
|
|
|
|
int npsvs, u32 *sig_index);
|
|
|
|
int mlx5_core_destroy_psv(struct mlx5_core_dev *dev, int psv_num);
|
2023-04-13 12:48:30 +00:00
|
|
|
__be32 mlx5_core_get_terminate_scatter_list_mkey(struct mlx5_core_dev *dev);
|
2014-10-02 09:19:45 +00:00
|
|
|
void mlx5_core_put_rsc(struct mlx5_core_rsc_common *common);
|
2013-07-07 14:25:49 +00:00
|
|
|
|
2016-06-23 14:02:37 +00:00
|
|
|
int mlx5_init_rl_table(struct mlx5_core_dev *dev);
|
|
|
|
void mlx5_cleanup_rl_table(struct mlx5_core_dev *dev);
|
2018-03-19 13:10:29 +00:00
|
|
|
int mlx5_rl_add_rate(struct mlx5_core_dev *dev, u16 *index,
|
|
|
|
struct mlx5_rate_limit *rl);
|
|
|
|
void mlx5_rl_remove_rate(struct mlx5_core_dev *dev, struct mlx5_rate_limit *rl);
|
2016-06-23 14:02:37 +00:00
|
|
|
bool mlx5_rl_is_in_range(struct mlx5_core_dev *dev, u32 rate);
|
2020-02-19 19:05:17 +00:00
|
|
|
int mlx5_rl_add_rate_raw(struct mlx5_core_dev *dev, void *rl_in, u16 uid,
|
|
|
|
bool dedicated_entry, u16 *index);
|
|
|
|
void mlx5_rl_remove_rate_raw(struct mlx5_core_dev *dev, u16 index);
|
2018-03-19 13:10:29 +00:00
|
|
|
bool mlx5_rl_are_equal(struct mlx5_rate_limit *rl_0,
|
|
|
|
struct mlx5_rate_limit *rl_1);
|
2017-01-03 21:55:23 +00:00
|
|
|
int mlx5_alloc_bfreg(struct mlx5_core_dev *mdev, struct mlx5_sq_bfreg *bfreg,
|
|
|
|
bool map_wc, bool fast_path);
|
|
|
|
void mlx5_free_bfreg(struct mlx5_core_dev *mdev, struct mlx5_sq_bfreg *bfreg);
|
2016-06-23 14:02:37 +00:00
|
|
|
|
2023-06-22 15:52:44 +00:00
|
|
|
unsigned int mlx5_comp_vectors_max(struct mlx5_core_dev *dev);
|
2023-06-12 08:58:14 +00:00
|
|
|
int mlx5_comp_vector_get_cpu(struct mlx5_core_dev *dev, int vector);
|
2017-03-26 14:01:57 +00:00
|
|
|
unsigned int mlx5_core_reserved_gids_count(struct mlx5_core_dev *dev);
|
|
|
|
int mlx5_core_roce_gid_set(struct mlx5_core_dev *dev, unsigned int index,
|
|
|
|
u8 roce_version, u8 roce_l3_type, const u8 *gid,
|
2018-01-04 15:25:41 +00:00
|
|
|
const u8 *mac, bool vlan, u16 vlan_id, u8 port_num);
|
2017-03-26 14:01:57 +00:00
|
|
|
|
2013-07-07 14:25:49 +00:00
|
|
|
static inline u32 mlx5_mkey_to_idx(u32 mkey)
|
|
|
|
{
|
|
|
|
return mkey >> 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u32 mlx5_idx_to_mkey(u32 mkey_idx)
|
|
|
|
{
|
|
|
|
return mkey_idx << 8;
|
|
|
|
}
|
|
|
|
|
2013-10-23 06:53:14 +00:00
|
|
|
static inline u8 mlx5_mkey_variant(u32 mkey)
|
|
|
|
{
|
|
|
|
return mkey & 0xff;
|
|
|
|
}
|
|
|
|
|
2021-01-26 23:24:11 +00:00
|
|
|
/* Async-atomic event notifier used by mlx5 core to forward FW
|
2021-07-30 03:03:00 +00:00
|
|
|
* evetns received from event queue to mlx5 consumers.
|
2021-01-26 23:24:11 +00:00
|
|
|
* Optimise event queue dipatching.
|
|
|
|
*/
|
2018-11-26 22:38:56 +00:00
|
|
|
int mlx5_notifier_register(struct mlx5_core_dev *dev, struct notifier_block *nb);
|
|
|
|
int mlx5_notifier_unregister(struct mlx5_core_dev *dev, struct notifier_block *nb);
|
2021-01-26 23:24:11 +00:00
|
|
|
|
|
|
|
/* Async-atomic event notifier used for forwarding
|
|
|
|
* evetns from the event queue into the to mlx5 events dispatcher,
|
|
|
|
* eswitch, clock and others.
|
|
|
|
*/
|
2019-06-30 16:23:24 +00:00
|
|
|
int mlx5_eq_notifier_register(struct mlx5_core_dev *dev, struct mlx5_nb *nb);
|
|
|
|
int mlx5_eq_notifier_unregister(struct mlx5_core_dev *dev, struct mlx5_nb *nb);
|
2018-11-26 22:38:56 +00:00
|
|
|
|
2021-01-26 23:24:11 +00:00
|
|
|
/* Blocking event notifier used to forward SW events, used for slow path */
|
|
|
|
int mlx5_blocking_notifier_register(struct mlx5_core_dev *dev, struct notifier_block *nb);
|
|
|
|
int mlx5_blocking_notifier_unregister(struct mlx5_core_dev *dev, struct notifier_block *nb);
|
|
|
|
int mlx5_blocking_notifier_call_chain(struct mlx5_core_dev *dev, unsigned int event,
|
|
|
|
void *data);
|
|
|
|
|
2015-06-04 16:30:42 +00:00
|
|
|
int mlx5_core_query_vendor_id(struct mlx5_core_dev *mdev, u32 *vendor_id);
|
2014-07-28 20:30:22 +00:00
|
|
|
|
2016-05-09 10:38:42 +00:00
|
|
|
int mlx5_cmd_create_vport_lag(struct mlx5_core_dev *dev);
|
|
|
|
int mlx5_cmd_destroy_vport_lag(struct mlx5_core_dev *dev);
|
2018-08-23 10:47:53 +00:00
|
|
|
bool mlx5_lag_is_roce(struct mlx5_core_dev *dev);
|
|
|
|
bool mlx5_lag_is_sriov(struct mlx5_core_dev *dev);
|
net/mlx5: Implement RoCE LAG feature
Available on dual port cards only, this feature keeps
track, using netdev LAG events, of the bonding
and link status of each port's PF netdev.
When both of the card's PF netdevs are enslaved to the
same bond/team master, and only them, LAG state
is active.
During LAG, only one IB device is present for both ports.
In addition to the above, this commit includes FW commands
used for managing the LAG, new facilities for adding and removing
a single device by interface, and port remap functionality according to
bond events.
Please note that this feature is currently used only for mimicking
Ethernet bonding for RoCE - netdevs functionality is not altered,
and their bonding continues to be managed solely by bond/team driver.
Signed-off-by: Aviv Heller <avivh@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2016-04-17 13:57:32 +00:00
|
|
|
bool mlx5_lag_is_active(struct mlx5_core_dev *dev);
|
2022-09-07 23:36:26 +00:00
|
|
|
bool mlx5_lag_mode_is_hash(struct mlx5_core_dev *dev);
|
2021-08-03 23:19:47 +00:00
|
|
|
bool mlx5_lag_is_master(struct mlx5_core_dev *dev);
|
|
|
|
bool mlx5_lag_is_shared_fdb(struct mlx5_core_dev *dev);
|
2022-12-05 13:32:52 +00:00
|
|
|
bool mlx5_lag_is_mpesw(struct mlx5_core_dev *dev);
|
2020-04-30 19:21:41 +00:00
|
|
|
u8 mlx5_lag_get_slave_port(struct mlx5_core_dev *dev,
|
|
|
|
struct net_device *slave);
|
2017-12-21 15:38:26 +00:00
|
|
|
int mlx5_lag_query_cong_counters(struct mlx5_core_dev *dev,
|
|
|
|
u64 *values,
|
|
|
|
int num_counters,
|
|
|
|
size_t *offsets);
|
2023-06-06 07:12:06 +00:00
|
|
|
struct mlx5_core_dev *mlx5_lag_get_next_peer_mdev(struct mlx5_core_dev *dev, int *i);
|
|
|
|
|
|
|
|
#define mlx5_lag_for_each_peer_mdev(dev, peer, i) \
|
|
|
|
for (i = 0, peer = mlx5_lag_get_next_peer_mdev(dev, &i); \
|
|
|
|
peer; \
|
|
|
|
peer = mlx5_lag_get_next_peer_mdev(dev, &i))
|
|
|
|
|
2022-03-01 15:42:01 +00:00
|
|
|
u8 mlx5_lag_get_num_ports(struct mlx5_core_dev *dev);
|
2017-01-03 21:55:24 +00:00
|
|
|
struct mlx5_uars_page *mlx5_get_uars_page(struct mlx5_core_dev *mdev);
|
|
|
|
void mlx5_put_uars_page(struct mlx5_core_dev *mdev, struct mlx5_uars_page *up);
|
2019-08-29 23:42:30 +00:00
|
|
|
int mlx5_dm_sw_icm_alloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type,
|
2020-04-24 19:45:04 +00:00
|
|
|
u64 length, u32 log_alignment, u16 uid,
|
|
|
|
phys_addr_t *addr, u32 *obj_id);
|
2019-08-29 23:42:30 +00:00
|
|
|
int mlx5_dm_sw_icm_dealloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type,
|
|
|
|
u64 length, u16 uid, phys_addr_t addr, u32 obj_id);
|
net/mlx5: Implement RoCE LAG feature
Available on dual port cards only, this feature keeps
track, using netdev LAG events, of the bonding
and link status of each port's PF netdev.
When both of the card's PF netdevs are enslaved to the
same bond/team master, and only them, LAG state
is active.
During LAG, only one IB device is present for both ports.
In addition to the above, this commit includes FW commands
used for managing the LAG, new facilities for adding and removing
a single device by interface, and port remap functionality according to
bond events.
Please note that this feature is currently used only for mimicking
Ethernet bonding for RoCE - netdevs functionality is not altered,
and their bonding continues to be managed solely by bond/team driver.
Signed-off-by: Aviv Heller <avivh@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2016-04-17 13:57:32 +00:00
|
|
|
|
2022-02-24 14:20:14 +00:00
|
|
|
struct mlx5_core_dev *mlx5_vf_get_core_dev(struct pci_dev *pdev);
|
|
|
|
void mlx5_vf_put_core_dev(struct mlx5_core_dev *mdev);
|
|
|
|
|
2022-05-10 09:02:03 +00:00
|
|
|
int mlx5_sriov_blocking_notifier_register(struct mlx5_core_dev *mdev,
|
|
|
|
int vf_id,
|
|
|
|
struct notifier_block *nb);
|
|
|
|
void mlx5_sriov_blocking_notifier_unregister(struct mlx5_core_dev *mdev,
|
|
|
|
int vf_id,
|
|
|
|
struct notifier_block *nb);
|
2018-08-14 11:08:51 +00:00
|
|
|
int mlx5_rdma_rn_get_params(struct mlx5_core_dev *mdev,
|
|
|
|
struct ib_device *device,
|
|
|
|
struct rdma_netdev_alloc_params *params);
|
2013-07-07 14:25:49 +00:00
|
|
|
|
2015-12-01 16:03:09 +00:00
|
|
|
enum {
|
|
|
|
MLX5_PCI_DEV_IS_VF = 1 << 0,
|
|
|
|
};
|
|
|
|
|
2019-05-15 05:04:27 +00:00
|
|
|
static inline bool mlx5_core_is_pf(const struct mlx5_core_dev *dev)
|
2015-12-01 16:03:09 +00:00
|
|
|
{
|
2019-06-28 22:35:58 +00:00
|
|
|
return dev->coredev_type == MLX5_COREDEV_PF;
|
2015-12-01 16:03:09 +00:00
|
|
|
}
|
|
|
|
|
2019-10-28 23:35:30 +00:00
|
|
|
static inline bool mlx5_core_is_vf(const struct mlx5_core_dev *dev)
|
|
|
|
{
|
|
|
|
return dev->coredev_type == MLX5_COREDEV_VF;
|
|
|
|
}
|
|
|
|
|
2024-12-03 13:45:37 +00:00
|
|
|
static inline bool mlx5_core_same_coredev_type(const struct mlx5_core_dev *dev1,
|
|
|
|
const struct mlx5_core_dev *dev2)
|
|
|
|
{
|
|
|
|
return dev1->coredev_type == dev2->coredev_type;
|
|
|
|
}
|
|
|
|
|
2020-11-20 23:03:36 +00:00
|
|
|
static inline bool mlx5_core_is_ecpf(const struct mlx5_core_dev *dev)
|
2019-02-13 06:55:35 +00:00
|
|
|
{
|
|
|
|
return dev->caps.embedded_cpu;
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:04:27 +00:00
|
|
|
static inline bool
|
|
|
|
mlx5_core_is_ecpf_esw_manager(const struct mlx5_core_dev *dev)
|
2019-02-13 06:55:38 +00:00
|
|
|
{
|
|
|
|
return dev->caps.embedded_cpu && MLX5_CAP_GEN(dev, eswitch_manager);
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:04:27 +00:00
|
|
|
static inline bool mlx5_ecpf_vport_exists(const struct mlx5_core_dev *dev)
|
2018-12-10 17:59:33 +00:00
|
|
|
{
|
|
|
|
return mlx5_core_is_pf(dev) && MLX5_CAP_ESW(dev, ecpf_vport_exists);
|
|
|
|
}
|
|
|
|
|
2019-05-15 05:04:27 +00:00
|
|
|
static inline u16 mlx5_core_max_vfs(const struct mlx5_core_dev *dev)
|
2019-02-13 06:55:39 +00:00
|
|
|
{
|
2019-06-10 23:38:19 +00:00
|
|
|
return dev->priv.sriov.max_vfs;
|
2019-02-13 06:55:39 +00:00
|
|
|
}
|
|
|
|
|
RDMA/mlx5: Fix affinity assignment
The cited commit aimed to ensure that Virtual Functions (VFs) assign a
queue affinity to a Queue Pair (QP) to distribute traffic when
the LAG master creates a hardware LAG. If the affinity was set while
the hardware was not in LAG, the firmware would ignore the affinity value.
However, this commit unintentionally assigned an affinity to QPs on the LAG
master's VPORT even if the RDMA device was not marked as LAG-enabled.
In most cases, this was not an issue because when the hardware entered
hardware LAG configuration, the RDMA device of the LAG master would be
destroyed and a new one would be created, marked as LAG-enabled.
The problem arises when a user configures Equal-Cost Multipath (ECMP).
In ECMP mode, traffic can be directed to different physical ports based on
the queue affinity, which is intended for use by VPORTS other than the
E-Switch manager. ECMP mode is supported only if both E-Switch managers are
in switchdev mode and the appropriate route is configured via IP. In this
configuration, the RDMA device is not destroyed, and we retain the RDMA
device that is not marked as LAG-enabled.
To ensure correct behavior, Send Queues (SQs) opened by the E-Switch
manager through verbs should be assigned strict affinity. This means they
will only be able to communicate through the native physical port
associated with the E-Switch manager. This will prevent the firmware from
assigning affinity and will not allow the SQs to be remapped in case of
failover.
Fixes: 802dcc7fc5ec ("RDMA/mlx5: Support TX port affinity for VF drivers in LAG mode")
Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Link: https://lore.kernel.org/r/425b05f4da840bc684b0f7e8ebf61aeb5cef09b0.1685960567.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2023-06-05 10:33:26 +00:00
|
|
|
static inline int mlx5_lag_is_lacp_owner(struct mlx5_core_dev *dev)
|
|
|
|
{
|
|
|
|
/* LACP owner conditions:
|
|
|
|
* 1) Function is physical.
|
|
|
|
* 2) LAG is supported by FW.
|
|
|
|
* 3) LAG is managed by driver (currently the only option).
|
|
|
|
*/
|
|
|
|
return MLX5_CAP_GEN(dev, vport_group_manager) &&
|
|
|
|
(MLX5_CAP_GEN(dev, num_lag_ports) > 1) &&
|
|
|
|
MLX5_CAP_GEN(dev, lag_master);
|
|
|
|
}
|
|
|
|
|
2023-03-07 17:36:14 +00:00
|
|
|
static inline u16 mlx5_core_max_ec_vfs(const struct mlx5_core_dev *dev)
|
|
|
|
{
|
|
|
|
return dev->priv.sriov.max_ec_vfs;
|
|
|
|
}
|
|
|
|
|
2015-06-04 16:30:41 +00:00
|
|
|
static inline int mlx5_get_gid_table_len(u16 param)
|
|
|
|
{
|
|
|
|
if (param > 4) {
|
|
|
|
pr_warn("gid table length is zero\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 8 * (1 << param);
|
|
|
|
}
|
|
|
|
|
2016-06-23 14:02:37 +00:00
|
|
|
static inline bool mlx5_rl_is_supported(struct mlx5_core_dev *dev)
|
|
|
|
{
|
|
|
|
return !!(dev->priv.rl_table.max_size);
|
|
|
|
}
|
|
|
|
|
{net, IB}/mlx5: Manage port association for multiport RoCE
When mlx5_ib_add is called determine if the mlx5 core device being
added is capable of dual port RoCE operation. If it is, determine
whether it is a master device or a slave device using the
num_vhca_ports and affiliate_nic_vport_criteria capabilities.
If the device is a slave, attempt to find a master device to affiliate it
with. Devices that can be affiliated will share a system image guid. If
none are found place it on a list of unaffiliated ports. If a master is
found bind the port to it by configuring the port affiliation in the NIC
vport context.
Similarly when mlx5_ib_remove is called determine the port type. If it's
a slave port, unaffiliate it from the master device, otherwise just
remove it from the unaffiliated port list.
The IB device is registered as a multiport device, even if a 2nd port is
not available for affiliation. When the 2nd port is affiliated later the
GID cache must be refreshed in order to get the default GIDs for the 2nd
port in the cache. Export roce_rescan_device to provide a mechanism to
refresh the cache after a new port is bound.
In a multiport configuration all IB object (QP, MR, PD, etc) related
commands should flow through the master mlx5_core_dev, other commands
must be sent to the slave port mlx5_core_mdev, an interface is provide
to get the correct mdev for non IB object commands.
Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
2018-01-04 15:25:36 +00:00
|
|
|
static inline int mlx5_core_is_mp_slave(struct mlx5_core_dev *dev)
|
|
|
|
{
|
|
|
|
return MLX5_CAP_GEN(dev, affiliate_nic_vport_criteria) &&
|
|
|
|
MLX5_CAP_GEN(dev, num_vhca_ports) <= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int mlx5_core_is_mp_master(struct mlx5_core_dev *dev)
|
|
|
|
{
|
|
|
|
return MLX5_CAP_GEN(dev, num_vhca_ports) > 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int mlx5_core_mp_enabled(struct mlx5_core_dev *dev)
|
|
|
|
{
|
|
|
|
return mlx5_core_is_mp_slave(dev) ||
|
|
|
|
mlx5_core_is_mp_master(dev);
|
|
|
|
}
|
|
|
|
|
2018-01-04 15:25:35 +00:00
|
|
|
static inline int mlx5_core_native_port_num(struct mlx5_core_dev *dev)
|
|
|
|
{
|
{net, IB}/mlx5: Manage port association for multiport RoCE
When mlx5_ib_add is called determine if the mlx5 core device being
added is capable of dual port RoCE operation. If it is, determine
whether it is a master device or a slave device using the
num_vhca_ports and affiliate_nic_vport_criteria capabilities.
If the device is a slave, attempt to find a master device to affiliate it
with. Devices that can be affiliated will share a system image guid. If
none are found place it on a list of unaffiliated ports. If a master is
found bind the port to it by configuring the port affiliation in the NIC
vport context.
Similarly when mlx5_ib_remove is called determine the port type. If it's
a slave port, unaffiliate it from the master device, otherwise just
remove it from the unaffiliated port list.
The IB device is registered as a multiport device, even if a 2nd port is
not available for affiliation. When the 2nd port is affiliated later the
GID cache must be refreshed in order to get the default GIDs for the 2nd
port in the cache. Export roce_rescan_device to provide a mechanism to
refresh the cache after a new port is bound.
In a multiport configuration all IB object (QP, MR, PD, etc) related
commands should flow through the master mlx5_core_dev, other commands
must be sent to the slave port mlx5_core_mdev, an interface is provide
to get the correct mdev for non IB object commands.
Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
2018-01-04 15:25:36 +00:00
|
|
|
if (!mlx5_core_mp_enabled(dev))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return MLX5_CAP_GEN(dev, native_port_num);
|
2018-01-04 15:25:35 +00:00
|
|
|
}
|
|
|
|
|
2021-09-16 07:46:17 +00:00
|
|
|
static inline int mlx5_get_dev_index(struct mlx5_core_dev *dev)
|
|
|
|
{
|
2021-10-12 07:40:52 +00:00
|
|
|
int idx = MLX5_CAP_GEN(dev, native_port_num);
|
|
|
|
|
|
|
|
if (idx >= 1 && idx <= MLX5_MAX_PORTS)
|
|
|
|
return idx - 1;
|
|
|
|
else
|
|
|
|
return PCI_FUNC(dev->pdev->devfn);
|
2021-09-16 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
2015-10-08 14:13:58 +00:00
|
|
|
enum {
|
|
|
|
MLX5_TRIGGERED_CMD_COMP = (u64)1 << 32,
|
|
|
|
};
|
|
|
|
|
2022-08-29 09:02:27 +00:00
|
|
|
bool mlx5_is_roce_on(struct mlx5_core_dev *dev);
|
|
|
|
|
|
|
|
static inline bool mlx5_get_roce_state(struct mlx5_core_dev *dev)
|
2019-11-08 23:45:24 +00:00
|
|
|
{
|
2022-08-29 09:02:27 +00:00
|
|
|
if (MLX5_CAP_GEN(dev, roce_rw_supported))
|
|
|
|
return MLX5_CAP_GEN(dev, roce);
|
|
|
|
|
|
|
|
/* If RoCE cap is read-only in FW, get RoCE state from devlink
|
|
|
|
* in order to support RoCE enable/disable feature
|
|
|
|
*/
|
|
|
|
return mlx5_is_roce_on(dev);
|
2019-11-08 23:45:24 +00:00
|
|
|
}
|
|
|
|
|
2023-04-13 09:04:59 +00:00
|
|
|
#ifdef CONFIG_MLX5_MACSEC
|
2022-05-03 05:37:48 +00:00
|
|
|
static inline bool mlx5e_is_macsec_device(const struct mlx5_core_dev *mdev)
|
|
|
|
{
|
|
|
|
if (!(MLX5_CAP_GEN_64(mdev, general_obj_types) &
|
|
|
|
MLX5_GENERAL_OBJ_TYPES_CAP_MACSEC_OFFLOAD))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!MLX5_CAP_GEN(mdev, log_max_dek))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!MLX5_CAP_MACSEC(mdev, log_max_macsec_offload))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!MLX5_CAP_FLOWTABLE_NIC_RX(mdev, macsec_decrypt) ||
|
|
|
|
!MLX5_CAP_FLOWTABLE_NIC_RX(mdev, reformat_remove_macsec))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!MLX5_CAP_FLOWTABLE_NIC_TX(mdev, macsec_encrypt) ||
|
|
|
|
!MLX5_CAP_FLOWTABLE_NIC_TX(mdev, reformat_add_macsec))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!MLX5_CAP_MACSEC(mdev, macsec_crypto_esp_aes_gcm_128_encrypt) &&
|
|
|
|
!MLX5_CAP_MACSEC(mdev, macsec_crypto_esp_aes_gcm_256_encrypt))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!MLX5_CAP_MACSEC(mdev, macsec_crypto_esp_aes_gcm_128_decrypt) &&
|
|
|
|
!MLX5_CAP_MACSEC(mdev, macsec_crypto_esp_aes_gcm_256_decrypt))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NIC_RDMA_BOTH_DIRS_CAPS (MLX5_FT_NIC_RX_2_NIC_RX_RDMA | MLX5_FT_NIC_TX_RDMA_2_NIC_TX)
|
|
|
|
|
|
|
|
static inline bool mlx5_is_macsec_roce_supported(struct mlx5_core_dev *mdev)
|
|
|
|
{
|
|
|
|
if (((MLX5_CAP_GEN_2(mdev, flow_table_type_2_type) &
|
|
|
|
NIC_RDMA_BOTH_DIRS_CAPS) != NIC_RDMA_BOTH_DIRS_CAPS) ||
|
|
|
|
!MLX5_CAP_FLOWTABLE_RDMA_TX(mdev, max_modify_header_actions) ||
|
2023-04-13 09:04:59 +00:00
|
|
|
!mlx5e_is_macsec_device(mdev) || !mdev->macsec_fs)
|
2022-05-03 05:37:48 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2023-04-13 09:04:59 +00:00
|
|
|
#endif
|
2022-05-03 05:37:48 +00:00
|
|
|
|
2022-10-02 04:56:22 +00:00
|
|
|
enum {
|
|
|
|
MLX5_OCTWORD = 16,
|
|
|
|
};
|
net/mlx5: Reimplement write combining test
The test of write combining was added before in mlx5_ib driver. It
opens UD QP and posts NOP WQEs, and uses BlueFlame doorbell. When
BlueFlame is used, WQEs get written directly to a PCI BAR of the
device (in addition to memory) so that the device handles them without
having to access memory.
In this test, the WQEs written in memory are different from the ones
written to the BlueFlame which request CQE update. By checking the
completion reports posted on CQ, we can know if BlueFlame succeeds or
not. The write combining must be supported if BlueFlame succeeds as
its register is written using write combining.
This patch reimplements the test in the same way, but using a pair of
SQ and CQ only. It is moved to mlx5_core as a general feature used by
both mlx5_core and mlx5_ib.
Besides, save write combine test result of the PCI function, so that
its thousands of child functions such as SF can query without paying
the time and resource penalty by itself. The test function is called
only after failing to get the cached result. With this enhancement,
all thousands of SFs of the PF attached to same driver no longer need
to perform WC check explicitly, which is already done in the system.
This saves several commands per SF, thereby speeds up SF creation and
also saves completion EQ creation.
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/4ff5a8cc4c5b5b0d98397baa45a5019bcdbf096e.1717409369.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2024-06-03 10:26:37 +00:00
|
|
|
|
|
|
|
bool mlx5_wc_support_get(struct mlx5_core_dev *mdev);
|
2013-07-07 14:25:49 +00:00
|
|
|
#endif /* MLX5_DRIVER_H */
|