diff mbox series

[OpenWrt-Devel] hotplug: Allow renaming wireless phy devices.

Message ID 20181217164802.20108-1-greearb@candelatech.com
State Changes Requested
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel] hotplug: Allow renaming wireless phy devices. | expand

Commit Message

Ben Greear Dec. 17, 2018, 4:48 p.m. UTC
From: Ben Greear <greearb@candelatech.com>

uci set wireless.@wifi-device[0].phyname=wiphy0

Then reboot and/or re-plug that device, and this will
name the phy wiphy0 instead of phy0, phy1, etc.

This can help keep phy names consistent through driver reloads
which may make the system easier to configure properly or to
make different systems have the same naming (where wiphy0 is always
the 2.4Ghz radio, for instance).

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 .../kernel/mac80211/files/mac80211.hotplug    | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)

Comments

John Crispin Oct. 27, 2019, 1:35 p.m. UTC | #1
On 17/12/2018 17:48, greearb@candelatech.com wrote:
> From: Ben Greear <greearb@candelatech.com>
> 
> uci set wireless.@wifi-device[0].phyname=wiphy0
> 
> Then reboot and/or re-plug that device, and this will
> name the phy wiphy0 instead of phy0, phy1, etc.
> 
> This can help keep phy names consistent through driver reloads
> which may make the system easier to configure properly or to
> make different systems have the same naming (where wiphy0 is always
> the 2.4Ghz radio, for instance).
> 
> Signed-off-by: Ben Greear <greearb@candelatech.com>
> ---
>   .../kernel/mac80211/files/mac80211.hotplug    | 32 +++++++++++++++++++
>   1 file changed, 32 insertions(+)
> 
> diff --git a/package/kernel/mac80211/files/mac80211.hotplug b/package/kernel/mac80211/files/mac80211.hotplug
> index b865552661..a394e3195e 100644
> --- a/package/kernel/mac80211/files/mac80211.hotplug
> +++ b/package/kernel/mac80211/files/mac80211.hotplug
> @@ -3,3 +3,35 @@
>   [ "${ACTION}" = "add" ] && {
>   	/sbin/wifi config
>   }
> +
> +
> +OPATH=${DEVPATH##/devices/platform/}
> +OPATH=${OPATH%%/ieee*}
> +
> +# For USB, OPATH looks like this at this point in this script:
> +# soc/soc:usb30@0/11000000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1:1.0
> +# But, the uci path has a platform/ prefix on that:
> +# platform/soc/soc:usb30@0/11000000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1:1.0
> +OPATH_USB="platform/$OPATH";
> +
> +# 10 radios is enough for anyone!
> +#echo "fix-wifi-mac, OPATH: $OPATH" >> /tmp/foo.txt
Hi Ben,
can you please drop all the debug code from the patch and resend
	John

> +for i in `seq 0 9`;
> +  do
> +  BUS=`uci get wireless.@wifi-device[$i].path`
> +  #echo "fix-wifi-mac, BUS[$i]: $BUS" >> /tmp/foo.txt
> +  if [ "$BUS " == "$OPATH " ] || [ "$BUS " == "$OPATH_USB " ]
> +      then
> +      PHYNAME=${DEVPATH##*ieee80211/}
> +      NPHYNAME=`uci get wireless.@wifi-device[$i].phyname`
> +      #echo "fix-wifi-mac, PHYNAME[$i]: $PHYNAME  NPHYNAME: $NPHYNAME" >> /tmp/foo.txt;
> +      if [ "$NPHYNAME " != " " ]
> +          then
> +          if [ "$PHYNAME " != "$NPHYNAME " ]
> +              then
> +	      #echo "fix-wifi-mac, renaming..." >> /tmp/foo.txt;
> +              iw $PHYNAME set name $NPHYNAME
> +          fi
> +      fi
> +  fi
> +done
>
Ben Greear Oct. 28, 2019, 4:50 p.m. UTC | #2
On 10/27/19 6:35 AM, John Crispin wrote:
> On 17/12/2018 17:48, greearb@candelatech.com wrote:
>> From: Ben Greear <greearb@candelatech.com>
>>
>> uci set wireless.@wifi-device[0].phyname=wiphy0
>>
>> Then reboot and/or re-plug that device, and this will
>> name the phy wiphy0 instead of phy0, phy1, etc.
>>
>> This can help keep phy names consistent through driver reloads
>> which may make the system easier to configure properly or to
>> make different systems have the same naming (where wiphy0 is always
>> the 2.4Ghz radio, for instance).
>>
>> Signed-off-by: Ben Greear <greearb@candelatech.com>
>> ---
>>   .../kernel/mac80211/files/mac80211.hotplug    | 32 +++++++++++++++++++
>>   1 file changed, 32 insertions(+)
>>
>> diff --git a/package/kernel/mac80211/files/mac80211.hotplug b/package/kernel/mac80211/files/mac80211.hotplug
>> index b865552661..a394e3195e 100644
>> --- a/package/kernel/mac80211/files/mac80211.hotplug
>> +++ b/package/kernel/mac80211/files/mac80211.hotplug
>> @@ -3,3 +3,35 @@
>>   [ "${ACTION}" = "add" ] && {
>>       /sbin/wifi config
>>   }
>> +
>> +
>> +OPATH=${DEVPATH##/devices/platform/}
>> +OPATH=${OPATH%%/ieee*}
>> +
>> +# For USB, OPATH looks like this at this point in this script:
>> +# soc/soc:usb30@0/11000000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1:1.0
>> +# But, the uci path has a platform/ prefix on that:
>> +# platform/soc/soc:usb30@0/11000000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1:1.0
>> +OPATH_USB="platform/$OPATH";
>> +
>> +# 10 radios is enough for anyone!
>> +#echo "fix-wifi-mac, OPATH: $OPATH" >> /tmp/foo.txt
> Hi Ben,
> can you please drop all the debug code from the patch and resend
>      John

It will be a while before I get a chance to rebase my tree
and do any useful testing, and I would rather not send in a patch
that has not had any testing.

So, I can resend later, or maybe someone else will have time to make the
tweaks and test against current upsteram code.

Thanks,
Ben


> 
>> +for i in `seq 0 9`;
>> +  do
>> +  BUS=`uci get wireless.@wifi-device[$i].path`
>> +  #echo "fix-wifi-mac, BUS[$i]: $BUS" >> /tmp/foo.txt
>> +  if [ "$BUS " == "$OPATH " ] || [ "$BUS " == "$OPATH_USB " ]
>> +      then
>> +      PHYNAME=${DEVPATH##*ieee80211/}
>> +      NPHYNAME=`uci get wireless.@wifi-device[$i].phyname`
>> +      #echo "fix-wifi-mac, PHYNAME[$i]: $PHYNAME  NPHYNAME: $NPHYNAME" >> /tmp/foo.txt;
>> +      if [ "$NPHYNAME " != " " ]
>> +          then
>> +          if [ "$PHYNAME " != "$NPHYNAME " ]
>> +              then
>> +          #echo "fix-wifi-mac, renaming..." >> /tmp/foo.txt;
>> +              iw $PHYNAME set name $NPHYNAME
>> +          fi
>> +      fi
>> +  fi
>> +done
>>
>
diff mbox series

Patch

diff --git a/package/kernel/mac80211/files/mac80211.hotplug b/package/kernel/mac80211/files/mac80211.hotplug
index b865552661..a394e3195e 100644
--- a/package/kernel/mac80211/files/mac80211.hotplug
+++ b/package/kernel/mac80211/files/mac80211.hotplug
@@ -3,3 +3,35 @@ 
 [ "${ACTION}" = "add" ] && {
 	/sbin/wifi config
 }
+
+
+OPATH=${DEVPATH##/devices/platform/}
+OPATH=${OPATH%%/ieee*}
+
+# For USB, OPATH looks like this at this point in this script:
+# soc/soc:usb30@0/11000000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1:1.0
+# But, the uci path has a platform/ prefix on that:
+# platform/soc/soc:usb30@0/11000000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1:1.0
+OPATH_USB="platform/$OPATH";
+
+# 10 radios is enough for anyone!
+#echo "fix-wifi-mac, OPATH: $OPATH" >> /tmp/foo.txt
+for i in `seq 0 9`;
+  do
+  BUS=`uci get wireless.@wifi-device[$i].path`
+  #echo "fix-wifi-mac, BUS[$i]: $BUS" >> /tmp/foo.txt
+  if [ "$BUS " == "$OPATH " ] || [ "$BUS " == "$OPATH_USB " ]
+      then
+      PHYNAME=${DEVPATH##*ieee80211/}
+      NPHYNAME=`uci get wireless.@wifi-device[$i].phyname`
+      #echo "fix-wifi-mac, PHYNAME[$i]: $PHYNAME  NPHYNAME: $NPHYNAME" >> /tmp/foo.txt;
+      if [ "$NPHYNAME " != " " ]
+          then
+          if [ "$PHYNAME " != "$NPHYNAME " ]
+              then
+	      #echo "fix-wifi-mac, renaming..." >> /tmp/foo.txt;
+              iw $PHYNAME set name $NPHYNAME
+          fi
+      fi
+  fi
+done