aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mlx5/main.c
diff options
context:
space:
mode:
authorAchiad Shochat <achiad@mellanox.com>2015-12-23 11:47:21 -0500
committerDoug Ledford <dledford@redhat.com>2015-12-23 12:07:37 -0500
commit3f89a643eb29543af0838d37604bbc29a4e1eb60 (patch)
tree4f4ae3c4ee32f022a78ee957b98bfdf2fda2655a /drivers/infiniband/hw/mlx5/main.c
parent9efa75254593d6ca3ae54bac8153f47e1a7cbcda (diff)
IB/mlx5: Extend query_device/port to support RoCE
Using the vport access functions to retrieve the Ethernet specific information and return this information in ib_query_device and ib_query_port. Signed-off-by: Achiad Shochat <achiad@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/hw/mlx5/main.c')
-rw-r--r--drivers/infiniband/hw/mlx5/main.c75
1 files changed, 69 insertions, 6 deletions
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 8c6e144ae75b..2b6ac2e7b4a0 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -40,6 +40,7 @@
40#include <linux/io-mapping.h> 40#include <linux/io-mapping.h>
41#include <linux/sched.h> 41#include <linux/sched.h>
42#include <rdma/ib_user_verbs.h> 42#include <rdma/ib_user_verbs.h>
43#include <rdma/ib_addr.h>
43#include <linux/mlx5/vport.h> 44#include <linux/mlx5/vport.h>
44#include <rdma/ib_smi.h> 45#include <rdma/ib_smi.h>
45#include <rdma/ib_umem.h> 46#include <rdma/ib_umem.h>
@@ -120,6 +121,50 @@ static struct net_device *mlx5_ib_get_netdev(struct ib_device *device,
120 return ndev; 121 return ndev;
121} 122}
122 123
124static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
125 struct ib_port_attr *props)
126{
127 struct mlx5_ib_dev *dev = to_mdev(device);
128 struct net_device *ndev;
129 enum ib_mtu ndev_ib_mtu;
130
131 memset(props, 0, sizeof(*props));
132
133 props->port_cap_flags |= IB_PORT_CM_SUP;
134 props->port_cap_flags |= IB_PORT_IP_BASED_GIDS;
135
136 props->gid_tbl_len = MLX5_CAP_ROCE(dev->mdev,
137 roce_address_table_size);
138 props->max_mtu = IB_MTU_4096;
139 props->max_msg_sz = 1 << MLX5_CAP_GEN(dev->mdev, log_max_msg);
140 props->pkey_tbl_len = 1;
141 props->state = IB_PORT_DOWN;
142 props->phys_state = 3;
143
144 mlx5_query_nic_vport_qkey_viol_cntr(dev->mdev,
145 (u16 *)&props->qkey_viol_cntr);
146
147 ndev = mlx5_ib_get_netdev(device, port_num);
148 if (!ndev)
149 return 0;
150
151 if (netif_running(ndev) && netif_carrier_ok(ndev)) {
152 props->state = IB_PORT_ACTIVE;
153 props->phys_state = 5;
154 }
155
156 ndev_ib_mtu = iboe_get_mtu(ndev->mtu);
157
158 dev_put(ndev);
159
160 props->active_mtu = min(props->max_mtu, ndev_ib_mtu);
161
162 props->active_width = IB_WIDTH_4X; /* TODO */
163 props->active_speed = IB_SPEED_QDR; /* TODO */
164
165 return 0;
166}
167
123static int mlx5_use_mad_ifc(struct mlx5_ib_dev *dev) 168static int mlx5_use_mad_ifc(struct mlx5_ib_dev *dev)
124{ 169{
125 return !dev->mdev->issi; 170 return !dev->mdev->issi;
@@ -158,13 +203,21 @@ static int mlx5_query_system_image_guid(struct ib_device *ibdev,
158 203
159 case MLX5_VPORT_ACCESS_METHOD_HCA: 204 case MLX5_VPORT_ACCESS_METHOD_HCA:
160 err = mlx5_query_hca_vport_system_image_guid(mdev, &tmp); 205 err = mlx5_query_hca_vport_system_image_guid(mdev, &tmp);
161 if (!err) 206 break;
162 *sys_image_guid = cpu_to_be64(tmp); 207
163 return err; 208 case MLX5_VPORT_ACCESS_METHOD_NIC:
209 err = mlx5_query_nic_vport_system_image_guid(mdev, &tmp);
210 break;
164 211
165 default: 212 default:
166 return -EINVAL; 213 return -EINVAL;
167 } 214 }
215
216 if (!err)
217 *sys_image_guid = cpu_to_be64(tmp);
218
219 return err;
220
168} 221}
169 222
170static int mlx5_query_max_pkeys(struct ib_device *ibdev, 223static int mlx5_query_max_pkeys(struct ib_device *ibdev,
@@ -218,13 +271,20 @@ static int mlx5_query_node_guid(struct mlx5_ib_dev *dev,
218 271
219 case MLX5_VPORT_ACCESS_METHOD_HCA: 272 case MLX5_VPORT_ACCESS_METHOD_HCA:
220 err = mlx5_query_hca_vport_node_guid(dev->mdev, &tmp); 273 err = mlx5_query_hca_vport_node_guid(dev->mdev, &tmp);
221 if (!err) 274 break;
222 *node_guid = cpu_to_be64(tmp); 275
223 return err; 276 case MLX5_VPORT_ACCESS_METHOD_NIC:
277 err = mlx5_query_nic_vport_node_guid(dev->mdev, &tmp);
278 break;
224 279
225 default: 280 default:
226 return -EINVAL; 281 return -EINVAL;
227 } 282 }
283
284 if (!err)
285 *node_guid = cpu_to_be64(tmp);
286
287 return err;
228} 288}
229 289
230struct mlx5_reg_node_desc { 290struct mlx5_reg_node_desc {
@@ -522,6 +582,9 @@ int mlx5_ib_query_port(struct ib_device *ibdev, u8 port,
522 case MLX5_VPORT_ACCESS_METHOD_HCA: 582 case MLX5_VPORT_ACCESS_METHOD_HCA:
523 return mlx5_query_hca_port(ibdev, port, props); 583 return mlx5_query_hca_port(ibdev, port, props);
524 584
585 case MLX5_VPORT_ACCESS_METHOD_NIC:
586 return mlx5_query_port_roce(ibdev, port, props);
587
525 default: 588 default:
526 return -EINVAL; 589 return -EINVAL;
527 } 590 }