From dacb0467c1dc9573b32408faa2a7f081605e34ca Mon Sep 17 00:00:00 2001 From: Bjørn Mork Date: Sat, 13 Oct 2012 12:44:30 +0200 Subject: usb-mbim: USB_CDC_GET_NTB_PARAMETERS support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bjørn Mork --- hw/usb/dev-mbim.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/hw/usb/dev-mbim.c b/hw/usb/dev-mbim.c index 2f2d37ff7..f7b4e9596 100644 --- a/hw/usb/dev-mbim.c +++ b/hw/usb/dev-mbim.c @@ -20,10 +20,34 @@ #define DPRINTF(fmt, ...) do {} while(0) #endif -#define RECV_BUF 384 - -#define DeviceOutVendor ((USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_DEVICE)<<8) -#define DeviceInVendor ((USB_DIR_IN |USB_TYPE_VENDOR|USB_RECIP_DEVICE)<<8) +#define InterfaceOutClass \ + ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)<<8) + +#define InterfaceInClass \ + ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE)<<8) + +#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00 +#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01 +#define USB_CDC_REQ_SET_LINE_CODING 0x20 +#define USB_CDC_REQ_GET_LINE_CODING 0x21 +#define USB_CDC_REQ_SET_CONTROL_LINE_STATE 0x22 +#define USB_CDC_REQ_SEND_BREAK 0x23 +#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40 +#define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41 +#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42 +#define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43 +#define USB_CDC_GET_ETHERNET_STATISTIC 0x44 +#define USB_CDC_GET_NTB_PARAMETERS 0x80 +#define USB_CDC_GET_NET_ADDRESS 0x81 +#define USB_CDC_SET_NET_ADDRESS 0x82 +#define USB_CDC_GET_NTB_FORMAT 0x83 +#define USB_CDC_SET_NTB_FORMAT 0x84 +#define USB_CDC_GET_NTB_INPUT_SIZE 0x85 +#define USB_CDC_SET_NTB_INPUT_SIZE 0x86 +#define USB_CDC_GET_MAX_DATAGRAM_SIZE 0x87 +#define USB_CDC_SET_MAX_DATAGRAM_SIZE 0x88 +#define USB_CDC_GET_CRC_MODE 0x89 +#define USB_CDC_SET_CRC_MODE 0x8a enum { STR_MANUFACTURER = 1, @@ -142,6 +166,7 @@ static const USBDescIface desc_iface_mbim[] = { .bEndpointAddress = USB_DIR_IN | 0x01, .bmAttributes = USB_ENDPOINT_XFER_INT, .wMaxPacketSize = 64, + .bInterval = 7, }, } },{ @@ -168,6 +193,7 @@ static const USBDescIface desc_iface_mbim[] = { .bEndpointAddress = USB_DIR_IN | 0x01, .bmAttributes = USB_ENDPOINT_XFER_INT, .wMaxPacketSize = 64, + .bInterval = 7, }, } },{ @@ -249,6 +275,7 @@ static const USBDescIface desc_iface_ncm[] = { .bEndpointAddress = USB_DIR_IN | 0x01, .bmAttributes = USB_ENDPOINT_XFER_INT, .wMaxPacketSize = 64, + .bInterval = 7, }, } },{ @@ -305,6 +332,7 @@ static const USBDescIface desc_iface_mbim_nocompat[] = { .bEndpointAddress = USB_DIR_IN | 0x01, .bmAttributes = USB_ENDPOINT_XFER_INT, .wMaxPacketSize = 64, + .bInterval = 7, }, } },{ @@ -421,6 +449,21 @@ static const USBDesc desc_mbim_nocompat = { .str = desc_strings, }; +static const uint8_t ncm_ntb_parameters[] = { + 0x1a, 0x00, /* __le16 wLength; */ + 0x00, 0x00, /* __le16 bmNtbFormatsSupported; */ + 0x00, 0x00, 0x02, 0x00, /* __le32 dwNtbInMaxSize; */ + 0x20, 0x00, /* __le16 wNdpInDivisor; */ + 0x00, 0x00, /* __le16 wNdpInPayloadRemainder; */ + 0x20, 0x00, /* __le16 wNdpInAlignment; */ + 0x00, 0x00, /* __le16 wPadding1; */ + 0x00, 0x80, /* __le32 dwNtbOutMaxSize; */ + 0x04, 0x00, /* __le16 wNdpOutDivisor; */ + 0x00, 0x00, /* __le16 wNdpOutPayloadRemainder; */ + 0x20, 0x00, /* __le16 wNdpOutAlignment; */ + 0x00, 0x00, /* __le16 wNtbOutMaxDatagrams; */ +}; + static void usb_mbim_handle_reset(USBDevice *dev) { @@ -439,12 +482,34 @@ static int usb_mbim_handle_control(USBDevice *dev, USBPacket *p, } ret = 0; + + /* Class specific requests. */ switch (request) { - case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: - ret = 0; + case InterfaceOutClass | USB_CDC_SET_NTB_INPUT_SIZE: + DPRINTF("USB_CDC_SET_NTB_INPUT_SIZE is not implemented\n"); + goto fail; + case InterfaceOutClass | USB_CDC_SET_CRC_MODE: + DPRINTF("USB_CDC_SET_CRC_MODE is not implemented\n"); + goto fail; + case InterfaceOutClass | USB_CDC_SET_NTB_FORMAT: + DPRINTF("USB_CDC_SET_NTB_FORMAT is not implemented\n"); + goto fail; + case InterfaceOutClass | USB_CDC_SET_MAX_DATAGRAM_SIZE: + DPRINTF("USB_CDC_SET_MAX_DATAGRAM_SIZE is not implemented\n"); + goto fail; + case InterfaceInClass | USB_CDC_GET_NTB_PARAMETERS: + if (length == sizeof(ncm_ntb_parameters)) + memcpy(data, ncm_ntb_parameters, sizeof(ncm_ntb_parameters)); + else + goto fail; + ret = sizeof(ncm_ntb_parameters); break; + case InterfaceInClass | USB_CDC_GET_MAX_DATAGRAM_SIZE: + DPRINTF("USB_CDC_GET_MAX_DATAGRAM_SIZE is not implemented\n"); + goto fail; default: DPRINTF("got unsupported/bogus control %x, value %x\n", request, value); + fail: ret = USB_RET_STALL; break; } -- cgit v1.2.3