Commit 95579e78 authored by Mark Bloch's avatar Mark Bloch Committed by Jason Gunthorpe

RDMA/mlx5: Move netdev info into the port struct

Netdev info is stored in a separate array and holds data relevant on a per
port basis, move it to be part of the port struct.
Signed-off-by: default avatarMark Bloch <markb@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 5331fa0d
...@@ -257,11 +257,11 @@ static struct net_device *mlx5_ib_get_netdev(struct ib_device *device, ...@@ -257,11 +257,11 @@ static struct net_device *mlx5_ib_get_netdev(struct ib_device *device,
/* Ensure ndev does not disappear before we invoke dev_hold() /* Ensure ndev does not disappear before we invoke dev_hold()
*/ */
read_lock(&ibdev->roce[port_num - 1].netdev_lock); read_lock(&ibdev->port[port_num - 1].roce.netdev_lock);
ndev = ibdev->roce[port_num - 1].netdev; ndev = ibdev->port[port_num - 1].roce.netdev;
if (ndev) if (ndev)
dev_hold(ndev); dev_hold(ndev);
read_unlock(&ibdev->roce[port_num - 1].netdev_lock); read_unlock(&ibdev->port[port_num - 1].roce.netdev_lock);
out: out:
mlx5_ib_put_native_port_mdev(ibdev, port_num); mlx5_ib_put_native_port_mdev(ibdev, port_num);
...@@ -1952,11 +1952,11 @@ static int mlx5_ib_alloc_ucontext(struct ib_ucontext *uctx, ...@@ -1952,11 +1952,11 @@ static int mlx5_ib_alloc_ucontext(struct ib_ucontext *uctx,
print_lib_caps(dev, context->lib_caps); print_lib_caps(dev, context->lib_caps);
if (dev->lag_active) { if (dev->lag_active) {
u8 port = mlx5_core_native_port_num(dev->mdev); u8 port = mlx5_core_native_port_num(dev->mdev) - 1;
atomic_set(&context->tx_port_affinity, atomic_set(&context->tx_port_affinity,
atomic_add_return( atomic_add_return(
1, &dev->roce[port].tx_port_affinity)); 1, &dev->port[port].roce.tx_port_affinity));
} }
return 0; return 0;
...@@ -5024,10 +5024,10 @@ static int mlx5_add_netdev_notifier(struct mlx5_ib_dev *dev, u8 port_num) ...@@ -5024,10 +5024,10 @@ static int mlx5_add_netdev_notifier(struct mlx5_ib_dev *dev, u8 port_num)
{ {
int err; int err;
dev->roce[port_num].nb.notifier_call = mlx5_netdev_event; dev->port[port_num].roce.nb.notifier_call = mlx5_netdev_event;
err = register_netdevice_notifier(&dev->roce[port_num].nb); err = register_netdevice_notifier(&dev->port[port_num].roce.nb);
if (err) { if (err) {
dev->roce[port_num].nb.notifier_call = NULL; dev->port[port_num].roce.nb.notifier_call = NULL;
return err; return err;
} }
...@@ -5036,9 +5036,9 @@ static int mlx5_add_netdev_notifier(struct mlx5_ib_dev *dev, u8 port_num) ...@@ -5036,9 +5036,9 @@ static int mlx5_add_netdev_notifier(struct mlx5_ib_dev *dev, u8 port_num)
static void mlx5_remove_netdev_notifier(struct mlx5_ib_dev *dev, u8 port_num) static void mlx5_remove_netdev_notifier(struct mlx5_ib_dev *dev, u8 port_num)
{ {
if (dev->roce[port_num].nb.notifier_call) { if (dev->port[port_num].roce.nb.notifier_call) {
unregister_netdevice_notifier(&dev->roce[port_num].nb); unregister_netdevice_notifier(&dev->port[port_num].roce.nb);
dev->roce[port_num].nb.notifier_call = NULL; dev->port[port_num].roce.nb.notifier_call = NULL;
} }
} }
...@@ -5587,7 +5587,7 @@ static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev, ...@@ -5587,7 +5587,7 @@ static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev,
mlx5_ib_err(ibdev, "Failed to unaffiliate port %u\n", mlx5_ib_err(ibdev, "Failed to unaffiliate port %u\n",
port_num + 1); port_num + 1);
ibdev->roce[port_num].last_port_state = IB_PORT_DOWN; ibdev->port[port_num].roce.last_port_state = IB_PORT_DOWN;
} }
/* The mlx5_ib_multiport_mutex should be held when calling this function */ /* The mlx5_ib_multiport_mutex should be held when calling this function */
...@@ -5860,7 +5860,7 @@ int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev) ...@@ -5860,7 +5860,7 @@ int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
for (i = 0; i < dev->num_ports; i++) { for (i = 0; i < dev->num_ports; i++) {
spin_lock_init(&dev->port[i].mp.mpi_lock); spin_lock_init(&dev->port[i].mp.mpi_lock);
rwlock_init(&dev->roce[i].netdev_lock); rwlock_init(&dev->port[i].roce.netdev_lock);
} }
err = mlx5_ib_init_multiport_master(dev); err = mlx5_ib_init_multiport_master(dev);
...@@ -6163,9 +6163,9 @@ static int mlx5_ib_stage_common_roce_init(struct mlx5_ib_dev *dev) ...@@ -6163,9 +6163,9 @@ static int mlx5_ib_stage_common_roce_init(struct mlx5_ib_dev *dev)
int i; int i;
for (i = 0; i < dev->num_ports; i++) { for (i = 0; i < dev->num_ports; i++) {
dev->roce[i].dev = dev; dev->port[i].roce.dev = dev;
dev->roce[i].native_port_num = i + 1; dev->port[i].roce.native_port_num = i + 1;
dev->roce[i].last_port_state = IB_PORT_DOWN; dev->port[i].roce.last_port_state = IB_PORT_DOWN;
} }
dev->ib_dev.uverbs_ex_cmd_mask |= dev->ib_dev.uverbs_ex_cmd_mask |=
......
...@@ -702,12 +702,6 @@ struct mlx5_ib_multiport { ...@@ -702,12 +702,6 @@ struct mlx5_ib_multiport {
spinlock_t mpi_lock; spinlock_t mpi_lock;
}; };
struct mlx5_ib_port {
struct mlx5_ib_counters cnts;
struct mlx5_ib_multiport mp;
struct mlx5_ib_dbg_cc_params *dbg_cc_params;
};
struct mlx5_roce { struct mlx5_roce {
/* Protect mlx5_ib_get_netdev from invoking dev_hold() with a NULL /* Protect mlx5_ib_get_netdev from invoking dev_hold() with a NULL
* netdev pointer * netdev pointer
...@@ -721,6 +715,13 @@ struct mlx5_roce { ...@@ -721,6 +715,13 @@ struct mlx5_roce {
u8 native_port_num; u8 native_port_num;
}; };
struct mlx5_ib_port {
struct mlx5_ib_counters cnts;
struct mlx5_ib_multiport mp;
struct mlx5_ib_dbg_cc_params *dbg_cc_params;
struct mlx5_roce roce;
};
struct mlx5_ib_dbg_param { struct mlx5_ib_dbg_param {
int offset; int offset;
struct mlx5_ib_dev *dev; struct mlx5_ib_dev *dev;
...@@ -905,7 +906,6 @@ struct mlx5_ib_dev { ...@@ -905,7 +906,6 @@ struct mlx5_ib_dev {
struct ib_device ib_dev; struct ib_device ib_dev;
struct mlx5_core_dev *mdev; struct mlx5_core_dev *mdev;
struct notifier_block mdev_events; struct notifier_block mdev_events;
struct mlx5_roce roce[MLX5_MAX_PORTS];
int num_ports; int num_ports;
/* serialize update of capability mask /* serialize update of capability mask
*/ */
......
...@@ -3303,7 +3303,7 @@ static unsigned int get_tx_affinity(struct mlx5_ib_dev *dev, ...@@ -3303,7 +3303,7 @@ static unsigned int get_tx_affinity(struct mlx5_ib_dev *dev,
} else { } else {
tx_port_affinity = tx_port_affinity =
(unsigned int)atomic_add_return( (unsigned int)atomic_add_return(
1, &dev->roce[port_num].tx_port_affinity) % 1, &dev->port[port_num].roce.tx_port_affinity) %
MLX5_MAX_PORTS + MLX5_MAX_PORTS +
1; 1;
mlx5_ib_dbg(dev, "Set tx affinity 0x%x to qpn 0x%x\n", mlx5_ib_dbg(dev, "Set tx affinity 0x%x to qpn 0x%x\n",
...@@ -3408,7 +3408,7 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp, ...@@ -3408,7 +3408,7 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
(ibqp->qp_type == IB_QPT_XRC_INI) || (ibqp->qp_type == IB_QPT_XRC_INI) ||
(ibqp->qp_type == IB_QPT_XRC_TGT)) { (ibqp->qp_type == IB_QPT_XRC_TGT)) {
if (dev->lag_active) { if (dev->lag_active) {
u8 p = mlx5_core_native_port_num(dev->mdev); u8 p = mlx5_core_native_port_num(dev->mdev) - 1;
tx_affinity = get_tx_affinity(dev, pd, base, p, tx_affinity = get_tx_affinity(dev, pd, base, p,
udata); udata);
context->flags |= cpu_to_be32(tx_affinity << 24); context->flags |= cpu_to_be32(tx_affinity << 24);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment