Chinaunix首页 | 论坛 | 博客
  • 博客访问: 164041
  • 博文数量: 68
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 650
  • 用 户 组: 普通用户
  • 注册时间: 2005-05-18 11:13
文章分类

全部博文(68)

文章存档

2011年(1)

2006年(21)

2005年(46)

我的朋友

分类:

2005-05-18 13:13:58

Configuring NIC Speed/Duplex on Solaris

出自:
原文:

Solaris NIC speed and duplex settings

Querying your current NIC settings (ex. hme0, assuming "instance" is 0):

# ndd -get /dev/hme link_mode

Interpretation:
0 -- half-duplex
1 -- full-duplex

# ndd -get /dev/hme link_speed
Interpretation:
0 -- 10 Mbit
1 -- 100 Mbit
1000 -- 1 Gbit

To query a different NIC, such as hme1, set the "instance" to 1, and then perform the link_mode and link_speed queries above.

# ndd -set /dev/hme instance 1

Note: the ndd commands above must be run as root. Otherwise, you will receive errors such as "couldn't push module 'hme0', No such device or address."

Here is a quick script I wrote to determine the speed and duplex settings for all plumbed network interfaces on a Solaris system. Thanks to William Favorite for fixing the script to work with two-letter network interfaces (e.g. ge0); the original script did not.

#!/bin/sh

# Only the root user can run the ndd commands
if [ "`/usr/bin/id | /usr/bin/cut -c1-5`" != "uid=0" ] ; then
   echo "You must be the root user to run `basename $0`."
   exit 1
fi

# Print column header information
/usr/bin/echo "Interface Speed Duplex"
/usr/bin/echo "--------- ----- ------"

# Determine the speed and duplex for each live NIC on the system
for INTERFACE in `/usr/bin/netstat -i | /usr/bin/egrep -v "^Name|^lo0" | /usr/bin/awk '{print $1}'`
do
  
INTERFACE_TYPE=`/usr/bin/echo $INTERFACE | /usr/bin/sed -e "s/[0-9]*$//"`
   INSTANCE=`/usr/bin/echo $INTERFACE | /usr/bin/sed -e "s/^[a-z]*//"`
   /usr/sbin/ndd -set /dev/$INTERFACE_TYPE instance $INSTANCE
   SPEED=`/usr/sbin/ndd -get /dev/$INTERFACE_TYPE link_speed`
   case "$SPEED" in
      0) SPEED="10 Mbit/s" ;;
      1) SPEED="100 Mbit/s" ;;
      1000) SPEED="1 Gbit/s" ;;
      *) SPEED="Use "kstat $INTERFACE_TYPE" for speed and duplex information."
   esac
   DUPLEX=`/usr/sbin/ndd -get /dev/$INTERFACE_TYPE link_mode`
   case "$DUPLEX" in
      0) DUPLEX="half" ;;
      1) DUPLEX="full" ;;
      *) DUPLEX="" ;;
   esac
   /usr/bin/echo "$INTERFACE $SPEED $DUPLEX"
done

Example output:

Interface       Speed         & amp; nbsp; Duplex
---------       -----         & amp; nbsp; ------
hme0         &a mp;n bsp;  100 Mbit/s      full
hme1         &a mp;n bsp;  100 Mbit/s      full
hme2         &a mp;n bsp;  100 Mbit/s      full


Solaris often is unable to correctly auto-negotiate duplex settings with a link partner (e.g. switch), especially when a switch is set to 100Mbit full-duplex. You can force the NIC into 100Mbit full-duplex by disabling auto-negotiation and disabling 100Mbit half-duplex capability.

Example with hme0:

1. Make the changes to the running system.
ndd -set /dev/hme adv_100hdx_cap 0
ndd -set /dev/hme adv_100fdx_cap 1
ndd -set /dev/hme adv_autoneg_cap 0

2. Make kernel parameter changes to preserve the speed and duplex settings after a reboot.
vi /etc/system

Add:
set hme:hme_adv_autoneg_cap=0
set hme:hme_adv_100hdx_cap=0
set hme:hme_adv_100fdx_cap=1

Note: the /etc/system change affects all hme interfaces if multiple NICs are present (ex. hme0, hme1).

More information:

ce Ethernet adapters

Older versions of the Sun GigaSwift Ethernet 1.0 driver do not support the ndd link_mode and link_speed parameters. You may either install the latest Sun GigaSwift Ethernet adapter patch (111883) or you may use kstat ce ce_device to get speed and duplex information for "ce" Ethernet adapters.

-----

For example (from http://www.samag.com/documents/s=9142/sam0405l/0405l.htm):

netstat -k ce0 | egrep 'link_speed|link_status|link_duplex'

The output has the following meaning:

link_up - 0 down, 1 up
link_speed - speed in Mbit/s
link_duplex - 1 half duplex, 2 full duplex, 0 down

-----

The /etc/system settings listed above are not supported for configuring "ce" Ethernet adapters during system startup; you may either use ndd commands in an /etc/rc?.d script or create a /platform/sun4u/kernel/drv/ce.conf file detailed .

Example: /etc/init.d/nddconfig

#!/bin/sh


ndd -set /dev/ce instance 0
ndd -set /dev/ce adv_1000fdx_cap 0
ndd -set /dev/ce adv_1000hdx_cap 0
ndd -set /dev/ce adv_100fdx_cap 1
ndd -set /dev/ce adv_100hdx_cap 0
ndd -set /dev/ce adv_10fdx_cap 0
ndd -set /dev/ce adv_10hdx_cap 0
ndd -set /dev/ce adv_autoneg_cap 0

ln -s /etc/init.d/nddconfig /etc/rc2.d/S31nddconfig

dmesg | grep ce0
Jan 20 11:05:01 crmmdb22 genunix: [ID 611667 kern.info] NOTICE: ce0: xcvr addr:0x01 - link up 100 Mbps half duplex
Jan 20 11:05:15 crmmdb22 genunix: [ID 408822 kern.info] NOTICE: ce0: no fault external to device; service available
Jan 20 11:05:15 crmmdb22 genunix: [ID 611667 kern.info] NOTICE: ce0: xcvr addr:0x01 - link up 100 Mbps full duplex
阅读(917) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~