Enable QP creation with a given source QP number, the created QP will use the source QPN as its wire QP number. To create such a QP, root privileges (i.e. CAP_NET_RAW) are required from the user application. This comes as a pre-patch for downstream patches in this series to allow user space applications to accelerate traffic which is typically handled by IPoIB ULP.
Unified · Split
| @@ -1383,8 +1383,9 @@ static int create_qp(struct ib_uverbs_file *file, · 1382 unmodified lines | |||
| 1383 | attr.rwq_ind_tbl = ind_tbl; | 1383 | attr.rwq_ind_tbl = ind_tbl; |
| 1384 | } | 1384 | } |
| 1385 | 1385 | ||
| 1386 | if ((cmd_sz >= offsetof(typeof(*cmd), reserved1) + | 1386 | if (cmd_sz > sizeof(*cmd) && |
| 1387 | sizeof(cmd->reserved1)) && cmd->reserved1) { | 1387 | !ib_is_udata_cleared(ucore, sizeof(*cmd), |
| 1388 | cmd_sz - sizeof(*cmd))) { | ||
| 1388 | ret = -EOPNOTSUPP; | 1389 | ret = -EOPNOTSUPP; |
| 1389 | goto err_put; | 1390 | goto err_put; |
| 1390 | } | 1391 | } |
| @@ -1482,11 +1483,21 @@ static int create_qp(struct ib_uverbs_file *file, · 91 unmodified lines | |||
| 1482 | IB_QP_CREATE_MANAGED_SEND | | 1483 | IB_QP_CREATE_MANAGED_SEND | |
| 1483 | IB_QP_CREATE_MANAGED_RECV | | 1484 | IB_QP_CREATE_MANAGED_RECV | |
| 1484 | IB_QP_CREATE_SCATTER_FCS | | 1485 | IB_QP_CREATE_SCATTER_FCS | |
| 1485 | IB_QP_CREATE_CVLAN_STRIPPING)) { | 1486 | IB_QP_CREATE_CVLAN_STRIPPING | |
| 1487 | IB_QP_CREATE_SOURCE_QPN)) { | ||
| 1486 | ret = -EINVAL; | 1488 | ret = -EINVAL; |
| 1487 | goto err_put; | 1489 | goto err_put; |
| 1488 | } | 1490 | } |
| 1489 | 1491 | ||
| 1492 | if (attr.create_flags & IB_QP_CREATE_SOURCE_QPN) { | ||
| 1493 | if (!capable(CAP_NET_RAW)) { | ||
| 1494 | ret = -EPERM; | ||
| 1495 | goto err_put; | ||
| 1496 | } | ||
| 1497 | |||
| 1498 | attr.source_qpn = cmd->source_qpn; | ||
| 1499 | } | ||
| 1500 | |||
| 1490 | buf = (void *)cmd + sizeof(*cmd); | 1501 | buf = (void *)cmd + sizeof(*cmd); |
| 1491 | if (cmd_sz > sizeof(*cmd)) | 1502 | if (cmd_sz > sizeof(*cmd)) |
| 1492 | if (!(buf[0] == 0 && !memcmp(buf, buf + 1, | 1503 | if (!(buf[0] == 0 && !memcmp(buf, buf + 1, |
| @@ -578,7 +578,7 @@ struct ib_uverbs_ex_create_qp { · 577 unmodified lines | |||
| 578 | __u32 comp_mask; | 578 | __u32 comp_mask; |
| 579 | __u32 create_flags; | 579 | __u32 create_flags; |
| 580 | __u32 rwq_ind_tbl_handle; | 580 | __u32 rwq_ind_tbl_handle; |
| 581 | __u32 reserved1; | 581 | __u32 source_qpn; |
| 582 | }; | 582 | }; |
| 583 | 583 | ||
| 584 | struct ib_uverbs_open_qp { | 584 | struct ib_uverbs_open_qp { |