Commit graph

450 commits

Author SHA1 Message Date
Matias Karhumaa 933acfef43 usb: Fix ACL data tx stalling
This patch increases size of acl_tx_pool and makes sure that acl_read_cb
waits for available buffers.

Size of acl_tx_pool is now configurable with CONFIG_BT_CTLR_TX_BUFFERS.

Previously it was possible to run out of buffers and in that case
acl_read_cb returned. This caused ACL data TX to stall because device
did not read data from HCI out endpoint.

Fixes #14899

Signed-off-by: Matias Karhumaa <matias.karhumaa@gmail.com>
2019-03-28 10:48:26 +01:00
Filip Kubicz 521d046fdc USB: Fix warning in DFU class
Move unused variable to scope where it is used.

Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
2019-03-26 11:21:23 +01:00
Andrei Emeltchenko de17b27886 usb: cdc_acm: Make ring buffer size configurable
Add new configuration parameter USB_CDC_ACM_RINGBUF_SIZE, default to
1024.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-25 12:03:15 +01:00
Andrei Emeltchenko cd95560cce usb: cdc_acm: Use ringbuf for RX path
Use ringbuf library for handling RX CDC ACM path. Remove old code
artifacts handling specific hardware.

Fixes #14288

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-25 12:03:15 +01:00
Andrei Emeltchenko 57b92e90fe usb: cdc_acm: Make parameters boolean
Remove 'U' after every assignment and make code more logical.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-25 12:03:15 +01:00
Andrei Emeltchenko 5a7fd0ebc9 usb: netusb: ecm: Print packet hexdump only for VERBOSE_DEBUG
Use VERBOSE_DEBUG to enable net_pkt_hexdump().

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 4496e99869 usb: netusb: rndis: Remove old unused code
Remove old unused code sending media status, sending this packet
causes Windows problems although Linux works with it. Removing this
code does not affect RNDIS functionality.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 276f50a623 usb: netusb: rndis: Fix maximum RNDIS frame size
Use standard NET_ETH_MAX_FRAME_SIZE in calculation adding space for
ethernet header.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 48be0443b7 usb: netusb: eem: Add check for large packets
Make sure we do not overwrite tx_buf.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko f4bfca6e44 usb: netusb: eem: Use NET_ETH_MAX_FRAME_SIZE as frame size
Use standard NET_ETH_MAX_FRAME_SIZE for frame size calculation. This
changes buffer from 1522 to 1514 + 2 + 4. Remove also magic numbers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 57041dd9c0 usb: netusb: ecm: Add check for large packets
Make sure we do not overwrite tx_buf.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 7ee481aad7 usb: netusb: ecm: Use NET_ETH_MAX_FRAME_SIZE as frame size
Use standard defined frame size for buffer and wMaxSegmentSize
parameter. Changes frame size from 1522 to 1514.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 00c58f770b usb: netusb: rndis: Add check for large packets
Drop packets larger then tx_buf.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Andrei Emeltchenko 742c177977 usb: netusb: Cleanup USB Ethernet networking
Cleanup ECM, EEM and RNDIS networking functions, removing unneeded
headers and unused definitions.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-21 09:01:36 -05:00
Tomasz Bursztyka d6d52ce9e5 net/pkt: Remove _new suffix to net_pkt_write functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka a25f054cbd net/pkt: Remove _new suffix to net_pkt_read functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Andrei Emeltchenko d293d0c682 usb: netusb: Remove unused helpers and cleanup
Remove try_write() which is not used anymore and general cleanup.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-13 05:46:01 -05:00
Andrei Emeltchenko db311047d0 usb: rndis: Use usb_transfer() for data transfer
Use USB transfer API for data transfer. Simplify notification count,
removing delayed work, use usb_transfer() logic instead.

Fixes #14127

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-13 05:46:01 -05:00
Andrei Emeltchenko 31ed124692 usb: netusb: rndis: Cleanup code
Remove unnecessary line breaks.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-13 05:46:01 -05:00
Andrei Emeltchenko fd496a5e67 usb: netusb: ecm: Remove forward declaration
Make code more readable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-13 05:46:01 -05:00
Andrei Emeltchenko 8a5cbb47cc usb: netusb: eem: Use sys_get_le16() helper
Use helper to make code cleaner.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-13 05:46:01 -05:00
Ulf Magnusson 94a9342843 kconfig: subsys: usb: Remove redundant USB_DEVICE_STACK deps.
subsys/usb/Kconfig 'source's subsys/usb/class/Kconfig (which in turn
'source's subsys/usb/class/netusb/Kconfig) within an
'if USB_DEVICE_STACK', so the dependencies on USB_DEVICE_STACK added
within those files are redundant.

'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.

Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-09 10:03:27 -05:00
Rajavardhan Gundi fa49e3e4c7 usb: dfu: Signal completion of DFU
Generally when DFU is in progress, the system is not expected to
be doing anything else in addition. Hence, a completion signal
would help the system to know that DFU is over and it can proceed
towards next tasks.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-03-08 08:35:59 -05:00
Tomasz Bursztyka 7b2d33f432 usb/net: Switch RNDIS netusb driver to new net_pkt API
Using new allocator and pkt writer instead.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-06 17:46:18 -05:00
Tomasz Bursztyka 28f499ee15 usb/net: Fix MTU size
Commit 766101c was a wrong fix as NETUSB_MTU is the actual network MTU.
Instead of using this value in EEM/ECM drivers, a relevant value should
be set for each there.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-06 17:46:18 -05:00
Tomasz Bursztyka 846f84a20f usb/net: Switch ECM netusb driver to new net_pkt API
Using new allocator and pkt writer instead.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-06 17:46:18 -05:00
Tomasz Bursztyka b8b63e06db usb/net: Switch EEM netusb driver to new net_pkt API
Using new allocator and pkt writer instead.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-06 17:46:18 -05:00
Tomasz Bursztyka e911f3821b usb/net: Extend netusb API to get the actual network interface pointer
This will be needed from receiver implementation (eem or ecm).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-06 17:46:18 -05:00
David B. Kinder e731bdc81a doc: fix docs, include, and Kconfig misspellings
Fix misspellings missed during regular reviews

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-02-28 09:32:12 +01:00
Andrei Emeltchenko 4035cb62dd usb: dfu: Fix missing break in case statement
Fixes #13870

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-27 08:49:13 -06:00
Paweł Zadrożniak 3ecbff501a usb: Add remote wakeup support
This commit adds support for remote wakeup and extends USB api
with a wakeup request call. Remote wakeup can be dsabled in kconfig
when a specific driver does not support this feature.

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2019-02-27 10:37:16 +01:00
Ulf Magnusson 40436f730b kconfig: Use a short consistent prompt style
Same change as in commit 8cf8db3a73 ("Kconfig: Use a short, consistent
style for prompts"), fixing stuff that got introduced since then.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-02-27 09:23:30 +01:00
Aurelien Jarno 2c41103c8f usb/net: fix ECM driver in composite mode
Since commit b48a8c3247 ("usb: device: Add composite status callback")
the cb_usb_status callback is not called anymore in composite mode. The
cb_usb_status_composite callback is called instead.

This patch updates the ECM driver to use either one or the other
depending on CONFIG_USB_COMPOSITE_DEVICE.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-19 11:26:47 -05:00
Aurelien Jarno 70d13d87e2 usb/net: fix EEM driver in composite mode
Since commit b48a8c3247 ("usb: device: Add composite status callback")
the cb_usb_status callback is not called anymore in composite mode. The
cb_usb_status_composite callback is called instead.

This patch updates the EEM driver to use either one or the other
depending on CONFIG_USB_COMPOSITE_DEVICE.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-19 11:26:47 -05:00
Aurelien Jarno 70a0137f1f usb/net: fix RNDIS driver in composite mode
Since commit b48a8c3247 ("usb: device: Add composite status callback")
the cb_usb_status callback is not called anymore in composite mode. The
cb_usb_status_composite callback is called instead.

This patch updates the RNDIS driver to use either one or the other
depending on CONFIG_USB_COMPOSITE_DEVICE.

Note that in practice the RNDIS driver is forced to composite mode for
better compatility with Windows, so this fix is required to get the
RNDIS driver working.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-19 11:26:47 -05:00
Carlos Stuart 75f77db432 include: misc: util.h: Rename min/max to MIN/MAX
There are issues using lowercase min and max macros when compiling a C++
application with a third-party toolchain such as GNU ARM Embedded when
using some STL headers i.e. <chrono>.

This is because there are actual C++ functions called min and max
defined in some of the STL headers and these macros interfere with them.
By changing the macros to UPPERCASE, which is consistent with almost all
other pre-processor macros this naming conflict is avoided.

All files that use these macros have been updated.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-14 22:16:03 -05:00
Tomasz Bursztyka a6426620da net/private: Rename net_hexdump_frags to net_pkt_hexdump
And remove the parameter "full" as there is no "ll reserve" distinction
anymore. The parameter was unused since the ll reserve concept removal.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Andrei Emeltchenko d402d03555 usb: msc: Fix redeclaration of enumerators
Add prefixes to MSC enumerators, otherwise they are (ERROR) are
conflicting with other enumerators.

...
subsys/usb/class/mass_storage.c:149:2: error: redeclaration of
enumerator ‘ERROR’
 ERROR,        /* error */
 ^~~~~
...
ext/hal/st/stm32cube/stm32f4xx/soc/stm32f4xx.h:216:3: note: previous
 definition of ‘ERROR’ was here
   ERROR = 0U,
   ^~~~~
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 873ae0b14b usb: cdc_acm: Refactor Kconfig for CDC ACM
Remove unneeded "depends on" and use "if USB_CDC_ACM" instead of.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko d083067424 usb: cdc_acm: Use new device data interface
Use device data interface to handle device data.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 00339509b3 usb: hid: Use new device data interface
Use new interface for getting device data.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 9d85b2add0 usb: Add helpers for getting common device data
Add helpers to be used in USB classes for getting device data.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 495426e4d9 usb: hid: Add sys_le16_to_cpu() conversion
Add conversion since interface number is stored in lower byte of
wIndex.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 5863680b2c usb: hid: Add get_dev_data_by_cfg helper
Reduce time by using the helper.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 81f06f6117 usb: cdc_acm: Use u8_t for interface number
Change argument for get_dev_data_by_iface().

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko ca85890dc2 usb: hid: Add HID Device concept
Add HID Device associated with the instance of the HID. This allows to
create several HID instances for multifunction composite device.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko c725a90084 usb: hid: Add configuration options for second HID instance
Add configuration option for enabling second HID Device

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 6aefb16964 usb: cdc_acm: Add menuconfig option for multiple instances
Add menuconfig option to select another instance of CDC ACM device.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 5c5bb7409b usb: cdc_acm: Add macros for multi instance configuration
Add macros for defining multiple instances of CDC ACM devices.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 11201a1236 usb: cdc_acm: Use usb_cfg_data from config_info
Use saved data in dev->config->config_info.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko b48a8c3247 usb: device: Add composite status callback
Add new status callback with usb_cfg_data parameter to be able to
identify instance callback.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko 9ef8ad412f usb: Refactor usb_interface_config callback
Add interface parameter to interface configuration callback to be able
to configure several instances of the same class.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko b5786aded7 usb: cdc_acm: Correct debug logging
Remove extra newline characters.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrei Emeltchenko eb86b5ccc5 usb: cdc_acm: Allow to create several CDC ACM devices
Change global device pointer to device list where every device
registers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 11:23:04 -05:00
Andrzej Puzdrowski 40da5f3f40 usb/class/usb_dfu: use predefined string for image descriptors
Use predefined string for images string descriptors instead
of from DTS build-time generated labels.
This labels will be deprecated.

String content are kept the same as before.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-02-08 09:13:09 -06:00
Andrzej Puzdrowski ee7dfc1b34 usb/class/usb_dfu: use flash_map data instead of macro labels
Now flash_map is proper place to obtain all information about
flash-areas boundaries.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-02-08 09:13:09 -06:00
Findlay Feng 6199e97836 usb/class/usb_dfu: align to changes in dfu subsys'es
Changes in flash_map API makes flash_area structure proper
interface for point the image area instead of direct flash-bank-offsets.

This patch align code to changed APIa and allows to support operation
on the partition in any flash device.

Signed-off-by: Findlay Feng <i@fengch.me>
2019-02-08 09:13:09 -06:00
Andrei Emeltchenko f9293a0db3 usb: Remove unused variable
Cleanup code removing unused variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-05 11:08:24 -05:00
Aurelien Jarno 192fe2a528 usb: class: dfu: always provide payload_data
Given the device can be enumerated as both legacy and composite, we
always need to provide the payload_data buffer.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-04 18:46:05 -05:00
Aurelien Jarno b613864c8e usb: class: dfu: fix USB descriptors in composite mode
In composite mode the request handler buffer is common to all functions,
and its size is defined by CONFIG_USB_COMPOSITE_BUFFER_SIZE.

Given the device is enumerated as composite in runtime mode and
as legacy in download mode, we need to define wTransferSize as
the minimum of the two.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-04 18:46:05 -05:00
Aurelien Jarno ef2871dec9 usb: class: dfu: use the request handler provided buffer
The upload code assumes the buffer to use is the DFU provide one, and
not the one provided by the request handler, which is different in
composite mode.

This is only a theoretical issue, as this function is only executed
once the device has been re-enumerated in legacy mode, but that is a
required step before unifying legacy and composite code.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-04 18:46:05 -05:00
Aurelien Jarno 9550f9c358 usb: class: dfu: fix firmware upload
The flash_read() function takes an offset from beginning of the flash.
This patch subtract FLASH_BASE_ADDRESS from the absolute address. This
fixes DFU firmware upload.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-04 18:46:05 -05:00
Aurelien Jarno d77b1c843d usb: class: dfu: fix support for SPI based flash
With an SPI based flash, CONFIG_FLASH_BASE_ADDRESS is not defined. In
that case it is safe to assume that the base address is 0.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-04 18:46:05 -05:00
Nicolas LANTZ 766101cf09 usb: netusb: Align NETUSB_MTU & wMaxSegmentSize and increase it to 1522
As rx_buf & tx_buf are defined with a NETUSB_MTU size, this cause
that the frames over 1500 bytes can not be received and are discarded.

Secondly, as fragmentation is not supported (for UDP and TCP datagram),
increase NETUSB_MTU to the maximum possible ethernet frame size :1522

Signed-off-by: Nicolas LANTZ <nicolas.lantz@ubicore.net>
2019-02-04 17:52:35 +01:00
Andrei Emeltchenko bf9c6d72e8 usb: Add instance parameter to descriptors definitions
This allows to place instances of the class one after another in the
linker section.

Fixes #12908

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-01 19:11:32 -05:00
Andrei Emeltchenko 372fb5da51 usb: cdc_acm: Fix composite build
Fixes bug below:
subsys/usb/class/cdc_acm.c:554:15: error: ‘dev_data’ undeclared (first
use in this function) k_work_init(&dev_data->cb_work,
cdc_acm_irq_callback_work_handler); ^~~~~~~~

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-01-24 08:37:16 -05:00
Aurelien Jarno 7f334c84d6 usb: cdc_acm: call the IRQ callback from the system work queue
The IRQ callback function of the USB CDC ACM driver can currently be
called from:
- the USB thread when a bulk in or a bulk out interrupt has been
  triggered
- the thread calling cdc_acm_irq_rx_enable or cdc_acm_irq_tx_enable when
  enabling the interrupt fires an irq (ie if there is data to read or if
  there is no pending data to send)

This causes some issues with at least the shell uart backend, as the
IRQ callback function ends up being called twice concurrently in case a
USB driver sends the requested data almost instantaneously. This is the
case for example of the USB nRF driver which uses DMA. In turn this
cause ring_buf_item_get to be called concurrently, leading to data
corruption:

  uart:~$ help
  Please press the <Tab> button to see all available commandands.
  You can also use the e <Tab> button to prompt or auto-coomplelete all
  commands or its subcommands.
  You can try toto call commands with <-h> or <--help> parameter for
  more informatation.
  uart:~$

Fix that by always calling the IRQ callback function through the system
work queue.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-01-09 07:47:43 -06:00
Savinay Dharmappa 0fb1a8a836 usb: class: dfu: Add a worker thread to flash data from usb to flash
The bulk of implementation in the current DFU arch is done in the ISR.
This works well when the Flash device is memory mapped as these writes
get done comparatively quickly. However, in case of platforms where
the flash device is sitting on the SPI Bus, this was observed to
cause an exception. This exception may be because there are multiple
function calls consuming larger processing time inside the ISR. The
ISR stack may also end up going deeper and risk stack corruption on
devices with low RAM. To resolve this, we deferred flash write to a
worker thread. Also, some handshaking was added to have synchronization
with the host in accordance with the Host-Device DFU protocol.

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2018-12-30 16:24:33 -05:00
Savinay Dharmappa b9b8daa3bc samples: subsys: usb: dfu: Fix build error for intel_s1000
intel_s1000 uses DT_SPI_NOR_DRV_NAME instead of DT_FLASH_DEV_NAME
for device binding of flash device.

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2018-12-30 16:24:33 -05:00
Marcin Szymczyk 801b54edb9 usb: hid: boot protocol
Set_Protocol and Get_Protocol requests are handled now.
Tested with USB3CV.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-12-19 07:36:18 -06:00
Aurelien Jarno a1c3b0aad3 usb: fix CDC ACM breakage with CONFIG_USB_DEVICE_SOF
Commit e4c447aac3 ("usb: add SoF event") added support for calling the
status callback with the USB_DC_SOF value for each SoF when
CONFIG_USB_DEVICE_SOF is enabled. The CDC ACM driver saves the latest
received status and compares it USB_DC_CONFIGURED to decide if it can
send data to the host. This therefore doesn't work any more when the
status callback is called regulary with USB_DC_SOF.

Fix that by ignoring USB_DC_SOF when saving the latest received status.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-17 08:16:49 -06:00
Tomasz Bursztyka e97a543e9b net/pkt: Remove parameters to "reserve" some headroom
Such parameter is not used anymore, it was defaulted to 0 previously.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka 01a5238ee8 usb/netusb: Let's remove the use for ll reserve
It's useless now.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Marcin Szymczyk c6d5d09d70 usb: hid: allow hid_ops to be null
Allows for hid_ops argument in usb_hid_register_device() to be NULL.
In that case, application does not implement any custom callbacks.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-12-14 13:19:04 +01:00
Aurelien Jarno 46a1bb7cdd usb: cdc_acm: select SERIAL_HAS_DRIVER and SERIAL_SUPPORT_INTERRUPT
USB CDC ACM is a serial driver like another. Therefore select both
SERIAL_HAS_DRIVER and SERIAL_SUPPORT_INTERRUPT. This allows one to
enable the console driver without having to enable another serial
driver.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-05 08:53:15 -05:00
Aurelien Jarno 3eda3b61f8 usb: cdc_acm: fix interrupt mode
The CDC ACM driver has to emulate the TX and RX interrupts from the USB
ones. However it does not correctly emulate them as "TX buffer empty"
and "RX buffer not empty" interrupts.

For "TX buffer empty" interrupt:
- Reading the interrupt status should not clear the interrupt
- Enabling the interrupt should fire an interrupt if the TX buffer is
  empty
- An interrupt should be triggered when the USB device get configured

For "RX buffer not empty" interrupt:
- Reading the interrupt status should not clear the interrupt
- Enabling the interrupt should fire an interrupt if the RX buffer is
  not empty

This make the a console on the USB CDC ACM port usable for the shell
and the logs.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-12-05 08:53:15 -05:00
Patrik Flykt b97db52de7 misra-c: Add 'U' to unsigned variable assignments in subsys/
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Marcin Szymczyk d5b79ff42c usb: hid: implement idle rate
Idle rate functionality has been implemented for HID USB class.
Bassed on Device Class Definition for Human Interface Devices 1.11.
Tested with USB3CV and host with idle rate.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-12-04 15:58:19 -05:00
Marcin Szymczyk 6a4ddffaf9 usb: hid: default request handlers
HID class now defaults to universal request callbacks in case they
are not provided by the application. This applies to following,
class-specific requests: Get_Report, Set_Report, Get_Idle, Set_Idle,
Get_Protocol and Set_Protocol.
Tested with USB3CV.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-12-04 15:58:19 -05:00
Tomasz Bursztyka 9464ec3343 net/iface: Switch fully to a one-pass sending logic in net_if
Now instead of such path:

net_if_send_data -> L2's send -> net_if tx_queue -> net_if_tx -> driver
net_if's send

It will be:

net_if_send_data -> net_if tx_queue -> net_if_tx -> L2's send -> driver
net_if's send

Only Ethernet is adapted, but 15.4 and bt will follow up.
All Ethernet drivers are made compatible with that new scheme also.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Andrei Emeltchenko e209ebe05a usb: device: Use sys_le16_to_cpu conversion
USB protocol is Little Endian so make conversions.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-30 07:58:31 -08:00
Flavio Ceolin 98d03266f1 serial: Change poll_out signature
poll_out function was returning the character that was sent. It
happens that it is always constant and the return of this functions is
never tested. Changing it to be a void function.

MISRA-C rule 17.7

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-11-29 10:18:59 -08:00
Andrei Emeltchenko 575bd0bbc9 usb: Fix unaligned access
Use sys_put_le16() for unaligned access, this is refactored work of
PR #8495
PR #11432

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-26 09:13:56 -08:00
Marcin Szymczyk e4c447aac3 usb: add SoF event
Start of Frame events can now be accessed from USB classes.
This will be useful when implementing idle rate functionality.

Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
2018-11-23 09:18:41 -05:00
Savinay Dharmappa 0576f93ff8 usb: class: hid: Fix fault due to unaligned access
patch fix fault due to unaligned access while setting hid
report size on xtensa platform.

Fixes #11266

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2018-11-21 12:25:22 -05:00
Anas Nashif 065903f3c7 usb: netusb: fix log level macro
Using the wrong Kconfig for log level.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-15 15:24:32 -05:00
Andrei Emeltchenko db42716cde usb: msc: Check input parameters for class handle
Fixes USB Certification tests for class requests.

Fixes #11359

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-14 23:54:08 -05:00
Andrei Emeltchenko 5bf12356e2 usb: msc: Do not give warning after SET_INTERFACE
Add USB_DC_INTERFACE 'handling'.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-14 23:54:08 -05:00
Andrei Emeltchenko 3f698494bb usb: msc: Set default Serial Number string
According to the "USB Mass Storage Class" Spec. the serial
number shall contain at least 12 valid digits, represented
as a UNICODE string.

Fixes: #11336

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-14 23:54:08 -05:00
Andrzej Głąbek 20202902f2 dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig
These changes were obtained by running a script  created by
Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
specification:

1. Read the contents of all dts_fixup.h files in Zephyr
2. Check the left-hand side of the #define macros (i.e. the X in
   #define X Y)
3. Check if that name is also the name of a Kconfig option
   3.a If it is, then do nothing
   3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
       has neither of these two prefixes
4. Replace the use of the changed #define in the code itself
   (.c, .h, .ld)

Additionally, some tweaks had to be added to this script to catch some
of the macros used in the code in a parameterized form, e.g.:
- CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
- CONFIG_UART_##idx##_TX_PIN
- I2C_SBCON_##_num##_BASE_ADDR
and to prevent adding DT_ prefix to the following symbols:
- FLASH_START
- FLASH_SIZE
- SRAM_START
- SRAM_SIZE
- _ROM_ADDR
- _ROM_SIZE
- _RAM_ADDR
- _RAM_SIZE
which are surprisingly also defined in some dts_fixup.h files.

Finally, some manual corrections had to be done as well:
- name##_IRQ -> DT_##name##_IRQ in uart_stm32.c

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06:00
Kumar Gala e8587f4493 usb: Make USB_VBUS_GPIO a Kconfig option
Previously we had a set of magic #define's in board.h that would both
enable and set the GPIO controller & pin if a given board used a GPIO
for USB VBUS.  Now we make it a proper Kconfig set of options that
specify if the feature is needed, the GPIO controller device name, and
pin number.  In the future this should move to devicetree.

Updated the related boards that used this feature to set the Kconfig
options in the Kconfig.defconfig

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-13 07:10:04 -06:00
Andrei Emeltchenko 40f7a49ffe usb: hid: Trivial syntax fix
Fix typo

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-13 12:41:39 +01:00
Andrei Emeltchenko 85cfe33262 usb: hid: Define helper definitions and cleanup code
Use newly defined definitions for cleaning the code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-13 12:41:39 +01:00
Andrei Emeltchenko f6a20b83d6 usb: hid: Implement Return HID Descriptor
Resolves certification USB tests.
Fixes #11321

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-13 12:41:39 +01:00
Krzysztof Chruscinski 97345dbb1b logging: Fix errors in log usage
Couple of findings which were revealed after changing
LOG_MODULE_REGISTER macro:
- missing semicolons after LOG_MODULE_REGISTER()
- missing LOG_LEVEL defines
- other

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-11-10 12:38:29 -05:00
Andrei Emeltchenko 93bd26343e usb: logs: Rename USB_WRN to LOG_WRN
Since logger is now suitable for our logs use it directly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-08 08:35:20 -05:00
Andrei Emeltchenko f22060cdbe usb: logs: Rename USB_INF to LOG_INF
Since logger is now suitable for our logs use it directly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-08 08:35:20 -05:00
Andrei Emeltchenko 17f7abd3dc usb: logs: Rename USB_ERR to LOG_ERR
Since logger is now suitable for our logs use it directly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-08 08:35:20 -05:00
Andrei Emeltchenko 92c7ab74c0 usb: logs: Rename USB_DBG to LOG_DBG
Since logger is now suitable for our logs use it directly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-11-08 08:35:20 -05:00
Aurelien Jarno fdfa975b9d usb: device: fix wrong direction in usb_transfer_ep_callback
In case no transfer is ongoing, the usb_transfer_ep_callback consumes
the received data. This is however associated with the wrong test. USB
is host centric, so data reception on the device is signaled by
USB_DC_EP_DATA_OUT and not USB_DC_EP_DATA_IN.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-11-05 16:33:01 +01:00
Kumar Gala f05888446d subsys: usb_device: Fix removal of board.h
Restore including board.h to get USB_VUSB_EN_GPIO and associate defines
if the board.h sets them.  This should move to device tree in the
future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-02 14:55:53 -04:00
Kumar Gala cabdf5e9dd subsys: Remove board.h include
The subsys code doesn't need anything from board.h so lets remove the
include.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-01 13:15:18 +01:00
Kumar Gala 42dc4e9b51 usb: device: Fix compile warning
/home/galak/git/zephyr/subsys/usb/usb_device.c: In function ‘usb_transfer_work’:
/home/galak/git/zephyr/subsys/usb/usb_device.c:1156:58: error: passing argument 4 of ‘usb_dc_ep_write’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   ret = usb_dc_ep_write(ep, trans->buffer, trans->bsize, &bytes);
                                                          ^
In file included from /home/galak/git/zephyr/include/usb/usb_device.h:39:0,
                 from /home/galak/git/zephyr/subsys/usb/usb_device.c:68:
/home/galak/git/zephyr/include/drivers/usb/usb_dc.h:270:5: note: expected ‘u32_t * const {aka long unsigned int * const}’ but argument is of type ‘int *’
 int usb_dc_ep_write(const u8_t ep, const u8_t *const data,
     ^~~~~~~~~~~~~~~
/home/galak/git/zephyr/subsys/usb/usb_device.c:1168:8: error: passing argument 4 of ‘usb_dc_ep_read_wait’ from incompatible pointer type [-Werror=incompatible-pointer-types]
        &bytes);
        ^
In file included from /home/galak/git/zephyr/include/usb/usb_device.h:39:0,
                 from /home/galak/git/zephyr/subsys/usb/usb_device.c:68:
/home/galak/git/zephyr/include/drivers/usb/usb_dc.h:328:5: note: expected ‘u32_t * {aka long unsigned int *}’ but argument is of type ‘int *’
 int usb_dc_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len,
     ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-10-29 10:52:00 -04:00
Pawel Dunaj 8d55b03414 subsys: usb: class: hid: Allow control of USB poll interval
This closes issue #10807

Signed-off-by: Pawel Dunaj <pawel.dunaj@nordicsemi.no>
2018-10-25 12:54:24 +01:00
Andrei Emeltchenko a6340c588d usb: loopback: Add documentation markers
Add markers to the code to be included in the USB documentation.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-24 11:18:12 +01:00
Andrei Emeltchenko 4bec02019b usb: logs: Remove newlines from the logs
Fixes double newline in the logger output.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-18 09:45:29 -04:00
Andrei Emeltchenko 557f0ed72e usb: Enable log level menu after enabling module
This makes menuconfig much more readable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-15 12:58:27 -04:00
Andrei Emeltchenko cfa04c318e netusb: Remove ifdef registration for functions
netusb functions are now registered when interface is selected or
configured.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-11 14:45:26 -04:00
Andrei Emeltchenko 216b1457ed netusb: Move init() to separate functions
Move init() invocation to function code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-11 14:45:26 -04:00
Andrei Emeltchenko 91fc0bcd50 netusb: Register each function
Register each function found in the linker USB data cfg section.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-11 14:45:26 -04:00
Andrei Emeltchenko 6b3c096a95 netusb: Refactor RNDIS code
Move RNDIS functionality from netusb to function_rndis.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-11 14:45:26 -04:00
Andrei Emeltchenko 0db9062cdb netusb: Refactor EEM code
Move EEM functionality from netusb to function_eem.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-11 14:45:26 -04:00
Andrei Emeltchenko fd1ac0f209 netusb: Refactor ECM code
Move ECM functionality from netusb to function_ecm making defines not
needed in many cases.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-11 14:45:26 -04:00
Aurelien Jarno 124f5776a7 usb: device: fix the log level of a debug message
When using composite devices, an error is printed during the
initialization:

| [00:00:00.000,000] <err> usb_device: set cb, ep: 0x81
|
| [00:00:00.000,000] <err> usb_device: set cb, ep: 0x1
|
| [00:00:00.000,000] <err> usb_device: set cb, ep: 0x82
|
| [00:00:00.000,000] <err> usb_device: set cb, ep: 0x2

This is actually not an error, but rather a debug message. In addition
it should not contain a new line as it is automatically added by the
logger subsystem.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-10-10 17:48:55 -04:00
Andrei Emeltchenko 1eb6a01723 usb: Use const for status_callback parameter
usb_dc_status_callback() parameters are interface or configuration
numbers and should be const.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-10 09:21:55 -04:00
Andrei Emeltchenko adf056dc92 usb: Use always single callback definition
Use one callback type, remove duplicates.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-10 09:21:55 -04:00
Andrei Emeltchenko 82a5ee0cad usb: hid: General code cleanup
Trivial style cleanup.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-10 09:21:55 -04:00
Andrei Emeltchenko 3288da9c0b usb: hid: Add status_cb to hid ops
Adding status callback allows to control report sending only when i.e.
device is connected or configured.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-10-10 09:21:55 -04:00
Paweł Zadrożniak a6134a374e subsys: usb: Change the buffer fragmentation for IN transfers.
USB controller was performing the fragmentation by itself and the driver
was not aware if current chunk is the last one if data size is equal to
maximum chunk size. Some hardware controllers (i.e. in nRF52840) handle
the status stage by hardware which must be triggered after the last data
chunk.
Currently, the whole remaining data is passed to the driver, and the
driver decides whether to fragment the data internally, or send only
the chunk and report back to the stack.

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2018-10-09 21:37:51 +02:00
Yannis Damigos d1a655a624 subsys/usb: Move to new logger subsystem
Move to new logger subsystem.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-10-08 12:54:57 -04:00
Jukka Rissanen 009e4dafa7 net: Make Kconfig template variables prettier
Adding spaces around "=" when definining Kconfig template so
that is more consistent with overall style of these template
variables.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-05 09:01:37 -04:00
Jukka Rissanen ac88baca02 usb: net: Convert to use new logging
Convert the USB networking to use the new logging system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-04 14:13:57 +03:00
Jukka Rissanen 4851e2ea1b usb: Fix net_hexdump_frags() parameters
One parameter was missing when calling net_hexdump_frags() which
caused compile error.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-04 14:13:57 +03:00
Flavio Ceolin da49f2e440 coccicnelle: Ignore return of memset
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.

The only directory excluded directory was ext/* since it contains
only imported code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Savinay Dharmappa 6b44a00336 subsys: usb: class: hid: Add OUT interrupt endpoint
patch add a OUT interrupt endpoint descriptor and registers a
corresponding notification callback with usb driver, which is invoked
when data is sent to device from host.

Implement the read ready notification as suggesteed by
Aurelien Jarno <aurelien@aurel32.net>

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-08-27 18:59:58 -04:00
Flavio Ceolin 0866d18d03 irq: Fix irq_lock api usage
irq_lock returns an unsigned int, though, several places was using
signed int. This commit fix this behaviour.

In order to avoid this error happens again, a coccinelle script was
added and can be used to check violations.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-08-16 19:47:41 -07:00
Ulf Magnusson 8cf8db3a73 Kconfig: Use a short, consistent style for prompts
Consistently use

    config FOO
            bool/int/hex/string "Prompt text"

instead of

    config FOO
            bool/int/hex/string
            prompt "Prompt text"

(...and a bunch of other variations that e.g. swapped the order of the
type and the 'prompt', or put other properties between them).

The shorthand is fully equivalent to using 'prompt'. It saves lines and
avoids tricking people into thinking there is some semantic difference.

Most of the grunt work was done by a modified version of
https://unix.stackexchange.com/questions/26284/
how-can-i-use-sed-to-replace-a-multi-line-string/26290#26290, but some
of the rarer variations had to be converted manually.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-15 04:10:10 -07:00
Oleg Zhurakivskyy ac92a01f5a net: ipv6: Refactor IPv6 header length handling
Change the length to uint16_t and work with it
through standard htons/ntohs() macros.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-08-13 13:53:14 +03:00
Ulf Magnusson ec3eff57e0 Kconfig: Use the first default with a satisfied condition
Up until now, Zephyr has patched Kconfig to use the last 'default' with
a satisfied condition, instead of the first one. I'm not sure why the
patch was added (it predates Kconfiglib), but I suspect it's related to
Kconfig.defconfig files.

There are at least three problems with the patch:

  1. It's inconsistent with how Kconfig works in other projects, which
     might confuse newcomers.

  2. Due to oversights, earlier 'range' properties are still preferred,
     as well as earlier 'default' properties on choices.

     In addition to being inconsistent, this makes it impossible to
     override 'range' properties and choice 'default' properties if the
     base definition of the symbol/choice already has 'range'/'default'
     properties.

     I've seen errors caused by the inconsistency, and I suspect there
     are more.

  3. A fork of Kconfiglib that adds the patch needs to be maintained.

Get rid of the patch and go back to standard Kconfig behavior, as
follows:

  1. Include the Kconfig.defconfig files first instead of last in
     Kconfig.zephyr.

  2. Include boards/Kconfig and arch/<arch>/Kconfig first instead of
     last in arch/Kconfig.

  3. Include arch/<arch>/soc/*/Kconfig first instead of last in
     arch/<arch>/Kconfig.

  4. Swap a few other 'source's to preserve behavior for some scattered
     symbols with multiple definitions.

     Swap 'source's in some no-op cases too, where it might match the
     intent.

  5. Reverse the defaults on symbol definitions that have more than one
     default.

     Skip defaults that are mutually exclusive, e.g. where each default
     has an 'if <some board>' condition. They are already safe.

  6. Remove the prefer-later-defaults patch from Kconfiglib.

Testing was done with a Python script that lists all Kconfig
symbols/choices with multiple defaults, along with a whitelist of fixed
symbols. The script also verifies that there are no "unreachable"
defaults hidden by defaults without conditions

As an additional test, zephyr/.config was generated before and after the
change for several samples and checked to be identical (after sorting).

This commit includes some default-related cleanups as well:

  - Simplify some symbol definitions, e.g. where a default has 'if FOO'
    when the symbol already has 'depends on FOO'.

  - Remove some redundant 'default ""' for string symbols. This is the
    implicit default.

Piggyback fixes for swapped ranges on BT_L2CAP_RX_MTU and
BT_L2CAP_TX_MTU (caused by confusing inconsistency).

Piggyback some fixes for style nits too, e.g. unindented help texts.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 12:38:28 -07:00
Oleg Zhurakivskyy fbac80bb94 net: ipv4: Refactor IPv4 header length handling
Change the length to uint16_t and work with it
through standard htons/ntohs() macros.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-08-09 16:25:17 +03:00
Paul Sokolovsky 57286afdd6 drivers: uart: Allow to pass arbitrary user data to irq callback
Zephyr UART drivers offer very low-level functionality. Oftentimes,
it would be useful to provide higher-level wrappers around UART
device which would offer additional functionality. However, UART
driver irq callback routine receives just a pointer to (low-level)
UART device, and it's not possible to get to a wrapper structure
(without introducing expensive external mapping structures). This
is an indirect reason why the current UARt wrappers - uart_pipe,
console - are instantiated statically just for one underlying UART
device and cannot be reused for multiple devices.

Solve this by allowing to pass an arbitrary user data to irq
callback, set by new uart_irq_callback_user_data_set() function.
Existing uart_irq_callback_set() keeps setting a callback which
will receive pointer to the device.

While public API maintains compatibility, drivers themselves need
to be updated to support arbitrary user data storage/passing (as
legacy uart_irq_callback_set() functionality is now implemented in
terms of it).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-08-02 19:20:12 +02:00
Ulf Magnusson d1684a83a4 Kconfig: Clean up some symbol definitions
- Remove redundant 'n' defaults. 'n' is the default value for bool
  symbols.

  This makes the auto-generated documentation clearer as well: You get
  "implicitly defaults to n" instead of
  "- n if <propagated dependencies>".

- Shorten

      <type>
      prompt "foo"

  to

      <type> "foo"

  This works for all types, not just bool.

- Various formatting nits.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-01 12:47:17 -04:00
qianfan Zhao 32e6d0ca87 usb: set SN string descriptor at runtime
implement a method that can set SN string descriptor at runtime.
but runtime SN and default SN configured in Kconfig must has the
same length.

Fixes: #6593

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-07-16 17:20:58 +02:00
Ulf Magnusson 1073882998 subsys: kconfig: Remove 'default n' properties and clean up a bit
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.

Remove some 'default ""' properties on string symbols too.

Also make definitions more consistent by converting some

  config FOO
  	<type>
  	prompt "foo"

definitions to a shorter form:

  config FOO
  	<type> "foo"

This shorthand works for int/hex/string symbols too, not just for bool
symbols.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-12 23:13:22 -04:00
Andrei Emeltchenko c8af08e5d4 usb: osdesc: Use definition for string descriptor index
Use definition and add description block.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-07-12 23:10:22 -04:00
Andrei Emeltchenko 25afcc574f usb: device: Refactor vendor_handler
Since vendor commands cannot assume that wIndex keeps interface number
we change logic trying to call every vendor handler which should check
input parameters.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-07-12 23:10:22 -04:00
Andrei Emeltchenko c2fdfbb835 usb: rndis: Use RFC 7042 Doc value for Host MAC
Use similar RFC 7042 Documentation value like it is in CDC ECM.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-07-12 23:10:22 -04:00
Andrei Emeltchenko 7b0e9d7c53 usb: composite: Add handling osdesc feature
Add handling osdesc feature also for composite configuration.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-07-12 23:10:22 -04:00
Andrei Emeltchenko d8da50a30d usb: rndis: Set subCompatibleID parameter for exact MS driver
Set subCompatibleID value according to "C:\Windows\INF\rndiscmp.inf"
file. The exact matching part is:
"USB\MS_COMP_RNDIS&MS_SUBCOMP_5162001"

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-07-12 23:10:22 -04:00
Andrei Emeltchenko 93dd1b99c2 usb: rndis: Add MS OS v1 descriptors to RNDIS
This should allow automatic driver loading in MS Windows.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-07-12 23:10:22 -04:00
Andrei Emeltchenko 59e9cd0f13 usb: osdesc: Add MS OS Descriptors version 1 support
Add support for MS OS Descriptors. The patch structures already
existing code for webusb to the single place to be easy added to other
places.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-07-12 23:10:22 -04:00
Andrei Emeltchenko a19b469ae3 usb: Cleanup code style for usb_device
Make usb_device code consistent with the rest of the code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-07-12 23:10:22 -04:00
Andrei Emeltchenko 44b7076c22 usb: Correct include path
This makes possible to include headers from subsys/usb

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-07-12 23:10:22 -04:00
Johann Fischer 25b0212fc3 subsys: usb: class: add loopback function
Add loopback function. This function can be used to test
USB device drivers and device stack connected to linux host
and has the similar interface as "Gadget Zero" [1] of the Linux
kernel.

Use modprobe usbtest to load the module, see also [2] for the
description of the tests and for Vendor and Product ID of the
"Gadget Zero". The userspace tool testusb [3] is needed to start
the tests.

[1] linux/drivers/usb/gadget/function/f_loopback.c
[2] linux/drivers/usb/misc/usbtest.c
[3] linux/tools/usb/testusb.c

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-07-06 11:56:16 -05:00
Johann Fischer 3a471e3240 subsys: usb: stall if there is no data buffer
Return a STALL in the setup or data stage if there is no data buffer.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-07-06 11:56:16 -05:00
Johann Fischer 1b5775249d usb: add callback codes for Set/Clear Feature ENDPOINT_HALT
Add callback codes for Set/Clear Feature ENDPOINT_HALT.
These can be used to inform a function that the device stack has
received Set/Clear Feature request ENDPOINT_HALT. The function can
then abort or restart the transfer accordingly.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-07-06 11:56:16 -05:00
Andrei Emeltchenko 7cb8689397 usb: netusb: Add ethernet_init()
After PR #8608 every driver should call ethernet_init(), fixes missing
chunks of that PR.

Fixes: #8752

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-07-05 09:56:53 -04:00
Johann Fischer 06ac62ed32 usb: usb_descriptor: fix null pointer dereference
Fix possible null pointer dereference if the device
descriptor is not complete.

Fixes: #8700
Coverity-ID: 186841

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-07-03 14:28:46 -04:00
Anas Nashif 964979f539 usb: mark unused arguments correctly
use ARG_UNUSED instead of making variable equal itself.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-01 22:58:23 +02:00
Paweł Zadrożniak f3d1b22487 subsys: usb: Fixes USB DFU class by updating the bcdUSB value.
bcdUSB has been previously updated from 1.1 to 2.0 in default
device descriptor, but not in DFU class. After USB bus reset
performed by dfu-util, alternative descriptor is registered
with bcdUSB set to 1.1. This mismatch causes communication failure.
DFU descriptor's bcdUSB has been updated to match default one.

Relates to #7570

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
2018-06-27 13:38:12 +02:00
Johann Fischer c36e800e8e usb: remove all CONFIG_*_EP_ADDR options
Remove all CONFIG_*_EP_ADDR options but keep the default
values for it, as they are necessary to find ep_addr in
usb_ep_cfg_data associated with bEndpointAddress in
interface descriptor.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-22 12:30:55 -04:00
Andrei Emeltchenko c1724f65bf usb: bos: Add USB BOS descriptors API
Add API for USB BOS Descriptors.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-06-20 15:47:00 -04:00
Andrei Emeltchenko f07275e6e6 usb: trivial: Remove unneeded braces
Clean up the code

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-06-20 15:47:00 -04:00
Andrei Emeltchenko b25567eab8 usb: Allow to enable stack on native_posix arch
At the moment USB Device stack is not possible to enable for
native_posix architecture since there is not USB controller.
The patch allows to enable stack making possible to use it in unit
tests.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-06-20 15:47:00 -04:00
Sathish Kuttan a3095087aa subsys: usb: Make HID payload size configurable
The payload size was hardcoded to 64.
This commit adds a configuration option to choose > 64 bytes
when the device allows larger packets.
A configuration option USB_HID_MAX_PAYLOAD_SIZE is added in
subsys/usb/class/hid/Kconfig
The default value is set to 64

Signed-off-by: Sathish Kuttan <sathish.k.kuttan@intel.com>
2018-06-19 20:16:18 -04:00
Johann Fischer 085a8b75c5 usb: hid: fix write to interrupt IN endpoint
A HID application can no longer write to the default
interrupt IN endpoint because the addresses are assigned
dynamically. Add hid_int_ep_write() function  and leave
it to the hid-core to call the usb_write() with the correct
endpoint address.

fixes: #8424

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-16 11:46:56 +02:00
Johann Fischer 32cac08e55 usb: class: adapt functions for new composite interface
Adapt functions for new composite interface.

Assign bInterfaceNumber and similar variables of a Interface
default values, these should be valid values for non-composite
configuration. For the case of the composite configuration,
these variables must be set by the interface configuration
function (interface_config) accordingly.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-15 11:02:05 +02:00
Johann Fischer 1383dad8a7 subsys: usb: rework composite device support
This patch reworks composite device support. It allows the
functions to be modular and the user to combine its own
functions with the USB functions of the Zephyr OS.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-15 11:02:05 +02:00
Johann Fischer 1237549082 subsys: usb: configure Interface descriptor at runtime
Introduce function to configure interface descriptor at runtime.
It is simple to leave the corresponding function to configure the
interface descriptor and fix bInterfaceNumber and iInterface values,
for example.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-15 11:02:05 +02:00
Johann Fischer bf332d0004 subsys: usb: validate and update endpoint address
Add the routine to validate endpoint address and update the endpoint
descriptors and usb_ep_cfg_data at runtime.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-15 11:02:05 +02:00
Johann Fischer 18b27b7f9d subsys: usb: fetch endpoint address from usb_ep_cfg_data
This patch changes all class functions so that the endpoint
address will be retrieved from the usb_ep_cfg_data at runtime.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-15 11:02:05 +02:00
Johann Fischer 6807f3a826 subsys: usb: move descriptor parts to the class drivers
This patch moves the descriptor parts to related class
and function drivers and extends the usb_fix_descriptor
function so that the wTotalLength and bNumInterfaces
are corrected before enumeration.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-15 11:02:05 +02:00
Johann Fischer 589dbc4cd8 subsys: usb: add function to find and fix USB descriptors
This patch introduces a function to find and correct all string
descriptor.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-15 11:02:05 +02:00
Johann Fischer 0fca16443a subsys: usb: rework usb string descriptor fixup
This patch simplifies the handling of the string descriptors.
It introduces common macro for all string descriptors to
calculate the length of the bString.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-15 11:02:05 +02:00
Aurelien Jarno a55c72d35f subsys: usb/class/hid: make interrupt endpoint size configurable
The Kconfig option HID_INTERRUPT_EP_MPS does not have a prompt entry,
so it is not configurable in practice. Fix that.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-06-13 21:07:09 -04:00
Johann Fischer 1ce6a6eaa8 subsys: usb: update bcdUSB to 2.00
Update bcdUSB to 2.00

resolves #7570

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-06-11 17:31:15 -04:00
Loic Poulain 452cb61844 usb: bluetooth: Use transfer API for ACL packets
Use transfer API for ACL out transfers. No extra buffer is requested,
directly use the net buf and update its len on transfer completion.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-06-11 17:28:27 -04:00
Loic Poulain 00a6b4c5ae usb: bluetooth: Fix assert due to unreserved headroom
Bluetooth net buffers have 1-byte reserve, which can be used by HCI bus
driver (uart, spi...) to set packet type (H4).
This fixes assert when building hci_usb with CONFIG_NET_BUF_SIMPLE_LOG.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-06-11 17:28:27 -04:00
Loic Poulain 51fecf80d9 usb: bluetooth: Add TX thread
Calling bt_send from IRQ context is not safe, at least in HCI SPI case.
In the same way as hci_core, create a thread for TX.
This fixes hci_usb sample for 96b_carbon board.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-06-11 17:28:27 -04:00
Andrei Emeltchenko 73009d05ce usb: cdc_acm: Set bInterfaceProtocol to No Protocol (0)
Do not set protocol in interface descriptor. Although this field has
been ignored by major OSs during the last decades, this creates a big
deal of problems with ModemManager sending unexpected AT commands when
plugging in a dev board.

Fixes: #6646

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-05-30 09:05:40 -04:00
Johann Fischer cb0dd0cc93 usb: function_eem: fix eem_read_cb
This patch prevents eem_read_cb from trying to allocate a lot of memory.

It may happen that EEM payload size is zero, the eem_read_cb then tries
to allocate a buffer which is 0xfffc bytes large and luckily blocks.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-05-28 12:47:32 -04:00
Andrei Emeltchenko fc8bcb9a1b usb: netusb: Refactor function's status callbacks
Refactor functions status callbacks for netusb ECM, EEM and RNDIS.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-05-26 08:27:16 -04:00
Andrei Emeltchenko 7a6f1c9884 usb: netusb: Implement status callback for RNDIS
Implement status callback

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-05-26 08:27:16 -04:00
Andrei Emeltchenko 1d5692a7b6 usb: netusb: Implement status callback for EEM
Implement status callback.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-05-26 08:27:16 -04:00
Andrei Emeltchenko 851195bfe3 usb: netusb: Implement status callback for ECM
Implement status callback.

Fixes: #7364

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-05-26 08:27:16 -04:00
Andrei Emeltchenko 3497791372 usb: netusb: Use function - defined status callbacks
Allow functions to define status callbacks

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-05-26 08:27:16 -04:00
Andrei Emeltchenko 5135a73391 usb: netusb: Add subsys/usb to include list
This helps to source files without ../../ etc paths.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-05-26 08:27:16 -04:00
Kumar Gala b0e697cc43 subsys: usb: Remove undefined CONFIG_USB_DEVICE_HID_BOOTP
The Kconfig symbol CONFIG_USB_DEVICE_HID_BOOTP isn't defined anywhere,
so remove dead code associated with it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-05-25 08:04:36 -05:00
Kumar Gala 5013cca676 usb: rndis: Rename CONFIG_RNDIS_TX_BUF_* and CONFIG_RNDIS_CMD_BUF_*
Rename CONFIG_RNDIS_TX_BUF_* to CFG_RNDIS_TX_BUF_* and rename
CONFIG_RNDIS_CMD_BUF_* to CFG_RNDIS_CMD_BUF_*.  The CONFIG options where
not exposed in Kconfig so limit use of CONFIG_ to Kconfig only symbols.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-05-23 17:57:06 -04:00
Johann Fischer 4b0b65c1b8 subsys: usb: check for invalid descriptor type request
Implementation of Get Descriptor Request should not return interface
or endpoint descriptors in a single request without configuration
descriptor, see USB Spec. Revision 2.0, 9.4.3 Get Descriptor

This patch fixes linux kernel usbtest subtest 7 and subtest 11 errors.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-05-14 17:24:52 -04:00
qianfan Zhao 63ffbe9dcb usb: usb_device.c: rewrite if condition judgment
The 'if condition' in usb_handle_control_transfer is diffcult
to understand. So I rewrite another version.

Fixes #7340

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-05-14 17:23:21 -04:00
qianfan Zhao 4e324e2171 usb: dfu: fix 'this area can not be overwritten'
fix issue #7336

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-05-10 16:26:38 -07:00
Ramakrishna Pallala 2b5b7da9f3 subsys: disk: Add support for multiple disk interfaces
Add support for enabling multiple disk interfaces (Flash, RAM)
simultaneously in Zephyr by introducing a simple disk interface
framework where we can register multiple disks which would
interface with different storage devices. This would enable us
to have multiple instances of FATFS in Zephyr.

Add support for mass storage drive disk name which will be
used as an argument when calling the disk interface API's.

Enable multiple volumes support configuration in
ELM FAT library.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-05-08 08:53:01 -04:00
Johann Fischer b2ca5ee5bc subsys: usb: rework USB DFU class driver
This patch moves USB DFU class driver to subsys/usb/class.

For the first the USB DFU class driver depends on DFU image
manager and partition layout and is limited to use as an
application for the bootloader. The driver fetches the
information about the flash, erase block size, write block
size and partitions offset from the DT now. The driver has
two interfaces associated with the two partitions "SLOT-0"
and "SLOT-1". The "SLOT-0" can only be read.

In the following work the class driver can be extended so
that it can be used from the bootloader and update a flash
region directly from the bootloader.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-04-30 17:42:40 -04:00
Andrei Emeltchenko 222aa6009c netusb: rndis: Fix RNDIS always disabled state
Fix regression with RNDIS due to different USB configuration method.
RNDIS drivers in Windows never call Set Interface and netusb is always
disabled. Change to enable netusb upon USB Set Configuration.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-26 16:30:29 +03:00
Andrei Emeltchenko 185f2be681 netusb: rndis: Add more debugs
Add debug for enable / disable callbacks

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-26 16:30:29 +03:00
Andrei Emeltchenko 7e067414cd usb: Remove unneeded header include
The should be included from sources

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-25 07:17:42 +05:30
qianfan Zhao b7862eb832 hid: core: truncated wLength if it doesn't match report descriptor size
Some buggy system may be pass a larger wLength when it try read
HID report descriptor, although we had already tell it the right
descriptor size.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-04-21 07:01:36 -07:00
Andrei Emeltchenko 53410af994 usb: Add Bluetooth device class core functionality
Implement Bluetooth over USB functionality through Bluetooth raw
access to the Bluetooth controller. Most devices with Bluetooth and
USB controllers supported by Zephyr can export themselves as USB
Bluetooth dongles.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-20 21:04:42 -07:00
Andrei Emeltchenko 0322af5896 usb: Add Bluetooth device decriptors
Add USB Bluetooth device descriptors to usb_descriptor table.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-20 21:04:42 -07:00
Andrei Emeltchenko 4d703b1e14 usb: Add Bluetooth USB Device configuration options
Add USB_DEVICE_BLUETOOTH option

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-20 21:04:42 -07:00
Andrei Emeltchenko 1653254924 usb: mass_storage: Use simpler header include
Use searched dirs for descriptor headers

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-20 21:04:42 -07:00
Andrei Emeltchenko 6239341add usb: Add subsys/usb for device descriptor header
Support device descriptor header easy access

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-20 21:04:42 -07:00
Andrei Emeltchenko 773f3e18bb usb: Add sys_cpu_to_le16() conversion for USB field
Add missing conversion.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-20 21:04:42 -07:00
Michael Hope dbb2264454 usb: hid: implement set_report()
set_report() is used by the host to set a feature on the device such
as turning a LED on or off.

This is also used by protocols such as FIDO U2F to transfer data to
the device.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-04-06 23:06:07 -04:00
Michael Hope 0d04aef6fe usb: hid: add a INT IN transfer complete callback.
int_in_ready is an optional callback that is called when the current
interrupt IN transfer has completed.  This can be used to wait for the
endpoint to go idle or to trigger the next transfer.

This is needed for protocols like FIDO U2F that use the interrupt
endpoint for transfers.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-04-06 23:06:07 -04:00
Loic Poulain d80ae8aeeb usb: netusb: Add CDC EEM network usb function
Add CDC Ethernet Emulation Model function driver. This usb network
function can be used for ethernet over USB. Ethernet packet are
encapsulated within EEM packets. An EEM pkt contains 2-byte header
and 4-byte sentinel (or crc).

Note that EEM packets can be split across USB packets but shall not
be split across USB transfers.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-04-06 06:50:34 -04:00
Loic Poulain 992e32842b usb: netusb: Rework netusb media connect/disconnect
Consider media connected when interface is selected by the host and
disconnected on device diconnection.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-04-06 06:50:34 -04:00
Jukka Rissanen de13e979fc net: if: vlan: Add virtual lan support
This allows creation of virtual lan (VLAN) networks. VLAN support is
only available for ethernet network technology.

Fixes #3234

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-04-05 08:54:19 -04:00
Andrei Emeltchenko 4291fb67a3 usb: Remove duplicated CDC_ECM_SUBCLASS definition
Use ECM_SUBCLASS instead.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-04-04 08:21:06 -04:00