Changeset 4fa5342 in mainline


Ignore:
Timestamp:
2017-07-13T18:59:25Z (7 years ago)
Author:
Jaroslav Jindrak <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
05aeee0e
Parents:
c9ce62a
Message:

Added more compact way to report error codes similar to the trb type reporting one.

Location:
uspace/drv/bus/usb/xhci
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/commands.c

    rc9ce62a r4fa5342  
    6363}
    6464
     65static const char *trb_codes [] = {
     66#define TRBC(t) [XHCI_TRBC_##t] = #t
     67        TRBC(INVALID),
     68        TRBC(SUCCESS),
     69        TRBC(DATA_BUFFER_ERROR),
     70        TRBC(BABBLE_DETECTED_ERROR),
     71        TRBC(USB_TRANSACTION_ERROR),
     72        TRBC(TRB_ERROR),
     73        TRBC(STALL_ERROR),
     74        TRBC(RESOURCE_ERROR),
     75        TRBC(BANDWIDTH_ERROR),
     76        TRBC(NO_SLOTS_ERROR),
     77        TRBC(INVALID_STREAM_ERROR),
     78        TRBC(SLOT_NOT_ENABLED_ERROR),
     79        TRBC(EP_NOT_ENABLED_ERROR),
     80        TRBC(SHORT_PACKET),
     81        TRBC(RING_UNDERRUN),
     82        TRBC(RING_OVERRUN),
     83        TRBC(VF_EVENT_RING_FULL),
     84        TRBC(PARAMETER_ERROR),
     85        TRBC(BANDWIDTH_OVERRUN_ERROR),
     86        TRBC(CONTEXT_STATE_ERROR),
     87        TRBC(NO_PING_RESPONSE_ERROR),
     88        TRBC(EVENT_RING_FULL_ERROR),
     89        TRBC(INCOMPATIBLE_DEVICE_ERROR),
     90        TRBC(MISSED_SERVICE_ERROR),
     91        TRBC(COMMAND_RING_STOPPED),
     92        TRBC(COMMAND_ABORTED),
     93        TRBC(STOPPED),
     94        TRBC(STOPPED_LENGTH_INVALID),
     95        TRBC(STOPPED_SHORT_PACKET),
     96        TRBC(MAX_EXIT_LATENCY_TOO_LARGE_ERROR),
     97        [30] = "<reserved>",
     98        TRBC(ISOCH_BUFFER_OVERRUN),
     99        TRBC(EVENT_LOST_ERROR),
     100        TRBC(UNDEFINED_ERROR),
     101        TRBC(INVALID_STREAM_ID_ERROR),
     102        TRBC(SECONDARY_BANDWIDTH_ERROR),
     103        TRBC(SPLIT_TRANSACTION_ERROR),
     104        [XHCI_TRBC_MAX] = NULL
     105#undef TRBC
     106};
     107
     108static void report_error(int code)
     109{
     110        if (code < XHCI_TRBC_MAX && trb_codes[code] != NULL)
     111                usb_log_error("Command resulted in error: %s.", trb_codes[code]);
     112        else
     113                usb_log_error("Command resulted in reserved or vendor specific error.");
     114}
     115
    65116int xhci_send_no_op_command(xhci_hc_t *hc)
    66117{
     
    164215}
    165216
    166 static int report_error(int code)
    167 {
    168         // TODO: Order these by their value.
    169         switch (code) {
    170         case XHCI_TRBC_NO_SLOTS_ERROR:
    171                 usb_log_error("Device slot not available.");
    172                 break;
    173         case XHCI_TRBC_SLOT_NOT_ENABLE_ERROR:
    174                 usb_log_error("Slot ID is not enabled.");
    175                 break;
    176         case XHCI_TRBC_CONTEXT_STATE_ERROR:
    177                 usb_log_error("Slot is not in enabled or default state.");
    178                 break;
    179         case XHCI_TRBC_TRANSACTION_ERROR:
    180                 usb_log_error("Request to the USB device failed.");
    181                 break;
    182         case XHCI_TRBC_BANDWIDTH_ERROR:
    183                 usb_log_error("Bandwidth required is not available.");
    184                 break;
    185         case XHCI_TRBC_SECONDARY_BANDWIDTH_ERROR:
    186                 usb_log_error("Bandwidth error encountered in secondary domain.");
    187                 break;
    188         case XHCI_TRBC_RESOURCE_ERROR:
    189                 usb_log_error("Resource required is not available.");
    190                 break;
    191         case XHCI_TRBC_PARAMETER_ERROR:
    192                 usb_log_error("Parameter given is invalid.");
    193                 break;
    194         default:
    195                 usb_log_error("Unknown error code.");
    196                 break;
    197         }
    198         return ENAK;
    199 }
    200 
    201217int xhci_handle_command_completion(xhci_hc_t *hc, xhci_trb_t *trb)
    202218{
     
    211227        command = (xhci_trb_t *) XHCI_QWORD_EXTRACT(trb->parameter, 63, 4);
    212228        slot_id = XHCI_DWORD_EXTRACT(trb->control, 31, 24);
     229        (void) slot_id;
    213230
    214231        if (TRB_TYPE(*command) != XHCI_TRB_TYPE_NO_OP_CMD) {
    215232                if (code != XHCI_TRBC_SUCCESS) {
    216                         usb_log_debug2("Command resulted in failure.");
     233                        report_error(code);
    217234                        xhci_dump_trb(command);
    218235                }
  • uspace/drv/bus/usb/xhci/hw_struct/trb.h

    rc9ce62a r4fa5342  
    192192        XHCI_TRBC_INVALID_STREAM_ID_ERROR,
    193193        XHCI_TRBC_SECONDARY_BANDWIDTH_ERROR,
    194         XHCI_TRBC_SPLIT_TRANSACTION_ERROR
     194        XHCI_TRBC_SPLIT_TRANSACTION_ERROR,
     195        XHCI_TRBC_MAX
    195196        /**
    196197         *  37 - 191 reserved
Note: See TracChangeset for help on using the changeset viewer.