Topic: [HOWTO] limit the switch to use only 10BASE-T / disable 100BASE-TX

You may have your own reasons why you want to limit your switch to use only 10BASE-T.
The reason why I prefer 10BASE-T is the wiring in the house I live.
These telephone cables have no twisted pairs, they are more than 20m long and replacing them is not an option.
100BASE-TX may work on these cables, but I want to be on the safe side using 10 MHz instead of 100 MHz.
I own a D-Link DIR-300 and I will show you step by step what I have done to disable 100BASE-TX on the 4 ports of the switch.
I am using the method to disable Auto-Negotiation  Advertisement.

1. Determine the chip used for the switch.

# swconfig dev eth0 show
Global attributes:
        enable_vlan: 1
        name: IP175C
.
.
.

The DIR-300 has the IP175C.

2. Find and read the datasheet of your chip.

http://www.icplus.com.tw/pp-ip175c.html
http://www.icplus.com.tw/Data/Datasheet/IP175Cx-DS-R17-20081121.pdf

On page 63 the "Auto-Negotiation Advertisement register" is explained.
It is "MII register 4 of PHY0-4".
Bit 7 controls "100BASE-TX" Advertisement on/off (1/0).
Bit 8 controls "100BASE-TX full duplex" Advertisement on/off (1/0).

3. Read and write register 4 of port 0.

# swconfig dev eth0 set phy 0
# swconfig dev eth0 set reg 4
# swconfig dev eth0 get val
1505

http://calc.50x.eu/?size=2&dec=1505

If you clear bit 7 and 8 you will get 1121.

# swconfig dev eth0 set val 1121

When you now plug in a cable on port 0 you should get a connection limited to 10BASE-T only.
You can check this on your PC with "ethtool".

4. Restart Auto-Negotiation

There is no need to unplug your cables everytime you change the Auto-Negotiation Advertisement.
On page 59 of the datasheet the "Restart Auto-Negotiation" bit is listed.
It is "MII register 0 of PHY0-4" bit 9.
This is similar to step 3.

5. Automate

For automation you may need a one-liner to set and clear the bits.
http://graphics.stanford.edu/~seander/bithacks.html#ConditionalSetOrClearBitsWithoutBranching

Here is the initscript I use: http://pastebin.com/ShP1vtQK

I want to thank all developers of OpenWrt!