Auto init usb nic at boot

Hi!

I have usb network adapter:

usbconfig -d ugen0.2 dump_device_desc

Result:

Code:
ugen0.2: <TP-LINK USB 10/100 LAN> at usbus0, cfg=1 md=HOST spd=HIGH (480Mbps) pwr=ON (100mA)

  bLength = 0x0012
  bDescriptorType = 0x0001
  bcdUSB = 0x0210
  bDeviceClass = 0x0000  <Probed by interface class>
  bDeviceSubClass = 0x0000
  bDeviceProtocol = 0x0000
  bMaxPacketSize0 = 0x0040
  idVendor = 0x2357
  idProduct = 0x0602
  bcdDevice = 0x2000
  iManufacturer = 0x0001  <TP-LINK>
  iProduct = 0x0002  <USB 10/100 LAN>
  iSerialNumber = 0x0003  <D03745A72A81>
  bNumConfigurations = 0x0002

It works only after I directly init it:

usbconfig -d ugen0.2 set_config 1

And last thing:

ifconfig ue0 up.

After this commands device works (after setting an ip address). I want to configure it to initialize in loader.conf/rc.conf to make it working automatically.

How to configure it properly?
 
alex-t said:
I want to configure it to initialize in loader.conf/rc.conf to make it working automatically.

Normally, devd will recognise a USB device. It will then show up in dmesg. If you need additional commands to make it work the way you want, the proper way is to make a file for it in /usr/local/etc/devd.
Use the idVendor, idProduct and/or iManufacturer codes to identify your device, then add the needed commands to the action line. Could be something like this:
Code:
notify 900 {
    match "vendor"      "0x2357";
    match "product"     "0x0602";
    action "usbconfig -d $cdev set_config 1 && ifconfig ue0 up";
};
 
Hi!

Looks like I solve this problem in some different way. I read all docs about usb subsystem and find out that FreeBSD operates with usb quirks. Next, in man usb_quirks, I found that exists some options hw.usb.quirk.%d, where %d in 1..100 - quirk number (please read man about it, if you see this first time). So, in /boot/loader.conf I added next options:

Code:
if_cdce_load="YES"
usb_quirk_load="YES"
hw.usb.quirk.0="0x2357 0x0602 0 0xffff UQ_CFG_INDEX_1"

First line means load if_cdce module, for usb network adapters.
Second line - load usb quirks module, for operating with quirks, I understand that quirks is some options for modifying usb devices state.
And third and "main" line means "devices of vendor 0x2357 with idProduct 0x0602 from revision 0 to revision 0xffff (in other words, all revisions) change state to 1".

Command for check:
usbconfig -d ugen0.2 dump_info

Result:
Code:
ugen0.2: <TP-LINK USB 10/100 LAN> at usbus0, cfg=1 md=HOST spd=HIGH (480Mbps) pwr=ON (100mA)

Without configuration in loader.conf I get cfg=0 and device not works.

And last thing in rc.conf:

Code:
ifconfig_ue0="inet XXX.XXX.XXX.XXX netmask 0xffffff00"

And device works after boot and has an ip address.
 
OP: Thanks for this thread. It had me wondering about networks that are not being used on my Thinkpad laptop. Recently, some funny activity was occurring there. So, with so many security conscious items forced me to take a closer look.

The F3705 Ericsson Mobile network card I used only many years ago. But now I never use it.
So, I took the corollary of your method to turn the device off:
Code:
usbconfig ugen3.2 power_off
For persistent boots, I edited /etc/rc.conf with the same code.
THX
 
OP: Thanks for this thread. It had me wondering about networks that are not being used on my Thinkpad laptop. Recently, some funny activity was occurring there. So, with so many security conscious items forced me to take a closer look.

The F3705 Ericsson Mobile network card I used only many years ago. But now I never use it.
So, I took the corollary of your method to turn the device off:
Code:
usbconfig ugen3.2 power_off
For persistent boots, I edited /etc/rc.conf with the same code.
THX
Hi, bookwormep!

I was glad to help you!

You mean that you turn off unused device to reduce power consuming?
 
Sorry, a typo, s/b Ericsson F3507g Mobile network card. Someone or something was trying to use this device (but not me). So, following your method's corollary, turning the device off seemed to be a more secure way of handling the situation. But, as you say, power consumption would be another benefit as well.
 
Back
Top