Re: [PATCH V3 for-next 02/13] RDMA/hns: Optimize hns_roce_modify_qp function

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

 



On Sat, 2019-08-03 at 16:45 +0800, Lijun Ou wrote:
> +static int hns_roce_check_qp_attr(struct ib_qp *ibqp, struct
> ib_qp_attr *attr,
> +                                 int attr_mask)
> +{
> +       struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
> +       struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
> +       int ret = 0;
> +       int p;
>  
>         if ((attr_mask & IB_QP_PORT) &&
>             (attr->port_num == 0 || attr->port_num > hr_dev-
> >caps.num_ports)) {
> -               dev_err(dev, "attr port_num invalid.attr-
> >port_num=%d\n",
> +               ibdev_err(&hr_dev->ib_dev,
> +                       "attr port_num invalid.attr->port_num=%d\n",
>                         attr->port_num);
> -               goto out;
> +               return -EINVAL;
>         }
>  
>         if (attr_mask & IB_QP_PKEY_INDEX) {
>                 p = attr_mask & IB_QP_PORT ? (attr->port_num - 1) :
> hr_qp->port;
>                 if (attr->pkey_index >= hr_dev-
> >caps.pkey_table_len[p]) {
> -                       dev_err(dev, "attr pkey_index invalid.attr-
> >pkey_index=%d\n",
> +                       ibdev_err(&hr_dev->ib_dev,
> +                               "attr pkey_index invalid.attr-
> >pkey_index=%d\n",
>                                 attr->pkey_index);
> -                       goto out;
> +                       return -EINVAL;
>                 }
>         }
>  
>         if (attr_mask & IB_QP_PATH_MTU) {
> -               p = attr_mask & IB_QP_PORT ? (attr->port_num - 1) :
> hr_qp->port;
> -               active_mtu = iboe_get_mtu(hr_dev->iboe.netdevs[p]-
> >mtu);
> -
> -               if ((hr_dev->caps.max_mtu == IB_MTU_4096 &&
> -                   attr->path_mtu > IB_MTU_4096) ||
> -                   (hr_dev->caps.max_mtu == IB_MTU_2048 &&
> -                   attr->path_mtu > IB_MTU_2048) ||
> -                   attr->path_mtu < IB_MTU_256 ||
> -                   attr->path_mtu > active_mtu) {
> -                       dev_err(dev, "attr path_mtu(%d)invalid while
> modify qp",
> -                               attr->path_mtu);
> -                       goto out;
> -               }
> +               ret = check_mtu_validate(hr_dev, hr_qp, attr,
> attr_mask);
> +               if (ret)
> +                       return ret;
>         }

If you make this the last test in the function, you can completely
eliminate the use of the ret variable and instead do:

if (attr_mask & IB_QP_PATH_MTU) {
   ...
   return check_mtu_validate(hr_dev, hr_qp, attr, attr_mask);
}

return 0;

>  
>         if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
>             attr->max_rd_atomic > hr_dev->caps.max_qp_init_rdma) {
> -               dev_err(dev, "attr max_rd_atomic invalid.attr-
> >max_rd_atomic=%d\n",
> +               ibdev_err(&hr_dev->ib_dev,
> +                       "attr max_rd_atomic invalid.attr-
> >max_rd_atomic=%d\n",
>                         attr->max_rd_atomic);
> -               goto out;
> +               return -EINVAL;
>         }
>  
>         if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC &&
>             attr->max_dest_rd_atomic > hr_dev->caps.max_qp_dest_rdma)
> {
> -               dev_err(dev, "attr max_dest_rd_atomic invalid.attr-
> >max_dest_rd_atomic=%d\n",
> +               ibdev_err(&hr_dev->ib_dev,
> +                       "attr max_dest_rd_atomic invalid.attr-
> >max_dest_rd_atomic=%d\n",
>                         attr->max_dest_rd_atomic);
> +               return -EINVAL;
> +       }
> +
> +       return ret;
> +}

-- 
Doug Ledford <dledford@xxxxxxxxxx>
    GPG KeyID: B826A3330E572FDD
    Fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

Attachment: signature.asc
Description: This is a digitally signed message part


[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