main.c (f5f502a3ea349bc549dd42fb2aca7daaccc9bd03) main.c (758ce14aee825f8f3ca8f76c9991c108094cae8b)
1// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2/*
3 * Copyright (c) 2013-2020, Mellanox Technologies inc. All rights reserved.
4 * Copyright (c) 2020, Intel Corporation. All rights reserved.
5 */
6
7#include <linux/debugfs.h>
8#include <linux/highmem.h>

--- 32 unchanged lines hidden (view full) ---

41#include "wr.h"
42#include "restrack.h"
43#include "counters.h"
44#include "umr.h"
45#include <rdma/uverbs_std_types.h>
46#include <rdma/uverbs_ioctl.h>
47#include <rdma/mlx5_user_ioctl_verbs.h>
48#include <rdma/mlx5_user_ioctl_cmds.h>
1// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2/*
3 * Copyright (c) 2013-2020, Mellanox Technologies inc. All rights reserved.
4 * Copyright (c) 2020, Intel Corporation. All rights reserved.
5 */
6
7#include <linux/debugfs.h>
8#include <linux/highmem.h>

--- 32 unchanged lines hidden (view full) ---

41#include "wr.h"
42#include "restrack.h"
43#include "counters.h"
44#include "umr.h"
45#include <rdma/uverbs_std_types.h>
46#include <rdma/uverbs_ioctl.h>
47#include <rdma/mlx5_user_ioctl_verbs.h>
48#include <rdma/mlx5_user_ioctl_cmds.h>
49#include "macsec.h"
49
50#define UVERBS_MODULE_NAME mlx5_ib
51#include <rdma/uverbs_named_ioctl.h>
52
53MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>");
54MODULE_DESCRIPTION("Mellanox 5th generation network adapters (ConnectX series) IB driver");
55MODULE_LICENSE("Dual BSD/GPL");
56

--- 502 unchanged lines hidden (view full) ---

559
560 props->active_mtu = min(props->max_mtu, ndev_ib_mtu);
561out:
562 if (put_mdev)
563 mlx5_ib_put_native_port_mdev(dev, port_num);
564 return err;
565}
566
50
51#define UVERBS_MODULE_NAME mlx5_ib
52#include <rdma/uverbs_named_ioctl.h>
53
54MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>");
55MODULE_DESCRIPTION("Mellanox 5th generation network adapters (ConnectX series) IB driver");
56MODULE_LICENSE("Dual BSD/GPL");
57

--- 502 unchanged lines hidden (view full) ---

560
561 props->active_mtu = min(props->max_mtu, ndev_ib_mtu);
562out:
563 if (put_mdev)
564 mlx5_ib_put_native_port_mdev(dev, port_num);
565 return err;
566}
567
567static int set_roce_addr(struct mlx5_ib_dev *dev, u32 port_num,
568 unsigned int index, const union ib_gid *gid,
569 const struct ib_gid_attr *attr)
568int set_roce_addr(struct mlx5_ib_dev *dev, u32 port_num,
569 unsigned int index, const union ib_gid *gid,
570 const struct ib_gid_attr *attr)
570{
571 enum ib_gid_type gid_type;
572 u16 vlan_id = 0xffff;
573 u8 roce_version = 0;
574 u8 roce_l3_type = 0;
575 u8 mac[ETH_ALEN];
576 int ret;
577

--- 24 unchanged lines hidden (view full) ---

602 roce_l3_type, gid->raw, mac,
603 vlan_id < VLAN_CFI_MASK, vlan_id,
604 port_num);
605}
606
607static int mlx5_ib_add_gid(const struct ib_gid_attr *attr,
608 __always_unused void **context)
609{
571{
572 enum ib_gid_type gid_type;
573 u16 vlan_id = 0xffff;
574 u8 roce_version = 0;
575 u8 roce_l3_type = 0;
576 u8 mac[ETH_ALEN];
577 int ret;
578

--- 24 unchanged lines hidden (view full) ---

603 roce_l3_type, gid->raw, mac,
604 vlan_id < VLAN_CFI_MASK, vlan_id,
605 port_num);
606}
607
608static int mlx5_ib_add_gid(const struct ib_gid_attr *attr,
609 __always_unused void **context)
610{
611 int ret;
612
613 ret = mlx5r_add_gid_macsec_operations(attr);
614 if (ret)
615 return ret;
616
610 return set_roce_addr(to_mdev(attr->device), attr->port_num,
611 attr->index, &attr->gid, attr);
612}
613
614static int mlx5_ib_del_gid(const struct ib_gid_attr *attr,
615 __always_unused void **context)
616{
617 return set_roce_addr(to_mdev(attr->device), attr->port_num,
618 attr->index, &attr->gid, attr);
619}
620
621static int mlx5_ib_del_gid(const struct ib_gid_attr *attr,
622 __always_unused void **context)
623{
617 return set_roce_addr(to_mdev(attr->device), attr->port_num,
618 attr->index, NULL, attr);
624 int ret;
625
626 ret = set_roce_addr(to_mdev(attr->device), attr->port_num,
627 attr->index, NULL, attr);
628 if (ret)
629 return ret;
630
631 mlx5r_del_gid_macsec_operations(attr);
632 return 0;
619}
620
621__be16 mlx5_get_roce_udp_sport_min(const struct mlx5_ib_dev *dev,
622 const struct ib_gid_attr *attr)
623{
624 if (attr->gid_type != IB_GID_TYPE_ROCE_UDP_ENCAP)
625 return 0;
626

--- 3012 unchanged lines hidden (view full) ---

3639
3640static void mlx5_ib_stage_init_cleanup(struct mlx5_ib_dev *dev)
3641{
3642 mlx5_ib_cleanup_multiport_master(dev);
3643 WARN_ON(!xa_empty(&dev->odp_mkeys));
3644 mutex_destroy(&dev->cap_mask_mutex);
3645 WARN_ON(!xa_empty(&dev->sig_mrs));
3646 WARN_ON(!bitmap_empty(dev->dm.memic_alloc_pages, MLX5_MAX_MEMIC_PAGES));
633}
634
635__be16 mlx5_get_roce_udp_sport_min(const struct mlx5_ib_dev *dev,
636 const struct ib_gid_attr *attr)
637{
638 if (attr->gid_type != IB_GID_TYPE_ROCE_UDP_ENCAP)
639 return 0;
640

--- 3012 unchanged lines hidden (view full) ---

3653
3654static void mlx5_ib_stage_init_cleanup(struct mlx5_ib_dev *dev)
3655{
3656 mlx5_ib_cleanup_multiport_master(dev);
3657 WARN_ON(!xa_empty(&dev->odp_mkeys));
3658 mutex_destroy(&dev->cap_mask_mutex);
3659 WARN_ON(!xa_empty(&dev->sig_mrs));
3660 WARN_ON(!bitmap_empty(dev->dm.memic_alloc_pages, MLX5_MAX_MEMIC_PAGES));
3661 mlx5r_macsec_dealloc_gids(dev);
3647}
3648
3649static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
3650{
3651 struct mlx5_core_dev *mdev = dev->mdev;
3662}
3663
3664static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
3665{
3666 struct mlx5_core_dev *mdev = dev->mdev;
3652 int err;
3653 int i;
3667 int err, i;
3654
3655 dev->ib_dev.node_type = RDMA_NODE_IB_CA;
3656 dev->ib_dev.local_dma_lkey = 0 /* not supported for now */;
3657 dev->ib_dev.phys_port_cnt = dev->num_ports;
3658 dev->ib_dev.dev.parent = mdev->device;
3659 dev->ib_dev.lag_flags = RDMA_LAG_FLAGS_HASH_ALL_SLAVES;
3660
3661 for (i = 0; i < dev->num_ports; i++) {
3662 spin_lock_init(&dev->port[i].mp.mpi_lock);
3663 rwlock_init(&dev->port[i].roce.netdev_lock);
3664 dev->port[i].roce.dev = dev;
3665 dev->port[i].roce.native_port_num = i + 1;
3666 dev->port[i].roce.last_port_state = IB_PORT_DOWN;
3667 }
3668
3669 err = mlx5r_cmd_query_special_mkeys(dev);
3670 if (err)
3671 return err;
3672
3668
3669 dev->ib_dev.node_type = RDMA_NODE_IB_CA;
3670 dev->ib_dev.local_dma_lkey = 0 /* not supported for now */;
3671 dev->ib_dev.phys_port_cnt = dev->num_ports;
3672 dev->ib_dev.dev.parent = mdev->device;
3673 dev->ib_dev.lag_flags = RDMA_LAG_FLAGS_HASH_ALL_SLAVES;
3674
3675 for (i = 0; i < dev->num_ports; i++) {
3676 spin_lock_init(&dev->port[i].mp.mpi_lock);
3677 rwlock_init(&dev->port[i].roce.netdev_lock);
3678 dev->port[i].roce.dev = dev;
3679 dev->port[i].roce.native_port_num = i + 1;
3680 dev->port[i].roce.last_port_state = IB_PORT_DOWN;
3681 }
3682
3683 err = mlx5r_cmd_query_special_mkeys(dev);
3684 if (err)
3685 return err;
3686
3673 err = mlx5_ib_init_multiport_master(dev);
3687 err = mlx5r_macsec_alloc_gids(dev);
3674 if (err)
3675 return err;
3676
3688 if (err)
3689 return err;
3690
3691 err = mlx5_ib_init_multiport_master(dev);
3692 if (err)
3693 goto err;
3694
3677 err = set_has_smi_cap(dev);
3678 if (err)
3679 goto err_mp;
3680
3681 err = mlx5_query_max_pkeys(&dev->ib_dev, &dev->pkey_table_len);
3682 if (err)
3683 goto err_mp;
3684
3685 if (mlx5_use_mad_ifc(dev))
3686 get_ext_port_caps(dev);
3687
3695 err = set_has_smi_cap(dev);
3696 if (err)
3697 goto err_mp;
3698
3699 err = mlx5_query_max_pkeys(&dev->ib_dev, &dev->pkey_table_len);
3700 if (err)
3701 goto err_mp;
3702
3703 if (mlx5_use_mad_ifc(dev))
3704 get_ext_port_caps(dev);
3705
3688 dev->ib_dev.num_comp_vectors = mlx5_comp_vectors_max(mdev);
3706 dev->ib_dev.num_comp_vectors = mlx5_comp_vectors_count(mdev);
3689
3690 mutex_init(&dev->cap_mask_mutex);
3691 INIT_LIST_HEAD(&dev->qp_list);
3692 spin_lock_init(&dev->reset_flow_resource_lock);
3693 xa_init(&dev->odp_mkeys);
3694 xa_init(&dev->sig_mrs);
3695 atomic_set(&dev->mkey_var, 0);
3696
3697 spin_lock_init(&dev->dm.lock);
3698 dev->dm.dev = mdev;
3699 return 0;
3707
3708 mutex_init(&dev->cap_mask_mutex);
3709 INIT_LIST_HEAD(&dev->qp_list);
3710 spin_lock_init(&dev->reset_flow_resource_lock);
3711 xa_init(&dev->odp_mkeys);
3712 xa_init(&dev->sig_mrs);
3713 atomic_set(&dev->mkey_var, 0);
3714
3715 spin_lock_init(&dev->dm.lock);
3716 dev->dm.dev = mdev;
3717 return 0;
3700
3718err:
3719 mlx5r_macsec_dealloc_gids(dev);
3701err_mp:
3702 mlx5_ib_cleanup_multiport_master(dev);
3703 return err;
3704}
3705
3706static int mlx5_ib_enable_driver(struct ib_device *dev)
3707{
3708 struct mlx5_ib_dev *mdev = to_mdev(dev);

--- 770 unchanged lines hidden ---
3720err_mp:
3721 mlx5_ib_cleanup_multiport_master(dev);
3722 return err;
3723}
3724
3725static int mlx5_ib_enable_driver(struct ib_device *dev)
3726{
3727 struct mlx5_ib_dev *mdev = to_mdev(dev);

--- 770 unchanged lines hidden ---