Skip to content
Snippets Groups Projects
  1. Nov 21, 2022
  2. Aug 31, 2022
  3. Jul 14, 2022
  4. Jun 09, 2022
  5. Apr 21, 2022
  6. Jan 31, 2022
  7. Jan 26, 2022
  8. Dec 30, 2021
  9. Aug 05, 2021
  10. Jul 21, 2021
  11. Jun 17, 2021
  12. Jun 09, 2021
  13. May 13, 2021
  14. May 10, 2021
  15. Apr 09, 2021
  16. Jan 26, 2021
  17. Jan 15, 2021
    • Lorenzo Colitti's avatar
      usb: gadget: u_ether: support configuring interface names. · 63d15214
      Lorenzo Colitti authored
      
      This patch allows the administrator to configure the interface
      name of a function using u_ether (e.g., eem, ncm, rndis).
      
      Currently, all such interfaces, regardless of function type, are
      always called usb0, usb1, etc. This makes it very cumbersome to
      use more than one such type at a time, because userspace cannnot
      easily tell the interfaces apart and apply the right
      configuration to each one. Interface renaming in userspace based
      on driver doesn't help, because the interfaces all have the same
      driver. Without this patch, doing this require hacks/workarounds
      such as setting fixed MAC addresses on the functions, and then
      renaming by MAC address, or scraping configfs after each
      interface is created to find out what it is.
      
      Setting the interface name is done by writing to the same
      "ifname" configfs attribute that reports the interface name after
      the function is bound. The write must contain an interface
      pattern such as "usb%d" (which will cause the net core to pick
      the next available interface name starting with "usb").
      This patch does not allow writing an exact interface name (as
      opposed to a pattern) because if the interface already exists at
      bind time, the bind will fail and the whole gadget will fail to
      activate. This could be allowed in a future patch.
      
      For compatibility with current userspace, when reading an ifname
      that has not currently been set, the result is still "(unnamed
      net_device)". Once a write to ifname happens, then reading ifname
      will return whatever was last written.
      
      Tested by configuring an rndis function and an ncm function on
      the same gadget, and writing "rndis%d" to ifname on the rndis
      function and "ncm%d" to ifname on the ncm function. When the
      gadget was bound, the rndis interface was rndis0 and the ncm
      interface was ncm0.
      
      Signed-off-by: default avatarLorenzo Colitti <lorenzo@google.com>
      Link: https://lore.kernel.org/r/20210113234222.3272933-1-lorenzo@google.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      63d15214
  18. Jul 21, 2020
  19. May 14, 2020
    • Andrey Konovalov's avatar
      usb: raw-gadget: documentation updates · 61d2658d
      Andrey Konovalov authored
      
      Mention the issue with fixed UDC addresses.
      
      Links external examples and test suite.
      
      Add more implmenetation details and potential improvements.
      
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      61d2658d
    • Andrey Konovalov's avatar
      usb: raw-gadget: support stalling/halting/wedging endpoints · c61769bd
      Andrey Konovalov authored
      
      Raw Gadget is currently unable to stall/halt/wedge gadget endpoints,
      which is required for proper emulation of certain USB classes.
      
      This patch adds a few more ioctls:
      
      - USB_RAW_IOCTL_EP0_STALL allows to stall control endpoint #0 when
        there's a pending setup request for it.
      - USB_RAW_IOCTL_SET/CLEAR_HALT/WEDGE allow to set/clear halt/wedge status
        on non-control non-isochronous endpoints.
      
      Fixes: f2c2e717 ("usb: gadget: add raw-gadget interface")
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      c61769bd
    • Andrey Konovalov's avatar
      usb: raw-gadget: fix gadget endpoint selection · 97df5e57
      Andrey Konovalov authored
      
      Currently automatic gadget endpoint selection based on required features
      doesn't work. Raw Gadget tries iterating over the list of available
      endpoints and finding one that has the right direction and transfer type.
      Unfortunately selecting arbitrary gadget endpoints (even if they satisfy
      feature requirements) doesn't work, as (depending on the UDC driver) they
      might have fixed addresses, and one also needs to provide matching
      endpoint addresses in the descriptors sent to the host.
      
      The composite framework deals with this by assigning endpoint addresses
      in usb_ep_autoconfig() before enumeration starts. This approach won't work
      with Raw Gadget as the endpoints are supposed to be enabled after a
      set_configuration/set_interface request from the host, so it's too late to
      patch the endpoint descriptors that had already been sent to the host.
      
      For Raw Gadget we take another approach. Similarly to GadgetFS, we allow
      the user to make the decision as to which gadget endpoints to use.
      
      This patch adds another Raw Gadget ioctl USB_RAW_IOCTL_EPS_INFO that
      exposes information about all non-control endpoints that a currently
      connected UDC has. This information includes endpoints addresses, as well
      as their capabilities and limits to allow the user to choose the most
      fitting gadget endpoint.
      
      The USB_RAW_IOCTL_EP_ENABLE ioctl is updated to use the proper endpoint
      validation routine usb_gadget_ep_match_desc().
      
      These changes affect the portability of the gadgets that use Raw Gadget
      when running on different UDCs. Nevertheless, as long as the user relies
      on the information provided by USB_RAW_IOCTL_EPS_INFO to dynamically
      choose endpoint addresses, UDC-agnostic gadgets can still be written with
      Raw Gadget.
      
      Fixes: f2c2e717 ("usb: gadget: add raw-gadget interface")
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      97df5e57
  20. May 05, 2020
  21. Mar 15, 2020
    • Andrey Konovalov's avatar
      usb: gadget: add raw-gadget interface · f2c2e717
      Andrey Konovalov authored
      
      USB Raw Gadget is a kernel module that provides a userspace interface for
      the USB Gadget subsystem. Essentially it allows to emulate USB devices
      from userspace. Enabled with CONFIG_USB_RAW_GADGET. Raw Gadget is
      currently a strictly debugging feature and shouldn't be used in
      production.
      
      Raw Gadget is similar to GadgetFS, but provides a more low-level and
      direct access to the USB Gadget layer for the userspace. The key
      differences are:
      
      1. Every USB request is passed to the userspace to get a response, while
         GadgetFS responds to some USB requests internally based on the provided
         descriptors. However note, that the UDC driver might respond to some
         requests on its own and never forward them to the Gadget layer.
      
      2. GadgetFS performs some sanity checks on the provided USB descriptors,
         while Raw Gadget allows you to provide arbitrary data as responses to
         USB requests.
      
      3. Raw Gadget provides a way to select a UDC device/driver to bind to,
         while GadgetFS currently binds to the first available UDC.
      
      4. Raw Gadget uses predictable endpoint names (handles) across different
         UDCs (as long as UDCs have enough endpoints of each required transfer
         type).
      
      5. Raw Gadget has ioctl-based interface instead of a filesystem-based one.
      
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      f2c2e717
  22. Jan 28, 2020
  23. Oct 04, 2019
  24. Aug 08, 2019
  25. Jun 20, 2019
  26. May 21, 2019
  27. Apr 16, 2019
  28. Feb 22, 2019
  29. Nov 26, 2018
  30. Jul 11, 2018
  31. Jun 18, 2018
Loading