RE: [PATCH v2 0/8] Equivalent of g_ncm.ko with configfs

2013-05-13 Thread Andrzej Pietrasiewicz
On Tuesday, April 23, 2013 1:43 PM I wrote:
 Here I present the conversion of everthing that is required to provide
 the equivalent of g_ncm.ko with configfs.
 
 This is the second version of the series after discussion with Alan
 and Michal's review - thank you guys.
 
 A branch will be available here (from 24th April 2013):
 git://git.infradead.org/users/kmpark/linux-samsung usb-gadget-configfs
 
 v1..v2:
 
 - delayed registering a network interface until gadgets's bind
   (per Alan's request)

snip

@Felipe: please _DO NOT_ take this series. After some more testing
I discovered a bug. It is related to delaying registering a network
interface until gadget's bind. Before the mentioned change a network
interface was registered at the moment its corresponding usb function's
directory was created, so it happened exactly once for each interface.
After the change it is registered at function's bind and if a function
happens to be used across several configurations, its network interface
will be registered more than once which results in kernel BUG at
net/core/dev.c:5143.

I will post a corrected v3 series soon.

Andrzej


--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/8] Equivalent of g_ncm.ko with configfs

2013-04-23 Thread Andrzej Pietrasiewicz
Here I present the conversion of everthing that is required to provide
the equivalent of g_ncm.ko with configfs.

This is the second version of the series after discussion with Alan
and Michal's review - thank you guys.

A branch will be available here (from 24th April 2013):
git://git.infradead.org/users/kmpark/linux-samsung usb-gadget-configfs

v1..v2:

- delayed registering a network interface until gadgets's bind
  (per Alan's request)
- created a helper macro to define USB Ethernet modules' parameters (Michal's
  review)
- fixed and simplified some helper functions (Michal's review)
- changed hostaddr variable name to host_mac in several modules
  (Michal's review)


BACKWARD COMPATIBILITY
==

Please note that the old g_ncm.ko is still available and works.


USING THE NEW GADGET
==

Please refer to this post:

http://www.spinics.net/lists/linux-usb/msg76388.html

for general information from Sebastian on how to use configfs-based
gadgets (*).

Here is the description specific to using g_ncm.ko equivalent.

The old g_ncm.ko offered three parameters:

qmult  - queue length multiplier for high/super -speed devices
dev_addr   - device's MAC address
host_addr  - host's MAC address

With configfs the procedure is as follows, compared to the information
mentioned above (*):

instead of mkdir functions/acm.ttyS1 do

mkdir functions/ncm.instance name

e.g. mkdir functions/ncm.usb0

In functions/ncm.instance name there will be the following attribute files:

qmult
dev_addr
host_addr
ifname

and after creating the functions/ncm.instance name they contain default
values: qmult is 5, dev_addr and host_addr are randomly selected.
Except for ifname they can be written to until the function is linked to a
configuration. The ifname is read-only and contains the name of the interface
which was assigned by the net core, e. g. usb0.

The rest of the procedure (*) remains the same.

After unbinding the gadget with echo   UDC
the symbolic links in the configuration directory can be removed,
the strings/* subdirectories in the configuration directory can
be removed, the strings/* subdirectories at the gadget level can
be removed and the configs/* subdirectories can be removed.
The functions/* subdirectories can be removed.
After that the gadget directory can be removed.
After that the respective modules can be unloaded.


TESTING THE FUNCTIONS (actually there is just one)
==

ncm)

On the device: ping host's IP
On the host: ping device's IP


Andrzej Pietrasiewicz (8):
  usb/gadget: u_ether: convert into module
  usb/gadget: rndis: convert into module
  usb/gadget: u_ether: construct with default values and add
setters/getters
  usb/gadget: f_ncm: convert to new function interface with backward
compatibility
  usb/gadget: ncm: convert to new function interface
  usb/gadget: f_ncm: remove compatibility layer
  usb/gadget: f_ncm: use usb_gstrings_attach
  usb/gadget: f_ncm: add configfs support

 drivers/usb/gadget/Kconfig   |   20 +++
 drivers/usb/gadget/Makefile  |5 +
 drivers/usb/gadget/cdc2.c|   10 +-
 drivers/usb/gadget/ether.c   |   18 ++-
 drivers/usb/gadget/f_ncm.c   |  323 +-
 drivers/usb/gadget/g_ffs.c   |   15 ++-
 drivers/usb/gadget/multi.c   |   15 ++-
 drivers/usb/gadget/ncm.c |   58 +---
 drivers/usb/gadget/nokia.c   |   11 +-
 drivers/usb/gadget/rndis.c   |   16 ++
 drivers/usb/gadget/rndis.h   |1 +
 drivers/usb/gadget/u_ether.c |  223 ++---
 drivers/usb/gadget/u_ether.h |  155 +++-
 drivers/usb/gadget/u_ncm.h   |   35 +
 14 files changed, 765 insertions(+), 140 deletions(-)
 create mode 100644 drivers/usb/gadget/u_ncm.h

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html