Commit f1fa035f authored by Felipe Zimmerle's avatar Felipe Zimmerle Committed by David Vrabel

wusb: wusb-cbaf (CBA driver) sysfs ABI simplification

Simplify the sysfs ABI of the wusb-cbaf (Cable Based Association)
driver: use one value per file and cause the write of the CHID to
fetch the CDID (instead of requiring a separate read).

Update the example wusb-cbaf script to work with this revised ABI.
Signed-off-by: default avatarFelipe Zimmerle <felipe.zimmerle@indt.org.br>
Signed-off-by: default avatarDavid Vrabel <david.vrabel@csr.com>
parent c8cf2465
...@@ -70,32 +70,42 @@ EOF ...@@ -70,32 +70,42 @@ EOF
# FIXME: CHID should come from a database :), band group from the host # FIXME: CHID should come from a database :), band group from the host
host_CHID="00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff" host_CHID="00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"
host_band_group="0001" host_band_group="0001"
host_name="Linux-WUSB" host_name=$(hostname)
devs="$(echo /sys/bus/usb/drivers/wusb-cbaf/[0-9]*)" devs="$(echo /sys/bus/usb/drivers/wusb-cbaf/[0-9]*)"
hdevs="$(find /sys -name wusb_chid -printf "%h\n")" hdevs="$(for h in /sys/class/uwb_rc/*/wusbhc; do readlink -f $h; done)"
result=0 result=0
case $1 in case $1 in
start) start)
for dev in ${2:-$hdevs} for dev in ${2:-$hdevs}
do do
uwb_rc=$(find $(dirname $(dirname $dev)) -iname uwb_rc:uwb*) uwb_rc=$(readlink -f $dev/uwb_rc)
if cat $uwb_rc/uwb_rc/beacon | grep -q "channel: -1" if cat $uwb_rc/beacon | grep -q -- "-1"
then then
echo 13 0 | cat > $uwb_rc/uwb_rc/beacon echo 13 0 > $uwb_rc/beacon
echo I: started beaconing on ch 13 in host $(basename $uwb_rc) echo I: started beaconing on ch 13 on $(basename $uwb_rc) >&2
fi fi
echo $host_CHID | cat > $dev/wusb_chid echo $host_CHID > $dev/wusb_chid
echo I: started host $(basename $dev) echo I: started host $(basename $dev) >&2
done
;;
stop)
for dev in ${2:-$hdevs}
do
echo 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > $dev/wusb_chid
echo I: stopped host $(basename $dev) >&2
uwb_rc=$(readlink -f $dev/uwb_rc)
echo -1 | cat > $uwb_rc/beacon
echo I: stopped beaconing on $(basename $uwb_rc) >&2
done done
;; ;;
set-chid) set-chid)
shift shift
for dev in ${2:-$devs} for dev in ${2:-$devs}; do
do echo "${4:-$host_name}" > $dev/wusb_host_name
echo "${2:-$host_CHID}" "${3:-$host_band_group}" "${4:-$host_name}" \ echo "${3:-$host_band_group}" > $dev/wusb_host_band_groups
| cat > $dev/wusb_host_info echo ${2:-$host_CHID} > $dev/wusb_chid
done done
;; ;;
get-cdid) get-cdid)
...@@ -105,21 +115,17 @@ case $1 in ...@@ -105,21 +115,17 @@ case $1 in
done done
;; ;;
set-cc) set-cc)
for dev in ${2:-$devs} for dev in ${2:-$devs}; do
do
shift shift
CDID="$(head --bytes=16 /dev/urandom | od -tx1 -An)" CDID="$(head --bytes=16 /dev/urandom | od -tx1 -An)"
CK="$(head --bytes=16 /dev/urandom | od -tx1 -An)" CK="$(head --bytes=16 /dev/urandom | od -tx1 -An)"
cat > $dev/wusb_cc <<EOF echo "$CDID" > $dev/wusb_cdid
CDID:$CDID echo "$CK" > $dev/wusb_ck
CK:$CK
EOF echo I: CC set >&2
cat <<EOF echo "CHID: $(cat $dev/wusb_chid)"
I: CC set echo "CDID:$CDID"
CHID: $host_CHID echo "CK: $CK"
CDID:$CDID
CK: $CK
EOF
done done
;; ;;
help|h|--help|-h) help|h|--help|-h)
......
...@@ -15,3 +15,26 @@ config USB_WUSB ...@@ -15,3 +15,26 @@ config USB_WUSB
To compile this support select Y (built in). It is safe to To compile this support select Y (built in). It is safe to
select even if you don't have the hardware. select even if you don't have the hardware.
config USB_WUSB_CBAF
tristate "Support WUSB Cable Based Association (CBA)"
depends on USB
help
Some WUSB devices support Cable Based Association. It's used to
enable the secure communication between the host and the
device.
Enable this option if your WUSB device must to be connected
via wired USB before establishing a wireless link.
It is safe to select even if you don't have a compatible
hardware.
config USB_WUSB_CBAF_DEBUG
bool "Enable CBA debug messages"
depends on USB_WUSB_CBAF
help
Say Y here if you want the CBA to produce a bunch of debug messages
to the system log. Select this if you are having a problem with
CBA support and want to see more of what is going on.
obj-$(CONFIG_USB_WUSB) += wusbcore.o wusb-cbaf.o obj-$(CONFIG_USB_WUSB) += wusbcore.o
obj-$(CONFIG_USB_HWA_HCD) += wusb-wa.o obj-$(CONFIG_USB_HWA_HCD) += wusb-wa.o
obj-$(CONFIG_USB_WUSB_CBAF) += wusb-cbaf.o
wusbcore-objs := \ wusbcore-objs := \
crypto.o \ crypto.o \
...@@ -18,3 +20,7 @@ wusb-wa-objs := wa-hc.o \ ...@@ -18,3 +20,7 @@ wusb-wa-objs := wa-hc.o \
wa-nep.o \ wa-nep.o \
wa-rpipe.o \ wa-rpipe.o \
wa-xfer.o wa-xfer.o
ifeq ($(CONFIG_USB_WUSB_CBAF_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
endif
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment