RE: [PATCH rdma-next 4/4] RDMA/verbs: Simplify modify QP check

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

 




> -----Original Message-----
> From: linux-rdma-owner@xxxxxxxxxxxxxxx [mailto:linux-rdma-
> owner@xxxxxxxxxxxxxxx] On Behalf Of Leon Romanovsky
> Sent: Sunday, March 11, 2018 6:52 AM
> To: Doug Ledford <dledford@xxxxxxxxxx>; Jason Gunthorpe
> <jgg@xxxxxxxxxxxx>
> Cc: Leon Romanovsky <leonro@xxxxxxxxxxxx>; RDMA mailing list <linux-
> rdma@xxxxxxxxxxxxxxx>; Maor Gottlieb <maorg@xxxxxxxxxxxx>
> Subject: [PATCH rdma-next 4/4] RDMA/verbs: Simplify modify QP check
> 
> From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> 
> All callers to ib_modify_qp_is_ok() provides enum ib_qp_state makes the checks
> of out-of-scope redundant. Let's remove them together with updating function
> signature to return boolean result.
> 
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> ---
>  drivers/infiniband/core/verbs.c | 20 ++++++++------------
>  include/rdma/ib_verbs.h         |  6 +++---
>  2 files changed, 11 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> index 873b7aa9e8dd..f7de886da430 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -1263,34 +1263,30 @@ static const struct {
>  	}
>  };
> 
> -int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state
> next_state,
> -		       enum ib_qp_type type, enum ib_qp_attr_mask mask,
> -		       enum rdma_link_layer ll)
> +bool ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state
> next_state,
> +			enum ib_qp_type type, enum ib_qp_attr_mask mask,
> +			enum rdma_link_layer ll)
>  {
>  	enum ib_qp_attr_mask req_param, opt_param;
> 
> -	if (cur_state  < 0 || cur_state  > IB_QPS_ERR ||
> -	    next_state < 0 || next_state > IB_QPS_ERR)
> -		return 0;
> -
>  	if (mask & IB_QP_CUR_STATE  &&
>  	    cur_state != IB_QPS_RTR && cur_state != IB_QPS_RTS &&
>  	    cur_state != IB_QPS_SQD && cur_state != IB_QPS_SQE)
> -		return 0;
> +		return false;
> 
>  	if (!qp_state_table[cur_state][next_state].valid)
> -		return 0;
> +		return false;
> 
>  	req_param = qp_state_table[cur_state][next_state].req_param[type];
>  	opt_param = qp_state_table[cur_state][next_state].opt_param[type];
> 
>  	if ((mask & req_param) != req_param)
> -		return 0;
> +		return false;
> 
>  	if (mask & ~(req_param | opt_param | IB_QP_STATE))
> -		return 0;
> +		return false;
> 
> -	return 1;
> +	return true;
>  }
>  EXPORT_SYMBOL(ib_modify_qp_is_ok);
> 
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index
> 5ff4eeaa19cb..ac3791e056cf 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -2480,9 +2480,9 @@ static inline bool ib_is_udata_cleared(struct ib_udata
> *udata,
>   * transition from cur_state to next_state is allowed by the IB spec,
>   * and that the attribute mask supplied is allowed for the transition.
>   */
> -int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state
> next_state,
> -		       enum ib_qp_type type, enum ib_qp_attr_mask mask,
> -		       enum rdma_link_layer ll);
> +bool ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state
> next_state,
> +			enum ib_qp_type type, enum ib_qp_attr_mask mask,
> +			enum rdma_link_layer ll);
> 
>  void ib_register_event_handler(struct ib_event_handler *event_handler);  void
> ib_unregister_event_handler(struct ib_event_handler *event_handler);
> --
> 2.16.2

ib_modify_qp_is_ok input field link layer field is not used.
Do you want to refactor that as well here or in different patch?
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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