| .. | .. |
|---|
| 392 | 392 | |
|---|
| 393 | 393 | fu->flags = USBG_IS_BOT; |
|---|
| 394 | 394 | |
|---|
| 395 | | - config_ep_by_speed(gadget, f, fu->ep_in); |
|---|
| 395 | + config_ep_by_speed_and_alt(gadget, f, fu->ep_in, USB_G_ALT_INT_BBB); |
|---|
| 396 | 396 | ret = usb_ep_enable(fu->ep_in); |
|---|
| 397 | 397 | if (ret) |
|---|
| 398 | 398 | goto err_b_in; |
|---|
| 399 | 399 | |
|---|
| 400 | | - config_ep_by_speed(gadget, f, fu->ep_out); |
|---|
| 400 | + config_ep_by_speed_and_alt(gadget, f, fu->ep_out, USB_G_ALT_INT_BBB); |
|---|
| 401 | 401 | ret = usb_ep_enable(fu->ep_out); |
|---|
| 402 | 402 | if (ret) |
|---|
| 403 | 403 | goto err_b_out; |
|---|
| .. | .. |
|---|
| 531 | 531 | stream->req_in->sg = se_cmd->t_data_sg; |
|---|
| 532 | 532 | } |
|---|
| 533 | 533 | |
|---|
| 534 | + stream->req_in->is_last = 1; |
|---|
| 534 | 535 | stream->req_in->complete = uasp_status_data_cmpl; |
|---|
| 535 | 536 | stream->req_in->length = se_cmd->data_length; |
|---|
| 536 | 537 | stream->req_in->context = cmd; |
|---|
| .. | .. |
|---|
| 554 | 555 | */ |
|---|
| 555 | 556 | iu->len = cpu_to_be16(se_cmd->scsi_sense_length); |
|---|
| 556 | 557 | iu->status = se_cmd->scsi_status; |
|---|
| 558 | + stream->req_status->is_last = 1; |
|---|
| 557 | 559 | stream->req_status->context = cmd; |
|---|
| 558 | 560 | stream->req_status->length = se_cmd->scsi_sense_length + 16; |
|---|
| 559 | 561 | stream->req_status->buf = iu; |
|---|
| .. | .. |
|---|
| 847 | 849 | |
|---|
| 848 | 850 | fu->flags = USBG_IS_UAS; |
|---|
| 849 | 851 | |
|---|
| 850 | | - if (gadget->speed == USB_SPEED_SUPER) |
|---|
| 852 | + if (gadget->speed >= USB_SPEED_SUPER) |
|---|
| 851 | 853 | fu->flags |= USBG_USE_STREAMS; |
|---|
| 852 | 854 | |
|---|
| 853 | | - config_ep_by_speed(gadget, f, fu->ep_in); |
|---|
| 855 | + config_ep_by_speed_and_alt(gadget, f, fu->ep_in, USB_G_ALT_INT_UAS); |
|---|
| 854 | 856 | ret = usb_ep_enable(fu->ep_in); |
|---|
| 855 | 857 | if (ret) |
|---|
| 856 | 858 | goto err_b_in; |
|---|
| 857 | 859 | |
|---|
| 858 | | - config_ep_by_speed(gadget, f, fu->ep_out); |
|---|
| 860 | + config_ep_by_speed_and_alt(gadget, f, fu->ep_out, USB_G_ALT_INT_UAS); |
|---|
| 859 | 861 | ret = usb_ep_enable(fu->ep_out); |
|---|
| 860 | 862 | if (ret) |
|---|
| 861 | 863 | goto err_b_out; |
|---|
| 862 | 864 | |
|---|
| 863 | | - config_ep_by_speed(gadget, f, fu->ep_cmd); |
|---|
| 865 | + config_ep_by_speed_and_alt(gadget, f, fu->ep_cmd, USB_G_ALT_INT_UAS); |
|---|
| 864 | 866 | ret = usb_ep_enable(fu->ep_cmd); |
|---|
| 865 | 867 | if (ret) |
|---|
| 866 | 868 | goto err_cmd; |
|---|
| 867 | | - config_ep_by_speed(gadget, f, fu->ep_status); |
|---|
| 869 | + config_ep_by_speed_and_alt(gadget, f, fu->ep_status, USB_G_ALT_INT_UAS); |
|---|
| 868 | 870 | ret = usb_ep_enable(fu->ep_status); |
|---|
| 869 | 871 | if (ret) |
|---|
| 870 | 872 | goto err_status; |
|---|
| .. | .. |
|---|
| 992 | 994 | req->sg = se_cmd->t_data_sg; |
|---|
| 993 | 995 | } |
|---|
| 994 | 996 | |
|---|
| 997 | + req->is_last = 1; |
|---|
| 995 | 998 | req->complete = usbg_data_write_cmpl; |
|---|
| 996 | 999 | req->length = se_cmd->data_length; |
|---|
| 997 | 1000 | req->context = cmd; |
|---|
| .. | .. |
|---|
| 1050 | 1053 | transport_init_se_cmd(se_cmd, |
|---|
| 1051 | 1054 | tv_nexus->tvn_se_sess->se_tpg->se_tpg_tfo, |
|---|
| 1052 | 1055 | tv_nexus->tvn_se_sess, cmd->data_len, DMA_NONE, |
|---|
| 1053 | | - cmd->prio_attr, cmd->sense_iu.sense); |
|---|
| 1056 | + cmd->prio_attr, cmd->sense_iu.sense, |
|---|
| 1057 | + cmd->unpacked_lun); |
|---|
| 1054 | 1058 | goto out; |
|---|
| 1055 | 1059 | } |
|---|
| 1056 | 1060 | |
|---|
| .. | .. |
|---|
| 1147 | 1151 | default: |
|---|
| 1148 | 1152 | pr_debug_once("Unsupported prio_attr: %02x.\n", |
|---|
| 1149 | 1153 | cmd_iu->prio_attr); |
|---|
| 1150 | | - /* fall through */ |
|---|
| 1154 | + fallthrough; |
|---|
| 1151 | 1155 | case UAS_SIMPLE_TAG: |
|---|
| 1152 | 1156 | cmd->prio_attr = TCM_SIMPLE_TAG; |
|---|
| 1153 | 1157 | break; |
|---|
| .. | .. |
|---|
| 1180 | 1184 | transport_init_se_cmd(se_cmd, |
|---|
| 1181 | 1185 | tv_nexus->tvn_se_sess->se_tpg->se_tpg_tfo, |
|---|
| 1182 | 1186 | tv_nexus->tvn_se_sess, cmd->data_len, DMA_NONE, |
|---|
| 1183 | | - cmd->prio_attr, cmd->sense_iu.sense); |
|---|
| 1187 | + cmd->prio_attr, cmd->sense_iu.sense, |
|---|
| 1188 | + cmd->unpacked_lun); |
|---|
| 1184 | 1189 | goto out; |
|---|
| 1185 | 1190 | } |
|---|
| 1186 | 1191 | |
|---|
| .. | .. |
|---|
| 1257 | 1262 | return 0; |
|---|
| 1258 | 1263 | } |
|---|
| 1259 | 1264 | |
|---|
| 1260 | | -static char *usbg_get_fabric_name(void) |
|---|
| 1261 | | -{ |
|---|
| 1262 | | - return "usb_gadget"; |
|---|
| 1263 | | -} |
|---|
| 1264 | | - |
|---|
| 1265 | 1265 | static char *usbg_get_fabric_wwn(struct se_portal_group *se_tpg) |
|---|
| 1266 | 1266 | { |
|---|
| 1267 | 1267 | struct usbg_tpg *tpg = container_of(se_tpg, |
|---|
| .. | .. |
|---|
| 1294 | 1294 | } |
|---|
| 1295 | 1295 | |
|---|
| 1296 | 1296 | static u32 usbg_sess_get_index(struct se_session *se_sess) |
|---|
| 1297 | | -{ |
|---|
| 1298 | | - return 0; |
|---|
| 1299 | | -} |
|---|
| 1300 | | - |
|---|
| 1301 | | -/* |
|---|
| 1302 | | - * XXX Error recovery: return != 0 if we expect writes. Dunno when that could be |
|---|
| 1303 | | - */ |
|---|
| 1304 | | -static int usbg_write_pending_status(struct se_cmd *se_cmd) |
|---|
| 1305 | 1297 | { |
|---|
| 1306 | 1298 | return 0; |
|---|
| 1307 | 1299 | } |
|---|
| .. | .. |
|---|
| 1719 | 1711 | |
|---|
| 1720 | 1712 | static const struct target_core_fabric_ops usbg_ops = { |
|---|
| 1721 | 1713 | .module = THIS_MODULE, |
|---|
| 1722 | | - .name = "usb_gadget", |
|---|
| 1723 | | - .get_fabric_name = usbg_get_fabric_name, |
|---|
| 1714 | + .fabric_name = "usb_gadget", |
|---|
| 1724 | 1715 | .tpg_get_wwn = usbg_get_fabric_wwn, |
|---|
| 1725 | 1716 | .tpg_get_tag = usbg_get_tag, |
|---|
| 1726 | 1717 | .tpg_check_demo_mode = usbg_check_true, |
|---|
| .. | .. |
|---|
| 1732 | 1723 | .sess_get_index = usbg_sess_get_index, |
|---|
| 1733 | 1724 | .sess_get_initiator_sid = NULL, |
|---|
| 1734 | 1725 | .write_pending = usbg_send_write_request, |
|---|
| 1735 | | - .write_pending_status = usbg_write_pending_status, |
|---|
| 1736 | 1726 | .set_default_node_attributes = usbg_set_default_node_attrs, |
|---|
| 1737 | 1727 | .get_cmd_state = usbg_get_cmd_state, |
|---|
| 1738 | 1728 | .queue_data_in = usbg_send_read_response, |
|---|
| .. | .. |
|---|
| 2110 | 2100 | usb_composite_setup_continue(fu->function.config->cdev); |
|---|
| 2111 | 2101 | } |
|---|
| 2112 | 2102 | |
|---|
| 2103 | +static int tcm_get_alt(struct usb_function *f, unsigned intf) |
|---|
| 2104 | +{ |
|---|
| 2105 | + if (intf == bot_intf_desc.bInterfaceNumber) |
|---|
| 2106 | + return USB_G_ALT_INT_BBB; |
|---|
| 2107 | + if (intf == uasp_intf_desc.bInterfaceNumber) |
|---|
| 2108 | + return USB_G_ALT_INT_UAS; |
|---|
| 2109 | + |
|---|
| 2110 | + return -EOPNOTSUPP; |
|---|
| 2111 | +} |
|---|
| 2112 | + |
|---|
| 2113 | 2113 | static int tcm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) |
|---|
| 2114 | 2114 | { |
|---|
| 2115 | 2115 | struct f_uas *fu = to_f_uas(f); |
|---|
| .. | .. |
|---|
| 2317 | 2317 | fu->function.bind = tcm_bind; |
|---|
| 2318 | 2318 | fu->function.unbind = tcm_unbind; |
|---|
| 2319 | 2319 | fu->function.set_alt = tcm_set_alt; |
|---|
| 2320 | + fu->function.get_alt = tcm_get_alt; |
|---|
| 2320 | 2321 | fu->function.setup = tcm_setup; |
|---|
| 2321 | 2322 | fu->function.disable = tcm_disable; |
|---|
| 2322 | 2323 | fu->function.free_func = tcm_free; |
|---|