@@ -83,6 +83,8 @@ EXPORT_SYMBOL(ibcm_reject_msg);
83
83
struct cm_id_private ;
84
84
static void cm_add_one (struct ib_device * device );
85
85
static void cm_remove_one (struct ib_device * device , void * client_data );
86
+ static int cm_send_sidr_rep_locked (struct cm_id_private * cm_id_priv ,
87
+ struct ib_cm_sidr_rep_param * param );
86
88
static int cm_send_dreq_locked (struct cm_id_private * cm_id_priv ,
87
89
const void * private_data , u8 private_data_len );
88
90
static int cm_send_drep_locked (struct cm_id_private * cm_id_priv ,
@@ -830,16 +832,6 @@ static struct cm_id_private * cm_insert_remote_sidr(struct cm_id_private
830
832
return NULL ;
831
833
}
832
834
833
- static void cm_reject_sidr_req (struct cm_id_private * cm_id_priv ,
834
- enum ib_cm_sidr_status status )
835
- {
836
- struct ib_cm_sidr_rep_param param ;
837
-
838
- memset (& param , 0 , sizeof param );
839
- param .status = status ;
840
- ib_send_cm_sidr_rep (& cm_id_priv -> id , & param );
841
- }
842
-
843
835
static struct cm_id_private * cm_alloc_id_priv (struct ib_device * device ,
844
836
ib_cm_handler cm_handler ,
845
837
void * context )
@@ -1058,8 +1050,10 @@ static void cm_destroy_id(struct ib_cm_id *cm_id, int err)
1058
1050
spin_unlock_irq (& cm_id_priv -> lock );
1059
1051
break ;
1060
1052
case IB_CM_SIDR_REQ_RCVD :
1053
+ cm_send_sidr_rep_locked (cm_id_priv ,
1054
+ & (struct ib_cm_sidr_rep_param ){
1055
+ .status = IB_SIDR_REJECT });
1061
1056
spin_unlock_irq (& cm_id_priv -> lock );
1062
- cm_reject_sidr_req (cm_id_priv , IB_SIDR_REJECT );
1063
1057
break ;
1064
1058
case IB_CM_REQ_SENT :
1065
1059
case IB_CM_MRA_REQ_RCVD :
@@ -3640,7 +3634,9 @@ static int cm_sidr_req_handler(struct cm_work *work)
3640
3634
cm_id_priv -> id .service_id );
3641
3635
if (!listen_cm_id_priv ) {
3642
3636
spin_unlock_irq (& cm .lock );
3643
- cm_reject_sidr_req (cm_id_priv , IB_SIDR_UNSUPPORTED );
3637
+ ib_send_cm_sidr_rep (& cm_id_priv -> id ,
3638
+ & (struct ib_cm_sidr_rep_param ){
3639
+ .status = IB_SIDR_UNSUPPORTED });
3644
3640
goto out ; /* No match. */
3645
3641
}
3646
3642
refcount_inc (& listen_cm_id_priv -> refcount );
@@ -3694,50 +3690,52 @@ static void cm_format_sidr_rep(struct cm_sidr_rep_msg *sidr_rep_msg,
3694
3690
param -> private_data , param -> private_data_len );
3695
3691
}
3696
3692
3697
- int ib_send_cm_sidr_rep (struct ib_cm_id * cm_id ,
3698
- struct ib_cm_sidr_rep_param * param )
3693
+ static int cm_send_sidr_rep_locked (struct cm_id_private * cm_id_priv ,
3694
+ struct ib_cm_sidr_rep_param * param )
3699
3695
{
3700
- struct cm_id_private * cm_id_priv ;
3701
3696
struct ib_mad_send_buf * msg ;
3702
- unsigned long flags ;
3703
3697
int ret ;
3704
3698
3699
+ lockdep_assert_held (& cm_id_priv -> lock );
3700
+
3705
3701
if ((param -> info && param -> info_length > IB_CM_SIDR_REP_INFO_LENGTH ) ||
3706
3702
(param -> private_data &&
3707
3703
param -> private_data_len > IB_CM_SIDR_REP_PRIVATE_DATA_SIZE ))
3708
3704
return - EINVAL ;
3709
3705
3710
- cm_id_priv = container_of (cm_id , struct cm_id_private , id );
3711
- spin_lock_irqsave (& cm_id_priv -> lock , flags );
3712
- if (cm_id -> state != IB_CM_SIDR_REQ_RCVD ) {
3713
- ret = - EINVAL ;
3714
- goto error ;
3715
- }
3706
+ if (cm_id_priv -> id .state != IB_CM_SIDR_REQ_RCVD )
3707
+ return - EINVAL ;
3716
3708
3717
3709
ret = cm_alloc_msg (cm_id_priv , & msg );
3718
3710
if (ret )
3719
- goto error ;
3711
+ return ret ;
3720
3712
3721
3713
cm_format_sidr_rep ((struct cm_sidr_rep_msg * ) msg -> mad , cm_id_priv ,
3722
3714
param );
3723
3715
ret = ib_post_send_mad (msg , NULL );
3724
3716
if (ret ) {
3725
- spin_unlock_irqrestore (& cm_id_priv -> lock , flags );
3726
3717
cm_free_msg (msg );
3727
3718
return ret ;
3728
3719
}
3729
- cm_id -> state = IB_CM_IDLE ;
3730
- spin_unlock_irqrestore (& cm_id_priv -> lock , flags );
3731
-
3732
- spin_lock_irqsave (& cm .lock , flags );
3720
+ cm_id_priv -> id .state = IB_CM_IDLE ;
3733
3721
if (!RB_EMPTY_NODE (& cm_id_priv -> sidr_id_node )) {
3734
3722
rb_erase (& cm_id_priv -> sidr_id_node , & cm .remote_sidr_table );
3735
3723
RB_CLEAR_NODE (& cm_id_priv -> sidr_id_node );
3736
3724
}
3737
- spin_unlock_irqrestore (& cm .lock , flags );
3738
3725
return 0 ;
3726
+ }
3739
3727
3740
- error : spin_unlock_irqrestore (& cm_id_priv -> lock , flags );
3728
+ int ib_send_cm_sidr_rep (struct ib_cm_id * cm_id ,
3729
+ struct ib_cm_sidr_rep_param * param )
3730
+ {
3731
+ struct cm_id_private * cm_id_priv =
3732
+ container_of (cm_id , struct cm_id_private , id );
3733
+ unsigned long flags ;
3734
+ int ret ;
3735
+
3736
+ spin_lock_irqsave (& cm_id_priv -> lock , flags );
3737
+ ret = cm_send_sidr_rep_locked (cm_id_priv , param );
3738
+ spin_unlock_irqrestore (& cm_id_priv -> lock , flags );
3741
3739
return ret ;
3742
3740
}
3743
3741
EXPORT_SYMBOL (ib_send_cm_sidr_rep );
0 commit comments