spapr-vscsi: Report error on unsupported MAD requests
The existing driver just dropped unsupported requests. This adds error responses to those unhandled requests. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
26573a0c1f
commit
f4ff3b7ba1
|
@ -977,29 +977,43 @@ static int vscsi_send_capabilities(VSCSIState *s, vscsi_req *req)
|
||||||
static int vscsi_handle_mad_req(VSCSIState *s, vscsi_req *req)
|
static int vscsi_handle_mad_req(VSCSIState *s, vscsi_req *req)
|
||||||
{
|
{
|
||||||
union mad_iu *mad = &req->iu.mad;
|
union mad_iu *mad = &req->iu.mad;
|
||||||
|
bool request_handled = false;
|
||||||
|
uint64_t retlen = 0;
|
||||||
|
|
||||||
switch (be32_to_cpu(mad->empty_iu.common.type)) {
|
switch (be32_to_cpu(mad->empty_iu.common.type)) {
|
||||||
case VIOSRP_EMPTY_IU_TYPE:
|
case VIOSRP_EMPTY_IU_TYPE:
|
||||||
fprintf(stderr, "Unsupported EMPTY MAD IU\n");
|
fprintf(stderr, "Unsupported EMPTY MAD IU\n");
|
||||||
|
retlen = sizeof(mad->empty_iu);
|
||||||
break;
|
break;
|
||||||
case VIOSRP_ERROR_LOG_TYPE:
|
case VIOSRP_ERROR_LOG_TYPE:
|
||||||
fprintf(stderr, "Unsupported ERROR LOG MAD IU\n");
|
fprintf(stderr, "Unsupported ERROR LOG MAD IU\n");
|
||||||
mad->error_log.common.status = cpu_to_be16(1);
|
retlen = sizeof(mad->error_log);
|
||||||
vscsi_send_iu(s, req, sizeof(mad->error_log), VIOSRP_MAD_FORMAT);
|
|
||||||
break;
|
break;
|
||||||
case VIOSRP_ADAPTER_INFO_TYPE:
|
case VIOSRP_ADAPTER_INFO_TYPE:
|
||||||
vscsi_send_adapter_info(s, req);
|
vscsi_send_adapter_info(s, req);
|
||||||
|
request_handled = true;
|
||||||
break;
|
break;
|
||||||
case VIOSRP_HOST_CONFIG_TYPE:
|
case VIOSRP_HOST_CONFIG_TYPE:
|
||||||
mad->host_config.common.status = cpu_to_be16(1);
|
retlen = sizeof(mad->host_config);
|
||||||
vscsi_send_iu(s, req, sizeof(mad->host_config), VIOSRP_MAD_FORMAT);
|
|
||||||
break;
|
break;
|
||||||
case VIOSRP_CAPABILITIES_TYPE:
|
case VIOSRP_CAPABILITIES_TYPE:
|
||||||
vscsi_send_capabilities(s, req);
|
vscsi_send_capabilities(s, req);
|
||||||
|
request_handled = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "VSCSI: Unknown MAD type %02x\n",
|
fprintf(stderr, "VSCSI: Unknown MAD type %02x\n",
|
||||||
be32_to_cpu(mad->empty_iu.common.type));
|
be32_to_cpu(mad->empty_iu.common.type));
|
||||||
|
/*
|
||||||
|
* PAPR+ says that "The length field is set to the length
|
||||||
|
* of the data structure(s) used in the command".
|
||||||
|
* As we did not recognize the request type, put zero there.
|
||||||
|
*/
|
||||||
|
retlen = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!request_handled) {
|
||||||
|
mad->empty_iu.common.status = cpu_to_be16(VIOSRP_MAD_NOT_SUPPORTED);
|
||||||
|
vscsi_send_iu(s, req, retlen, VIOSRP_MAD_FORMAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue