[bug report] IB/mlx4: Add support for steerable IB UD QPs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[ Ancient code.  No idea why this is only showing up now...  -dan ]

Hello Matan Barak,

The patch c1c98501121e: "IB/mlx4: Add support for steerable IB UD
QPs" from Nov 7, 2013, leads to the following Smatch static checker
warning:

	drivers/infiniband/hw/mlx4/qp.c:1103 create_qp_common()
	warn: missing error code 'err'

drivers/infiniband/hw/mlx4/qp.c
    952 static int create_qp_common(struct ib_pd *pd, struct ib_qp_init_attr *init_attr,
    953                             struct ib_udata *udata, int sqpn,
    954                             struct mlx4_ib_qp *qp)
    955 {
    956         struct mlx4_ib_dev *dev = to_mdev(pd->device);
    957         int qpn;
    958         int err;
    959         struct mlx4_ib_ucontext *context = rdma_udata_to_drv_context(
    960                 udata, struct mlx4_ib_ucontext, ibucontext);
    961         enum mlx4_ib_qp_type qp_type = (enum mlx4_ib_qp_type) init_attr->qp_type;
    962         struct mlx4_ib_cq *mcq;
    963         unsigned long flags;
    964 
    965         /* When tunneling special qps, we use a plain UD qp */
    966         if (sqpn) {
    967                 if (mlx4_is_mfunc(dev->dev) &&
    968                     (!mlx4_is_master(dev->dev) ||
    969                      !(init_attr->create_flags & MLX4_IB_SRIOV_SQP))) {
    970                         if (init_attr->qp_type == IB_QPT_GSI)
    971                                 qp_type = MLX4_IB_QPT_PROXY_GSI;
    972                         else {
    973                                 if (mlx4_is_master(dev->dev) ||
    974                                     qp0_enabled_vf(dev->dev, sqpn))
    975                                         qp_type = MLX4_IB_QPT_PROXY_SMI_OWNER;
    976                                 else
    977                                         qp_type = MLX4_IB_QPT_PROXY_SMI;
    978                         }
    979                 }
    980                 qpn = sqpn;
    981                 /* add extra sg entry for tunneling */
    982                 init_attr->cap.max_recv_sge++;
    983         } else if (init_attr->create_flags & MLX4_IB_SRIOV_TUNNEL_QP) {
    984                 struct mlx4_ib_qp_tunnel_init_attr *tnl_init =
    985                         container_of(init_attr,
    986                                      struct mlx4_ib_qp_tunnel_init_attr, init_attr);
    987                 if ((tnl_init->proxy_qp_type != IB_QPT_SMI &&
    988                      tnl_init->proxy_qp_type != IB_QPT_GSI)   ||
    989                     !mlx4_is_master(dev->dev))
    990                         return -EINVAL;
    991                 if (tnl_init->proxy_qp_type == IB_QPT_GSI)
    992                         qp_type = MLX4_IB_QPT_TUN_GSI;
    993                 else if (tnl_init->slave == mlx4_master_func_num(dev->dev) ||
    994                          mlx4_vf_smi_enabled(dev->dev, tnl_init->slave,
    995                                              tnl_init->port))
    996                         qp_type = MLX4_IB_QPT_TUN_SMI_OWNER;
    997                 else
    998                         qp_type = MLX4_IB_QPT_TUN_SMI;
    999                 /* we are definitely in the PPF here, since we are creating
    1000                  * tunnel QPs. base_tunnel_sqpn is therefore valid. */
    1001                 qpn = dev->dev->phys_caps.base_tunnel_sqpn + 8 * tnl_init->slave
    1002                         + tnl_init->proxy_qp_type * 2 + tnl_init->port - 1;
    1003                 sqpn = qpn;
    1004         }
    1005 
    1006         if (init_attr->qp_type == IB_QPT_SMI ||
    1007             init_attr->qp_type == IB_QPT_GSI || qp_type == MLX4_IB_QPT_SMI ||
    1008             qp_type == MLX4_IB_QPT_GSI ||
    1009             (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER |
    1010                         MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) {
    1011                 qp->sqp = kzalloc(sizeof(struct mlx4_ib_sqp), GFP_KERNEL);
    1012                 if (!qp->sqp)
    1013                         return -ENOMEM;
    1014         }
    1015 
    1016         qp->mlx4_ib_qp_type = qp_type;
    1017 
    1018         spin_lock_init(&qp->sq.lock);
    1019         spin_lock_init(&qp->rq.lock);
    1020         INIT_LIST_HEAD(&qp->gid_list);
    1021         INIT_LIST_HEAD(&qp->steering_rules);
    1022 
    1023         qp->state = IB_QPS_RESET;
    1024         if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR)
    1025                 qp->sq_signal_bits = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE);
    1026 
    1027         if (udata) {
    1028                 struct mlx4_ib_create_qp ucmd;
    1029                 size_t copy_len;
    1030                 int shift;
    1031                 int n;
    1032 
    1033                 copy_len = sizeof(struct mlx4_ib_create_qp);
    1034 
    1035                 if (ib_copy_from_udata(&ucmd, udata, copy_len)) {
    1036                         err = -EFAULT;
    1037                         goto err;
    1038                 }
    1039 
    1040                 qp->inl_recv_sz = ucmd.inl_recv_sz;
    1041 
    1042                 if (init_attr->create_flags & IB_QP_CREATE_SCATTER_FCS) {
    1043                         if (!(dev->dev->caps.flags &
    1044                               MLX4_DEV_CAP_FLAG_FCS_KEEP)) {
    1045                                 pr_debug("scatter FCS is unsupported\n");
    1046                                 err = -EOPNOTSUPP;
    1047                                 goto err;
    1048                         }
    1049 
    1050                         qp->flags |= MLX4_IB_QP_SCATTER_FCS;
    1051                 }
    1052 
    1053                 err = set_rq_size(dev, &init_attr->cap, udata,
    1054                                   qp_has_rq(init_attr), qp, qp->inl_recv_sz);
    1055                 if (err)
    1056                         goto err;
    1057 
    1058                 qp->sq_no_prefetch = ucmd.sq_no_prefetch;
    1059 
    1060                 err = set_user_sq_size(dev, qp, &ucmd);
    1061                 if (err)
    1062                         goto err;
    1063 
    1064                 qp->umem =
    1065                         ib_umem_get(pd->device, ucmd.buf_addr, qp->buf_size, 0);
    1066                 if (IS_ERR(qp->umem)) {
    1067                         err = PTR_ERR(qp->umem);
    1068                         goto err;
    1069                 }
    1070 
    1071                 shift = mlx4_ib_umem_calc_optimal_mtt_size(qp->umem, 0, &n);
    1072                 err = mlx4_mtt_init(dev->dev, n, shift, &qp->mtt);
    1073 
    1074                 if (err)
    1075                         goto err_buf;
    1076 
    1077                 err = mlx4_ib_umem_write_mtt(dev, &qp->mtt, qp->umem);
    1078                 if (err)
    1079                         goto err_mtt;
    1080 
    1081                 if (qp_has_rq(init_attr)) {
    1082                         err = mlx4_ib_db_map_user(udata, ucmd.db_addr, &qp->db);
    1083                         if (err)
    1084                                 goto err_mtt;
    1085                 }
    1086                 qp->mqp.usage = MLX4_RES_USAGE_USER_VERBS;
    1087         } else {
    1088                 err = set_rq_size(dev, &init_attr->cap, udata,
    1089                                   qp_has_rq(init_attr), qp, 0);
    1090                 if (err)
    1091                         goto err;
    1092 
    1093                 qp->sq_no_prefetch = 0;
    1094 
    1095                 if (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO)
    1096                         qp->flags |= MLX4_IB_QP_LSO;
    1097 
    1098                 if (init_attr->create_flags & IB_QP_CREATE_NETIF_QP) {
    1099                         if (dev->steering_support ==
    1100                             MLX4_STEERING_MODE_DEVICE_MANAGED)
    1101                                 qp->flags |= MLX4_IB_QP_NETIF;
    1102                         else
--> 1103                                 goto err;
                                         ^^^^^^^^
It looks like this should have an error code.

    1104                 }
    1105 
    1106                 err = set_kernel_sq_size(dev, &init_attr->cap, qp_type, qp);
    1107                 if (err)
    1108                         goto err;
    1109 
    1110                 if (qp_has_rq(init_attr)) {
    1111                         err = mlx4_db_alloc(dev->dev, &qp->db, 0);
    1112                         if (err)
    1113                                 goto err;
    1114 
    1115                         *qp->db.db = 0;
    1116                 }
    1117 
    1118                 if (mlx4_buf_alloc(dev->dev, qp->buf_size,  PAGE_SIZE * 2,
    1119                                    &qp->buf)) {
    1120                         err = -ENOMEM;
    1121                         goto err_db;
    1122                 }
    1123 
    1124                 err = mlx4_mtt_init(dev->dev, qp->buf.npages, qp->buf.page_shift,
    1125                                     &qp->mtt);
    1126                 if (err)
    1127                         goto err_buf;
    1128 
    1129                 err = mlx4_buf_write_mtt(dev->dev, &qp->mtt, &qp->buf);
    1130                 if (err)
    1131                         goto err_mtt;
    1132 
    1133                 qp->sq.wrid = kvmalloc_array(qp->sq.wqe_cnt,
    1134                                              sizeof(u64), GFP_KERNEL);
    1135                 qp->rq.wrid = kvmalloc_array(qp->rq.wqe_cnt,
    1136                                              sizeof(u64), GFP_KERNEL);
    1137                 if (!qp->sq.wrid || !qp->rq.wrid) {
    1138                         err = -ENOMEM;
    1139                         goto err_wrid;
    1140                 }
    1141                 qp->mqp.usage = MLX4_RES_USAGE_DRIVER;
    1142         }
    1143 
    1144         if (sqpn) {
    1145                 if (qp->mlx4_ib_qp_type & (MLX4_IB_QPT_PROXY_SMI_OWNER |
    1146                     MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI)) {
    1147                         if (alloc_proxy_bufs(pd->device, qp)) {
    1148                                 err = -ENOMEM;
    1149                                 goto err_wrid;
    1150                         }
    1151                 }
    1152         } else {
    1153                 /* Raw packet QPNs may not have bits 6,7 set in their qp_num;
    1154                  * otherwise, the WQE BlueFlame setup flow wrongly causes
    1155                  * VLAN insertion. */
    1156                 if (init_attr->qp_type == IB_QPT_RAW_PACKET)
    1157                         err = mlx4_qp_reserve_range(dev->dev, 1, 1, &qpn,
    1158                                                     (init_attr->cap.max_send_wr ?
    1159                                                      MLX4_RESERVE_ETH_BF_QP : 0) |
    1160                                                     (init_attr->cap.max_recv_wr ?
    1161                                                      MLX4_RESERVE_A0_QP : 0),
    1162                                                     qp->mqp.usage);
    1163                 else
    1164                         if (qp->flags & MLX4_IB_QP_NETIF)
    1165                                 err = mlx4_ib_steer_qp_alloc(dev, 1, &qpn);
    1166                         else
    1167                                 err = mlx4_qp_reserve_range(dev->dev, 1, 1,
    1168                                                             &qpn, 0, qp->mqp.usage);
    1169                 if (err)
    1170                         goto err_proxy;
    1171         }
    1172 
    1173         if (init_attr->create_flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK)
    1174                 qp->flags |= MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK;
    1175 
    1176         err = mlx4_qp_alloc(dev->dev, qpn, &qp->mqp);
    1177         if (err)
    1178                 goto err_qpn;
    1179 
    1180         if (init_attr->qp_type == IB_QPT_XRC_TGT)
    1181                 qp->mqp.qpn |= (1 << 23);
    1182 
    1183         /*
    1184          * Hardware wants QPN written in big-endian order (after
    1185          * shifting) for send doorbell.  Precompute this value to save
    1186          * a little bit when posting sends.
    1187          */
    1188         qp->doorbell_qpn = swab32(qp->mqp.qpn << 8);
    1189 
    1190         qp->mqp.event = mlx4_ib_qp_event;
    1191 
    1192         spin_lock_irqsave(&dev->reset_flow_resource_lock, flags);
    1193         mlx4_ib_lock_cqs(to_mcq(init_attr->send_cq),
    1194                          to_mcq(init_attr->recv_cq));
    1195         /* Maintain device to QPs access, needed for further handling
    1196          * via reset flow
    1197          */
    1198         list_add_tail(&qp->qps_list, &dev->qp_list);
    1199         /* Maintain CQ to QPs access, needed for further handling
    1200          * via reset flow
    1201          */
    1202         mcq = to_mcq(init_attr->send_cq);
    1203         list_add_tail(&qp->cq_send_list, &mcq->send_qp_list);
    1204         mcq = to_mcq(init_attr->recv_cq);
    1205         list_add_tail(&qp->cq_recv_list, &mcq->recv_qp_list);
    1206         mlx4_ib_unlock_cqs(to_mcq(init_attr->send_cq),
    1207                            to_mcq(init_attr->recv_cq));
    1208         spin_unlock_irqrestore(&dev->reset_flow_resource_lock, flags);
    1209         return 0;
    1210 
    1211 err_qpn:
    1212         if (!sqpn) {
    1213                 if (qp->flags & MLX4_IB_QP_NETIF)
    1214                         mlx4_ib_steer_qp_free(dev, qpn, 1);
    1215                 else
    1216                         mlx4_qp_release_range(dev->dev, qpn, 1);
    1217         }
    1218 err_proxy:
    1219         if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_PROXY_GSI)
    1220                 free_proxy_bufs(pd->device, qp);
    1221 err_wrid:
    1222         if (udata) {
    1223                 if (qp_has_rq(init_attr))
    1224                         mlx4_ib_db_unmap_user(context, &qp->db);
    1225         } else {
    1226                 kvfree(qp->sq.wrid);
    1227                 kvfree(qp->rq.wrid);
    1228         }
    1229 
    1230 err_mtt:
    1231         mlx4_mtt_cleanup(dev->dev, &qp->mtt);
    1232 
    1233 err_buf:
    1234         if (!qp->umem)
    1235                 mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf);
    1236         ib_umem_release(qp->umem);
    1237 
    1238 err_db:
    1239         if (!udata && qp_has_rq(init_attr))
    1240                 mlx4_db_free(dev->dev, &qp->db);
    1241 
    1242 err:
    1243         kfree(qp->sqp);
    1244         return err;
    1245 }

regards,
dan carpenter



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux