aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw
diff options
context:
space:
mode:
authorRoland Dreier <roland@purestorage.com>2014-01-23 02:24:21 -0500
committerRoland Dreier <roland@purestorage.com>2014-01-23 02:24:21 -0500
commitfb1b5034e4987b158179a62732fb6dfb8f7ec88e (patch)
tree93d02ff7f0f530286fd54d03b632c6eaabc9dcc9 /drivers/infiniband/hw
parent8f399921ea9a562bc8221258c4b8a7bd69577939 (diff)
parent27cdef637c25705b433d5c4deeef4cf8dcb75d6a (diff)
Merge branch 'ip-roce' into for-next
Conflicts: drivers/infiniband/hw/mlx4/main.c
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_qp.c2
-rw-r--r--drivers/infiniband/hw/mlx4/Kconfig2
-rw-r--r--drivers/infiniband/hw/mlx4/ah.c40
-rw-r--r--drivers/infiniband/hw/mlx4/cq.c9
-rw-r--r--drivers/infiniband/hw/mlx4/main.c475
-rw-r--r--drivers/infiniband/hw/mlx4/mlx4_ib.h6
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c104
-rw-r--r--drivers/infiniband/hw/mlx5/qp.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c3
-rw-r--r--drivers/infiniband/hw/ocrdma/Kconfig2
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma.h12
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_ah.c5
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_hw.c21
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_hw.h1
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_main.c138
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_verbs.c3
-rw-r--r--drivers/infiniband/hw/qib/qib_qp.c2
18 files changed, 504 insertions, 326 deletions
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index 00d6861a6a18..2e89356c46fa 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -1329,7 +1329,7 @@ static int internal_modify_qp(struct ib_qp *ibqp,
1329 qp_new_state = attr_mask & IB_QP_STATE ? attr->qp_state : qp_cur_state; 1329 qp_new_state = attr_mask & IB_QP_STATE ? attr->qp_state : qp_cur_state;
1330 if (!smi_reset2init && 1330 if (!smi_reset2init &&
1331 !ib_modify_qp_is_ok(qp_cur_state, qp_new_state, ibqp->qp_type, 1331 !ib_modify_qp_is_ok(qp_cur_state, qp_new_state, ibqp->qp_type,
1332 attr_mask)) { 1332 attr_mask, IB_LINK_LAYER_UNSPECIFIED)) {
1333 ret = -EINVAL; 1333 ret = -EINVAL;
1334 ehca_err(ibqp->device, 1334 ehca_err(ibqp->device,
1335 "Invalid qp transition new_state=%x cur_state=%x " 1335 "Invalid qp transition new_state=%x cur_state=%x "
diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c
index 0857a9c3cd3d..face87602dc1 100644
--- a/drivers/infiniband/hw/ipath/ipath_qp.c
+++ b/drivers/infiniband/hw/ipath/ipath_qp.c
@@ -463,7 +463,7 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
463 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state; 463 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
464 464
465 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, 465 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type,
466 attr_mask)) 466 attr_mask, IB_LINK_LAYER_UNSPECIFIED))
467 goto inval; 467 goto inval;
468 468
469 if (attr_mask & IB_QP_AV) { 469 if (attr_mask & IB_QP_AV) {
diff --git a/drivers/infiniband/hw/mlx4/Kconfig b/drivers/infiniband/hw/mlx4/Kconfig
index 24ab11a9ad1e..fc01deac1d3c 100644
--- a/drivers/infiniband/hw/mlx4/Kconfig
+++ b/drivers/infiniband/hw/mlx4/Kconfig
@@ -1,6 +1,6 @@
1config MLX4_INFINIBAND 1config MLX4_INFINIBAND
2 tristate "Mellanox ConnectX HCA support" 2 tristate "Mellanox ConnectX HCA support"
3 depends on NETDEVICES && ETHERNET && PCI 3 depends on NETDEVICES && ETHERNET && PCI && INET
4 select NET_VENDOR_MELLANOX 4 select NET_VENDOR_MELLANOX
5 select MLX4_CORE 5 select MLX4_CORE
6 ---help--- 6 ---help---
diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
index a251becdaa98..170dca608042 100644
--- a/drivers/infiniband/hw/mlx4/ah.c
+++ b/drivers/infiniband/hw/mlx4/ah.c
@@ -39,25 +39,6 @@
39 39
40#include "mlx4_ib.h" 40#include "mlx4_ib.h"
41 41
42int mlx4_ib_resolve_grh(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah_attr,
43 u8 *mac, int *is_mcast, u8 port)
44{
45 struct in6_addr in6;
46
47 *is_mcast = 0;
48
49 memcpy(&in6, ah_attr->grh.dgid.raw, sizeof in6);
50 if (rdma_link_local_addr(&in6))
51 rdma_get_ll_mac(&in6, mac);
52 else if (rdma_is_multicast_addr(&in6)) {
53 rdma_get_mcast_mac(&in6, mac);
54 *is_mcast = 1;
55 } else
56 return -EINVAL;
57
58 return 0;
59}
60
61static struct ib_ah *create_ib_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr, 42static struct ib_ah *create_ib_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr,
62 struct mlx4_ib_ah *ah) 43 struct mlx4_ib_ah *ah)
63{ 44{
@@ -92,21 +73,18 @@ static struct ib_ah *create_iboe_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr
92{ 73{
93 struct mlx4_ib_dev *ibdev = to_mdev(pd->device); 74 struct mlx4_ib_dev *ibdev = to_mdev(pd->device);
94 struct mlx4_dev *dev = ibdev->dev; 75 struct mlx4_dev *dev = ibdev->dev;
95 union ib_gid sgid;
96 u8 mac[6];
97 int err;
98 int is_mcast; 76 int is_mcast;
77 struct in6_addr in6;
99 u16 vlan_tag; 78 u16 vlan_tag;
100 79
101 err = mlx4_ib_resolve_grh(ibdev, ah_attr, mac, &is_mcast, ah_attr->port_num); 80 memcpy(&in6, ah_attr->grh.dgid.raw, sizeof(in6));
102 if (err) 81 if (rdma_is_multicast_addr(&in6)) {
103 return ERR_PTR(err); 82 is_mcast = 1;
104 83 rdma_get_mcast_mac(&in6, ah->av.eth.mac);
105 memcpy(ah->av.eth.mac, mac, 6); 84 } else {
106 err = ib_get_cached_gid(pd->device, ah_attr->port_num, ah_attr->grh.sgid_index, &sgid); 85 memcpy(ah->av.eth.mac, ah_attr->dmac, ETH_ALEN);
107 if (err) 86 }
108 return ERR_PTR(err); 87 vlan_tag = ah_attr->vlan_id;
109 vlan_tag = rdma_get_vlan_id(&sgid);
110 if (vlan_tag < 0x1000) 88 if (vlan_tag < 0x1000)
111 vlan_tag |= (ah_attr->sl & 7) << 13; 89 vlan_tag |= (ah_attr->sl & 7) << 13;
112 ah->av.eth.port_pd = cpu_to_be32(to_mpd(pd)->pdn | (ah_attr->port_num << 24)); 90 ah->av.eth.port_pd = cpu_to_be32(to_mpd(pd)->pdn | (ah_attr->port_num << 24));
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index 66dbf8062374..cc40f08ca8f1 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -798,6 +798,15 @@ repoll:
798 wc->sl = be16_to_cpu(cqe->sl_vid) >> 13; 798 wc->sl = be16_to_cpu(cqe->sl_vid) >> 13;
799 else 799 else
800 wc->sl = be16_to_cpu(cqe->sl_vid) >> 12; 800 wc->sl = be16_to_cpu(cqe->sl_vid) >> 12;
801 if (be32_to_cpu(cqe->vlan_my_qpn) & MLX4_CQE_VLAN_PRESENT_MASK) {
802 wc->vlan_id = be16_to_cpu(cqe->sl_vid) &
803 MLX4_CQE_VID_MASK;
804 } else {
805 wc->vlan_id = 0xffff;
806 }
807 wc->wc_flags |= IB_WC_WITH_VLAN;
808 memcpy(wc->smac, cqe->smac, ETH_ALEN);
809 wc->wc_flags |= IB_WC_WITH_SMAC;
801 } 810 }
802 811
803 return 0; 812 return 0;
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index ea5844e89b2a..c2702f549f10 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -39,6 +39,8 @@
39#include <linux/inetdevice.h> 39#include <linux/inetdevice.h>
40#include <linux/rtnetlink.h> 40#include <linux/rtnetlink.h>
41#include <linux/if_vlan.h> 41#include <linux/if_vlan.h>
42#include <net/ipv6.h>
43#include <net/addrconf.h>
42 44
43#include <rdma/ib_smi.h> 45#include <rdma/ib_smi.h>
44#include <rdma/ib_user_verbs.h> 46#include <rdma/ib_user_verbs.h>
@@ -794,7 +796,6 @@ static int add_gid_entry(struct ib_qp *ibqp, union ib_gid *gid)
794int mlx4_ib_add_mc(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp, 796int mlx4_ib_add_mc(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
795 union ib_gid *gid) 797 union ib_gid *gid)
796{ 798{
797 u8 mac[6];
798 struct net_device *ndev; 799 struct net_device *ndev;
799 int ret = 0; 800 int ret = 0;
800 801
@@ -808,11 +809,7 @@ int mlx4_ib_add_mc(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
808 spin_unlock(&mdev->iboe.lock); 809 spin_unlock(&mdev->iboe.lock);
809 810
810 if (ndev) { 811 if (ndev) {
811 rdma_get_mcast_mac((struct in6_addr *)gid, mac);
812 rtnl_lock();
813 dev_mc_add(mdev->iboe.netdevs[mqp->port - 1], mac);
814 ret = 1; 812 ret = 1;
815 rtnl_unlock();
816 dev_put(ndev); 813 dev_put(ndev);
817 } 814 }
818 815
@@ -1164,6 +1161,8 @@ static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
1164 struct mlx4_ib_qp *mqp = to_mqp(ibqp); 1161 struct mlx4_ib_qp *mqp = to_mqp(ibqp);
1165 u64 reg_id; 1162 u64 reg_id;
1166 struct mlx4_ib_steering *ib_steering = NULL; 1163 struct mlx4_ib_steering *ib_steering = NULL;
1164 enum mlx4_protocol prot = (gid->raw[1] == 0x0e) ?
1165 MLX4_PROT_IB_IPV4 : MLX4_PROT_IB_IPV6;
1167 1166
1168 if (mdev->dev->caps.steering_mode == 1167 if (mdev->dev->caps.steering_mode ==
1169 MLX4_STEERING_MODE_DEVICE_MANAGED) { 1168 MLX4_STEERING_MODE_DEVICE_MANAGED) {
@@ -1175,7 +1174,7 @@ static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
1175 err = mlx4_multicast_attach(mdev->dev, &mqp->mqp, gid->raw, mqp->port, 1174 err = mlx4_multicast_attach(mdev->dev, &mqp->mqp, gid->raw, mqp->port,
1176 !!(mqp->flags & 1175 !!(mqp->flags &
1177 MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK), 1176 MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK),
1178 MLX4_PROT_IB_IPV6, &reg_id); 1177 prot, &reg_id);
1179 if (err) 1178 if (err)
1180 goto err_malloc; 1179 goto err_malloc;
1181 1180
@@ -1194,7 +1193,7 @@ static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
1194 1193
1195err_add: 1194err_add:
1196 mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw, 1195 mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw,
1197 MLX4_PROT_IB_IPV6, reg_id); 1196 prot, reg_id);
1198err_malloc: 1197err_malloc:
1199 kfree(ib_steering); 1198 kfree(ib_steering);
1200 1199
@@ -1222,10 +1221,11 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
1222 int err; 1221 int err;
1223 struct mlx4_ib_dev *mdev = to_mdev(ibqp->device); 1222 struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
1224 struct mlx4_ib_qp *mqp = to_mqp(ibqp); 1223 struct mlx4_ib_qp *mqp = to_mqp(ibqp);
1225 u8 mac[6];
1226 struct net_device *ndev; 1224 struct net_device *ndev;
1227 struct mlx4_ib_gid_entry *ge; 1225 struct mlx4_ib_gid_entry *ge;
1228 u64 reg_id = 0; 1226 u64 reg_id = 0;
1227 enum mlx4_protocol prot = (gid->raw[1] == 0x0e) ?
1228 MLX4_PROT_IB_IPV4 : MLX4_PROT_IB_IPV6;
1229 1229
1230 if (mdev->dev->caps.steering_mode == 1230 if (mdev->dev->caps.steering_mode ==
1231 MLX4_STEERING_MODE_DEVICE_MANAGED) { 1231 MLX4_STEERING_MODE_DEVICE_MANAGED) {
@@ -1248,7 +1248,7 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
1248 } 1248 }
1249 1249
1250 err = mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw, 1250 err = mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw,
1251 MLX4_PROT_IB_IPV6, reg_id); 1251 prot, reg_id);
1252 if (err) 1252 if (err)
1253 return err; 1253 return err;
1254 1254
@@ -1260,13 +1260,8 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
1260 if (ndev) 1260 if (ndev)
1261 dev_hold(ndev); 1261 dev_hold(ndev);
1262 spin_unlock(&mdev->iboe.lock); 1262 spin_unlock(&mdev->iboe.lock);
1263 rdma_get_mcast_mac((struct in6_addr *)gid, mac); 1263 if (ndev)
1264 if (ndev) {
1265 rtnl_lock();
1266 dev_mc_del(mdev->iboe.netdevs[ge->port - 1], mac);
1267 rtnl_unlock();
1268 dev_put(ndev); 1264 dev_put(ndev);
1269 }
1270 list_del(&ge->list); 1265 list_del(&ge->list);
1271 kfree(ge); 1266 kfree(ge);
1272 } else 1267 } else
@@ -1362,20 +1357,6 @@ static struct device_attribute *mlx4_class_attributes[] = {
1362 &dev_attr_board_id 1357 &dev_attr_board_id
1363}; 1358};
1364 1359
1365static void mlx4_addrconf_ifid_eui48(u8 *eui, u16 vlan_id, struct net_device *dev)
1366{
1367 memcpy(eui, dev->dev_addr, 3);
1368 memcpy(eui + 5, dev->dev_addr + 3, 3);
1369 if (vlan_id < 0x1000) {
1370 eui[3] = vlan_id >> 8;
1371 eui[4] = vlan_id & 0xff;
1372 } else {
1373 eui[3] = 0xff;
1374 eui[4] = 0xfe;
1375 }
1376 eui[0] ^= 2;
1377}
1378
1379static void update_gids_task(struct work_struct *work) 1360static void update_gids_task(struct work_struct *work)
1380{ 1361{
1381 struct update_gid_work *gw = container_of(work, struct update_gid_work, work); 1362 struct update_gid_work *gw = container_of(work, struct update_gid_work, work);
@@ -1398,161 +1379,318 @@ static void update_gids_task(struct work_struct *work)
1398 MLX4_CMD_WRAPPED); 1379 MLX4_CMD_WRAPPED);
1399 if (err) 1380 if (err)
1400 pr_warn("set port command failed\n"); 1381 pr_warn("set port command failed\n");
1401 else { 1382 else
1402 memcpy(gw->dev->iboe.gid_table[gw->port - 1], gw->gids, sizeof gw->gids);
1403 mlx4_ib_dispatch_event(gw->dev, gw->port, IB_EVENT_GID_CHANGE); 1383 mlx4_ib_dispatch_event(gw->dev, gw->port, IB_EVENT_GID_CHANGE);
1404 }
1405 1384
1406 mlx4_free_cmd_mailbox(dev, mailbox); 1385 mlx4_free_cmd_mailbox(dev, mailbox);
1407 kfree(gw); 1386 kfree(gw);
1408} 1387}
1409 1388
1410static int update_ipv6_gids(struct mlx4_ib_dev *dev, int port, int clear) 1389static void reset_gids_task(struct work_struct *work)
1411{ 1390{
1412 struct net_device *ndev = dev->iboe.netdevs[port - 1]; 1391 struct update_gid_work *gw =
1413 struct update_gid_work *work; 1392 container_of(work, struct update_gid_work, work);
1414 struct net_device *tmp; 1393 struct mlx4_cmd_mailbox *mailbox;
1394 union ib_gid *gids;
1395 int err;
1415 int i; 1396 int i;
1416 u8 *hits; 1397 struct mlx4_dev *dev = gw->dev->dev;
1417 int ret;
1418 union ib_gid gid;
1419 int free;
1420 int found;
1421 int need_update = 0;
1422 u16 vid;
1423 1398
1424 work = kzalloc(sizeof *work, GFP_ATOMIC); 1399 mailbox = mlx4_alloc_cmd_mailbox(dev);
1425 if (!work) 1400 if (IS_ERR(mailbox)) {
1426 return -ENOMEM; 1401 pr_warn("reset gid table failed\n");
1402 goto free;
1403 }
1427 1404
1428 hits = kzalloc(128, GFP_ATOMIC); 1405 gids = mailbox->buf;
1429 if (!hits) { 1406 memcpy(gids, gw->gids, sizeof(gw->gids));
1430 ret = -ENOMEM; 1407
1431 goto out; 1408 for (i = 1; i < gw->dev->num_ports + 1; i++) {
1409 if (mlx4_ib_port_link_layer(&gw->dev->ib_dev, i) ==
1410 IB_LINK_LAYER_ETHERNET) {
1411 err = mlx4_cmd(dev, mailbox->dma,
1412 MLX4_SET_PORT_GID_TABLE << 8 | i,
1413 1, MLX4_CMD_SET_PORT,
1414 MLX4_CMD_TIME_CLASS_B,
1415 MLX4_CMD_WRAPPED);
1416 if (err)
1417 pr_warn(KERN_WARNING
1418 "set port %d command failed\n", i);
1419 }
1432 } 1420 }
1433 1421
1434 rcu_read_lock(); 1422 mlx4_free_cmd_mailbox(dev, mailbox);
1435 for_each_netdev_rcu(&init_net, tmp) { 1423free:
1436 if (ndev && (tmp == ndev || rdma_vlan_dev_real_dev(tmp) == ndev)) { 1424 kfree(gw);
1437 gid.global.subnet_prefix = cpu_to_be64(0xfe80000000000000LL); 1425}
1438 vid = rdma_vlan_dev_vlan_id(tmp);
1439 mlx4_addrconf_ifid_eui48(&gid.raw[8], vid, ndev);
1440 found = 0;
1441 free = -1;
1442 for (i = 0; i < 128; ++i) {
1443 if (free < 0 &&
1444 !memcmp(&dev->iboe.gid_table[port - 1][i], &zgid, sizeof zgid))
1445 free = i;
1446 if (!memcmp(&dev->iboe.gid_table[port - 1][i], &gid, sizeof gid)) {
1447 hits[i] = 1;
1448 found = 1;
1449 break;
1450 }
1451 }
1452 1426
1453 if (!found) { 1427static int update_gid_table(struct mlx4_ib_dev *dev, int port,
1454 if (tmp == ndev && 1428 union ib_gid *gid, int clear)
1455 (memcmp(&dev->iboe.gid_table[port - 1][0], 1429{
1456 &gid, sizeof gid) || 1430 struct update_gid_work *work;
1457 !memcmp(&dev->iboe.gid_table[port - 1][0], 1431 int i;
1458 &zgid, sizeof gid))) { 1432 int need_update = 0;
1459 dev->iboe.gid_table[port - 1][0] = gid; 1433 int free = -1;
1460 ++need_update; 1434 int found = -1;
1461 hits[0] = 1; 1435 int max_gids;
1462 } else if (free >= 0) { 1436
1463 dev->iboe.gid_table[port - 1][free] = gid; 1437 max_gids = dev->dev->caps.gid_table_len[port];
1464 hits[free] = 1; 1438 for (i = 0; i < max_gids; ++i) {
1465 ++need_update; 1439 if (!memcmp(&dev->iboe.gid_table[port - 1][i], gid,
1466 } 1440 sizeof(*gid)))
1441 found = i;
1442
1443 if (clear) {
1444 if (found >= 0) {
1445 need_update = 1;
1446 dev->iboe.gid_table[port - 1][found] = zgid;
1447 break;
1467 } 1448 }
1449 } else {
1450 if (found >= 0)
1451 break;
1452
1453 if (free < 0 &&
1454 !memcmp(&dev->iboe.gid_table[port - 1][i], &zgid,
1455 sizeof(*gid)))
1456 free = i;
1468 } 1457 }
1469 } 1458 }
1470 rcu_read_unlock();
1471 1459
1472 for (i = 0; i < 128; ++i) 1460 if (found == -1 && !clear && free >= 0) {
1473 if (!hits[i]) { 1461 dev->iboe.gid_table[port - 1][free] = *gid;
1474 if (memcmp(&dev->iboe.gid_table[port - 1][i], &zgid, sizeof zgid)) 1462 need_update = 1;
1475 ++need_update; 1463 }
1476 dev->iboe.gid_table[port - 1][i] = zgid;
1477 }
1478 1464
1479 if (need_update) { 1465 if (!need_update)
1480 memcpy(work->gids, dev->iboe.gid_table[port - 1], sizeof work->gids); 1466 return 0;
1481 INIT_WORK(&work->work, update_gids_task); 1467
1482 work->port = port; 1468 work = kzalloc(sizeof(*work), GFP_ATOMIC);
1483 work->dev = dev; 1469 if (!work)
1484 queue_work(wq, &work->work); 1470 return -ENOMEM;
1485 } else 1471
1486 kfree(work); 1472 memcpy(work->gids, dev->iboe.gid_table[port - 1], sizeof(work->gids));
1473 INIT_WORK(&work->work, update_gids_task);
1474 work->port = port;
1475 work->dev = dev;
1476 queue_work(wq, &work->work);
1487 1477
1488 kfree(hits);
1489 return 0; 1478 return 0;
1479}
1490 1480
1491out: 1481static int reset_gid_table(struct mlx4_ib_dev *dev)
1492 kfree(work); 1482{
1493 return ret; 1483 struct update_gid_work *work;
1484
1485
1486 work = kzalloc(sizeof(*work), GFP_ATOMIC);
1487 if (!work)
1488 return -ENOMEM;
1489 memset(dev->iboe.gid_table, 0, sizeof(dev->iboe.gid_table));
1490 memset(work->gids, 0, sizeof(work->gids));
1491 INIT_WORK(&work->work, reset_gids_task);
1492 work->dev = dev;
1493 queue_work(wq, &work->work);
1494 return 0;
1494} 1495}
1495 1496
1496static void handle_en_event(struct mlx4_ib_dev *dev, int port, unsigned long event) 1497static int mlx4_ib_addr_event(int event, struct net_device *event_netdev,
1498 struct mlx4_ib_dev *ibdev, union ib_gid *gid)
1497{ 1499{
1498 switch (event) { 1500 struct mlx4_ib_iboe *iboe;
1499 case NETDEV_UP: 1501 int port = 0;
1500 case NETDEV_CHANGEADDR: 1502 struct net_device *real_dev = rdma_vlan_dev_real_dev(event_netdev) ?
1501 update_ipv6_gids(dev, port, 0); 1503 rdma_vlan_dev_real_dev(event_netdev) :
1502 break; 1504 event_netdev;
1505
1506 if (event != NETDEV_DOWN && event != NETDEV_UP)
1507 return 0;
1508
1509 if ((real_dev != event_netdev) &&
1510 (event == NETDEV_DOWN) &&
1511 rdma_link_local_addr((struct in6_addr *)gid))
1512 return 0;
1513
1514 iboe = &ibdev->iboe;
1515 spin_lock(&iboe->lock);
1516
1517 for (port = 1; port <= MLX4_MAX_PORTS; ++port)
1518 if ((netif_is_bond_master(real_dev) &&
1519 (real_dev == iboe->masters[port - 1])) ||
1520 (!netif_is_bond_master(real_dev) &&
1521 (real_dev == iboe->netdevs[port - 1])))
1522 update_gid_table(ibdev, port, gid,
1523 event == NETDEV_DOWN);
1524
1525 spin_unlock(&iboe->lock);
1526 return 0;
1503 1527
1504 case NETDEV_DOWN:
1505 update_ipv6_gids(dev, port, 1);
1506 dev->iboe.netdevs[port - 1] = NULL;
1507 }
1508} 1528}
1509 1529
1510static void netdev_added(struct mlx4_ib_dev *dev, int port) 1530static u8 mlx4_ib_get_dev_port(struct net_device *dev,
1531 struct mlx4_ib_dev *ibdev)
1511{ 1532{
1512 update_ipv6_gids(dev, port, 0); 1533 u8 port = 0;
1534 struct mlx4_ib_iboe *iboe;
1535 struct net_device *real_dev = rdma_vlan_dev_real_dev(dev) ?
1536 rdma_vlan_dev_real_dev(dev) : dev;
1537
1538 iboe = &ibdev->iboe;
1539 spin_lock(&iboe->lock);
1540
1541 for (port = 1; port <= MLX4_MAX_PORTS; ++port)
1542 if ((netif_is_bond_master(real_dev) &&
1543 (real_dev == iboe->masters[port - 1])) ||
1544 (!netif_is_bond_master(real_dev) &&
1545 (real_dev == iboe->netdevs[port - 1])))
1546 break;
1547
1548 spin_unlock(&iboe->lock);
1549
1550 if ((port == 0) || (port > MLX4_MAX_PORTS))
1551 return 0;
1552 else
1553 return port;
1513} 1554}
1514 1555
1515static void netdev_removed(struct mlx4_ib_dev *dev, int port) 1556static int mlx4_ib_inet_event(struct notifier_block *this, unsigned long event,
1557 void *ptr)
1516{ 1558{
1517 update_ipv6_gids(dev, port, 1); 1559 struct mlx4_ib_dev *ibdev;
1560 struct in_ifaddr *ifa = ptr;
1561 union ib_gid gid;
1562 struct net_device *event_netdev = ifa->ifa_dev->dev;
1563
1564 ipv6_addr_set_v4mapped(ifa->ifa_address, (struct in6_addr *)&gid);
1565
1566 ibdev = container_of(this, struct mlx4_ib_dev, iboe.nb_inet);
1567
1568 mlx4_ib_addr_event(event, event_netdev, ibdev, &gid);
1569 return NOTIFY_DONE;
1518} 1570}
1519 1571
1520static int mlx4_ib_netdev_event(struct notifier_block *this, unsigned long event, 1572#if IS_ENABLED(CONFIG_IPV6)
1573static int mlx4_ib_inet6_event(struct notifier_block *this, unsigned long event,
1521 void *ptr) 1574 void *ptr)
1522{ 1575{
1523 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
1524 struct mlx4_ib_dev *ibdev; 1576 struct mlx4_ib_dev *ibdev;
1525 struct net_device *oldnd; 1577 struct inet6_ifaddr *ifa = ptr;
1578 union ib_gid *gid = (union ib_gid *)&ifa->addr;
1579 struct net_device *event_netdev = ifa->idev->dev;
1580
1581 ibdev = container_of(this, struct mlx4_ib_dev, iboe.nb_inet6);
1582
1583 mlx4_ib_addr_event(event, event_netdev, ibdev, gid);
1584 return NOTIFY_DONE;
1585}
1586#endif
1587
1588static void mlx4_ib_get_dev_addr(struct net_device *dev,
1589 struct mlx4_ib_dev *ibdev, u8 port)
1590{
1591 struct in_device *in_dev;
1592#if IS_ENABLED(CONFIG_IPV6)
1593 struct inet6_dev *in6_dev;
1594 union ib_gid *pgid;
1595 struct inet6_ifaddr *ifp;
1596#endif
1597 union ib_gid gid;
1598
1599
1600 if ((port == 0) || (port > MLX4_MAX_PORTS))
1601 return;
1602
1603 /* IPv4 gids */
1604 in_dev = in_dev_get(dev);
1605 if (in_dev) {
1606 for_ifa(in_dev) {
1607 /*ifa->ifa_address;*/
1608 ipv6_addr_set_v4mapped(ifa->ifa_address,
1609 (struct in6_addr *)&gid);
1610 update_gid_table(ibdev, port, &gid, 0);
1611 }
1612 endfor_ifa(in_dev);
1613 in_dev_put(in_dev);
1614 }
1615#if IS_ENABLED(CONFIG_IPV6)
1616 /* IPv6 gids */
1617 in6_dev = in6_dev_get(dev);
1618 if (in6_dev) {
1619 read_lock_bh(&in6_dev->lock);
1620 list_for_each_entry(ifp, &in6_dev->addr_list, if_list) {
1621 pgid = (union ib_gid *)&ifp->addr;
1622 update_gid_table(ibdev, port, pgid, 0);
1623 }
1624 read_unlock_bh(&in6_dev->lock);
1625 in6_dev_put(in6_dev);
1626 }
1627#endif
1628}
1629
1630static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
1631{
1632 struct net_device *dev;
1633
1634 if (reset_gid_table(ibdev))
1635 return -1;
1636
1637 read_lock(&dev_base_lock);
1638
1639 for_each_netdev(&init_net, dev) {
1640 u8 port = mlx4_ib_get_dev_port(dev, ibdev);
1641 if (port)
1642 mlx4_ib_get_dev_addr(dev, ibdev, port);
1643 }
1644
1645 read_unlock(&dev_base_lock);
1646
1647 return 0;
1648}
1649
1650static void mlx4_ib_scan_netdevs(struct mlx4_ib_dev *ibdev)
1651{
1526 struct mlx4_ib_iboe *iboe; 1652 struct mlx4_ib_iboe *iboe;
1527 int port; 1653 int port;
1528 1654
1529 if (!net_eq(dev_net(dev), &init_net))
1530 return NOTIFY_DONE;
1531
1532 ibdev = container_of(this, struct mlx4_ib_dev, iboe.nb);
1533 iboe = &ibdev->iboe; 1655 iboe = &ibdev->iboe;
1534 1656
1535 spin_lock(&iboe->lock); 1657 spin_lock(&iboe->lock);
1536 mlx4_foreach_ib_transport_port(port, ibdev->dev) { 1658 mlx4_foreach_ib_transport_port(port, ibdev->dev) {
1537 oldnd = iboe->netdevs[port - 1]; 1659 struct net_device *old_master = iboe->masters[port - 1];
1660 struct net_device *curr_master;
1538 iboe->netdevs[port - 1] = 1661 iboe->netdevs[port - 1] =
1539 mlx4_get_protocol_dev(ibdev->dev, MLX4_PROT_ETH, port); 1662 mlx4_get_protocol_dev(ibdev->dev, MLX4_PROT_ETH, port);
1540 if (oldnd != iboe->netdevs[port - 1]) { 1663
1541 if (iboe->netdevs[port - 1]) 1664 if (iboe->netdevs[port - 1] &&
1542 netdev_added(ibdev, port); 1665 netif_is_bond_slave(iboe->netdevs[port - 1])) {
1543 else 1666 rtnl_lock();
1544 netdev_removed(ibdev, port); 1667 iboe->masters[port - 1] = netdev_master_upper_dev_get(
1668 iboe->netdevs[port - 1]);
1669 rtnl_unlock();
1545 } 1670 }
1546 } 1671 curr_master = iboe->masters[port - 1];
1547 1672
1548 if (dev == iboe->netdevs[0] || 1673 /* if bonding is used it is possible that we add it to masters
1549 (iboe->netdevs[0] && rdma_vlan_dev_real_dev(dev) == iboe->netdevs[0])) 1674 only after IP address is assigned to the net bonding
1550 handle_en_event(ibdev, 1, event); 1675 interface */
1551 else if (dev == iboe->netdevs[1] 1676 if (curr_master && (old_master != curr_master))
1552 || (iboe->netdevs[1] && rdma_vlan_dev_real_dev(dev) == iboe->netdevs[1])) 1677 mlx4_ib_get_dev_addr(curr_master, ibdev, port);
1553 handle_en_event(ibdev, 2, event); 1678 }
1554 1679
1555 spin_unlock(&iboe->lock); 1680 spin_unlock(&iboe->lock);
1681}
1682
1683static int mlx4_ib_netdev_event(struct notifier_block *this,
1684 unsigned long event, void *ptr)
1685{
1686 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
1687 struct mlx4_ib_dev *ibdev;
1688
1689 if (!net_eq(dev_net(dev), &init_net))
1690 return NOTIFY_DONE;
1691
1692 ibdev = container_of(this, struct mlx4_ib_dev, iboe.nb);
1693 mlx4_ib_scan_netdevs(ibdev);
1556 1694
1557 return NOTIFY_DONE; 1695 return NOTIFY_DONE;
1558} 1696}
@@ -1886,11 +2024,35 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
1886 if (mlx4_ib_init_sriov(ibdev)) 2024 if (mlx4_ib_init_sriov(ibdev))
1887 goto err_mad; 2025 goto err_mad;
1888 2026
1889 if (dev->caps.flags & MLX4_DEV_CAP_FLAG_IBOE && !iboe->nb.notifier_call) { 2027 if (dev->caps.flags & MLX4_DEV_CAP_FLAG_IBOE) {
1890 iboe->nb.notifier_call = mlx4_ib_netdev_event; 2028 if (!iboe->nb.notifier_call) {
1891 err = register_netdevice_notifier(&iboe->nb); 2029 iboe->nb.notifier_call = mlx4_ib_netdev_event;
1892 if (err) 2030 err = register_netdevice_notifier(&iboe->nb);
1893 goto err_sriov; 2031 if (err) {
2032 iboe->nb.notifier_call = NULL;
2033 goto err_notif;
2034 }
2035 }
2036 if (!iboe->nb_inet.notifier_call) {
2037 iboe->nb_inet.notifier_call = mlx4_ib_inet_event;
2038 err = register_inetaddr_notifier(&iboe->nb_inet);
2039 if (err) {
2040 iboe->nb_inet.notifier_call = NULL;
2041 goto err_notif;
2042 }
2043 }
2044#if IS_ENABLED(CONFIG_IPV6)
2045 if (!iboe->nb_inet6.notifier_call) {
2046 iboe->nb_inet6.notifier_call = mlx4_ib_inet6_event;
2047 err = register_inet6addr_notifier(&iboe->nb_inet6);
2048 if (err) {
2049 iboe->nb_inet6.notifier_call = NULL;
2050 goto err_notif;
2051 }
2052 }
2053#endif
2054 mlx4_ib_scan_netdevs(ibdev);
2055 mlx4_ib_init_gid_table(ibdev);
1894 } 2056 }
1895 2057
1896 for (j = 0; j < ARRAY_SIZE(mlx4_class_attributes); ++j) { 2058 for (j = 0; j < ARRAY_SIZE(mlx4_class_attributes); ++j) {
@@ -1916,11 +2078,25 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
1916 return ibdev; 2078 return ibdev;
1917 2079
1918err_notif: 2080err_notif:
1919 if (unregister_netdevice_notifier(&ibdev->iboe.nb)) 2081 if (ibdev->iboe.nb.notifier_call) {
1920 pr_warn("failure unregistering notifier\n"); 2082 if (unregister_netdevice_notifier(&ibdev->iboe.nb))
2083 pr_warn("failure unregistering notifier\n");
2084 ibdev->iboe.nb.notifier_call = NULL;
2085 }
2086 if (ibdev->iboe.nb_inet.notifier_call) {
2087 if (unregister_inetaddr_notifier(&ibdev->iboe.nb_inet))
2088 pr_warn("failure unregistering notifier\n");
2089 ibdev->iboe.nb_inet.notifier_call = NULL;
2090 }
2091#if IS_ENABLED(CONFIG_IPV6)
2092 if (ibdev->iboe.nb_inet6.notifier_call) {
2093 if (unregister_inet6addr_notifier(&ibdev->iboe.nb_inet6))
2094 pr_warn("failure unregistering notifier\n");
2095 ibdev->iboe.nb_inet6.notifier_call = NULL;
2096 }
2097#endif
1921 flush_workqueue(wq); 2098 flush_workqueue(wq);
1922 2099
1923err_sriov:
1924 mlx4_ib_close_sriov(ibdev); 2100 mlx4_ib_close_sriov(ibdev);
1925 2101
1926err_mad: 2102err_mad:
@@ -2039,6 +2215,19 @@ static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr)
2039 kfree(ibdev->ib_uc_qpns_bitmap); 2215 kfree(ibdev->ib_uc_qpns_bitmap);
2040 } 2216 }
2041 2217
2218 if (ibdev->iboe.nb_inet.notifier_call) {
2219 if (unregister_inetaddr_notifier(&ibdev->iboe.nb_inet))
2220 pr_warn("failure unregistering notifier\n");
2221 ibdev->iboe.nb_inet.notifier_call = NULL;
2222 }
2223#if IS_ENABLED(CONFIG_IPV6)
2224 if (ibdev->iboe.nb_inet6.notifier_call) {
2225 if (unregister_inet6addr_notifier(&ibdev->iboe.nb_inet6))
2226 pr_warn("failure unregistering notifier\n");
2227 ibdev->iboe.nb_inet6.notifier_call = NULL;
2228 }
2229#endif
2230
2042 iounmap(ibdev->uar_map); 2231 iounmap(ibdev->uar_map);
2043 for (p = 0; p < ibdev->num_ports; ++p) 2232 for (p = 0; p < ibdev->num_ports; ++p)
2044 if (ibdev->counters[p] != -1) 2233 if (ibdev->counters[p] != -1)
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 837f9aa3d2a2..a230683af940 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -432,7 +432,10 @@ struct mlx4_ib_sriov {
432struct mlx4_ib_iboe { 432struct mlx4_ib_iboe {
433 spinlock_t lock; 433 spinlock_t lock;
434 struct net_device *netdevs[MLX4_MAX_PORTS]; 434 struct net_device *netdevs[MLX4_MAX_PORTS];
435 struct net_device *masters[MLX4_MAX_PORTS];
435 struct notifier_block nb; 436 struct notifier_block nb;
437 struct notifier_block nb_inet;
438 struct notifier_block nb_inet6;
436 union ib_gid gid_table[MLX4_MAX_PORTS][128]; 439 union ib_gid gid_table[MLX4_MAX_PORTS][128];
437}; 440};
438 441
@@ -683,9 +686,6 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
683int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index, 686int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
684 union ib_gid *gid, int netw_view); 687 union ib_gid *gid, int netw_view);
685 688
686int mlx4_ib_resolve_grh(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah_attr,
687 u8 *mac, int *is_mcast, u8 port);
688
689static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah) 689static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
690{ 690{
691 u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3; 691 u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 387fbf274151..d8f4d1fe8494 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -90,6 +90,21 @@ enum {
90 MLX4_RAW_QP_MSGMAX = 31, 90 MLX4_RAW_QP_MSGMAX = 31,
91}; 91};
92 92
93#ifndef ETH_ALEN
94#define ETH_ALEN 6
95#endif
96static inline u64 mlx4_mac_to_u64(u8 *addr)
97{
98 u64 mac = 0;
99 int i;
100
101 for (i = 0; i < ETH_ALEN; i++) {
102 mac <<= 8;
103 mac |= addr[i];
104 }
105 return mac;
106}
107
93static const __be32 mlx4_ib_opcode[] = { 108static const __be32 mlx4_ib_opcode[] = {
94 [IB_WR_SEND] = cpu_to_be32(MLX4_OPCODE_SEND), 109 [IB_WR_SEND] = cpu_to_be32(MLX4_OPCODE_SEND),
95 [IB_WR_LSO] = cpu_to_be32(MLX4_OPCODE_LSO), 110 [IB_WR_LSO] = cpu_to_be32(MLX4_OPCODE_LSO),
@@ -1171,16 +1186,15 @@ static void mlx4_set_sched(struct mlx4_qp_path *path, u8 port)
1171 path->sched_queue = (path->sched_queue & 0xbf) | ((port - 1) << 6); 1186 path->sched_queue = (path->sched_queue & 0xbf) | ((port - 1) << 6);
1172} 1187}
1173 1188
1174static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah, 1189static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
1175 struct mlx4_qp_path *path, u8 port) 1190 u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
1191 u8 port)
1176{ 1192{
1177 int err;
1178 int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) == 1193 int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
1179 IB_LINK_LAYER_ETHERNET; 1194 IB_LINK_LAYER_ETHERNET;
1180 u8 mac[6];
1181 int is_mcast;
1182 u16 vlan_tag;
1183 int vidx; 1195 int vidx;
1196 int smac_index;
1197
1184 1198
1185 path->grh_mylmc = ah->src_path_bits & 0x7f; 1199 path->grh_mylmc = ah->src_path_bits & 0x7f;
1186 path->rlid = cpu_to_be16(ah->dlid); 1200 path->rlid = cpu_to_be16(ah->dlid);
@@ -1215,22 +1229,27 @@ static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
1215 if (!(ah->ah_flags & IB_AH_GRH)) 1229 if (!(ah->ah_flags & IB_AH_GRH))
1216 return -1; 1230 return -1;
1217 1231
1218 err = mlx4_ib_resolve_grh(dev, ah, mac, &is_mcast, port); 1232 memcpy(path->dmac, ah->dmac, ETH_ALEN);
1219 if (err)
1220 return err;
1221
1222 memcpy(path->dmac, mac, 6);
1223 path->ackto = MLX4_IB_LINK_TYPE_ETH; 1233 path->ackto = MLX4_IB_LINK_TYPE_ETH;
1224 /* use index 0 into MAC table for IBoE */ 1234 /* find the index into MAC table for IBoE */
1225 path->grh_mylmc &= 0x80; 1235 if (!is_zero_ether_addr((const u8 *)&smac)) {
1236 if (mlx4_find_cached_mac(dev->dev, port, smac,
1237 &smac_index))
1238 return -ENOENT;
1239 } else {
1240 smac_index = 0;
1241 }
1226 1242
1227 vlan_tag = rdma_get_vlan_id(&dev->iboe.gid_table[port - 1][ah->grh.sgid_index]); 1243 path->grh_mylmc &= 0x80 | smac_index;
1244
1245 path->feup |= MLX4_FEUP_FORCE_ETH_UP;
1228 if (vlan_tag < 0x1000) { 1246 if (vlan_tag < 0x1000) {
1229 if (mlx4_find_cached_vlan(dev->dev, port, vlan_tag, &vidx)) 1247 if (mlx4_find_cached_vlan(dev->dev, port, vlan_tag, &vidx))
1230 return -ENOENT; 1248 return -ENOENT;
1231 1249
1232 path->vlan_index = vidx; 1250 path->vlan_index = vidx;
1233 path->fl = 1 << 6; 1251 path->fl = 1 << 6;
1252 path->feup |= MLX4_FVL_FORCE_ETH_VLAN;
1234 } 1253 }
1235 } else 1254 } else
1236 path->sched_queue = MLX4_IB_DEFAULT_SCHED_QUEUE | 1255 path->sched_queue = MLX4_IB_DEFAULT_SCHED_QUEUE |
@@ -1239,6 +1258,28 @@ static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
1239 return 0; 1258 return 0;
1240} 1259}
1241 1260
1261static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_qp_attr *qp,
1262 enum ib_qp_attr_mask qp_attr_mask,
1263 struct mlx4_qp_path *path, u8 port)
1264{
1265 return _mlx4_set_path(dev, &qp->ah_attr,
1266 mlx4_mac_to_u64((u8 *)qp->smac),
1267 (qp_attr_mask & IB_QP_VID) ? qp->vlan_id : 0xffff,
1268 path, port);
1269}
1270
1271static int mlx4_set_alt_path(struct mlx4_ib_dev *dev,
1272 const struct ib_qp_attr *qp,
1273 enum ib_qp_attr_mask qp_attr_mask,
1274 struct mlx4_qp_path *path, u8 port)
1275{
1276 return _mlx4_set_path(dev, &qp->alt_ah_attr,
1277 mlx4_mac_to_u64((u8 *)qp->alt_smac),
1278 (qp_attr_mask & IB_QP_ALT_VID) ?
1279 qp->alt_vlan_id : 0xffff,
1280 path, port);
1281}
1282
1242static void update_mcg_macs(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp) 1283static void update_mcg_macs(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp)
1243{ 1284{
1244 struct mlx4_ib_gid_entry *ge, *tmp; 1285 struct mlx4_ib_gid_entry *ge, *tmp;
@@ -1362,7 +1403,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
1362 } 1403 }
1363 1404
1364 if (attr_mask & IB_QP_AV) { 1405 if (attr_mask & IB_QP_AV) {
1365 if (mlx4_set_path(dev, &attr->ah_attr, &context->pri_path, 1406 if (mlx4_set_path(dev, attr, attr_mask, &context->pri_path,
1366 attr_mask & IB_QP_PORT ? 1407 attr_mask & IB_QP_PORT ?
1367 attr->port_num : qp->port)) 1408 attr->port_num : qp->port))
1368 goto out; 1409 goto out;
@@ -1385,8 +1426,8 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
1385 dev->dev->caps.pkey_table_len[attr->alt_port_num]) 1426 dev->dev->caps.pkey_table_len[attr->alt_port_num])
1386 goto out; 1427 goto out;
1387 1428
1388 if (mlx4_set_path(dev, &attr->alt_ah_attr, &context->alt_path, 1429 if (mlx4_set_alt_path(dev, attr, attr_mask, &context->alt_path,
1389 attr->alt_port_num)) 1430 attr->alt_port_num))
1390 goto out; 1431 goto out;
1391 1432
1392 context->alt_path.pkey_index = attr->alt_pkey_index; 1433 context->alt_path.pkey_index = attr->alt_pkey_index;
@@ -1497,6 +1538,17 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
1497 context->pri_path.ackto = (context->pri_path.ackto & 0xf8) | 1538 context->pri_path.ackto = (context->pri_path.ackto & 0xf8) |
1498 MLX4_IB_LINK_TYPE_ETH; 1539 MLX4_IB_LINK_TYPE_ETH;
1499 1540
1541 if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
1542 int is_eth = rdma_port_get_link_layer(
1543 &dev->ib_dev, qp->port) ==
1544 IB_LINK_LAYER_ETHERNET;
1545 if (is_eth) {
1546 context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
1547 optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
1548 }
1549 }
1550
1551
1500 if (cur_state == IB_QPS_RTS && new_state == IB_QPS_SQD && 1552 if (cur_state == IB_QPS_RTS && new_state == IB_QPS_SQD &&
1501 attr_mask & IB_QP_EN_SQD_ASYNC_NOTIFY && attr->en_sqd_async_notify) 1553 attr_mask & IB_QP_EN_SQD_ASYNC_NOTIFY && attr->en_sqd_async_notify)
1502 sqd_event = 1; 1554 sqd_event = 1;
@@ -1599,13 +1651,21 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
1599 struct mlx4_ib_qp *qp = to_mqp(ibqp); 1651 struct mlx4_ib_qp *qp = to_mqp(ibqp);
1600 enum ib_qp_state cur_state, new_state; 1652 enum ib_qp_state cur_state, new_state;
1601 int err = -EINVAL; 1653 int err = -EINVAL;
1602 1654 int ll;
1603 mutex_lock(&qp->mutex); 1655 mutex_lock(&qp->mutex);
1604 1656
1605 cur_state = attr_mask & IB_QP_CUR_STATE ? attr->cur_qp_state : qp->state; 1657 cur_state = attr_mask & IB_QP_CUR_STATE ? attr->cur_qp_state : qp->state;
1606 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state; 1658 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
1607 1659
1608 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask)) { 1660 if (cur_state == new_state && cur_state == IB_QPS_RESET) {
1661 ll = IB_LINK_LAYER_UNSPECIFIED;
1662 } else {
1663 int port = attr_mask & IB_QP_PORT ? attr->port_num : qp->port;
1664 ll = rdma_port_get_link_layer(&dev->ib_dev, port);
1665 }
1666
1667 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type,
1668 attr_mask, ll)) {
1609 pr_debug("qpn 0x%x: invalid attribute mask specified " 1669 pr_debug("qpn 0x%x: invalid attribute mask specified "
1610 "for transition %d to %d. qp_type %d," 1670 "for transition %d to %d. qp_type %d,"
1611 " attr_mask 0x%x\n", 1671 " attr_mask 0x%x\n",
@@ -1822,8 +1882,10 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
1822 return err; 1882 return err;
1823 } 1883 }
1824 1884
1825 vlan = rdma_get_vlan_id(&sgid); 1885 if (ah->av.eth.vlan != 0xffff) {
1826 is_vlan = vlan < 0x1000; 1886 vlan = be16_to_cpu(ah->av.eth.vlan) & 0x0fff;
1887 is_vlan = 1;
1888 }
1827 } 1889 }
1828 ib_ud_header_init(send_size, !is_eth, is_eth, is_vlan, is_grh, 0, &sqp->ud_header); 1890 ib_ud_header_init(send_size, !is_eth, is_eth, is_vlan, is_grh, 0, &sqp->ud_header);
1829 1891
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 70dd77085db6..ae37fb9bf262 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -1664,7 +1664,8 @@ int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
1664 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state; 1664 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
1665 1665
1666 if (ibqp->qp_type != MLX5_IB_QPT_REG_UMR && 1666 if (ibqp->qp_type != MLX5_IB_QPT_REG_UMR &&
1667 !ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask)) 1667 !ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask,
1668 IB_LINK_LAYER_UNSPECIFIED))
1668 goto out; 1669 goto out;
1669 1670
1670 if ((attr_mask & IB_QP_PORT) && 1671 if ((attr_mask & IB_QP_PORT) &&
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 26a684536109..e354b2f04ad9 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -860,7 +860,8 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
860 860
861 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state; 861 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
862 862
863 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask)) { 863 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask,
864 IB_LINK_LAYER_UNSPECIFIED)) {
864 mthca_dbg(dev, "Bad QP transition (transport %d) " 865 mthca_dbg(dev, "Bad QP transition (transport %d) "
865 "%d->%d with attr 0x%08x\n", 866 "%d->%d with attr 0x%08x\n",
866 qp->transport, cur_state, new_state, 867 qp->transport, cur_state, new_state,
diff --git a/drivers/infiniband/hw/ocrdma/Kconfig b/drivers/infiniband/hw/ocrdma/Kconfig
index b5b6056c8518..c0cddc0192d1 100644
--- a/drivers/infiniband/hw/ocrdma/Kconfig
+++ b/drivers/infiniband/hw/ocrdma/Kconfig
@@ -1,6 +1,6 @@
1config INFINIBAND_OCRDMA 1config INFINIBAND_OCRDMA
2 tristate "Emulex One Connect HCA support" 2 tristate "Emulex One Connect HCA support"
3 depends on ETHERNET && NETDEVICES && PCI && (IPV6 || IPV6=n) 3 depends on ETHERNET && NETDEVICES && PCI && INET && (IPV6 || IPV6=n)
4 select NET_VENDOR_EMULEX 4 select NET_VENDOR_EMULEX
5 select BE2NET 5 select BE2NET
6 ---help--- 6 ---help---
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma.h b/drivers/infiniband/hw/ocrdma/ocrdma.h
index 294dd27b601e..7c001b97b23f 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma.h
@@ -423,5 +423,17 @@ static inline int is_cqe_wr_imm(struct ocrdma_cqe *cqe)
423 OCRDMA_CQE_WRITE_IMM) ? 1 : 0; 423 OCRDMA_CQE_WRITE_IMM) ? 1 : 0;
424} 424}
425 425
426static inline int ocrdma_resolve_dmac(struct ocrdma_dev *dev,
427 struct ib_ah_attr *ah_attr, u8 *mac_addr)
428{
429 struct in6_addr in6;
430
431 memcpy(&in6, ah_attr->grh.dgid.raw, sizeof(in6));
432 if (rdma_is_multicast_addr(&in6))
433 rdma_get_mcast_mac(&in6, mac_addr);
434 else
435 memcpy(mac_addr, ah_attr->dmac, ETH_ALEN);
436 return 0;
437}
426 438
427#endif 439#endif
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index 69da5dd1ca8a..34071143006e 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -49,7 +49,7 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
49 49
50 ah->sgid_index = attr->grh.sgid_index; 50 ah->sgid_index = attr->grh.sgid_index;
51 51
52 vlan_tag = rdma_get_vlan_id(&attr->grh.dgid); 52 vlan_tag = attr->vlan_id;
53 if (!vlan_tag || (vlan_tag > 0xFFF)) 53 if (!vlan_tag || (vlan_tag > 0xFFF))
54 vlan_tag = dev->pvid; 54 vlan_tag = dev->pvid;
55 if (vlan_tag && (vlan_tag < 0x1000)) { 55 if (vlan_tag && (vlan_tag < 0x1000)) {
@@ -64,7 +64,8 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
64 eth_sz = sizeof(struct ocrdma_eth_basic); 64 eth_sz = sizeof(struct ocrdma_eth_basic);
65 } 65 }
66 memcpy(&eth.smac[0], &dev->nic_info.mac_addr[0], ETH_ALEN); 66 memcpy(&eth.smac[0], &dev->nic_info.mac_addr[0], ETH_ALEN);
67 status = ocrdma_resolve_dgid(dev, &attr->grh.dgid, &eth.dmac[0]); 67 memcpy(&eth.dmac[0], attr->dmac, ETH_ALEN);
68 status = ocrdma_resolve_dmac(dev, attr, &eth.dmac[0]);
68 if (status) 69 if (status)
69 return status; 70 return status;
70 status = ocrdma_query_gid(&dev->ibdev, 1, attr->grh.sgid_index, 71 status = ocrdma_query_gid(&dev->ibdev, 1, attr->grh.sgid_index,
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
index 56bf32fcb62c..1664d648cbfc 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
@@ -2076,23 +2076,6 @@ mbx_err:
2076 return status; 2076 return status;
2077} 2077}
2078 2078
2079int ocrdma_resolve_dgid(struct ocrdma_dev *dev, union ib_gid *dgid,
2080 u8 *mac_addr)
2081{
2082 struct in6_addr in6;
2083
2084 memcpy(&in6, dgid, sizeof in6);
2085 if (rdma_is_multicast_addr(&in6)) {
2086 rdma_get_mcast_mac(&in6, mac_addr);
2087 } else if (rdma_link_local_addr(&in6)) {
2088 rdma_get_ll_mac(&in6, mac_addr);
2089 } else {
2090 pr_err("%s() fail to resolve mac_addr.\n", __func__);
2091 return -EINVAL;
2092 }
2093 return 0;
2094}
2095
2096static int ocrdma_set_av_params(struct ocrdma_qp *qp, 2079static int ocrdma_set_av_params(struct ocrdma_qp *qp,
2097 struct ocrdma_modify_qp *cmd, 2080 struct ocrdma_modify_qp *cmd,
2098 struct ib_qp_attr *attrs) 2081 struct ib_qp_attr *attrs)
@@ -2126,14 +2109,14 @@ static int ocrdma_set_av_params(struct ocrdma_qp *qp,
2126 2109
2127 qp->sgid_idx = ah_attr->grh.sgid_index; 2110 qp->sgid_idx = ah_attr->grh.sgid_index;
2128 memcpy(&cmd->params.sgid[0], &sgid.raw[0], sizeof(cmd->params.sgid)); 2111 memcpy(&cmd->params.sgid[0], &sgid.raw[0], sizeof(cmd->params.sgid));
2129 ocrdma_resolve_dgid(qp->dev, &ah_attr->grh.dgid, &mac_addr[0]); 2112 ocrdma_resolve_dmac(qp->dev, ah_attr, &mac_addr[0]);
2130 cmd->params.dmac_b0_to_b3 = mac_addr[0] | (mac_addr[1] << 8) | 2113 cmd->params.dmac_b0_to_b3 = mac_addr[0] | (mac_addr[1] << 8) |
2131 (mac_addr[2] << 16) | (mac_addr[3] << 24); 2114 (mac_addr[2] << 16) | (mac_addr[3] << 24);
2132 /* convert them to LE format. */ 2115 /* convert them to LE format. */
2133 ocrdma_cpu_to_le32(&cmd->params.dgid[0], sizeof(cmd->params.dgid)); 2116 ocrdma_cpu_to_le32(&cmd->params.dgid[0], sizeof(cmd->params.dgid));
2134 ocrdma_cpu_to_le32(&cmd->params.sgid[0], sizeof(cmd->params.sgid)); 2117 ocrdma_cpu_to_le32(&cmd->params.sgid[0], sizeof(cmd->params.sgid));
2135 cmd->params.vlan_dmac_b4_to_b5 = mac_addr[4] | (mac_addr[5] << 8); 2118 cmd->params.vlan_dmac_b4_to_b5 = mac_addr[4] | (mac_addr[5] << 8);
2136 vlan_id = rdma_get_vlan_id(&sgid); 2119 vlan_id = ah_attr->vlan_id;
2137 if (vlan_id && (vlan_id < 0x1000)) { 2120 if (vlan_id && (vlan_id < 0x1000)) {
2138 cmd->params.vlan_dmac_b4_to_b5 |= 2121 cmd->params.vlan_dmac_b4_to_b5 |=
2139 vlan_id << OCRDMA_QP_PARAMS_VLAN_SHIFT; 2122 vlan_id << OCRDMA_QP_PARAMS_VLAN_SHIFT;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.h b/drivers/infiniband/hw/ocrdma/ocrdma_hw.h
index f2a89d4cc7c4..82fe332ae6c6 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.h
@@ -94,7 +94,6 @@ void ocrdma_ring_cq_db(struct ocrdma_dev *, u16 cq_id, bool armed,
94int ocrdma_mbx_get_link_speed(struct ocrdma_dev *dev, u8 *lnk_speed); 94int ocrdma_mbx_get_link_speed(struct ocrdma_dev *dev, u8 *lnk_speed);
95int ocrdma_query_config(struct ocrdma_dev *, 95int ocrdma_query_config(struct ocrdma_dev *,
96 struct ocrdma_mbx_query_config *config); 96 struct ocrdma_mbx_query_config *config);
97int ocrdma_resolve_dgid(struct ocrdma_dev *, union ib_gid *dgid, u8 *mac_addr);
98 97
99int ocrdma_mbx_alloc_pd(struct ocrdma_dev *, struct ocrdma_pd *); 98int ocrdma_mbx_alloc_pd(struct ocrdma_dev *, struct ocrdma_pd *);
100int ocrdma_mbx_dealloc_pd(struct ocrdma_dev *, struct ocrdma_pd *); 99int ocrdma_mbx_dealloc_pd(struct ocrdma_dev *, struct ocrdma_pd *);
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c
index 91443bcb9e0e..2ca86ca818bd 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c
@@ -67,46 +67,24 @@ void ocrdma_get_guid(struct ocrdma_dev *dev, u8 *guid)
67 guid[7] = mac_addr[5]; 67 guid[7] = mac_addr[5];
68} 68}
69 69
70static void ocrdma_build_sgid_mac(union ib_gid *sgid, unsigned char *mac_addr, 70static bool ocrdma_add_sgid(struct ocrdma_dev *dev, union ib_gid *new_sgid)
71 bool is_vlan, u16 vlan_id)
72{
73 sgid->global.subnet_prefix = cpu_to_be64(0xfe80000000000000LL);
74 sgid->raw[8] = mac_addr[0] ^ 2;
75 sgid->raw[9] = mac_addr[1];
76 sgid->raw[10] = mac_addr[2];
77 if (is_vlan) {
78 sgid->raw[11] = vlan_id >> 8;
79 sgid->raw[12] = vlan_id & 0xff;
80 } else {
81 sgid->raw[11] = 0xff;
82 sgid->raw[12] = 0xfe;
83 }
84 sgid->raw[13] = mac_addr[3];
85 sgid->raw[14] = mac_addr[4];
86 sgid->raw[15] = mac_addr[5];
87}
88
89static bool ocrdma_add_sgid(struct ocrdma_dev *dev, unsigned char *mac_addr,
90 bool is_vlan, u16 vlan_id)
91{ 71{
92 int i; 72 int i;
93 union ib_gid new_sgid;
94 unsigned long flags; 73 unsigned long flags;
95 74
96 memset(&ocrdma_zero_sgid, 0, sizeof(union ib_gid)); 75 memset(&ocrdma_zero_sgid, 0, sizeof(union ib_gid));
97 76
98 ocrdma_build_sgid_mac(&new_sgid, mac_addr, is_vlan, vlan_id);
99 77
100 spin_lock_irqsave(&dev->sgid_lock, flags); 78 spin_lock_irqsave(&dev->sgid_lock, flags);
101 for (i = 0; i < OCRDMA_MAX_SGID; i++) { 79 for (i = 0; i < OCRDMA_MAX_SGID; i++) {
102 if (!memcmp(&dev->sgid_tbl[i], &ocrdma_zero_sgid, 80 if (!memcmp(&dev->sgid_tbl[i], &ocrdma_zero_sgid,
103 sizeof(union ib_gid))) { 81 sizeof(union ib_gid))) {
104 /* found free entry */ 82 /* found free entry */
105 memcpy(&dev->sgid_tbl[i], &new_sgid, 83 memcpy(&dev->sgid_tbl[i], new_sgid,
106 sizeof(union ib_gid)); 84 sizeof(union ib_gid));
107 spin_unlock_irqrestore(&dev->sgid_lock, flags); 85 spin_unlock_irqrestore(&dev->sgid_lock, flags);
108 return true; 86 return true;
109 } else if (!memcmp(&dev->sgid_tbl[i], &new_sgid, 87 } else if (!memcmp(&dev->sgid_tbl[i], new_sgid,
110 sizeof(union ib_gid))) { 88 sizeof(union ib_gid))) {
111 /* entry already present, no addition is required. */ 89 /* entry already present, no addition is required. */
112 spin_unlock_irqrestore(&dev->sgid_lock, flags); 90 spin_unlock_irqrestore(&dev->sgid_lock, flags);
@@ -117,20 +95,17 @@ static bool ocrdma_add_sgid(struct ocrdma_dev *dev, unsigned char *mac_addr,
117 return false; 95 return false;
118} 96}
119 97
120static bool ocrdma_del_sgid(struct ocrdma_dev *dev, unsigned char *mac_addr, 98static bool ocrdma_del_sgid(struct ocrdma_dev *dev, union ib_gid *sgid)
121 bool is_vlan, u16 vlan_id)
122{ 99{
123 int found = false; 100 int found = false;
124 int i; 101 int i;
125 union ib_gid sgid;
126 unsigned long flags; 102 unsigned long flags;
127 103
128 ocrdma_build_sgid_mac(&sgid, mac_addr, is_vlan, vlan_id);
129 104
130 spin_lock_irqsave(&dev->sgid_lock, flags); 105 spin_lock_irqsave(&dev->sgid_lock, flags);
131 /* first is default sgid, which cannot be deleted. */ 106 /* first is default sgid, which cannot be deleted. */
132 for (i = 1; i < OCRDMA_MAX_SGID; i++) { 107 for (i = 1; i < OCRDMA_MAX_SGID; i++) {
133 if (!memcmp(&dev->sgid_tbl[i], &sgid, sizeof(union ib_gid))) { 108 if (!memcmp(&dev->sgid_tbl[i], sgid, sizeof(union ib_gid))) {
134 /* found matching entry */ 109 /* found matching entry */
135 memset(&dev->sgid_tbl[i], 0, sizeof(union ib_gid)); 110 memset(&dev->sgid_tbl[i], 0, sizeof(union ib_gid));
136 found = true; 111 found = true;
@@ -141,75 +116,18 @@ static bool ocrdma_del_sgid(struct ocrdma_dev *dev, unsigned char *mac_addr,
141 return found; 116 return found;
142} 117}
143 118
144static void ocrdma_add_default_sgid(struct ocrdma_dev *dev) 119static int ocrdma_addr_event(unsigned long event, struct net_device *netdev,
145{ 120 union ib_gid *gid)
146 /* GID Index 0 - Invariant manufacturer-assigned EUI-64 */
147 union ib_gid *sgid = &dev->sgid_tbl[0];
148
149 sgid->global.subnet_prefix = cpu_to_be64(0xfe80000000000000LL);
150 ocrdma_get_guid(dev, &sgid->raw[8]);
151}
152
153#if IS_ENABLED(CONFIG_VLAN_8021Q)
154static void ocrdma_add_vlan_sgids(struct ocrdma_dev *dev)
155{
156 struct net_device *netdev, *tmp;
157 u16 vlan_id;
158 bool is_vlan;
159
160 netdev = dev->nic_info.netdev;
161
162 rcu_read_lock();
163 for_each_netdev_rcu(&init_net, tmp) {
164 if (netdev == tmp || vlan_dev_real_dev(tmp) == netdev) {
165 if (!netif_running(tmp) || !netif_oper_up(tmp))
166 continue;
167 if (netdev != tmp) {
168 vlan_id = vlan_dev_vlan_id(tmp);
169 is_vlan = true;
170 } else {
171 is_vlan = false;
172 vlan_id = 0;
173 tmp = netdev;
174 }
175 ocrdma_add_sgid(dev, tmp->dev_addr, is_vlan, vlan_id);
176 }
177 }
178 rcu_read_unlock();
179}
180#else
181static void ocrdma_add_vlan_sgids(struct ocrdma_dev *dev)
182{
183
184}
185#endif /* VLAN */
186
187static int ocrdma_build_sgid_tbl(struct ocrdma_dev *dev)
188{ 121{
189 ocrdma_add_default_sgid(dev);
190 ocrdma_add_vlan_sgids(dev);
191 return 0;
192}
193
194#if IS_ENABLED(CONFIG_IPV6)
195
196static int ocrdma_inet6addr_event(struct notifier_block *notifier,
197 unsigned long event, void *ptr)
198{
199 struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr;
200 struct net_device *netdev = ifa->idev->dev;
201 struct ib_event gid_event; 122 struct ib_event gid_event;
202 struct ocrdma_dev *dev; 123 struct ocrdma_dev *dev;
203 bool found = false; 124 bool found = false;
204 bool updated = false; 125 bool updated = false;
205 bool is_vlan = false; 126 bool is_vlan = false;
206 u16 vid = 0;
207 127
208 is_vlan = netdev->priv_flags & IFF_802_1Q_VLAN; 128 is_vlan = netdev->priv_flags & IFF_802_1Q_VLAN;
209 if (is_vlan) { 129 if (is_vlan)
210 vid = vlan_dev_vlan_id(netdev);
211 netdev = vlan_dev_real_dev(netdev); 130 netdev = vlan_dev_real_dev(netdev);
212 }
213 131
214 rcu_read_lock(); 132 rcu_read_lock();
215 list_for_each_entry_rcu(dev, &ocrdma_dev_list, entry) { 133 list_for_each_entry_rcu(dev, &ocrdma_dev_list, entry) {
@@ -222,16 +140,14 @@ static int ocrdma_inet6addr_event(struct notifier_block *notifier,
222 140
223 if (!found) 141 if (!found)
224 return NOTIFY_DONE; 142 return NOTIFY_DONE;
225 if (!rdma_link_local_addr((struct in6_addr *)&ifa->addr))
226 return NOTIFY_DONE;
227 143
228 mutex_lock(&dev->dev_lock); 144 mutex_lock(&dev->dev_lock);
229 switch (event) { 145 switch (event) {
230 case NETDEV_UP: 146 case NETDEV_UP:
231 updated = ocrdma_add_sgid(dev, netdev->dev_addr, is_vlan, vid); 147 updated = ocrdma_add_sgid(dev, gid);
232 break; 148 break;
233 case NETDEV_DOWN: 149 case NETDEV_DOWN:
234 updated = ocrdma_del_sgid(dev, netdev->dev_addr, is_vlan, vid); 150 updated = ocrdma_del_sgid(dev, gid);
235 break; 151 break;
236 default: 152 default:
237 break; 153 break;
@@ -247,6 +163,32 @@ static int ocrdma_inet6addr_event(struct notifier_block *notifier,
247 return NOTIFY_OK; 163 return NOTIFY_OK;
248} 164}
249 165
166static int ocrdma_inetaddr_event(struct notifier_block *notifier,
167 unsigned long event, void *ptr)
168{
169 struct in_ifaddr *ifa = ptr;
170 union ib_gid gid;
171 struct net_device *netdev = ifa->ifa_dev->dev;
172
173 ipv6_addr_set_v4mapped(ifa->ifa_address, (struct in6_addr *)&gid);
174 return ocrdma_addr_event(event, netdev, &gid);
175}
176
177static struct notifier_block ocrdma_inetaddr_notifier = {
178 .notifier_call = ocrdma_inetaddr_event
179};
180
181#if IS_ENABLED(CONFIG_IPV6)
182
183static int ocrdma_inet6addr_event(struct notifier_block *notifier,
184 unsigned long event, void *ptr)
185{
186 struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr;
187 union ib_gid *gid = (union ib_gid *)&ifa->addr;
188 struct net_device *netdev = ifa->idev->dev;
189 return ocrdma_addr_event(event, netdev, gid);
190}
191
250static struct notifier_block ocrdma_inet6addr_notifier = { 192static struct notifier_block ocrdma_inet6addr_notifier = {
251 .notifier_call = ocrdma_inet6addr_event 193 .notifier_call = ocrdma_inet6addr_event
252}; 194};
@@ -423,10 +365,6 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info)
423 if (status) 365 if (status)
424 goto alloc_err; 366 goto alloc_err;
425 367
426 status = ocrdma_build_sgid_tbl(dev);
427 if (status)
428 goto alloc_err;
429
430 status = ocrdma_register_device(dev); 368 status = ocrdma_register_device(dev);
431 if (status) 369 if (status)
432 goto alloc_err; 370 goto alloc_err;
@@ -553,6 +491,10 @@ static int __init ocrdma_init_module(void)
553{ 491{
554 int status; 492 int status;
555 493
494 status = register_inetaddr_notifier(&ocrdma_inetaddr_notifier);
495 if (status)
496 return status;
497
556#if IS_ENABLED(CONFIG_IPV6) 498#if IS_ENABLED(CONFIG_IPV6)
557 status = register_inet6addr_notifier(&ocrdma_inet6addr_notifier); 499 status = register_inet6addr_notifier(&ocrdma_inet6addr_notifier);
558 if (status) 500 if (status)
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 7686dceadd29..aa92f40c9d50 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -1326,7 +1326,8 @@ int ocrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
1326 new_qps = old_qps; 1326 new_qps = old_qps;
1327 spin_unlock_irqrestore(&qp->q_lock, flags); 1327 spin_unlock_irqrestore(&qp->q_lock, flags);
1328 1328
1329 if (!ib_modify_qp_is_ok(old_qps, new_qps, ibqp->qp_type, attr_mask)) { 1329 if (!ib_modify_qp_is_ok(old_qps, new_qps, ibqp->qp_type, attr_mask,
1330 IB_LINK_LAYER_ETHERNET)) {
1330 pr_err("%s(%d) invalid attribute mask=0x%x specified for\n" 1331 pr_err("%s(%d) invalid attribute mask=0x%x specified for\n"
1331 "qpn=0x%x of type=0x%x old_qps=0x%x, new_qps=0x%x\n", 1332 "qpn=0x%x of type=0x%x old_qps=0x%x, new_qps=0x%x\n",
1332 __func__, dev->id, attr_mask, qp->id, ibqp->qp_type, 1333 __func__, dev->id, attr_mask, qp->id, ibqp->qp_type,
diff --git a/drivers/infiniband/hw/qib/qib_qp.c b/drivers/infiniband/hw/qib/qib_qp.c
index 3cca55b51e54..0cad0c40d742 100644
--- a/drivers/infiniband/hw/qib/qib_qp.c
+++ b/drivers/infiniband/hw/qib/qib_qp.c
@@ -585,7 +585,7 @@ int qib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
585 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state; 585 new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
586 586
587 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, 587 if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type,
588 attr_mask)) 588 attr_mask, IB_LINK_LAYER_UNSPECIFIED))
589 goto inval; 589 goto inval;
590 590
591 if (attr_mask & IB_QP_AV) { 591 if (attr_mask & IB_QP_AV) {