On Sat, 17 Aug 2013 15:40:43 +0200
Hauke Mehrtens <[email protected]> wrote:

> On 08/17/2013 02:09 PM, Hauke Mehrtens wrote:
> > On 09/23/2012 11:07 PM, Nathan Hintz wrote:
> >> This is partly based on patches sent by Ɓukasz Kwestarz (See
> >> https://lists.openwrt.org/pipermail/openwrt-devel/2012-March/014356.html).
> >>
> >> Signed-off-by: Nathan Hintz <nlhintz at hotmail.com>
> >>
> >> Index: trunk/package/broadcom-wl/Makefile
> >> ===================================================================
> >> --- trunk/package/broadcom-wl/Makefile     (revision 33530)
> >> +++ trunk/package/broadcom-wl/Makefile     (working copy)
> >> @@ -10,7 +10,7 @@
> >>  
> >>  PKG_NAME:=broadcom-wl
> >>  PKG_VERSION:=5.10.56.27.3
> >> -PKG_RELEASE:=4
> >> +PKG_RELEASE:=5
> >>  
> >>  PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(ARCH).tar.bz2
> >>  PKG_SOURCE_URL:=http://downloads.openwrt.org/sources
> >> Index: trunk/package/broadcom-wl/src/wlc.c
> >> ===================================================================
> >> --- trunk/package/broadcom-wl/src/wlc.c    (revision 33530)
> >> +++ trunk/package/broadcom-wl/src/wlc.c    (working copy)
> >> @@ -499,8 +499,8 @@
> >>    /* driver doesn't support GET */
> >>  
> >>    if ((param & PARAM_MODE) == SET) {
> >> -          strncpy(pmk.key, value, WSEC_MAX_PSK_LEN);
> >> -          pmk.key_len = strlen(value);
> >> +          strncpy(pmk.key, str, WSEC_MAX_PSK_LEN);
> >> +          pmk.key_len = strlen(str);
> >>  
> >>            if (pmk.key_len > WSEC_MAX_PSK_LEN)
> >>                    pmk.key_len = WSEC_MAX_PSK_LEN;
> >> @@ -912,6 +912,41 @@
> >>            .handler = wlc_ioctl,
> >>            .desc = "G Mode"
> >>    },
> >> +  {
> >> +          .name = "phytype",
> >> +          .param = INT,
> >> +          .data.num = (WLC_GET_PHYTYPE << 16),
> >> +          .handler = wlc_ioctl,
> >> +          .desc = "PHY Type"
> >> +  },
> >> +  {
> >> +          .name = "nmode",
> >> +          .param = INT,
> >> +          .handler = wlc_iovar,
> >> +          .data.str = "nmode",
> >> +          .desc = "N Mode"
> >> +  },
> >> +  {
> >> +          .name = "nreqd",
> >> +          .param = INT,
> >> +          .handler = wlc_iovar,
> >> +          .data.str = "nreqd",
> >> +          .desc = "N Mode required"
> >> +  },
> >> +  {
> >> +          .name = "chanspec",
> >> +          .param = INT,
> >> +          .handler = wlc_iovar,
> >> +          .data.str = "chanspec",
> >> +          .desc = "Channel Spec (See bcmwifi.h)"
> >> +  },
> >> +  {
> >> +          .name = "band",
> >> +          .param = INT,
> >> +          .data.num = ((WLC_GET_BAND << 16) | WLC_SET_BAND),
> >> +          .handler = wlc_ioctl,
> >> +          .desc = "Band"
> >> +  },
> >>  };
> >>  #define wlc_calls_size (sizeof(wlc_calls) / sizeof(struct
> >> wlc_call)) 
> >> @@ -971,7 +1006,7 @@
> >>            set = 1;
> >>            switch(cmd->param & PARAM_TYPE) {
> >>                    case INT:
> >> -                          intval = strtoul(arg, &end, 10);
> >> +                          intval = strtoul(arg, &end, 0);
> >>                            if (end && !(*end)) {
> >>                                    memcpy(buf, &intval,
> >> sizeof(intval)); } else {
> >> Index: trunk/package/broadcom-wl/files/lib/wifi/broadcom.sh
> >> ===================================================================
> >> --- trunk/package/broadcom-wl/files/lib/wifi/broadcom.sh
> >> (revision 33530) +++
> >> trunk/package/broadcom-wl/files/lib/wifi/broadcom.sh
> >> (working copy) @@ -131,6 +131,7 @@ config_get frag "$device" frag
> >>    config_get rts "$device" rts
> >>    config_get hwmode "$device" hwmode
> >> +  config_get htmode "$device" htmode
> >>    local vif_pre_up vif_post_up vif_do_up vif_txpower
> >>    local doth=0
> >>    local wmm=1
> >> @@ -161,15 +162,40 @@
> >>            ;;
> >>    esac
> >>  
> >> +  [ ${channel:-0} -ge 1 -a ${channel:-0} -le 14 ] && band=2
> >> +  [ ${channel:-0} -ge 36 ] && band=1
> >> +
> >>    case "$hwmode" in
> >> -          *b)   hwmode=0;;
> >> -          *bg)  hwmode=1;;
> >> -          *g)   hwmode=2;;
> >> -          *gst) hwmode=4;;
> >> -          *lrs) hwmode=5;;
> >> -          *)    hwmode=1;;
> >> +          *na)    nmode=1; nreqd=0;;
> >> +          *a)     nmode=0;;
> >> +          *ng)    gmode=1; nmode=1; nreqd=0;;
> >> +          *n)     nmode=1; nreqd=1;;
> >> +          *b)     gmode=0; nmode=0;;
> >> +          *bg)    gmode=1; nmode=0;;
> >> +          *g)     gmode=2; nmode=0;;
> >> +          *gst)   gmode=4; nmode=0;;
> >> +          *lrs)   gmode=5; nmode=0;;
> >> +          *)      case "$band" in
> >> +                          2) gmode=1; nmode=1; nreqd=0;;
> >> +                          1) nmode=1; nreqd=0;;
> >> +                          *) gmode=1; nmode=1; nreqd=0;;
> >> +                  esac
> >> +                  ;;
> >>    esac
> >>  
> >> +        # Use 'nmode' for N-Phy only
> >> +  [ "$(wlc ifname $device phytype)" = 4 ] || nmode=
> >> +
> >> +  # Use 'chanspec' instead of 'channel' for 'N' modes (See
> >> bcmwifi.h)
> >> +  [ ${nmode:-0} -ne 0 -a -n "$band" ] && {
> >> +          case "$htmode" in
> >> +                  HT40-)  chanspec=$(printf
> >> 0x%x%x%02x $band 0xe $(($channel - 2))); channel=;;
> >> +                  HT40+)  chanspec=$(printf
> >> 0x%x%x%02x $band 0xd $(($channel + 2))); channel=;;
> >> +                  HT20)   chanspec=$(printf 0x%x%x%02x
> >> $band 0xb $channel); channel=;;
> >> +                  *) ;;
> >> +          esac
> >> +  }
> >> +
> >>    for vif in $vifs; do
> >>            config_get vif_txpower "$vif" txpower
> >>  
> >> @@ -322,7 +348,10 @@
> >>    wlc ifname "$device" stdin <<EOF
> >>  $ifdown
> >>  
> >> -gmode ${hwmode:-1}
> >> +${nmode:+band ${band:-0}}
> >> +${nmode:+nmode $nmode}
> >> +${nmode:+${nreqd:+nreqd $nreqd}}
> >> +${gmode:+gmode $gmode}
> >>  apsta $apsta
> >>  ap $ap
> >>  ${mssid:+mssid $mssid}
> >> @@ -344,6 +373,7 @@
> >>  ${wds:+wds $wds}
> >>  country ${country:-US}
> >>  ${channel:+channel $channel}
> >> +${chanspec:+chanspec $chanspec}
> >>  maxassoc ${maxassoc:-128}
> >>  slottime ${slottime:--1}
> >>  ${frameburst:+frameburst $frameburst}
> >>
> > Hi Nathan,
> > 
> > I had a look at this patch some time earlier, but it somehow slipped
> > through.
> > 
> > This looks nice to me. The detect part should also be extended to
> > write a correct initial config.
> > 
> > Hauke
> 
> This was committed in r37802.
> 
> I still have a problem when I activate encryption I do not see any
> beacons, but this seams to be unrelated to your patch.
> 
> @Nathan I hope I applied all of your patches.
> 
> Hauke
> 

Hi Hauke:

Thanks for applying the patch!  I'll send updates for others if I
think they might be worthwhile.

I had made an additional modification to broadcom.sh that is attached below.
It might be considered overkill; but was intended to handle the case where
'hwmode' was specified w/o specifying a 'channel' (not sure if that is a
legitimate case... client mode?).  There's no checking for
inconsistencies between the 'hwmode' and 'channel' (channel wins!).

Also, will issuing a 'band' command all of the time affect older devices
in any way (the previous patch restricted setting 'band' to just N-PHY
devices... assumed to support it)?

There are other issues with broadcom.sh being able to work with two radios
that need to be fixed before this will work completely.  I'll send a separate
patch for that (I just have to isolate it from the other changes I've made).

(I'm using a new mail client, so hopefully it doesn't mangle this).

Nathan

Index: package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh
===================================================================
--- package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh       (revision 37806)
+++ package/kernel/broadcom-wl/files/lib/wifi/broadcom.sh       (working copy)
@@ -166,15 +166,15 @@
        [ ${channel:-0} -ge 36 ] && band=1
 
        case "$hwmode" in
-               *na)    nmode=1; nreqd=0;;
-               *a)     nmode=0;;
-               *ng)    gmode=1; nmode=1; nreqd=0;;
+               *na)    band=${band:-1}; nmode=1; nreqd=0;;
+               *a)     band=${band:-1}; nmode=0;;
+               *ng)    band=${band:-2}; gmode=1; nmode=1; nreqd=0;;
                *n)     nmode=1; nreqd=1;;
-               *b)     gmode=0; nmode=0;;
-               *bg)    gmode=1; nmode=0;;
-               *g)     gmode=2; nmode=0;;
-               *gst)   gmode=4; nmode=0;;
-               *lrs)   gmode=5; nmode=0;;
+               *b)     band=${band:-2}; gmode=0; nmode=0;;
+               *bg)    band=${band:-2}; gmode=1; nmode=0;;
+               *g)     band=${band:-2}; gmode=2; nmode=0;;
+               *gst)   band=${band:-2}; gmode=4; nmode=0;;
+               *lrs)   band=${band:-2}; gmode=5; nmode=0;;
                *)      case "$band" in
                                2) gmode=1; nmode=1; nreqd=0;;
                                1) nmode=1; nreqd=0;;
@@ -187,7 +187,7 @@
        [ "$(wlc ifname $device phytype)" = 4 ] || nmode=
 
        # Use 'chanspec' instead of 'channel' for 'N' modes (See bcmwifi.h)
-       [ ${nmode:-0} -ne 0 -a -n "$band" ] && {
+       [ ${nmode:-0} -ne 0 -a -n "$band" -a -n "$channel" ] && {
                case "$htmode" in
                        HT40-)  chanspec=$(printf 0x%x%x%02x $band 0xe 
$(($channel - 2))); channel=;;
                        HT40+)  chanspec=$(printf 0x%x%x%02x $band 0xd 
$(($channel + 2))); channel=;;
@@ -348,7 +348,7 @@
        wlc ifname "$device" stdin <<EOF
 $ifdown
 
-${nmode:+band ${band:-0}}
+band ${band:-0}
 ${nmode:+nmode $nmode}
 ${nmode:+${nreqd:+nreqd $nreqd}}
 ${gmode:+gmode $gmode}
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to