2 * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 #include <linux/highmem.h>
34 #include <linux/module.h>
35 #include <linux/init.h>
36 #include <linux/errno.h>
37 #include <linux/pci.h>
38 #include <linux/dma-mapping.h>
39 #include <linux/slab.h>
40 #include <linux/io-mapping.h>
41 #include <linux/interrupt.h>
42 #include <linux/delay.h>
43 #include <linux/mlx5/driver.h>
44 #include <linux/mlx5/cq.h>
45 #include <linux/mlx5/qp.h>
46 #include <linux/mlx5/srq.h>
47 #include <linux/debugfs.h>
48 #include <linux/kmod.h>
49 #include <linux/mlx5/mlx5_ifc.h>
50 #include <linux/mlx5/vport.h>
51 #ifdef CONFIG_RFS_ACCEL
52 #include <linux/cpu_rmap.h>
54 #include <net/devlink.h>
55 #include "mlx5_core.h"
60 #include "fpga/core.h"
61 #include "fpga/ipsec.h"
62 #include "accel/ipsec.h"
63 #include "accel/tls.h"
64 #include "lib/clock.h"
66 MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>");
67 MODULE_DESCRIPTION("Mellanox Connect-IB, ConnectX-4 core driver");
68 MODULE_LICENSE("Dual BSD/GPL");
69 MODULE_VERSION(DRIVER_VERSION);
71 unsigned int mlx5_core_debug_mask;
72 module_param_named(debug_mask, mlx5_core_debug_mask, uint, 0644);
73 MODULE_PARM_DESC(debug_mask, "debug mask: 1 = dump cmd data, 2 = dump cmd exec time, 3 = both. Default=0");
75 #define MLX5_DEFAULT_PROF 2
76 static unsigned int prof_sel = MLX5_DEFAULT_PROF;
77 module_param_named(prof_sel, prof_sel, uint, 0444);
78 MODULE_PARM_DESC(prof_sel, "profile selector. Valid range 0 - 2");
80 static u32 sw_owner_id[4];
83 MLX5_ATOMIC_REQ_MODE_BE = 0x0,
84 MLX5_ATOMIC_REQ_MODE_HOST_ENDIANNESS = 0x1,
87 static struct mlx5_profile profile[] = {
92 .mask = MLX5_PROF_MASK_QP_SIZE,
96 .mask = MLX5_PROF_MASK_QP_SIZE |
97 MLX5_PROF_MASK_MR_CACHE,
186 #define FW_INIT_TIMEOUT_MILI 2000
187 #define FW_INIT_WAIT_MS 2
188 #define FW_PRE_INIT_TIMEOUT_MILI 10000
190 static int wait_fw_init(struct mlx5_core_dev *dev, u32 max_wait_mili)
192 unsigned long end = jiffies + msecs_to_jiffies(max_wait_mili);
195 while (fw_initializing(dev)) {
196 if (time_after(jiffies, end)) {
200 msleep(FW_INIT_WAIT_MS);
206 static void mlx5_set_driver_version(struct mlx5_core_dev *dev)
208 int driver_ver_sz = MLX5_FLD_SZ_BYTES(set_driver_version_in,
210 u8 in[MLX5_ST_SZ_BYTES(set_driver_version_in)] = {0};
211 u8 out[MLX5_ST_SZ_BYTES(set_driver_version_out)] = {0};
212 int remaining_size = driver_ver_sz;
215 if (!MLX5_CAP_GEN(dev, driver_version))
218 string = MLX5_ADDR_OF(set_driver_version_in, in, driver_version);
220 strncpy(string, "Linux", remaining_size);
222 remaining_size = max_t(int, 0, driver_ver_sz - strlen(string));
223 strncat(string, ",", remaining_size);
225 remaining_size = max_t(int, 0, driver_ver_sz - strlen(string));
226 strncat(string, DRIVER_NAME, remaining_size);
228 remaining_size = max_t(int, 0, driver_ver_sz - strlen(string));
229 strncat(string, ",", remaining_size);
231 remaining_size = max_t(int, 0, driver_ver_sz - strlen(string));
232 strncat(string, DRIVER_VERSION, remaining_size);
235 MLX5_SET(set_driver_version_in, in, opcode,
236 MLX5_CMD_OP_SET_DRIVER_VERSION);
238 mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
241 static int set_dma_caps(struct pci_dev *pdev)
245 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
247 dev_warn(&pdev->dev, "Warning: couldn't set 64-bit PCI DMA mask\n");
248 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
250 dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting\n");
255 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
258 "Warning: couldn't set 64-bit consistent PCI DMA mask\n");
259 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
262 "Can't set consistent PCI DMA mask, aborting\n");
267 dma_set_max_seg_size(&pdev->dev, 2u * 1024 * 1024 * 1024);
271 static int mlx5_pci_enable_device(struct mlx5_core_dev *dev)
273 struct pci_dev *pdev = dev->pdev;
276 mutex_lock(&dev->pci_status_mutex);
277 if (dev->pci_status == MLX5_PCI_STATUS_DISABLED) {
278 err = pci_enable_device(pdev);
280 dev->pci_status = MLX5_PCI_STATUS_ENABLED;
282 mutex_unlock(&dev->pci_status_mutex);
287 static void mlx5_pci_disable_device(struct mlx5_core_dev *dev)
289 struct pci_dev *pdev = dev->pdev;
291 mutex_lock(&dev->pci_status_mutex);
292 if (dev->pci_status == MLX5_PCI_STATUS_ENABLED) {
293 pci_disable_device(pdev);
294 dev->pci_status = MLX5_PCI_STATUS_DISABLED;
296 mutex_unlock(&dev->pci_status_mutex);
299 static int request_bar(struct pci_dev *pdev)
303 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
304 dev_err(&pdev->dev, "Missing registers BAR, aborting\n");
308 err = pci_request_regions(pdev, DRIVER_NAME);
310 dev_err(&pdev->dev, "Couldn't get PCI resources, aborting\n");
315 static void release_bar(struct pci_dev *pdev)
317 pci_release_regions(pdev);
320 static int mlx5_alloc_irq_vectors(struct mlx5_core_dev *dev)
322 struct mlx5_priv *priv = &dev->priv;
323 struct mlx5_eq_table *table = &priv->eq_table;
324 int num_eqs = 1 << MLX5_CAP_GEN(dev, log_max_eq);
328 nvec = MLX5_CAP_GEN(dev, num_ports) * num_online_cpus() +
329 MLX5_EQ_VEC_COMP_BASE;
330 nvec = min_t(int, nvec, num_eqs);
331 if (nvec <= MLX5_EQ_VEC_COMP_BASE)
334 priv->irq_info = kcalloc(nvec, sizeof(*priv->irq_info), GFP_KERNEL);
338 nvec = pci_alloc_irq_vectors(dev->pdev,
339 MLX5_EQ_VEC_COMP_BASE + 1, nvec,
343 goto err_free_irq_info;
346 table->num_comp_vectors = nvec - MLX5_EQ_VEC_COMP_BASE;
351 kfree(priv->irq_info);
355 static void mlx5_free_irq_vectors(struct mlx5_core_dev *dev)
357 struct mlx5_priv *priv = &dev->priv;
359 pci_free_irq_vectors(dev->pdev);
360 kfree(priv->irq_info);
363 struct mlx5_reg_host_endianness {
368 #define CAP_MASK(pos, size) ((u64)((1 << (size)) - 1) << (pos))
371 MLX5_CAP_BITS_RW_MASK = CAP_MASK(MLX5_CAP_OFF_CMDIF_CSUM, 2) |
372 MLX5_DEV_CAP_FLAG_DCT,
375 static u16 to_fw_pkey_sz(struct mlx5_core_dev *dev, u32 size)
391 mlx5_core_warn(dev, "invalid pkey table size %d\n", size);
396 static int mlx5_core_get_caps_mode(struct mlx5_core_dev *dev,
397 enum mlx5_cap_type cap_type,
398 enum mlx5_cap_mode cap_mode)
400 u8 in[MLX5_ST_SZ_BYTES(query_hca_cap_in)];
401 int out_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out);
402 void *out, *hca_caps;
403 u16 opmod = (cap_type << 1) | (cap_mode & 0x01);
406 memset(in, 0, sizeof(in));
407 out = kzalloc(out_sz, GFP_KERNEL);
411 MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP);
412 MLX5_SET(query_hca_cap_in, in, op_mod, opmod);
413 err = mlx5_cmd_exec(dev, in, sizeof(in), out, out_sz);
416 "QUERY_HCA_CAP : type(%x) opmode(%x) Failed(%d)\n",
417 cap_type, cap_mode, err);
421 hca_caps = MLX5_ADDR_OF(query_hca_cap_out, out, capability);
424 case HCA_CAP_OPMOD_GET_MAX:
425 memcpy(dev->caps.hca_max[cap_type], hca_caps,
426 MLX5_UN_SZ_BYTES(hca_cap_union));
428 case HCA_CAP_OPMOD_GET_CUR:
429 memcpy(dev->caps.hca_cur[cap_type], hca_caps,
430 MLX5_UN_SZ_BYTES(hca_cap_union));
434 "Tried to query dev cap type(%x) with wrong opmode(%x)\n",
444 int mlx5_core_get_caps(struct mlx5_core_dev *dev, enum mlx5_cap_type cap_type)
448 ret = mlx5_core_get_caps_mode(dev, cap_type, HCA_CAP_OPMOD_GET_CUR);
451 return mlx5_core_get_caps_mode(dev, cap_type, HCA_CAP_OPMOD_GET_MAX);
454 static int set_caps(struct mlx5_core_dev *dev, void *in, int in_sz, int opmod)
456 u32 out[MLX5_ST_SZ_DW(set_hca_cap_out)] = {0};
458 MLX5_SET(set_hca_cap_in, in, opcode, MLX5_CMD_OP_SET_HCA_CAP);
459 MLX5_SET(set_hca_cap_in, in, op_mod, opmod << 1);
460 return mlx5_cmd_exec(dev, in, in_sz, out, sizeof(out));
463 static int handle_hca_cap_atomic(struct mlx5_core_dev *dev)
467 int set_sz = MLX5_ST_SZ_BYTES(set_hca_cap_in);
471 if (MLX5_CAP_GEN(dev, atomic)) {
472 err = mlx5_core_get_caps(dev, MLX5_CAP_ATOMIC);
481 supported_atomic_req_8B_endianness_mode_1);
483 if (req_endianness != MLX5_ATOMIC_REQ_MODE_HOST_ENDIANNESS)
486 set_ctx = kzalloc(set_sz, GFP_KERNEL);
490 set_hca_cap = MLX5_ADDR_OF(set_hca_cap_in, set_ctx, capability);
492 /* Set requestor to host endianness */
493 MLX5_SET(atomic_caps, set_hca_cap, atomic_req_8B_endianness_mode,
494 MLX5_ATOMIC_REQ_MODE_HOST_ENDIANNESS);
496 err = set_caps(dev, set_ctx, set_sz, MLX5_SET_HCA_CAP_OP_MOD_ATOMIC);
502 static int handle_hca_cap(struct mlx5_core_dev *dev)
504 void *set_ctx = NULL;
505 struct mlx5_profile *prof = dev->profile;
507 int set_sz = MLX5_ST_SZ_BYTES(set_hca_cap_in);
510 set_ctx = kzalloc(set_sz, GFP_KERNEL);
514 err = mlx5_core_get_caps(dev, MLX5_CAP_GENERAL);
518 set_hca_cap = MLX5_ADDR_OF(set_hca_cap_in, set_ctx,
520 memcpy(set_hca_cap, dev->caps.hca_cur[MLX5_CAP_GENERAL],
521 MLX5_ST_SZ_BYTES(cmd_hca_cap));
523 mlx5_core_dbg(dev, "Current Pkey table size %d Setting new size %d\n",
524 mlx5_to_sw_pkey_sz(MLX5_CAP_GEN(dev, pkey_table_size)),
526 /* we limit the size of the pkey table to 128 entries for now */
527 MLX5_SET(cmd_hca_cap, set_hca_cap, pkey_table_size,
528 to_fw_pkey_sz(dev, 128));
530 /* Check log_max_qp from HCA caps to set in current profile */
531 if (MLX5_CAP_GEN_MAX(dev, log_max_qp) < profile[prof_sel].log_max_qp) {
532 mlx5_core_warn(dev, "log_max_qp value in current profile is %d, changing it to HCA capability limit (%d)\n",
533 profile[prof_sel].log_max_qp,
534 MLX5_CAP_GEN_MAX(dev, log_max_qp));
535 profile[prof_sel].log_max_qp = MLX5_CAP_GEN_MAX(dev, log_max_qp);
537 if (prof->mask & MLX5_PROF_MASK_QP_SIZE)
538 MLX5_SET(cmd_hca_cap, set_hca_cap, log_max_qp,
541 /* disable cmdif checksum */
542 MLX5_SET(cmd_hca_cap, set_hca_cap, cmdif_checksum, 0);
544 /* Enable 4K UAR only when HCA supports it and page size is bigger
547 if (MLX5_CAP_GEN_MAX(dev, uar_4k) && PAGE_SIZE > 4096)
548 MLX5_SET(cmd_hca_cap, set_hca_cap, uar_4k, 1);
550 MLX5_SET(cmd_hca_cap, set_hca_cap, log_uar_page_sz, PAGE_SHIFT - 12);
552 if (MLX5_CAP_GEN_MAX(dev, cache_line_128byte))
553 MLX5_SET(cmd_hca_cap,
556 cache_line_size() >= 128 ? 1 : 0);
558 if (MLX5_CAP_GEN_MAX(dev, dct))
559 MLX5_SET(cmd_hca_cap, set_hca_cap, dct, 1);
561 if (MLX5_CAP_GEN_MAX(dev, num_vhca_ports))
562 MLX5_SET(cmd_hca_cap,
565 MLX5_CAP_GEN_MAX(dev, num_vhca_ports));
567 err = set_caps(dev, set_ctx, set_sz,
568 MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE);
575 static int set_hca_ctrl(struct mlx5_core_dev *dev)
577 struct mlx5_reg_host_endianness he_in;
578 struct mlx5_reg_host_endianness he_out;
581 if (!mlx5_core_is_pf(dev))
584 memset(&he_in, 0, sizeof(he_in));
585 he_in.he = MLX5_SET_HOST_ENDIANNESS;
586 err = mlx5_core_access_reg(dev, &he_in, sizeof(he_in),
587 &he_out, sizeof(he_out),
588 MLX5_REG_HOST_ENDIANNESS, 0, 1);
592 static int mlx5_core_set_hca_defaults(struct mlx5_core_dev *dev)
596 /* Disable local_lb by default */
597 if (MLX5_CAP_GEN(dev, port_type) == MLX5_CAP_PORT_TYPE_ETH)
598 ret = mlx5_nic_vport_update_local_lb(dev, false);
603 int mlx5_core_enable_hca(struct mlx5_core_dev *dev, u16 func_id)
605 u32 out[MLX5_ST_SZ_DW(enable_hca_out)] = {0};
606 u32 in[MLX5_ST_SZ_DW(enable_hca_in)] = {0};
608 MLX5_SET(enable_hca_in, in, opcode, MLX5_CMD_OP_ENABLE_HCA);
609 MLX5_SET(enable_hca_in, in, function_id, func_id);
610 return mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
613 int mlx5_core_disable_hca(struct mlx5_core_dev *dev, u16 func_id)
615 u32 out[MLX5_ST_SZ_DW(disable_hca_out)] = {0};
616 u32 in[MLX5_ST_SZ_DW(disable_hca_in)] = {0};
618 MLX5_SET(disable_hca_in, in, opcode, MLX5_CMD_OP_DISABLE_HCA);
619 MLX5_SET(disable_hca_in, in, function_id, func_id);
620 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
623 u64 mlx5_read_internal_timer(struct mlx5_core_dev *dev)
625 u32 timer_h, timer_h1, timer_l;
627 timer_h = ioread32be(&dev->iseg->internal_timer_h);
628 timer_l = ioread32be(&dev->iseg->internal_timer_l);
629 timer_h1 = ioread32be(&dev->iseg->internal_timer_h);
630 if (timer_h != timer_h1) /* wrap around */
631 timer_l = ioread32be(&dev->iseg->internal_timer_l);
633 return (u64)timer_l | (u64)timer_h1 << 32;
636 static int mlx5_irq_set_affinity_hint(struct mlx5_core_dev *mdev, int i)
638 struct mlx5_priv *priv = &mdev->priv;
639 int irq = pci_irq_vector(mdev->pdev, MLX5_EQ_VEC_COMP_BASE + i);
641 if (!zalloc_cpumask_var(&priv->irq_info[i].mask, GFP_KERNEL)) {
642 mlx5_core_warn(mdev, "zalloc_cpumask_var failed");
646 cpumask_set_cpu(cpumask_local_spread(i, priv->numa_node),
647 priv->irq_info[i].mask);
649 if (IS_ENABLED(CONFIG_SMP) &&
650 irq_set_affinity_hint(irq, priv->irq_info[i].mask))
651 mlx5_core_warn(mdev, "irq_set_affinity_hint failed, irq 0x%.4x", irq);
656 static void mlx5_irq_clear_affinity_hint(struct mlx5_core_dev *mdev, int i)
658 struct mlx5_priv *priv = &mdev->priv;
659 int irq = pci_irq_vector(mdev->pdev, MLX5_EQ_VEC_COMP_BASE + i);
661 irq_set_affinity_hint(irq, NULL);
662 free_cpumask_var(priv->irq_info[i].mask);
665 static int mlx5_irq_set_affinity_hints(struct mlx5_core_dev *mdev)
670 for (i = 0; i < mdev->priv.eq_table.num_comp_vectors; i++) {
671 err = mlx5_irq_set_affinity_hint(mdev, i);
679 for (i--; i >= 0; i--)
680 mlx5_irq_clear_affinity_hint(mdev, i);
685 static void mlx5_irq_clear_affinity_hints(struct mlx5_core_dev *mdev)
689 for (i = 0; i < mdev->priv.eq_table.num_comp_vectors; i++)
690 mlx5_irq_clear_affinity_hint(mdev, i);
693 int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn,
696 struct mlx5_eq_table *table = &dev->priv.eq_table;
697 struct mlx5_eq *eq, *n;
700 spin_lock(&table->lock);
701 list_for_each_entry_safe(eq, n, &table->comp_eqs_list, list) {
702 if (eq->index == vector) {
709 spin_unlock(&table->lock);
713 EXPORT_SYMBOL(mlx5_vector2eqn);
715 struct mlx5_eq *mlx5_eqn2eq(struct mlx5_core_dev *dev, int eqn)
717 struct mlx5_eq_table *table = &dev->priv.eq_table;
720 spin_lock(&table->lock);
721 list_for_each_entry(eq, &table->comp_eqs_list, list)
722 if (eq->eqn == eqn) {
723 spin_unlock(&table->lock);
727 spin_unlock(&table->lock);
729 return ERR_PTR(-ENOENT);
732 static void free_comp_eqs(struct mlx5_core_dev *dev)
734 struct mlx5_eq_table *table = &dev->priv.eq_table;
735 struct mlx5_eq *eq, *n;
737 #ifdef CONFIG_RFS_ACCEL
739 free_irq_cpu_rmap(dev->rmap);
743 spin_lock(&table->lock);
744 list_for_each_entry_safe(eq, n, &table->comp_eqs_list, list) {
746 spin_unlock(&table->lock);
747 if (mlx5_destroy_unmap_eq(dev, eq))
748 mlx5_core_warn(dev, "failed to destroy EQ 0x%x\n",
751 spin_lock(&table->lock);
753 spin_unlock(&table->lock);
756 static int alloc_comp_eqs(struct mlx5_core_dev *dev)
758 struct mlx5_eq_table *table = &dev->priv.eq_table;
759 char name[MLX5_MAX_IRQ_NAME];
766 INIT_LIST_HEAD(&table->comp_eqs_list);
767 ncomp_vec = table->num_comp_vectors;
768 nent = MLX5_COMP_EQ_SIZE;
769 #ifdef CONFIG_RFS_ACCEL
770 dev->rmap = alloc_irq_cpu_rmap(ncomp_vec);
774 for (i = 0; i < ncomp_vec; i++) {
775 eq = kzalloc(sizeof(*eq), GFP_KERNEL);
781 #ifdef CONFIG_RFS_ACCEL
782 irq_cpu_rmap_add(dev->rmap, pci_irq_vector(dev->pdev,
783 MLX5_EQ_VEC_COMP_BASE + i));
785 snprintf(name, MLX5_MAX_IRQ_NAME, "mlx5_comp%d", i);
786 err = mlx5_create_map_eq(dev, eq,
787 i + MLX5_EQ_VEC_COMP_BASE, nent, 0,
788 name, MLX5_EQ_TYPE_COMP);
793 mlx5_core_dbg(dev, "allocated completion EQN %d\n", eq->eqn);
795 spin_lock(&table->lock);
796 list_add_tail(&eq->list, &table->comp_eqs_list);
797 spin_unlock(&table->lock);
807 static int mlx5_core_set_issi(struct mlx5_core_dev *dev)
809 u32 query_in[MLX5_ST_SZ_DW(query_issi_in)] = {0};
810 u32 query_out[MLX5_ST_SZ_DW(query_issi_out)] = {0};
814 MLX5_SET(query_issi_in, query_in, opcode, MLX5_CMD_OP_QUERY_ISSI);
815 err = mlx5_cmd_exec(dev, query_in, sizeof(query_in),
816 query_out, sizeof(query_out));
821 mlx5_cmd_mbox_status(query_out, &status, &syndrome);
822 if (!status || syndrome == MLX5_DRIVER_SYND) {
823 mlx5_core_err(dev, "Failed to query ISSI err(%d) status(%d) synd(%d)\n",
824 err, status, syndrome);
828 mlx5_core_warn(dev, "Query ISSI is not supported by FW, ISSI is 0\n");
833 sup_issi = MLX5_GET(query_issi_out, query_out, supported_issi_dw0);
835 if (sup_issi & (1 << 1)) {
836 u32 set_in[MLX5_ST_SZ_DW(set_issi_in)] = {0};
837 u32 set_out[MLX5_ST_SZ_DW(set_issi_out)] = {0};
839 MLX5_SET(set_issi_in, set_in, opcode, MLX5_CMD_OP_SET_ISSI);
840 MLX5_SET(set_issi_in, set_in, current_issi, 1);
841 err = mlx5_cmd_exec(dev, set_in, sizeof(set_in),
842 set_out, sizeof(set_out));
844 mlx5_core_err(dev, "Failed to set ISSI to 1 err(%d)\n",
852 } else if (sup_issi & (1 << 0) || !sup_issi) {
859 static int mlx5_pci_init(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
861 struct pci_dev *pdev = dev->pdev;
864 pci_set_drvdata(dev->pdev, dev);
865 strncpy(priv->name, dev_name(&pdev->dev), MLX5_MAX_NAME_LEN);
866 priv->name[MLX5_MAX_NAME_LEN - 1] = 0;
868 mutex_init(&priv->pgdir_mutex);
869 INIT_LIST_HEAD(&priv->pgdir_list);
870 spin_lock_init(&priv->mkey_lock);
872 mutex_init(&priv->alloc_mutex);
874 priv->numa_node = dev_to_node(&dev->pdev->dev);
876 priv->dbg_root = debugfs_create_dir(dev_name(&pdev->dev), mlx5_debugfs_root);
880 err = mlx5_pci_enable_device(dev);
882 dev_err(&pdev->dev, "Cannot enable PCI device, aborting\n");
886 err = request_bar(pdev);
888 dev_err(&pdev->dev, "error requesting BARs, aborting\n");
892 pci_set_master(pdev);
894 err = set_dma_caps(pdev);
896 dev_err(&pdev->dev, "Failed setting DMA capabilities mask, aborting\n");
900 dev->iseg_base = pci_resource_start(dev->pdev, 0);
901 dev->iseg = ioremap(dev->iseg_base, sizeof(*dev->iseg));
904 dev_err(&pdev->dev, "Failed mapping initialization segment, aborting\n");
911 pci_clear_master(dev->pdev);
912 release_bar(dev->pdev);
914 mlx5_pci_disable_device(dev);
917 debugfs_remove(priv->dbg_root);
921 static void mlx5_pci_close(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
924 pci_clear_master(dev->pdev);
925 release_bar(dev->pdev);
926 mlx5_pci_disable_device(dev);
927 debugfs_remove(priv->dbg_root);
930 static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
932 struct pci_dev *pdev = dev->pdev;
935 err = mlx5_query_board_id(dev);
937 dev_err(&pdev->dev, "query board id failed\n");
941 err = mlx5_eq_init(dev);
943 dev_err(&pdev->dev, "failed to initialize eq\n");
947 err = mlx5_cq_debugfs_init(dev);
949 dev_err(&pdev->dev, "failed to initialize cq debugfs\n");
953 mlx5_init_qp_table(dev);
955 mlx5_init_srq_table(dev);
957 mlx5_init_mkey_table(dev);
959 mlx5_init_reserved_gids(dev);
961 mlx5_init_clock(dev);
963 err = mlx5_init_rl_table(dev);
965 dev_err(&pdev->dev, "Failed to init rate limiting\n");
966 goto err_tables_cleanup;
969 err = mlx5_mpfs_init(dev);
971 dev_err(&pdev->dev, "Failed to init l2 table %d\n", err);
975 err = mlx5_eswitch_init(dev);
977 dev_err(&pdev->dev, "Failed to init eswitch %d\n", err);
978 goto err_mpfs_cleanup;
981 err = mlx5_sriov_init(dev);
983 dev_err(&pdev->dev, "Failed to init sriov %d\n", err);
984 goto err_eswitch_cleanup;
987 err = mlx5_fpga_init(dev);
989 dev_err(&pdev->dev, "Failed to init fpga device %d\n", err);
990 goto err_sriov_cleanup;
996 mlx5_sriov_cleanup(dev);
998 mlx5_eswitch_cleanup(dev->priv.eswitch);
1000 mlx5_mpfs_cleanup(dev);
1002 mlx5_cleanup_rl_table(dev);
1004 mlx5_cleanup_mkey_table(dev);
1005 mlx5_cleanup_srq_table(dev);
1006 mlx5_cleanup_qp_table(dev);
1007 mlx5_cq_debugfs_cleanup(dev);
1010 mlx5_eq_cleanup(dev);
1016 static void mlx5_cleanup_once(struct mlx5_core_dev *dev)
1018 mlx5_fpga_cleanup(dev);
1019 mlx5_sriov_cleanup(dev);
1020 mlx5_eswitch_cleanup(dev->priv.eswitch);
1021 mlx5_mpfs_cleanup(dev);
1022 mlx5_cleanup_rl_table(dev);
1023 mlx5_cleanup_clock(dev);
1024 mlx5_cleanup_reserved_gids(dev);
1025 mlx5_cleanup_mkey_table(dev);
1026 mlx5_cleanup_srq_table(dev);
1027 mlx5_cleanup_qp_table(dev);
1028 mlx5_cq_debugfs_cleanup(dev);
1029 mlx5_eq_cleanup(dev);
1032 static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
1035 struct pci_dev *pdev = dev->pdev;
1038 mutex_lock(&dev->intf_state_mutex);
1039 if (test_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state)) {
1040 dev_warn(&dev->pdev->dev, "%s: interface is up, NOP\n",
1045 dev_info(&pdev->dev, "firmware version: %d.%d.%d\n", fw_rev_maj(dev),
1046 fw_rev_min(dev), fw_rev_sub(dev));
1048 /* Only PFs hold the relevant PCIe information for this query */
1049 if (mlx5_core_is_pf(dev))
1050 pcie_print_link_status(dev->pdev);
1052 /* on load removing any previous indication of internal error, device is
1055 dev->state = MLX5_DEVICE_STATE_UP;
1057 /* wait for firmware to accept initialization segments configurations
1059 err = wait_fw_init(dev, FW_PRE_INIT_TIMEOUT_MILI);
1061 dev_err(&dev->pdev->dev, "Firmware over %d MS in pre-initializing state, aborting\n",
1062 FW_PRE_INIT_TIMEOUT_MILI);
1066 err = mlx5_cmd_init(dev);
1068 dev_err(&pdev->dev, "Failed initializing command interface, aborting\n");
1072 err = wait_fw_init(dev, FW_INIT_TIMEOUT_MILI);
1074 dev_err(&dev->pdev->dev, "Firmware over %d MS in initializing state, aborting\n",
1075 FW_INIT_TIMEOUT_MILI);
1076 goto err_cmd_cleanup;
1079 err = mlx5_core_enable_hca(dev, 0);
1081 dev_err(&pdev->dev, "enable hca failed\n");
1082 goto err_cmd_cleanup;
1085 err = mlx5_core_set_issi(dev);
1087 dev_err(&pdev->dev, "failed to set issi\n");
1088 goto err_disable_hca;
1091 err = mlx5_satisfy_startup_pages(dev, 1);
1093 dev_err(&pdev->dev, "failed to allocate boot pages\n");
1094 goto err_disable_hca;
1097 err = set_hca_ctrl(dev);
1099 dev_err(&pdev->dev, "set_hca_ctrl failed\n");
1100 goto reclaim_boot_pages;
1103 err = handle_hca_cap(dev);
1105 dev_err(&pdev->dev, "handle_hca_cap failed\n");
1106 goto reclaim_boot_pages;
1109 err = handle_hca_cap_atomic(dev);
1111 dev_err(&pdev->dev, "handle_hca_cap_atomic failed\n");
1112 goto reclaim_boot_pages;
1115 err = mlx5_satisfy_startup_pages(dev, 0);
1117 dev_err(&pdev->dev, "failed to allocate init pages\n");
1118 goto reclaim_boot_pages;
1121 err = mlx5_pagealloc_start(dev);
1123 dev_err(&pdev->dev, "mlx5_pagealloc_start failed\n");
1124 goto reclaim_boot_pages;
1127 err = mlx5_cmd_init_hca(dev, sw_owner_id);
1129 dev_err(&pdev->dev, "init hca failed\n");
1130 goto err_pagealloc_stop;
1133 mlx5_set_driver_version(dev);
1135 mlx5_start_health_poll(dev);
1137 err = mlx5_query_hca_caps(dev);
1139 dev_err(&pdev->dev, "query hca failed\n");
1144 err = mlx5_init_once(dev, priv);
1146 dev_err(&pdev->dev, "sw objs init failed\n");
1151 err = mlx5_alloc_irq_vectors(dev);
1153 dev_err(&pdev->dev, "alloc irq vectors failed\n");
1154 goto err_cleanup_once;
1157 dev->priv.uar = mlx5_get_uars_page(dev);
1158 if (IS_ERR(dev->priv.uar)) {
1159 dev_err(&pdev->dev, "Failed allocating uar, aborting\n");
1160 err = PTR_ERR(dev->priv.uar);
1161 goto err_disable_msix;
1164 err = mlx5_start_eqs(dev);
1166 dev_err(&pdev->dev, "Failed to start pages and async EQs\n");
1170 err = alloc_comp_eqs(dev);
1172 dev_err(&pdev->dev, "Failed to alloc completion EQs\n");
1176 err = mlx5_irq_set_affinity_hints(dev);
1178 dev_err(&pdev->dev, "Failed to alloc affinity hint cpumask\n");
1179 goto err_affinity_hints;
1182 err = mlx5_fpga_device_start(dev);
1184 dev_err(&pdev->dev, "fpga device start failed %d\n", err);
1185 goto err_fpga_start;
1188 err = mlx5_accel_ipsec_init(dev);
1190 dev_err(&pdev->dev, "IPSec device start failed %d\n", err);
1191 goto err_ipsec_start;
1194 err = mlx5_accel_tls_init(dev);
1196 dev_err(&pdev->dev, "TLS device start failed %d\n", err);
1200 err = mlx5_init_fs(dev);
1202 dev_err(&pdev->dev, "Failed to init flow steering\n");
1206 err = mlx5_core_set_hca_defaults(dev);
1208 dev_err(&pdev->dev, "Failed to set hca defaults\n");
1212 err = mlx5_sriov_attach(dev);
1214 dev_err(&pdev->dev, "sriov init failed %d\n", err);
1218 if (mlx5_device_registered(dev)) {
1219 mlx5_attach_device(dev);
1221 err = mlx5_register_device(dev);
1223 dev_err(&pdev->dev, "mlx5_register_device failed %d\n", err);
1228 set_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state);
1230 mutex_unlock(&dev->intf_state_mutex);
1235 mlx5_sriov_detach(dev);
1238 mlx5_cleanup_fs(dev);
1241 mlx5_accel_tls_cleanup(dev);
1244 mlx5_accel_ipsec_cleanup(dev);
1247 mlx5_fpga_device_stop(dev);
1250 mlx5_irq_clear_affinity_hints(dev);
1259 mlx5_put_uars_page(dev, priv->uar);
1262 mlx5_free_irq_vectors(dev);
1266 mlx5_cleanup_once(dev);
1269 mlx5_stop_health_poll(dev);
1270 if (mlx5_cmd_teardown_hca(dev)) {
1271 dev_err(&dev->pdev->dev, "tear_down_hca failed, skip cleanup\n");
1276 mlx5_pagealloc_stop(dev);
1279 mlx5_reclaim_startup_pages(dev);
1282 mlx5_core_disable_hca(dev, 0);
1285 mlx5_cmd_cleanup(dev);
1288 dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR;
1289 mutex_unlock(&dev->intf_state_mutex);
1294 static int mlx5_unload_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
1300 mlx5_drain_health_recovery(dev);
1302 mutex_lock(&dev->intf_state_mutex);
1303 if (!test_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state)) {
1304 dev_warn(&dev->pdev->dev, "%s: interface is down, NOP\n",
1307 mlx5_cleanup_once(dev);
1311 clear_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state);
1313 if (mlx5_device_registered(dev))
1314 mlx5_detach_device(dev);
1316 mlx5_sriov_detach(dev);
1317 mlx5_cleanup_fs(dev);
1318 mlx5_accel_ipsec_cleanup(dev);
1319 mlx5_accel_tls_cleanup(dev);
1320 mlx5_fpga_device_stop(dev);
1321 mlx5_irq_clear_affinity_hints(dev);
1324 mlx5_put_uars_page(dev, priv->uar);
1325 mlx5_free_irq_vectors(dev);
1327 mlx5_cleanup_once(dev);
1328 mlx5_stop_health_poll(dev);
1329 err = mlx5_cmd_teardown_hca(dev);
1331 dev_err(&dev->pdev->dev, "tear_down_hca failed, skip cleanup\n");
1334 mlx5_pagealloc_stop(dev);
1335 mlx5_reclaim_startup_pages(dev);
1336 mlx5_core_disable_hca(dev, 0);
1337 mlx5_cmd_cleanup(dev);
1340 mutex_unlock(&dev->intf_state_mutex);
1344 struct mlx5_core_event_handler {
1345 void (*event)(struct mlx5_core_dev *dev,
1346 enum mlx5_dev_event event,
1350 static const struct devlink_ops mlx5_devlink_ops = {
1351 #ifdef CONFIG_MLX5_ESWITCH
1352 .eswitch_mode_set = mlx5_devlink_eswitch_mode_set,
1353 .eswitch_mode_get = mlx5_devlink_eswitch_mode_get,
1354 .eswitch_inline_mode_set = mlx5_devlink_eswitch_inline_mode_set,
1355 .eswitch_inline_mode_get = mlx5_devlink_eswitch_inline_mode_get,
1356 .eswitch_encap_mode_set = mlx5_devlink_eswitch_encap_mode_set,
1357 .eswitch_encap_mode_get = mlx5_devlink_eswitch_encap_mode_get,
1361 #define MLX5_IB_MOD "mlx5_ib"
1362 static int init_one(struct pci_dev *pdev,
1363 const struct pci_device_id *id)
1365 struct mlx5_core_dev *dev;
1366 struct devlink *devlink;
1367 struct mlx5_priv *priv;
1370 devlink = devlink_alloc(&mlx5_devlink_ops, sizeof(*dev));
1372 dev_err(&pdev->dev, "kzalloc failed\n");
1376 dev = devlink_priv(devlink);
1378 priv->pci_dev_data = id->driver_data;
1380 pci_set_drvdata(pdev, dev);
1383 dev->event = mlx5_core_event;
1384 dev->profile = &profile[prof_sel];
1386 INIT_LIST_HEAD(&priv->ctx_list);
1387 spin_lock_init(&priv->ctx_lock);
1388 mutex_init(&dev->pci_status_mutex);
1389 mutex_init(&dev->intf_state_mutex);
1391 INIT_LIST_HEAD(&priv->waiting_events_list);
1392 priv->is_accum_events = false;
1394 #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
1395 err = init_srcu_struct(&priv->pfault_srcu);
1397 dev_err(&pdev->dev, "init_srcu_struct failed with error code %d\n",
1402 mutex_init(&priv->bfregs.reg_head.lock);
1403 mutex_init(&priv->bfregs.wc_head.lock);
1404 INIT_LIST_HEAD(&priv->bfregs.reg_head.list);
1405 INIT_LIST_HEAD(&priv->bfregs.wc_head.list);
1407 err = mlx5_pci_init(dev, priv);
1409 dev_err(&pdev->dev, "mlx5_pci_init failed with error code %d\n", err);
1413 err = mlx5_health_init(dev);
1415 dev_err(&pdev->dev, "mlx5_health_init failed with error code %d\n", err);
1419 mlx5_pagealloc_init(dev);
1421 err = mlx5_load_one(dev, priv, true);
1423 dev_err(&pdev->dev, "mlx5_load_one failed with error code %d\n", err);
1427 request_module_nowait(MLX5_IB_MOD);
1429 err = devlink_register(devlink, &pdev->dev);
1433 pci_save_state(pdev);
1437 mlx5_unload_one(dev, priv, true);
1439 mlx5_pagealloc_cleanup(dev);
1440 mlx5_health_cleanup(dev);
1442 mlx5_pci_close(dev, priv);
1444 #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
1445 cleanup_srcu_struct(&priv->pfault_srcu);
1448 devlink_free(devlink);
1453 static void remove_one(struct pci_dev *pdev)
1455 struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
1456 struct devlink *devlink = priv_to_devlink(dev);
1457 struct mlx5_priv *priv = &dev->priv;
1459 devlink_unregister(devlink);
1460 mlx5_unregister_device(dev);
1462 if (mlx5_unload_one(dev, priv, true)) {
1463 dev_err(&dev->pdev->dev, "mlx5_unload_one failed\n");
1464 mlx5_health_cleanup(dev);
1468 mlx5_pagealloc_cleanup(dev);
1469 mlx5_health_cleanup(dev);
1470 mlx5_pci_close(dev, priv);
1471 #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
1472 cleanup_srcu_struct(&priv->pfault_srcu);
1474 devlink_free(devlink);
1477 static pci_ers_result_t mlx5_pci_err_detected(struct pci_dev *pdev,
1478 pci_channel_state_t state)
1480 struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
1481 struct mlx5_priv *priv = &dev->priv;
1483 dev_info(&pdev->dev, "%s was called\n", __func__);
1485 mlx5_enter_error_state(dev, false);
1486 mlx5_unload_one(dev, priv, false);
1487 /* In case of kernel call drain the health wq */
1489 mlx5_drain_health_wq(dev);
1490 mlx5_pci_disable_device(dev);
1493 return state == pci_channel_io_perm_failure ?
1494 PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET;
1497 /* wait for the device to show vital signs by waiting
1498 * for the health counter to start counting.
1500 static int wait_vital(struct pci_dev *pdev)
1502 struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
1503 struct mlx5_core_health *health = &dev->priv.health;
1504 const int niter = 100;
1509 for (i = 0; i < niter; i++) {
1510 count = ioread32be(health->health_counter);
1511 if (count && count != 0xffffffff) {
1512 if (last_count && last_count != count) {
1513 dev_info(&pdev->dev, "Counter value 0x%x after %d iterations\n", count, i);
1524 static pci_ers_result_t mlx5_pci_slot_reset(struct pci_dev *pdev)
1526 struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
1529 dev_info(&pdev->dev, "%s was called\n", __func__);
1531 err = mlx5_pci_enable_device(dev);
1533 dev_err(&pdev->dev, "%s: mlx5_pci_enable_device failed with error code: %d\n"
1535 return PCI_ERS_RESULT_DISCONNECT;
1538 pci_set_master(pdev);
1539 pci_restore_state(pdev);
1540 pci_save_state(pdev);
1542 if (wait_vital(pdev)) {
1543 dev_err(&pdev->dev, "%s: wait_vital timed out\n", __func__);
1544 return PCI_ERS_RESULT_DISCONNECT;
1547 return PCI_ERS_RESULT_RECOVERED;
1550 static void mlx5_pci_resume(struct pci_dev *pdev)
1552 struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
1553 struct mlx5_priv *priv = &dev->priv;
1556 dev_info(&pdev->dev, "%s was called\n", __func__);
1558 err = mlx5_load_one(dev, priv, false);
1560 dev_err(&pdev->dev, "%s: mlx5_load_one failed with error code: %d\n"
1563 dev_info(&pdev->dev, "%s: device recovered\n", __func__);
1566 static const struct pci_error_handlers mlx5_err_handler = {
1567 .error_detected = mlx5_pci_err_detected,
1568 .slot_reset = mlx5_pci_slot_reset,
1569 .resume = mlx5_pci_resume
1572 static int mlx5_try_fast_unload(struct mlx5_core_dev *dev)
1576 if (!MLX5_CAP_GEN(dev, force_teardown)) {
1577 mlx5_core_dbg(dev, "force teardown is not supported in the firmware\n");
1581 if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
1582 mlx5_core_dbg(dev, "Device in internal error state, giving up\n");
1586 /* Panic tear down fw command will stop the PCI bus communication
1587 * with the HCA, so the health polll is no longer needed.
1589 mlx5_drain_health_wq(dev);
1590 mlx5_stop_health_poll(dev);
1592 ret = mlx5_cmd_force_teardown_hca(dev);
1594 mlx5_core_dbg(dev, "Firmware couldn't do fast unload error: %d\n", ret);
1595 mlx5_start_health_poll(dev);
1599 mlx5_enter_error_state(dev, true);
1604 static void shutdown(struct pci_dev *pdev)
1606 struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
1607 struct mlx5_priv *priv = &dev->priv;
1610 dev_info(&pdev->dev, "Shutdown was called\n");
1611 err = mlx5_try_fast_unload(dev);
1613 mlx5_unload_one(dev, priv, false);
1614 mlx5_pci_disable_device(dev);
1617 static const struct pci_device_id mlx5_core_pci_table[] = {
1618 { PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_CONNECTIB) },
1619 { PCI_VDEVICE(MELLANOX, 0x1012), MLX5_PCI_DEV_IS_VF}, /* Connect-IB VF */
1620 { PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_CONNECTX4) },
1621 { PCI_VDEVICE(MELLANOX, 0x1014), MLX5_PCI_DEV_IS_VF}, /* ConnectX-4 VF */
1622 { PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_CONNECTX4_LX) },
1623 { PCI_VDEVICE(MELLANOX, 0x1016), MLX5_PCI_DEV_IS_VF}, /* ConnectX-4LX VF */
1624 { PCI_VDEVICE(MELLANOX, 0x1017) }, /* ConnectX-5, PCIe 3.0 */
1625 { PCI_VDEVICE(MELLANOX, 0x1018), MLX5_PCI_DEV_IS_VF}, /* ConnectX-5 VF */
1626 { PCI_VDEVICE(MELLANOX, 0x1019) }, /* ConnectX-5 Ex */
1627 { PCI_VDEVICE(MELLANOX, 0x101a), MLX5_PCI_DEV_IS_VF}, /* ConnectX-5 Ex VF */
1628 { PCI_VDEVICE(MELLANOX, 0x101b) }, /* ConnectX-6 */
1629 { PCI_VDEVICE(MELLANOX, 0x101c), MLX5_PCI_DEV_IS_VF}, /* ConnectX-6 VF */
1630 { PCI_VDEVICE(MELLANOX, 0xa2d2) }, /* BlueField integrated ConnectX-5 network controller */
1631 { PCI_VDEVICE(MELLANOX, 0xa2d3), MLX5_PCI_DEV_IS_VF}, /* BlueField integrated ConnectX-5 network controller VF */
1635 MODULE_DEVICE_TABLE(pci, mlx5_core_pci_table);
1637 void mlx5_disable_device(struct mlx5_core_dev *dev)
1639 mlx5_pci_err_detected(dev->pdev, 0);
1642 void mlx5_recover_device(struct mlx5_core_dev *dev)
1644 mlx5_pci_disable_device(dev);
1645 if (mlx5_pci_slot_reset(dev->pdev) == PCI_ERS_RESULT_RECOVERED)
1646 mlx5_pci_resume(dev->pdev);
1649 static struct pci_driver mlx5_core_driver = {
1650 .name = DRIVER_NAME,
1651 .id_table = mlx5_core_pci_table,
1653 .remove = remove_one,
1654 .shutdown = shutdown,
1655 .err_handler = &mlx5_err_handler,
1656 .sriov_configure = mlx5_core_sriov_configure,
1659 static void mlx5_core_verify_params(void)
1661 if (prof_sel >= ARRAY_SIZE(profile)) {
1662 pr_warn("mlx5_core: WARNING: Invalid module parameter prof_sel %d, valid range 0-%zu, changing back to default(%d)\n",
1664 ARRAY_SIZE(profile) - 1,
1666 prof_sel = MLX5_DEFAULT_PROF;
1670 static int __init init(void)
1674 get_random_bytes(&sw_owner_id, sizeof(sw_owner_id));
1676 mlx5_core_verify_params();
1677 mlx5_fpga_ipsec_build_fs_cmds();
1678 mlx5_register_debugfs();
1680 err = pci_register_driver(&mlx5_core_driver);
1684 #ifdef CONFIG_MLX5_CORE_EN
1691 mlx5_unregister_debugfs();
1695 static void __exit cleanup(void)
1697 #ifdef CONFIG_MLX5_CORE_EN
1700 pci_unregister_driver(&mlx5_core_driver);
1701 mlx5_unregister_debugfs();
1705 module_exit(cleanup);