@@ -886,18 +886,17 @@ unsigned int ipmi_addr_length(int addr_type)
886
886
}
887
887
EXPORT_SYMBOL (ipmi_addr_length );
888
888
889
- static void deliver_response (struct ipmi_recv_msg * msg )
889
+ static int deliver_response (struct ipmi_smi * intf , struct ipmi_recv_msg * msg )
890
890
{
891
- if (!msg -> user ) {
892
- struct ipmi_smi * intf = msg -> user_msg_data ;
891
+ int rv = 0 ;
893
892
893
+ if (!msg -> user ) {
894
894
/* Special handling for NULL users. */
895
895
if (intf -> null_user_handler ) {
896
896
intf -> null_user_handler (intf , msg );
897
- ipmi_inc_stat (intf , handled_local_responses );
898
897
} else {
899
898
/* No handler, so give up. */
900
- ipmi_inc_stat ( intf , unhandled_local_responses ) ;
899
+ rv = - EINVAL ;
901
900
}
902
901
ipmi_free_recv_msg (msg );
903
902
} else if (!oops_in_progress ) {
@@ -910,17 +909,28 @@ static void deliver_response(struct ipmi_recv_msg *msg)
910
909
struct ipmi_user * user = msg -> user ;
911
910
user -> handler -> ipmi_recv_hndl (msg , user -> handler_data );
912
911
}
912
+
913
+ return rv ;
913
914
}
914
915
915
- static void
916
- deliver_err_response (struct ipmi_recv_msg * msg , int err )
916
+ static void deliver_local_response (struct ipmi_smi * intf ,
917
+ struct ipmi_recv_msg * msg )
918
+ {
919
+ if (deliver_response (intf , msg ))
920
+ ipmi_inc_stat (intf , unhandled_local_responses );
921
+ else
922
+ ipmi_inc_stat (intf , handled_local_responses );
923
+ }
924
+
925
+ static void deliver_err_response (struct ipmi_smi * intf ,
926
+ struct ipmi_recv_msg * msg , int err )
917
927
{
918
928
msg -> recv_type = IPMI_RESPONSE_RECV_TYPE ;
919
929
msg -> msg_data [0 ] = err ;
920
930
msg -> msg .netfn |= 1 ; /* Convert to a response. */
921
931
msg -> msg .data_len = 1 ;
922
932
msg -> msg .data = msg -> msg_data ;
923
- deliver_response ( msg );
933
+ deliver_local_response ( intf , msg );
924
934
}
925
935
926
936
/*
@@ -1071,7 +1081,7 @@ static int intf_err_seq(struct ipmi_smi *intf,
1071
1081
spin_unlock_irqrestore (& intf -> seq_lock , flags );
1072
1082
1073
1083
if (msg )
1074
- deliver_err_response (msg , err );
1084
+ deliver_err_response (intf , msg , err );
1075
1085
1076
1086
return rv ;
1077
1087
}
@@ -1443,7 +1453,7 @@ int ipmi_set_gets_events(struct ipmi_user *user, bool val)
1443
1453
list_for_each_entry_safe (msg , msg2 , & msgs , link ) {
1444
1454
msg -> user = user ;
1445
1455
kref_get (& user -> refcount );
1446
- deliver_response ( msg );
1456
+ deliver_local_response ( intf , msg );
1447
1457
}
1448
1458
1449
1459
spin_lock_irqsave (& intf -> events_lock , flags );
@@ -3614,7 +3624,7 @@ static void cleanup_smi_msgs(struct ipmi_smi *intf)
3614
3624
ent = & intf -> seq_table [i ];
3615
3625
if (!ent -> inuse )
3616
3626
continue ;
3617
- deliver_err_response (ent -> recv_msg , IPMI_ERR_UNSPECIFIED );
3627
+ deliver_err_response (intf , ent -> recv_msg , IPMI_ERR_UNSPECIFIED );
3618
3628
}
3619
3629
}
3620
3630
@@ -3719,8 +3729,10 @@ static int handle_ipmb_get_msg_rsp(struct ipmi_smi *intf,
3719
3729
recv_msg -> msg .data = recv_msg -> msg_data ;
3720
3730
recv_msg -> msg .data_len = msg -> rsp_size - 10 ;
3721
3731
recv_msg -> recv_type = IPMI_RESPONSE_RECV_TYPE ;
3722
- ipmi_inc_stat (intf , handled_ipmb_responses );
3723
- deliver_response (recv_msg );
3732
+ if (deliver_response (intf , recv_msg ))
3733
+ ipmi_inc_stat (intf , unhandled_ipmb_responses );
3734
+ else
3735
+ ipmi_inc_stat (intf , handled_ipmb_responses );
3724
3736
3725
3737
return 0 ;
3726
3738
}
@@ -3793,9 +3805,6 @@ static int handle_ipmb_get_msg_cmd(struct ipmi_smi *intf,
3793
3805
}
3794
3806
rcu_read_unlock ();
3795
3807
} else {
3796
- /* Deliver the message to the user. */
3797
- ipmi_inc_stat (intf , handled_commands );
3798
-
3799
3808
recv_msg = ipmi_alloc_recv_msg ();
3800
3809
if (!recv_msg ) {
3801
3810
/*
@@ -3831,7 +3840,10 @@ static int handle_ipmb_get_msg_cmd(struct ipmi_smi *intf,
3831
3840
recv_msg -> msg .data_len = msg -> rsp_size - 10 ;
3832
3841
memcpy (recv_msg -> msg_data , & msg -> rsp [9 ],
3833
3842
msg -> rsp_size - 10 );
3834
- deliver_response (recv_msg );
3843
+ if (deliver_response (intf , recv_msg ))
3844
+ ipmi_inc_stat (intf , unhandled_commands );
3845
+ else
3846
+ ipmi_inc_stat (intf , handled_commands );
3835
3847
}
3836
3848
}
3837
3849
@@ -3897,8 +3909,10 @@ static int handle_lan_get_msg_rsp(struct ipmi_smi *intf,
3897
3909
recv_msg -> msg .data = recv_msg -> msg_data ;
3898
3910
recv_msg -> msg .data_len = msg -> rsp_size - 12 ;
3899
3911
recv_msg -> recv_type = IPMI_RESPONSE_RECV_TYPE ;
3900
- ipmi_inc_stat (intf , handled_lan_responses );
3901
- deliver_response (recv_msg );
3912
+ if (deliver_response (intf , recv_msg ))
3913
+ ipmi_inc_stat (intf , unhandled_lan_responses );
3914
+ else
3915
+ ipmi_inc_stat (intf , handled_lan_responses );
3902
3916
3903
3917
return 0 ;
3904
3918
}
@@ -3949,9 +3963,6 @@ static int handle_lan_get_msg_cmd(struct ipmi_smi *intf,
3949
3963
*/
3950
3964
rv = 0 ;
3951
3965
} else {
3952
- /* Deliver the message to the user. */
3953
- ipmi_inc_stat (intf , handled_commands );
3954
-
3955
3966
recv_msg = ipmi_alloc_recv_msg ();
3956
3967
if (!recv_msg ) {
3957
3968
/*
@@ -3989,7 +4000,10 @@ static int handle_lan_get_msg_cmd(struct ipmi_smi *intf,
3989
4000
recv_msg -> msg .data_len = msg -> rsp_size - 12 ;
3990
4001
memcpy (recv_msg -> msg_data , & msg -> rsp [11 ],
3991
4002
msg -> rsp_size - 12 );
3992
- deliver_response (recv_msg );
4003
+ if (deliver_response (intf , recv_msg ))
4004
+ ipmi_inc_stat (intf , unhandled_commands );
4005
+ else
4006
+ ipmi_inc_stat (intf , handled_commands );
3993
4007
}
3994
4008
}
3995
4009
@@ -4057,9 +4071,6 @@ static int handle_oem_get_msg_cmd(struct ipmi_smi *intf,
4057
4071
4058
4072
rv = 0 ;
4059
4073
} else {
4060
- /* Deliver the message to the user. */
4061
- ipmi_inc_stat (intf , handled_commands );
4062
-
4063
4074
recv_msg = ipmi_alloc_recv_msg ();
4064
4075
if (!recv_msg ) {
4065
4076
/*
@@ -4096,7 +4107,10 @@ static int handle_oem_get_msg_cmd(struct ipmi_smi *intf,
4096
4107
recv_msg -> msg .data_len = msg -> rsp_size - 4 ;
4097
4108
memcpy (recv_msg -> msg_data , & msg -> rsp [4 ],
4098
4109
msg -> rsp_size - 4 );
4099
- deliver_response (recv_msg );
4110
+ if (deliver_response (intf , recv_msg ))
4111
+ ipmi_inc_stat (intf , unhandled_commands );
4112
+ else
4113
+ ipmi_inc_stat (intf , handled_commands );
4100
4114
}
4101
4115
}
4102
4116
@@ -4187,7 +4201,7 @@ static int handle_read_event_rsp(struct ipmi_smi *intf,
4187
4201
/* Now deliver all the messages. */
4188
4202
list_for_each_entry_safe (recv_msg , recv_msg2 , & msgs , link ) {
4189
4203
list_del (& recv_msg -> link );
4190
- deliver_response ( recv_msg );
4204
+ deliver_local_response ( intf , recv_msg );
4191
4205
}
4192
4206
} else if (intf -> waiting_events_count < MAX_EVENTS_IN_QUEUE ) {
4193
4207
/*
@@ -4259,7 +4273,7 @@ static int handle_bmc_rsp(struct ipmi_smi *intf,
4259
4273
memcpy (recv_msg -> msg_data , & msg -> rsp [2 ], msg -> rsp_size - 2 );
4260
4274
recv_msg -> msg .data = recv_msg -> msg_data ;
4261
4275
recv_msg -> msg .data_len = msg -> rsp_size - 2 ;
4262
- deliver_response ( recv_msg );
4276
+ deliver_local_response ( intf , recv_msg );
4263
4277
}
4264
4278
4265
4279
return 0 ;
@@ -4336,7 +4350,7 @@ static int handle_one_recv_msg(struct ipmi_smi *intf,
4336
4350
recv_msg -> msg .data = recv_msg -> msg_data ;
4337
4351
recv_msg -> msg .data_len = 1 ;
4338
4352
recv_msg -> msg_data [0 ] = msg -> rsp [2 ];
4339
- deliver_response ( recv_msg );
4353
+ deliver_local_response ( intf , recv_msg );
4340
4354
} else if ((msg -> rsp [0 ] == ((IPMI_NETFN_APP_REQUEST |1 ) << 2 ))
4341
4355
&& (msg -> rsp [1 ] == IPMI_GET_MSG_CMD )) {
4342
4356
struct ipmi_channel * chans ;
@@ -4761,7 +4775,7 @@ static unsigned int ipmi_timeout_handler(struct ipmi_smi *intf,
4761
4775
spin_unlock_irqrestore (& intf -> seq_lock , flags );
4762
4776
4763
4777
list_for_each_entry_safe (msg , msg2 , & timeouts , link )
4764
- deliver_err_response (msg , IPMI_TIMEOUT_COMPLETION_CODE );
4778
+ deliver_err_response (intf , msg , IPMI_TIMEOUT_COMPLETION_CODE );
4765
4779
4766
4780
/*
4767
4781
* Maintenance mode handling. Check the timeout
0 commit comments