diff options
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/main.c | 7 | ||||
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/port.c | 35 | ||||
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 23 |
3 files changed, 47 insertions, 18 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index cef267e24f9c..7cf9dadcb471 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c | |||
| @@ -754,10 +754,10 @@ static void mlx4_request_modules(struct mlx4_dev *dev) | |||
| 754 | has_eth_port = true; | 754 | has_eth_port = true; |
| 755 | } | 755 | } |
| 756 | 756 | ||
| 757 | if (has_ib_port || (dev->caps.flags & MLX4_DEV_CAP_FLAG_IBOE)) | ||
| 758 | request_module_nowait(IB_DRV_NAME); | ||
| 759 | if (has_eth_port) | 757 | if (has_eth_port) |
| 760 | request_module_nowait(EN_DRV_NAME); | 758 | request_module_nowait(EN_DRV_NAME); |
| 759 | if (has_ib_port || (dev->caps.flags & MLX4_DEV_CAP_FLAG_IBOE)) | ||
| 760 | request_module_nowait(IB_DRV_NAME); | ||
| 761 | } | 761 | } |
| 762 | 762 | ||
| 763 | /* | 763 | /* |
| @@ -2440,7 +2440,8 @@ slave_start: | |||
| 2440 | * No return code for this call, just warn the user in case of PCI | 2440 | * No return code for this call, just warn the user in case of PCI |
| 2441 | * express device capabilities are under-satisfied by the bus. | 2441 | * express device capabilities are under-satisfied by the bus. |
| 2442 | */ | 2442 | */ |
| 2443 | mlx4_check_pcie_caps(dev); | 2443 | if (!mlx4_is_slave(dev)) |
| 2444 | mlx4_check_pcie_caps(dev); | ||
| 2444 | 2445 | ||
| 2445 | /* In master functions, the communication channel must be initialized | 2446 | /* In master functions, the communication channel must be initialized |
| 2446 | * after obtaining its address from fw */ | 2447 | * after obtaining its address from fw */ |
diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c index cfcad26ed40f..b5b3549b0c8d 100644 --- a/drivers/net/ethernet/mellanox/mlx4/port.c +++ b/drivers/net/ethernet/mellanox/mlx4/port.c | |||
| @@ -1106,6 +1106,9 @@ int mlx4_get_slave_from_roce_gid(struct mlx4_dev *dev, int port, u8 *gid, | |||
| 1106 | } | 1106 | } |
| 1107 | 1107 | ||
| 1108 | if (found_ix >= 0) { | 1108 | if (found_ix >= 0) { |
| 1109 | /* Calculate a slave_gid which is the slave number in the gid | ||
| 1110 | * table and not a globally unique slave number. | ||
| 1111 | */ | ||
| 1109 | if (found_ix < MLX4_ROCE_PF_GIDS) | 1112 | if (found_ix < MLX4_ROCE_PF_GIDS) |
| 1110 | slave_gid = 0; | 1113 | slave_gid = 0; |
| 1111 | else if (found_ix < MLX4_ROCE_PF_GIDS + (vf_gids % num_vfs) * | 1114 | else if (found_ix < MLX4_ROCE_PF_GIDS + (vf_gids % num_vfs) * |
| @@ -1118,41 +1121,43 @@ int mlx4_get_slave_from_roce_gid(struct mlx4_dev *dev, int port, u8 *gid, | |||
| 1118 | ((vf_gids % num_vfs) * ((vf_gids / num_vfs + 1)))) / | 1121 | ((vf_gids % num_vfs) * ((vf_gids / num_vfs + 1)))) / |
| 1119 | (vf_gids / num_vfs)) + vf_gids % num_vfs + 1; | 1122 | (vf_gids / num_vfs)) + vf_gids % num_vfs + 1; |
| 1120 | 1123 | ||
| 1124 | /* Calculate the globally unique slave id */ | ||
| 1121 | if (slave_gid) { | 1125 | if (slave_gid) { |
| 1122 | struct mlx4_active_ports exclusive_ports; | 1126 | struct mlx4_active_ports exclusive_ports; |
| 1123 | struct mlx4_active_ports actv_ports; | 1127 | struct mlx4_active_ports actv_ports; |
| 1124 | struct mlx4_slaves_pport slaves_pport_actv; | 1128 | struct mlx4_slaves_pport slaves_pport_actv; |
| 1125 | unsigned max_port_p_one; | 1129 | unsigned max_port_p_one; |
| 1126 | int num_slaves_before = 1; | 1130 | int num_vfs_before = 0; |
| 1131 | int candidate_slave_gid; | ||
| 1127 | 1132 | ||
| 1133 | /* Calculate how many VFs are on the previous port, if exists */ | ||
| 1128 | for (i = 1; i < port; i++) { | 1134 | for (i = 1; i < port; i++) { |
| 1129 | bitmap_zero(exclusive_ports.ports, dev->caps.num_ports); | 1135 | bitmap_zero(exclusive_ports.ports, dev->caps.num_ports); |
| 1130 | set_bit(i, exclusive_ports.ports); | 1136 | set_bit(i - 1, exclusive_ports.ports); |
| 1131 | slaves_pport_actv = | 1137 | slaves_pport_actv = |
| 1132 | mlx4_phys_to_slaves_pport_actv( | 1138 | mlx4_phys_to_slaves_pport_actv( |
| 1133 | dev, &exclusive_ports); | 1139 | dev, &exclusive_ports); |
| 1134 | num_slaves_before += bitmap_weight( | 1140 | num_vfs_before += bitmap_weight( |
| 1135 | slaves_pport_actv.slaves, | 1141 | slaves_pport_actv.slaves, |
| 1136 | dev->num_vfs + 1); | 1142 | dev->num_vfs + 1); |
| 1137 | } | 1143 | } |
| 1138 | 1144 | ||
| 1139 | if (slave_gid < num_slaves_before) { | 1145 | /* candidate_slave_gid isn't necessarily the correct slave, but |
| 1140 | bitmap_zero(exclusive_ports.ports, dev->caps.num_ports); | 1146 | * it has the same number of ports and is assigned to the same |
| 1141 | set_bit(port - 1, exclusive_ports.ports); | 1147 | * ports as the real slave we're looking for. On dual port VF, |
| 1142 | slaves_pport_actv = | 1148 | * slave_gid = [single port VFs on port <port>] + |
| 1143 | mlx4_phys_to_slaves_pport_actv( | 1149 | * [offset of the current slave from the first dual port VF] + |
| 1144 | dev, &exclusive_ports); | 1150 | * 1 (for the PF). |
| 1145 | slave_gid += bitmap_weight( | 1151 | */ |
| 1146 | slaves_pport_actv.slaves, | 1152 | candidate_slave_gid = slave_gid + num_vfs_before; |
| 1147 | dev->num_vfs + 1) - | 1153 | |
| 1148 | num_slaves_before; | 1154 | actv_ports = mlx4_get_active_ports(dev, candidate_slave_gid); |
| 1149 | } | ||
| 1150 | actv_ports = mlx4_get_active_ports(dev, slave_gid); | ||
| 1151 | max_port_p_one = find_first_bit( | 1155 | max_port_p_one = find_first_bit( |
| 1152 | actv_ports.ports, dev->caps.num_ports) + | 1156 | actv_ports.ports, dev->caps.num_ports) + |
| 1153 | bitmap_weight(actv_ports.ports, | 1157 | bitmap_weight(actv_ports.ports, |
| 1154 | dev->caps.num_ports) + 1; | 1158 | dev->caps.num_ports) + 1; |
| 1155 | 1159 | ||
| 1160 | /* Calculate the real slave number */ | ||
| 1156 | for (i = 1; i < max_port_p_one; i++) { | 1161 | for (i = 1; i < max_port_p_one; i++) { |
| 1157 | if (i == port) | 1162 | if (i == port) |
| 1158 | continue; | 1163 | continue; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c index 3b5f53ef29b2..1c3fdd4a1f7d 100644 --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | |||
| @@ -3733,6 +3733,25 @@ static int qp_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, | |||
| 3733 | } | 3733 | } |
| 3734 | } | 3734 | } |
| 3735 | 3735 | ||
| 3736 | static int mlx4_adjust_port(struct mlx4_dev *dev, int slave, | ||
| 3737 | u8 *gid, enum mlx4_protocol prot) | ||
| 3738 | { | ||
| 3739 | int real_port; | ||
| 3740 | |||
| 3741 | if (prot != MLX4_PROT_ETH) | ||
| 3742 | return 0; | ||
| 3743 | |||
| 3744 | if (dev->caps.steering_mode == MLX4_STEERING_MODE_B0 || | ||
| 3745 | dev->caps.steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED) { | ||
| 3746 | real_port = mlx4_slave_convert_port(dev, slave, gid[5]); | ||
| 3747 | if (real_port < 0) | ||
| 3748 | return -EINVAL; | ||
| 3749 | gid[5] = real_port; | ||
| 3750 | } | ||
| 3751 | |||
| 3752 | return 0; | ||
| 3753 | } | ||
| 3754 | |||
| 3736 | int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, | 3755 | int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, |
| 3737 | struct mlx4_vhcr *vhcr, | 3756 | struct mlx4_vhcr *vhcr, |
| 3738 | struct mlx4_cmd_mailbox *inbox, | 3757 | struct mlx4_cmd_mailbox *inbox, |
| @@ -3768,6 +3787,10 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, | |||
| 3768 | if (err) | 3787 | if (err) |
| 3769 | goto ex_detach; | 3788 | goto ex_detach; |
| 3770 | } else { | 3789 | } else { |
| 3790 | err = mlx4_adjust_port(dev, slave, gid, prot); | ||
| 3791 | if (err) | ||
| 3792 | goto ex_put; | ||
| 3793 | |||
| 3771 | err = rem_mcg_res(dev, slave, rqp, gid, prot, type, ®_id); | 3794 | err = rem_mcg_res(dev, slave, rqp, gid, prot, type, ®_id); |
| 3772 | if (err) | 3795 | if (err) |
| 3773 | goto ex_put; | 3796 | goto ex_put; |
